Pass InGameMenu to Equipment constructor
Signed-off-by: William Brawner <me@wbrawner.com>
This commit is contained in:
parent
46bb9d42f6
commit
59badb7d25
3 changed files with 10 additions and 14 deletions
|
@ -72,14 +72,14 @@ static unordered_map<Equipment::Slot, int32_t> g_slotStrRefs = {
|
|||
{ Equipment::Slot::WeapR2, 31379 }
|
||||
};
|
||||
|
||||
Equipment::Equipment(Game *game) : GameGUI(game) {
|
||||
Equipment::Equipment(Game *game, InGameMenu *inGameMenu) : GameGUI(game), _inGameMenu(inGameMenu) {
|
||||
_resRef = getResRef("equip");
|
||||
|
||||
initForGame();
|
||||
loadBackground(BackgroundType::Menu);
|
||||
}
|
||||
|
||||
void Equipment::bindControls(InGameMenu *menu) {
|
||||
void Equipment::bindControls() {
|
||||
_binding.lblCantEquip = getControlPtr<Label>("LBL_CANTEQUIP");
|
||||
if (!isTSL(_game->gameId())) {
|
||||
_binding.lblAttackInfo = getControlPtr<Label>("LBL_ATTACK_INFO");
|
||||
|
@ -105,8 +105,8 @@ void Equipment::bindControls(InGameMenu *menu) {
|
|||
_binding.btnPrevNpc = getControlPtr<Button>("BTN_PREVNPC");
|
||||
_binding.btnNextNpc = getControlPtr<Button>("BTN_NEXTNPC");
|
||||
_binding.lblDefText = getControlPtr<Label>("LBL_DEF_TEXT");
|
||||
_binding.btnChange1 = menu->getBtnChange2();
|
||||
_binding.btnChange2 = menu->getBtnChange3();
|
||||
_binding.btnChange1 = _inGameMenu->getBtnChange2();
|
||||
_binding.btnChange2 = _inGameMenu->getBtnChange3();
|
||||
_binding.btnCharLeft = getControlPtr<Button>("BTN_PREVNPC");
|
||||
_binding.btnCharRight = getControlPtr<Button>("BTN_NEXTNPC");
|
||||
}
|
||||
|
@ -131,12 +131,8 @@ void Equipment::bindControls(InGameMenu *menu) {
|
|||
}
|
||||
|
||||
void Equipment::load() {
|
||||
Equipment::load(nullptr);
|
||||
}
|
||||
|
||||
void Equipment::load(InGameMenu *menu) {
|
||||
GUI::load();
|
||||
bindControls(menu);
|
||||
bindControls();
|
||||
|
||||
_binding.btnChange1->setFocusable(false);
|
||||
_binding.btnChange2->setFocusable(false);
|
||||
|
|
|
@ -47,10 +47,9 @@ public:
|
|||
WeapR2
|
||||
};
|
||||
|
||||
Equipment(Game *game);
|
||||
Equipment(Game *game, InGameMenu *inGameMenu);
|
||||
|
||||
void load() override;
|
||||
void load(InGameMenu *menu);
|
||||
|
||||
void update();
|
||||
|
||||
|
@ -101,6 +100,7 @@ private:
|
|||
} _binding;
|
||||
Slot _selectedSlot { Slot::None };
|
||||
int _selectedItemIdx { -1 };
|
||||
InGameMenu *_inGameMenu;
|
||||
|
||||
void onClick(const std::string &control) override;
|
||||
void onFocusChanged(const std::string &control, bool focus) override;
|
||||
|
@ -116,7 +116,7 @@ private:
|
|||
std::shared_ptr<graphics::Texture> getItemFrameTexture(int stackSize) const;
|
||||
std::shared_ptr<graphics::Texture> getEmptySlotIcon(Slot slot) const;
|
||||
|
||||
void bindControls(InGameMenu *menu);
|
||||
void bindControls();
|
||||
};
|
||||
|
||||
} // namespace game
|
||||
|
|
|
@ -79,8 +79,8 @@ void InGameMenu::load() {
|
|||
}
|
||||
|
||||
void InGameMenu::loadEquipment() {
|
||||
_equip = make_unique<Equipment>(_game);
|
||||
_equip->load(this);
|
||||
_equip = make_unique<Equipment>(_game, this);
|
||||
_equip->load();
|
||||
}
|
||||
|
||||
void InGameMenu::loadInventory() {
|
||||
|
|
Loading…
Reference in a new issue