1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-23 21:07:17 +00:00

history:: specifically mark starting position

This commit is contained in:
Zeno Rogue 2020-04-01 11:26:19 +02:00
parent fee3734c6b
commit e53f61a8be
3 changed files with 80 additions and 29 deletions

View File

@ -567,6 +567,7 @@ void cheat_move(char c) {
else if(c == 'm') cheat(), cwt += wmirror;
else if(c == 'z') cheat(), cwt.spin = 0, cwt.mirrored = false;
else if(c == 'F') fullcenter();
else if(c == 'a') cheat(), history::save_end();
else println(hlog, "unknown move command: ", c);
}

View File

@ -181,6 +181,41 @@ EX namespace history {
EX int bandhalf = 200;
EX int bandsegment = 16000;
EX int saved_ends;
EX cell* first_center_at;
EX transmatrix first_center_view;
EX void save_end() {
if(canmove && !cheater) {
addMessage("Enable cheat mode or GAME OVER to use this");
return;
}
if(canmove && cheater) cheater++;
switch(saved_ends) {
case 0:
first_center_at = centerover;
first_center_view = View;
saved_ends = 1;
return;
case 1: {
shmup::monster *m = new shmup::monster;
m->at = inverse(first_center_view);
m->base = first_center_at;
v.push_back(m);
create(first_center_at, centerover, inverse(ggmatrix(centerover)));
if(on) saved_ends = 2;
return;
}
case 2:
on = false;
saved_ends = 0;
return;
}
}
EX bool autoband = false;
EX bool autobandhistory = false;
EX bool dospiral = true;
@ -196,6 +231,37 @@ EX namespace history {
v.resize(0);
}
EX void smoothen_line() {
int Q = isize(v)-1;
// virtualRebase(v[0], false);
// virtualRebase(v[Q], false);
for(int i=0; i<1000; i++) {
progress(XLAT("Preparing the line (%1/1000)...", its(i+1)));
for(int j=1; j<Q; j++) if((j^i)&1) {
// virtualRebase(v[j], false);
hyperpoint prev = calc_relative_matrix(v[j-1]->base, v[j]->base, C0) *
v[j-1]->at * C0;
hyperpoint next = calc_relative_matrix(v[j+1]->base, v[j]->base, C0) *
v[j+1]->at * C0;
hyperpoint hmid = mid(prev, next);
transmatrix at = rgpushxto0(hmid);
v[j]->at = at * rspintox(inverse(at) * next);
fixmatrix(v[j]->at);
}
}
hyperpoint next0 = calc_relative_matrix(v[1]->base, v[0]->base, C0) * v[1]->at * C0;
v[0]->at = v[0]->at * rspintox(inverse(v[0]->at) * next0);
}
EX void create(cell *start, cell *target, transmatrix last) {
if(target == start && !(quotient && isize(path_for_lineanimation) > 1)) {
@ -223,34 +289,7 @@ EX namespace history {
v.back()->at = last;
int Q = isize(v)-1;
// virtualRebase(v[0], false);
// virtualRebase(v[Q], false);
for(int i=0; i<1000; i++) {
progress(XLAT("Preparing the line (%1/1000)...", its(i+1)));
for(int j=1; j<Q; j++) if((j^i)&1) {
// virtualRebase(v[j], false);
hyperpoint prev = calc_relative_matrix(v[j-1]->base, v[j]->base, C0) *
v[j-1]->at * C0;
hyperpoint next = calc_relative_matrix(v[j+1]->base, v[j]->base, C0) *
v[j+1]->at * C0;
hyperpoint hmid = mid(prev, next);
transmatrix at = rgpushxto0(hmid);
v[j]->at = at * rspintox(inverse(at) * next);
fixmatrix(v[j]->at);
}
}
hyperpoint next0 = calc_relative_matrix(v[1]->base, v[0]->base, C0) * v[1]->at * C0;
v[0]->at = v[0]->at * rspintox(inverse(v[0]->at) * next0);
smoothen_line();
llv = ticks;
phase = 0;
@ -494,6 +533,15 @@ EX namespace history {
dialog::addBoolItem(XLAT("animate from start to current player position"), (on), 'e');
dialog::addBoolItem(XLAT("animate from last recenter to current view"), (on), 'E');
dialog::addBoolItem(XLAT("animate from last recenter to precise current view"), (on), 'E'-64);
if(saved_ends == 0)
dialog::addItem(XLAT("save the animation starting point"), '1');
else if(saved_ends == 1)
dialog::addItem(XLAT("animate from the starting point"), '1');
else
dialog::addItem(XLAT("reset animation"), '1');
dialog::add_action(save_end);
if(on) dialog::addSelItem(XLAT("animation speed"), fts(lvspeed), 'a');
else dialog::addBreak(100);
dialog::addSelItem(XLAT("extend the ends"), fts(extra_line_steps), 'p');
@ -648,6 +696,7 @@ EX namespace history {
history::findhistory.clear();
history::movehistory.clear();
history::path_for_lineanimation.clear();
history::saved_ends = 0;
history::includeHistory = false;
});

View File

@ -1476,6 +1476,7 @@ EX void panning(hyperpoint hf, hyperpoint ht) {
EX int cells_drawn, cells_generated;
EX void fullcenter() {
if(history::saved_ends == 0)
history::path_for_lineanimation.clear();
if(playerfound && false) centerpc(INF);
else {