diff --git a/debug.cpp b/debug.cpp index 4dc8530a..2f61e610 100644 --- a/debug.cpp +++ b/debug.cpp @@ -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); } diff --git a/history.cpp b/history.cpp index 80bfc4a1..b7bf4ae1 100644 --- a/history.cpp +++ b/history.cpp @@ -180,6 +180,41 @@ EX namespace history { EX ld lvspeed = 1; 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; @@ -195,6 +230,37 @@ EX namespace history { for(int i=0; ibase, 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) { @@ -223,35 +289,8 @@ EX namespace history { v.back()->at = last; - int Q = isize(v)-1; - // virtualRebase(v[0], false); - // virtualRebase(v[Q], false); + smoothen_line(); - for(int i=0; i<1000; i++) { - progress(XLAT("Preparing the line (%1/1000)...", its(i+1))); - - for(int j=1; jbase, 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); - 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; }); diff --git a/hypgraph.cpp b/hypgraph.cpp index 1855ed0e..d922aba8 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -1476,7 +1476,8 @@ EX void panning(hyperpoint hf, hyperpoint ht) { EX int cells_drawn, cells_generated; EX void fullcenter() { - history::path_for_lineanimation.clear(); + if(history::saved_ends == 0) + history::path_for_lineanimation.clear(); if(playerfound && false) centerpc(INF); else { bfs();