1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-08 06:59:55 +00:00

generalized show_turns to menu_format

This commit is contained in:
Zeno Rogue 2024-05-28 15:09:00 +02:00
parent a9d6def718
commit 99bc842c57
3 changed files with 41 additions and 6 deletions

View File

@ -1160,8 +1160,9 @@ EX void initConfig() {
param_i(min_cells_drawn, "min_cells_drawn");
param_b(show_turns, "show_turns", false)
-> editable("show turn count", 'T');
param_str(menu_format, "menu_format", "")
->editable("menu format", "programmable menu key", 'T')
->set_standard_editor();
param_i(menu_darkening, "menu_darkening", 2)
-> editable(0, 8, 1, "menu map darkening", "A larger number means darker game map in the background. Set to 8 to disable the background.", 'd')
-> set_sets([] { dialog::bound_low(0); dialog::bound_up(8); dialog::get_di().dialogflags |= sm::DARKEN; });
@ -2439,7 +2440,7 @@ EX void configureInterface() {
};
});
add_edit(show_turns);
add_edit(menu_format);
add_edit(menu_darkening);
add_edit(centered_menus);
add_edit(startanims::enabled);

View File

@ -5673,7 +5673,8 @@ EX bool just_refreshing;
EX int menu_darkening = 2;
EX bool centered_menus = false;
EX bool show_turns = false;
EX string menu_format = "";
EX void gamescreen() {
@ -5800,8 +5801,8 @@ EX void normalscreen() {
cmode = sm::NORMAL | sm::DOTOUR | sm::CENTER;
if(viewdists && show_distance_lists) cmode |= sm::SIDE | sm::MAYDARK;
gamescreen(); drawStats();
if(show_turns)
displayButton(vid.xres-8, vid.yres-vid.fsize, "t:" + its(turncount), 'v', 16);
if(menu_format != "")
displayButton(vid.xres-8, vid.yres-vid.fsize, eval_programmable_string(menu_format), 'v', 16);
else if(nomenukey || ISMOBILE)
;
#if CAP_TOUR

View File

@ -1029,6 +1029,39 @@ EX string read_file_as_string(string fname) {
return buf;
}
EX string eval_programmable_string(const string& fmt) {
try {
exp_parser ep;
ep.s = fmt;
string out;
while(ep.at < (int) fmt.size()) {
if(ep.eat("$(")) {
auto res = ep.parse();
if(ep.eat(",")) {
int prec = ep.iparse();
std::stringstream str;
str.precision(prec);
str << std::fixed;
if(prec) str << std::showpoint;
str << real(res);
if(imag(res)) str << "+i" << imag(res);
out += str.str();
}
else {
out += fts(real(res));
if(imag(res)) out += "+i" + fts(imag(res));
}
ep.force_eat(")");
}
else out += ep.eatchar();
}
return out;
}
catch(hr_parse_exception& ex) {
return fmt;
}
}
EX void floyd_warshall(vector<vector<char>>& v) {
int N = isize(v);
for(int k=0; k<N; k++)