Improve in game resizing handling
This commit is contained in:
parent
0a7f9cd314
commit
23a26648d8
@ -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. */
|
||||
|
@ -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()
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -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
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -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<RibbonWidget>("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();
|
||||
|
@ -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())
|
||||
|
Loading…
Reference in New Issue
Block a user