Commit b75488b4 authored by Richard Gobeille's avatar Richard Gobeille
Browse files

editor: block undo/redo during editing operations...

I am frankly amazed that it took years for this to ever become a problem.
parent ecb604e3
......@@ -58,6 +58,7 @@ extern int16_t searchsector, searchwall, searchstat; //search output
extern int16_t searchbottomwall, searchisbottom;
extern int32_t zmode, kensplayerheight, zlock;
extern int16_t newnumwalls, joinsector[2];
extern int16_t highlightsector[MAXSECTORS], highlightsectorcnt;
extern int16_t highlight[MAXWALLS+MAXSPRITES];
extern int16_t asksave;
......@@ -134,6 +135,18 @@ extern void M32_DrawRoomsAndMasks(void);
extern void yax_tweakpicnums(int32_t bunchnum, int32_t cf, int32_t restore); // editor-only
extern void M32_ResetFakeRORTiles(void);
//// Interactive Scaling
struct iscdata_t {
int8_t active, rotatep;
vec2_t piv; // pivot point
int32_t dragx, dragy; // dragged point
int32_t xsc, ysc, ang;
};
extern iscdata_t isc;
#define EDITING_MAP_P() (newnumwalls>=0 || joinsector[0]>=0 || circlewall>=0 || (bstatus&1) || isc.active)
// set to 1 to enable:
#define M32_UNDO 1
extern int32_t map_revision;
......
......@@ -2122,7 +2122,8 @@ static int32_t restore_highlighted_map(mapinfofull_t *mapinfo, int32_t forreal)
}
static int16_t newnumwalls=-1;
int16_t newnumwalls=-1;
int16_t joinsector[2];
void ovh_whiteoutgrab(int32_t restoreredwalls)
{
......@@ -3416,12 +3417,7 @@ static void draw_square(int32_t dax, int32_t day, int32_t ps, int32_t col)
}
//// Interactive Scaling
static struct {
int8_t active, rotatep;
vec2_t piv; // pivot point
int32_t dragx, dragy; // dragged point
int32_t xsc, ysc, ang;
} isc;
iscdata_t isc;
static void isc_transform(int32_t *x, int32_t *y)
{
......@@ -3480,8 +3476,6 @@ static void drawspritelabel(int i)
drawsmallabel(dabuffer, editorcolors[0], col, bordercol, s->x, s->y, s->z);
}
#define EDITING_MAP_P() (newnumwalls>=0 || joinsector[0]>=0 || circlewall>=0 || (bstatus&1) || isc.active)
#define HLMEMBERX(Hl, Member) (*(((Hl)&16384) ? &sprite[(Hl)&16383].Member : &wall[Hl].Member))
#define HLMEMBER(Hlidx, Member) HLMEMBERX(highlight[Hlidx], Member)
......@@ -3794,7 +3788,7 @@ void overheadeditor(void)
int32_t i, j, k, m=0, mousxplc=0, mousyplc=0, firstx=0, firsty=0, oposz, col;
int32_t numwalls_bak;
int32_t startwall=0, endwall, dax, day, x1, y1, x2, y2, x3, y3; //, x4, y4;
int16_t bad, joinsector[2];
int16_t bad;
int32_t bstatus, mousewaitmask=0;
int16_t circlepoints;
int32_t sectorhighlightx=0, sectorhighlighty=0;
......@@ -8477,14 +8471,20 @@ CANCEL:
else if (ch == 'u' || ch == 'U')
{
bad = 0;
if (map_undoredo(0)) printmessage16("Nothing to undo!");
else printmessage16("Revision %d undone",map_revision);
if (!EDITING_MAP_P())
{
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);
if (!EDITING_MAP_P())
{
if (map_undoredo(1)) printmessage16("Nothing to redo!");
else printmessage16("Restored revision %d", map_revision - 1);
}
}
#endif
else if (ch == 'q' || ch == 'Q') //Q
......
......@@ -10854,7 +10854,7 @@ static void Keys2d3d(void)
if (PRESSED_KEYSC(P)) // Ctrl-P: Map playtesting
test_map(eitherALT);
if (PRESSED_KEYSC(Z)) // CTRL+Z
if (!EDITING_MAP_P() && PRESSED_KEYSC(Z)) // CTRL+Z
{
if (!in3dmode() || m32_3dundo)
{
......
......@@ -503,7 +503,8 @@ void map_undoredo_free(void)
int32_t map_undoredo(int dir)
{
if (mapstate == NULL) return 1;
auto bstatus = mouseReadButtons();
if (mapstate == NULL || EDITING_MAP_P()) return 1;
auto const which = dir ? mapstate->next : mapstate->prev;
if (which == NULL || !which->num[UNDO_SECTORS]) return 1;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment