Skip to content

Commit

Permalink
Disable resizable window by default
Browse files Browse the repository at this point in the history
  • Loading branch information
rollerozxa committed Oct 16, 2024
1 parent 8ecccc1 commit 5cb81c6
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 12 deletions.
14 changes: 10 additions & 4 deletions src/src/pscreen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,16 @@ pscreen::handle_input(tms::event *ev, int action)
case TMS_KEY_F11:
uint32_t flags = SDL_GetWindowFlags(_tms._window);

if (flags & SDL_WINDOW_FULLSCREEN_DESKTOP)
SDL_SetWindowFullscreen(_tms._window, 0);
else
SDL_SetWindowFullscreen(_tms._window, SDL_WINDOW_FULLSCREEN_DESKTOP);
if (settings["window_resizable"]->v.b) {
if (flags & SDL_WINDOW_FULLSCREEN_DESKTOP)
SDL_SetWindowFullscreen(_tms._window, 0);
else
SDL_SetWindowFullscreen(_tms._window, SDL_WINDOW_FULLSCREEN_DESKTOP);
} else {
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_WARNING, "Principia",
"Principia does not support resizing the window while in-game. For fullscreen changes to take effect, please restart the game.",
0);
}

settings["window_fullscreen"]->v.b = (flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == 0;
break;
Expand Down
5 changes: 2 additions & 3 deletions src/src/settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ _settings::init()
this->add("window_height", S_INT32, _tms.window_height);
this->add("window_maximized", S_BOOL, 0);
this->add("window_fullscreen", S_BOOL, false);

// False for now to allow for resetting the screensize if resizing somehow breaks it.
this->add("autosave_screensize",S_BOOL, false);
this->add("window_resizable", S_BOOL, false);
this->add("autosave_screensize",S_BOOL, true);
#endif

this->add("shadow_quality", S_UINT8, 1);
Expand Down
16 changes: 13 additions & 3 deletions src/src/ui_gtk3.hh
Original file line number Diff line number Diff line change
Expand Up @@ -441,9 +441,9 @@ struct table_setting_row settings_interface_rows[] = {
"uiscale",
setting_row_type::create_hscale(0.25, 2.0, 0.05),
},{
"Autosave screen size",
"Save the screen size when resizing the window.",
"autosave_screensize",
"Fullscreen mode",
"Toggle fullscreen mode",
"window_fullscreen",
setting_row_type::create_checkbox()
}, {
"Display object ID",
Expand Down Expand Up @@ -480,6 +480,16 @@ struct table_setting_row settings_interface_rows[] = {
"Always ask before submitting highscore.",
"score_ask_before_submitting",
setting_row_type::create_checkbox()
}, {
"Resizable window",
"Allow the window to be resized. NOTE: Principia does not support resizing while in-game. Things will break.",
"window_resizable",
setting_row_type::create_checkbox()
}, {
"Autosave screen size",
"Save the screen size when resizing the window.",
"autosave_screensize",
setting_row_type::create_checkbox()
},
};

Expand Down
7 changes: 5 additions & 2 deletions src/tms/backend/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -353,15 +353,18 @@ tbackend_init_surface()
_tms.xppcm = 108.f/2.54f * 1.5f;
_tms.yppcm = 107.f/2.54f * 1.5f;

uint32_t flags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE;
uint32_t flags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN;

if (settings["window_maximized"]->v.b)
flags |= SDL_WINDOW_MAXIMIZED;

if (settings["window_fullscreen"]->v.b)
flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;

tms_infof("Creating window..."); \
if (settings["window_resizable"]->v.b)
flags |= SDL_WINDOW_RESIZABLE;

tms_infof("Creating window...");
_window = SDL_CreateWindow("Principia", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
_tms.window_width, _tms.window_height, flags);

Expand Down

0 comments on commit 5cb81c6

Please sign in to comment.