diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-07-20 20:58:31 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-07-21 00:18:17 +0300 |
commit | 744b9d6689b67779a1d17c6d3de7cd016ca1033b (patch) | |
tree | 8c7f235ec6ffd1f00bd6865a355be3f731b30395 | |
parent | c42d25a77f5bd7bcd04636abded20452a753fa6d (diff) | |
download | manaverse-744b9d6689b67779a1d17c6d3de7cd016ca1033b.tar.gz manaverse-744b9d6689b67779a1d17c6d3de7cd016ca1033b.tar.bz2 manaverse-744b9d6689b67779a1d17c6d3de7cd016ca1033b.tar.xz manaverse-744b9d6689b67779a1d17c6d3de7cd016ca1033b.zip |
move "change move" option into gamemodifiers.
-rw-r--r-- | src/actionmanager.cpp | 12 | ||||
-rw-r--r-- | src/being/localplayer.cpp | 46 | ||||
-rw-r--r-- | src/being/localplayer.h | 12 | ||||
-rw-r--r-- | src/gamemodifiers.cpp | 57 | ||||
-rw-r--r-- | src/gamemodifiers.h | 8 | ||||
-rw-r--r-- | src/gui/popups/statuspopup.cpp | 6 | ||||
-rw-r--r-- | src/gui/windows/statuswindow.cpp | 3 | ||||
-rw-r--r-- | src/settings.h | 2 |
8 files changed, 84 insertions, 62 deletions
diff --git a/src/actionmanager.cpp b/src/actionmanager.cpp index 2d9d366b5..f30fab781 100644 --- a/src/actionmanager.cpp +++ b/src/actionmanager.cpp @@ -24,6 +24,7 @@ #include "dropshortcut.h" #include "emoteshortcut.h" #include "game.h" +#include "gamemodifiers.h" #include "itemshortcut.h" #include "soundmanager.h" @@ -97,6 +98,15 @@ } \ return false; +#define callYellowBar2(name) \ + if (modifiers) \ + { \ + modifiers->name(!inputManager.isActionActive( \ + InputAction::STOP_ATTACK)); \ + return true; \ + } \ + return false; + #define callYellowBarCond(name) \ if (player_node && !player_node->getDisableGameModifiers()) \ { \ @@ -499,7 +509,7 @@ impHandler0(setHome) impHandler0(changeMoveType) { - callYellowBar(changeMoveType); + callYellowBar2(changeMoveType); } impHandler0(changeAttackWeaponType) diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp index ac73d45df..df42ffc24 100644 --- a/src/being/localplayer.cpp +++ b/src/being/localplayer.cpp @@ -30,6 +30,7 @@ #include "guild.h" #include "item.h" #include "party.h" +#include "settings.h" #include "soundconsts.h" #include "soundmanager.h" #include "statuseffect.h" @@ -112,7 +113,6 @@ LocalPlayer::LocalPlayer(const int id, const uint16_t subtype) : AttributeListener(), StatListener(), mGMLevel(0), - mMoveType(0), mCrazyMoveType(config.getIntValue("crazyMoveType")), mCrazyMoveState(0), mAttackWeaponType(config.getIntValue("attackWeaponType")), @@ -568,7 +568,7 @@ void LocalPlayer::setDestination(const int x, const int y) // Only send a new message to the server when destination changes if (x != mDest.x || y != mDest.y) { - if (mMoveType != 1) + if (settings.moveType != 1) { Net::getPlayerHandler()->setDestination(x, y, mDirection); Being::setDestination(x, y); @@ -1237,8 +1237,6 @@ void LocalPlayer::moveToHome() } } -static const unsigned moveTypeSize = 5; - void LocalPlayer::changeMode(unsigned *restrict const var, const unsigned limit, const char *restrict const conf, @@ -1272,35 +1270,6 @@ void LocalPlayer::changeMode(unsigned *restrict const var, debugMsg(str.substr(4)); } -void LocalPlayer::changeMoveType(const bool forward) -{ - mMoveState = 0; - changeMode(&mMoveType, moveTypeSize, "invertMoveDirection", - &LocalPlayer::getMoveTypeString, 0, false, forward); -} - -static const char *const moveTypeStrings[] = -{ - // TRANSLATORS: move type in status bar - N_("(D) default moves"), - // TRANSLATORS: move type in status bar - N_("(I) invert moves"), - // TRANSLATORS: move type in status bar - N_("(c) moves with some crazy moves"), - // TRANSLATORS: move type in status bar - N_("(C) moves with crazy moves"), - // TRANSLATORS: move type in status bar - N_("(d) double normal + crazy"), - // TRANSLATORS: move type in status bar - N_("(?) unknown move") -}; - -std::string LocalPlayer::getMoveTypeString() -{ - return gettext(getVarItem(&moveTypeStrings[0], - mMoveType, moveTypeSize)); -} - static const unsigned crazyMoveTypeSize = 11; void LocalPlayer::changeCrazyMoveType(const bool forward) @@ -2671,18 +2640,17 @@ void LocalPlayer::specialMove(const unsigned char direction) if (direction && (mNavigateX || mNavigateY)) navigateClean(); - if (direction && (mMoveType >= 2 - && mMoveType <= 4) - && !mIsServerBuggy) + if (direction && (settings.moveType >= 2 + && settings.moveType <= 4)) { if (mAction == BeingAction::MOVE) return; int max; - if (mMoveType == 2) + if (settings.moveType == 2) max = 5; - else if (mMoveType == 4) + else if (settings.moveType == 4) max = 1; else max = 3; @@ -3724,7 +3692,7 @@ void LocalPlayer::checkNewName(Being *const being) void LocalPlayer::resetYellowBar() { - mMoveType = 0; + settings.moveType = 0; mCrazyMoveType = config.resetIntValue("crazyMoveType"); mMoveToTargetType = config.resetIntValue("moveToTargetType"); mFollowMode = config.resetIntValue("followMode"); diff --git a/src/being/localplayer.h b/src/being/localplayer.h index 82a258678..5a2d10627 100644 --- a/src/being/localplayer.h +++ b/src/being/localplayer.h @@ -186,14 +186,6 @@ class LocalPlayer final : public Being, bool isPathSetByMouse() const A_WARN_UNUSED { return mPathSetByMouse; } - int getMoveType() const A_WARN_UNUSED - { return mMoveType; } - - void setMoveType(const int n) - { mMoveType = n; } - - void changeMoveType(const bool forward); - int getAttackWeaponType() const A_WARN_UNUSED { return mAttackWeaponType; } @@ -451,8 +443,6 @@ class LocalPlayer final : public Being, void setTestParticle(const std::string &fileName, const bool updateHash = true); - std::string getMoveTypeString(); - std::string getCrazyMoveTypeString(); std::string getMoveToTargetTypeString(); @@ -537,8 +527,6 @@ class LocalPlayer final : public Being, int mGMLevel; - // move type - unsigned int mMoveType; // crazy move type unsigned int mCrazyMoveType; // crazy move state diff --git a/src/gamemodifiers.cpp b/src/gamemodifiers.cpp index 3aa5b3b0f..aea2fa6d6 100644 --- a/src/gamemodifiers.cpp +++ b/src/gamemodifiers.cpp @@ -21,11 +21,16 @@ #include "gamemodifiers.h" #include "configuration.h" +#include "settings.h" + +#include "being/localplayer.h" #include "gui/widgets/tabs/chattab.h" #include "listeners/updatestatuslistener.h" +#include "utils/gettext.h" + #include "debug.h" GameModifiers *modifiers = nullptr; @@ -39,12 +44,12 @@ GameModifiers::~GameModifiers() } void GameModifiers::changeMode(unsigned *restrict const var, - const unsigned limit, - const char *restrict const conf, - std::string (GameModifiers::*const func)(), - const unsigned def, - const bool save, - const bool forward) + const unsigned limit, + const char *restrict const conf, + std::string (GameModifiers::*const func)(), + const unsigned def, + const bool save, + const bool forward) { if (!var) return; @@ -70,3 +75,43 @@ void GameModifiers::changeMode(unsigned *restrict const var, if (str.size() > 4) debugMsg(str.substr(4)); } + +const char *GameModifiers::getVarItem(const char *const *const arr, + const unsigned index, + const unsigned sz) +{ + if (index < sz) + return arr[index]; + return arr[sz]; +} + +static const unsigned moveTypeSize = 5; + +void GameModifiers::changeMoveType(const bool forward) +{ + player_node->setMoveState(0); + changeMode(&settings.moveType, moveTypeSize, "invertMoveDirection", + &GameModifiers::getMoveTypeString, 0, false, forward); +} + +static const char *const moveTypeStrings[] = +{ + // TRANSLATORS: move type in status bar + N_("(D) default moves"), + // TRANSLATORS: move type in status bar + N_("(I) invert moves"), + // TRANSLATORS: move type in status bar + N_("(c) moves with some crazy moves"), + // TRANSLATORS: move type in status bar + N_("(C) moves with crazy moves"), + // TRANSLATORS: move type in status bar + N_("(d) double normal + crazy"), + // TRANSLATORS: move type in status bar + N_("(?) unknown move") +}; + +std::string GameModifiers::getMoveTypeString() +{ + return gettext(getVarItem(&moveTypeStrings[0], + settings.moveType, moveTypeSize)); +} diff --git a/src/gamemodifiers.h b/src/gamemodifiers.h index 4b2b54497..0a1aa945f 100644 --- a/src/gamemodifiers.h +++ b/src/gamemodifiers.h @@ -42,8 +42,14 @@ class GameModifiers final const bool save, const bool forward); - protected: + void changeMoveType(const bool forward); + + std::string getMoveTypeString(); + protected: + static const char *getVarItem(const char *const *const arr, + const unsigned index, + const unsigned sz) A_WARN_UNUSED; }; extern GameModifiers *modifiers; diff --git a/src/gui/popups/statuspopup.cpp b/src/gui/popups/statuspopup.cpp index 688898afe..23c0f313f 100644 --- a/src/gui/popups/statuspopup.cpp +++ b/src/gui/popups/statuspopup.cpp @@ -23,6 +23,8 @@ #include "gui/viewport.h" +#include "gamemodifiers.h" + #include "gui/popups/statuspopup.h" #include "gui/widgets/label.h" @@ -135,10 +137,10 @@ void StatusPopup::setLabelText(const int num, void StatusPopup::updateLabels() const { - if (!player_node || !viewport) + if (!player_node || !viewport || !modifiers) return; - setLabelText(0, player_node->getMoveTypeString(), + setLabelText(0, modifiers->getMoveTypeString(), InputAction::INVERT_DIRECTION); setLabelText(1, player_node->getCrazyMoveTypeString(), InputAction::CHANGE_CRAZY_MOVES_TYPE); diff --git a/src/gui/windows/statuswindow.cpp b/src/gui/windows/statuswindow.cpp index 029bfff1a..470028024 100644 --- a/src/gui/windows/statuswindow.cpp +++ b/src/gui/windows/statuswindow.cpp @@ -24,6 +24,7 @@ #include "configuration.h" #include "equipment.h" +#include "gamemodifiers.h" #include "inventory.h" #include "item.h" #include "units.h" @@ -641,7 +642,7 @@ void StatusWindow::updateStatusBar(ProgressBar *const bar, if (!player_node || !viewport) return; - bar->setText(translateLetter2(player_node->getMoveTypeString()) + bar->setText(translateLetter2(modifiers->getMoveTypeString()) .append(translateLetter2(player_node->getCrazyMoveTypeString())) .append(translateLetter2(player_node->getMoveToTargetTypeString())) .append(translateLetter2(player_node->getFollowModeString())) diff --git a/src/settings.h b/src/settings.h index 847600c95..50ea3223d 100644 --- a/src/settings.h +++ b/src/settings.h @@ -52,6 +52,7 @@ class Settings final options(), guiAlpha(1.0F), textureSize(1024), + moveType(0U), persistentIp(true), limitFps(false), inputFocused(true), @@ -78,6 +79,7 @@ class Settings final Options options; float guiAlpha; unsigned int textureSize; + unsigned int moveType; bool persistentIp; bool limitFps; bool inputFocused; |