From 399a822fd7e34ef70f44f3b2beaacab743289344 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Thu, 26 Aug 2010 13:50:09 +0000 Subject: [PATCH] Fixes various issues with selecting: sectors and duplicating them many times in a row, sprites and then deleting some of them (also adds set union ['] and difference [;] to RSHIFT); adds the ability to move all selected sprites in the XY plane in 3d mode with SHIFT-LMB and align to the grid in an absolute fashion with CTRL. git-svn-id: https://svn.eduke32.com/eduke32@1701 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/build.c | 341 ++++++++++++++++-------------- polymer/eduke32/source/astub.c | 163 +++++++------- 2 files changed, 272 insertions(+), 232 deletions(-) diff --git a/polymer/eduke32/build/src/build.c b/polymer/eduke32/build/src/build.c index ad1778f7c..e0feffcde 100644 --- a/polymer/eduke32/build/src/build.c +++ b/polymer/eduke32/build/src/build.c @@ -1291,6 +1291,105 @@ static inline void drawline16base(int32_t bx, int32_t by, int32_t x1, int32_t y1 drawline16(bx+x1, by+y1, bx+x2, by+y2, col); } +static void duplicate_selected_sectors() +{ + int32_t i, j, startwall, endwall, newnumsectors, newwalls = 0; + + for (i=0; i= 0) + checksectorpointer(wall[j].nextwall,wall[j].nextsector); + checksectorpointer(j, highlightsector[i]); + } + + // Then, highlight the ones just copied. + // These will have all walls whited out. + highlightsector[i] = numsectors+i; + } + + numsectors = newnumsectors; + numwalls = newnumwalls; + + newnumwalls = -1; + newnumsectors = -1; + + updatenumsprites(); + printmessage16("Sectors duplicated and stamped."); + asksave = 1; + } + else + { + printmessage16("Copying sectors would exceed sector or wall limit."); + } +} + +static void duplicate_selected_sprites() +{ + int32_t i, j, k; + + if (highlightcnt + numsprites <= MAXSPRITES) + { + for (i=0; i>3]&(1<<(i&7))) + highlight[highlightcnt++] = i; + for (i=0; i>3]&(1<<(i&7))) + highlight[highlightcnt++] = i+16384; + } + else + show2dsprite[i>>3] &= ~(1<<(i&7)); + + if (highlightcnt == 0) + highlightcnt = -1; +} + void overheadeditor(void) { char buffer[80], *dabuffer, ch; @@ -1298,7 +1397,7 @@ void overheadeditor(void) int32_t tempint, tempint1, tempint2, doubvel; int32_t startwall=0, endwall, dax, day, x1, y1, x2, y2, x3, y3, x4, y4; int32_t highlightx1, highlighty1, highlightx2, highlighty2, xvect, yvect; - int16_t pag, suckwall=0, sucksect, /*newnumwalls,*/ newnumsectors, split=0, bad, goodtogo; + int16_t pag, suckwall=0, sucksect, split=0, bad, goodtogo; int16_t splitsect=0, danumwalls, secondstartwall, joinsector[2], joinsectnum; int16_t splitstartwall=0, splitendwall, loopnum; int32_t mousx, mousy, bstatus; @@ -1699,18 +1798,31 @@ void overheadeditor(void) drawline16(searchx,0, searchx,8, editorcolors[15]); drawline16(0,searchy, 8,searchy, editorcolors[15]); - col = 15-((gridlock<<1)+gridlock); + // draw mouse pointer + col = editorcolors[15 - 3*gridlock]; if (joinsector[0] >= 0) - col = 11; + col = editorcolors[11]; - drawline16base(searchx,searchy, +0,-8, +0,-1, editorcolors[col]); - drawline16base(searchx,searchy, +1,-8, +1,-1, editorcolors[col]); - drawline16base(searchx,searchy, +0,+2, +0,+9, editorcolors[col]); - drawline16base(searchx,searchy, +1,+2, +1,+9, editorcolors[col]); - drawline16base(searchx,searchy, -8,+0, -1,+0, editorcolors[col]); - drawline16base(searchx,searchy, -8,+1, -1,+1, editorcolors[col]); - drawline16base(searchx,searchy, +2,+0, +9,+0, editorcolors[col]); - drawline16base(searchx,searchy, +2,+1, +9,+1, editorcolors[col]); + if (keystatus[0x36] && !eitherCTRL) // RSHIFT + { + if (keystatus[0x27] || keystatus[0x28]) // ' and ; + { + col = editorcolors[14]; + + drawline16base(searchx+16, searchy-16, -4,0, +4,0, col); + if (keystatus[0x28]) + drawline16base(searchx+16, searchy-16, 0,-4, 0,+4, col); + } + } + + drawline16base(searchx,searchy, +0,-8, +0,-1, col); + drawline16base(searchx,searchy, +1,-8, +1,-1, col); + drawline16base(searchx,searchy, +0,+2, +0,+9, col); + drawline16base(searchx,searchy, +1,+2, +1,+9, col); + drawline16base(searchx,searchy, -8,+0, -1,+0, col); + drawline16base(searchx,searchy, -8,+1, -1,+1, col); + drawline16base(searchx,searchy, +2,+0, +9,+0, col); + drawline16base(searchx,searchy, +2,+1, +9,+1, col); //Draw the white pixel closest to mouse cursor on linehighlight if (linehighlight>=0) @@ -2235,7 +2347,9 @@ void overheadeditor(void) { if (highlightcnt == 0) { - highlightx2 = searchx, highlighty2 = searchy; + highlightx2 = searchx; + highlighty2 = searchy; + ydim16 = ydim-STATUS2DSIZ2; drawline16(highlightx2,highlighty1, highlightx1,highlighty1, editorcolors[5]); drawline16(highlightx2,highlighty2, highlightx1,highlighty2, editorcolors[5]); @@ -2245,13 +2359,11 @@ void overheadeditor(void) else { highlightcnt = 0; + highlightx1 = searchx; highlighty1 = searchy; highlightx2 = searchx; highlighty2 = searchx; - - Bmemset(show2dwall, 0, sizeof(show2dwall)); - Bmemset(show2dsprite, 0, sizeof(show2dsprite)); } } else @@ -2268,50 +2380,64 @@ void overheadeditor(void) if (eitherCTRL) { + Bmemset(show2dwall, 0, sizeof(show2dwall)); + Bmemset(show2dsprite, 0, sizeof(show2dsprite)); + if ((linehighlight >= 0) && (linehighlight < MAXWALLS)) { i = linehighlight; do { - highlight[highlightcnt++] = i; show2dwall[i>>3] |= (1<<(i&7)); for (j=0; j>3] |= (1<<(j&7)); - } i = wall[i].point2; } while (i != linehighlight); } + + update_highlight(); } else { - for (i=0; i= highlightx1 && wall[i].x <= highlightx2) - if (wall[i].y >= highlighty1 && wall[i].y <= highlighty2) - { - highlight[highlightcnt++] = i; - show2dwall[i>>3] |= (1<<(i&7)); - } - for (i=0; i= highlightx1 && sprite[i].x <= highlightx2) - if (sprite[i].y >= highlighty1 && sprite[i].y <= highlighty2) - { - highlight[highlightcnt++] = i+16384; - show2dsprite[i>>3] |= (1<<(i&7)); - } - } + int32_t add=keystatus[0x28], sub=(!add && keystatus[0x27]), setop=(add||sub); - if (highlightcnt <= 0) - highlightcnt = -1; + if (!setop) + { + Bmemset(show2dwall, 0, sizeof(show2dwall)); + Bmemset(show2dsprite, 0, sizeof(show2dsprite)); + } + + for (i=0; i= highlightx1 && wall[i].x <= highlightx2 && + wall[i].y >= highlighty1 && wall[i].y <= highlighty2) + { + if (!sub) + show2dwall[i>>3] |= (1<<(i&7)); + else if (sub) + show2dwall[i>>3] &= ~(1<<(i&7)); + } + + for (i=0; i= highlightx1 && sprite[i].x <= highlightx2 && + sprite[i].y >= highlighty1 && sprite[i].y <= highlighty2) + { + if (!sub) + show2dsprite[i>>3] |= (1<<(i&7)); + else + show2dsprite[i>>3] &= ~(1<<(i&7)); + } + + update_highlight(); + } } } } + if (highlightcnt < 0) { if (keystatus[0xb8]) //Right alt (sector highlighting) @@ -2327,7 +2453,7 @@ void overheadeditor(void) drawline16(highlightx2,highlighty2, highlightx2,highlighty1, editorcolors[10]); enddrawing(); //}}} } - if (highlightsectorcnt != 0) + else { for (i=0; i= 0) - { - newnumsectors = numsectors; - newnumwalls = numwalls; - for (i=0; i= 0) - checksectorpointer(wall[j].nextwall,wall[j].nextsector); - checksectorpointer((int16_t)j,highlightsector[i]); - } - highlightsector[i] = numsectors+i; - } - numsectors = newnumsectors; - numwalls = newnumwalls; - - newnumwalls = -1; - newnumsectors = -1; - - updatenumsprites(); - printmessage16("Sectors duplicated and stamped."); - asksave = 1; - } + duplicate_selected_sectors(); else if (highlightcnt >= 0) - { - for (i=0; i= 0) { @@ -3898,16 +3978,25 @@ SKIP: if (highlightsector[k] >= highlightsector[j]) highlightsector[k]--; } - printmessage16("Highlighted sectors deleted."); + newnumwalls = -1; - k = 1; highlightsectorcnt = -1; + + Bmemset(show2dwall, 0, sizeof(show2dwall)); + update_highlight(); + + printmessage16("Highlighted sectors deleted."); + k = 1; break; } if (k == 0) { deletesector((int16_t)i); highlightsectorcnt = -1; + + Bmemset(show2dwall, 0, sizeof(show2dwall)); + update_highlight(); + printmessage16("Sector deleted."); } newnumwalls = -1; @@ -3923,6 +4012,7 @@ SKIP: deletesprite(pointhighlight&16383); printmessage16("Sprite deleted."); updatenumsprites(); + update_highlight(); asksave = 1; } keystatus[0xd3] = 0; @@ -3931,72 +4021,9 @@ SKIP: if (keystatus[0xd2] || keystatus[0x17]) //InsertPoint { if (highlightsectorcnt >= 0) - { - int32_t newwalls = 0; - for (i=0; i= 0) - checksectorpointer(wall[j].nextwall,wall[j].nextsector); - checksectorpointer((int16_t)j,highlightsector[i]); - } - highlightsector[i] = numsectors+i; - } - numsectors = newnumsectors; - numwalls = newnumwalls; - - newnumwalls = -1; - newnumsectors = -1; - - updatenumsprites(); - printmessage16("Sectors duplicated and stamped."); - asksave = 1; - } - else - { - printmessage16("Copying sectors would exceed sector or wall limit."); - } - } + duplicate_selected_sectors(); else if (highlightcnt >= 0) - { - if (highlightcnt + numsprites <= MAXSPRITES) - { - for (i=0; i= 0) { int32_t wallsdrawn = newnumwalls-numwalls; @@ -6073,8 +6100,12 @@ void copysector(int16_t soursector, int16_t destsector, int16_t deststartwall, c wall[newnumwalls].point2 += deststartwall-startwall; if (wall[newnumwalls].nextwall >= 0) { - wall[newnumwalls].nextwall += deststartwall-startwall; - wall[newnumwalls].nextsector += destsector-soursector; + wall[newnumwalls].nextwall = -1; + wall[newnumwalls].nextsector = -1; + // the below code is incorrect in the general case since, in a set of + // selected sectors, the order may not be the same as the destination ones +// wall[newnumwalls].nextwall += deststartwall-startwall; +// wall[newnumwalls].nextsector += destsector-soursector; } newnumwalls++; } diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index 0ddd86a84..35322deb3 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -4237,6 +4237,89 @@ ERROR_NOMEMORY: lockclock = totalclock; //Reset timing } +static void mouseaction_movesprites(int32_t *sumxvect, int32_t *sumyvect, int32_t yangofs, int32_t mousexory) +{ + int32_t xvect,yvect, daxvect,dayvect, ii, spi; + int32_t units, gridlock = (eitherCTRL && grid > 0 && grid < 9); + spritetype *sp = &sprite[searchwall]; + int16_t tsect = sp->sectnum; + vec3_t tvec = { sp->x, sp->y, sp->z }; + + xvect = -((mousexory*(int32_t)sintable[(ang+yangofs+512)&2047])<<3); + yvect = -((mousexory*(int32_t)sintable[(ang+yangofs)&2047])<<3); + + if (gridlock) + { + units = 1<<(11-grid); + + if ((tvec.x & (units-1)) || (tvec.y & (units-1))) + { + daxvect = ((tvec.x & ~(units-1)) - tvec.x)<<14; + dayvect = ((tvec.y & ~(units-1)) - tvec.y)<<14; + } + else + { + units <<= 14; + + *sumxvect += xvect; + *sumyvect += yvect; + + if (klabs(*sumxvect) >= units) + { + daxvect = ((*sumxvect)/units)*units; + *sumxvect %= units; + } + else + daxvect = 0; + + if (klabs(*sumyvect) >= units) + { + dayvect = ((*sumyvect)/units)*units; + *sumyvect %= units; + } + else + dayvect = 0; + } + } + else + { + daxvect = xvect; + dayvect = yvect; + } + + if (highlightcnt<=0 || (show2dsprite[searchwall>>3] & (1<<(searchwall&7)))==0) + { + clipmove(&tvec, &tsect, daxvect,dayvect, 128,64<<4,64<<4, spnoclip?1:CLIPMASK0); + setsprite(searchwall, &tvec); + } + else + { + xvect = daxvect; + yvect = dayvect; + + for (ii=0; ii 0 && grid < 9); - - xvect = -((mousex*(int32_t)sintable[(ang+2048)&2047])<<3); - yvect = -((mousex*(int32_t)sintable[(ang+1536)&2047])<<3); - - if (gridlock) - { - units = (2048 >> grid) << 14; - sumxvect += xvect; - sumyvect += yvect; - if (klabs(sumxvect) >= units) - { - daxvect = (sumxvect/units)*units; - sumxvect %= units; - } - else - daxvect = 0; - - if (klabs(sumyvect) >= units) - { - dayvect = (sumyvect/units)*units; - sumyvect %= units; - } - else - dayvect = 0; - } - else - { - daxvect = xvect; - dayvect = yvect; - } - clipmove((vec3_t *)&sprite[searchwall], - &cursectnum,daxvect,dayvect,128L,4L<<8,4L<<8,spnoclip?1:CLIPMASK0); - setsprite(searchwall,(vec3_t *)&sprite[searchwall]); - } + mouseaction_movesprites(&sumxvect, &sumyvect, 1536, mousex); else { sumxvect = sumyvect = 0; @@ -6084,44 +6130,7 @@ static void Keys3d(void) static int32_t sumxvect=0, sumyvect=0; if (mouseaction==1) - { - int32_t xvect,yvect,daxvect,dayvect; - int16_t cursectnum=sprite[searchwall].sectnum; - int32_t units, gridlock = (eitherCTRL && grid > 0 && grid < 9); - - xvect = -((mousey*(int32_t)sintable[(ang+2560)&2047])<<3); - yvect = -((mousey*(int32_t)sintable[(ang+2048)&2047])<<3); - - if (gridlock) - { - units = (2048 >> grid) << 14; - sumxvect += xvect; - sumyvect += yvect; - if (klabs(sumxvect) >= units) - { - daxvect = (sumxvect/units)*units; - sumxvect %= units; - } - else - daxvect = 0; - - if (klabs(sumyvect) >= units) - { - dayvect = (sumyvect/units)*units; - sumyvect %= units; - } - else - dayvect = 0; - } - else - { - daxvect = xvect; - dayvect = yvect; - } - clipmove((vec3_t *)&sprite[searchwall], - &cursectnum,daxvect,dayvect,128L,4L<<8,4L<<8,spnoclip?1:CLIPMASK0); - setsprite(searchwall,(vec3_t *)&sprite[searchwall]); - } + mouseaction_movesprites(&sumxvect, &sumyvect, 2048, mousey); else { sumxvect = sumyvect = 0;