1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-23 21:07:17 +00:00

Move all defaulting-of-CAP_FOO to sysconfig.h.

- The phrase `#ifdef CAP_` should never appear anywhere.

- The phrase `#ifndef CAP_` should appear only in sysconfig.h.

- The phrases `#if CAP_` and `#if !CAP_` may appear wherever,
    as long as "sysconfig.h" is included first.

The rules for `CAP_FOO` equally apply to `ISFOO`.

There are many one-off macros still tested with `#ifdef`,
including `HAVE_ACHIEVEMENTS`, `PRINT_ACHIEVEMENTS`,
`FAKEWEB`, `FAKE_SDL`, `EASY`, and `WHATEVER`. I don't
have much grasp on what these are used for or how they're
configured, so I'm leaving them alone.
This commit is contained in:
Arthur O'Dwyer 2020-05-03 14:56:41 -04:00
parent f56e0fe2e3
commit f2b7746c1b
23 changed files with 64 additions and 67 deletions

View File

@ -952,12 +952,12 @@ EX void achievement_display() {
col /= 10; col *= 0x10101; col /= 10; col *= 0x10101;
displayfr(vid.xres/2, vid.yres/4, 2, vid.fsize * 2, achievementMessage[0], col & 0xFFFF00, 8); displayfr(vid.xres/2, vid.yres/4, 2, vid.fsize * 2, achievementMessage[0], col & 0xFFFF00, 8);
int w = 2 * vid.fsize; int w = 2 * vid.fsize;
#if ISMOBILE==0 #if !ISMOBILE
while(w>3 && textwidth(w, achievementMessage[1]) > vid.xres) w--; while(w>3 && textwidth(w, achievementMessage[1]) > vid.xres) w--;
#endif #endif
displayfr(vid.xres/2, vid.yres/4 + vid.fsize*2, 2, w, achievementMessage[1], col, 8); displayfr(vid.xres/2, vid.yres/4 + vid.fsize*2, 2, w, achievementMessage[1], col, 8);
w = vid.fsize; w = vid.fsize;
#if ISMOBILE==0 #if !ISMOBILE
while(w>3 && textwidth(w, achievementMessage[2]) > vid.xres) w--; while(w>3 && textwidth(w, achievementMessage[2]) > vid.xres) w--;
#endif #endif
displayfr(vid.xres/2, vid.yres/4 + vid.fsize*4, 2, w, achievementMessage[2], col, 8); displayfr(vid.xres/2, vid.yres/4 + vid.fsize*4, 2, w, achievementMessage[2], col, 8);

View File

@ -3848,12 +3848,12 @@ EX namespace halloween {
} }
int id = hrand(100); int id = hrand(100);
if(items[itTreat] == 1) { if(items[itTreat] == 1) {
#if ISMOBILE==0 #if !ISMOBILE
addMessage(XLAT("Hint: use arrow keys to scroll.")); addMessage(XLAT("Hint: use arrow keys to scroll."));
#endif #endif
} }
else if(items[itTreat] == 2) { else if(items[itTreat] == 2) {
#if ISMOBILE==0 #if !ISMOBILE
addMessage(XLAT("Hint: press 1 2 3 4 to change the projection.")); addMessage(XLAT("Hint: press 1 2 3 4 to change the projection."));
#endif #endif
} }

View File

@ -8,7 +8,7 @@
*/ */
#include "hyper.h" #include "hyper.h"
#ifdef CAP_COMPLEX2 #if CAP_COMPLEX2
namespace hr { namespace hr {

View File

@ -800,7 +800,7 @@ EX void saveConfig() {
fprintf(f, "%s=%s\n", s->name.c_str(), s->save().c_str()); fprintf(f, "%s=%s\n", s->name.c_str(), s->save().c_str());
fclose(f); fclose(f);
#if ISMOBILE==0 #if !ISMOBILE
addMessage(s0 + "Configuration saved to: " + conffile); addMessage(s0 + "Configuration saved to: " + conffile);
#else #else
addMessage(s0 + "Configuration saved"); addMessage(s0 + "Configuration saved");
@ -1642,12 +1642,12 @@ EX void show3D() {
gamescreen(0); gamescreen(0);
dialog::init(XLAT("3D configuration")); dialog::init(XLAT("3D configuration"));
#if MAXMDIM >= 4 #if MAXMDIM >= 4
if(WDIM == 2) { if(WDIM == 2) {
dialog::addBoolItem(XLAT("use the full 3D models"), vid.always3, 'U'); dialog::addBoolItem(XLAT("use the full 3D models"), vid.always3, 'U');
dialog::add_action(geom3::switch_always3); dialog::add_action(geom3::switch_always3);
} }
#endif #endif
if(vid.use_smart_range == 0 && GDIM == 2) { if(vid.use_smart_range == 0 && GDIM == 2) {
dialog::addSelItem(XLAT("High detail range"), fts(vid.highdetail), 'n'); dialog::addSelItem(XLAT("High detail range"), fts(vid.highdetail), 'n');
dialog::addSelItem(XLAT("Mid detail range"), fts(vid.middetail), 'm'); dialog::addSelItem(XLAT("Mid detail range"), fts(vid.middetail), 'm');
@ -1749,12 +1749,12 @@ EX void show3D() {
dialog::add_action(geom3::switch_tpp); dialog::add_action(geom3::switch_tpp);
} }
#if MAXMDIM >=4 #if MAXMDIM >=4
if(WDIM == 2) { if(WDIM == 2) {
dialog::addBoolItem(XLAT("configure FPP automatically"), GDIM == 3, 'F'); dialog::addBoolItem(XLAT("configure FPP automatically"), GDIM == 3, 'F');
dialog::add_action(geom3::switch_fpp); dialog::add_action(geom3::switch_fpp);
} }
#endif #endif
if(0); if(0);
#if CAP_RUG #if CAP_RUG
@ -2422,22 +2422,22 @@ EX int read_config_args() {
PHASEFROM(2); PHASEFROM(2);
nomenukey = true; nomenukey = true;
} }
#if MAXMDIM >= 4 #if MAXMDIM >= 4
else if(argis("-switch-fpp")) { else if(argis("-switch-fpp")) {
PHASEFROM(2); PHASEFROM(2);
geom3::switch_fpp(); geom3::switch_fpp();
} }
#endif #endif
else if(argis("-switch-tpp")) { else if(argis("-switch-tpp")) {
PHASEFROM(2); PHASEFROM(2);
geom3::switch_tpp(); geom3::switch_tpp();
} }
#if MAXMDIM >= 4 #if MAXMDIM >= 4
else if(argis("-switch-3d")) { else if(argis("-switch-3d")) {
PHASEFROM(2); PHASEFROM(2);
geom3::switch_always3(); geom3::switch_always3();
} }
#endif #endif
else if(argis("-nohelp")) { else if(argis("-nohelp")) {
PHASEFROM(2); PHASEFROM(2);
nohelp = true; nohelp = true;

View File

@ -1021,7 +1021,7 @@ EX void mainloop() {
#endif #endif
} }
#if ISMOBILE==1 #if ISMOBILE
EX void displayabutton(int px, int py, string s, int col) { EX void displayabutton(int px, int py, string s, int col) {
// TMP // TMP
int siz = vid.yres > vid.xres ? vid.fsize*2 : vid.fsize * 3/2; int siz = vid.yres > vid.xres ? vid.fsize*2 : vid.fsize * 3/2;

View File

@ -803,7 +803,7 @@ EX namespace dialog {
else else
addSlider(ne.sc.direct(ne.vmin), ne.sc.direct(*ne.editwhat), ne.sc.direct(ne.vmax), 500); addSlider(ne.sc.direct(ne.vmin), ne.sc.direct(*ne.editwhat), ne.sc.direct(ne.vmax), 500);
addBreak(100); addBreak(100);
#if ISMOBILE==0 #if !ISMOBILE
addHelp(XLAT("You can scroll with arrow keys -- Ctrl to fine-tune")); addHelp(XLAT("You can scroll with arrow keys -- Ctrl to fine-tune"));
addBreak(100); addBreak(100);
#endif #endif

View File

@ -239,7 +239,7 @@ EX void glflush() {
} }
#endif #endif
#if ISMOBILE==0 #if !ISMOBILE
SDL_Surface *aux; SDL_Surface *aux;
#endif #endif
@ -1661,7 +1661,7 @@ void dqi_poly::draw() {
} }
#endif #endif
#if CAP_SVG==1 #if CAP_SVG
if(svg::in) { if(svg::in) {
coords_to_poly(); coords_to_poly();
color_t col = color; color_t col = color;
@ -1678,10 +1678,10 @@ void dqi_poly::draw() {
coords_to_poly(); coords_to_poly();
#if CAP_XGD==1 #if CAP_XGD
gdpush(1); gdpush(color); gdpush(outline); gdpush(polyi); gdpush(1); gdpush(color); gdpush(outline); gdpush(polyi);
for(int i=0; i<polyi; i++) gdpush(polyx[i]), gdpush(polyy[i]); for(int i=0; i<polyi; i++) gdpush(polyx[i]), gdpush(polyy[i]);
#elif CAP_SDLGFX==1 #elif CAP_SDLGFX
if(tinf) { if(tinf) {
#if CAP_TEXTURE #if CAP_TEXTURE
@ -1803,7 +1803,7 @@ void dqi_string::draw() {
return; return;
} }
#endif #endif
#if ISMOBILE==0 #if !ISMOBILE
int fr = frame & 255; int fr = frame & 255;
displayfrSP(x, y, shift, fr, size, str, color, align, frame >> 8); displayfrSP(x, y, shift, fr, size, str, color, align, frame >> 8);
#else #else

View File

@ -24,10 +24,6 @@ EX void glError(const char* GLcall, const char* file, const int line) {
} }
} }
#ifndef CAP_VERTEXBUFFER
#define CAP_VERTEXBUFFER (ISWEB)
#endif
#if HDR #if HDR
#if CAP_SHADER && CAP_NOSHADER #if CAP_SHADER && CAP_NOSHADER
#define WITHSHADER(x, y) if(glhr::noshaders) y else x #define WITHSHADER(x, y) if(glhr::noshaders) y else x

View File

@ -4052,7 +4052,7 @@ EX void queuecircleat(cell *c, double rad, color_t col) {
} }
#endif #endif
#if ISMOBILE==1 #if ISMOBILE
#define MOBON (clicked) #define MOBON (clicked)
#else #else
#define MOBON true #define MOBON true

View File

@ -357,7 +357,7 @@ EX string generateHelpForItem(eItem it) {
" You need to go deep to collect lots of them."); " You need to go deep to collect lots of them.");
} }
#if ISMOBILE==1 #if ISMOBILE
if(it == itOrbSafety) if(it == itOrbSafety)
help += XLAT("This might be very useful for devices with limited memory."); help += XLAT("This might be very useful for devices with limited memory.");
#else #else
@ -525,7 +525,7 @@ void addMinefieldExplanation(string& s) {
); );
s += "\n\n"; s += "\n\n";
#if ISMOBILE==0 #if !ISMOBILE
s += XLAT("Known mines may be marked by pressing 'm'. Your allies won't step on marked mines."); s += XLAT("Known mines may be marked by pressing 'm'. Your allies won't step on marked mines.");
#else #else
s += XLAT("Known mines may be marked by touching while in drag mode. Your allies won't step on marked mines."); s += XLAT("Known mines may be marked by touching while in drag mode. Your allies won't step on marked mines.");

View File

@ -731,7 +731,7 @@ struct colortable: vector<color_t> {
namespace scores { void load(); } namespace scores { void load(); }
#if ISMOBILE==1 #if ISMOBILE
namespace leader { void showMenu(); void handleKey(int sym, int uni); } namespace leader { void showMenu(); void handleKey(int sym, int uni); }
#endif #endif
@ -740,7 +740,7 @@ int textwidth(int siz, const string &str);
int gl_width(int size, const char *s); int gl_width(int size, const char *s);
#endif #endif
#ifdef ISMOBILE #if ISMOBILE
extern int andmode; extern int andmode;
extern bool longclick; extern bool longclick;
extern bool useRangedOrb; extern bool useRangedOrb;

View File

@ -30,10 +30,6 @@
#define EMSCRIPTEN #define EMSCRIPTEN
#endif #endif
#ifndef CAP_ORIENTATION
#define CAP_ORIENTATION 1
#endif
#ifdef FAKEWEB #ifdef FAKEWEB
namespace hr { void mainloopiter(); } namespace hr { void mainloopiter(); }
template<class A, class B, class C> void emscripten_set_main_loop(A a, B b, C c) { while(true) mainloopiter(); } template<class A, class B, class C> void emscripten_set_main_loop(A a, B b, C c) { while(true) mainloopiter(); }

View File

@ -588,7 +588,7 @@ EX namespace inv {
displaystr(vid.xres/2, vid.yres - vid.fsize*6, 2, vid.fsize, osminfo(which), icol, 8); displaystr(vid.xres/2, vid.yres - vid.fsize*6, 2, vid.fsize, osminfo(which), icol, 8);
} }
#if ISMOBILE==0 #if !ISMOBILE
string hot = XLAT1("Hotkey: "); hot += getcstat; string hot = XLAT1("Hotkey: "); hot += getcstat;
displaystr(vid.xres/2, vid.yres - vid.fsize*5, 2, vid.fsize, hot, icol, 8); displaystr(vid.xres/2, vid.yres - vid.fsize*5, 2, vid.fsize, hot, icol, 8);
#endif #endif

View File

@ -467,7 +467,7 @@ EX void gainItem(eItem it) {
if(chaosmode && gold() >= 300) if(chaosmode && gold() >= 300)
achievement_gain_once("CHAOS", rg::chaos); achievement_gain_once("CHAOS", rg::chaos);
#if ISMOBILE==1 #if ISMOBILE
if(g < lastsafety + R30*3/2 && g2 >= lastsafety + R30*3/2) if(g < lastsafety + R30*3/2 && g2 >= lastsafety + R30*3/2)
addMessage(XLAT("The Orb of Safety from the Land of Eternal Motion might save you.")); addMessage(XLAT("The Orb of Safety from the Land of Eternal Motion might save you."));
#endif #endif

View File

@ -230,7 +230,7 @@ EX void showMainMenu() {
dialog::addItem(XLAT(inSpecialMode() ? "reset special modes" : "back to the start menu"), 'R'); dialog::addItem(XLAT(inSpecialMode() ? "reset special modes" : "back to the start menu"), 'R');
string q; string q;
#if ISMOBILE==1 #if ISMOBILE
dialog::addItem(XLAT("visit the website"), 'q'); dialog::addItem(XLAT("visit the website"), 'q');
#else #else
q = quitsaves() ? "save" : "quit"; q = quitsaves() ? "save" : "quit";
@ -248,7 +248,7 @@ EX void showMainMenu() {
if(inv::on) if(inv::on)
dialog::addItem(XLAT("inventory"), 'i'); dialog::addItem(XLAT("inventory"), 'i');
#if ISMOBILE==1 #if ISMOBILE
#if CAP_ACHIEVE #if CAP_ACHIEVE
dialog::addItem(XLAT("leaderboards/achievements"), '3'); dialog::addItem(XLAT("leaderboards/achievements"), '3');
#endif #endif
@ -305,7 +305,7 @@ EX void showMainMenu() {
#endif #endif
else if(sym == SDLK_ESCAPE) else if(sym == SDLK_ESCAPE)
showMissionScreen(); showMissionScreen();
#if ISMOBILE==1 #if ISMOBILE
#ifdef HAVE_ACHIEVEMENTS #ifdef HAVE_ACHIEVEMENTS
else if(NUMBERKEY == '3') { else if(NUMBERKEY == '3') {
achievement_final(false); achievement_final(false);
@ -382,7 +382,7 @@ EX void enable_cheat() {
else if(!cheater) dialog::cheat_if_confirmed([] { else if(!cheater) dialog::cheat_if_confirmed([] {
cheater++; cheater++;
addMessage(XLAT("You activate your demonic powers!")); addMessage(XLAT("You activate your demonic powers!"));
#if ISMOBILE==0 #if !ISMOBILE
addMessage(XLAT("Shift+F, Shift+O, Shift+T, Shift+L, Shift+U, etc.")); addMessage(XLAT("Shift+F, Shift+O, Shift+T, Shift+L, Shift+U, etc."));
#endif #endif
popScreen(); popScreen();

View File

@ -44,7 +44,7 @@ string buildScoreDescription() {
} }
#endif #endif
#if ISMOBILE==1 #if ISMOBILE
int andmode; int andmode;

View File

@ -549,7 +549,7 @@ EX void initConfig() {
t[(int)'s'] = 16 + 6; t[(int)'s'] = 16 + 6;
t[(int)'a'] = 16 + 7; t[(int)'a'] = 16 + 7;
#if ISMOBILE==0 #if !ISMOBILE
t[SDLK_KP8] = 16 + 4; t[SDLK_KP8] = 16 + 4;
t[SDLK_KP6] = 16 + 5; t[SDLK_KP6] = 16 + 5;
t[SDLK_KP2] = 16 + 6; t[SDLK_KP2] = 16 + 6;
@ -572,7 +572,7 @@ EX void initConfig() {
t[(int)'p'] = 32 + 10; t[(int)'p'] = 32 + 10;
t[(int)'['] = 32 + pcCenter; t[(int)'['] = 32 + pcCenter;
#if ISMOBILE==0 #if !ISMOBILE
t[SDLK_UP] = 48 ; t[SDLK_UP] = 48 ;
t[SDLK_RIGHT] = 48 + 1; t[SDLK_RIGHT] = 48 + 1;
t[SDLK_DOWN] = 48 + 2; t[SDLK_DOWN] = 48 + 2;
@ -973,4 +973,4 @@ EX void handleInput(int delta) {
EX } EX }
} }

View File

@ -122,7 +122,7 @@ EX hint hints[] = {
[]() { return true; }, []() { return true; },
[]() { []() {
dialog::addInfo(XLAT( dialog::addInfo(XLAT(
#if ISMOBILE==1 #if ISMOBILE
"The 'world overview' shows all the lands in HyperRogue." "The 'world overview' shows all the lands in HyperRogue."
#else #else
"Press 'o' to see all the lands in HyperRogue." "Press 'o' to see all the lands in HyperRogue."
@ -457,12 +457,12 @@ EX void showMission() {
dialog::addItem(XLAT("inventory"), 'i'); dialog::addItem(XLAT("inventory"), 'i');
if(racing::on) if(racing::on)
dialog::addItem(XLAT("racing menu"), 'o'); dialog::addItem(XLAT("racing menu"), 'o');
#if ISMOBILE==0 #if !ISMOBILE
dialog::addItem(XLAT(quitsaves() ? "save" : "quit"), SDLK_F10); dialog::addItem(XLAT(quitsaves() ? "save" : "quit"), SDLK_F10);
#endif #endif
#if CAP_ANDROIDSHARE #if CAP_ANDROIDSHARE
dialog::addItem(XLAT("SHARE"), 's'-96); dialog::addItem(XLAT("SHARE"), 's'-96);
#endif #endif
} }
dialog::addItem(XLAT("message log"), 'l'); dialog::addItem(XLAT("message log"), 'l');

View File

@ -4,14 +4,7 @@
#include "../hyper.h" #include "../hyper.h"
#ifndef CAP_NCONF
#define CAP_NCONF 0
#endif
#if CAP_NCONF #if CAP_NCONF
#ifndef CAP_DRAW
#define CAP_DRAW 0
#endif
#define main nconf_main #define main nconf_main
#undef unordered_map #undef unordered_map
#undef self #undef self

View File

@ -913,10 +913,6 @@ void close() {
relmatrices.clear(); relmatrices.clear();
} }
#ifndef CAP_RVSLIDES
#define CAP_RVSLIDES (CAP_TOUR && !ISWEB)
#endif
#if CAP_COMMANDLINE #if CAP_COMMANDLINE
int readArgs() { int readArgs() {
using namespace arg; using namespace arg;

View File

@ -370,10 +370,6 @@ int dexp_comb_colors[16] = {
int coverage_style; int coverage_style;
EX vector<pair<hyperpoint, int> > coverage; EX vector<pair<hyperpoint, int> > coverage;
#ifndef CAP_KUEN_MAP
#define CAP_KUEN_MAP 0
#endif
#if CAP_KUEN_MAP #if CAP_KUEN_MAP
void draw_kuen_map() { void draw_kuen_map() {
SDL_Surface *kuen_map = SDL_CreateRGBSurface(SDL_SWSURFACE,512,512,32,0,0,0,0); SDL_Surface *kuen_map = SDL_CreateRGBSurface(SDL_SWSURFACE,512,512,32,0,0,0,0);

View File

@ -63,6 +63,14 @@
#define ISMINI 0 #define ISMINI 0
#endif #endif
#ifndef CAP_NCONF
#define CAP_NCONF 0
#endif
#ifndef CAP_DRAW
#define CAP_DRAW 0
#endif
#ifndef CAP_XGD #ifndef CAP_XGD
#define CAP_XGD (ISANDROID || ISFAKEMOBILE) #define CAP_XGD (ISANDROID || ISFAKEMOBILE)
#endif #endif
@ -85,6 +93,10 @@
#define NOLICENSE ISSTEAM #define NOLICENSE ISSTEAM
#endif #endif
#ifndef CAP_VERTEXBUFFER
#define CAP_VERTEXBUFFER (ISWEB)
#endif
#ifndef CAP_SHADER #ifndef CAP_SHADER
#define CAP_SHADER CAP_GL #define CAP_SHADER CAP_GL
#endif #endif
@ -153,6 +165,10 @@
#define CAP_SURFACE CAP_RUG #define CAP_SURFACE CAP_RUG
#endif #endif
#ifndef CAP_KUEN_MAP
#define CAP_KUEN_MAP 0
#endif
#ifndef CAP_EDIT #ifndef CAP_EDIT
#define CAP_EDIT (CAP_FILES && !ISWEB && !ISMINI) #define CAP_EDIT (CAP_FILES && !ISWEB && !ISMINI)
#endif #endif
@ -197,6 +213,10 @@
#define CAP_ROGUEVIZ 0 #define CAP_ROGUEVIZ 0
#endif #endif
#ifndef CAP_RVSLIDES
#define CAP_RVSLIDES (CAP_TOUR && !ISWEB)
#endif
#ifndef CAP_PROFILING #ifndef CAP_PROFILING
#define CAP_PROFILING 0 #define CAP_PROFILING 0
#endif #endif
@ -210,7 +230,7 @@
#endif #endif
#ifndef CAP_ORIENTATION #ifndef CAP_ORIENTATION
#define CAP_ORIENTATION ISMOBILE #define CAP_ORIENTATION (ISMOBILE || ISWEB)
#endif #endif
#ifndef CAP_MOUSEGRAB #ifndef CAP_MOUSEGRAB

View File

@ -1068,7 +1068,7 @@ EX void saveStats(bool emergency IS(false)) {
fprintf(f, "\n\n\n"); fprintf(f, "\n\n\n");
#if ISMOBILE==0 #if !ISMOBILE
DEBB(DF_INIT, ("Game statistics saved to ", scorefile)); DEBB(DF_INIT, ("Game statistics saved to ", scorefile));
addMessage(XLAT("Game statistics saved to %1", scorefile)); addMessage(XLAT("Game statistics saved to %1", scorefile));
#endif #endif
@ -1556,7 +1556,7 @@ EX void finishAll() {
saveStats(); saveStats();
#endif #endif
clearMemory(); clearMemory();
#if ISMOBILE==0 #if !ISMOBILE
cleargraph(); cleargraph();
#endif #endif