From ecc57ec1a0fb4b9e06a3f8bf0a2f17a6acae7f1f Mon Sep 17 00:00:00 2001 From: lahm86 <33758420+lahm86@users.noreply.github.com> Date: Mon, 3 Apr 2023 19:42:37 +0100 Subject: [PATCH] overlay: fix FPS, healthbar, and arrows from overlapping Resolves #787. --- CHANGELOG.md | 1 + src/game/game/game_pause.c | 4 +-- src/game/inventory/inventory.c | 9 ++++-- src/game/inventory/inventory_ring.c | 22 +++++++++++++++ src/game/overlay.c | 43 +++++++++++++++++++++++++++-- src/game/overlay.h | 3 +- src/game/stats.c | 4 +-- src/global/types.h | 7 +++-- 8 files changed, 80 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4e8935dd1..8b7daa54bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ - fixed the text and bar scaling from being able to be set below the max and min (#698) - fixed a data issue in Colosseum, which prevented a bat from triggering (#750) - fixed lightning and gun flash continuing to animate in the inventory, pause and statistics screens (#767) +- fixed the FPS, healthbar, and arrows from overlapping on the inventory screen (#787) - improved the control of Lara's braid to result in smoother animation and to detect floor collision (#761) - increased the number of effects from 100 to 1000 (#623) - removed the fix_pyramid_secret gameflow sequence (now handled by data injection) (#788) diff --git a/src/game/game/game_pause.c b/src/game/game/game_pause.c index 4bc75f8c9c..6531d9aab8 100644 --- a/src/game/game/game_pause.c +++ b/src/game/game/game_pause.c @@ -150,7 +150,7 @@ bool Game_Pause(void) Music_Pause(); Sound_StopAmbientSounds(); Sound_StopAllSamples(); - g_GameInfo.status = GMS_IN_PAUSE; + g_GameInfo.status |= GMS_IN_PAUSE; Output_FadeToSemiBlack(true); int32_t select = Game_Pause_Loop(); @@ -159,6 +159,6 @@ bool Game_Pause(void) Music_Unpause(); Requester_Remove(&m_PauseRequester); Game_Pause_RemoveText(); - g_GameInfo.status = GMS_IN_GAME; + g_GameInfo.status &= ~GMS_IN_PAUSE; return select < 0; } diff --git a/src/game/inventory/inventory.c b/src/game/inventory/inventory.c index b8c54fd55a..851c5045c0 100644 --- a/src/game/inventory/inventory.c +++ b/src/game/inventory/inventory.c @@ -476,7 +476,10 @@ static int32_t Inv_ConstructAndDisplay(int inv_mode) Inv_Ring_NotActive(); } - Overlay_DrawFPSInfo(); + bool inv_ring_above = g_InvMode == INV_GAME_MODE + && ((ring.type == RT_MAIN && g_InvKeysObjects) + || (ring.type == RT_OPTION && g_InvMainObjects)); + Overlay_DrawFPSInfo(inv_ring_above); Text_Draw(); m_InvNFrames = Output_DumpScreen(); @@ -1001,8 +1004,8 @@ static int32_t Inv_ConstructAndDisplay(int inv_mode) int32_t Inv_Display(int inv_mode) { - g_GameInfo.status = GMS_IN_INVENTORY; + g_GameInfo.status |= GMS_IN_INVENTORY; int32_t inv_result = Inv_ConstructAndDisplay(inv_mode); - g_GameInfo.status = GMS_IN_GAME; + g_GameInfo.status &= ~GMS_IN_INVENTORY; return inv_result; } diff --git a/src/game/inventory/inventory_ring.c b/src/game/inventory/inventory_ring.c index 1e99235411..d832f9d95c 100644 --- a/src/game/inventory/inventory_ring.c +++ b/src/game/inventory/inventory_ring.c @@ -1,5 +1,6 @@ #include "game/inventory/inventory_ring.h" +#include "config.h" #include "game/gameflow.h" #include "game/inventory.h" #include "game/inventory/inventory_vars.h" @@ -11,6 +12,7 @@ #include "global/vars.h" #include "math/math_misc.h" +#include #include #include @@ -343,6 +345,26 @@ void Inv_Ring_Active(INVENTORY_ITEM *inv_item) default: break; } + + if (inv_item->object_number == O_MEDI_OPTION + || inv_item->object_number == O_BIGMEDI_OPTION) { + if (g_Config.healthbar_location == BL_TOP_LEFT) { + Text_Hide(m_InvUpArrow1, true); + } else if (g_Config.healthbar_location == BL_TOP_RIGHT) { + Text_Hide(m_InvUpArrow2, true); + } else if (g_Config.healthbar_location == BL_BOTTOM_LEFT) { + Text_Hide(m_InvDownArrow1, true); + } else if (g_Config.healthbar_location == BL_BOTTOM_RIGHT) { + Text_Hide(m_InvDownArrow2, true); + } + g_GameInfo.status |= GMS_IN_INVENTORY_HEALTH; + } else { + Text_Hide(m_InvUpArrow1, false); + Text_Hide(m_InvUpArrow2, false); + Text_Hide(m_InvDownArrow1, false); + Text_Hide(m_InvDownArrow2, false); + g_GameInfo.status &= ~GMS_IN_INVENTORY_HEALTH; + } } void Inv_Ring_NotActive(void) diff --git a/src/game/overlay.c b/src/game/overlay.c index b79d8f89a7..a565009183 100644 --- a/src/game/overlay.c +++ b/src/game/overlay.c @@ -200,6 +200,15 @@ static void Overlay_BarGetLocation( - m_BarOffsetY[bar_info->location]; } + if ((g_GameInfo.status & GMS_IN_INVENTORY) + && (bar_info->location == BL_TOP_CENTER + || bar_info->location == BL_BOTTOM_CENTER)) { + double scale_bar_to_text = + g_Config.ui.text_scale / g_Config.ui.bar_scale; + *y = screen_margin_v + m_BarOffsetY[bar_info->location] + + scale_bar_to_text * (TEXT_HEIGHT + bar_spacing); + } + m_BarOffsetY[bar_info->location] += *height + bar_spacing; } @@ -482,11 +491,21 @@ void Overlay_DrawPickups(void) } } -void Overlay_DrawFPSInfo(void) +void Overlay_DrawFPSInfo(bool inv_ring_above) { static int32_t elapsed = 0; if (g_Config.rendering.enable_fps_counter) { + static int32_t elapsed = 0; + + const int32_t text_offset_x = 3; + const int32_t text_height = 17; + const int32_t text_inv_offset_y = 3; + double scale_fps_to_bar = + g_Config.ui.bar_scale / g_Config.ui.text_scale; + int16_t x = 21; + int16_t y = 10; + if (Clock_GetMS() - elapsed >= 1000) { if (m_FPSText) { char fps_buf[20]; @@ -501,6 +520,26 @@ void Overlay_DrawFPSInfo(void) g_FPSCounter = 0; elapsed = Clock_GetMS(); } + + bool inv_health_showable = (g_GameInfo.status & GMS_IN_INVENTORY_HEALTH) + && m_HealthBar.location == BL_TOP_LEFT; + bool game_bar_showable = !(g_GameInfo.status & GMS_IN_INVENTORY) + && (m_HealthBar.location == BL_TOP_LEFT + || m_AirBar.location == BL_TOP_LEFT + || m_EnemyBar.location == BL_TOP_LEFT); + + if (inv_health_showable || game_bar_showable) { + x = (x * scale_fps_to_bar) + text_offset_x; + y = text_height + + scale_fps_to_bar * (y + m_BarOffsetY[BL_TOP_LEFT]); + } else if ( + (g_GameInfo.status & GMS_IN_INVENTORY) && inv_ring_above) { + y += (text_height * 2) + text_inv_offset_y; + } else { + y += text_height; + } + + Text_SetPos(m_FPSText, x, y); } else if (m_FPSText) { Text_Remove(m_FPSText); m_FPSText = NULL; @@ -515,7 +554,7 @@ void Overlay_DrawGameInfo(void) Overlay_BarDrawEnemy(); Overlay_DrawPickups(); Overlay_DrawAmmoInfo(); - Overlay_DrawFPSInfo(); + Overlay_DrawFPSInfo(false); Text_Draw(); } diff --git a/src/game/overlay.h b/src/game/overlay.h index 604019a165..ffa2b3281a 100644 --- a/src/game/overlay.h +++ b/src/game/overlay.h @@ -2,6 +2,7 @@ #include "global/types.h" +#include #include struct BAR_INFO; @@ -17,7 +18,7 @@ void Overlay_BarDrawEnemy(void); void Overlay_RemoveAmmoText(void); void Overlay_DrawAmmoInfo(void); void Overlay_DrawPickups(void); -void Overlay_DrawFPSInfo(void); +void Overlay_DrawFPSInfo(bool inv_ring_above); void Overlay_DrawGameInfo(void); void Overlay_AddPickup(int16_t object_num); diff --git a/src/game/stats.c b/src/game/stats.c index 448c31f758..e707027ac4 100644 --- a/src/game/stats.c +++ b/src/game/stats.c @@ -271,7 +271,7 @@ void Stats_Show(int32_t level_num) return; } - g_GameInfo.status = GMS_IN_STATS; + g_GameInfo.status |= GMS_IN_STATS; char buf[100]; char time_str[100]; @@ -381,7 +381,7 @@ void Stats_Show(int32_t level_num) } Output_FadeReset(); - g_GameInfo.status = GMS_IN_GAME; + g_GameInfo.status &= ~GMS_IN_STATS; } void Stats_ShowTotal(const char *filename) diff --git a/src/global/types.h b/src/global/types.h index 6eeea81bfd..ac8f4256c6 100644 --- a/src/global/types.h +++ b/src/global/types.h @@ -1566,9 +1566,10 @@ typedef struct RESUME_INFO { typedef enum GAME_STATUS { GMS_IN_GAME = 0, - GMS_IN_INVENTORY = 1, - GMS_IN_PAUSE = 2, - GMS_IN_STATS = 3, + GMS_IN_INVENTORY = 1 << 0, + GMS_IN_PAUSE = 1 << 1, + GMS_IN_STATS = 1 << 2, + GMS_IN_INVENTORY_HEALTH = 1 << 3, } GAME_STATUS; typedef struct GAME_INFO {