Skip to content

Commit

Permalink
overlay: add option to toggle game UI
Browse files Browse the repository at this point in the history
This adds an option to allow toggling the in-game UI.

Resolves LostArtefacts#1656.
  • Loading branch information
lahm86 committed Oct 4, 2024
1 parent 457a3a2 commit c0f136b
Show file tree
Hide file tree
Showing 14 changed files with 50 additions and 3 deletions.
3 changes: 3 additions & 0 deletions data/tr1/ship/cfg/TR1X_gameflow.json5
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,7 @@
"KEYMAP_SAVE": "Quick Save",
"KEYMAP_STEP_LEFT": "Step Left",
"KEYMAP_STEP_RIGHT": "Step Right",
"KEYMAP_TOGGLE_UI": "Toggle UI",
"KEYMAP_TURBO_CHEAT": "Turbo Speed",
"KEYMAP_USE_BIG_MEDI": "Large Medi",
"KEYMAP_USE_SMALL_MEDI": "Small Medi",
Expand Down Expand Up @@ -757,6 +758,8 @@
"OSD_TEXTURE_FILTER_BILINEAR": "bilinear",
"OSD_TEXTURE_FILTER_NN": "nearest-neighbor",
"OSD_TEXTURE_FILTER_SET": "Texture filter set to %s",
"OSD_UI_OFF": "UI disabled",
"OSD_UI_ON": "UI enabled",
"OSD_UNKNOWN_COMMAND": "Unknown command: %s",
"PASSPORT_EXIT_GAME": "Exit Game",
"PASSPORT_EXIT_TO_TITLE": "Exit to Title",
Expand Down
3 changes: 3 additions & 0 deletions data/tr1/ship/cfg/TR1X_gameflow_demo_pc.json5
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@
"KEYMAP_SAVE": "Quick Save",
"KEYMAP_STEP_LEFT": "Step Left",
"KEYMAP_STEP_RIGHT": "Step Right",
"KEYMAP_TOGGLE_UI": "Toggle UI",
"KEYMAP_TURBO_CHEAT": "Turbo Speed",
"KEYMAP_USE_BIG_MEDI": "Large Medi",
"KEYMAP_USE_SMALL_MEDI": "Small Medi",
Expand Down Expand Up @@ -250,6 +251,8 @@
"OSD_TEXTURE_FILTER_BILINEAR": "bilinear",
"OSD_TEXTURE_FILTER_NN": "nearest-neighbor",
"OSD_TEXTURE_FILTER_SET": "Texture filter set to %s",
"OSD_UI_OFF": "UI disabled",
"OSD_UI_ON": "UI enabled",
"OSD_UNKNOWN_COMMAND": "Unknown command: %s",
"PASSPORT_EXIT_GAME": "Exit Game",
"PASSPORT_EXIT_TO_TITLE": "Exit to Title",
Expand Down
3 changes: 3 additions & 0 deletions data/tr1/ship/cfg/TR1X_gameflow_ub.json5
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@
"KEYMAP_SAVE": "Quick Save",
"KEYMAP_STEP_LEFT": "Step Left",
"KEYMAP_STEP_RIGHT": "Step Right",
"KEYMAP_TOGGLE_UI": "Toggle UI",
"KEYMAP_TURBO_CHEAT": "Turbo Speed",
"KEYMAP_USE_BIG_MEDI": "Large Medi",
"KEYMAP_USE_SMALL_MEDI": "Small Medi",
Expand Down Expand Up @@ -322,6 +323,8 @@
"OSD_TEXTURE_FILTER_BILINEAR": "bilinear",
"OSD_TEXTURE_FILTER_NN": "nearest-neighbor",
"OSD_TEXTURE_FILTER_SET": "Texture filter set to %s",
"OSD_UI_OFF": "UI disabled",
"OSD_UI_ON": "UI enabled",
"OSD_UNKNOWN_COMMAND": "Unknown command: %s",
"PASSPORT_EXIT_GAME": "Exit Game",
"PASSPORT_EXIT_TO_TITLE": "Exit to Title",
Expand Down
1 change: 1 addition & 0 deletions docs/tr1/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
- added `/sfx` command
- added `/nextlevel` alias to `/endlevel` console command
- added `/quit` alias to `/exit` console command
- added an option to toggle the in-game UI, such as healthbars and ammo text (#1656)
- changed the easter egg console command to pack more punch
- changed `/set` console command to do fuzzy matching (LostArtefacts/libtrx#38)
- fixed console caret position off by a couple of pixels (regression from 3.0)
Expand Down
1 change: 1 addition & 0 deletions docs/tr1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ Not all options are turned on by default. Refer to `TR1X_ConfigTool.exe` for det
- added fade effects to displayed images
- added an option to use PS1 loading screens
- added a wireframe mode
- added an option to toggle in-game UI, such as healthbars and ammo text
- improved support for windowed mode

#### Gameplay
Expand Down
1 change: 1 addition & 0 deletions src/tr1/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ typedef struct {
} rendering;

struct {
bool enable_ui;
double text_scale;
double bar_scale;
UI_STYLE menu_style;
Expand Down
1 change: 1 addition & 0 deletions src/tr1/config_map.def
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,4 @@ CFG_BOOL(g_Config, profile.new_game_plus_unlock, false)
CFG_BOOL(g_Config, fix_animated_sprites, true)
CFG_BOOL(g_Config, enable_skybox, true)
CFG_BOOL(g_Config, enable_ps1_crystals, true)
CFG_BOOL(g_Config, ui.enable_ui, true)
3 changes: 3 additions & 0 deletions src/tr1/game/game_string.def
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ GS_DEFINE(KEYMAP_LEVEL_SKIP_CHEAT, "Level Skip")
GS_DEFINE(KEYMAP_TURBO_CHEAT, "Turbo Speed")
GS_DEFINE(KEYMAP_ENTER_CONSOLE, "Enter Console")
GS_DEFINE(KEYMAP_CHANGE_TARGET, "Change Target")
GS_DEFINE(KEYMAP_TOGGLE_UI, "Toggle UI")
GS_DEFINE(KEYMAP_CAMERA_UP, "Camera Up")
GS_DEFINE(KEYMAP_CAMERA_DOWN, "Camera Down")
GS_DEFINE(KEYMAP_CAMERA_LEFT, "Camera Left")
Expand Down Expand Up @@ -151,6 +152,8 @@ GS_DEFINE(OSD_PERSPECTIVE_FILTER_ON, "Perspective filter enabled")
GS_DEFINE(OSD_PERSPECTIVE_FILTER_OFF, "Perspective filter disabled")
GS_DEFINE(OSD_FPS_COUNTER_ON, "FPS counter enabled")
GS_DEFINE(OSD_FPS_COUNTER_OFF, "FPS counter disabled")
GS_DEFINE(OSD_UI_ON, "UI enabled")
GS_DEFINE(OSD_UI_OFF, "UI disabled")
GS_DEFINE(OSD_DOOR_OPEN, "Open Sesame!")
GS_DEFINE(OSD_DOOR_CLOSE, "Close Sesame!")
GS_DEFINE(OSD_DOOR_OPEN_FAIL, "No doors in Lara's proximity")
2 changes: 2 additions & 0 deletions src/tr1/game/option/option_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ static const TEXT_COLUMN_PLACEMENT CtrlTextPlacementNormal[] = {
{ INPUT_ROLE_FPS, GS_ID(KEYMAP_FPS), true },
{ INPUT_ROLE_BILINEAR, GS_ID(KEYMAP_BILINEAR), true },
{ INPUT_ROLE_ENTER_CONSOLE, GS_ID(KEYMAP_ENTER_CONSOLE), true },
{ INPUT_ROLE_TOGGLE_UI, GS_ID(KEYMAP_TOGGLE_UI), true },
// end
{ COL_END, NULL, false },
};
Expand Down Expand Up @@ -184,6 +185,7 @@ static const TEXT_COLUMN_PLACEMENT CtrlTextPlacementCheats[] = {
{ INPUT_ROLE_LEVEL_SKIP_CHEAT, GS_ID(KEYMAP_LEVEL_SKIP_CHEAT), true },
{ INPUT_ROLE_TURBO_CHEAT, GS_ID(KEYMAP_TURBO_CHEAT), true },
{ INPUT_ROLE_ENTER_CONSOLE, GS_ID(KEYMAP_ENTER_CONSOLE), true },
{ INPUT_ROLE_TOGGLE_UI, GS_ID(KEYMAP_TOGGLE_UI), true },
// end
{ COL_END, NULL, false },
};
Expand Down
11 changes: 10 additions & 1 deletion src/tr1/game/overlay.c
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,11 @@ void Overlay_HideGameInfo(void)
void Overlay_DrawGameInfo(void)
{
M_ResetBarLocations();
if (!g_Config.ui.enable_ui) {
M_RemoveAmmoText();
return;
}

Overlay_BarDrawHealth();
M_BarDrawAir();
M_BarDrawEnemy();
Expand All @@ -724,7 +729,7 @@ void Overlay_DrawGameInfo(void)

void Overlay_DrawFPSInfo(void)
{
if (g_Config.rendering.enable_fps_counter) {
if (g_Config.rendering.enable_fps_counter && g_Config.ui.enable_ui) {
const int32_t text_offset_x = 3;
const int32_t text_height = 17;
const int32_t text_inv_offset_y = 3;
Expand Down Expand Up @@ -781,6 +786,10 @@ void Overlay_DrawFPSInfo(void)

void Overlay_AddPickup(const GAME_OBJECT_ID object_id)
{
if (!g_Config.ui.enable_ui) {
return;
}

int32_t grid_x = -1;
int32_t grid_y = -1;
for (int i = 0; i < MAX_PICKUPS; i++) {
Expand Down
4 changes: 3 additions & 1 deletion src/tr1/game/phase/phase_inventory.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ static void Inv_Draw(RING_INFO *ring, IMOTION_INFO *motion)
switch (inv_item->object_id) {
case O_MEDI_OPTION:
case O_BIGMEDI_OPTION:
Overlay_BarDrawHealth();
if (g_Config.ui.enable_ui) {
Overlay_BarDrawHealth();
}
break;

default:
Expand Down
6 changes: 6 additions & 0 deletions src/tr1/game/shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,12 @@ void Shell_ProcessInput(void)
Config_Write();
}

if (g_InputDB.toggle_ui) {
g_Config.ui.enable_ui ^= true;
Console_Log(g_Config.ui.enable_ui ? GS(OSD_UI_ON) : GS(OSD_UI_OFF));
Config_Write();
}

if (g_InputDB.turbo_cheat) {
Clock_CycleTurboSpeed(!g_Input.slow);
}
Expand Down
4 changes: 3 additions & 1 deletion src/tr1/global/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,7 @@ typedef union INPUT_STATE {
uint64_t menu_back : 1;
uint64_t enter_console : 1;
uint64_t change_target : 1;
uint64_t toggle_ui : 1;
};
} INPUT_STATE;

Expand Down Expand Up @@ -1005,7 +1006,8 @@ typedef enum {
INPUT_ROLE_BILINEAR = 32,
INPUT_ROLE_ENTER_CONSOLE = 33,
INPUT_ROLE_CHANGE_TARGET = 34,
INPUT_ROLE_NUMBER_OF = 35,
INPUT_ROLE_TOGGLE_UI = 35,
INPUT_ROLE_NUMBER_OF = 36,
} INPUT_ROLE;

typedef enum {
Expand Down
10 changes: 10 additions & 0 deletions src/tr1/specific/s_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ static INPUT_SCANCODE m_Layout[INPUT_LAYOUT_NUMBER_OF][INPUT_ROLE_NUMBER_OF] = {
SDL_SCANCODE_F3, // INPUT_ROLE_BILINEAR
SDL_SCANCODE_SLASH, // INPUT_ROLE_ENTER_CONSOLE
SDL_SCANCODE_Z, // INPUT_ROLE_CHANGE_TARGET
SDL_SCANCODE_H, // INPUT_ROLE_TOGGLE_UI
},

// custom user controls
Expand Down Expand Up @@ -103,6 +104,7 @@ static INPUT_SCANCODE m_Layout[INPUT_LAYOUT_NUMBER_OF][INPUT_ROLE_NUMBER_OF] = {
SDL_SCANCODE_F3, // INPUT_ROLE_BILINEAR
SDL_SCANCODE_SLASH, // INPUT_ROLE_ENTER_CONSOLE
SDL_SCANCODE_Z, // INPUT_ROLE_CHANGE_TARGET
SDL_SCANCODE_H, // INPUT_ROLE_TOGGLE_UI
},

{
Expand Down Expand Up @@ -141,6 +143,7 @@ static INPUT_SCANCODE m_Layout[INPUT_LAYOUT_NUMBER_OF][INPUT_ROLE_NUMBER_OF] = {
SDL_SCANCODE_F3, // INPUT_ROLE_BILINEAR
SDL_SCANCODE_SLASH, // INPUT_ROLE_ENTER_CONSOLE
SDL_SCANCODE_Z, // INPUT_ROLE_CHANGE_TARGET
SDL_SCANCODE_H, // INPUT_ROLE_TOGGLE_UI
},

{
Expand Down Expand Up @@ -179,6 +182,7 @@ static INPUT_SCANCODE m_Layout[INPUT_LAYOUT_NUMBER_OF][INPUT_ROLE_NUMBER_OF] = {
SDL_SCANCODE_F3, // INPUT_ROLE_BILINEAR
SDL_SCANCODE_SLASH, // INPUT_ROLE_ENTER_CONSOLE
SDL_SCANCODE_Z, // INPUT_ROLE_CHANGE_TARGET
SDL_SCANCODE_H, // INPUT_ROLE_TOGGLE_UI
}
// clang-format on
};
Expand Down Expand Up @@ -222,6 +226,7 @@ static CONTROLLER_MAP
{ BT_BUTTON, {SDL_CONTROLLER_BUTTON_INVALID}, 0 }, // INPUT_ROLE_BILINEAR
{ BT_BUTTON, {SDL_CONTROLLER_BUTTON_INVALID}, 0 }, // INPUT_ROLE_ENTER_CONSOLE
{ BT_BUTTON, {SDL_CONTROLLER_BUTTON_LEFTSTICK}, 0 }, // INPUT_ROLE_CHANGE_TARGET
{ BT_BUTTON, {SDL_CONTROLLER_BUTTON_INVALID}, 0 }, // INPUT_ROLE_TOGGLE_UI
},

{
Expand Down Expand Up @@ -260,6 +265,7 @@ static CONTROLLER_MAP
{ BT_BUTTON, {SDL_CONTROLLER_BUTTON_INVALID}, 0 }, // INPUT_ROLE_BILINEAR
{ BT_BUTTON, {SDL_CONTROLLER_BUTTON_INVALID}, 0 }, // INPUT_ROLE_ENTER_CONSOLE
{ BT_BUTTON, {SDL_CONTROLLER_BUTTON_LEFTSTICK}, 0 }, // INPUT_ROLE_CHANGE_TARGET
{ BT_BUTTON, {SDL_CONTROLLER_BUTTON_INVALID}, 0 }, // INPUT_ROLE_TOGGLE_UI
},

{
Expand Down Expand Up @@ -298,6 +304,7 @@ static CONTROLLER_MAP
{ BT_BUTTON, {SDL_CONTROLLER_BUTTON_INVALID}, 0 }, // INPUT_ROLE_BILINEAR
{ BT_BUTTON, {SDL_CONTROLLER_BUTTON_INVALID}, 0 }, // INPUT_ROLE_ENTER_CONSOLE
{ BT_BUTTON, {SDL_CONTROLLER_BUTTON_LEFTSTICK}, 0 }, // INPUT_ROLE_CHANGE_TARGET
{ BT_BUTTON, {SDL_CONTROLLER_BUTTON_INVALID}, 0 }, // INPUT_ROLE_TOGGLE_UI
},

{
Expand Down Expand Up @@ -336,6 +343,7 @@ static CONTROLLER_MAP
{ BT_BUTTON, {SDL_CONTROLLER_BUTTON_INVALID}, 0 }, // INPUT_ROLE_BILINEAR
{ BT_BUTTON, {SDL_CONTROLLER_BUTTON_INVALID}, 0 }, // INPUT_ROLE_ENTER_CONSOLE
{ BT_BUTTON, {SDL_CONTROLLER_BUTTON_LEFTSTICK}, 0 }, // INPUT_ROLE_CHANGE_TARGET
{ BT_BUTTON, {SDL_CONTROLLER_BUTTON_INVALID}, 0 }, // INPUT_ROLE_TOGGLE_UI
}
// clang-format on
};
Expand Down Expand Up @@ -868,6 +876,7 @@ static INPUT_STATE M_GetControllerState(
state.load |= M_GetBindState(INPUT_ROLE_LOAD, cntlr_layout_num);
state.toggle_fps_counter |= M_GetBindState(INPUT_ROLE_FPS, cntlr_layout_num);
state.toggle_bilinear_filter |= M_GetBindState(INPUT_ROLE_BILINEAR, cntlr_layout_num);
state.toggle_ui |= M_GetBindState(INPUT_ROLE_TOGGLE_UI, cntlr_layout_num);
state.change_target |= M_GetBindState(INPUT_ROLE_CHANGE_TARGET, cntlr_layout_num);
state.menu_confirm |= M_JoyBtn(SDL_CONTROLLER_BUTTON_A);
state.menu_back |= M_JoyBtn(SDL_CONTROLLER_BUTTON_B);
Expand Down Expand Up @@ -982,6 +991,7 @@ INPUT_STATE S_Input_GetCurrentState(
linput.toggle_fps_counter = M_Key(INPUT_ROLE_FPS, layout_num);
linput.toggle_bilinear_filter = M_Key(INPUT_ROLE_BILINEAR, layout_num);
linput.toggle_perspective_filter = KEY_DOWN(SDL_SCANCODE_F4);
linput.toggle_ui = M_Key(INPUT_ROLE_TOGGLE_UI, layout_num);
// clang-format on

if (m_Controller) {
Expand Down

0 comments on commit c0f136b

Please sign in to comment.