1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-24 01:00:25 +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
void show();
int readArgs() {
using namespace arg;
@ -774,6 +776,8 @@ int readArgs() {
}
else if(argis("-dgeom")) debug_geometry = true;
else if(argis("-dual")) { PHASEFROM(2); set_variation(eVariation::dual); }
else if(argis("-d:arcm"))
launch_dialog(show);
else return 1;
return 0;
}

View File

@ -79,8 +79,20 @@ namespace arg {
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() {
// first phase options

View File

@ -1655,12 +1655,10 @@ void selectLanguageScreen() {
#if CAP_COMMANDLINE
int read_config_args() {
int read_color_args() {
using namespace arg;
if(argis("-c")) { PHASE(1); shift(); conffile = argcs(); }
// change the configuration from the command line
else if(argis("-back")) {
if(argis("-back")) {
PHASEFROM(2); shift(); backcolor = arghex();
}
else if(argis("-fillmodel")) {
@ -1681,6 +1679,17 @@ int read_config_args() {
else if(argis("-dialog")) {
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("-lw")) { PHASEFROM(2); shift_arg_formula(vid.linewidth); }
else if(argis("-wm")) { PHASEFROM(2); shift(); vid.wallmode = argi(); }
@ -1740,6 +1749,24 @@ int read_config_args() {
}
TOGGLE('o', vid.usingGL, switchGL())
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;
return 0;
}
@ -1764,7 +1791,7 @@ int read_gamemode_args() {
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
unordered_map<string, ld&> params = {

View File

@ -628,6 +628,34 @@ namespace conformal {
dialog::bound_up(isize(torus_zeros)-1);
}
void edit_formula() {
if(pmodel != mdFormula) basic_model = pmodel;
dialog::edit_string(formula, "formula",
XLAT(
"This lets you specify the projection as a formula f. "
"The formula has access to the value 'z', which is a complex number corresponding to the x,y coordinates in the currently selected model; "
"the point z is mapped to f(z). You can also use the underlying coordinates ux, uy, uz."
) + "\n\n" + parser_help()
);
dialog::extra_options = [] () {
initquickqueue();
queuereset(mdUnchanged, PPR::LINE);
for(int a=-1; a<=1; a++) {
curvepoint(hpxyz(-M_PI/2 * vid.radius, a*vid.radius, 0));
curvepoint(hpxyz(+M_PI/2 * vid.radius, a*vid.radius, 0));
queuecurve(forecolor, 0, PPR::LINE);
curvepoint(hpxyz(a*vid.radius, -M_PI/2*vid.radius, 0));
curvepoint(hpxyz(a*vid.radius, +M_PI/2*vid.radius, 0));
queuecurve(forecolor, 0, PPR::LINE);
}
queuereset(pmodel, PPR::LINE);
quickqueue();
};
dialog::reaction_final = [] () {
pmodel = mdFormula;
};
}
void model_menu() {
cmode = sm::SIDE | sm::MAYDARK | sm::CENTER;
gamescreen(0);
@ -638,31 +666,7 @@ namespace conformal {
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",
XLAT(
"This lets you specify the projection as a formula f. "
"The formula has access to the value 'z', which is a complex number corresponding to the x,y coordinates in the currently selected model; "
"the point z is mapped to f(z). You can also use the underlying coordinates ux, uy, uz."
) + "\n\n" + parser_help()
);
dialog::extra_options = [] () {
initquickqueue();
queuereset(mdUnchanged, PPR::LINE);
for(int a=-1; a<=1; a++) {
curvepoint(hpxyz(-M_PI/2 * vid.radius, a*vid.radius, 0));
curvepoint(hpxyz(+M_PI/2 * vid.radius, a*vid.radius, 0));
queuecurve(forecolor, 0, PPR::LINE);
curvepoint(hpxyz(a*vid.radius, -M_PI/2*vid.radius, 0));
curvepoint(hpxyz(a*vid.radius, +M_PI/2*vid.radius, 0));
queuecurve(forecolor, 0, PPR::LINE);
}
queuereset(pmodel, PPR::LINE);
quickqueue();
};
dialog::reaction_final = [] () {
pmodel = mdFormula;
};
edit_formula();
return;
}
pmodel = m;
@ -1108,6 +1112,16 @@ namespace conformal {
else if(argis("-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;
return 0;
}

View File

@ -93,8 +93,18 @@ void showQuotientConfig() {
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() {
cmode = sm::SIDE | sm::TORUSCONFIG;
cmode = sm::SIDE;
if(torus) cmode |= sm::TORUSCONFIG;
gamescreen(2);
dialog::init(XLAT("advanced configuration"));
@ -468,12 +478,7 @@ void showEuclideanMenu() {
ewhichscreen ^= 3;
else if(uni == '4') {
if(torus)
torusconfig::newdy = torusconfig::dy,
torusconfig::newqty = torusconfig::qty,
torusconfig::newsdx = torusconfig::sdx,
torusconfig::newsdy = torusconfig::sdy,
torusconfig::newmode = torusconfig::torus_mode,
torus_bitrunc = PURE,
prepare_torusconfig(),
pushScreen(showTorusConfig);
else if(geometry == gFieldQuotient)
pushScreen(showQuotientConfig);
@ -639,6 +644,14 @@ int read_geom_args() {
cheat();
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;
return 0;
}

View File

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

View File

@ -901,4 +901,33 @@ void showMessageLog() {
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);
}
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;
return 0;
}

View File

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

View File

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