1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-10-18 09:46:40 +00:00

Update controller buttons for character creation and level up

This commit is contained in:
Andrew Lanzone 2025-06-01 16:27:49 -07:00
parent 263863f3f2
commit 2aa9847b24
8 changed files with 49 additions and 55 deletions

View file

@ -60,10 +60,9 @@ namespace MWGui
if (Settings::gui().mControllerMenus) if (Settings::gui().mControllerMenus)
{ {
mOkButton->setStateSelected(true); mControllerButtons.lStick = "#{sMouse}";
mControllerButtons.a = "#{sSelect}"; mControllerButtons.a = "#{sSelect}";
mControllerButtons.b = "#{sBack}"; mControllerButtons.b = "#{sBack}";
mControllerButtons.x = "#{sDone}";
} }
updateBirths(); updateBirths();
@ -76,8 +75,17 @@ namespace MWGui
getWidget(okButton, "OKButton"); getWidget(okButton, "OKButton");
if (shown) if (shown)
{
okButton->setCaption( okButton->setCaption(
MyGUI::UString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sNext", {}))); MyGUI::UString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sNext", {})));
mControllerButtons.x = "#{sNext}";
}
else if (Settings::gui().mControllerMenus)
{
okButton->setCaption(
MyGUI::UString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sDone", {})));
mControllerButtons.x = "#{sDone}";
}
else else
okButton->setCaption( okButton->setCaption(
MyGUI::UString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sOK", {}))); MyGUI::UString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sOK", {})));
@ -280,14 +288,7 @@ namespace MWGui
bool BirthDialog::onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) bool BirthDialog::onControllerButtonEvent(const SDL_ControllerButtonEvent& arg)
{ {
if (arg.button == SDL_CONTROLLER_BUTTON_A) if (arg.button == SDL_CONTROLLER_BUTTON_B)
{
if (mOkButtonFocus)
onOkClicked(mOkButton);
else
onBackClicked(mBackButton);
}
else if (arg.button == SDL_CONTROLLER_BUTTON_B)
{ {
onBackClicked(mBackButton); onBackClicked(mBackButton);
} }
@ -307,13 +308,6 @@ namespace MWGui
winMgr->setKeyFocusWidget(mBirthList); winMgr->setKeyFocusWidget(mBirthList);
winMgr->injectKeyPress(MyGUI::KeyCode::ArrowDown, 0, false); winMgr->injectKeyPress(MyGUI::KeyCode::ArrowDown, 0, false);
} }
else if ((arg.button == SDL_CONTROLLER_BUTTON_DPAD_LEFT && mOkButtonFocus) ||
(arg.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT && !mOkButtonFocus))
{
mOkButtonFocus = !mOkButtonFocus;
mOkButton->setStateSelected(mOkButtonFocus);
mBackButton->setStateSelected(!mOkButtonFocus);
}
return true; return true;
} }

View file

@ -59,7 +59,6 @@ namespace MWGui
ESM::RefId mCurrentBirthId; ESM::RefId mCurrentBirthId;
bool onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) override; bool onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) override;
bool mOkButtonFocus = true;
}; };
} }
#endif #endif

View file

@ -149,10 +149,9 @@ namespace MWGui
if (Settings::gui().mControllerMenus) if (Settings::gui().mControllerMenus)
{ {
mOkButton->setStateSelected(true); mControllerButtons.lStick = "#{sMouse}";
mControllerButtons.a = "#{sSelect}"; mControllerButtons.a = "#{sSelect}";
mControllerButtons.b = "#{sBack}"; mControllerButtons.b = "#{sBack}";
mControllerButtons.x = "#{sDone}";
} }
updateClasses(); updateClasses();
@ -165,8 +164,17 @@ namespace MWGui
getWidget(okButton, "OKButton"); getWidget(okButton, "OKButton");
if (shown) if (shown)
{
okButton->setCaption( okButton->setCaption(
MyGUI::UString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sNext", {}))); MyGUI::UString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sNext", {})));
mControllerButtons.x = "#{sNext}";
}
else if (Settings::gui().mControllerMenus)
{
okButton->setCaption(
MyGUI::UString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sDone", {})));
mControllerButtons.x = "#{sDone}";
}
else else
okButton->setCaption( okButton->setCaption(
MyGUI::UString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sOK", {}))); MyGUI::UString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sOK", {})));
@ -317,14 +325,7 @@ namespace MWGui
bool PickClassDialog::onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) bool PickClassDialog::onControllerButtonEvent(const SDL_ControllerButtonEvent& arg)
{ {
if (arg.button == SDL_CONTROLLER_BUTTON_A) if (arg.button == SDL_CONTROLLER_BUTTON_B)
{
if (mOkButtonFocus)
onOkClicked(mOkButton);
else
onBackClicked(mBackButton);
}
else if (arg.button == SDL_CONTROLLER_BUTTON_B)
{ {
onBackClicked(mBackButton); onBackClicked(mBackButton);
} }
@ -344,13 +345,6 @@ namespace MWGui
winMgr->setKeyFocusWidget(mClassList); winMgr->setKeyFocusWidget(mClassList);
winMgr->injectKeyPress(MyGUI::KeyCode::ArrowDown, 0, false); winMgr->injectKeyPress(MyGUI::KeyCode::ArrowDown, 0, false);
} }
else if ((arg.button == SDL_CONTROLLER_BUTTON_DPAD_LEFT && mOkButtonFocus) ||
(arg.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT && !mOkButtonFocus))
{
mOkButtonFocus = !mOkButtonFocus;
mOkButton->setStateSelected(mOkButtonFocus);
mBackButton->setStateSelected(!mOkButtonFocus);
}
return true; return true;
} }
@ -590,9 +584,9 @@ namespace MWGui
if (Settings::gui().mControllerMenus) if (Settings::gui().mControllerMenus)
{ {
okButton->setStateSelected(true); okButton->setStateSelected(true);
mControllerButtons.lStick = "#{sMouse}";
mControllerButtons.a = "#{sSelect}"; mControllerButtons.a = "#{sSelect}";
mControllerButtons.b = "#{sBack}"; mControllerButtons.b = "#{sBack}";
mControllerButtons.x = "#{sDone}";
} }
// Set default skills, attributes // Set default skills, attributes
@ -681,8 +675,17 @@ namespace MWGui
getWidget(okButton, "OKButton"); getWidget(okButton, "OKButton");
if (shown) if (shown)
{
okButton->setCaption( okButton->setCaption(
MyGUI::UString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sNext", {}))); MyGUI::UString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sNext", {})));
mControllerButtons.x = "#{sNext}";
}
else if (Settings::gui().mControllerMenus)
{
okButton->setCaption(
MyGUI::UString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sDone", {})));
mControllerButtons.x = "#{sDone}";
}
else else
okButton->setCaption( okButton->setCaption(
MyGUI::UString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sOK", {}))); MyGUI::UString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sOK", {})));
@ -1150,6 +1153,8 @@ namespace MWGui
// Make sure the edit box has focus // Make sure the edit box has focus
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mTextEdit); MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mTextEdit);
mControllerButtons.a = "#{sOk}";
} }
DescriptionDialog::~DescriptionDialog() {} DescriptionDialog::~DescriptionDialog() {}

View file

@ -155,7 +155,6 @@ namespace MWGui
ESM::RefId mCurrentClassId; ESM::RefId mCurrentClassId;
bool onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) override; bool onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) override;
bool mOkButtonFocus = true;
}; };
class SelectSpecializationDialog : public WindowModal class SelectSpecializationDialog : public WindowModal

View file

@ -97,6 +97,8 @@ namespace MWGui
mDisableGamepadCursor = true; mDisableGamepadCursor = true;
mControllerButtons.a = "#{sSelect}"; mControllerButtons.a = "#{sSelect}";
mControllerButtons.x = "#{sDone}"; mControllerButtons.x = "#{sDone}";
mOkButton->setCaption(
MyGUI::UString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sDone", {})));
} }
center(); center();

View file

@ -108,10 +108,9 @@ namespace MWGui
if (Settings::gui().mControllerMenus) if (Settings::gui().mControllerMenus)
{ {
mOkButton->setStateSelected(true); mControllerButtons.lStick = "#{sMouse}";
mControllerButtons.a = "#{sSelect}"; mControllerButtons.a = "#{sSelect}";
mControllerButtons.b = "#{sBack}"; mControllerButtons.b = "#{sBack}";
mControllerButtons.x = "#{sDone}";
mControllerButtons.y = "#{sSex}"; mControllerButtons.y = "#{sSex}";
mControllerButtons.l1 = "#{sHair}"; mControllerButtons.l1 = "#{sHair}";
mControllerButtons.r1 = "#{sFace}"; mControllerButtons.r1 = "#{sFace}";
@ -128,8 +127,17 @@ namespace MWGui
getWidget(okButton, "OKButton"); getWidget(okButton, "OKButton");
if (shown) if (shown)
{
okButton->setCaption( okButton->setCaption(
MyGUI::UString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sNext", {}))); MyGUI::UString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sNext", {})));
mControllerButtons.x = "#{sNext}";
}
else if (Settings::gui().mControllerMenus)
{
okButton->setCaption(
MyGUI::UString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sDone", {})));
mControllerButtons.x = "#{sDone}";
}
else else
okButton->setCaption( okButton->setCaption(
MyGUI::UString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sOK", {}))); MyGUI::UString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sOK", {})));
@ -463,14 +471,7 @@ namespace MWGui
bool RaceDialog::onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) bool RaceDialog::onControllerButtonEvent(const SDL_ControllerButtonEvent& arg)
{ {
if (arg.button == SDL_CONTROLLER_BUTTON_A) if (arg.button == SDL_CONTROLLER_BUTTON_B)
{
if (mOkButtonFocus)
onOkClicked(mOkButton);
else
onBackClicked(mBackButton);
}
else if (arg.button == SDL_CONTROLLER_BUTTON_B)
{ {
onBackClicked(mBackButton); onBackClicked(mBackButton);
} }
@ -502,13 +503,6 @@ namespace MWGui
winMgr->setKeyFocusWidget(mRaceList); winMgr->setKeyFocusWidget(mRaceList);
winMgr->injectKeyPress(MyGUI::KeyCode::ArrowDown, 0, false); winMgr->injectKeyPress(MyGUI::KeyCode::ArrowDown, 0, false);
} }
else if ((arg.button == SDL_CONTROLLER_BUTTON_DPAD_LEFT && mOkButtonFocus) ||
(arg.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT && !mOkButtonFocus))
{
mOkButtonFocus = !mOkButtonFocus;
mOkButton->setStateSelected(mOkButtonFocus);
mBackButton->setStateSelected(!mOkButtonFocus);
}
return true; return true;
} }

View file

@ -124,7 +124,6 @@ namespace MWGui
bool onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) override; bool onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) override;
bool onControllerThumbstickEvent(const SDL_ControllerAxisEvent& arg) override; bool onControllerThumbstickEvent(const SDL_ControllerAxisEvent& arg) override;
bool mOkButtonFocus = true;
}; };
} }
#endif #endif

View file

@ -125,6 +125,8 @@ namespace MWGui
mControllerButtons.a = "#{sSelect}"; mControllerButtons.a = "#{sSelect}";
mControllerButtons.b = "#{sBack}"; mControllerButtons.b = "#{sBack}";
mControllerButtons.x = "#{sDone}"; mControllerButtons.x = "#{sDone}";
okButton->setCaption(
MyGUI::UString(MWBase::Environment::get().getWindowManager()->getGameSettingString("sDone", {})));
} }
} }