mirror of
https://github.com/LostArtefacts/TRX.git
synced 2025-04-28 20:58:07 +03:00
parent
bfab140dfc
commit
4fe7045ce1
14 changed files with 140 additions and 52 deletions
|
@ -31,6 +31,7 @@
|
|||
- moved the enable_game_modes option from the gameflow to the config tool and added a gameflow option to override (#962)
|
||||
- moved the enable_save_crystals option from the gameflow to the config tool (#962)
|
||||
- improved Spanish localization for the config tool
|
||||
- improved support for windowed mode (#896)
|
||||
|
||||
## [2.15.3](https://github.com/rr-/Tomb1Main/compare/2.15.2...2.15.3) - 2023-08-15
|
||||
- fixed Lara stuttering when performing certain animations (#901, regression from 2.14)
|
||||
|
|
|
@ -237,6 +237,7 @@ Not all options are turned on by default. Refer to `Tomb1Main_ConfigTool.exe` fo
|
|||
- added enemy health bars
|
||||
- added PS1 style UI
|
||||
- added fade effects to displayed images
|
||||
- improved support for windowed mode
|
||||
|
||||
#### Gameplay
|
||||
- added ability to set user-defined FOV
|
||||
|
|
15
src/config.c
15
src/config.c
|
@ -243,6 +243,12 @@ bool Config_ReadFromJSON(const char *cfg_data)
|
|||
|
||||
// User settings
|
||||
READ_INTEGER(rendering.render_mode, GFX_RM_LEGACY);
|
||||
READ_BOOL(rendering.enable_fullscreen, true);
|
||||
READ_BOOL(rendering.enable_maximized, true);
|
||||
READ_INTEGER(rendering.window_x, -1);
|
||||
READ_INTEGER(rendering.window_y, -1);
|
||||
READ_INTEGER(rendering.window_width, -1);
|
||||
READ_INTEGER(rendering.window_height, -1);
|
||||
READ_BOOL(rendering.enable_bilinear_filter, true);
|
||||
READ_BOOL(rendering.enable_perspective_filter, true);
|
||||
READ_BOOL(rendering.enable_vsync, true);
|
||||
|
@ -316,6 +322,8 @@ bool Config_ReadFromJSON(const char *cfg_data)
|
|||
if (root) {
|
||||
json_value_free(root);
|
||||
}
|
||||
|
||||
g_Config.loaded = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -430,8 +438,13 @@ bool Config_Write(void)
|
|||
WRITE_BOOL(enable_game_modes);
|
||||
WRITE_BOOL(enable_save_crystals);
|
||||
|
||||
// User settings
|
||||
WRITE_INTEGER(rendering.render_mode);
|
||||
WRITE_BOOL(rendering.enable_fullscreen);
|
||||
WRITE_BOOL(rendering.enable_maximized);
|
||||
WRITE_INTEGER(rendering.window_x);
|
||||
WRITE_INTEGER(rendering.window_y);
|
||||
WRITE_INTEGER(rendering.window_width);
|
||||
WRITE_INTEGER(rendering.window_height);
|
||||
WRITE_BOOL(rendering.enable_bilinear_filter);
|
||||
WRITE_BOOL(rendering.enable_perspective_filter);
|
||||
WRITE_BOOL(rendering.enable_vsync);
|
||||
|
|
|
@ -48,6 +48,8 @@ typedef enum {
|
|||
} BAR_SHOW_MODE;
|
||||
|
||||
typedef struct {
|
||||
bool loaded;
|
||||
|
||||
bool disable_healing_between_levels;
|
||||
bool disable_medpacks;
|
||||
bool disable_magnums;
|
||||
|
@ -127,6 +129,12 @@ typedef struct {
|
|||
|
||||
struct {
|
||||
GFX_RENDER_MODE render_mode;
|
||||
bool enable_fullscreen;
|
||||
bool enable_maximized;
|
||||
int32_t window_x;
|
||||
int32_t window_y;
|
||||
int32_t window_width;
|
||||
int32_t window_height;
|
||||
bool enable_perspective_filter;
|
||||
bool enable_bilinear_filter;
|
||||
bool enable_vsync;
|
||||
|
|
|
@ -389,11 +389,6 @@ void Output_SetWindowSize(int width, int height)
|
|||
S_Output_SetWindowSize(width, height);
|
||||
}
|
||||
|
||||
void Output_SetFullscreen(bool fullscreen)
|
||||
{
|
||||
S_Output_SetFullscreen(fullscreen);
|
||||
}
|
||||
|
||||
void Output_ApplyRenderSettings(void)
|
||||
{
|
||||
S_Output_ApplyRenderSettings();
|
||||
|
|
|
@ -9,7 +9,6 @@ bool Output_Init(void);
|
|||
void Output_Shutdown(void);
|
||||
|
||||
void Output_SetWindowSize(int width, int height);
|
||||
void Output_SetFullscreen(bool fullscreen);
|
||||
void Output_ApplyRenderSettings(void);
|
||||
void Output_DownloadTextures(int page_count);
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ static char *Shell_GetScreenshotName(void)
|
|||
|
||||
void Shell_Init(const char *gameflow_path)
|
||||
{
|
||||
S_Shell_SeedRandom();
|
||||
S_Shell_Init();
|
||||
|
||||
if (!Output_Init()) {
|
||||
Shell_ExitSystem("Could not initialise video system");
|
||||
|
|
|
@ -20,7 +20,6 @@ typedef struct GFX_CONTEXT {
|
|||
int32_t window_width;
|
||||
int32_t window_height;
|
||||
|
||||
bool is_fullscreen; // fullscreen flag
|
||||
bool is_rendered; // rendering flag
|
||||
char *scheduled_screenshot_path;
|
||||
GFX_FBO_Renderer renderer_fbo;
|
||||
|
@ -180,16 +179,6 @@ void GFX_Context_SetVSync(bool vsync)
|
|||
SDL_GL_SetSwapInterval(vsync);
|
||||
}
|
||||
|
||||
bool GFX_Context_IsFullscreen(void)
|
||||
{
|
||||
return m_Context.is_fullscreen;
|
||||
}
|
||||
|
||||
void GFX_Context_SetFullscreen(bool fullscreen)
|
||||
{
|
||||
m_Context.is_fullscreen = fullscreen;
|
||||
}
|
||||
|
||||
void GFX_Context_SetWindowSize(int32_t width, int32_t height)
|
||||
{
|
||||
LOG_INFO("Window size: %dx%d", width, height);
|
||||
|
|
|
@ -17,8 +17,6 @@ typedef enum GFX_RENDER_MODE {
|
|||
void GFX_Context_Attach(void *window_handle);
|
||||
void GFX_Context_Detach(void);
|
||||
void GFX_Context_SetVSync(bool vsync);
|
||||
bool GFX_Context_IsFullscreen(void);
|
||||
void GFX_Context_SetFullscreen(bool fullscreen);
|
||||
void GFX_Context_SetWindowSize(int32_t width, int32_t height);
|
||||
void GFX_Context_SetDisplaySize(int32_t width, int32_t height);
|
||||
void GFX_Context_SetRenderingMode(GFX_RENDER_MODE target_mode);
|
||||
|
|
|
@ -2240,11 +2240,12 @@ static void S_FMV_EventLoop(VideoState *is)
|
|||
is->audio_volume = 0;
|
||||
break;
|
||||
|
||||
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
||||
case SDL_WINDOWEVENT_MOVED:
|
||||
case SDL_WINDOWEVENT_RESIZED:
|
||||
is->width = event.window.data1;
|
||||
is->height = event.window.data2;
|
||||
is->force_refresh = true;
|
||||
Output_SetWindowSize(event.window.data1, event.window.data2);
|
||||
S_Shell_HandleWindowResize();
|
||||
break;
|
||||
|
||||
case SDL_WINDOWEVENT_EXPOSED:
|
||||
|
|
|
@ -966,11 +966,6 @@ void S_Output_SetWindowSize(int width, int height)
|
|||
GFX_Context_SetWindowSize(width, height);
|
||||
}
|
||||
|
||||
void S_Output_SetFullscreen(bool fullscreen)
|
||||
{
|
||||
GFX_Context_SetFullscreen(fullscreen);
|
||||
}
|
||||
|
||||
bool S_Output_Init(void)
|
||||
{
|
||||
for (int i = 0; i < GFX_MAX_TEXTURES; i++) {
|
||||
|
|
|
@ -22,7 +22,6 @@ void S_Output_ClearDepthBuffer(void);
|
|||
void S_Output_DrawEmpty(void);
|
||||
|
||||
void S_Output_SetWindowSize(int width, int height);
|
||||
void S_Output_SetFullscreen(bool fullscreen);
|
||||
void S_Output_ApplyRenderSettings(void);
|
||||
|
||||
void S_Output_SetPalette(RGB888 palette[256]);
|
||||
|
|
|
@ -31,12 +31,15 @@
|
|||
|
||||
static int m_ArgCount = 0;
|
||||
static char **m_ArgStrings = NULL;
|
||||
static bool m_Fullscreen = true;
|
||||
static SDL_Window *m_Window = NULL;
|
||||
|
||||
static void S_Shell_PostWindowResize(void);
|
||||
static void S_Shell_SeedRandom(void);
|
||||
static void S_Shell_SetWindowPos(int32_t x, int32_t y, bool update);
|
||||
static void S_Shell_SetWindowSize(int32_t width, int32_t height, bool update);
|
||||
static void S_Shell_SetWindowMaximized(bool is_enabled, bool update);
|
||||
static void S_Shell_SetFullscreen(bool is_enabled, bool update);
|
||||
|
||||
void S_Shell_SeedRandom(void)
|
||||
static void S_Shell_SeedRandom(void)
|
||||
{
|
||||
time_t lt = time(0);
|
||||
struct tm *tptr = localtime(<);
|
||||
|
@ -44,12 +47,109 @@ void S_Shell_SeedRandom(void)
|
|||
Random_SeedDraw(tptr->tm_sec + 43 * tptr->tm_min + 3477 * tptr->tm_hour);
|
||||
}
|
||||
|
||||
static void S_Shell_PostWindowResize(void)
|
||||
static void S_Shell_SetWindowPos(int32_t x, int32_t y, bool update)
|
||||
{
|
||||
if (x <= 0 || y <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// only save window position if it's in windowed state.
|
||||
if (!g_Config.rendering.enable_fullscreen
|
||||
&& !g_Config.rendering.enable_maximized) {
|
||||
g_Config.rendering.window_x = x;
|
||||
g_Config.rendering.window_y = y;
|
||||
}
|
||||
|
||||
if (update) {
|
||||
SDL_SetWindowPosition(m_Window, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
static void S_Shell_SetWindowSize(int32_t width, int32_t height, bool update)
|
||||
{
|
||||
if (width <= 0 || height <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// only save window size if it's in windowed state.
|
||||
if (!g_Config.rendering.enable_fullscreen
|
||||
&& !g_Config.rendering.enable_maximized) {
|
||||
g_Config.rendering.window_width = width;
|
||||
g_Config.rendering.window_height = height;
|
||||
}
|
||||
|
||||
Output_SetWindowSize(width, height);
|
||||
|
||||
if (update) {
|
||||
SDL_SetWindowSize(m_Window, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
static void S_Shell_SetWindowMaximized(bool is_enabled, bool update)
|
||||
{
|
||||
g_Config.rendering.enable_maximized = is_enabled;
|
||||
|
||||
if (update && is_enabled) {
|
||||
SDL_MaximizeWindow(m_Window);
|
||||
}
|
||||
}
|
||||
|
||||
static void S_Shell_SetFullscreen(bool is_enabled, bool update)
|
||||
{
|
||||
g_Config.rendering.enable_fullscreen = is_enabled;
|
||||
|
||||
if (update) {
|
||||
SDL_SetWindowFullscreen(
|
||||
m_Window, is_enabled ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
|
||||
SDL_ShowCursor(is_enabled ? SDL_DISABLE : SDL_ENABLE);
|
||||
}
|
||||
}
|
||||
|
||||
void S_Shell_ToggleFullscreen(void)
|
||||
{
|
||||
S_Shell_SetFullscreen(!g_Config.rendering.enable_fullscreen, true);
|
||||
|
||||
// save the updated config, but ensure it was loaded first
|
||||
if (g_Config.loaded) {
|
||||
Config_Write();
|
||||
}
|
||||
}
|
||||
|
||||
void S_Shell_HandleWindowResize(void)
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
int width;
|
||||
int height;
|
||||
bool is_maximized;
|
||||
|
||||
Uint32 window_flags = SDL_GetWindowFlags(m_Window);
|
||||
is_maximized = window_flags & SDL_WINDOW_MAXIMIZED;
|
||||
SDL_GetWindowSize(m_Window, &width, &height);
|
||||
Output_SetWindowSize(width, height);
|
||||
SDL_GetWindowPosition(m_Window, &x, &y);
|
||||
LOG_INFO("%dx%d+%d,%d (maximized: %d)", width, height, x, y, is_maximized);
|
||||
|
||||
S_Shell_SetWindowMaximized(is_maximized, false);
|
||||
S_Shell_SetWindowPos(x, y, false);
|
||||
S_Shell_SetWindowSize(width, height, false);
|
||||
|
||||
// save the updated config, but ensure it was loaded first
|
||||
if (g_Config.loaded) {
|
||||
Config_Write();
|
||||
}
|
||||
}
|
||||
|
||||
void S_Shell_Init(void)
|
||||
{
|
||||
S_Shell_SeedRandom();
|
||||
|
||||
S_Shell_SetFullscreen(g_Config.rendering.enable_fullscreen, true);
|
||||
S_Shell_SetWindowPos(
|
||||
g_Config.rendering.window_x, g_Config.rendering.window_y, true);
|
||||
S_Shell_SetWindowSize(
|
||||
g_Config.rendering.window_width, g_Config.rendering.window_height,
|
||||
true);
|
||||
S_Shell_SetWindowMaximized(g_Config.rendering.enable_maximized, true);
|
||||
}
|
||||
|
||||
void S_Shell_ShowFatalError(const char *message)
|
||||
|
@ -60,16 +160,6 @@ void S_Shell_ShowFatalError(const char *message)
|
|||
S_Shell_TerminateGame(1);
|
||||
}
|
||||
|
||||
void S_Shell_ToggleFullscreen(void)
|
||||
{
|
||||
m_Fullscreen = !m_Fullscreen;
|
||||
Output_SetFullscreen(m_Fullscreen);
|
||||
SDL_SetWindowFullscreen(
|
||||
m_Window, m_Fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
|
||||
SDL_ShowCursor(m_Fullscreen ? SDL_DISABLE : SDL_ENABLE);
|
||||
S_Shell_PostWindowResize();
|
||||
}
|
||||
|
||||
void S_Shell_TerminateGame(int exit_code)
|
||||
{
|
||||
Shell_Shutdown();
|
||||
|
@ -115,11 +205,11 @@ void S_Shell_SpinMessageLoop(void)
|
|||
Sound_SetMasterVolume(0);
|
||||
break;
|
||||
|
||||
case SDL_WINDOWEVENT_RESIZED: {
|
||||
Output_SetWindowSize(event.window.data1, event.window.data2);
|
||||
case SDL_WINDOWEVENT_MOVED:
|
||||
case SDL_WINDOWEVENT_RESIZED:
|
||||
S_Shell_HandleWindowResize();
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_CONTROLLERDEVICEADDED:
|
||||
|
@ -197,9 +287,7 @@ int main(int argc, char **argv)
|
|||
return 1;
|
||||
}
|
||||
|
||||
S_Shell_PostWindowResize();
|
||||
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
S_Shell_HandleWindowResize();
|
||||
|
||||
Shell_Main();
|
||||
|
||||
|
|
|
@ -5,11 +5,12 @@
|
|||
|
||||
void S_Shell_ShowFatalError(const char *message);
|
||||
|
||||
void S_Shell_SeedRandom(void);
|
||||
void S_Shell_Init(void);
|
||||
void S_Shell_SpinMessageLoop(void);
|
||||
bool S_Shell_GetCommandLine(int *arg_count, char ***args);
|
||||
void *S_Shell_GetWindowHandle(void);
|
||||
void S_Shell_TerminateGame(int exit_code);
|
||||
void S_Shell_ToggleFullscreen(void);
|
||||
void S_Shell_HandleWindowResize(void);
|
||||
void S_Shell_TerminateGame(int exit_code);
|
||||
int S_Shell_GetCurrentDisplayWidth(void);
|
||||
int S_Shell_GetCurrentDisplayHeight(void);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue