mirror of
https://github.com/OpenMW/openmw.git
synced 2025-12-13 04:43:06 +00:00
Minimal controller bindings for save/load window
This commit is contained in:
parent
2970913d55
commit
58c4e0ddf7
2 changed files with 60 additions and 0 deletions
|
|
@ -63,6 +63,9 @@ namespace MWGui
|
||||||
|
|
||||||
// To avoid accidental deletions
|
// To avoid accidental deletions
|
||||||
mDeleteButton->setNeedKeyFocus(false);
|
mDeleteButton->setNeedKeyFocus(false);
|
||||||
|
|
||||||
|
trackFocusEvents(mCancelButton);
|
||||||
|
trackFocusEvents(mDeleteButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveGameDialog::onSlotActivated(MyGUI::ListBox* sender, size_t pos)
|
void SaveGameDialog::onSlotActivated(MyGUI::ListBox* sender, size_t pos)
|
||||||
|
|
@ -487,4 +490,59 @@ namespace MWGui
|
||||||
mScreenshotTexture = std::make_unique<osgMyGUI::OSGTexture>(texture);
|
mScreenshotTexture = std::make_unique<osgMyGUI::OSGTexture>(texture);
|
||||||
mScreenshot->setRenderItemTexture(mScreenshotTexture.get());
|
mScreenshot->setRenderItemTexture(mScreenshotTexture.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SaveGameDialog::onControllerButtonEvent(const SDL_ControllerButtonEvent& arg)
|
||||||
|
{
|
||||||
|
if (arg.button == SDL_CONTROLLER_BUTTON_A)
|
||||||
|
{
|
||||||
|
if (mMouseFocus != nullptr)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
onOkButtonClicked(mOkButton);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (arg.button == SDL_CONTROLLER_BUTTON_B)
|
||||||
|
{
|
||||||
|
onCancelButtonClicked(mCancelButton);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_UP)
|
||||||
|
{
|
||||||
|
MWBase::WindowManager* winMgr = MWBase::Environment::get().getWindowManager();
|
||||||
|
winMgr->setKeyFocusWidget(mSaveList);
|
||||||
|
winMgr->injectKeyPress(MyGUI::KeyCode::ArrowUp, 0, false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (arg.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN)
|
||||||
|
{
|
||||||
|
MWBase::WindowManager* winMgr = MWBase::Environment::get().getWindowManager();
|
||||||
|
winMgr->setKeyFocusWidget(mSaveList);
|
||||||
|
winMgr->injectKeyPress(MyGUI::KeyCode::ArrowDown, 0, false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (arg.button == SDL_CONTROLLER_BUTTON_LEFTSHOULDER)
|
||||||
|
{
|
||||||
|
uint32_t index = mCharacterSelection->getIndexSelected();
|
||||||
|
if (index <= 0)
|
||||||
|
index = mCharacterSelection->getItemCount() - 1;
|
||||||
|
else
|
||||||
|
index--;
|
||||||
|
mCharacterSelection->setIndexSelected(index);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (arg.button == SDL_CONTROLLER_BUTTON_RIGHTSHOULDER)
|
||||||
|
{
|
||||||
|
uint32_t index = mCharacterSelection->getIndexSelected();
|
||||||
|
if (index >= mCharacterSelection->getItemCount() - 1)
|
||||||
|
index = 0;
|
||||||
|
else
|
||||||
|
index++;
|
||||||
|
mCharacterSelection->setIndexSelected(index);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,8 @@ namespace MWGui
|
||||||
|
|
||||||
void setLoadOrSave(bool load);
|
void setLoadOrSave(bool load);
|
||||||
|
|
||||||
|
bool onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void confirmDeleteSave();
|
void confirmDeleteSave();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue