1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-25 01:20:37 +00:00

arg:: most important dialogs can be launched from command line

This commit is contained in:
Zeno Rogue 2018-11-11 11:06:32 +01:00
parent 01dc4997dc
commit 7b4028418e
10 changed files with 153 additions and 37 deletions

View File

@ -754,6 +754,8 @@ void archimedean_tiling::parse() {
} }
#if CAP_COMMANDLINE #if CAP_COMMANDLINE
void show();
int readArgs() { int readArgs() {
using namespace arg; using namespace arg;
@ -774,6 +776,8 @@ int readArgs() {
} }
else if(argis("-dgeom")) debug_geometry = true; else if(argis("-dgeom")) debug_geometry = true;
else if(argis("-dual")) { PHASEFROM(2); set_variation(eVariation::dual); } else if(argis("-dual")) { PHASEFROM(2); set_variation(eVariation::dual); }
else if(argis("-d:arcm"))
launch_dialog(show);
else return 1; else return 1;
return 0; return 0;
} }

View File

@ -79,7 +79,19 @@ namespace arg {
exit(1); exit(1);
} }
bool dialog_launched = false;
void launch_dialog(const reaction_t& r) {
if(!dialog_launched) {
popScreenAll();
showstartmenu = false;
dialog_launched = true;
} }
if(r) pushScreen(r);
}
}
int arg::readCommon() { int arg::readCommon() {

View File

@ -1655,12 +1655,10 @@ void selectLanguageScreen() {
#if CAP_COMMANDLINE #if CAP_COMMANDLINE
int read_config_args() { int read_color_args() {
using namespace arg; using namespace arg;
if(argis("-c")) { PHASE(1); shift(); conffile = argcs(); } if(argis("-back")) {
// change the configuration from the command line
else if(argis("-back")) {
PHASEFROM(2); shift(); backcolor = arghex(); PHASEFROM(2); shift(); backcolor = arghex();
} }
else if(argis("-fillmodel")) { else if(argis("-fillmodel")) {
@ -1681,6 +1679,17 @@ int read_config_args() {
else if(argis("-dialog")) { else if(argis("-dialog")) {
PHASEFROM(2); shift(); dialog::dialogcolor = arghex(); PHASEFROM(2); shift(); dialog::dialogcolor = arghex();
} }
else if(argis("-d:color"))
launch_dialog(show_color_dialog);
else return 1;
return 0;
}
int read_config_args() {
using namespace arg;
if(argis("-c")) { PHASE(1); shift(); conffile = argcs(); }
// change the configuration from the command line
else if(argis("-aa")) { PHASEFROM(2); shift(); vid.antialias = argi(); } else if(argis("-aa")) { PHASEFROM(2); shift(); vid.antialias = argi(); }
else if(argis("-lw")) { PHASEFROM(2); shift_arg_formula(vid.linewidth); } else if(argis("-lw")) { PHASEFROM(2); shift_arg_formula(vid.linewidth); }
else if(argis("-wm")) { PHASEFROM(2); shift(); vid.wallmode = argi(); } else if(argis("-wm")) { PHASEFROM(2); shift(); vid.wallmode = argi(); }
@ -1740,6 +1749,24 @@ int read_config_args() {
} }
TOGGLE('o', vid.usingGL, switchGL()) TOGGLE('o', vid.usingGL, switchGL())
TOGGLE('f', vid.full, switchFullscreen()) TOGGLE('f', vid.full, switchFullscreen())
else if(argis("-d:sight")) {
PHASEFROM(2); launch_dialog(); edit_sightrange();
}
else if(argis("-d:char")) {
PHASEFROM(2); launch_dialog(showCustomizeChar);
}
else if(argis("-d:3")) {
PHASEFROM(2); launch_dialog(show3D);
}
else if(argis("-d:stereo")) {
PHASEFROM(2); launch_dialog(showStereo);
}
else if(argis("-d:basic")) {
PHASEFROM(2); launch_dialog(showBasicConfig);
}
else if(argis("-d:graph")) {
PHASEFROM(2); launch_dialog(showGraphConfig);
}
else return 1; else return 1;
return 0; return 0;
} }
@ -1764,7 +1791,7 @@ int read_gamemode_args() {
return 0; return 0;
} }
auto ah_config = addHook(hooks_args, 0, read_config_args) + addHook(hooks_args, 0, read_gamemode_args); auto ah_config = addHook(hooks_args, 0, read_config_args) + addHook(hooks_args, 0, read_gamemode_args) + addHook(hooks_args, 0, read_color_args);
#endif #endif
unordered_map<string, ld&> params = { unordered_map<string, ld&> params = {

View File

@ -628,17 +628,8 @@ namespace conformal {
dialog::bound_up(isize(torus_zeros)-1); dialog::bound_up(isize(torus_zeros)-1);
} }
void model_menu() { void edit_formula() {
cmode = sm::SIDE | sm::MAYDARK | sm::CENTER; if(pmodel != mdFormula) basic_model = pmodel;
gamescreen(0);
dialog::init(XLAT("models of hyperbolic geometry"));
for(int i=0; i<mdGUARD; i++) {
eModel m = eModel(i);
if(model_available(m)) {
dialog::addBoolItem(get_model_name(m), pmodel == m, "0123456789!@#$%^&*()" [m]);
dialog::add_action([m] () {
if(m == mdFormula) {
if(pmodel != m) basic_model = pmodel;
dialog::edit_string(formula, "formula", dialog::edit_string(formula, "formula",
XLAT( XLAT(
"This lets you specify the projection as a formula f. " "This lets you specify the projection as a formula f. "
@ -663,6 +654,19 @@ namespace conformal {
dialog::reaction_final = [] () { dialog::reaction_final = [] () {
pmodel = mdFormula; pmodel = mdFormula;
}; };
}
void model_menu() {
cmode = sm::SIDE | sm::MAYDARK | sm::CENTER;
gamescreen(0);
dialog::init(XLAT("models of hyperbolic geometry"));
for(int i=0; i<mdGUARD; i++) {
eModel m = eModel(i);
if(model_available(m)) {
dialog::addBoolItem(get_model_name(m), pmodel == m, "0123456789!@#$%^&*()" [m]);
dialog::add_action([m] () {
if(m == mdFormula) {
edit_formula();
return; return;
} }
pmodel = m; pmodel = m;
@ -1108,6 +1112,16 @@ namespace conformal {
else if(argis("-alpha")) { else if(argis("-alpha")) {
PHASEFROM(2); shift_arg_formula(vid.alpha); PHASEFROM(2); shift_arg_formula(vid.alpha);
} }
else if(argis("-d:model"))
launch_dialog(model_menu);
else if(argis("-d:formula")) {
launch_dialog();
edit_formula();
}
else if(argis("-d:match")) {
launch_dialog(match_torus_period);
edit_formula();
}
else return 1; else return 1;
return 0; return 0;
} }

View File

@ -93,8 +93,18 @@ void showQuotientConfig() {
bool torus_bitrunc; bool torus_bitrunc;
void prepare_torusconfig() {
torusconfig::newdy = torusconfig::dy;
torusconfig::newqty = torusconfig::qty;
torusconfig::newsdx = torusconfig::sdx;
torusconfig::newsdy = torusconfig::sdy;
torusconfig::newmode = torusconfig::torus_mode;
torus_bitrunc = PURE;
}
void showTorusConfig() { void showTorusConfig() {
cmode = sm::SIDE | sm::TORUSCONFIG; cmode = sm::SIDE;
if(torus) cmode |= sm::TORUSCONFIG;
gamescreen(2); gamescreen(2);
dialog::init(XLAT("advanced configuration")); dialog::init(XLAT("advanced configuration"));
@ -468,12 +478,7 @@ void showEuclideanMenu() {
ewhichscreen ^= 3; ewhichscreen ^= 3;
else if(uni == '4') { else if(uni == '4') {
if(torus) if(torus)
torusconfig::newdy = torusconfig::dy, prepare_torusconfig(),
torusconfig::newqty = torusconfig::qty,
torusconfig::newsdx = torusconfig::sdx,
torusconfig::newsdy = torusconfig::sdy,
torusconfig::newmode = torusconfig::torus_mode,
torus_bitrunc = PURE,
pushScreen(showTorusConfig); pushScreen(showTorusConfig);
else if(geometry == gFieldQuotient) else if(geometry == gFieldQuotient)
pushScreen(showQuotientConfig); pushScreen(showQuotientConfig);
@ -639,6 +644,14 @@ int read_geom_args() {
cheat(); cheat();
shift(); currfp.qpaths.push_back(args()); shift(); currfp.qpaths.push_back(args());
} }
else if(argis("-d:quotient"))
launch_dialog(showQuotientConfig);
else if(argis("-d:torus")) {
launch_dialog(showTorusConfig);
prepare_torusconfig();
}
else if(argis("-d:geom"))
launch_dialog(showEuclideanMenu);
else return 1; else return 1;
return 0; return 0;
} }

View File

@ -2084,6 +2084,8 @@ namespace arg {
void init(int _argc, char **_argv); void init(int _argc, char **_argv);
void launch_dialog(const reaction_t& r = reaction_t());
extern int curphase; extern int curphase;
void phaseerror(int x); void phaseerror(int x);

View File

@ -901,4 +901,33 @@ void showMessageLog() {
else if(doexiton(sym, uni)) popScreen(); else if(doexiton(sym, uni)) popScreen();
}; };
} }
#if CAP_COMMANDLINE
int read_menu_args() {
using namespace arg;
if(argis("-d:over")) {
PHASEFROM(2); launch_dialog(showOverview);
}
else if(argis("-d:main")) {
PHASEFROM(2); launch_dialog(showMainMenu);
}
else if(argis("-d:display")) {
PHASEFROM(2); launch_dialog(showDisplayMode);
}
else if(argis("-d:mode")) {
PHASEFROM(2); launch_dialog(showChangeMode);
}
else if(argis("-d:shmup")) {
PHASEFROM(2); launch_dialog(shmup::showShmupConfig);
}
else return 1;
return 0;
}
auto ah_menu = addHook(hooks_args, 0, read_menu_args);
#endif
} }

View File

@ -2374,6 +2374,15 @@ int read_pattern_args() {
stop_game_and_switch_mode(rg::nothing); stop_game_and_switch_mode(rg::nothing);
} }
else if(argis("-d:line"))
launch_dialog(linepatterns::showMenu);
else if(argis("-d:reg"))
launch_dialog(patterns::showPrePattern);
else if(argis("-d:pattern"))
launch_dialog(patterns::showPattern);
else return 1; else return 1;
return 0; return 0;
} }

View File

@ -1943,6 +1943,9 @@ int rugArgs() {
shift_arg_formula(anticusp_factor); shift_arg_formula(anticusp_factor);
} }
else if(argis("-d:rug"))
launch_dialog(show);
else return 1; else return 1;
return 0; return 0;
} }

View File

@ -808,6 +808,9 @@ int surface_args() {
run_shape(dsHyperboloid); run_shape(dsHyperboloid);
} }
else if(argis("-d:surface"))
launch_dialog(show_surfaces);
else return 1; else return 1;
return 0; return 0;
} }