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

Merge pull request #108 from Quuxplusone/ifdef

Move all defaulting-of-`CAP_FOO` to sysconfig.h
This commit is contained in:
Zeno Rogue 2020-05-15 11:32:38 +02:00 committed by GitHub
commit daeff80ff5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 128 additions and 122 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

@ -380,7 +380,7 @@ void connection_debugger() {
string cap = its(k) + primes(last.second) + " -> " + its(get<1>(con)) + primes(get<0>(con)) + (get<2>(con) ? " (m) " : "");
dialog::addSelItem(cap, "go", '0' + k);
dialog::add_action([k, last, &sh, con] {
dialog::add_action([k, last, con] {
debug_polys.emplace_back(last.first * get_adj(debugged, last.second, k, -1), get<0>(con));
});
@ -689,4 +689,4 @@ EX void choose() {
}
EX }
}
}

View File

@ -9,11 +9,17 @@
namespace hr {
EX namespace bt {
#if CAP_BT
/** note: nihsolv and kd3 tilings return bt::in(). They are defined elsewhere, although some of bt:: functions are used for them */
EX bool in() { return cgflags & qBINARY; }
EX bool in() {
#if CAP_BT
return cgflags & qBINARY;
#else
return false;
#endif
}
#if CAP_BT
#if HDR
enum bindir {
bd_right = 0,

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");
@ -1269,36 +1269,34 @@ EX void configureOther() {
// dialog::addBoolItem_action(XLAT("forget faraway cells"), memory_saving_mode, 'y');
#if CAP_AUDIO
if(CAP_AUDIO) {
dialog::addSelItem(XLAT("background music volume"), its(musicvolume), 'b');
dialog::add_action([] {
dialog::editNumber(musicvolume, 0, 128, 10, 60, XLAT("background music volume"), "");
dialog::reaction = [] () {
#if CAP_SDLAUDIO
Mix_VolumeMusic(musicvolume);
#endif
#if ISANDROID
settingsChanged = true;
#endif
};
dialog::bound_low(0);
dialog::bound_up(MIX_MAX_VOLUME);
});
#if CAP_AUDIO
dialog::addSelItem(XLAT("background music volume"), its(musicvolume), 'b');
dialog::add_action([] {
dialog::editNumber(musicvolume, 0, 128, 10, 60, XLAT("background music volume"), "");
dialog::reaction = [] () {
#if CAP_SDLAUDIO
Mix_VolumeMusic(musicvolume);
#endif
#if ISANDROID
settingsChanged = true;
#endif
};
dialog::bound_low(0);
dialog::bound_up(MIX_MAX_VOLUME);
});
dialog::addSelItem(XLAT("sound effects volume"), its(effvolume), 'e');
dialog::add_action([] {
dialog::editNumber(effvolume, 0, 128, 10, 60, XLAT("sound effects volume"), "");
dialog::reaction = [] () {
#if ISANDROID
settingsChanged = true;
#endif
};
dialog::bound_low(0);
dialog::bound_up(MIX_MAX_VOLUME);
});
}
#endif
dialog::addSelItem(XLAT("sound effects volume"), its(effvolume), 'e');
dialog::add_action([] {
dialog::editNumber(effvolume, 0, 128, 10, 60, XLAT("sound effects volume"), "");
dialog::reaction = [] () {
#if ISANDROID
settingsChanged = true;
#endif
};
dialog::bound_low(0);
dialog::bound_up(MIX_MAX_VOLUME);
});
#endif
menuitem_sightrange('r');
@ -1317,12 +1315,10 @@ EX void configureInterface() {
gamescreen(3);
dialog::init(XLAT("interface"));
#if CAP_TRANS
if(CAP_TRANS) {
dialog::addSelItem(XLAT("language"), XLAT("EN"), 'l');
dialog::add_action_push(selectLanguageScreen);
}
#endif
#if CAP_TRANS
dialog::addSelItem(XLAT("language"), XLAT("EN"), 'l');
dialog::add_action_push(selectLanguageScreen);
#endif
dialog::addSelItem(XLAT("player character"), numplayers() > 1 ? "" : csname(vid.cs), 'g');
dialog::add_action_push(showCustomizeChar);
@ -1642,12 +1638,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 +1745,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
@ -2312,11 +2308,9 @@ EX void showSettings() {
dialog::addItem(XLAT("colors & aura"), 'c');
dialog::add_action_push(show_color_dialog);
#if CAP_SHMUP
if(CAP_SHMUP && !ISMOBILE) {
dialog::addSelItem(XLAT("keyboard & joysticks"), "", 'k');
dialog::add_action(multi::configure);
}
#if CAP_SHMUP && !ISMOBILE
dialog::addSelItem(XLAT("keyboard & joysticks"), "", 'k');
dialog::add_action(multi::configure);
#endif
dialog::addSelItem(XLAT("mouse & touchscreen"), "", 'm');
@ -2422,22 +2416,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

@ -433,16 +433,16 @@ hpcshape
ld alpha;
int area;
};
shared_ptr<gpdata_t> gpdata;
shared_ptr<gpdata_t> gpdata = nullptr;
#endif
int state;
int usershape_state;
int state = 0;
int usershape_state = 0;
/** contains the texture point coordinates for 3D models */
basic_textureinfo models_texture;
geometry_information() { last = NULL; state = usershape_state = 0; gpdata = NULL; }
geometry_information() { last = NULL; }
void require_basics() { if(state & 1) return; state |= 1; prepare_basics(); }
void require_shapes() { if(state & 2) return; state |= 2; prepare_shapes(); }

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

@ -732,7 +732,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
@ -741,7 +741,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

@ -289,6 +289,7 @@ EX namespace reg3 {
return Id;
}
#if CAP_CRYSTAL
int encode_coord(const crystal::coord& co) {
int c = 0;
for(int i=0; i<4; i++) c |= ((co[i]>>1) & 3) << (2*i);
@ -321,6 +322,7 @@ EX namespace reg3 {
}
}
};
#endif
struct hrmap_field3 : reg3::hrmap_quotient3 {

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

@ -1624,8 +1624,10 @@ EX void show() {
else if(uni == 'n' && !rug::rugged)
pushScreen(rug_geometry_choice);
#endif
else if(uni == 'g' && !rug::rugged && CAP_SDL)
#if CAP_SDL
else if(uni == 'g' && !rug::rugged)
rendernogl = !rendernogl;
#endif
else if(uni == 's') {
texturesize *= 2;
if(texturesize == 8192) texturesize = 64;

View File

@ -285,7 +285,7 @@ EX void show_memory_menu() {
}
EX bool protect_memory() {
if(!CAP_MEMORY_RESERVE) return false;
#if CAP_MEMORY_RESERVE
apply_memory_reserve();
if(reserve_limit && reserve_count < reserve_limit && !ignored_memory_warning) {
pushScreen(show_memory_menu);
@ -295,6 +295,7 @@ EX bool protect_memory() {
pushScreen(show_memory_menu);
return true;
}
#endif
return false;
}

View File

@ -358,13 +358,14 @@ EX always_false in;
/** 0 = no/unknown/disabled texture, 1 = rug, 2 = gradient, 3 = floor texture */
EX int texture_type(dqi_poly& p) {
if(!p.tinf) return 0;
if(!CAP_PNG) return 0;
#if CAP_PNG
if(!textures) return 0;
if(p.tinf == &rug::tinf) return 1;
#if MAXMDIM >= 4
if(p.tinf->texture_id == (int) floor_textures->renderedTexture)
return (p.tinf->tvertices[0][0] == 0) ? 2 : 3;
#endif
#endif
return 0;
}
@ -1732,8 +1733,13 @@ startanim perspective { "projection distance", no_init, [] {
}};
startanim rug { "Hypersian Rug", [] {
if(!CAP_RUG) { pick(); return; }
rug::init(), rug::rugged = false; }, [] {
#if CAP_RUG
rug::init();
rug::rugged = false;
#else
pick();
#endif
}, [] {
dynamicval<bool> b(rug::rugged, true);
rug::physics();
dynamicval<transmatrix> t(rug::rugView, cspin(1, 2, ticks / 3000.) * rug::rugView);

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
@ -387,7 +407,6 @@ extern "C" {
#define CAP_GLEW (CAP_GL && !ISMOBILE && !ISMAC && !ISLINUX && !ISWEB)
#endif
#if CAP_GL
#if CAP_GLEW
#include <GL/glew.h>
#else
@ -409,7 +428,6 @@ extern "C" {
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glext.h>
#endif
#endif
#endif

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