mirror of
				https://github.com/zenorogue/hyperrogue.git
				synced 2025-10-26 03:17:39 +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:
		
							
								
								
									
										74
									
								
								config.cpp
									
									
									
									
									
								
							
							
						
						
									
										74
									
								
								config.cpp
									
									
									
									
									
								
							| @@ -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); | ||||
| @@ -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'); | ||||
|   | ||||
							
								
								
									
										4
									
								
								rug.cpp
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								rug.cpp
									
									
									
									
									
								
							| @@ -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; | ||||
|   | ||||
| @@ -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; | ||||
|   } | ||||
|  | ||||
|   | ||||
| @@ -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); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Arthur O'Dwyer
					Arthur O'Dwyer