[SettingsMenuState] Now disabling 'Resolution' button when fullscreen mode is enabled. Also updates resolution button text on window resize.
This commit is contained in:
parent
36bcbf2aee
commit
542b9277f8
@ -73,8 +73,11 @@ void SettingsMenuState::init() {
|
|||||||
void SettingsMenuState::onEvent(const SDL_Event &event) {
|
void SettingsMenuState::onEvent(const SDL_Event &event) {
|
||||||
InterfaceState::onEvent(event);
|
InterfaceState::onEvent(event);
|
||||||
|
|
||||||
if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED && &m_stateStack->top() != this) {
|
if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) {
|
||||||
|
if (&m_stateStack->top() != this)
|
||||||
m_menuWidget.onEvent(event);
|
m_menuWidget.onEvent(event);
|
||||||
|
else if (m_state == MenuState::Graphics && m_resolutionButton)
|
||||||
|
m_resolutionButton->setText("Resolution: " + std::to_string(Config::screenWidth) + "x" + std::to_string(Config::screenHeight));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_stateStack->empty() && &m_stateStack->top() == this) {
|
if (!m_stateStack->empty() && &m_stateStack->top() == this) {
|
||||||
@ -138,6 +141,7 @@ void SettingsMenuState::updateWidgetPosition() {
|
|||||||
|
|
||||||
void SettingsMenuState::doneButtonAction() {
|
void SettingsMenuState::doneButtonAction() {
|
||||||
if (m_state != MenuState::Main) {
|
if (m_state != MenuState::Main) {
|
||||||
|
m_resolutionButton = nullptr;
|
||||||
m_state = MenuState::Main;
|
m_state = MenuState::Main;
|
||||||
addMainButtons();
|
addMainButtons();
|
||||||
} else {
|
} else {
|
||||||
@ -244,8 +248,7 @@ void SettingsMenuState::addGraphicsButtons() {
|
|||||||
}
|
}
|
||||||
}, 1, 3, Config::guiScale);
|
}, 1, 3, Config::guiScale);
|
||||||
|
|
||||||
addToggleButton("Fullscreen", Config::isFullscreenModeEnabled, false);
|
m_resolutionButton = &m_menuWidget.addButton("Resolution: " + std::to_string(Config::screenWidth) + "x" + std::to_string(Config::screenHeight), [] (TextButton &button) {
|
||||||
m_menuWidget.addButton("Resolution: " + std::to_string(Config::screenWidth) + "x" + std::to_string(Config::screenHeight), [] (TextButton &button) {
|
|
||||||
if (Config::isFullscreenModeEnabled) return;
|
if (Config::isFullscreenModeEnabled) return;
|
||||||
|
|
||||||
// FIXME: Find a better way to do this
|
// FIXME: Find a better way to do this
|
||||||
@ -265,6 +268,15 @@ void SettingsMenuState::addGraphicsButtons() {
|
|||||||
button.setText("Resolution: " + std::to_string(Config::screenWidth) + "x" + std::to_string(Config::screenHeight));
|
button.setText("Resolution: " + std::to_string(Config::screenWidth) + "x" + std::to_string(Config::screenHeight));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
m_resolutionButton->setEnabled(!Config::isFullscreenModeEnabled);
|
||||||
|
|
||||||
|
m_menuWidget.addButton(std::string("Fullscreen: ") + (Config::isFullscreenModeEnabled ? "ON" : "OFF"), [&, aoValueNames] (TextButton &button) {
|
||||||
|
Config::isFullscreenModeEnabled = !Config::isFullscreenModeEnabled;
|
||||||
|
button.setText(std::string("Fullscreen: ") + (Config::isFullscreenModeEnabled ? "ON" : "OFF"));
|
||||||
|
|
||||||
|
m_resolutionButton->setEnabled(!Config::isFullscreenModeEnabled);
|
||||||
|
});
|
||||||
|
|
||||||
addToggleButton("Use VSync", Config::isVerticalSyncEnabled, false);
|
addToggleButton("Use VSync", Config::isVerticalSyncEnabled, false);
|
||||||
|
|
||||||
m_menuWidget.addSlider("Mipmap Levels: " + std::to_string(Config::mipmapLevels), [] (SliderWidget &slider, u32) {
|
m_menuWidget.addSlider("Mipmap Levels: " + std::to_string(Config::mipmapLevels), [] (SliderWidget &slider, u32) {
|
||||||
|
@ -85,7 +85,7 @@ class SettingsMenuState : public InterfaceState {
|
|||||||
|
|
||||||
MenuState m_state = MenuState::Main;
|
MenuState m_state = MenuState::Main;
|
||||||
|
|
||||||
TextButton *m_aoButton = nullptr;
|
TextButton *m_resolutionButton = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SETTINGSMENUSTATE_HPP_
|
#endif // SETTINGSMENUSTATE_HPP_
|
||||||
|
Loading…
x
Reference in New Issue
Block a user