undo/redo with editmeta pressed also restores player position

also selects the affected area
(less useful in coopedit because always the own position is restored)

for testers: editmeta still defaults to LCTRL
This commit is contained in:
ac-stef
2014-05-15 13:48:31 +02:00
parent aaf01e8b2a
commit 832e46141b
2 changed files with 30 additions and 4 deletions
+29 -3
View File
@@ -25,6 +25,9 @@ sqr rtex;
VAR(editing, 1, 0, 0);
bool editmetakeydown = false;
COMMANDF(editmeta, "d", (bool on) { editmetakeydown = on; } );
void toggleedit(bool force)
{
if(player1->state==CS_DEAD) return; // do not allow dead players to edit to avoid state confusion
@@ -308,18 +311,43 @@ void pruneundos(int maxremain) // bound memory
}
}
void storeposition(short p[])
{
loopi(3) p[i] = player1->o.v[i] * DMF;
p[3] = player1->yaw;
p[4] = player1->pitch;
}
void makeundo(block &sel)
{
storeposition(sel.p);
undos.add(blockcopy(sel));
pruneundos(undomegs<<20);
}
void restoreposition(short p[])
{
loopi(3) player1->o.v[i] = float(p[i]) / DMF;
player1->yaw = p[3];
player1->pitch = p[4];
player1->resetinterp();
}
void restoreposition(block &sel)
{
restoreposition(sel.p);
resetselections();
addselection(sel.x, sel.y, sel.xs, sel.ys, sel.h); // select undone area
checkselections();
}
void editundo()
{
EDITMP;
if(undos.empty()) { conoutf("nothing more to undo"); return; }
block *p = undos.pop();
redos.add(blockcopy(*p));
if(editmetakeydown) restoreposition(*p);
blockpaste(*p);
freeblock(p);
}
@@ -330,6 +358,7 @@ void editredo()
if(redos.empty()) { conoutf("nothing more to redo"); return; }
block *p = redos.pop();
undos.add(blockcopy(*p));
if(editmetakeydown) restoreposition(*p);
blockpaste(*p);
freeblock(p);
}
@@ -411,9 +440,6 @@ void tofronttex() // maintain most recentl
}
}
bool editmetakeydown = false;
COMMANDF(editmeta, "d", (bool on) { editmetakeydown = on; } );
void editdrag(bool isdown)
{
if((dragging = isdown))