Keep fullscreen checkbox focus when toggling it

This commit is contained in:
Benau 2022-08-30 09:27:54 +08:00
parent 7a9300b56a
commit 1703e829eb
3 changed files with 35 additions and 10 deletions

View File

@ -35,10 +35,10 @@
<div width="100%" height="fit" layout="horizontal-row"> <div width="100%" height="fit" layout="horizontal-row">
<spacer width="3%" height="100%" /> <spacer width="3%" height="100%" />
<div layout="vertical-row" width="10f" height="fit"> <div layout="vertical-row" width="10f" height="fit">
<gauge id="gfx_level" min_value="1" max_value="8" width="100%" align="center" /> <gauge id="scale_rtts" min_value="0" max_value="7" width="100%" align="center" />
</div> </div>
<div layout="vertical-row" proportion="1" height="100%"> <div layout="vertical-row" proportion="1" height="100%">
<label height="100%" I18N="In the video settings" text="Graphical Effects Level" align="left"/> <label id="scale_rtts_label" height="100%" I18N="In the video settings" text="Render resolution" align="left"/>
</div> </div>
</div> </div>
@ -47,10 +47,10 @@
<div width="100%" height="fit" layout="horizontal-row"> <div width="100%" height="fit" layout="horizontal-row">
<spacer width="3%" height="100%" /> <spacer width="3%" height="100%" />
<div layout="vertical-row" width="10f" height="fit"> <div layout="vertical-row" width="10f" height="fit">
<gauge id="scale_rtts" min_value="0" max_value="7" width="100%" align="center" /> <gauge id="gfx_level" min_value="1" max_value="8" width="100%" align="center" />
</div> </div>
<div layout="vertical-row" proportion="1" height="100%"> <div layout="vertical-row" proportion="1" height="100%">
<label id="scale_rtts_label" height="100%" I18N="In the video settings" text="Render resolution" align="left"/> <label height="100%" I18N="In the video settings" text="Graphical Effects Level" align="left"/>
</div> </div>
</div> </div>
@ -90,13 +90,8 @@
<spacer width="5" height="3%"/> <spacer width="5" height="3%"/>
<!-- ************ RESOLUTION CHOICE ************ --> <!-- ************ RESOLUTION CHOICE ************ -->
<spacer width="5" height="1%"/>
<label width="100%" I18N="In the video settings" text="Resolution"/> <label width="100%" I18N="In the video settings" text="Resolution"/>
<scrollable_ribbon id="resolutions" height="20%" label_location="each"
width="100%" square_items="false"
align="center" child_width="128" child_height="128" />
<spacer width="5" height="1%"/> <spacer width="5" height="1%"/>
<div layout="horizontal-row" width="100%" height="fit"> <div layout="horizontal-row" width="100%" height="fit">
@ -115,6 +110,12 @@
</div> </div>
</div> </div>
<spacer width="5" height="1%"/>
<scrollable_ribbon id="resolutions" height="20%" label_location="each"
width="100%" square_items="false"
align="center" child_width="128" child_height="128" />
<spacer width="5" height="2%"/> <spacer width="5" height="2%"/>
<div width="100%" height="fit" layout="horizontal-row" > <div width="100%" height="fit" layout="horizontal-row" >

View File

@ -54,6 +54,7 @@
#include <sstream> #include <sstream>
using namespace GUIEngine; using namespace GUIEngine;
bool OptionsScreenVideo::m_fullscreen_checkbox_focus = false;
// -------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------
void OptionsScreenVideo::initPresets() void OptionsScreenVideo::initPresets()
@ -498,7 +499,12 @@ void OptionsScreenVideo::init()
#endif #endif
updateResolutionsList(); updateResolutionsList();
if (m_fullscreen_checkbox_focus)
{
m_fullscreen_checkbox_focus = false;
getWidget("fullscreen")->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
}
} // init } // init
// -------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------
@ -907,8 +913,11 @@ void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name,
->handleNewSize(new_width, new_height); ->handleNewSize(new_width, new_height);
irr_driver->handleWindowResize(); irr_driver->handleWindowResize();
Screen* new_screen = screen_function(); Screen* new_screen = screen_function();
OptionsScreenVideo::m_fullscreen_checkbox_focus = true;
new_screen->push(); new_screen->push();
} }
else
OptionsScreenVideo::m_fullscreen_checkbox_focus = true;
} }
else else
updateResolutionsList(); updateResolutionsList();
@ -920,6 +929,10 @@ void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name,
void OptionsScreenVideo::tearDown() void OptionsScreenVideo::tearDown()
{ {
if (getWidget("fullscreen")->isVisible() &&
getWidget("fullscreen")->isFocusedForPlayer(PLAYER_ID_GAME_MASTER))
OptionsScreenVideo::m_fullscreen_checkbox_focus = true;
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 &&
@ -939,6 +952,14 @@ void OptionsScreenVideo::tearDown()
// -------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------
bool OptionsScreenVideo::onEscapePressed()
{
GUIEngine::focusNothingForPlayer(PLAYER_ID_GAME_MASTER);
return true;
}
// --------------------------------------------------------------------------------------------
void OptionsScreenVideo::unloaded() void OptionsScreenVideo::unloaded()
{ {
m_inited = false; m_inited = false;

View File

@ -89,6 +89,7 @@ struct Resolution
class OptionsScreenVideo : public GUIEngine::Screen, public GUIEngine::ScreenSingleton<OptionsScreenVideo> class OptionsScreenVideo : public GUIEngine::Screen, public GUIEngine::ScreenSingleton<OptionsScreenVideo>
{ {
private: private:
static bool m_fullscreen_checkbox_focus;
bool m_prev_adv_pipline; bool m_prev_adv_pipline;
int m_prev_img_quality; int m_prev_img_quality;
OptionsScreenVideo(); OptionsScreenVideo();
@ -122,6 +123,8 @@ public:
/** \brief implement optional callback from parent class GUIEngine::Screen */ /** \brief implement optional callback from parent class GUIEngine::Screen */
virtual void unloaded() OVERRIDE; virtual void unloaded() OVERRIDE;
virtual bool onEscapePressed() OVERRIDE;
void updateGfxSlider(); void updateGfxSlider();
void updateBlurSlider(); void updateBlurSlider();
void updateScaleRTTsSlider(); void updateScaleRTTsSlider();