From e47b890189ac4f43db51926a2dc0e1325b5b0ce2 Mon Sep 17 00:00:00 2001 From: terminx Date: Tue, 5 May 2009 21:25:06 +0000 Subject: [PATCH] undo improvements git-svn-id: https://svn.eduke32.com/eduke32@1363 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/build.c | 16 +++++++-- polymer/eduke32/source/astub.c | 59 ++++++++++--------------------- 2 files changed, 32 insertions(+), 43 deletions(-) diff --git a/polymer/eduke32/build/src/build.c b/polymer/eduke32/build/src/build.c index c6dc550e1..bb757840d 100644 --- a/polymer/eduke32/build/src/build.c +++ b/polymer/eduke32/build/src/build.c @@ -218,6 +218,7 @@ int32_t getfilenames(char *path, char *kind); void clearfilenames(void); void loadmhk(); extern int32_t map_revision; +extern int32_t map_undoredo(int32_t dir); void clearkeys(void) { memset(keystatus,0,sizeof(keystatus)); } @@ -4148,8 +4149,7 @@ CANCEL: if (keystatus[1]) { keystatus[1] = 0; - _printmessage16("(N)ew, (L)oad, (S)ave, save (A)s, (T)est map, (Q)uit"); -// printext16(200L+248, ydim-STATUS2DSIZ+20L, 9, 0, "(U)ndo, (R)edo", 0); + _printmessage16("(N)ew, (L)oad, (S)ave, save (A)s, (T)est map, (U)ndo, (R)edo, (Q)uit"); showframe(1); bflushchars(); bad = 1; @@ -4511,6 +4511,18 @@ CANCEL: { test_map(0); } + else if (ch == 'u' || ch == 'U') + { + bad = 0; + if (map_undoredo(0)) printmessage16("Nothing to undo!"); + else printmessage16("Revision %d undone",map_revision); + } + else if (ch == 'r' || ch == 'R') + { + bad = 0; + if (map_undoredo(1)) printmessage16("Nothing to redo!"); + else printmessage16("Restored revision %d",map_revision-1); + } else if (ch == 'q' || ch == 'Q') //Q { bad = 0; diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index 805e8242f..f24e8c27a 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -253,48 +253,24 @@ void create_map_snapshot(void) mapstate = mapstate->next; } -int32_t map_undo(void) +int32_t map_undoredo(int32_t dir) { int32_t i; - if (mapstate == NULL || mapstate->prev == NULL || !mapstate->prev->numsectors) return 1; - - mapstate = mapstate->prev; - - numsectors = mapstate->numsectors; - numwalls = mapstate->numwalls; - numsprites = mapstate->numsprites; - - initspritelists(); - - lzf_decompress(&mapstate->sectors[0], mapstate->sectsiz, §or[0], sizeof(sectortype) * numsectors); - lzf_decompress(&mapstate->walls[0], mapstate->wallsiz, &wall[0], sizeof(walltype) * numwalls); - lzf_decompress(&mapstate->sprites[0], mapstate->spritesiz, &sprite[0], sizeof(spritetype) * numsprites); - - updatenumsprites(); - - for (i=0; inext == NULL || !mapstate->next->numsectors) return 1; + + while (map_revision+1 != mapstate->revision) + mapstate = mapstate->next; } + else + { + if (mapstate == NULL || mapstate->prev == NULL || !mapstate->prev->numsectors) return 1; - map_revision = mapstate->revision; - -#ifdef POLYMER - if (qsetmode == 200 && rendmode == 4) - polymer_loadboard(); -#endif - return 0; -} - -int32_t map_redo(void) -{ - int32_t i; - - if (mapstate == NULL || mapstate->next == NULL || !mapstate->next->numsectors) return 1; - - mapstate = mapstate->next; + while (map_revision-1 != mapstate->revision) + mapstate = mapstate->prev; + } numsectors = mapstate->numsectors; numwalls = mapstate->numwalls; @@ -9845,7 +9821,6 @@ void ExtPreCheckKeys(void) // just before drawrooms if (qsetmode == 200) //In 3D mode { - if (shadepreview) { int32_t i = 0; @@ -10023,6 +9998,8 @@ void ExtPreCheckKeys(void) // just before drawrooms xp1 += halfxdim16; yp1 += midydim16; + ydim16 = ydim-STATUS2DSIZ2; + if (xp1 < 4 || xp1 > xdim-6 || yp1 < 4 || yp1 > ydim16-6) continue; rotatesprite(xp1<<16,yp1<<16,zoom<<5,ang,picnum, @@ -10315,13 +10292,13 @@ static void Keys2d3d(void) keystatus[KEYSC_Z] = 0; if (eitherSHIFT) { - if (map_redo()) message("Nothing to redo!"); - else message("Restored undo rev %d",map_revision-1); + if (map_undoredo(1)) message("Nothing to redo!"); + else message("Restored revision %d",map_revision-1); } else { - if (map_undo()) message("Nothing to undo!"); - else message("Restored undo rev %d",map_revision-1); + if (map_undoredo(0)) printmessage16("Nothing to undo!"); + else message("Revision %d undone",map_revision); } }