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 getLeftPadding() { return 0; }
|
||||||
virtual s32 getRightPadding() { return 0; }
|
virtual s32 getRightPadding() { return 0; }
|
||||||
virtual void setWindowMinimumSize(u32 width, u32 height) {}
|
virtual void setWindowMinimumSize(u32 width, u32 height) {}
|
||||||
|
virtual bool isResizable() const { return false; }
|
||||||
//! Check if a driver type is supported by the engine.
|
//! Check if a driver type is supported by the engine.
|
||||||
/** Even if true is returned the driver may not be available
|
/** Even if true is returned the driver may not be available
|
||||||
for a configuration requested when creating the device. */
|
for a configuration requested when creating the device. */
|
||||||
|
@ -45,7 +45,7 @@ CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param)
|
|||||||
Window(0), Context(0),
|
Window(0), Context(0),
|
||||||
MouseX(0), MouseY(0), MouseButtonStates(0),
|
MouseX(0), MouseY(0), MouseButtonStates(0),
|
||||||
Width(param.WindowSize.Width), Height(param.WindowSize.Height),
|
Width(param.WindowSize.Width), Height(param.WindowSize.Height),
|
||||||
WindowHasFocus(false), WindowMinimized(false)
|
WindowHasFocus(false), WindowMinimized(false), Resizable(false)
|
||||||
{
|
{
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
setDebugName("CIrrDeviceSDL");
|
setDebugName("CIrrDeviceSDL");
|
||||||
@ -637,10 +637,19 @@ void CIrrDeviceSDL::setResizable(bool resize)
|
|||||||
if (CreationParams.Fullscreen)
|
if (CreationParams.Fullscreen)
|
||||||
return;
|
return;
|
||||||
SDL_SetWindowResizable(Window, resize ? SDL_TRUE : SDL_FALSE);
|
SDL_SetWindowResizable(Window, resize ? SDL_TRUE : SDL_FALSE);
|
||||||
|
Resizable = resize;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool CIrrDeviceSDL::isResizable() const
|
||||||
|
{
|
||||||
|
if (CreationParams.Fullscreen)
|
||||||
|
return false;
|
||||||
|
return Resizable;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//! Minimizes window if possible
|
//! Minimizes window if possible
|
||||||
void CIrrDeviceSDL::minimizeWindow()
|
void CIrrDeviceSDL::minimizeWindow()
|
||||||
{
|
{
|
||||||
|
@ -71,6 +71,8 @@ namespace irr
|
|||||||
//! Sets if the window should be resizable in windowed mode.
|
//! Sets if the window should be resizable in windowed mode.
|
||||||
virtual void setResizable(bool resize=false);
|
virtual void setResizable(bool resize=false);
|
||||||
|
|
||||||
|
virtual bool isResizable() const;
|
||||||
|
|
||||||
//! Minimizes the window.
|
//! Minimizes the window.
|
||||||
virtual void minimizeWindow();
|
virtual void minimizeWindow();
|
||||||
|
|
||||||
@ -215,6 +217,7 @@ namespace irr
|
|||||||
|
|
||||||
bool WindowHasFocus;
|
bool WindowHasFocus;
|
||||||
bool WindowMinimized;
|
bool WindowMinimized;
|
||||||
|
bool Resizable;
|
||||||
|
|
||||||
struct SKeyMap
|
struct SKeyMap
|
||||||
{
|
{
|
||||||
|
@ -1992,11 +1992,12 @@ void IrrDriver::doScreenShot()
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
void IrrDriver::handleWindowResize()
|
void IrrDriver::handleWindowResize()
|
||||||
{
|
{
|
||||||
|
bool dialog_exists = GUIEngine::ModalDialog::isADialogActive() ||
|
||||||
|
GUIEngine::ScreenKeyboard::isActive();
|
||||||
if (m_actual_screen_size != m_video_driver->getCurrentRenderTargetSize())
|
if (m_actual_screen_size != m_video_driver->getCurrentRenderTargetSize())
|
||||||
{
|
{
|
||||||
// Don't update when dialog is opened
|
// Don't update when dialog is opened
|
||||||
if (GUIEngine::ModalDialog::isADialogActive() ||
|
if (dialog_exists)
|
||||||
GUIEngine::ScreenKeyboard::isActive())
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_actual_screen_size = m_video_driver->getCurrentRenderTargetSize();
|
m_actual_screen_size = m_video_driver->getCurrentRenderTargetSize();
|
||||||
@ -2004,6 +2005,11 @@ void IrrDriver::handleWindowResize()
|
|||||||
UserConfigParams::m_height = m_actual_screen_size.Height;
|
UserConfigParams::m_height = m_actual_screen_size.Height;
|
||||||
resizeWindow();
|
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
|
} // handleWindowResize
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@ -58,6 +58,8 @@ ModalDialog::ModalDialog(const float percentWidth, const float percentHeight,
|
|||||||
m_percent_width = percentWidth;
|
m_percent_width = percentWidth;
|
||||||
m_percent_height = percentHeight;
|
m_percent_height = percentHeight;
|
||||||
m_irrlicht_window = NULL;
|
m_irrlicht_window = NULL;
|
||||||
|
m_was_resizable = GUIEngine::getDevice()->isResizable();
|
||||||
|
GUIEngine::getDevice()->setResizable(false);
|
||||||
} // ModalDialog
|
} // ModalDialog
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@ -175,6 +177,7 @@ ModalDialog::~ModalDialog()
|
|||||||
// to the deleted widgets will be gone, but some widgets
|
// to the deleted widgets will be gone, but some widgets
|
||||||
// may want to perform additional cleanup at this time
|
// may want to perform additional cleanup at this time
|
||||||
elementsWereDeleted();
|
elementsWereDeleted();
|
||||||
|
GUIEngine::getDevice()->setResizable(m_was_resizable);
|
||||||
} // ~ModalDialog
|
} // ~ModalDialog
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@ -60,7 +60,7 @@ namespace GUIEngine
|
|||||||
|
|
||||||
float m_percent_width, m_percent_height;
|
float m_percent_width, m_percent_height;
|
||||||
bool m_init;
|
bool m_init;
|
||||||
|
bool m_was_resizable;
|
||||||
protected:
|
protected:
|
||||||
irr::gui::IGUIWindow* m_irrlicht_window;
|
irr::gui::IGUIWindow* m_irrlicht_window;
|
||||||
irr::core::rect< irr::s32 > m_area;
|
irr::core::rect< irr::s32 > m_area;
|
||||||
|
@ -40,7 +40,6 @@ using namespace irr::gui;
|
|||||||
CustomVideoSettingsDialog::CustomVideoSettingsDialog(const float w, const float h) :
|
CustomVideoSettingsDialog::CustomVideoSettingsDialog(const float w, const float h) :
|
||||||
ModalDialog(w, h)
|
ModalDialog(w, h)
|
||||||
{
|
{
|
||||||
GUIEngine::getDevice()->setResizable(false);
|
|
||||||
loadFromFile("custom_video_settings.stkgui");
|
loadFromFile("custom_video_settings.stkgui");
|
||||||
updateActivation();
|
updateActivation();
|
||||||
}
|
}
|
||||||
@ -49,7 +48,6 @@ CustomVideoSettingsDialog::CustomVideoSettingsDialog(const float w, const float
|
|||||||
|
|
||||||
CustomVideoSettingsDialog::~CustomVideoSettingsDialog()
|
CustomVideoSettingsDialog::~CustomVideoSettingsDialog()
|
||||||
{
|
{
|
||||||
GUIEngine::getDevice()->setResizable(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
@ -78,8 +78,8 @@ void OptionsScreenGeneral::loadedFromFile()
|
|||||||
|
|
||||||
void OptionsScreenGeneral::init()
|
void OptionsScreenGeneral::init()
|
||||||
{
|
{
|
||||||
if (StateManager::get()->getGameState() == GUIEngine::MENU)
|
GUIEngine::getDevice()->setResizable(
|
||||||
GUIEngine::getDevice()->setResizable(true);
|
StateManager::get()->getGameState() == GUIEngine::MENU);
|
||||||
Screen::init();
|
Screen::init();
|
||||||
RibbonWidget* ribbon = getWidget<RibbonWidget>("options_choice");
|
RibbonWidget* ribbon = getWidget<RibbonWidget>("options_choice");
|
||||||
assert(ribbon != NULL);
|
assert(ribbon != NULL);
|
||||||
@ -279,8 +279,7 @@ void OptionsScreenGeneral::setInternetCheckboxes(bool activate)
|
|||||||
|
|
||||||
void OptionsScreenGeneral::tearDown()
|
void OptionsScreenGeneral::tearDown()
|
||||||
{
|
{
|
||||||
if (StateManager::get()->getGameState() == GUIEngine::MENU)
|
GUIEngine::getDevice()->setResizable(false);
|
||||||
GUIEngine::getDevice()->setResizable(false);
|
|
||||||
Screen::tearDown();
|
Screen::tearDown();
|
||||||
// save changes when leaving screen
|
// save changes when leaving screen
|
||||||
user_config->saveConfig();
|
user_config->saveConfig();
|
||||||
|
@ -192,8 +192,8 @@ void OptionsScreenVideo::loadedFromFile()
|
|||||||
|
|
||||||
void OptionsScreenVideo::init()
|
void OptionsScreenVideo::init()
|
||||||
{
|
{
|
||||||
if (StateManager::get()->getGameState() == GUIEngine::MENU)
|
GUIEngine::getDevice()->setResizable(
|
||||||
GUIEngine::getDevice()->setResizable(true);
|
StateManager::get()->getGameState() == GUIEngine::MENU);
|
||||||
Screen::init();
|
Screen::init();
|
||||||
m_prev_adv_pipline = UserConfigParams::m_dynamic_lights;
|
m_prev_adv_pipline = UserConfigParams::m_dynamic_lights;
|
||||||
m_prev_img_quality = getImageQuality();
|
m_prev_img_quality = getImageQuality();
|
||||||
@ -747,8 +747,7 @@ void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name,
|
|||||||
|
|
||||||
void OptionsScreenVideo::tearDown()
|
void OptionsScreenVideo::tearDown()
|
||||||
{
|
{
|
||||||
if (StateManager::get()->getGameState() == GUIEngine::MENU)
|
GUIEngine::getDevice()->setResizable(false);
|
||||||
GUIEngine::getDevice()->setResizable(false);
|
|
||||||
#ifndef SERVER_ONLY
|
#ifndef SERVER_ONLY
|
||||||
if (m_prev_adv_pipline != UserConfigParams::m_dynamic_lights &&
|
if (m_prev_adv_pipline != UserConfigParams::m_dynamic_lights &&
|
||||||
CVS->isGLSL())
|
CVS->isGLSL())
|
||||||
|
Loading…
Reference in New Issue
Block a user