mirror of
https://github.com/OpenMW/openmw.git
synced 2025-10-22 14:26:36 +00:00
Add controller support to count dialog
This commit is contained in:
parent
f15cc663ae
commit
f80d46dc94
2 changed files with 18 additions and 0 deletions
|
@ -27,6 +27,9 @@ namespace MWGui
|
|||
mSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &CountDialog::onSliderMoved);
|
||||
// make sure we read the enter key being pressed to accept multiple items
|
||||
mItemEdit->eventEditSelectAccept += MyGUI::newDelegate(this, &CountDialog::onEnterKeyPressed);
|
||||
|
||||
mControllerButtons.a = "#{sOk}";
|
||||
mControllerButtons.b = "#{sCancel}";
|
||||
}
|
||||
|
||||
void CountDialog::openCountDialog(const std::string& item, const std::string& message, const int maxCount)
|
||||
|
@ -86,4 +89,18 @@ namespace MWGui
|
|||
{
|
||||
mItemEdit->setValue(_position + 1);
|
||||
}
|
||||
|
||||
bool CountDialog::onControllerButtonEvent(const SDL_ControllerButtonEvent& arg)
|
||||
{
|
||||
if (arg.button == SDL_CONTROLLER_BUTTON_A)
|
||||
onOkButtonClicked(mOkButton);
|
||||
else if (arg.button == SDL_CONTROLLER_BUTTON_B)
|
||||
onCancelButtonClicked(mCancelButton);
|
||||
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_LEFT)
|
||||
MWBase::Environment::get().getWindowManager()->injectKeyPress(MyGUI::KeyCode::ArrowDown, 0, false);
|
||||
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT)
|
||||
MWBase::Environment::get().getWindowManager()->injectKeyPress(MyGUI::KeyCode::ArrowUp, 0, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ namespace MWGui
|
|||
void onEditValueChanged(int value);
|
||||
void onSliderMoved(MyGUI::ScrollBar* _sender, size_t _position);
|
||||
void onEnterKeyPressed(MyGUI::EditBox* _sender);
|
||||
bool onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue