mirror of
https://github.com/OpenMW/openmw.git
synced 2025-12-15 21:43:07 +00:00
Basic controller support for the books
This commit is contained in:
parent
bb88becc2b
commit
be298f78cb
2 changed files with 43 additions and 0 deletions
|
|
@ -27,15 +27,19 @@ namespace MWGui
|
|||
{
|
||||
getWidget(mCloseButton, "CloseButton");
|
||||
mCloseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BookWindow::onCloseButtonClicked);
|
||||
trackFocusEvents(mCloseButton);
|
||||
|
||||
getWidget(mTakeButton, "TakeButton");
|
||||
mTakeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BookWindow::onTakeButtonClicked);
|
||||
trackFocusEvents(mTakeButton);
|
||||
|
||||
getWidget(mNextPageButton, "NextPageBTN");
|
||||
mNextPageButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BookWindow::onNextPageButtonClicked);
|
||||
trackFocusEvents(mNextPageButton);
|
||||
|
||||
getWidget(mPrevPageButton, "PrevPageBTN");
|
||||
mPrevPageButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BookWindow::onPrevPageButtonClicked);
|
||||
trackFocusEvents(mPrevPageButton);
|
||||
|
||||
getWidget(mLeftPageNumber, "LeftPageNumber");
|
||||
getWidget(mRightPageNumber, "RightPageNumber");
|
||||
|
|
@ -218,4 +222,42 @@ namespace MWGui
|
|||
}
|
||||
}
|
||||
|
||||
bool BookWindow::onControllerButtonEvent(const SDL_ControllerButtonEvent& arg)
|
||||
{
|
||||
if (arg.button == SDL_CONTROLLER_BUTTON_A)
|
||||
{
|
||||
if (mMouseFocus != nullptr)
|
||||
return false;
|
||||
|
||||
if (mTakeButton->getVisible())
|
||||
onTakeButtonClicked(mTakeButton);
|
||||
else
|
||||
onCloseButtonClicked(mCloseButton);
|
||||
return true;
|
||||
}
|
||||
else if (arg.button == SDL_CONTROLLER_BUTTON_B)
|
||||
{
|
||||
onCloseButtonClicked(mCloseButton);
|
||||
return true;
|
||||
}
|
||||
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_UP ||
|
||||
arg.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (arg.button == SDL_CONTROLLER_BUTTON_LEFTSHOULDER ||
|
||||
arg.button == SDL_CONTROLLER_BUTTON_DPAD_LEFT)
|
||||
{
|
||||
prevPage();
|
||||
return true;
|
||||
}
|
||||
else if (arg.button == SDL_CONTROLLER_BUTTON_RIGHTSHOULDER ||
|
||||
arg.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT)
|
||||
{
|
||||
nextPage();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ namespace MWGui
|
|||
void setInventoryAllowed(bool allowed);
|
||||
|
||||
void onResChange(int, int) override { center(); }
|
||||
bool onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) override;
|
||||
|
||||
std::string_view getWindowIdForLua() const override { return "Book"; }
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue