1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-06-29 08:33:25 +00:00

nilrider:: loaded_or_planned flag

This commit is contained in:
Zeno Rogue 2022-05-06 12:56:08 +02:00
parent b0587572ae
commit 0dace6f3c2
4 changed files with 20 additions and 4 deletions

View File

@ -21,6 +21,7 @@ ld aimspeed_key_x = 1, aimspeed_key_y = 1, aimspeed_mouse_x = 1, aimspeed_mouse_
vector<string> move_names = { "camera down", "move left", "camera up", "move right", "fine control", "pause", "reverse time", "view simulation", "menu" }; vector<string> move_names = { "camera down", "move left", "camera up", "move right", "fine control", "pause", "reverse time", "view simulation", "menu" };
int reversals = 0; int reversals = 0;
bool loaded_or_planned = false;
void frame() { void frame() {
if(planning_mode && !view_replay) return; if(planning_mode && !view_replay) return;
@ -74,6 +75,7 @@ bool turn(int delta) {
} }
else { else {
reversals = 0; reversals = 0;
loaded_or_planned = false;
timer = 0; timer = 0;
} }
} }
@ -187,6 +189,16 @@ void run() {
}; };
} }
void clear_path(level *l) {
l->history.clear();
l->current = l->start;
l->history.push_back(l->start);
timer = 0;
paused = false;
reversals = 0;
loaded_or_planned = false;
}
void pick_level() { void pick_level() {
clearMessages(); clearMessages();
dialog::init(XLAT("select the track"), 0xC0C0FFFF, 150, 100); dialog::init(XLAT("select the track"), 0xC0C0FFFF, 150, 100);
@ -196,6 +208,7 @@ void pick_level() {
curlev = l; curlev = l;
recompute_plan_transform = true; recompute_plan_transform = true;
l->init(); l->init();
clear_path(l);
popScreen(); popScreen();
}); });
} }
@ -292,6 +305,7 @@ void replays() {
curlev->history.clear(); curlev->history.clear();
auto& current = curlev->current; auto& current = curlev->current;
current = curlev->start; current = curlev->start;
loaded_or_planned = true;
for(auto h: r.headings) { for(auto h: r.headings) {
current.heading_angle = int_to_heading(h); current.heading_angle = int_to_heading(h);
curlev->history.push_back(current); curlev->history.push_back(current);
@ -329,9 +343,7 @@ void main_menu() {
if(!planning_mode) { if(!planning_mode) {
dialog::addItem("restart", 'r'); dialog::addItem("restart", 'r');
dialog::add_action([] { dialog::add_action([] {
curlev->current = curlev->start; clear_path(curlev);
timer = 0;
paused = false;
popScreen(); popScreen();
}); });

View File

@ -197,5 +197,6 @@ extern map<char, array<string, 16> > submaps;
hyperpoint sym_to_heis(hyperpoint H); hyperpoint sym_to_heis(hyperpoint H);
extern int reversals; extern int reversals;
extern bool loaded_or_planned;
} }

View File

@ -3,6 +3,7 @@ namespace nilrider {
hyperpoint get_spline(ld t); hyperpoint get_spline(ld t);
bool level::simulate() { bool level::simulate() {
loaded_or_planned = true;
if(history.empty()) if(history.empty())
history.push_back(start); history.push_back(start);
auto at = history.back(); auto at = history.back();

View File

@ -324,7 +324,9 @@ void timestamp::draw_instruments(level* l, ld t) {
string s = format("%d:%02d.%02d", int(t / 60), int(t) % 60, int(frac(t) * 100)); string s = format("%d:%02d.%02d", int(t / 60), int(t) % 60, int(frac(t) * 100));
displaystr(vid.xres - vid.fsize, vid.fsize*2, 0, vid.fsize * 2, s, 0, 16); displaystr(vid.xres - vid.fsize, vid.fsize*2, 0, vid.fsize * 2, s, 0, 16);
if(reversals) s = format("+%d", reversals); if(loaded_or_planned) s = "R";
else if(reversals) s = format("+%d", reversals);
else return;
displaystr(vid.xres - vid.fsize, vid.fsize*4, 0, vid.fsize, s, 0, 16); displaystr(vid.xres - vid.fsize, vid.fsize*4, 0, vid.fsize, s, 0, 16);
} }