From 77846cfb61a3e4793d3fae5c1cc23fb68851c9ac Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Mon, 25 Mar 2024 17:13:57 +0100 Subject: Avoid accessing static members through instances Fixed with clang-tidy `readability-static-accessed-through-instance` check. --- src/gui/inventorywindow.cpp | 2 +- src/gui/setup_keyboard.cpp | 10 +++++----- src/gui/viewport.cpp | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/gui') diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index 450ddfe5..048f83f5 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -277,7 +277,7 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event) if (event.getButton() == gcn::MouseEvent::LEFT) { - if (instances.size() > 1 && keyboard.isKeyActive(keyboard.KEY_EMOTE)) + if (instances.size() > 1 && keyboard.isKeyActive(KeyboardConfig::KEY_EMOTE)) { Item *item = mItems->getSelectedItem(); diff --git a/src/gui/setup_keyboard.cpp b/src/gui/setup_keyboard.cpp index ee6e340f..f40a8109 100644 --- a/src/gui/setup_keyboard.cpp +++ b/src/gui/setup_keyboard.cpp @@ -51,7 +51,7 @@ class KeyListModel : public gcn::ListModel /** * Returns the number of elements in container. */ - int getNumberOfElements() override { return keyboard.KEY_TOTAL; } + int getNumberOfElements() override { return KeyboardConfig::KEY_TOTAL; } /** * Returns element from container. @@ -161,7 +161,7 @@ void Setup_Keyboard::action(const gcn::ActionEvent &event) int i(mKeyList->getSelected()); keyboard.setNewKeyIndex(i); refreshAssignedKey(mKeyList->getSelected()); - keyboard.setNewKey(keyboard.KEY_NO_VALUE); + keyboard.setNewKey(KeyboardConfig::KEY_NO_VALUE); mAssignKeyButton->setEnabled(true); } else if (event.getId() == "makeDefault") @@ -174,7 +174,7 @@ void Setup_Keyboard::action(const gcn::ActionEvent &event) void Setup_Keyboard::refreshAssignedKey(int index) { std::string caption; - if (keyboard.getKeyValue(index) == keyboard.KEY_NO_VALUE) + if (keyboard.getKeyValue(index) == KeyboardConfig::KEY_NO_VALUE) caption = keyboard.getKeyCaption(index) + ": "; else { @@ -198,7 +198,7 @@ void Setup_Keyboard::newKeyCallback(int index) void Setup_Keyboard::refreshKeys() { - for (int i = 0; i < keyboard.KEY_TOTAL; i++) + for (int i = 0; i < KeyboardConfig::KEY_TOTAL; i++) { refreshAssignedKey(i); } @@ -209,6 +209,6 @@ void Setup_Keyboard::keyUnresolved() if (mKeySetting) { newKeyCallback(keyboard.getNewKeyIndex()); - keyboard.setNewKeyIndex(keyboard.KEY_NO_VALUE); + keyboard.setNewKeyIndex(KeyboardConfig::KEY_NO_VALUE); } } diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 9c1d2c9f..8fcca014 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -480,10 +480,10 @@ void Viewport::mousePressed(gcn::MouseEvent &event) { if (local_player->withinRange(mHoverBeing, local_player->getAttackRange()) - || keyboard.isKeyActive(keyboard.KEY_ATTACK)) + || keyboard.isKeyActive(KeyboardConfig::KEY_ATTACK)) { local_player->attack(mHoverBeing, - !keyboard.isKeyActive(keyboard.KEY_TARGET)); + !keyboard.isKeyActive(KeyboardConfig::KEY_TARGET)); } else { -- cgit v1.2.3-70-g09d2