tr2/game_flow: specify title background in game flow

This allows the title background picture path to be defined in the game
flow.
This commit is contained in:
lahm86 2025-03-15 18:35:40 +00:00
parent c4e9e7593a
commit 0b231c2afa
8 changed files with 20 additions and 2 deletions

View file

@ -2,6 +2,8 @@
// NOTE: bad changes to this file may result in crashes.
// Lines starting with double slashes are comments and are ignored.
"main_menu_picture": "data/title.pcx",
"cmd_init": {"action": "exit_to_title"},
"cmd_title": {"action": "noop"},
"cmd_death_in_demo": {"action": "exit_to_title"},

View file

@ -1,6 +1,8 @@
{
// This file is used to enable the -l argument support.
"main_menu_picture": "data/title.pcx",
"cmd_init": {"action": "exit_to_title"},
"cmd_title": {"action": "noop"},
"cmd_death_in_demo": {"action": "exit_to_title"},

View file

@ -291,6 +291,11 @@ remains distinct for each game.
The number of seconds to pass in the main menu before playing the demo.
</td>
</tr>
<tr valign="top">
<td><code>main_menu_picture</code></td>
<td>String<strong>*</strong></td>
<td>Path to the main menu background image.</td>
</tr>
<tr valign="top">
<td><code>secret_track</code></td>
<td>Integer</td>

View file

@ -41,6 +41,7 @@
- improved roll support
- expanded world bounding box by 5 tiles in each direction
- added support for 60 FPS
- removed the hardcoded title screen image path, replacing it with a game flow file property instead
## [0.9.2](https://github.com/LostArtefacts/TRX/compare/tr2-0.9.1...tr2-0.9.2) - 2025-02-19
- fixed secret rewards not handed out after loading a save (#2528, regression from 0.8)

View file

@ -89,8 +89,8 @@ void GF_Shutdown(void)
Memory_FreePointer(&gf->title_level);
}
#if TR_VERSION == 1
Memory_FreePointer(&gf->main_menu_background_path);
#if TR_VERSION == 1
Memory_FreePointer(&gf->savegame_fmt_legacy);
Memory_FreePointer(&gf->savegame_fmt_bson);
#else

View file

@ -124,6 +124,13 @@ static void M_LoadRoot(JSON_OBJECT *const obj, GAME_FLOW *const gf)
gf->settings = m_DefaultSettings;
M_LoadSettings(obj, &gf->settings);
const char *const tmp_s =
JSON_ObjectGetString(obj, "main_menu_picture", JSON_INVALID_STRING);
if (tmp_s == JSON_INVALID_STRING) {
Shell_ExitSystem("'main_menu_picture' must be a string");
}
gf->main_menu_background_path = Memory_DupStr(tmp_s);
// clang-format off
gf->demo_delay = JSON_ObjectGetInt(obj, "demo_delay", 30);
gf->load_save_disabled = JSON_ObjectGetBool(obj, "load_save_disabled", false);

View file

@ -171,6 +171,7 @@ typedef struct {
// global settings
struct {
float demo_delay;
char *main_menu_background_path;
bool is_demo_version;
bool play_any_level;
bool gym_enabled;

View file

@ -856,7 +856,7 @@ INV_RING *InvRing_Open(const INVENTORY_MODE mode)
}
if (mode == INV_TITLE_MODE) {
Output_LoadBackgroundFromFile("data/title.pcx");
Output_LoadBackgroundFromFile(g_GameFlow.main_menu_background_path);
Fader_Init(
&ring->top_fader, FADER_BLACK, FADER_TRANSPARENT,
INV_RING_FADE_TIME_FAST);