mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-11-23 21:07:17 +00:00
CAP_MEMORY_RESERVE and memory reserve handled in mobile (if CAP_MEMORY_RESERVE was 1)
This commit is contained in:
parent
977c5f2d69
commit
fe635cc7d8
5
hud.cpp
5
hud.cpp
@ -652,12 +652,15 @@ void drawStats() {
|
||||
string vers = VER;
|
||||
if(!nofps) vers += XLAT(" fps: ") + its(calcfps());
|
||||
|
||||
#if CAP_MEMORY_RESERVE
|
||||
if(reserve_limit && reserve_count < reserve_limit) {
|
||||
vers += " " + its(reserve_count) + "/" + its(reserve_limit) + " MB";
|
||||
if(displayButtonS(4, vid.yres - 4 - vid.fsize/2, vers, 0xFF2020, 0, vid.fsize/2))
|
||||
getcstat = PSEUDOKEY_MEMORY, instat = true;
|
||||
}
|
||||
else if(displayButtonS(4, vid.yres - 4 - vid.fsize/2, vers, 0x202020, 0, vid.fsize/2)) {
|
||||
else
|
||||
#endif
|
||||
if(displayButtonS(4, vid.yres - 4 - vid.fsize/2, vers, 0x202020, 0, vid.fsize/2)) {
|
||||
mouseovers = XLAT("frames per second"),
|
||||
getcstat = SDLK_F1,
|
||||
instat = true,
|
||||
|
1
init.cpp
1
init.cpp
@ -225,6 +225,7 @@ void shareScore(MOBPAR_FORMAL);
|
||||
|
||||
void mobile_draw(MOBPAR_FORMAL) {
|
||||
|
||||
apply_memory_reserve();
|
||||
optimizeview();
|
||||
|
||||
int lastt = ticks; ticks = SDL_GetTicks();
|
||||
|
@ -195,6 +195,7 @@ void reserve_handler() {
|
||||
}
|
||||
|
||||
void apply_memory_reserve() {
|
||||
#if CAP_MEMORY_RESERVE
|
||||
if(reserve_count > 0) std::set_new_handler(default_handler);
|
||||
if(reserve_limit > max_reserve) reserve_limit = max_reserve;
|
||||
if(reserve_limit < 0) reserve_limit = 0;
|
||||
@ -214,6 +215,7 @@ void apply_memory_reserve() {
|
||||
default_handler = std::get_new_handler();
|
||||
#endif
|
||||
if(reserve_count > 0) std::set_new_handler(reserve_handler);
|
||||
#endif
|
||||
}
|
||||
|
||||
void memory_for_lib() {
|
||||
@ -250,6 +252,7 @@ void show_memory_menu() {
|
||||
|
||||
dialog::addBoolItem_action(XLAT("show memory warnings"), show_memory_warning, 'w');
|
||||
|
||||
#if CAP_MEMORY_RESERVE
|
||||
if(reserve_limit > 0 && reserve_count < reserve_limit) {
|
||||
dialog::addItem(XLAT("just let me find Orb of Safety or finish the game"), 'l');
|
||||
dialog::add_action([] { ignored_memory_warning = true; popScreen(); });
|
||||
@ -264,6 +267,7 @@ void show_memory_menu() {
|
||||
dialog::bound_up(max_reserve);
|
||||
dialog::reaction = apply_memory_reserve;
|
||||
});
|
||||
#endif
|
||||
|
||||
dialog::addItem(XLAT("clear caches"), 'c');
|
||||
dialog::add_action([] { callhooks(hooks_clear_cache); });
|
||||
@ -273,6 +277,7 @@ void show_memory_menu() {
|
||||
}
|
||||
|
||||
bool protect_memory() {
|
||||
if(!CAP_MEMORY_RESERVE) return false;
|
||||
if(reserve_limit && reserve_count < reserve_limit && !ignored_memory_warning) {
|
||||
pushScreen(show_memory_menu);
|
||||
return true;
|
||||
|
@ -496,4 +496,8 @@ union SDL_Event;
|
||||
#define CAP_FIELD (!(ISMINI))
|
||||
#endif
|
||||
|
||||
#ifndef CAP_MEMORY_RESERVE
|
||||
#define CAP_MEMORY_RESERVE (!ISMOBILE)
|
||||
#endif
|
||||
|
||||
#undef TRANSPARENT
|
||||
|
Loading…
Reference in New Issue
Block a user