mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-02-09 07:30:09 +00:00
nilrider: improved saved replays/plans menu, can rename
This commit is contained in:
parent
7996dd4aba
commit
2cff14a23c
@ -421,26 +421,46 @@ void settings() {
|
|||||||
dialog::display();
|
dialog::display();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool deleting = false;
|
|
||||||
|
|
||||||
template<class T, class U> void replays_of_type(vector<T>& v, const U& loader) {
|
template<class T, class U> void replays_of_type(vector<T>& v, const U& loader) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(auto& r: v) {
|
for(auto& r: v) {
|
||||||
dialog::addItem(r.name, 'a');
|
dialog::addItem(r.name, 'a');
|
||||||
dialog::add_action([&v, i, loader] {
|
dialog::add_action([&v, i, loader] {
|
||||||
if(deleting) {
|
pushScreen([&v, i, loader] {
|
||||||
dialog::push_confirm_dialog(
|
dialog::init(XLAT(planning_mode ? "saved plan" : "replay"), 0xC0C0FFFF, 150, 100);
|
||||||
[&, i] { v.erase(v.begin() + i); save(); },
|
dialog::addInfo(v[i].name);
|
||||||
"Are you sure you want to delete '" + v[i].name + "'?"
|
|
||||||
);
|
dialog::addItem(planning_mode ? "load plan" : "load replay", 'l');
|
||||||
}
|
dialog::add_action([&v, i, loader] { popScreen(); loader(v[i]); });
|
||||||
else loader(v[i]);
|
|
||||||
|
dialog::addItem(planning_mode ? "load plan as ghost" : "load replay as ghost", 'g');
|
||||||
|
dialog::add_action([] { popScreen(); println(hlog, "not implemented"); });
|
||||||
|
|
||||||
|
dialog::addItem("rename", 'r');
|
||||||
|
dialog::add_action([&v, i] {
|
||||||
|
popScreen();
|
||||||
|
dialog::edit_string(v[i].name, planning_mode ? "name plan" : "name replay", "");
|
||||||
|
dialog::get_di().reaction_final = [] { save(); };
|
||||||
|
});
|
||||||
|
|
||||||
|
dialog::addItem("delete", 'd');
|
||||||
|
dialog::add_action([&v, i] {
|
||||||
|
popScreen();
|
||||||
|
dialog::push_confirm_dialog(
|
||||||
|
[&v, i] { v.erase(v.begin() + i); save(); },
|
||||||
|
"Are you sure you want to delete '" + v[i].name + "'?"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
dialog::display();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CAP_SAVE
|
#if CAP_SAVE
|
||||||
|
|
||||||
void replays() {
|
void replays() {
|
||||||
dialog::init(XLAT(planning_mode ? "saved plans" : "replays"), 0xC0C0FFFF, 150, 100);
|
dialog::init(XLAT(planning_mode ? "saved plans" : "replays"), 0xC0C0FFFF, 150, 100);
|
||||||
if(!planning_mode) replays_of_type(curlev->manual_replays, [] (manual_replay& r) {
|
if(!planning_mode) replays_of_type(curlev->manual_replays, [] (manual_replay& r) {
|
||||||
@ -463,13 +483,11 @@ void replays() {
|
|||||||
curlev->plan = r.plan;
|
curlev->plan = r.plan;
|
||||||
popScreen();
|
popScreen();
|
||||||
});
|
});
|
||||||
dialog::addBoolItem_action("delete", deleting, 'X');
|
|
||||||
dialog::addBack();
|
dialog::addBack();
|
||||||
dialog::display();
|
dialog::display();
|
||||||
}
|
}
|
||||||
|
|
||||||
void pop_and_push_replays() {
|
void pop_and_push_replays() {
|
||||||
deleting = false;
|
|
||||||
popScreen();
|
popScreen();
|
||||||
pushScreen(replays);
|
pushScreen(replays);
|
||||||
}
|
}
|
||||||
@ -508,7 +526,7 @@ void main_menu() {
|
|||||||
save();
|
save();
|
||||||
});
|
});
|
||||||
|
|
||||||
dialog::addItem("load a replay", 'l');
|
dialog::addItem("saved replays", 'l');
|
||||||
dialog::add_action(pop_and_push_replays);
|
dialog::add_action(pop_and_push_replays);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -520,7 +538,7 @@ void main_menu() {
|
|||||||
save();
|
save();
|
||||||
});
|
});
|
||||||
|
|
||||||
dialog::addItem("load a plan", 'l');
|
dialog::addItem("saved plans", 'l');
|
||||||
dialog::add_action(pop_and_push_replays);
|
dialog::add_action(pop_and_push_replays);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user