Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

console: move ui to libtrx #1541

Merged
merged 9 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
## [Unreleased](https://github.com/LostArtefacts/TR1X/compare/stable...develop) - ××××-××-××
- added `/sfx` command
- changed the easter egg console command to pack more punch
- fixed console caret position off by a couple of pixels (regression from 3.0)
- fixed holding a key when closing the console registering as a game input (regression from 3.0)
- fixed ability to crash the game with extreme FOV values (regression from 0.9)
- fixed double "Fly mode enabled" message when using `/fly` console command (regression from 4.0)
- fixed crash in the `/set` console command (regression from 4.4)
- fixed toggling fullscreen not always saving (regression from 4.4)

## [4.4](https://github.com/LostArtefacts/TR1X/compare/4.3-102-g458cd96...4.4) - 2024-09-20
- added `/exit` command (#1462)
Expand Down
4 changes: 4 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ sources = [
'src/game/effect_routines/chain_block.c',
'src/game/effect_routines/dino_stomp.c',
'src/game/effect_routines/earthquake.c',
'src/game/ui/common.c',
'src/game/ui/widgets/label.c',
'src/game/ui/widgets/prompt.c',
'src/game/ui/widgets/window.c',
'src/game/effect_routines/explosion.c',
'src/game/effect_routines/finish_level.c',
'src/game/effect_routines/flicker.c',
Expand Down
41 changes: 17 additions & 24 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
#include "global/types.h"
#include "global/vars.h"

#include <libtrx/config/config_file.h>
#include <libtrx/config/file.h>
#include <libtrx/filesystem.h>
#include <libtrx/game/console/common.h>
#include <libtrx/game/ui/events.h>
#include <libtrx/json.h>
#include <libtrx/log.h>
#include <libtrx/memory.h>
#include <libtrx/utils.h>

Expand All @@ -34,8 +35,6 @@ static void M_LoadLegacyOptions(JSON_OBJECT *const parent_obj);
static void M_DumpKeyboardLayout(JSON_OBJECT *parent_obj, INPUT_LAYOUT layout);
static void M_DumpControllerLayout(
JSON_OBJECT *parent_obj, INPUT_LAYOUT layout);
static void M_Load(JSON_OBJECT *root_obj);
static void M_Dump(JSON_OBJECT *root_obj);

static void M_LoadKeyboardLayout(
JSON_OBJECT *const parent_obj, const INPUT_LAYOUT layout)
Expand Down Expand Up @@ -240,7 +239,12 @@ static void M_DumpControllerLayout(
}
}

static void M_Load(JSON_OBJECT *root_obj)
const char *Config_GetPath(void)
{
return m_ConfigPath;
}

void Config_LoadFromJSON(JSON_OBJECT *root_obj)
{
ConfigFile_LoadOptions(root_obj, g_ConfigOptionMap);

Expand All @@ -252,10 +256,10 @@ static void M_Load(JSON_OBJECT *root_obj)

M_LoadLegacyOptions(root_obj);

Config_Sanitize();
g_Config.loaded = true;
}

static void M_Dump(JSON_OBJECT *root_obj)
void Config_DumpToJSON(JSON_OBJECT *root_obj)
{
ConfigFile_DumpOptions(root_obj, g_ConfigOptionMap);

Expand All @@ -270,23 +274,6 @@ static void M_Dump(JSON_OBJECT *root_obj)
}
}

bool Config_Read(void)
{
const bool result = ConfigFile_Read(m_ConfigPath, &M_Load);
Input_CheckConflicts(CM_KEYBOARD, g_Config.input.layout);
Input_CheckConflicts(CM_CONTROLLER, g_Config.input.cntlr_layout);
Music_SetVolume(g_Config.music_volume);
Sound_SetMasterVolume(g_Config.sound_volume);
Requester_Shutdown(&g_SavegameRequester);
Requester_Init(&g_SavegameRequester, g_Config.maximum_save_slots);
return result;
}

bool Config_Write(void)
{
return ConfigFile_Write(m_ConfigPath, &M_Dump);
}

void Config_Sanitize(void)
{
CLAMP(g_Config.start_lara_hitpoints, 1, LARA_MAX_HITPOINTS);
Expand All @@ -312,6 +299,12 @@ void Config_Sanitize(void)

void Config_ApplyChanges(void)
{
Input_CheckConflicts(CM_KEYBOARD, g_Config.input.layout);
Input_CheckConflicts(CM_CONTROLLER, g_Config.input.cntlr_layout);
Music_SetVolume(g_Config.music_volume);
Sound_SetMasterVolume(g_Config.sound_volume);
Requester_Shutdown(&g_SavegameRequester);
Requester_Init(&g_SavegameRequester, g_Config.maximum_save_slots);
Output_ApplyRenderSettings();
}

Expand Down
6 changes: 1 addition & 5 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "global/types.h"

#include <libtrx/config.h>
#include <libtrx/gfx/common.h>

#include <stdbool.h>
Expand Down Expand Up @@ -139,8 +140,3 @@ typedef struct {
} CONFIG;

extern CONFIG g_Config;

bool Config_Read(void);
bool Config_Write(void);
void Config_Sanitize(void);
void Config_ApplyChanges(void);
2 changes: 1 addition & 1 deletion src/config_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "config.h"

// import order guard
#include <libtrx/config/config_map.h>
#include <libtrx/config/map.h>
// import order guard

#include "global/enum_str.h"
Expand Down
2 changes: 1 addition & 1 deletion src/config_map.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once

#include <libtrx/config/config_option.h>
#include <libtrx/config/option.h>

extern const CONFIG_OPTION g_ConfigOptionMap[];
2 changes: 1 addition & 1 deletion src/game/clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ void Clock_SetTurboSpeed(int32_t value)
{
CLAMP(value, CLOCK_TURBO_SPEED_MIN, CLOCK_TURBO_SPEED_MAX);
g_Config.rendering.turbo_speed = value;
Console_Log(GS(OSD_SPEED_SET), value);
Config_Write();
Console_Log(GS(OSD_SPEED_SET), value);
}

double Clock_GetSpeedMultiplier(void)
Expand Down
Loading
Loading