diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-07-23 16:30:02 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-07-23 16:37:35 +0300 |
commit | 9f05a455bc052317260d859f82e80d36f4f21991 (patch) | |
tree | 82ab7e7731004d60e8d11521ac07fdacf0e155fb /src | |
parent | 7314f563ed9390760d514d8708948c7863240e0e (diff) | |
download | plus-9f05a455bc052317260d859f82e80d36f4f21991.tar.gz plus-9f05a455bc052317260d859f82e80d36f4f21991.tar.bz2 plus-9f05a455bc052317260d859f82e80d36f4f21991.tar.xz plus-9f05a455bc052317260d859f82e80d36f4f21991.zip |
In gamemodifiers simplify change methods.
Diffstat (limited to 'src')
-rw-r--r-- | src/gamemodifiers.cpp | 68 | ||||
-rw-r--r-- | src/gamemodifiers.h | 2 | ||||
-rw-r--r-- | src/gui/popups/statuspopup.cpp | 2 | ||||
-rw-r--r-- | src/gui/windows/statuswindow.cpp | 2 |
4 files changed, 21 insertions, 53 deletions
diff --git a/src/gamemodifiers.cpp b/src/gamemodifiers.cpp index 16bd95a30..8c3e56e64 100644 --- a/src/gamemodifiers.cpp +++ b/src/gamemodifiers.cpp @@ -53,6 +53,13 @@ settings.name2, m##name1##Size)); \ } +#define changeMethod(name1, name2, str) \ + void GameModifiers::change##name1(const bool forward) \ + { \ + changeMode(&settings.name2, m##name1##Size, str, \ + &GameModifiers::get##name1##String, 0, true, forward); \ + } + GameModifiers *modifiers = nullptr; GameModifiers::GameModifiers() @@ -204,12 +211,7 @@ addModifier(MoveToTargetType, 13) N_("(?) move to target") }; -void GameModifiers::changeMoveToTargetType(const bool forward) -{ - changeMode(&settings.moveToTargetType, mMoveToTargetTypeSize, - "moveToTargetType", - &GameModifiers::getMoveToTargetTypeString, 0, true, forward); -} +changeMethod(MoveToTargetType, moveToTargetType, "moveToTargetType") stringModifier(MoveToTargetType, moveToTargetType) @@ -227,11 +229,7 @@ addModifier(FollowMode, 4) N_("(?) unknown follow") }; -void GameModifiers::changeFollowMode(const bool forward) -{ - changeMode(&settings.followMode, mFollowModeSize, "followMode", - &GameModifiers::getFollowModeString, 0, true, forward); -} +changeMethod(FollowMode, followMode, "followMode") stringModifier(FollowMode, followMode) @@ -249,12 +247,7 @@ addModifier(AttackWeaponType, 4) N_("(?) attack") }; -void GameModifiers::changeAttackWeaponType(const bool forward) -{ - changeMode(&settings.attackWeaponType, mAttackWeaponTypeSize, - "attackWeaponType", - &GameModifiers::getAttackWeaponTypeString, 1, true, forward); -} +changeMethod(AttackWeaponType, attackWeaponType, "attackWeaponType") stringModifier(AttackWeaponType, attackWeaponType) @@ -272,22 +265,13 @@ addModifier(AttackType, 4) N_("(?) attack") }; -void GameModifiers::changeAttackType(const bool forward) -{ - changeMode(&settings.attackType, mAttackTypeSize, "attackType", - &GameModifiers::getAttackTypeString, 0, true, forward); -} +changeMethod(AttackType, attackType, "attackType") stringModifier(AttackType, attackType) const unsigned mQuickDropCounterSize = 31; -void GameModifiers::changeQuickDropCounter(const bool forward) -{ - changeMode(&settings.quickDropCounter, mQuickDropCounterSize, - "quickDropCounter", - &GameModifiers::getQuickDropCounterString, 1, true, forward); -} +changeMethod(QuickDropCounter, quickDropCounter, "quickDropCounter") std::string GameModifiers::getQuickDropCounterString() { @@ -332,15 +316,11 @@ addModifier(PickUpType, 7) N_("(?) pick up") }; -void GameModifiers::changePickUpType(const bool forward) -{ - changeMode(&settings.pickUpType, mPickUpTypeSize, "pickUpType", - &GameModifiers::getPickUpTypeString, 0, true, forward); -} +changeMethod(PickUpType, pickUpType, "pickUpType") stringModifier(PickUpType, pickUpType) -addModifier(MagicAttack, 5) +addModifier(MagicAttackType, 5) { // TRANSLATORS: magic attack in status bar N_("(f) use #flar for magic attack"), @@ -356,13 +336,9 @@ addModifier(MagicAttack, 5) N_("(?) magic attack") }; -void GameModifiers::changeMagicAttackType(const bool forward) -{ - changeMode(&settings.magicAttackType, mMagicAttackSize, "magicAttackType", - &GameModifiers::getMagicAttackString, 0, true, forward); -} +changeMethod(MagicAttackType, magicAttackType, "magicAttackType") -stringModifier(MagicAttack, magicAttack) +stringModifier(MagicAttackType, magicAttackType) addModifier(PvpAttackType, 4) { @@ -378,11 +354,7 @@ addModifier(PvpAttackType, 4) N_("(?) pvp attack") }; -void GameModifiers::changePvpAttackType(const bool forward) -{ - changeMode(&settings.pvpAttackType, mPvpAttackTypeSize, "pvpAttackType", - &GameModifiers::getPvpAttackTypeString, 0, true, forward); -} +changeMethod(PvpAttackType, pvpAttackType, "pvpAttackType") stringModifier(PvpAttackType, pvpAttackType) @@ -396,11 +368,7 @@ addModifier(ImitationMode, 2) N_("(?) imitation") }; -void GameModifiers::changeImitationMode(const bool forward) -{ - changeMode(&settings.imitationMode, mImitationModeSize, "imitationMode", - &GameModifiers::getImitationModeString, 0, true, forward); -} +changeMethod(ImitationMode, imitationMode, "imitationMode") stringModifier(ImitationMode, imitationMode) diff --git a/src/gamemodifiers.h b/src/gamemodifiers.h index 972db2e69..10ea579d9 100644 --- a/src/gamemodifiers.h +++ b/src/gamemodifiers.h @@ -86,7 +86,7 @@ class GameModifiers final std::string getPickUpTypeString(); - std::string getMagicAttackString(); + std::string getMagicAttackTypeString(); std::string getPvpAttackTypeString(); diff --git a/src/gui/popups/statuspopup.cpp b/src/gui/popups/statuspopup.cpp index 16ea93e42..235d2aee6 100644 --- a/src/gui/popups/statuspopup.cpp +++ b/src/gui/popups/statuspopup.cpp @@ -158,7 +158,7 @@ void StatusPopup::updateLabels() const InputAction::CHANGE_PICKUP_TYPE); setLabelText(8, modifiers->getMapDrawTypeString(), InputAction::PATHFIND); - setLabelText(9, modifiers->getMagicAttackString(), + setLabelText(9, modifiers->getMagicAttackTypeString(), InputAction::SWITCH_MAGIC_ATTACK); setLabelText(10, modifiers->getPvpAttackTypeString(), InputAction::SWITCH_PVP_ATTACK); diff --git a/src/gui/windows/statuswindow.cpp b/src/gui/windows/statuswindow.cpp index cdbf33fe8..adde623bb 100644 --- a/src/gui/windows/statuswindow.cpp +++ b/src/gui/windows/statuswindow.cpp @@ -650,7 +650,7 @@ void StatusWindow::updateStatusBar(ProgressBar *const bar, .append(" ").append(translateLetter2( modifiers->getAttackWeaponTypeString())) .append(translateLetter2(modifiers->getAttackTypeString())) - .append(translateLetter2(modifiers->getMagicAttackString())) + .append(translateLetter2(modifiers->getMagicAttackTypeString())) .append(translateLetter2(modifiers->getPvpAttackTypeString())) .append(" ").append(translateLetter2( modifiers->getQuickDropCounterString())) |