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;
displayfr(vid.xres/2, vid.yres/4, 2, vid.fsize * 2, achievementMessage[0], col & 0xFFFF00, 8);
int w = 2 * vid.fsize;
#if ISMOBILE==0
#if !ISMOBILE
while(w>3 && textwidth(w, achievementMessage[1]) > vid.xres) w--;
#endif
displayfr(vid.xres/2, vid.yres/4 + vid.fsize*2, 2, w, achievementMessage[1], col, 8);
w = vid.fsize;
#if ISMOBILE==0
#if !ISMOBILE
while(w>3 && textwidth(w, achievementMessage[2]) > vid.xres) w--;
#endif
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);
if(items[itTreat] == 1) {
#if ISMOBILE==0
#if !ISMOBILE
addMessage(XLAT("Hint: use arrow keys to scroll."));
#endif
}
else if(items[itTreat] == 2) {
#if ISMOBILE==0
#if !ISMOBILE
addMessage(XLAT("Hint: press 1 2 3 4 to change the projection."));
#endif
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -357,7 +357,7 @@ EX string generateHelpForItem(eItem it) {
" You need to go deep to collect lots of them.");
}
#if ISMOBILE==1
#if ISMOBILE
if(it == itOrbSafety)
help += XLAT("This might be very useful for devices with limited memory.");
#else
@ -525,7 +525,7 @@ void addMinefieldExplanation(string& s) {
);
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.");
#else
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(); }
#if ISMOBILE==1
#if ISMOBILE
namespace leader { void showMenu(); void handleKey(int sym, int uni); }
#endif
@ -740,7 +740,7 @@ int textwidth(int siz, const string &str);
int gl_width(int size, const char *s);
#endif
#ifdef ISMOBILE
#if ISMOBILE
extern int andmode;
extern bool longclick;
extern bool useRangedOrb;

View File

@ -30,10 +30,6 @@
#define EMSCRIPTEN
#endif
#ifndef CAP_ORIENTATION
#define CAP_ORIENTATION 1
#endif
#ifdef FAKEWEB
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(); }

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);
}
#if ISMOBILE==0
#if !ISMOBILE
string hot = XLAT1("Hotkey: "); hot += getcstat;
displaystr(vid.xres/2, vid.yres - vid.fsize*5, 2, vid.fsize, hot, icol, 8);
#endif

View File

@ -467,7 +467,7 @@ EX void gainItem(eItem it) {
if(chaosmode && gold() >= 300)
achievement_gain_once("CHAOS", rg::chaos);
#if ISMOBILE==1
#if ISMOBILE
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."));
#endif

View File

@ -230,7 +230,7 @@ EX void showMainMenu() {
dialog::addItem(XLAT(inSpecialMode() ? "reset special modes" : "back to the start menu"), 'R');
string q;
#if ISMOBILE==1
#if ISMOBILE
dialog::addItem(XLAT("visit the website"), 'q');
#else
q = quitsaves() ? "save" : "quit";
@ -248,7 +248,7 @@ EX void showMainMenu() {
if(inv::on)
dialog::addItem(XLAT("inventory"), 'i');
#if ISMOBILE==1
#if ISMOBILE
#if CAP_ACHIEVE
dialog::addItem(XLAT("leaderboards/achievements"), '3');
#endif
@ -305,7 +305,7 @@ EX void showMainMenu() {
#endif
else if(sym == SDLK_ESCAPE)
showMissionScreen();
#if ISMOBILE==1
#if ISMOBILE
#ifdef HAVE_ACHIEVEMENTS
else if(NUMBERKEY == '3') {
achievement_final(false);
@ -382,7 +382,7 @@ EX void enable_cheat() {
else if(!cheater) dialog::cheat_if_confirmed([] {
cheater++;
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."));
#endif
popScreen();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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