cmd/demo: add console log when playing a demo

This commit is contained in:
Marcin Kurczewski 2025-02-02 18:46:30 +01:00
parent 77b711dbc6
commit ed18dcce71
7 changed files with 30 additions and 24 deletions

View file

@ -467,6 +467,7 @@
"OSD_PERSPECTIVE_FILTER_ON": "Perspective correction: on",
"OSD_PHOTO_MODE_LAUNCHED": "Entering photo mode, press %s for help",
"OSD_PLAY_CUTSCENE": "Loading cutscene %d",
"OSD_PLAY_DEMO": "Loading demo %d",
"OSD_PLAY_LEVEL": "Loading %s",
"OSD_POS_GET": "Level: %d (%s) Room: %d\nPosition: %.3f, %.3f, %.3f\nRotation: %.3f,%.3f,%.3f",
"OSD_POS_SET_ITEM": "Teleported to object: %s",

View file

@ -561,6 +561,7 @@
"OSD_PERSPECTIVE_FILTER_ON": "Perspective correction: on",
"OSD_PHOTO_MODE_LAUNCHED": "Entering photo mode, press %s for help",
"OSD_PLAY_CUTSCENE": "Loading cutscene %d",
"OSD_PLAY_DEMO": "Loading demo %d",
"OSD_PLAY_LEVEL": "Loading %s",
"OSD_POS_GET": "Level: %d (%s) Room: %d\nPosition: %.3f, %.3f, %.3f\nRotation: %.3f,%.3f,%.3f",
"OSD_POS_SET_ITEM": "Teleported to object: %s",

View file

@ -11,6 +11,7 @@
- added exit fade-out effects (#2348)
- added optional dynamic lighting for gun flashes and explosions, similar to TR2+ (#2357)
- added a `/cut` console command for playing cutscenes
- added a console log when using the `/demo` command
- ⚠️ changed the game data to use a separate strings file for text information, removing it from the game flow file
- changed the object texture limit from 2048 to unlimited (within game's overall memory cap)
- changed the sprite texture limit from 512 to unlimited (within game's overall memory cap)

View file

@ -9,6 +9,7 @@
- added a fade-out effect when completing Lara's Home
- added support for animated sprites (#2401)
- added a `/cut` console command for playing cutscenes
- added a console log when using the `/demo` command
- changed the object texture limit from 2048 to unlimited (within game's overall memory cap) (#1795)
- changed the sprite texture limit from 512 to unlimited (within game's overall memory cap) (#1795)
- changed the texture page limit from 32 to 128 (#1796)

View file

@ -1,5 +1,6 @@
#include "game/console/cmd/play_demo.h"
#include "game/demo.h"
#include "game/game_flow/common.h"
#include "game/game_string.h"
#include "strings.h"
@ -9,26 +10,26 @@ static COMMAND_RESULT M_Entrypoint(const COMMAND_CONTEXT *ctx);
static COMMAND_RESULT M_Entrypoint(const COMMAND_CONTEXT *const ctx)
{
int32_t demo_to_load = -1;
if (String_ParseInteger(ctx->args, &demo_to_load)) {
const GF_LEVEL_TABLE *const level_table = GF_GetLevelTable(GFLT_DEMOS);
if (String_IsEmpty(ctx->args)) {
demo_to_load = Demo_ChooseLevel(-1);
} else if (String_ParseInteger(ctx->args, &demo_to_load)) {
demo_to_load--;
if (demo_to_load >= 0
&& demo_to_load < GF_GetLevelTable(GFLT_DEMOS)->count) {
GF_OverrideCommand((GF_COMMAND) {
.action = GF_START_DEMO,
.param = demo_to_load,
});
return CR_SUCCESS;
} else {
Console_Log(GS(OSD_INVALID_DEMO));
return CR_FAILURE;
}
} else if (String_IsEmpty(ctx->args)) {
GF_OverrideCommand(
(GF_COMMAND) { .action = GF_START_DEMO, .param = -1 });
return CR_SUCCESS;
} else {
return CR_BAD_INVOCATION;
}
if (demo_to_load < 0 || demo_to_load >= level_table->count) {
Console_Log(GS(OSD_INVALID_DEMO));
return CR_FAILURE;
}
const GF_LEVEL *const level = &level_table->levels[demo_to_load];
GF_OverrideCommand((GF_COMMAND) {
.action = GF_START_DEMO,
.param = demo_to_load,
});
Console_Log(GS(OSD_PLAY_DEMO), level->num + 1);
return CR_SUCCESS;
}
CONSOLE_COMMAND g_Console_Cmd_PlayDemo = {

View file

@ -2,12 +2,12 @@
#include "./game_flow/types.h"
bool Demo_Start(int32_t level_num);
void Demo_End(void);
void Demo_Pause(void);
void Demo_Unpause(void);
void Demo_StopFlashing(void);
extern bool Demo_Start(int32_t level_num);
extern void Demo_End(void);
extern void Demo_Pause(void);
extern void Demo_Unpause(void);
extern void Demo_StopFlashing(void);
bool Demo_GetInput(void);
GF_COMMAND Demo_Control(void);
int32_t Demo_ChooseLevel(int32_t demo_num);
extern bool Demo_GetInput(void);
extern GF_COMMAND Demo_Control(void);
extern int32_t Demo_ChooseLevel(int32_t demo_num);

View file

@ -38,6 +38,7 @@ GS_DEFINE(OSD_POS_SET_ITEM, "Teleported to object: %s")
GS_DEFINE(OSD_POS_SET_ITEM_FAIL, "Failed to teleport to object: %s")
GS_DEFINE(OSD_PLAY_LEVEL, "Loading %s")
GS_DEFINE(OSD_PLAY_CUTSCENE, "Loading cutscene %d")
GS_DEFINE(OSD_PLAY_DEMO, "Loading demo %d")
GS_DEFINE(OSD_INVALID_LEVEL, "Invalid level")
GS_DEFINE(OSD_INVALID_CUTSCENE, "Invalid cutscene")
GS_DEFINE(OSD_INVALID_DEMO, "Invalid demo")