mirror of
https://github.com/OpenMW/openmw.git
synced 2026-01-05 11:13:08 +00:00
Change type of mControllerFocus to size_t when applicable
This commit is contained in:
parent
622cbd5288
commit
084e4a3155
18 changed files with 45 additions and 35 deletions
|
|
@ -383,6 +383,7 @@ namespace MWGui
|
|||
|
||||
InfoBoxDialog::InfoBoxDialog()
|
||||
: WindowModal("openmw_infobox.layout")
|
||||
, mControllerFocus(0)
|
||||
{
|
||||
getWidget(mTextBox, "TextBox");
|
||||
getWidget(mText, "Text");
|
||||
|
|
@ -467,7 +468,7 @@ namespace MWGui
|
|||
{
|
||||
if (arg.button == SDL_CONTROLLER_BUTTON_A)
|
||||
{
|
||||
if (mControllerFocus >= 0 && mControllerFocus < static_cast<int>(mButtons.size()))
|
||||
if (mControllerFocus < mButtons.size())
|
||||
onButtonClicked(mButtons[mControllerFocus]);
|
||||
}
|
||||
else if (arg.button == SDL_CONTROLLER_BUTTON_B)
|
||||
|
|
@ -490,7 +491,7 @@ namespace MWGui
|
|||
{
|
||||
if (mButtons.size() <= 1)
|
||||
return true;
|
||||
if (mButtons.size() == 2 && mControllerFocus == static_cast<int>(mButtons.size()) - 1)
|
||||
if (mButtons.size() == 2 && mControllerFocus == 1)
|
||||
return true;
|
||||
|
||||
setControllerFocus(mButtons, mControllerFocus, false);
|
||||
|
|
@ -524,6 +525,7 @@ namespace MWGui
|
|||
: WindowModal("openmw_chargen_create_class.layout")
|
||||
, mAffectedAttribute(nullptr)
|
||||
, mAffectedSkill(nullptr)
|
||||
, mControllerFocus(2)
|
||||
{
|
||||
// Centre dialog
|
||||
center();
|
||||
|
|
@ -992,7 +994,7 @@ namespace MWGui
|
|||
{
|
||||
if (arg.button == SDL_CONTROLLER_BUTTON_A)
|
||||
{
|
||||
if (mControllerFocus >= 0 && mControllerFocus < static_cast<int>(mAttributeButtons.size()))
|
||||
if (mControllerFocus < mAttributeButtons.size())
|
||||
onAttributeClicked(mAttributeButtons[mControllerFocus]);
|
||||
}
|
||||
else if (arg.button == SDL_CONTROLLER_BUTTON_B)
|
||||
|
|
@ -1094,7 +1096,7 @@ namespace MWGui
|
|||
{
|
||||
if (arg.button == SDL_CONTROLLER_BUTTON_A)
|
||||
{
|
||||
if (mControllerFocus >= 0 && mControllerFocus < static_cast<int>(mSkillButtons.size()))
|
||||
if (mControllerFocus < mSkillButtons.size())
|
||||
onSkillClicked(mSkillButtons[mControllerFocus]);
|
||||
}
|
||||
else if (arg.button == SDL_CONTROLLER_BUTTON_B)
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ namespace MWGui
|
|||
MyGUI::TextBox* mText;
|
||||
MyGUI::Widget* mButtonBar;
|
||||
std::vector<MyGUI::Button*> mButtons;
|
||||
int mControllerFocus = 0;
|
||||
size_t mControllerFocus;
|
||||
};
|
||||
|
||||
// Lets the player choose between 3 ways of creating a class
|
||||
|
|
@ -218,7 +218,7 @@ namespace MWGui
|
|||
void onAttributeClicked(Widgets::MWAttributePtr _sender);
|
||||
void onCancelClicked(MyGUI::Widget* _sender);
|
||||
bool onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) override;
|
||||
int mControllerFocus;
|
||||
size_t mControllerFocus;
|
||||
std::vector<Widgets::MWAttribute*> mAttributeButtons;
|
||||
|
||||
private:
|
||||
|
|
@ -252,7 +252,7 @@ namespace MWGui
|
|||
void onSkillClicked(Widgets::MWSkillPtr _sender);
|
||||
void onCancelClicked(MyGUI::Widget* _sender);
|
||||
bool onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) override;
|
||||
int mControllerFocus;
|
||||
size_t mControllerFocus;
|
||||
std::vector<Widgets::MWSkill*> mSkillButtons;
|
||||
|
||||
private:
|
||||
|
|
@ -350,7 +350,7 @@ namespace MWGui
|
|||
Widgets::MWSkillPtr mAffectedSkill;
|
||||
|
||||
bool onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) override;
|
||||
int mControllerFocus = 2;
|
||||
size_t mControllerFocus;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -386,7 +386,7 @@ namespace MWGui
|
|||
{
|
||||
if (arg.button == SDL_CONTROLLER_BUTTON_A)
|
||||
{
|
||||
if (mControllerFocus >= 0 && mControllerFocus < static_cast<int>(mAttributeButtons.size()))
|
||||
if (mControllerFocus < mAttributeButtons.size())
|
||||
onAttributeClicked(mAttributeButtons[mControllerFocus]);
|
||||
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("Item Gold Up"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ namespace MWGui
|
|||
|
||||
bool onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) override;
|
||||
std::vector<MyGUI::Button*> mAttributeButtons;
|
||||
int mControllerFocus;
|
||||
size_t mControllerFocus;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ namespace MWGui
|
|||
{
|
||||
if (arg.button == SDL_CONTROLLER_BUTTON_A)
|
||||
{
|
||||
if (mControllerFocus >= 0 && mControllerFocus < static_cast<int>(mButtons.size()))
|
||||
if (mControllerFocus < mButtons.size())
|
||||
onRepairButtonClick(mButtons[mControllerFocus].first);
|
||||
}
|
||||
else if (arg.button == SDL_CONTROLLER_BUTTON_B)
|
||||
|
|
@ -205,7 +205,7 @@ namespace MWGui
|
|||
}
|
||||
|
||||
// Scroll the list to keep the active item in view
|
||||
if (mControllerFocus >= 0 && mControllerFocus < static_cast<int>(mButtons.size()))
|
||||
if (mControllerFocus < mButtons.size())
|
||||
{
|
||||
int line = mButtons[mControllerFocus].second;
|
||||
if (line <= 5)
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ namespace MWGui
|
|||
|
||||
MWWorld::Ptr mActor;
|
||||
|
||||
int mControllerFocus;
|
||||
size_t mControllerFocus;
|
||||
|
||||
protected:
|
||||
void onMouseWheel(MyGUI::Widget* _sender, int _rel);
|
||||
|
|
|
|||
|
|
@ -218,7 +218,7 @@ namespace MWGui
|
|||
}
|
||||
|
||||
InteractiveMessageBox::InteractiveMessageBox(MessageBoxManager& parMessageBoxManager, const std::string& message,
|
||||
const std::vector<std::string>& buttons, bool immediate, int defaultFocus)
|
||||
const std::vector<std::string>& buttons, bool immediate, size_t defaultFocus)
|
||||
: WindowModal(MWBase::Environment::get().getWindowManager()->isGuiMode()
|
||||
? "openmw_interactive_messagebox_notransp.layout"
|
||||
: "openmw_interactive_messagebox.layout")
|
||||
|
|
@ -226,6 +226,7 @@ namespace MWGui
|
|||
, mButtonPressed(-1)
|
||||
, mDefaultFocus(defaultFocus)
|
||||
, mImmediate(immediate)
|
||||
, mControllerFocus(0)
|
||||
{
|
||||
int textPadding = 10; // padding between text-widget and main-widget
|
||||
int textButtonPadding = 10; // padding between the text-widget und the button-widget
|
||||
|
|
@ -290,9 +291,9 @@ namespace MWGui
|
|||
if (mButtons.size() > 1)
|
||||
{
|
||||
mControllerFocus = 0;
|
||||
if (mDefaultFocus >= 0 && mDefaultFocus < static_cast<int>(mButtons.size()))
|
||||
if (mDefaultFocus < mButtons.size())
|
||||
mControllerFocus = mDefaultFocus;
|
||||
for (int i = 0; i < static_cast<int>(mButtons.size()); ++i)
|
||||
for (size_t i = 0; i < mButtons.size(); ++i)
|
||||
mButtons[i]->setStateSelected(i == mControllerFocus);
|
||||
}
|
||||
}
|
||||
|
|
@ -397,7 +398,7 @@ namespace MWGui
|
|||
|
||||
MyGUI::Widget* InteractiveMessageBox::getDefaultKeyFocus()
|
||||
{
|
||||
if (mDefaultFocus >= 0 && mDefaultFocus < static_cast<int>(mButtons.size()))
|
||||
if (mDefaultFocus < mButtons.size())
|
||||
return mButtons[mDefaultFocus];
|
||||
auto& languageManager = MyGUI::LanguageManager::getInstance();
|
||||
std::vector<MyGUI::UString> keywords{ languageManager.replaceTags("#{sOk}"),
|
||||
|
|
@ -452,8 +453,12 @@ namespace MWGui
|
|||
{
|
||||
if (arg.button == SDL_CONTROLLER_BUTTON_A)
|
||||
{
|
||||
mControllerFocus = std::clamp(mControllerFocus, 0, static_cast<int>(mButtons.size()) - 1);
|
||||
buttonActivated(mButtons[mControllerFocus]);
|
||||
if (!mButtons.empty())
|
||||
{
|
||||
if (mControllerFocus >= mButtons.size())
|
||||
mControllerFocus = mButtons.size() - 1;
|
||||
buttonActivated(mButtons[mControllerFocus]);
|
||||
}
|
||||
}
|
||||
else if (arg.button == SDL_CONTROLLER_BUTTON_B)
|
||||
{
|
||||
|
|
@ -475,7 +480,7 @@ namespace MWGui
|
|||
{
|
||||
if (mButtons.size() <= 1)
|
||||
return true;
|
||||
if (mButtons.size() == 2 && mControllerFocus == static_cast<int>(mButtons.size()) - 1)
|
||||
if (mButtons.size() == 2 && mControllerFocus == 1)
|
||||
return true;
|
||||
|
||||
setControllerFocus(mButtons, mControllerFocus, false);
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ namespace MWGui
|
|||
{
|
||||
public:
|
||||
InteractiveMessageBox(MessageBoxManager& parMessageBoxManager, const std::string& message,
|
||||
const std::vector<std::string>& buttons, bool immediate, int defaultFocus);
|
||||
const std::vector<std::string>& buttons, bool immediate, size_t defaultFocus);
|
||||
void mousePressed(MyGUI::Widget* _widget);
|
||||
int readPressedButton();
|
||||
|
||||
|
|
@ -114,9 +114,9 @@ namespace MWGui
|
|||
std::vector<MyGUI::Button*> mButtons;
|
||||
|
||||
int mButtonPressed;
|
||||
int mDefaultFocus;
|
||||
size_t mDefaultFocus;
|
||||
bool mImmediate;
|
||||
int mControllerFocus = 0;
|
||||
size_t mControllerFocus;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ namespace MWGui
|
|||
, mKey(std::vector<keyData>(10))
|
||||
, mSelected(nullptr)
|
||||
, mActivated(nullptr)
|
||||
|
||||
, mControllerFocus(0)
|
||||
{
|
||||
getWidget(mOkButton, "OKButton");
|
||||
getWidget(mInstructionLabel, "InstructionLabel");
|
||||
|
|
@ -118,7 +118,7 @@ namespace MWGui
|
|||
if (Settings::gui().mControllerMenus)
|
||||
{
|
||||
mControllerFocus = 0;
|
||||
for (int i = 0; i < static_cast<int>(mKey.size()); i++)
|
||||
for (size_t i = 0; i < mKey.size(); i++)
|
||||
mKey[i].button->setControllerFocus(i == mControllerFocus);
|
||||
}
|
||||
}
|
||||
|
|
@ -490,7 +490,7 @@ namespace MWGui
|
|||
mControllerFocus++;
|
||||
}
|
||||
|
||||
for (int i = 0; i < static_cast<int>(mKey.size()); i++)
|
||||
for (size_t i = 0; i < mKey.size(); i++)
|
||||
mKey[i].button->setControllerFocus(i == mControllerFocus);
|
||||
|
||||
return true;
|
||||
|
|
@ -501,6 +501,7 @@ namespace MWGui
|
|||
QuickKeysMenuAssign::QuickKeysMenuAssign(QuickKeysMenu* parent)
|
||||
: WindowModal("openmw_quickkeys_menu_assign.layout")
|
||||
, mParent(parent)
|
||||
, mControllerFocus(0)
|
||||
{
|
||||
getWidget(mLabel, "Label");
|
||||
getWidget(mItemButton, "ItemButton");
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ namespace MWGui
|
|||
void unassign(keyData* key);
|
||||
|
||||
bool onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) override;
|
||||
int mControllerFocus;
|
||||
size_t mControllerFocus;
|
||||
};
|
||||
|
||||
class QuickKeysMenuAssign : public WindowModal
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ namespace MWGui
|
|||
ReviewDialog::ReviewDialog()
|
||||
: WindowModal("openmw_chargen_review.layout")
|
||||
, mUpdateSkillArea(false)
|
||||
, mControllerFocus(5)
|
||||
{
|
||||
// Centre dialog
|
||||
center();
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ namespace MWGui
|
|||
|
||||
// 0 = Name, 1 = Race, 2 = Class, 3 = BirthSign, 4 = Back, 5 = OK
|
||||
std::vector<MyGUI::Button*> mButtons;
|
||||
int mControllerFocus = 5;
|
||||
int mControllerFocus;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ namespace MWGui
|
|||
SpellBuyingWindow::SpellBuyingWindow()
|
||||
: WindowBase("openmw_spell_buying_window.layout")
|
||||
, mCurrentY(0)
|
||||
, mControllerFocus(0)
|
||||
{
|
||||
getWidget(mCancelButton, "CancelButton");
|
||||
getWidget(mPlayerGold, "PlayerGold");
|
||||
|
|
@ -229,7 +230,7 @@ namespace MWGui
|
|||
{
|
||||
if (arg.button == SDL_CONTROLLER_BUTTON_A)
|
||||
{
|
||||
if (mControllerFocus >= 0 && mControllerFocus < static_cast<int>(mSpellButtons.size()))
|
||||
if (mControllerFocus < mSpellButtons.size())
|
||||
onSpellButtonClick(mSpellButtons[mControllerFocus].first);
|
||||
}
|
||||
else if (arg.button == SDL_CONTROLLER_BUTTON_B)
|
||||
|
|
@ -261,7 +262,7 @@ namespace MWGui
|
|||
mSpellButtons[mControllerFocus].first->setStateSelected(true);
|
||||
}
|
||||
|
||||
if (mControllerFocus >= 0 && mControllerFocus < static_cast<int>(mSpellButtons.size()))
|
||||
if (mControllerFocus < mSpellButtons.size())
|
||||
{
|
||||
// Scroll the list to keep the active item in view
|
||||
int line = mSpellButtons[mControllerFocus].second;
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ namespace MWGui
|
|||
private:
|
||||
static bool sortSpells(const ESM::Spell* left, const ESM::Spell* right);
|
||||
bool onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) override;
|
||||
int mControllerFocus;
|
||||
size_t mControllerFocus;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -250,7 +250,7 @@ namespace MWGui
|
|||
{
|
||||
if (arg.button == SDL_CONTROLLER_BUTTON_A)
|
||||
{
|
||||
if (mControllerFocus >= 0 && mControllerFocus < static_cast<int>(mTrainingButtons.size()))
|
||||
if (mControllerFocus < mTrainingButtons.size())
|
||||
onTrainingSelected(mTrainingButtons[mControllerFocus]);
|
||||
}
|
||||
else if (arg.button == SDL_CONTROLLER_BUTTON_B)
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ namespace MWGui
|
|||
TimeAdvancer mTimeAdvancer;
|
||||
|
||||
bool onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) override;
|
||||
int mControllerFocus;
|
||||
size_t mControllerFocus;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -263,7 +263,7 @@ namespace MWGui
|
|||
{
|
||||
if (arg.button == SDL_CONTROLLER_BUTTON_A)
|
||||
{
|
||||
if (mControllerFocus >= 0 && mControllerFocus < static_cast<int>(mDestinationButtons.size()))
|
||||
if (mControllerFocus < mDestinationButtons.size())
|
||||
{
|
||||
onTravelButtonClick(mDestinationButtons[mControllerFocus]);
|
||||
MWBase::Environment::get().getWindowManager()->playSound(ESM::RefId::stringRefId("Menu Click"));
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ namespace MWGui
|
|||
|
||||
private:
|
||||
bool onControllerButtonEvent(const SDL_ControllerButtonEvent& arg) override;
|
||||
int mControllerFocus;
|
||||
size_t mControllerFocus;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue