mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-17 01:32:21 +02:00
Fixed UI updates on switching to/from fullscreen
This commit is contained in:
@ -449,19 +449,6 @@ void playIntro()
|
|||||||
|
|
||||||
static void mainLoop()
|
static void mainLoop()
|
||||||
{
|
{
|
||||||
SettingsListener resChanged = settings.listen["video"]["resolution"];
|
|
||||||
SettingsListener fsChanged = settings.listen["video"]["fullscreen"];
|
|
||||||
|
|
||||||
auto functor = [](const JsonNode &newState){
|
|
||||||
GH.dispatchMainThread([](){
|
|
||||||
boost::unique_lock<boost::recursive_mutex> lock(*CPlayerInterface::pim);
|
|
||||||
GH.onScreenResize();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
resChanged(functor);
|
|
||||||
fsChanged(functor);
|
|
||||||
|
|
||||||
inGuiThread.reset(new bool(true));
|
inGuiThread.reset(new bool(true));
|
||||||
|
|
||||||
while(1) //main SDL events loop
|
while(1) //main SDL events loop
|
||||||
|
@ -121,6 +121,8 @@ void InputHandler::preprocessEvent(const SDL_Event & ev)
|
|||||||
{
|
{
|
||||||
Settings full = settings.write["video"]["fullscreen"];
|
Settings full = settings.write["video"]["fullscreen"];
|
||||||
full->Bool() = !full->Bool();
|
full->Bool() = !full->Bool();
|
||||||
|
|
||||||
|
GH.onScreenResize();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if(ev.type == SDL_USEREVENT)
|
else if(ev.type == SDL_USEREVENT)
|
||||||
|
@ -25,10 +25,6 @@
|
|||||||
# include <dispatch/dispatch.h>
|
# include <dispatch/dispatch.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef VCMI_IOS
|
|
||||||
# include "ios/utils.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void InputSourceText::handleEventTextInput(const SDL_TextInputEvent & text)
|
void InputSourceText::handleEventTextInput(const SDL_TextInputEvent & text)
|
||||||
{
|
{
|
||||||
GH.events().dispatchTextInput(text.text);
|
GH.events().dispatchTextInput(text.text);
|
||||||
|
@ -22,6 +22,10 @@
|
|||||||
#include "../lib/CAndroidVMHelper.h"
|
#include "../lib/CAndroidVMHelper.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef VCMI_IOS
|
||||||
|
# include "ios/utils.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
// TODO: should be made into a private members of ScreenHandler
|
// TODO: should be made into a private members of ScreenHandler
|
||||||
|
@ -331,11 +331,16 @@ void CToggleBase::setEnabled(bool enabled)
|
|||||||
// for overrides
|
// for overrides
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CToggleBase::setSelectedSilent(bool on)
|
||||||
|
{
|
||||||
|
selected = on;
|
||||||
|
doSelect(on);
|
||||||
|
}
|
||||||
|
|
||||||
void CToggleBase::setSelected(bool on)
|
void CToggleBase::setSelected(bool on)
|
||||||
{
|
{
|
||||||
bool changed = (on != selected);
|
bool changed = (on != selected);
|
||||||
selected = on;
|
setSelectedSilent(on);
|
||||||
doSelect(on);
|
|
||||||
if (changed)
|
if (changed)
|
||||||
callback(on);
|
callback(on);
|
||||||
}
|
}
|
||||||
|
@ -136,6 +136,9 @@ public:
|
|||||||
/// Changes selection to "on", and calls callback
|
/// Changes selection to "on", and calls callback
|
||||||
void setSelected(bool on);
|
void setSelected(bool on);
|
||||||
|
|
||||||
|
/// Changes selection to "on" without calling callback
|
||||||
|
void setSelectedSilent(bool on);
|
||||||
|
|
||||||
void addCallback(std::function<void(bool)> callback);
|
void addCallback(std::function<void(bool)> callback);
|
||||||
|
|
||||||
/// Set whether the toggle is currently enabled for user to use, this is only inplemented in ToggleButton, not for other toggles yet.
|
/// Set whether the toggle is currently enabled for user to use, this is only inplemented in ToggleButton, not for other toggles yet.
|
||||||
|
@ -277,10 +277,18 @@ void GeneralOptionsTab::setGameResolution(int index)
|
|||||||
gameRes["height"].Float() = resolution.y;
|
gameRes["height"].Float() = resolution.y;
|
||||||
|
|
||||||
widget<CLabel>("resolutionLabel")->setText(resolutionToLabelString(resolution.x, resolution.y));
|
widget<CLabel>("resolutionLabel")->setText(resolutionToLabelString(resolution.x, resolution.y));
|
||||||
|
|
||||||
|
GH.dispatchMainThread([](){
|
||||||
|
boost::unique_lock<boost::recursive_mutex> lock(*CPlayerInterface::pim);
|
||||||
|
GH.onScreenResize();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeneralOptionsTab::setFullscreenMode(bool on, bool exclusive)
|
void GeneralOptionsTab::setFullscreenMode(bool on, bool exclusive)
|
||||||
{
|
{
|
||||||
|
if (on == settings["video"]["fullscreen"].Bool() && exclusive == settings["video"]["realFullscreen"].Bool())
|
||||||
|
return;
|
||||||
|
|
||||||
setBoolSetting("video", "realFullscreen", exclusive);
|
setBoolSetting("video", "realFullscreen", exclusive);
|
||||||
setBoolSetting("video", "fullscreen", on);
|
setBoolSetting("video", "fullscreen", on);
|
||||||
|
|
||||||
@ -288,12 +296,17 @@ void GeneralOptionsTab::setFullscreenMode(bool on, bool exclusive)
|
|||||||
std::shared_ptr<CToggleButton> fullscreenBorderlessCheckbox = widget<CToggleButton>("fullscreenBorderlessCheckbox");
|
std::shared_ptr<CToggleButton> fullscreenBorderlessCheckbox = widget<CToggleButton>("fullscreenBorderlessCheckbox");
|
||||||
|
|
||||||
if (fullscreenBorderlessCheckbox)
|
if (fullscreenBorderlessCheckbox)
|
||||||
fullscreenBorderlessCheckbox->setSelected(on && !exclusive);
|
fullscreenBorderlessCheckbox->setSelectedSilent(on && !exclusive);
|
||||||
|
|
||||||
if (fullscreenExclusiveCheckbox)
|
if (fullscreenExclusiveCheckbox)
|
||||||
fullscreenExclusiveCheckbox->setSelected(on && exclusive);
|
fullscreenExclusiveCheckbox->setSelectedSilent(on && exclusive);
|
||||||
|
|
||||||
updateResolutionSelector();
|
updateResolutionSelector();
|
||||||
|
|
||||||
|
GH.dispatchMainThread([](){
|
||||||
|
boost::unique_lock<boost::recursive_mutex> lock(*CPlayerInterface::pim);
|
||||||
|
GH.onScreenResize();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeneralOptionsTab::selectGameScaling()
|
void GeneralOptionsTab::selectGameScaling()
|
||||||
|
Reference in New Issue
Block a user