diff --git a/lib/irrlicht/include/IrrlichtDevice.h b/lib/irrlicht/include/IrrlichtDevice.h index 70476d69c..3de6e3627 100644 --- a/lib/irrlicht/include/IrrlichtDevice.h +++ b/lib/irrlicht/include/IrrlichtDevice.h @@ -319,6 +319,7 @@ namespace irr virtual s32 getLeftPadding() { return 0; } virtual s32 getRightPadding() { return 0; } virtual void setWindowMinimumSize(u32 width, u32 height) {} + virtual bool isResizable() const { return false; } //! Check if a driver type is supported by the engine. /** Even if true is returned the driver may not be available for a configuration requested when creating the device. */ diff --git a/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.cpp b/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.cpp index 9e12337fa..2b084cbeb 100644 --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.cpp +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.cpp @@ -45,7 +45,7 @@ CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param) Window(0), Context(0), MouseX(0), MouseY(0), MouseButtonStates(0), Width(param.WindowSize.Width), Height(param.WindowSize.Height), - WindowHasFocus(false), WindowMinimized(false) + WindowHasFocus(false), WindowMinimized(false), Resizable(false) { #ifdef _DEBUG setDebugName("CIrrDeviceSDL"); @@ -637,10 +637,19 @@ void CIrrDeviceSDL::setResizable(bool resize) if (CreationParams.Fullscreen) return; SDL_SetWindowResizable(Window, resize ? SDL_TRUE : SDL_FALSE); + Resizable = resize; #endif } +bool CIrrDeviceSDL::isResizable() const +{ + if (CreationParams.Fullscreen) + return false; + return Resizable; +} + + //! Minimizes window if possible void CIrrDeviceSDL::minimizeWindow() { diff --git a/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.h b/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.h index b2cda8bc1..b086d20ea 100644 --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.h +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.h @@ -71,6 +71,8 @@ namespace irr //! Sets if the window should be resizable in windowed mode. virtual void setResizable(bool resize=false); + virtual bool isResizable() const; + //! Minimizes the window. virtual void minimizeWindow(); @@ -215,6 +217,7 @@ namespace irr bool WindowHasFocus; bool WindowMinimized; + bool Resizable; struct SKeyMap { diff --git a/src/graphics/irr_driver.cpp b/src/graphics/irr_driver.cpp index 30a7d2efe..c422f48dd 100644 --- a/src/graphics/irr_driver.cpp +++ b/src/graphics/irr_driver.cpp @@ -1992,11 +1992,12 @@ void IrrDriver::doScreenShot() // ---------------------------------------------------------------------------- void IrrDriver::handleWindowResize() { + bool dialog_exists = GUIEngine::ModalDialog::isADialogActive() || + GUIEngine::ScreenKeyboard::isActive(); if (m_actual_screen_size != m_video_driver->getCurrentRenderTargetSize()) { // Don't update when dialog is opened - if (GUIEngine::ModalDialog::isADialogActive() || - GUIEngine::ScreenKeyboard::isActive()) + if (dialog_exists) return; m_actual_screen_size = m_video_driver->getCurrentRenderTargetSize(); @@ -2004,6 +2005,11 @@ void IrrDriver::handleWindowResize() UserConfigParams::m_height = m_actual_screen_size.Height; resizeWindow(); } + // In case reset by opening options in game + if (!dialog_exists && + StateManager::get()->getGameState() == GUIEngine::GAME && + !m_device->isResizable()) + m_device->setResizable(true); } // handleWindowResize // ---------------------------------------------------------------------------- diff --git a/src/guiengine/modaldialog.cpp b/src/guiengine/modaldialog.cpp index 1d7b37845..61741ad88 100644 --- a/src/guiengine/modaldialog.cpp +++ b/src/guiengine/modaldialog.cpp @@ -58,6 +58,8 @@ ModalDialog::ModalDialog(const float percentWidth, const float percentHeight, m_percent_width = percentWidth; m_percent_height = percentHeight; m_irrlicht_window = NULL; + m_was_resizable = GUIEngine::getDevice()->isResizable(); + GUIEngine::getDevice()->setResizable(false); } // ModalDialog // ---------------------------------------------------------------------------- @@ -175,6 +177,7 @@ ModalDialog::~ModalDialog() // to the deleted widgets will be gone, but some widgets // may want to perform additional cleanup at this time elementsWereDeleted(); + GUIEngine::getDevice()->setResizable(m_was_resizable); } // ~ModalDialog // ---------------------------------------------------------------------------- diff --git a/src/guiengine/modaldialog.hpp b/src/guiengine/modaldialog.hpp index 37519b1db..d12847610 100644 --- a/src/guiengine/modaldialog.hpp +++ b/src/guiengine/modaldialog.hpp @@ -60,7 +60,7 @@ namespace GUIEngine float m_percent_width, m_percent_height; bool m_init; - + bool m_was_resizable; protected: irr::gui::IGUIWindow* m_irrlicht_window; irr::core::rect< irr::s32 > m_area; diff --git a/src/states_screens/dialogs/custom_video_settings.cpp b/src/states_screens/dialogs/custom_video_settings.cpp index 4e20e541f..49ca4621c 100644 --- a/src/states_screens/dialogs/custom_video_settings.cpp +++ b/src/states_screens/dialogs/custom_video_settings.cpp @@ -40,7 +40,6 @@ using namespace irr::gui; CustomVideoSettingsDialog::CustomVideoSettingsDialog(const float w, const float h) : ModalDialog(w, h) { - GUIEngine::getDevice()->setResizable(false); loadFromFile("custom_video_settings.stkgui"); updateActivation(); } @@ -49,7 +48,6 @@ CustomVideoSettingsDialog::CustomVideoSettingsDialog(const float w, const float CustomVideoSettingsDialog::~CustomVideoSettingsDialog() { - GUIEngine::getDevice()->setResizable(true); } // ----------------------------------------------------------------------------- diff --git a/src/states_screens/options/options_screen_general.cpp b/src/states_screens/options/options_screen_general.cpp index 4c2ad1839..04fef46fb 100644 --- a/src/states_screens/options/options_screen_general.cpp +++ b/src/states_screens/options/options_screen_general.cpp @@ -78,8 +78,8 @@ void OptionsScreenGeneral::loadedFromFile() void OptionsScreenGeneral::init() { - if (StateManager::get()->getGameState() == GUIEngine::MENU) - GUIEngine::getDevice()->setResizable(true); + GUIEngine::getDevice()->setResizable( + StateManager::get()->getGameState() == GUIEngine::MENU); Screen::init(); RibbonWidget* ribbon = getWidget("options_choice"); assert(ribbon != NULL); @@ -279,8 +279,7 @@ void OptionsScreenGeneral::setInternetCheckboxes(bool activate) void OptionsScreenGeneral::tearDown() { - if (StateManager::get()->getGameState() == GUIEngine::MENU) - GUIEngine::getDevice()->setResizable(false); + GUIEngine::getDevice()->setResizable(false); Screen::tearDown(); // save changes when leaving screen user_config->saveConfig(); diff --git a/src/states_screens/options/options_screen_video.cpp b/src/states_screens/options/options_screen_video.cpp index c2ad17993..99665c3b2 100644 --- a/src/states_screens/options/options_screen_video.cpp +++ b/src/states_screens/options/options_screen_video.cpp @@ -192,8 +192,8 @@ void OptionsScreenVideo::loadedFromFile() void OptionsScreenVideo::init() { - if (StateManager::get()->getGameState() == GUIEngine::MENU) - GUIEngine::getDevice()->setResizable(true); + GUIEngine::getDevice()->setResizable( + StateManager::get()->getGameState() == GUIEngine::MENU); Screen::init(); m_prev_adv_pipline = UserConfigParams::m_dynamic_lights; m_prev_img_quality = getImageQuality(); @@ -747,8 +747,7 @@ void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name, void OptionsScreenVideo::tearDown() { - if (StateManager::get()->getGameState() == GUIEngine::MENU) - GUIEngine::getDevice()->setResizable(false); + GUIEngine::getDevice()->setResizable(false); #ifndef SERVER_ONLY if (m_prev_adv_pipline != UserConfigParams::m_dynamic_lights && CVS->isGLSL())