From 38341b834062b4bfd8772ece2ea773c778bb29ad Mon Sep 17 00:00:00 2001 From: Richard Kettering Date: Mon, 24 Jul 2023 01:10:04 -0500 Subject: [PATCH 1/4] Fixing an issue where objects which were in a fatal collision state with other objects were not throwing the FFL exception that they're supposed to throw to allow us to gracefully recover, and were instead just asserting the game. Notably, this was causing a frogatto issue when moth bombers would drop a bomb through other moth bombers, and assert if said bomb overlapped another one as it was spawned. --- src/custom_object.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/custom_object.cpp b/src/custom_object.cpp index fab64f061..b17db7816 100755 --- a/src/custom_object.cpp +++ b/src/custom_object.cpp @@ -1702,8 +1702,28 @@ void CustomObject::process(Level& lvl) } CollisionInfo debug_collide_info; - ASSERT_LOG(type_->isStaticObject() || lvl.in_editor() || !entity_collides(Level::current(), *this, MOVE_DIRECTION::NONE, &debug_collide_info), "ENTITY " << getDebugDescription() << " COLLIDES WITH " << (debug_collide_info.collide_with ? debug_collide_info.collide_with->getDebugDescription() : "THE LEVEL") << " AT START OF PROCESS, WITH ITS SOLID RECT BEING [x,y,x2,y2]: " << solidRect()); + //ASSERT_LOG(type_->isStaticObject() || lvl.in_editor() || !entity_collides(Level::current(), *this, MOVE_DIRECTION::NONE, &debug_collide_info), "ENTITY " << getDebugDescription() << " COLLIDES WITH " << (debug_collide_info.collide_with ? debug_collide_info.collide_with->getDebugDescription() : "THE LEVEL") << " AT START OF PROCESS, WITH ITS SOLID RECT BEING [x,y,x2,y2]: " << solidRect()); + if( !(type_->isStaticObject() || lvl.in_editor() || !entity_collides(Level::current(), *this, MOVE_DIRECTION::NONE, &debug_collide_info) ) ){ + + if( debug_collide_info.collide_with ){ + //if we're overlapping another object, then we should try to invoke our FFL for handling that gracefully. + + game_logic::MapFormulaCallable* callable(new game_logic::MapFormulaCallable(this)); + + callable->add("collide_with", variant()); + game_logic::FormulaCallablePtr callable_ptr(callable); + + handleEvent(OBJECT_EVENT_CHANGE_SOLID_DIMENSIONS_FAIL, callable); + } else { + //if we're actually overlapping level solidity, then we screwed up big time, and this needs to be a proper and serious assert: + + ASSERT_LOG(false, "ENTITY " << getDebugDescription() << " COLLIDES WITH THE LEVEL AT START OF PROCESS, WITH ITS SOLID RECT BEING [x,y,x2,y2]: " << solidRect()); + } + } + + + if(parent_.get() != nullptr) { const point pos = parent_position(); const bool parent_facing = parent_->isFacingRight(); From 6b0689223f0575e0fb9437610d78d62cd5427dbf Mon Sep 17 00:00:00 2001 From: DDR Date: Thu, 7 Sep 2023 22:34:09 -0700 Subject: [PATCH 2/4] Moved fullscreen logic to screen_handling in prep for a fix. It needs to be further moved to WindowManager instead of screen_handling, to be beside `bool setWindowSize`. --- src/kre/WindowManager.hpp | 6 -- src/kre/WindowManagerFwd.hpp | 6 ++ src/level_runner.cpp | 46 ++---------- src/main.cpp | 87 +---------------------- src/screen_handling.cpp | 134 +++++++++++++++++++++++++++++++++++ src/screen_handling.hpp | 2 + src/video_selections.cpp | 35 ++++----- 7 files changed, 168 insertions(+), 148 deletions(-) diff --git a/src/kre/WindowManager.hpp b/src/kre/WindowManager.hpp index 959edbeff..0b2999a2b 100644 --- a/src/kre/WindowManager.hpp +++ b/src/kre/WindowManager.hpp @@ -34,12 +34,6 @@ namespace KRE { - enum class FullScreenMode { - WINDOWED, - FULLSCREEN_WINDOWED, - FULLSCREEN_EXCLUSIVE, - }; - struct WindowMode { int width; diff --git a/src/kre/WindowManagerFwd.hpp b/src/kre/WindowManagerFwd.hpp index a014958ab..de0990f51 100644 --- a/src/kre/WindowManagerFwd.hpp +++ b/src/kre/WindowManagerFwd.hpp @@ -27,6 +27,12 @@ namespace KRE { + enum class FullScreenMode { + WINDOWED, + FULLSCREEN_WINDOWED, + FULLSCREEN_EXCLUSIVE, + }; + class Surface; typedef std::shared_ptr SurfacePtr; diff --git a/src/level_runner.cpp b/src/level_runner.cpp index 639a0eeea..ab014b225 100644 --- a/src/level_runner.cpp +++ b/src/level_runner.cpp @@ -84,7 +84,6 @@ extern std::map g_user_info_registry; PREF_STRING(editor_object, "", "Object to use for the editor"); -extern bool g_desktop_fullscreen; extern bool g_particle_editor; extern int g_vsync; @@ -1592,45 +1591,12 @@ bool LevelRunner::play_cycle() const int virtual_height = gs.getVirtualHeight(); last_pushed = nevent_frame; - LOG_DEBUG("ctrl-f pushed"); - // XXX this changes if editor is active. - if(wnd->fullscreenMode() == KRE::FullScreenMode::WINDOWED) { - - LOG_DEBUG("Enter full-screen mode"); - wnd->setFullscreenMode(KRE::FullScreenMode::FULLSCREEN_WINDOWED); - - if(preferences::auto_size_window() || g_desktop_fullscreen) { - SDL_DisplayMode dm; - if(SDL_GetDesktopDisplayMode(0, &dm) == 0) { - preferences::adjust_virtual_width_to_match_physical(dm.w, dm.h); - wnd->setWindowSize(dm.w, dm.h); - gs.setDimensions(dm.w, dm.h); - gs.setVirtualDimensions(preferences::requested_virtual_window_width(), preferences::requested_virtual_window_height()); - } - - } - - } else { - LOG_DEBUG("Enter windowed mode"); - wnd->setFullscreenMode(KRE::FullScreenMode::WINDOWED); - - if(preferences::auto_size_window() || g_desktop_fullscreen) { - int width = 0, height = 0; - - if(preferences::requested_window_width() > 0 && preferences::requested_window_height() > 0) { - width = preferences::requested_window_width(); - height = preferences::requested_window_height(); - } else { - auto_select_resolution(wnd, width, height, true, false); - } - - preferences::adjust_virtual_width_to_match_physical(width, height); - - wnd->setWindowSize(width, height); - gs.setDimensions(width, height); - gs.setVirtualDimensions(preferences::requested_virtual_window_width(), preferences::requested_virtual_window_height()); - } - } + // This changes if editor is active. + gs.setFullscreen( + wnd->fullscreenMode() == KRE::FullScreenMode::WINDOWED + ? KRE::FullScreenMode::FULLSCREEN_WINDOWED + : KRE::FullScreenMode::WINDOWED + ); } else if(key == SDLK_F7) { if(formula_profiler::Manager::get()) { if(formula_profiler::Manager::get()->is_profiling()) { diff --git a/src/main.cpp b/src/main.cpp index 8f7ee83c9..d662b5a96 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -122,16 +122,9 @@ namespace PREF_INT(auto_update_timeout, 5000, "Timeout to use on auto updates (given in milliseconds)"); PREF_BOOL(resizeable, false, "Window is dynamically resizeable."); - PREF_INT(min_window_width, 934, "Minimum window width when auto-determining window size"); - PREF_INT(min_window_height, 700, "Minimum window height when auto-determining window size"); - - PREF_INT(max_window_width, 10240, "Minimum window width when auto-determining window size"); - PREF_INT(max_window_height, 7680, "Minimum window height when auto-determining window size"); PREF_BOOL(disable_global_alpha_filter, false, "Disables using alpha-colors.png to denote some special colors as 'alpha colors'"); - PREF_INT(auto_size_ideal_width, 0, ""); - PREF_INT(auto_size_ideal_height, 0, ""); PREF_BOOL(desktop_fullscreen_force, false, "(Windows) forces desktop fullscreen to actually use fullscreen rather than a borderless window the size of the desktop"); PREF_BOOL(msaa, false, "Use msaa"); @@ -355,84 +348,6 @@ namespace // behavior of the module. The `frogatto` module does not use this. PREF_BOOL(remember_me, true, "Remember me (my gamer account) when connecting to the server"); -// Seemingly, this is to select the "next common resolution down" for windowed mode. -// Takes a window, two out params for the best common w/h which will fit in the screen at 2x (?), and "reduce" (?). -void auto_select_resolution(const KRE::WindowPtr& wm, int& width, int& height, bool reduce, bool isFullscreen) -{ - auto mode = wm->getDisplaySize(); - auto best_mode = mode; - bool found = false; - - if(isFullscreen) { - LOG_INFO("RESOLUTION SET TO FULLSCREEN RESOLUTION " << mode.width << "x" << mode.height); - - width = mode.width; - height = mode.height; - - return; - } - - LOG_INFO("TARGET RESOLUTION IS " << mode.width << "x" << mode.height); - - const float MinReduction = reduce ? 0.9f : 2.0f; - for(auto& candidate_mode : wm->getWindowModes([](const KRE::WindowMode&){ return true; })) { - if(g_auto_size_ideal_width && g_auto_size_ideal_height) { - if(found && candidate_mode.width < best_mode.width) { - continue; - } - - if(candidate_mode.width > mode.width * MinReduction) { - LOG_INFO("REJECTED MODE IS " << candidate_mode.width << "x" << candidate_mode.height - << "; (width " << candidate_mode.width << " > " << mode.width * MinReduction << ")"); - continue; - } - - int h = (candidate_mode.width * g_auto_size_ideal_height) / g_auto_size_ideal_width; - if(h > mode.height * MinReduction) { - continue; - } - - best_mode = candidate_mode; - best_mode.height = h; - found = true; - - LOG_INFO("BETTER MODE IS " << best_mode.width << "x" << best_mode.height); - - } else - if( candidate_mode.width < mode.width * MinReduction - && candidate_mode.height < mode.height * MinReduction - && ((candidate_mode.width >= best_mode.width - && candidate_mode.height >= best_mode.height) || !found) - ) { - found = true; - LOG_INFO("BETTER MODE IS " << candidate_mode.width << "x" << candidate_mode.height << " vs " << best_mode.width << "x" << best_mode.height); - best_mode = candidate_mode; - } else { - LOG_INFO("REJECTED MODE IS " << candidate_mode.width << "x" << candidate_mode.height); - } - } - - if (best_mode.width < g_min_window_width || - best_mode.height < g_min_window_height) { - - best_mode.width = g_min_window_width; - best_mode.height = g_min_window_height; - } - - if (best_mode.width > g_max_window_width) { - best_mode.width = g_max_window_width; - } - - if (best_mode.height > g_max_window_height) { - best_mode.height = g_max_window_height; - } - - LOG_INFO("CHOSEN MODE IS " << best_mode.width << "x" << best_mode.height); - - width = best_mode.width; - height = best_mode.height; -} - extern int g_tile_scale; extern int g_tile_size; @@ -1033,7 +948,7 @@ int main(int argcount, char* argvec[]) int height = 0; bool isFullscreen = preferences::get_screen_mode() != preferences::ScreenMode::WINDOWED; - auto_select_resolution(main_wnd, width, height, true, isFullscreen); + graphics::GameScreen::autoSelectResolution(main_wnd, width, height, true, isFullscreen); preferences::adjust_virtual_width_to_match_physical(width, height); diff --git a/src/screen_handling.cpp b/src/screen_handling.cpp index 7e2b5fdd3..a701fb98a 100644 --- a/src/screen_handling.cpp +++ b/src/screen_handling.cpp @@ -27,9 +27,19 @@ #include "asserts.hpp" #include "screen_handling.hpp" +#include "preferences.hpp" + +extern bool g_desktop_fullscreen; //test namespace graphics { + PREF_INT(min_window_width, 934, "Minimum window width when auto-determining window size"); + PREF_INT(min_window_height, 700, "Minimum window height when auto-determining window size"); + PREF_INT(max_window_width, 10240, "Minimum window width when auto-determining window size"); + PREF_INT(max_window_height, 7680, "Minimum window height when auto-determining window size"); + PREF_INT(auto_size_ideal_width, 0, ""); + PREF_INT(auto_size_ideal_height, 0, ""); + GameScreen::GameScreen() : width_(0), height_(0), @@ -78,6 +88,128 @@ namespace graphics cam_ = std::make_shared("gs.cam", x_, virtual_width_, y_, virtual_height_); } + //should use the fullscreen mode from preferences.hpp + void GameScreen::setFullscreen(KRE::FullScreenMode mode) { + auto wnd = KRE::WindowManager::getMainWindow(); + auto& gs = graphics::GameScreen::get(); + + if(mode == KRE::FullScreenMode::FULLSCREEN_WINDOWED) + { + LOG_DEBUG("Entering full-screen mode."); + wnd->setFullscreenMode(KRE::FullScreenMode::FULLSCREEN_WINDOWED); + + if(preferences::auto_size_window() || g_desktop_fullscreen) { + SDL_DisplayMode dm; + if(SDL_GetDesktopDisplayMode(0, &dm) == 0) { + preferences::adjust_virtual_width_to_match_physical(dm.w, dm.h); + wnd->setWindowSize(dm.w, dm.h); + gs.setDimensions(dm.w, dm.h); + gs.setVirtualDimensions(preferences::requested_virtual_window_width(), preferences::requested_virtual_window_height()); + } + + } + } else { + LOG_DEBUG("Entering windowed mode."); + wnd->setFullscreenMode(KRE::FullScreenMode::WINDOWED); + + if(preferences::auto_size_window() || g_desktop_fullscreen) { + int width = 0, height = 0; + + if(preferences::requested_window_width() > 0 && preferences::requested_window_height() > 0) { + width = preferences::requested_window_width(); + height = preferences::requested_window_height(); + } else { + GameScreen::autoSelectResolution(wnd, width, height, true, false); + } + + preferences::adjust_virtual_width_to_match_physical(width, height); + + wnd->setWindowSize(width, height); + gs.setDimensions(width, height); + gs.setVirtualDimensions(preferences::requested_virtual_window_width(), preferences::requested_virtual_window_height()); + } + } + } + + + // Seemingly, this is to select the "next common resolution down" for windowed mode. + // Takes a window, two out params for the best common w/h which will fit in the screen at 2x (?), and "reduce" (?). + void GameScreen::autoSelectResolution(KRE::WindowPtr wm, int& width, int& height, bool reduce, bool isFullscreen) + { + auto mode = wm->getDisplaySize(); + auto best_mode = mode; + bool found = false; + + if(isFullscreen) { + LOG_INFO("RESOLUTION SET TO FULLSCREEN RESOLUTION " << mode.width << "x" << mode.height); + + width = mode.width; + height = mode.height; + + return; + } + + LOG_INFO("TARGET RESOLUTION IS " << mode.width << "x" << mode.height); + + const float MinReduction = reduce ? 0.9f : 2.0f; + for(auto& candidate_mode : wm->getWindowModes([](const KRE::WindowMode&){ return true; })) { + if(g_auto_size_ideal_width && g_auto_size_ideal_height) { + if(found && candidate_mode.width < best_mode.width) { + continue; + } + + if(candidate_mode.width > mode.width * MinReduction) { + LOG_INFO("REJECTED MODE IS " << candidate_mode.width << "x" << candidate_mode.height + << "; (width " << candidate_mode.width << " > " << mode.width * MinReduction << ")"); + continue; + } + + int h = (candidate_mode.width * g_auto_size_ideal_height) / g_auto_size_ideal_width; + if(h > mode.height * MinReduction) { + continue; + } + + best_mode = candidate_mode; + best_mode.height = h; + found = true; + + LOG_INFO("BETTER MODE IS " << best_mode.width << "x" << best_mode.height); + + } else + if( candidate_mode.width < mode.width * MinReduction + && candidate_mode.height < mode.height * MinReduction + && ((candidate_mode.width >= best_mode.width + && candidate_mode.height >= best_mode.height) || !found) + ) { + found = true; + LOG_INFO("BETTER MODE IS " << candidate_mode.width << "x" << candidate_mode.height << " vs " << best_mode.width << "x" << best_mode.height); + best_mode = candidate_mode; + } else { + LOG_INFO("REJECTED MODE IS " << candidate_mode.width << "x" << candidate_mode.height); + } + } + + if (best_mode.width < g_min_window_width || + best_mode.height < g_min_window_height) { + + best_mode.width = g_min_window_width; + best_mode.height = g_min_window_height; + } + + if (best_mode.width > g_max_window_width) { + best_mode.width = g_max_window_width; + } + + if (best_mode.height > g_max_window_height) { + best_mode.height = g_max_window_height; + } + + LOG_INFO("CHOSEN MODE IS " << best_mode.width << "x" << best_mode.height); + + width = best_mode.width; + height = best_mode.height; + } + void GameScreen::setupForDraw(KRE::WindowPtr wnd) { last_cam_ = KRE::DisplayDevice::getCurrent()->setDefaultCamera(cam_); @@ -102,4 +234,6 @@ namespace graphics { GameScreen::get().cleanupAfterDraw(wnd_); } + + extern bool g_desktop_fullscreen; } diff --git a/src/screen_handling.hpp b/src/screen_handling.hpp index e64f1d954..e3b71ce1f 100644 --- a/src/screen_handling.hpp +++ b/src/screen_handling.hpp @@ -51,6 +51,8 @@ namespace graphics void setLocation(int x, int y); void setDimensions(int width, int height); void setVirtualDimensions(int vwidth, int vheight); + void setFullscreen(KRE::FullScreenMode mode); + static void autoSelectResolution(KRE::WindowPtr wm, int& width, int& height, bool reduce, bool isFullscreen); KRE::CameraPtr getCurrentCamera() const { return cam_; } diff --git a/src/video_selections.cpp b/src/video_selections.cpp index b7cb71151..6b7e96257 100644 --- a/src/video_selections.cpp +++ b/src/video_selections.cpp @@ -137,6 +137,7 @@ void show_video_selection_dialog() // Video mode list. DropdownWidget* mode_list = new DropdownWidget(display_strings, 260, 20); + mode_list->setDropdownHeight(420); mode_list->setSelection(current_mode_index); mode_list->setZOrder(10); mode_list->setOnSelectHandler([&selected_mode](int selection,const std::string& s){ @@ -147,22 +148,24 @@ void show_video_selection_dialog() d.addWidget(make_font_label(_("Unable to enumerate video modes"))); } - // Fullscreen selection + preferences::ScreenMode fs_mode = preferences::get_screen_mode(); - std::vector fs_options; - fs_options.emplace_back(_("Windowed mode")); - fs_options.emplace_back(_("Fullscreen Windowed")); - //fs_options.push_back("Fullscreen"); - DropdownWidget* fs_list = new DropdownWidget(fs_options, 260, 20); - fs_list->setSelection(static_cast(preferences::get_screen_mode())); - fs_list->setZOrder(9); - fs_list->setOnSelectHandler([&fs_mode](int selection,const std::string& s){ - switch(selection) { - case 0: fs_mode = preferences::ScreenMode::WINDOWED; break; - case 1: fs_mode = preferences::ScreenMode::FULLSCREEN_WINDOWED; break; - } - }); - d.addWidget(WidgetPtr(fs_list)); + if(!preferences::no_fullscreen_ever()) { + // Fullscreen selection + std::vector fs_options; + fs_options.emplace_back(_("Windowed Mode")); + fs_options.emplace_back(_("Fullscreen Mode")); //Windowed-type fullscreen. + DropdownWidget* fs_list = new DropdownWidget(fs_options, 260, 20); + fs_list->setSelection(static_cast(preferences::get_screen_mode())); + fs_list->setZOrder(9); + fs_list->setOnSelectHandler([&fs_mode](int selection,const std::string& s){ + switch(selection) { + case 0: fs_mode = preferences::ScreenMode::WINDOWED; break; + case 1: fs_mode = preferences::ScreenMode::FULLSCREEN_WINDOWED; break; + } + }); + d.addWidget(WidgetPtr(fs_list)); + } // Vertical sync options std::vector vsync_options; @@ -198,6 +201,6 @@ void show_video_selection_dialog() if(selected_mode >= 0 && static_cast(selected_mode) < display_modes.size()) { KRE::WindowManager::getMainWindow()->setWindowSize(display_modes[selected_mode].width, display_modes[selected_mode].height); } - //preferences::set_screen_mode(fs_mode); + preferences::set_screen_mode(fs_mode); } } From 5af3c9d8cd8a3f05ff44034f67038ef045d261de Mon Sep 17 00:00:00 2001 From: DDR Date: Thu, 7 Sep 2023 22:42:02 -0700 Subject: [PATCH 3/4] Added external/ folder to gitignore, a Windows build artefact I think. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 7eac9fc7b..7369df040 100644 --- a/.gitignore +++ b/.gitignore @@ -70,6 +70,7 @@ modules/* !modules/gui !modules/tbs .vscode/ +/external/* #Ignore this, don't know why it's being created for me. imgui.ini From 44e4bae26164472eee201119866e483eecadea3a Mon Sep 17 00:00:00 2001 From: DDR Date: Sun, 17 Sep 2023 15:01:23 -0700 Subject: [PATCH 4/4] =?UTF-8?q?Made=20fullscreen=20mode=20in=20the=20esc?= =?UTF-8?q?=20menu=20work.=20Converted=20from=20dropdown=20=E2=86=92=20che?= =?UTF-8?q?ckbox.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils.cpp | 6 ----- src/utils.hpp | 1 - src/video_selections.cpp | 51 ++++++++++++++++++++-------------------- 3 files changed, 25 insertions(+), 33 deletions(-) diff --git a/src/utils.cpp b/src/utils.cpp index ee418212d..8daec422a 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -50,12 +50,6 @@ void write_autosave() sys::write_file(std::string(preferences::auto_save_file_path()) + ".stat", "1"); } -void toggle_fullscreen() -{ - auto wnd = KRE::WindowManager::getMainWindow(); - wnd->setFullscreenMode(wnd->fullscreenMode() == KRE::FullScreenMode::WINDOWED ? KRE::FullScreenMode::FULLSCREEN_WINDOWED : KRE::FullScreenMode::WINDOWED); -} - std::string get_http_datetime() { time_t rawtime; diff --git a/src/utils.hpp b/src/utils.hpp index e0856515d..3318154a5 100644 --- a/src/utils.hpp +++ b/src/utils.hpp @@ -32,7 +32,6 @@ std::string get_http_datetime(); int truncate_to_char(int value); void write_autosave(); -void toggle_fullscreen(); #if defined(_MSC_VER) int gettimeofday(struct timeval *tv, struct timezone2 *tz); diff --git a/src/video_selections.cpp b/src/video_selections.cpp index 6b7e96257..929584ea3 100644 --- a/src/video_selections.cpp +++ b/src/video_selections.cpp @@ -114,18 +114,19 @@ void show_video_selection_dialog() int selected_mode = -1; - std::function make_font_label; + std::function make_font_label; if(module::get_default_font() == "bitmap") { - make_font_label = [](const std::string& label){ - return WidgetPtr(new GraphicalFontLabel(label, "door_label", 2)); + make_font_label = [](const int size, const std::string& label){ + return WidgetPtr(new GraphicalFontLabel(label, "door_label", size)); }; } else { - make_font_label = [](const std::string& label){ - return WidgetPtr(new Label(label, 16, module::get_default_font())); + make_font_label = [](const int size, const std::string& label){ + static constexpr int sizes[] {12, 16, 18}; + return WidgetPtr(new Label(label, sizes[size], module::get_default_font())); }; } - d.addWidget(make_font_label(_("Select video options:")), padding, padding); + d.addWidget(make_font_label(2, _("Select video options:")), padding, padding); WindowModeList display_modes; int current_mode_index = enumerate_video_modes(&display_modes); if(!display_modes.empty()) { @@ -145,26 +146,17 @@ void show_video_selection_dialog() }); d.addWidget(WidgetPtr(mode_list)); } else { - d.addWidget(make_font_label(_("Unable to enumerate video modes"))); + d.addWidget(make_font_label(2, _("Unable to enumerate video modes"))); } - - preferences::ScreenMode fs_mode = preferences::get_screen_mode(); + // Fullscreen selection + Checkbox* fullscreenCheckbox = new Checkbox( + _("Fullscreen"), + KRE::WindowManager::getMainWindow()->fullscreenMode() != KRE::FullScreenMode::WINDOWED, + [](bool checked) { /* Do nothing here, only apply on dialog OK. */ } + ); if(!preferences::no_fullscreen_ever()) { - // Fullscreen selection - std::vector fs_options; - fs_options.emplace_back(_("Windowed Mode")); - fs_options.emplace_back(_("Fullscreen Mode")); //Windowed-type fullscreen. - DropdownWidget* fs_list = new DropdownWidget(fs_options, 260, 20); - fs_list->setSelection(static_cast(preferences::get_screen_mode())); - fs_list->setZOrder(9); - fs_list->setOnSelectHandler([&fs_mode](int selection,const std::string& s){ - switch(selection) { - case 0: fs_mode = preferences::ScreenMode::WINDOWED; break; - case 1: fs_mode = preferences::ScreenMode::FULLSCREEN_WINDOWED; break; - } - }); - d.addWidget(WidgetPtr(fs_list)); + d.addWidget(WidgetPtr(fullscreenCheckbox)); } // Vertical sync options @@ -184,10 +176,10 @@ void show_video_selection_dialog() }); d.addWidget(WidgetPtr(synch_list)); - WidgetPtr b_okay = new Button(make_font_label(_("OK")), [&d](){ + WidgetPtr b_okay = new Button(make_font_label(2, _("OK")), [&d](){ d.close(); }); - WidgetPtr b_cancel = new Button(make_font_label(_("Cancel")), [&d](){ + WidgetPtr b_cancel = new Button(make_font_label(2, _("Cancel")), [&d](){ d.cancel(); }); b_okay->setDim(button_width, button_height); @@ -201,6 +193,13 @@ void show_video_selection_dialog() if(selected_mode >= 0 && static_cast(selected_mode) < display_modes.size()) { KRE::WindowManager::getMainWindow()->setWindowSize(display_modes[selected_mode].width, display_modes[selected_mode].height); } - preferences::set_screen_mode(fs_mode); + + KRE::WindowManager::getMainWindow()->setFullscreenMode(fullscreenCheckbox->checked() + ? KRE::FullScreenMode::FULLSCREEN_WINDOWED + : KRE::FullScreenMode::WINDOWED); + preferences::set_screen_mode( + KRE::WindowManager::getMainWindow()->fullscreenMode() == KRE::FullScreenMode::WINDOWED + ? preferences::ScreenMode::WINDOWED + : preferences::ScreenMode::FULLSCREEN_WINDOWED); } }