From 454d133db749927616bcd405b1c6c27214449f62 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Sun, 13 Apr 2025 00:13:00 +0200 Subject: [PATCH] tr2/option: add fov to the graphic options Resolves #2728. --- data/tr2/ship/cfg/TR2X_strings.json5 | 2 ++ src/tr2/game/game_string.def | 2 ++ src/tr2/game/ui/widgets/graphics_dialog.c | 24 +++++++++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/data/tr2/ship/cfg/TR2X_strings.json5 b/data/tr2/ship/cfg/TR2X_strings.json5 index 27f4716f2..9df4028db 100644 --- a/data/tr2/ship/cfg/TR2X_strings.json5 +++ b/data/tr2/ship/cfg/TR2X_strings.json5 @@ -474,8 +474,10 @@ "DETAIL_FLOAT_FMT": "%.1f", "DETAIL_FOG_END": "Fog end", "DETAIL_FOG_START": "Fog start", + "DETAIL_FOV": "Field of view", "DETAIL_INTEGER_FMT": "%d", "DETAIL_TITLE": "Graphic Options", + "DETAIL_USE_PSX_FOV": "Use PSX FOV", "DETAIL_WATER_COLOR_B": "Water color (B)", "DETAIL_WATER_COLOR_G": "Water color (G)", "DETAIL_WATER_COLOR_R": "Water color (R)", diff --git a/src/tr2/game/game_string.def b/src/tr2/game/game_string.def index 72d31ae82..7dee247d8 100644 --- a/src/tr2/game/game_string.def +++ b/src/tr2/game/game_string.def @@ -42,3 +42,5 @@ GS_DEFINE(OSD_HARDWARE_RENDERING, "Hardware rendering") GS_DEFINE(OSD_SOFTWARE_RENDERING, "Software rendering") GS_DEFINE(OSD_PERSPECTIVE_FILTER_ON, "Perspective correction: on") GS_DEFINE(OSD_PERSPECTIVE_FILTER_OFF, "Perspective correction: off") +GS_DEFINE(DETAIL_FOV, "Field of view") +GS_DEFINE(DETAIL_USE_PSX_FOV, "Use PSX FOV") diff --git a/src/tr2/game/ui/widgets/graphics_dialog.c b/src/tr2/game/ui/widgets/graphics_dialog.c index c26453d0b..bc4cec418 100644 --- a/src/tr2/game/ui/widgets/graphics_dialog.c +++ b/src/tr2/game/ui/widgets/graphics_dialog.c @@ -104,6 +104,22 @@ static M_OPTION m_Options[] = { .misc = 2, }, + { + .option_type = COT_INT32, + .label_id = GS_ID(DETAIL_FOV), + .target = &g_Config.visuals.fov, + .min_value = 30, + .max_value = 150, + .delta_slow = 1, + .delta_fast = 10, + }, + + { + .option_type = COT_BOOL, + .label_id = GS_ID(DETAIL_USE_PSX_FOV), + .target = &g_Config.visuals.use_psx_fov, + }, + { .target = nullptr, }, @@ -166,6 +182,9 @@ static char *M_FormatRowValue(const int32_t row_idx) { const M_OPTION *const option = &m_Options[row_idx]; switch (option->option_type) { + case COT_BOOL: + return String_Format( + "%s", *(bool *)option->target ? GS(MISC_ON) : GS(MISC_OFF)); case COT_INT32: return String_Format( GS(DETAIL_INTEGER_FMT), *(int32_t *)option->target); @@ -183,6 +202,8 @@ static bool M_CanChangeValue(const int32_t row_idx, const int32_t dir) { const M_OPTION *const option = &m_Options[row_idx]; switch (option->option_type) { + case COT_BOOL: + return true; case COT_INT32: if (dir < 0) { return *(int32_t *)option->target > option->min_value; @@ -220,6 +241,9 @@ static bool M_RequestChangeValue( delta *= dir; switch (option->option_type) { + case COT_BOOL: + *(bool *)option->target = !*(bool *)option->target; + break; case COT_INT32: *(int32_t *)option->target += delta; break;