2018-02-08 23:40:26 +00:00
|
|
|
// Hyperbolic Rogue -- commandline options
|
|
|
|
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
|
|
|
|
|
2019-08-10 11:43:24 +00:00
|
|
|
/** \file commandline.cpp
|
|
|
|
* \brief Commandline options support
|
|
|
|
*/
|
|
|
|
|
2019-09-05 07:15:40 +00:00
|
|
|
#include "hyper.h"
|
2018-06-10 23:58:31 +00:00
|
|
|
namespace hr {
|
|
|
|
|
2020-05-15 23:30:33 +00:00
|
|
|
#ifdef RESOURCEDESTDIR
|
|
|
|
EX string rsrcdir = RESOURCEDESTDIR;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef RESOURCEDESTDIR
|
|
|
|
EX string rsrcdir = "";
|
|
|
|
#endif
|
|
|
|
|
2017-12-01 23:22:01 +00:00
|
|
|
#if CAP_COMMANDLINE
|
2022-09-15 10:38:39 +00:00
|
|
|
EX string scorefile = "hyperrogue.log";
|
2018-02-26 12:14:20 +00:00
|
|
|
|
2019-08-10 00:16:48 +00:00
|
|
|
EX namespace arg {
|
|
|
|
EX eLand readland(const string& ss) {
|
2017-12-01 23:22:01 +00:00
|
|
|
if(ss == "II") return laCrossroads2;
|
|
|
|
if(ss == "III") return laCrossroads3;
|
|
|
|
if(ss == "IV") return laCrossroads4;
|
|
|
|
if(ss == "V") return laCrossroads5;
|
2018-02-26 12:14:20 +00:00
|
|
|
for(int l=0; l<landtypes; l++) if(appears(linf[l].name, ss)) {
|
2017-12-01 23:22:01 +00:00
|
|
|
return eLand(l);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return laNone;
|
|
|
|
}
|
|
|
|
|
2019-08-10 00:16:48 +00:00
|
|
|
EX eItem readItem(const string& ss) {
|
2018-02-26 12:14:20 +00:00
|
|
|
for(int i=0; i<ittypes; i++) if(appears(iinf[i].name, ss)) {
|
2017-12-01 23:22:01 +00:00
|
|
|
return eItem(i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return itNone;
|
|
|
|
}
|
|
|
|
|
2019-08-10 00:16:48 +00:00
|
|
|
EX eMonster readMonster(const string& ss) {
|
2020-02-27 20:03:54 +00:00
|
|
|
if(ss == "Pike") return moPike;
|
2018-02-26 12:14:20 +00:00
|
|
|
for(int i=0; i<motypes; i++) if(appears(minf[i].name, ss)) {
|
2017-12-01 23:22:01 +00:00
|
|
|
return eMonster(i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return moNone;
|
|
|
|
}
|
2019-08-10 00:16:48 +00:00
|
|
|
EX }
|
2017-12-01 23:22:01 +00:00
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX void initializeCLI() {
|
2017-12-01 23:22:01 +00:00
|
|
|
printf("HyperRogue by Zeno Rogue <zeno@attnam.com>, version " VER "\n");
|
|
|
|
|
2019-02-08 23:18:56 +00:00
|
|
|
#if !NOLICENSE
|
2017-12-01 23:22:01 +00:00
|
|
|
printf("released under GNU General Public License version 2 and thus\n");
|
|
|
|
printf("comes with absolutely no warranty; see COPYING for details\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef FHS
|
|
|
|
static string sbuf, cbuf;
|
|
|
|
if(getenv("HOME")) {
|
|
|
|
sbuf = getenv("HOME"); sbuf += "/."; sbuf += scorefile;
|
|
|
|
cbuf = getenv("HOME"); cbuf += "/."; cbuf += conffile;
|
2022-09-15 10:38:39 +00:00
|
|
|
scorefile = sbuf;
|
2017-12-01 23:22:01 +00:00
|
|
|
conffile = cbuf.c_str();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2019-08-10 00:16:48 +00:00
|
|
|
EX namespace arg {
|
|
|
|
EX int curphase;
|
|
|
|
|
2019-09-12 22:31:54 +00:00
|
|
|
EX vector<string> argument;
|
2019-08-10 00:16:48 +00:00
|
|
|
EX int pos;
|
2018-02-26 12:14:20 +00:00
|
|
|
|
2019-08-10 00:16:48 +00:00
|
|
|
EX void lshift() { pos++; }
|
2019-09-06 06:17:02 +00:00
|
|
|
EX void unshift() { pos--; }
|
2018-02-26 12:14:20 +00:00
|
|
|
|
2019-08-10 00:16:48 +00:00
|
|
|
EX void shift() {
|
2019-04-23 10:02:58 +00:00
|
|
|
lshift(); if(pos >= isize(argument)) { printf("Missing parameter\n"); exit(1); }
|
2018-02-26 12:14:20 +00:00
|
|
|
}
|
|
|
|
|
2019-08-10 00:16:48 +00:00
|
|
|
EX bool nomore() { return pos >= isize(argument); }
|
2019-04-22 20:59:37 +00:00
|
|
|
|
2019-08-10 00:16:48 +00:00
|
|
|
EX const string& args() { return argument[pos]; }
|
|
|
|
EX const char* argcs() { return args().c_str(); }
|
|
|
|
EX int argi() { return atoi(argcs()); }
|
2022-10-23 13:47:26 +00:00
|
|
|
EX long long argll() { return atoll(argcs()); }
|
2021-03-31 12:35:13 +00:00
|
|
|
|
|
|
|
EX int shift_argi() { shift(); return argi(); }
|
|
|
|
EX const string& shift_args() { shift(); return args(); }
|
|
|
|
|
2019-08-10 00:16:48 +00:00
|
|
|
EX unsigned arghex() { return strtoll(argcs(), NULL, 16); }
|
2019-12-23 20:44:51 +00:00
|
|
|
EX ld argf() {
|
|
|
|
try {
|
|
|
|
return parseld(args());
|
|
|
|
}
|
|
|
|
catch(hr_parse_exception& ex) {
|
|
|
|
println(hlog, "error parsing commandline parameters: ", ex.s);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
2019-08-10 00:16:48 +00:00
|
|
|
EX bool argis(const string& s) { if(args()[0] == '-' && args()[1] == '-') return args().substr(1) == s; return args() == s; }
|
2021-10-17 07:18:31 +00:00
|
|
|
|
|
|
|
EX color_t argcolor(int bits) {
|
|
|
|
string s = args();
|
|
|
|
auto p = find_color_by_name(s);
|
|
|
|
if(p && bits == 24) return p->second;
|
|
|
|
if(p && bits == 32) return (p->second << 8) | 0xFF;
|
|
|
|
return strtoll(argcs(), NULL, 16);
|
|
|
|
}
|
2018-02-26 12:14:20 +00:00
|
|
|
|
2023-08-08 23:01:32 +00:00
|
|
|
int parameter_id;
|
|
|
|
|
2019-08-10 00:16:48 +00:00
|
|
|
EX void shift_arg_formula(ld& x, const reaction_t& r IS(reaction_t())) {
|
2023-08-08 23:01:32 +00:00
|
|
|
shift();
|
|
|
|
auto par = anims::find_param(&x);
|
|
|
|
if(!par) par = param_f(x, "tmp_parameter_" + its(parameter_id++))->set_reaction(r);
|
|
|
|
par->load_as_animation(args());
|
2019-08-10 00:16:48 +00:00
|
|
|
}
|
2023-08-08 14:27:52 +00:00
|
|
|
|
2019-08-10 00:16:48 +00:00
|
|
|
#if HDR
|
|
|
|
|
|
|
|
// an useful macro
|
|
|
|
#define PHASE(x) { if(arg::curphase > x) arg::phaseerror(x); else if(arg::curphase < x) return 2; }
|
|
|
|
#define PHASEFROM(x) { if(arg::curphase < x) return 2; }
|
|
|
|
|
|
|
|
#define TOGGLE(x, param, act) \
|
|
|
|
else if(args()[0] == '-' && args()[1] == x && !args()[2]) { PHASEFROM(2); showstartmenu = false; act; } \
|
|
|
|
else if(args()[0] == '-' && args()[1] == x && args()[2] == '1') { PHASEFROM(2); showstartmenu = false; if(!param) act; } \
|
|
|
|
else if(args()[0] == '-' && args()[1] == x && args()[2] == '0') { PHASEFROM(2); showstartmenu = false; if(param) act; }
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
EX void cheat() { autocheat = true; cheater++; timerghost = false; }
|
|
|
|
|
2021-10-15 20:14:30 +00:00
|
|
|
EX void run_arguments(const vector<string> vec) {
|
|
|
|
dynamicval<int> p(pos, 0);
|
|
|
|
dynamicval<vector<string>> orig(argument, vec);
|
|
|
|
read(3);
|
|
|
|
}
|
|
|
|
|
2019-08-10 00:16:48 +00:00
|
|
|
EX void init(int argc, char **argv) { for(int i=0; i<argc; i++) argument.push_back(argv[i]); lshift(); }
|
2018-02-26 12:14:20 +00:00
|
|
|
|
2019-08-10 00:16:48 +00:00
|
|
|
EX void phaseerror(int x) {
|
2018-02-26 12:14:20 +00:00
|
|
|
printf("Command line error: cannot read command '%s' from phase %d in phase %d\n", args().c_str(), x, curphase);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2018-11-11 10:06:32 +00:00
|
|
|
bool dialog_launched = false;
|
|
|
|
|
2019-08-10 00:16:48 +00:00
|
|
|
EX void launch_dialog(const reaction_t& r IS(reaction_t())) {
|
2018-11-11 10:06:32 +00:00
|
|
|
if(!dialog_launched) {
|
|
|
|
popScreenAll();
|
|
|
|
showstartmenu = false;
|
|
|
|
dialog_launched = true;
|
|
|
|
}
|
|
|
|
if(r) pushScreen(r);
|
|
|
|
}
|
|
|
|
|
2019-08-10 00:16:48 +00:00
|
|
|
EX int readCommon();
|
|
|
|
EX int readLocal();
|
|
|
|
EX void read(int phase);
|
|
|
|
EX }
|
2018-04-05 22:30:56 +00:00
|
|
|
|
2018-11-11 10:06:32 +00:00
|
|
|
|
2017-12-01 23:22:01 +00:00
|
|
|
int arg::readCommon() {
|
2018-06-10 21:49:52 +00:00
|
|
|
|
|
|
|
// first phase options
|
|
|
|
|
2022-09-15 10:38:39 +00:00
|
|
|
if(argis("-s")) { PHASE(2); shift(); scorefile = args(); savefile_selection = false; }
|
|
|
|
else if(argis("-no-s")) { PHASE(2); scorefile = ""; savefile_selection = false; }
|
2020-05-15 23:30:33 +00:00
|
|
|
else if(argis("-rsrc")) { PHASE(1); shift(); rsrcdir = args(); }
|
2018-06-10 21:49:52 +00:00
|
|
|
else if(argis("-nogui")) { PHASE(1); noGUI = true; }
|
2018-06-13 22:06:54 +00:00
|
|
|
#ifndef EMSCRIPTEN
|
2020-07-03 12:42:33 +00:00
|
|
|
#if CAP_SDL
|
2023-05-15 17:33:32 +00:00
|
|
|
else if(argis("-font")) { PHASE(1); shift(); fontpath = args();
|
|
|
|
#ifdef FONTCONFIG
|
|
|
|
font_to_find = "";
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#ifdef FONTCONFIG
|
|
|
|
else if(argis("-find-font")) { PHASE(1); shift(); font_to_find = args(); }
|
|
|
|
#endif
|
2020-07-03 12:42:33 +00:00
|
|
|
#endif
|
2018-06-13 22:06:54 +00:00
|
|
|
#endif
|
2018-06-10 21:49:52 +00:00
|
|
|
|
2021-02-04 15:15:47 +00:00
|
|
|
else if(argis("-test-ach"))
|
|
|
|
test_achievements = true;
|
|
|
|
|
2017-12-28 15:46:10 +00:00
|
|
|
else if(argis("-test"))
|
|
|
|
callhooks(hooks_tests);
|
2018-06-10 22:58:38 +00:00
|
|
|
else if(argis("-offline")) {
|
|
|
|
PHASE(1);
|
|
|
|
offlineMode = true;
|
|
|
|
}
|
2020-01-25 18:22:26 +00:00
|
|
|
else if(argis("-no-stamp")) {
|
|
|
|
debugflags &=~ DF_TIME;
|
|
|
|
}
|
2019-05-12 23:57:40 +00:00
|
|
|
else if(argis("-debf")) {
|
|
|
|
shift();
|
|
|
|
string s = args();
|
|
|
|
for(char c: s) {
|
|
|
|
for(int i=0; i<int(strlen(DF_KEYS)); i++) {
|
|
|
|
if(DF_KEYS[i] == c) debugflags |= (1<<i);
|
2019-08-10 18:47:50 +00:00
|
|
|
else if(DF_KEYS[i] == (c ^ 32)) debugflags &= ~(1<<i);
|
|
|
|
}
|
|
|
|
if(c >= '0' && c <= '9') {
|
|
|
|
debugflags &= DF_TIME;
|
|
|
|
if(c >= '1')
|
|
|
|
debugflags |= DF_INIT | DF_WARN | DF_MSG | DF_ERROR;
|
|
|
|
if(c >= '2')
|
|
|
|
debugflags |= DF_GEOM | DF_GP | DF_LOG | DF_FIELD | DF_POLY;
|
|
|
|
if(c >= '3')
|
|
|
|
debugflags |= DF_TURN | DF_STEAM;
|
|
|
|
if(c >= '4')
|
|
|
|
debugflags |= DF_GRAPH | DF_MEMORY;
|
|
|
|
}
|
|
|
|
else if(c == '+') {
|
|
|
|
if(debugfile) fclose(debugfile);
|
|
|
|
shift();
|
|
|
|
println(hlog, "writing to ", argcs());
|
|
|
|
debugfile = fopen(argcs(), "at");
|
|
|
|
}
|
|
|
|
else if(c == '@') {
|
|
|
|
if(debugfile) fclose(debugfile);
|
|
|
|
shift();
|
|
|
|
println(hlog, "writing to ", argcs());
|
|
|
|
debugfile = fopen(argcs(), "wt");
|
2019-05-12 23:57:40 +00:00
|
|
|
}
|
|
|
|
}
|
2017-12-01 23:22:01 +00:00
|
|
|
}
|
2018-11-10 18:49:41 +00:00
|
|
|
else if(argis("-run")) {
|
2018-06-10 22:58:38 +00:00
|
|
|
PHASE(3);
|
|
|
|
start_game();
|
|
|
|
mainloop(); quitmainloop = false;
|
2017-12-01 23:22:01 +00:00
|
|
|
}
|
2018-11-10 18:49:41 +00:00
|
|
|
else if(argis("-msg")) {
|
2017-12-14 01:50:28 +00:00
|
|
|
shift(); addMessage(args());
|
2018-04-05 22:30:56 +00:00
|
|
|
printf("%s\n", args().c_str());
|
2017-12-14 01:50:28 +00:00
|
|
|
}
|
2018-11-10 18:49:41 +00:00
|
|
|
else if(argis("-msg0")) {
|
2017-12-14 01:50:28 +00:00
|
|
|
clearMessages();
|
|
|
|
}
|
2017-12-01 23:22:01 +00:00
|
|
|
#if CAP_TOUR
|
2018-11-10 18:49:41 +00:00
|
|
|
else if(argis("-tour")) {
|
2020-04-07 15:14:45 +00:00
|
|
|
showstartmenu = false;
|
2018-06-10 22:58:38 +00:00
|
|
|
PHASEFROM(2); start_game(); tour::start();
|
2017-12-01 23:22:01 +00:00
|
|
|
}
|
2018-11-10 18:49:41 +00:00
|
|
|
else if(argis("-presentation")) {
|
2018-06-10 22:58:38 +00:00
|
|
|
PHASEFROM(2); tour::texts = false;
|
|
|
|
start_game(); tour::start();
|
2017-12-01 23:22:01 +00:00
|
|
|
}
|
2020-09-15 17:11:19 +00:00
|
|
|
else if(argis("-print-tour")) {
|
|
|
|
tour::print();
|
|
|
|
}
|
2017-12-01 23:22:01 +00:00
|
|
|
#endif
|
2018-11-10 18:49:41 +00:00
|
|
|
else if(argis("-draw")) {
|
2020-04-01 09:25:13 +00:00
|
|
|
PHASE(3); start_game(); drawscreen();
|
2017-12-01 23:22:01 +00:00
|
|
|
}
|
2023-08-09 12:35:18 +00:00
|
|
|
else if(argis("-sview")) {
|
2019-01-24 13:48:53 +00:00
|
|
|
PHASE(3); start_game();
|
2022-09-24 07:10:32 +00:00
|
|
|
playermoved = false;
|
2023-08-09 12:35:18 +00:00
|
|
|
transmatrix T = View;
|
|
|
|
shift(); View = parsematrix(args());
|
|
|
|
println(hlog, "View is set to ", View);
|
|
|
|
current_display->which_copy = View * inverse(T) * current_display->which_copy;
|
2018-09-05 13:17:24 +00:00
|
|
|
}
|
2022-06-16 21:13:38 +00:00
|
|
|
else if(argis("-rotate-up")) {
|
|
|
|
start_game();
|
|
|
|
shiftmatrix S = ggmatrix(cwt.at->master->move(0)->c7);
|
2022-11-12 21:38:45 +00:00
|
|
|
View = spin90() * spintox(S.T*C0) * View;
|
2022-09-24 07:10:32 +00:00
|
|
|
playermoved = false;
|
2022-06-16 21:13:38 +00:00
|
|
|
}
|
2020-05-27 23:38:21 +00:00
|
|
|
else if(argis("-face-vertex")) {
|
|
|
|
PHASE(3); start_game();
|
2021-07-12 09:32:39 +00:00
|
|
|
auto &ss = currentmap->get_cellshape(cwt.at);
|
2022-11-12 21:38:45 +00:00
|
|
|
View = cspin90(0, 2) * spintox(ss.vertices_only_local[0]);
|
2022-09-24 07:10:32 +00:00
|
|
|
playermoved = false;
|
2020-05-27 23:38:21 +00:00
|
|
|
}
|
|
|
|
else if(argis("-face-face")) {
|
|
|
|
PHASE(3); start_game();
|
2022-11-12 21:38:45 +00:00
|
|
|
View = cspin90(0, 2);
|
2020-05-27 23:38:21 +00:00
|
|
|
}
|
2023-06-10 09:07:49 +00:00
|
|
|
else if(argis("-center-vertex")) {
|
|
|
|
PHASE(3); shift(); int i = argi();
|
|
|
|
shift(); int j = argi();
|
|
|
|
shift(); int k = argi();
|
|
|
|
start_game();
|
|
|
|
auto fh = currentmap->get_cellshape(cwt.at).faces[j][k];
|
|
|
|
hyperpoint h = View * fh;
|
|
|
|
if(i == 0) {
|
|
|
|
shift_view_to(shiftless(h));
|
|
|
|
playermoved = false;
|
|
|
|
}
|
|
|
|
if(i == 1) {
|
|
|
|
rotate_view(spintox(h));
|
|
|
|
rotate_view(cspin90(0, 2));
|
|
|
|
}
|
|
|
|
}
|
2018-11-10 18:49:41 +00:00
|
|
|
else if(argis("-exit")) {
|
2022-08-25 08:28:26 +00:00
|
|
|
PHASE(3);
|
|
|
|
int t = SDL_GetTicks();
|
|
|
|
if(t > 1800 * 1000)
|
|
|
|
println(hlog, "Great Success!\n");
|
|
|
|
else
|
|
|
|
println(hlog, "Success.\n");
|
2022-09-09 10:20:33 +00:00
|
|
|
fflush(stdout);
|
2017-12-01 23:22:01 +00:00
|
|
|
exit(0);
|
|
|
|
}
|
2018-06-10 21:49:52 +00:00
|
|
|
|
|
|
|
// graphical options
|
|
|
|
else if(argis("-noscr")) {
|
|
|
|
PHASE(3);
|
|
|
|
popScreenAll();
|
|
|
|
showstartmenu = false;
|
|
|
|
}
|
|
|
|
|
2018-11-30 13:59:29 +00:00
|
|
|
else if(argis("-viz")) {
|
|
|
|
PHASE(3);
|
|
|
|
showstartmenu = false;
|
|
|
|
start_game();
|
|
|
|
popScreenAll();
|
|
|
|
clearMessages();
|
|
|
|
nohud = true;
|
|
|
|
mapeditor::drawplayer = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(argis("-vizhr")) {
|
|
|
|
PHASE(3);
|
|
|
|
showstartmenu = false;
|
|
|
|
popScreenAll();
|
|
|
|
clearMessages();
|
|
|
|
}
|
|
|
|
|
2018-06-10 21:49:52 +00:00
|
|
|
// informational
|
2018-11-10 18:49:41 +00:00
|
|
|
else if(argis("-version") || argis("-v")) {
|
2018-06-10 22:58:38 +00:00
|
|
|
printf("HyperRogue version " VER "\n");
|
|
|
|
exit(0);
|
|
|
|
}
|
2018-06-10 21:49:52 +00:00
|
|
|
else if(argis("-L")) {
|
|
|
|
printf("Treasures:\n");
|
|
|
|
for(int i=1; i<ittypes; i++)
|
|
|
|
if(itemclass(eItem(i)) == IC_TREASURE)
|
|
|
|
printf(" %s\n", iinf[i].name);
|
|
|
|
printf("\n");
|
|
|
|
printf("Orbs:\n");
|
|
|
|
for(int i=1; i<ittypes; i++)
|
|
|
|
if(itemclass(eItem(i)) == IC_ORB)
|
|
|
|
printf(" %s\n", iinf[i].name);
|
|
|
|
printf("\n");
|
|
|
|
printf("Other items:\n");
|
|
|
|
for(int i=1; i<ittypes; i++)
|
|
|
|
if(itemclass(eItem(i)) == IC_OTHER)
|
|
|
|
printf(" %s\n", iinf[i].name);
|
|
|
|
printf("\n");
|
|
|
|
printf("Monsters:\n");
|
|
|
|
for(int i=1; i<motypes; i++)
|
|
|
|
printf(" %s\n", minf[i].name);
|
|
|
|
printf("\n");
|
|
|
|
printf("Lands:\n");
|
|
|
|
for(int i=1; i<landtypes; i++)
|
|
|
|
printf(" %s\n", linf[i].name);
|
|
|
|
printf("\n");
|
|
|
|
printf("Walls:\n");
|
|
|
|
for(int i=0; i<walltypes; i++)
|
|
|
|
printf(" %s\n", winf[i].name);
|
|
|
|
printf("\n");
|
|
|
|
exit(0);
|
|
|
|
}
|
2018-11-10 18:49:41 +00:00
|
|
|
else if(argis("")) {}
|
|
|
|
else if(argis("-help") || argis("-h")) {
|
2017-12-01 23:22:01 +00:00
|
|
|
printf("Press F1 while playing to get ingame options.\n\n");
|
|
|
|
printf("HyperRogue accepts the following command line options:\n");
|
|
|
|
printf(" -c FILE - use the specified configuration file\n");
|
|
|
|
printf(" -s FILE - use the specified highscore file\n");
|
|
|
|
printf(" -m FILE - use the specified soundtrack (music)\n");
|
|
|
|
printf(" -se DIR - the directory containing sound effects\n");
|
|
|
|
printf(" -lev FILE - use the specified filename for the map editor (without loading)\n");
|
|
|
|
printf(" -load FILE - use the specified filename for the map editor\n");
|
|
|
|
printf(" -canvas COLOR - set background color or pattern code for the canvas\n");
|
|
|
|
printf(" --version, -v - show the version number\n");
|
|
|
|
printf(" --help, -h - show the commandline options\n");
|
|
|
|
printf(" -f* - toggle fullscreen mode\n");
|
|
|
|
printf(" -wm n, -mm n - start in the given wallmode or monmode\n");
|
|
|
|
printf(" -r WxHxF - use the given resolution and font size\n");
|
|
|
|
printf(" -o* - toggle the OpenGL mode\n");
|
|
|
|
printf(" -W LAND - start in the given land (cheat)\n");
|
|
|
|
printf(" -W2 LAND - make the given land easy to find (also turns on autocheat)\n");
|
|
|
|
printf(" -ch - auto-enable cheat mode\n");
|
|
|
|
printf(" -geo n - switch geometry (1=Euclidean, 2=spherical, 3=elliptic, 4/5=quotient)\n");
|
|
|
|
printf(" -qs <desc> - fieldpattern: quotient by the given <desc> (must be followed by qpar)\n");
|
|
|
|
printf(" -qpar <prime> - fieldpattern: use the given prime instead of 43\n");
|
|
|
|
printf(" -cs <desc> - fieldpattern: set subpath to the given <desc> (cannot be followed by qpar)\n");
|
|
|
|
printf(" -csp - fieldpattern: find the subpath of order <prime> (cannot be followed by qpar)\n");
|
|
|
|
printf(" -S* - toggle Shmup\n");
|
|
|
|
printf(" -P n - switch Shmup number of players (n=1..7)\n");
|
|
|
|
printf(" -PM - switch the model index\n");
|
|
|
|
printf(" -H* - toggle Hardcore\n");
|
|
|
|
printf(" -T* - toggle Tactical\n");
|
|
|
|
printf(" -7* - toggle heptagonal mode\n");
|
|
|
|
printf(" -C* - toggle Chaos mode\n");
|
|
|
|
printf(" -R* - toggle Random Pattern\n");
|
|
|
|
printf(" -Y id - enable Yendor, level id\n");
|
|
|
|
printf(" -D - disable all the special game modes\n");
|
|
|
|
printf(" -L - list of features\n");
|
|
|
|
printf(" -debugf 7 - output debugging information to hyperrogue-debug.txt\n");
|
|
|
|
printf(" -debuge 7 - output debugging information to stderr\n");
|
|
|
|
printf(" -offline - don't connect to Steam (for Steam versions)\n");
|
|
|
|
printf(" -I ITEM n - start with n of ITEM (activates cheat and disables ghosts)\n");
|
|
|
|
printf(" -fix - fix the seed\n");
|
2021-07-10 07:34:37 +00:00
|
|
|
printf("Toggles: -o0 disables, -o1 enables, -o switches\n");
|
|
|
|
printf("Not all options are documented, see hyper.cpp\n");
|
2017-12-01 23:22:01 +00:00
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
else return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-08-09 19:00:52 +00:00
|
|
|
EX purehookset hooks_config;
|
2017-12-01 23:22:01 +00:00
|
|
|
|
2020-04-11 18:47:14 +00:00
|
|
|
EX hookset<int()> hooks_args;
|
2017-12-01 23:22:01 +00:00
|
|
|
|
2021-03-31 01:00:51 +00:00
|
|
|
EX map<string, pair<int, reaction_t>> *added_commands;
|
2017-12-01 23:22:01 +00:00
|
|
|
|
2021-03-31 00:51:08 +00:00
|
|
|
EX namespace arg {
|
|
|
|
|
|
|
|
int read_added_commands() {
|
2021-03-31 01:00:51 +00:00
|
|
|
if(!added_commands) return 1;
|
|
|
|
if(added_commands->count(args())) {
|
|
|
|
auto& ac = (*added_commands)[args()];
|
2021-03-31 00:51:08 +00:00
|
|
|
if(ac.first == 2)
|
|
|
|
PHASEFROM(2);
|
|
|
|
if(ac.first == 3)
|
|
|
|
PHASE(3);
|
|
|
|
ac.second();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
EX int add_at(const string& s, int at, const reaction_t& r) {
|
2021-03-31 01:00:51 +00:00
|
|
|
if(!added_commands) added_commands = new map<string, pair<int, reaction_t>> ();
|
|
|
|
if(added_commands->count(s)) throw hr_exception("arg::add conflict");
|
|
|
|
(*added_commands)[s] = {at, r};
|
2021-03-31 00:51:08 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2021-03-31 00:58:03 +00:00
|
|
|
EX int add1(const string& s, const reaction_t& r) { return add_at(s, 1, r); }
|
2021-03-31 00:51:08 +00:00
|
|
|
EX int add2(const string& s, const reaction_t& r) { return add_at(s, 2, r); }
|
|
|
|
EX int add3(const string& s, const reaction_t& r) { return add_at(s, 3, r); }
|
|
|
|
|
|
|
|
auto ah = addHook(hooks_args, 0, readCommon) + addHook(hooks_args, 200, read_added_commands);
|
2017-12-01 23:22:01 +00:00
|
|
|
|
|
|
|
void read(int phase) {
|
|
|
|
curphase = phase;
|
|
|
|
callhooks(hooks_config);
|
2018-06-22 12:47:24 +00:00
|
|
|
while(pos < isize(argument)) {
|
2020-04-11 19:21:18 +00:00
|
|
|
int r = callhandlers(1, hooks_args);
|
|
|
|
switch (r) {
|
|
|
|
case 0: lshift(); break;
|
|
|
|
case 1: printf("Unknown option: %s\n", argcs()); exit(3); break;
|
|
|
|
case 2: return;
|
|
|
|
default: assert(false);
|
2017-12-01 23:22:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-03-31 00:51:08 +00:00
|
|
|
EX }
|
2017-12-01 23:22:01 +00:00
|
|
|
#endif
|
2018-06-10 23:58:31 +00:00
|
|
|
|
2021-03-31 00:58:03 +00:00
|
|
|
#if !CAP_COMMANDLINE
|
|
|
|
EX namespace arg {
|
2021-05-29 10:15:50 +00:00
|
|
|
EX int add1(const string& s, const reaction_t& r) { return 0; }
|
|
|
|
EX int add2(const string& s, const reaction_t& r) { return 0; }
|
|
|
|
EX int add3(const string& s, const reaction_t& r) { return 0; }
|
2021-03-31 00:58:03 +00:00
|
|
|
EX }
|
|
|
|
#endif
|
2018-06-10 23:58:31 +00:00
|
|
|
}
|