Place buttons in confirm dialog horizontally (#2573)
* Place buttons in confirm dialog horizontally closes #2548 * Use RibbonWidget for MessageDialog * Use buttonbar for confirm dialog
This commit is contained in:
parent
489c34edbf
commit
d213bef9db
@ -1,15 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<stkgui>
|
||||
<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="top" word_wrap="true" proportion="1" />
|
||||
|
||||
<spacer height="25" width="10" />
|
||||
|
||||
<button id="confirm" I18N="In a 'are you sure?' dialog" text="Yes" align="center"/>
|
||||
<buttonbar id="buttons" height="30%" width="30%" align="center">
|
||||
|
||||
<spacer height="15" width="10" />
|
||||
<icon-button id="confirm" icon="gui/green_check.png" I18N="In a 'are you sure?' dialog"
|
||||
text="Yes" align="center"/>
|
||||
|
||||
<button id="cancel" I18N="In a 'are you sure?' dialog" text="Cancel" align="center"/>
|
||||
<icon-button id="cancel" icon="gui/remove.png" I18N="In a 'are you sure?' dialog"
|
||||
text="Cancel" align="center"/>
|
||||
|
||||
</buttonbar>
|
||||
|
||||
<spacer height="10" width="10" />
|
||||
</div>
|
||||
|
@ -17,10 +17,8 @@
|
||||
|
||||
#include "states_screens/dialogs/message_dialog.hpp"
|
||||
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "guiengine/screen.hpp"
|
||||
#include "guiengine/widgets/button_widget.hpp"
|
||||
#include "guiengine/widgets/label_widget.hpp"
|
||||
#include "guiengine/widgets/ribbon_widget.hpp"
|
||||
#include "modes/world.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
@ -97,7 +95,7 @@ void MessageDialog::doInit(bool from_queue)
|
||||
|
||||
MessageDialog::~MessageDialog()
|
||||
{
|
||||
if (m_own_listener) delete m_listener;
|
||||
if (m_own_listener) delete m_listener;
|
||||
m_listener = NULL;
|
||||
|
||||
if (StateManager::get()->getGameState() == GUIEngine::GAME)
|
||||
@ -111,28 +109,29 @@ void MessageDialog::loadedFromFile()
|
||||
{
|
||||
LabelWidget* message = getWidget<LabelWidget>("title");
|
||||
message->setText( m_msg, false );
|
||||
RibbonWidget* ribbon = getWidget<RibbonWidget>("buttons");
|
||||
ribbon->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
|
||||
|
||||
// If the dialog is a simple 'OK' dialog, then hide the "Yes" button and
|
||||
// change "Cancel" to "OK"
|
||||
if (m_type == MessageDialog::MESSAGE_DIALOG_OK)
|
||||
{
|
||||
ButtonWidget* yesbtn = getWidget<ButtonWidget>("confirm");
|
||||
IconButtonWidget* yesbtn = getWidget<IconButtonWidget>("cancel");
|
||||
yesbtn->setVisible(false);
|
||||
|
||||
ButtonWidget* cancelbtn = getWidget<ButtonWidget>("cancel");
|
||||
IconButtonWidget* cancelbtn = getWidget<IconButtonWidget>("confirm");
|
||||
cancelbtn->setText(_("OK"));
|
||||
cancelbtn->setFocusForPlayer(PLAYER_ID_GAME_MASTER);
|
||||
}
|
||||
else if (m_type == MessageDialog::MESSAGE_DIALOG_YESNO)
|
||||
{
|
||||
ButtonWidget* cancelbtn = getWidget<ButtonWidget>("cancel");
|
||||
IconButtonWidget* cancelbtn = getWidget<IconButtonWidget>("cancel");
|
||||
cancelbtn->setText(_("No"));
|
||||
|
||||
}
|
||||
else if (m_type == MessageDialog::MESSAGE_DIALOG_OK_CANCEL)
|
||||
{
|
||||
// In case of a OK_CANCEL dialog, change the text from 'Yes' to 'Ok'
|
||||
ButtonWidget* yesbtn = getWidget<ButtonWidget>("confirm");
|
||||
IconButtonWidget* yesbtn = getWidget<IconButtonWidget>("confirm");
|
||||
yesbtn->setText(_("OK"));
|
||||
}
|
||||
}
|
||||
@ -147,8 +146,9 @@ void MessageDialog::onEnterPressedInternal()
|
||||
|
||||
GUIEngine::EventPropagation MessageDialog::processEvent(const std::string& eventSource)
|
||||
{
|
||||
|
||||
if (eventSource == "cancel")
|
||||
RibbonWidget* ribbon = getWidget<RibbonWidget>(eventSource.c_str());
|
||||
|
||||
if (ribbon->getSelectionIDString(PLAYER_ID_GAME_MASTER) == "cancel")
|
||||
{
|
||||
if (m_listener == NULL)
|
||||
{
|
||||
@ -161,7 +161,7 @@ GUIEngine::EventPropagation MessageDialog::processEvent(const std::string& event
|
||||
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
else if (eventSource == "confirm")
|
||||
else if (ribbon->getSelectionIDString(PLAYER_ID_GAME_MASTER) == "confirm")
|
||||
{
|
||||
if (m_listener == NULL)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user