Use a button bar for the keypress dialog that appears during controller configuration
This commit is contained in:
parent
33b75eae96
commit
68e6e93f2e
@ -2,15 +2,19 @@
|
||||
<stkgui>
|
||||
<div x="2%" y="10%" width="96%" height="80%" layout="vertical-row" >
|
||||
|
||||
<spacer proportion="1" />
|
||||
|
||||
<label id="title" width="100%" text_align="center" text="Press fully and release..." proportion="1" I18N="When changing input configurations" word_wrap="true"/>
|
||||
|
||||
<spacer height="4%" width="10" />
|
||||
|
||||
<button id="assignEsc" I18N="When configuring input" text="Assign to ESC key" align="center"/>
|
||||
<spacer height="2%" width="10" />
|
||||
<button id="assignNone" I18N="When configuring input" text="Assign nothing" align="center"/>
|
||||
<spacer height="2%" width="10" />
|
||||
<button id="cancel" I18N="When configuring input" text="Press ESC to cancel" align="center"/>
|
||||
<spacer proportion="1" />
|
||||
|
||||
<buttonbar id="buttons" height="45%" width="100%" align="center">
|
||||
<icon-button id="assignEsc" width="128" height="128" icon="gui/icons/back.png"
|
||||
I18N="When configuring input" text="Assign to ESC key" align="center"/>
|
||||
<icon-button id="assignNone" width="128" height="128" icon="gui/icons/remove.png"
|
||||
I18N="When configuring input" text="Assign nothing" align="center"/>
|
||||
<icon-button id="cancel" width="128" height="128" icon="gui/icons/main_quit.png"
|
||||
I18N="When configuring input" text="Cancel" align="center"/>
|
||||
</buttonbar>
|
||||
</div>
|
||||
</stkgui>
|
||||
|
@ -17,8 +17,11 @@
|
||||
|
||||
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "guiengine/widgets/icon_button_widget.hpp"
|
||||
#include "guiengine/widgets/ribbon_widget.hpp"
|
||||
#include "input/input.hpp"
|
||||
#include "input/input_manager.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "states_screens/dialogs/press_a_key_dialog.hpp"
|
||||
#include "states_screens/options/options_screen_device.hpp"
|
||||
#include "utils/string_utils.hpp"
|
||||
@ -33,17 +36,18 @@ PressAKeyDialog::PressAKeyDialog(const float w, const float h, const bool isKeyb
|
||||
ModalDialog(w, h)
|
||||
{
|
||||
loadFromFile("press_a_key_dialog.stkgui");
|
||||
Widget* title = getWidget("title");
|
||||
if(isKeyboardFlag)
|
||||
{
|
||||
Widget* title = getWidget("title");
|
||||
// I18N: In press a key dialog, tell user to press a key to bind configuration
|
||||
title->setText(_("Press any key..."));
|
||||
title->setText(_("Press any key...\n(Press ESC to cancel)"));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Gamepad configuration, rename cancel to just cancel and hide assign esc button
|
||||
getWidget("cancel")->setText(_("Cancel"));
|
||||
getWidget("assignEsc")->setVisible(false);
|
||||
// Gamepad configuration, rename title to omit keyboard buttons
|
||||
// and hide assign esc button
|
||||
title->setText(_("Press any key..."));
|
||||
getWidget<IconButtonWidget>("assignEsc")->setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -51,26 +55,31 @@ PressAKeyDialog::PressAKeyDialog(const float w, const float h, const bool isKeyb
|
||||
|
||||
GUIEngine::EventPropagation PressAKeyDialog::processEvent(const std::string& eventSource)
|
||||
{
|
||||
if (eventSource == "cancel")
|
||||
if (eventSource == "buttons")
|
||||
{
|
||||
input_manager->setMode(InputManager::MENU);
|
||||
dismiss();
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
else if (eventSource == "assignNone")
|
||||
{
|
||||
Input simulatedInput;
|
||||
OptionsScreenDevice::getInstance()->gotSensedInput(simulatedInput);
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
else if (eventSource == "assignEsc")
|
||||
{
|
||||
Input simulatedInput(Input::IT_KEYBOARD, 0 /* deviceID */,
|
||||
IRR_KEY_ESCAPE);
|
||||
OptionsScreenDevice::getInstance()->gotSensedInput(simulatedInput);
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
const std::string& selection = getWidget<RibbonWidget>("buttons")->
|
||||
getSelectionIDString(PLAYER_ID_GAME_MASTER);
|
||||
|
||||
if (selection == "assignEsc")
|
||||
{
|
||||
Input simulatedInput(Input::IT_KEYBOARD, 0 /* deviceID */,
|
||||
IRR_KEY_ESCAPE);
|
||||
OptionsScreenDevice::getInstance()->gotSensedInput(simulatedInput);
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
else if (selection == "assignNone")
|
||||
{
|
||||
Input simulatedInput;
|
||||
OptionsScreenDevice::getInstance()->gotSensedInput(simulatedInput);
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
else if (selection == "cancel")
|
||||
{
|
||||
input_manager->setMode(InputManager::MENU);
|
||||
dismiss();
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
}
|
||||
return GUIEngine::EVENT_LET;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user