Enable new screen resizing code
This commit is contained in:
parent
6e2d528b91
commit
aba99c22b6
@ -437,7 +437,7 @@ bool CIrrDeviceSDL::createWindow()
|
||||
}
|
||||
}
|
||||
|
||||
u32 flags = SDL_WINDOW_SHOWN;
|
||||
u32 flags = SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE;
|
||||
#if !defined(ANDROID) && !defined(__SWITCH__)
|
||||
if (CreationParams.DriverType == video::EDT_OPENGL ||
|
||||
CreationParams.DriverType == video::EDT_OGLES2 ||
|
||||
|
@ -805,7 +805,7 @@ begin:
|
||||
}
|
||||
|
||||
// This remaps the window, so it has to be done before the clear to avoid flicker
|
||||
m_device->setResizable(false);
|
||||
//m_device->setResizable(false);
|
||||
|
||||
// Immediate clear to black for a nicer user loading experience
|
||||
m_video_driver->beginScene(/*backBuffer clear*/true, /* Z */ false);
|
||||
@ -2078,14 +2078,11 @@ void IrrDriver::doScreenShot()
|
||||
// ----------------------------------------------------------------------------
|
||||
void IrrDriver::handleWindowResize()
|
||||
{
|
||||
bool dialog_exists = GUIEngine::ModalDialog::isADialogActive() ||
|
||||
GUIEngine::ScreenKeyboard::isActive();
|
||||
|
||||
// This will allow main menu auto resize if missed a resize event
|
||||
core::dimension2du current_screen_size =
|
||||
m_video_driver->getCurrentRenderTargetSize();
|
||||
GUIEngine::Screen* screen = GUIEngine::getCurrentScreen();
|
||||
if (screen && screen->isResizable())
|
||||
if (screen)
|
||||
{
|
||||
current_screen_size.Width = screen->getWidth();
|
||||
current_screen_size.Height = screen->getHeight();
|
||||
@ -2102,8 +2099,8 @@ void IrrDriver::handleWindowResize()
|
||||
current_screen_size != new_size ||
|
||||
screen_orientation_changed)
|
||||
{
|
||||
// Don't update when dialog is opened or minimized
|
||||
if (dialog_exists || new_size.getArea() == 0)
|
||||
// Don't update when minimized
|
||||
if (new_size.getArea() == 0)
|
||||
return;
|
||||
|
||||
m_screen_orientation = new_orientation;
|
||||
@ -2114,11 +2111,6 @@ void IrrDriver::handleWindowResize()
|
||||
UserConfigParams::m_real_height = (unsigned)((float)m_actual_screen_size.Height / m_device->getNativeScaleY());
|
||||
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
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -311,40 +311,3 @@ void AbstractStateManager::resetAndSetStack(Screen* screens[])
|
||||
|
||||
onTopMostScreenChanged();
|
||||
} // resetAndSetStack
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void AbstractStateManager::onResize()
|
||||
{
|
||||
// Happens in the first resize in main.cpp
|
||||
if (m_menu_stack.empty())
|
||||
return;
|
||||
|
||||
// In game resizing
|
||||
if (m_menu_stack[0].first == RACE_STATE_NAME)
|
||||
{
|
||||
if (m_menu_stack.size() == 1)
|
||||
{
|
||||
clearScreenCache();
|
||||
m_menu_stack.emplace_back(RACE_STATE_NAME, (Screen*)NULL);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// For some window manager it sends resize event when STK is not focus
|
||||
// even if the screen is not resizable, prevent it from resizing if wrong
|
||||
// screen
|
||||
if (!m_menu_stack.back().second ||
|
||||
!m_menu_stack.back().second->isResizable())
|
||||
return;
|
||||
|
||||
std::vector<std::function<Screen*()> > screen_function;
|
||||
for (auto& p : m_menu_stack)
|
||||
screen_function.push_back(p.second->getNewScreenPointer());
|
||||
clearScreenCache();
|
||||
std::vector<Screen*> new_screen;
|
||||
for (auto& screen : screen_function)
|
||||
new_screen.push_back(screen());
|
||||
new_screen.push_back(NULL);
|
||||
resetAndSetStack(new_screen.data());
|
||||
} // onResize
|
||||
|
@ -111,11 +111,6 @@ namespace GUIEngine
|
||||
*/
|
||||
void resetAndSetStack(Screen* screens[]);
|
||||
|
||||
/**
|
||||
* \brief Called when resizing of stk window
|
||||
*/
|
||||
void onResize();
|
||||
|
||||
/**
|
||||
* \brief Used in no graphics STK to enter menu screen (when server is
|
||||
* idle state)
|
||||
|
@ -1240,7 +1240,10 @@ namespace GUIEngine
|
||||
g_small_title_font->getDimension( L"X" ).Height;
|
||||
Private::tiny_title_font_height =
|
||||
g_tiny_title_font->getDimension( L"X" ).Height;
|
||||
StateManager::get()->onResize();
|
||||
if (ScreenKeyboard::isActive())
|
||||
ScreenKeyboard::getCurrent()->onResize();
|
||||
if (ModalDialog::isADialogActive())
|
||||
ModalDialog::getCurrent()->onResize();
|
||||
} // reloadForNewSize
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
@ -1283,6 +1286,16 @@ namespace GUIEngine
|
||||
|
||||
GameState gamestate = g_state_manager->getGameState();
|
||||
|
||||
core::dimension2d<u32> screen_size = irr_driver->getFrameSize();
|
||||
core::dimension2d<u32> cur_screen_size;
|
||||
if (getCurrentScreen())
|
||||
{
|
||||
cur_screen_size.Width = getCurrentScreen()->getWidth();
|
||||
cur_screen_size.Height = getCurrentScreen()->getHeight();
|
||||
if (screen_size != cur_screen_size)
|
||||
getCurrentScreen()->onResize();
|
||||
}
|
||||
|
||||
// ---- some menus may need updating
|
||||
bool dialog_opened = false;
|
||||
|
||||
@ -1372,7 +1385,6 @@ namespace GUIEngine
|
||||
|
||||
if (gamestate != GAME && !gui_messages.empty())
|
||||
{
|
||||
core::dimension2d<u32> screen_size = irr_driver->getFrameSize();
|
||||
const int text_height = getFontHeight() + 20;
|
||||
const int y_from = screen_size.Height - text_height;
|
||||
|
||||
|
@ -60,8 +60,6 @@ ModalDialog::ModalDialog(const float percentWidth, const float percentHeight,
|
||||
m_percent_width = percentWidth;
|
||||
m_percent_height = percentHeight;
|
||||
m_irrlicht_window = NULL;
|
||||
m_was_resizable = irr_driver->getDevice()->isResizable();
|
||||
irr_driver->getDevice()->setResizable(false);
|
||||
} // ModalDialog
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -191,7 +189,6 @@ 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,6 @@ 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;
|
||||
|
@ -58,7 +58,6 @@ Screen::Screen(const char* file, bool pause_race)
|
||||
m_update_in_background = false;
|
||||
m_width = irr_driver->getActualScreenSize().Width;
|
||||
m_height = irr_driver->getActualScreenSize().Height;
|
||||
m_resizable = false;
|
||||
} // Screen
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -71,9 +71,6 @@ namespace GUIEngine
|
||||
if (singleton == NULL)
|
||||
{
|
||||
singleton = new SCREEN();
|
||||
std::function<SCREEN*()> new_screen_function = []()
|
||||
{ return ScreenSingleton::getInstance(); };
|
||||
singleton->setScreenPointerFunction(new_screen_function);
|
||||
GUIEngine::addScreenToList(singleton);
|
||||
}
|
||||
|
||||
@ -95,10 +92,6 @@ namespace GUIEngine
|
||||
*/
|
||||
class Screen : public AbstractTopLevelContainer
|
||||
{
|
||||
protected:
|
||||
/** True if this screen is resizable
|
||||
*/
|
||||
bool m_resizable;
|
||||
private:
|
||||
/** True if the race (if it is running) should be paused when this
|
||||
* screen is shown. The RaceResultGUI uses this to leave the race
|
||||
@ -143,13 +136,6 @@ protected:
|
||||
PtrVector<Widget>& append_to,
|
||||
irr::gui::IGUIElement* parent = NULL);
|
||||
|
||||
/** Save the function before GUIEngine::clearScreenCache, call it after
|
||||
* to get the new screen instance pointer
|
||||
*/
|
||||
std::function<Screen*()> getNewScreenPointer() const { return m_screen_func; }
|
||||
|
||||
void setScreenPointerFunction(const std::function<Screen*()>& f) { m_screen_func = f; }
|
||||
|
||||
Screen(bool pause_race=true);
|
||||
|
||||
Screen(const char* filename, bool pause_race=true);
|
||||
@ -308,7 +294,6 @@ protected:
|
||||
|
||||
virtual int getHeight() { return m_height; }
|
||||
|
||||
virtual bool isResizable() const { return m_resizable; }
|
||||
/**
|
||||
* \brief Override this if you need to be notified of player actions
|
||||
* in subclasses.
|
||||
|
@ -129,8 +129,6 @@ World* World::m_world[PT_COUNT];
|
||||
*/
|
||||
World::World() : WorldStatus()
|
||||
{
|
||||
if (m_process_type == PT_MAIN)
|
||||
GUIEngine::getDevice()->setResizable(true);
|
||||
RewindManager::setEnable(NetworkConfig::get()->isNetworking());
|
||||
#ifdef DEBUG
|
||||
m_magic_number = 0xB01D6543;
|
||||
@ -614,7 +612,6 @@ World::~World()
|
||||
{
|
||||
if (m_process_type == PT_MAIN)
|
||||
{
|
||||
GUIEngine::getDevice()->setResizable(false);
|
||||
material_manager->unloadAllTextures();
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,6 @@ using namespace Online;
|
||||
|
||||
MainMenuScreen::MainMenuScreen() : Screen("main_menu.stkgui")
|
||||
{
|
||||
m_resizable = true;
|
||||
} // MainMenuScreen
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -125,7 +124,6 @@ void MainMenuScreen::beforeAddingWidget()
|
||||
//
|
||||
void MainMenuScreen::init()
|
||||
{
|
||||
GUIEngine::getDevice()->setResizable(true);
|
||||
Screen::init();
|
||||
|
||||
m_user_id = getWidget<ButtonWidget>("user-id");
|
||||
@ -612,7 +610,6 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
|
||||
void MainMenuScreen::tearDown()
|
||||
{
|
||||
GUIEngine::getDevice()->setResizable(false);
|
||||
} // tearDown
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -66,7 +66,6 @@ using namespace Online;
|
||||
|
||||
OptionsScreenGeneral::OptionsScreenGeneral() : Screen("options/options_general.stkgui")
|
||||
{
|
||||
m_resizable = true;
|
||||
m_inited = false;
|
||||
} // OptionsScreenVideo
|
||||
|
||||
@ -81,8 +80,6 @@ void OptionsScreenGeneral::loadedFromFile()
|
||||
|
||||
void OptionsScreenGeneral::init()
|
||||
{
|
||||
GUIEngine::getDevice()->setResizable(
|
||||
StateManager::get()->getGameState() == GUIEngine::MENU);
|
||||
Screen::init();
|
||||
RibbonWidget* ribbon = getWidget<RibbonWidget>("options_choice");
|
||||
assert(ribbon != NULL);
|
||||
@ -283,7 +280,6 @@ void OptionsScreenGeneral::setInternetCheckboxes(bool activate)
|
||||
|
||||
void OptionsScreenGeneral::tearDown()
|
||||
{
|
||||
GUIEngine::getDevice()->setResizable(false);
|
||||
Screen::tearDown();
|
||||
// save changes when leaving screen
|
||||
user_config->saveConfig();
|
||||
|
@ -205,7 +205,6 @@ OptionsScreenVideo::OptionsScreenVideo() : Screen("options/options_video.stkgui"
|
||||
m_prev_adv_pipline(false),
|
||||
m_prev_img_quality(-1)
|
||||
{
|
||||
m_resizable = true;
|
||||
m_inited = false;
|
||||
initPresets();
|
||||
} // OptionsScreenVideo
|
||||
@ -235,8 +234,6 @@ void OptionsScreenVideo::loadedFromFile()
|
||||
|
||||
void OptionsScreenVideo::init()
|
||||
{
|
||||
GUIEngine::getDevice()->setResizable(
|
||||
StateManager::get()->getGameState() == GUIEngine::MENU);
|
||||
Screen::init();
|
||||
m_prev_adv_pipline = UserConfigParams::m_dynamic_lights;
|
||||
m_prev_img_quality = getImageQuality();
|
||||
@ -367,12 +364,6 @@ void OptionsScreenVideo::init()
|
||||
|
||||
updateResolutionsList();
|
||||
|
||||
if (m_fullscreen_checkbox_focus)
|
||||
{
|
||||
m_fullscreen_checkbox_focus = false;
|
||||
getWidget("fullscreen")->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
|
||||
}
|
||||
|
||||
// If a benchmark was requested and the game had to reload
|
||||
// the graphics engine, start the benchmark when the
|
||||
// video settings screen is loaded back afterwards.
|
||||
@ -386,6 +377,13 @@ void OptionsScreenVideo::onResize()
|
||||
{
|
||||
Screen::onResize();
|
||||
configResolutionsList();
|
||||
if (m_fullscreen_checkbox_focus)
|
||||
{
|
||||
m_fullscreen_checkbox_focus = false;
|
||||
Widget* full = getWidget("fullscreen");
|
||||
if (full->isActivated() && full->isVisible())
|
||||
full->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
|
||||
}
|
||||
} // onResize
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
@ -987,24 +985,7 @@ void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name,
|
||||
{
|
||||
UserConfigParams::m_fullscreen = fullscreen->getState();
|
||||
update_fullscreen_desktop(UserConfigParams::m_fullscreen);
|
||||
if (StateManager::get()->getGameState() == GUIEngine::INGAME_MENU)
|
||||
{
|
||||
StateManager::get()->popMenu();
|
||||
std::function<Screen*()> screen_function =
|
||||
getNewScreenPointer();
|
||||
int new_width = 0;
|
||||
int new_height = 0;
|
||||
SDL_GetWindowSize(gevk->getSDLWindow(), &new_width,
|
||||
&new_height);
|
||||
static_cast<CIrrDeviceSDL*>(gevk->getIrrlichtDevice())
|
||||
->handleNewSize(new_width, new_height);
|
||||
irr_driver->handleWindowResize();
|
||||
Screen* new_screen = screen_function();
|
||||
OptionsScreenVideo::m_fullscreen_checkbox_focus = true;
|
||||
new_screen->push();
|
||||
}
|
||||
else
|
||||
OptionsScreenVideo::m_fullscreen_checkbox_focus = true;
|
||||
OptionsScreenVideo::m_fullscreen_checkbox_focus = true;
|
||||
}
|
||||
else
|
||||
updateResolutionsList();
|
||||
@ -1034,11 +1015,6 @@ void OptionsScreenVideo::startBenchmark()
|
||||
|
||||
void OptionsScreenVideo::tearDown()
|
||||
{
|
||||
if (getWidget("fullscreen")->isVisible() &&
|
||||
getWidget("fullscreen")->isFocusedForPlayer(PLAYER_ID_GAME_MASTER))
|
||||
OptionsScreenVideo::m_fullscreen_checkbox_focus = true;
|
||||
|
||||
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