mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-15 11:03:00 +01:00
Add the fullscreen mode to .ini config
This commit is contained in:
18
src/config.c
18
src/config.c
@@ -89,6 +89,7 @@ general_configuration_t gGeneral_config_default = {
|
||||
1, // landscape_smoothing
|
||||
0, // show_height_as_units
|
||||
1, // save_plugin_data
|
||||
0, // fullscreen mode (default: windowed)
|
||||
};
|
||||
sound_configuration_t gSound_config;
|
||||
|
||||
@@ -373,6 +374,13 @@ void config_write_ini_general(FILE *fp)
|
||||
else {
|
||||
fprintf(fp, "save_plugin_data = false\n");
|
||||
}
|
||||
|
||||
if (gGeneral_config.fullscreen_mode == 0)
|
||||
fprintf(fp, "fullscreen_mode = window\n");
|
||||
else if (gGeneral_config.fullscreen_mode == 1)
|
||||
fprintf(fp, "fullscreen_mode = fullscreen\n");
|
||||
else
|
||||
fprintf(fp, "fullscreen_mode = borderless_fullscreen\n");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -603,6 +611,16 @@ static void config_general(char *setting, char *value){
|
||||
gGeneral_config.save_plugin_data = 0;
|
||||
}
|
||||
}
|
||||
else if (strcmp(setting, "fullscreen_mode") == 0){
|
||||
if (strcmp(value, "window") == 0){
|
||||
gGeneral_config.fullscreen_mode = 0;
|
||||
}
|
||||
else if (strcmp(value, "fullscreen") == 0){
|
||||
gGeneral_config.fullscreen_mode = 1;
|
||||
}
|
||||
else
|
||||
gGeneral_config.fullscreen_mode = 2;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -127,6 +127,9 @@ typedef struct general_configuration {
|
||||
sint8 landscape_smoothing;
|
||||
sint8 show_height_as_units;
|
||||
sint8 save_plugin_data;
|
||||
|
||||
//new
|
||||
uint8 fullscreen_mode;
|
||||
} general_configuration_t;
|
||||
|
||||
static const struct { char *key; int value; } _currencyLookupTable[] = {
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <SDL_syswm.h>
|
||||
|
||||
#include "addresses.h"
|
||||
#include "config.h"
|
||||
#include "gfx.h"
|
||||
#include "osinterface.h"
|
||||
#include "window.h"
|
||||
@@ -53,6 +54,8 @@ static void *_screenBuffer;
|
||||
|
||||
static SDL_Cursor* _cursors[NO_CURSORS];
|
||||
|
||||
static const int fullscreen_modes[] = { 0, SDL_WINDOW_FULLSCREEN, SDL_WINDOW_FULLSCREEN_DESKTOP };
|
||||
|
||||
void osinterface_init()
|
||||
{
|
||||
osinterface_create_window();
|
||||
@@ -170,9 +173,8 @@ static void osinterface_create_window()
|
||||
|
||||
RCT2_GLOBAL(0x009E2D8C, sint32) = 0;
|
||||
|
||||
g_current_fullscreen_mode = 0;
|
||||
|
||||
_window = SDL_CreateWindow("OpenRCT2", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, SDL_WINDOW_RESIZABLE);
|
||||
_window = SDL_CreateWindow("OpenRCT2", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height,
|
||||
fullscreen_modes[gGeneral_config.fullscreen_mode]);
|
||||
if (!_window) {
|
||||
RCT2_ERROR("SDL_CreateWindow failed %s", SDL_GetError());
|
||||
exit(-1);
|
||||
@@ -384,7 +386,7 @@ void osinterface_process_messages()
|
||||
gLastKeyPressed = e.key.keysym.sym;
|
||||
gKeysPressed[e.key.keysym.scancode] = 1;
|
||||
if (e.key.keysym.sym == SDLK_RETURN && e.key.keysym.mod & KMOD_ALT)
|
||||
osinterface_set_fullscreen_mode(!g_current_fullscreen_mode);
|
||||
osinterface_set_fullscreen_mode(!gGeneral_config.fullscreen_mode);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -417,10 +419,8 @@ void osinterface_free()
|
||||
SDL_Quit();
|
||||
}
|
||||
|
||||
static const int fullscreen_modes[] = { 0, SDL_WINDOW_FULLSCREEN, SDL_WINDOW_FULLSCREEN_DESKTOP };
|
||||
|
||||
void osinterface_set_fullscreen_mode(int mode){
|
||||
if (mode == g_current_fullscreen_mode)
|
||||
if (mode == gGeneral_config.fullscreen_mode)
|
||||
return;
|
||||
|
||||
if (SDL_SetWindowFullscreen(_window, fullscreen_modes[mode])){
|
||||
@@ -430,7 +430,9 @@ void osinterface_set_fullscreen_mode(int mode){
|
||||
//SDL automatically resizes the fullscreen window to the nearest allowed screen resolution
|
||||
//No need to call osinterface_resize() here, SDL_WINDOWEVENT_SIZE_CHANGED event will be triggered anyway
|
||||
|
||||
g_current_fullscreen_mode = mode;
|
||||
gGeneral_config.fullscreen_mode = mode;
|
||||
|
||||
config_save();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -77,7 +77,6 @@ void osinterface_draw();
|
||||
void osinterface_free();
|
||||
void osinterface_update_palette(char* colours, int start_index, int num_colours);
|
||||
|
||||
int g_current_fullscreen_mode;
|
||||
void osinterface_set_fullscreen_mode(int mode);
|
||||
|
||||
void osinterface_set_cursor(char cursor);
|
||||
|
||||
@@ -397,7 +397,7 @@ static void window_options_mousedown(int widgetIndex, rct_window*w, rct_widget*
|
||||
gDropdownItemsArgs[0] = STR_CELSIUS;
|
||||
gDropdownItemsArgs[1] = STR_FAHRENHEIT;
|
||||
gDropdownItemsArgs[2] = STR_METRIC;
|
||||
gDropdownItemsChecked = 1 << g_current_fullscreen_mode;
|
||||
gDropdownItemsChecked = 1 << gGeneral_config.fullscreen_mode;
|
||||
break;
|
||||
case WIDX_TEMPERATURE_DROPDOWN:
|
||||
window_options_draw_dropdown_box(w, widget, 2);
|
||||
@@ -516,7 +516,7 @@ static void window_options_dropdown()
|
||||
RCT2_CALLPROC_EBPSAFE(0x006BB37D);
|
||||
break;
|
||||
case WIDX_FULLSCREEN_DROPDOWN:
|
||||
if (dropdownIndex != g_current_fullscreen_mode){
|
||||
if (dropdownIndex != gGeneral_config.fullscreen_mode){
|
||||
osinterface_set_fullscreen_mode(dropdownIndex);
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user