Use constants for binding lists sizes

Signed-off-by: William Brawner <me@wbrawner.com>
This commit is contained in:
William Brawner 2021-06-09 18:34:46 -06:00
parent 5fcafb49bc
commit 701b1f4f2a
4 changed files with 12 additions and 7 deletions

View file

@ -116,7 +116,7 @@ void CharacterMenu::bindControls() {
_binding.lblClass = getControlPtr<Label>("LBL_CLASS");
_binding.lblClass1 = getControlPtr<Label>("LBL_CLASS1");
_binding.lblClass2 = getControlPtr<Label>("LBL_CLASS2");
for (int i = 0; i < 10; ++i) {
for (int i = 0; i < kNumControlsGood; ++i) {
_binding.lblGood[i] = getControlPtr<Label>("LBL_GOOD" + to_string(i + 1));
}
_binding.lblLevel = getControlPtr<Label>("LBL_LEVEL");
@ -134,7 +134,7 @@ void CharacterMenu::bindControls() {
_binding.lblStatsBorder = getControlPtr<Label>("LBL_STATSBORDER");
_binding.lblTitle = getControlPtr<Label>("LBL_TITLE");
_binding.lblXpBack = getControlPtr<Label>("LBL_XP_BACK");
for (int i = 0; i < 6; ++i) {
for (int i = 0; i < kNumControlsBar; ++i) {
_binding.lblBar[i] = getControlPtr<Label>("LBL_BAR" + to_string(i + 1));
}
_binding.btnChange1 = _inGameMenu.getBtnChange2();

View file

@ -40,6 +40,9 @@ public:
void refreshControls();
private:
static constexpr int kNumControlsGood = 10;
static constexpr int kNumControlsBar = 6;
struct Binding {
std::shared_ptr<gui::Label> lbl3dChar;
std::shared_ptr<gui::Button> btn3dChar;
@ -94,7 +97,7 @@ private:
std::shared_ptr<gui::Label> lblClass;
std::shared_ptr<gui::Label> lblClass1;
std::shared_ptr<gui::Label> lblClass2;
std::shared_ptr<gui::Label> lblGood[10];
std::shared_ptr<gui::Label> lblGood[kNumControlsGood];
std::shared_ptr<gui::Label> lblLevel;
std::shared_ptr<gui::Label> lblLevel1;
std::shared_ptr<gui::Label> lblLevel2;
@ -110,7 +113,7 @@ private:
std::shared_ptr<gui::Label> lblStatsBorder;
std::shared_ptr<gui::Label> lblTitle;
std::shared_ptr<gui::Label> lblXpBack;
std::shared_ptr<gui::Label> lblBar[6];
std::shared_ptr<gui::Label> lblBar[kNumControlsBar];
// End TSL only
} _binding;

View file

@ -97,7 +97,7 @@ void Equipment::bindControls() {
} else {
_binding.lblBack1 = getControlPtr<Label>("LBL_BACK1");
_binding.lblDefBack = getControlPtr<Label>("LBL_DEF_BACK");
for (int i = 0; i < 5; ++i) {
for (int i = 0; i < kNumControlsBar; ++i) {
_binding.lblBar[i] = getControlPtr<Label>("LBL_BAR" + to_string(i + 1));
}
_binding.lblAttackMod = getControlPtr<Label>("LBL_ATTACKMOD");

View file

@ -55,7 +55,9 @@ public:
void update();
private:
struct Binding {
static constexpr int kNumControlsBar = 5;
struct Binding {
std::shared_ptr<gui::Label> lblCantEquip;
std::shared_ptr<gui::Label> lblAttackInfo;
std::shared_ptr<gui::Label> lblToHitR;
@ -90,7 +92,7 @@ private:
// TSL only
std::shared_ptr<gui::Label> lblBack1;
std::shared_ptr<gui::Label> lblDefBack;
std::shared_ptr<gui::Label> lblBar[5];
std::shared_ptr<gui::Label> lblBar[kNumControlsBar];
std::shared_ptr<gui::Label> lblAttackMod;
std::shared_ptr<gui::Label> lblDamText;
std::shared_ptr<gui::Button> btnSwapWeapons;