1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-24 17:10:36 +00:00

Eliminate some use of CAP_FOO and ISFOO outside of the preprocessor.

The old code worked, but it's strange to use these macros as if
they were C++ `bool` variables at runtime.
This commit is contained in:
Arthur O'Dwyer 2020-05-03 20:57:34 -04:00
parent f2b7746c1b
commit 3e3457bd81
4 changed files with 48 additions and 45 deletions

View File

@ -1270,7 +1270,6 @@ 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"), "");
@ -1297,7 +1296,6 @@ EX void configureOther() {
dialog::bound_low(0);
dialog::bound_up(MIX_MAX_VOLUME);
});
}
#endif
menuitem_sightrange('r');
@ -1318,10 +1316,8 @@ EX void configureInterface() {
dialog::init(XLAT("interface"));
#if CAP_TRANS
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');
@ -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) {
#if CAP_SHMUP && !ISMOBILE
dialog::addSelItem(XLAT("keyboard & joysticks"), "", 'k');
dialog::add_action(multi::configure);
}
#endif
dialog::addSelItem(XLAT("mouse & touchscreen"), "", 'm');

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;
}
@ -1730,8 +1731,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);