Use a button bar for the confirm resolution dialog, and make it slightly smaller

This commit is contained in:
Richard Qian 2021-03-07 12:09:47 -06:00
parent 1d65cd9ffc
commit 33b75eae96
2 changed files with 24 additions and 18 deletions

View File

@ -3,16 +3,16 @@
<div x="2%" y="10%" width="96%" height="80%" layout="vertical-row" > <div x="2%" y="10%" width="96%" height="80%" layout="vertical-row" >
<label id="title" width="100%" text_align="center" word_wrap="true" proportion="1" /> <label id="title" width="100%" text_align="center" word_wrap="true" proportion="1" />
<spacer height="4%" width="10" /> <spacer height="5%" width="10" />
<button id="accept" I18N="In the 'confirm resolution' dialog, that's shown when switching resoluton" <buttonbar id="buttons" height="30%" width="30%" align="center">
text="Keep this resolution" align="center"/>
<spacer height="3%" width="10" /> <icon-button id="accept" width="128" height="128" icon="gui/icons/green_check.png"
I18N="In the 'confirm resolution' dialog, that's shown when switching resoluton" text="Accept" align="center"/>
<button id="cancel" I18N="In the 'confirm resolution' dialog, that's shown when switching resoluton" <icon-button id="cancel" width="128" height="128" icon="gui/icons/restart.png"
text="Cancel" align="center"/> I18N="In the 'confirm resolution' dialog, that's shown when switching resoluton" text="Revert" align="center"/>
<spacer height="2%" width="10" /> </buttonbar>
</div> </div>
</stkgui> </stkgui>

View File

@ -21,6 +21,7 @@
#include "guiengine/engine.hpp" #include "guiengine/engine.hpp"
#include "guiengine/screen.hpp" #include "guiengine/screen.hpp"
#include "guiengine/widgets/label_widget.hpp" #include "guiengine/widgets/label_widget.hpp"
#include "guiengine/widgets/ribbon_widget.hpp"
#include "states_screens/state_manager.hpp" #include "states_screens/state_manager.hpp"
#include "utils/string_utils.hpp" #include "utils/string_utils.hpp"
#include "utils/translation.hpp" #include "utils/translation.hpp"
@ -31,7 +32,7 @@ using namespace irr::core;
// ------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------
ConfirmResolutionDialog::ConfirmResolutionDialog(bool unsupported_res) : ModalDialog(0.7f, 0.7f) ConfirmResolutionDialog::ConfirmResolutionDialog(bool unsupported_res) : ModalDialog(0.6f, 0.6f)
{ {
loadFromFile("confirm_resolution_dialog.stkgui"); loadFromFile("confirm_resolution_dialog.stkgui");
m_remaining_time = 10.99f; m_remaining_time = 10.99f;
@ -101,19 +102,24 @@ void ConfirmResolutionDialog::updateMessage()
GUIEngine::EventPropagation ConfirmResolutionDialog::processEvent(const std::string& eventSource) GUIEngine::EventPropagation ConfirmResolutionDialog::processEvent(const std::string& eventSource)
{ {
if (eventSource == "buttons")
if (eventSource == "cancel")
{ {
ModalDialog::dismiss(); const std::string& selection =
getWidget<RibbonWidget>("buttons")->getSelectionIDString(PLAYER_ID_GAME_MASTER);
irr_driver->cancelResChange(); if (selection == "cancel")
return GUIEngine::EVENT_BLOCK; {
} ModalDialog::dismiss();
else if (eventSource == "accept")
{
ModalDialog::dismiss();
return GUIEngine::EVENT_BLOCK; irr_driver->cancelResChange();
return GUIEngine::EVENT_BLOCK;
}
else if (selection == "accept")
{
ModalDialog::dismiss();
return GUIEngine::EVENT_BLOCK;
}
} }
return GUIEngine::EVENT_LET; return GUIEngine::EVENT_LET;