1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-27 14:37:16 +00:00

nilrider:: saving/viewing goals

This commit is contained in:
Zeno Rogue 2022-05-06 16:49:37 +02:00
parent 09266b3059
commit bc8811530f
6 changed files with 63 additions and 7 deletions

View File

@ -110,6 +110,9 @@ void level::init() {
/* start facing slightly to the right from the slope */
for(auto b: {true, false}) while(true) {
auto c = start;
/* no treasures are known, which confuses goals */
dynamicval<bool> lop1(loaded_or_planned, true);
dynamicval<bool> lop2(planning_mode, false);
if(c.tick(this) == b) break;
start.heading_angle -= 1 * degree;
}

View File

@ -275,9 +275,29 @@ void pick_game() {
dialog::init(XLAT("how do you want to play?"), 0xC0C0FFFF, 150, 100);
dialog::addSelItem("selected track", curlev->name, 't');
dialog::add_action_push(pick_level);
dialog::addInfo(curlev->longdesc);
dialog::addBreak(50);
dialog::addHelp(curlev->longdesc);
dialog::addBreak(100);
add_edit(planning_mode);
int gid = 0;
for(auto& g: curlev->goals) {
dialog::addBreak(50);
auto man = curlev->records[0][gid];
auto plan = curlev->records[1][gid];
if(man && plan)
dialog::addInfo("manual: " + format_timer(man) + " planning: " + format_timer(plan), g.color);
else if(man)
dialog::addInfo("manual: " + format_timer(man), g.color);
else if(plan)
dialog::addInfo("planning: " + format_timer(plan), g.color);
else
dialog::addInfo("goal not obtained:", g.color);
dialog::addBreak(50);
dialog::addHelp(g.desc);
gid++;
}
dialog::addBreak(100);
dialog::addBack();
dialog::display();
@ -425,10 +445,10 @@ void main_menu() {
dialog::add_action(pop_and_push_replays);
}
dialog::addItem("change track or game settings", 't');
dialog::addItem("track / mode / goals", 't');
dialog::add_action_push(pick_game);
dialog::addItem("change other settings", 'o');
dialog::addItem("change settings", 'o');
dialog::add_action_push(settings);
dialog::addItem("quit", 'q');

View File

@ -202,4 +202,6 @@ hyperpoint sym_to_heis(hyperpoint H);
extern int reversals;
extern bool loaded_or_planned;
extern bool planning_mode;
void save();
}

View File

@ -14,6 +14,17 @@ void save() {
println(hlog, "save called");
fhstream f("nilrider.save", "wt");
println(f, "NilRider version ", ver);
for(auto l: all_levels) {
for(int i: {0,1}) {
int qg = isize(l->records[i]);
for(int g=0; g<qg; g++)
if(l->records[i][g]) {
println(f, "*RECORD");
println(f, l->name);
println(f, format("%d %d %f", i, g, l->records[i][g]));
}
}
}
for(auto l: all_levels) {
for(auto& p: l->manual_replays) {
println(f, "*MANUAL");
@ -71,8 +82,22 @@ void load() {
if(l) l->plan_replays.emplace_back(plan_replay{name, std::move(plan)});
continue;
}
if(s == "*RECORD") {
string lev = scanline_noblank(f);
int i = scan<int>(f);
int g = scan<int>(f);
ld t = scan<ld>(f);
auto l = level_by_name(lev);
if(l) {
int qg = isize(l->goals);
if(i < 0 || i > 1) println(hlog, "error: wrong number as i");
if(g < 0 || g >= qg) println(hlog, "error: wrong goal index");
l->records[i].resize(qg, 0);
l->records[i][g] = t;
}
println(hlog, "error: unknown content ", s);
}
}
}
}

View File

@ -68,6 +68,7 @@ void level::solve() {
ts.where = point0;
ts.collected_triangles = v.collected;
ts.timer = 0;
loaded_or_planned = true;
ts.collect(this);
checkerparam p {&ts, this, 0};
auto res = goals[goal_id].check(p);

View File

@ -98,9 +98,14 @@ bool timestamp::collect(level *lev) {
else if(res == grSuccess) {
goals |= Flag(gid);
lev->current_score[gid] = timer;
if(planning_mode || !loaded_or_planned) {
auto &res = lev->records[planning_mode][gid];
if(res == 0 || timer < res)
if(res == 0 || timer < res) {
res = timer;
println(hlog, "saved -- success on goal ", gid, " in time ", timer);
save();
}
}
}
gid++;
}