diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-07-22 01:41:19 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-07-22 01:41:19 +0300 |
commit | d569dc78b5b50c0e6cbe84e48164e5774fd36de7 (patch) | |
tree | abe4bf6e0822fe0d1ee2149f88cd0e6e4452c396 | |
parent | aaa50f7ef8de21ea1f32065beb15a7a58faf28a5 (diff) | |
download | manaplus-d569dc78b5b50c0e6cbe84e48164e5774fd36de7.tar.gz manaplus-d569dc78b5b50c0e6cbe84e48164e5774fd36de7.tar.bz2 manaplus-d569dc78b5b50c0e6cbe84e48164e5774fd36de7.tar.xz manaplus-d569dc78b5b50c0e6cbe84e48164e5774fd36de7.zip |
move "change game modifiers" option into gamemodifiers.
-rw-r--r-- | src/actionmanager.cpp | 5 | ||||
-rw-r--r-- | src/being/localplayer.cpp | 34 | ||||
-rw-r--r-- | src/being/localplayer.h | 8 | ||||
-rw-r--r-- | src/gamemodifiers.cpp | 27 | ||||
-rw-r--r-- | src/gamemodifiers.h | 4 | ||||
-rw-r--r-- | src/gui/popups/statuspopup.cpp | 2 | ||||
-rw-r--r-- | src/gui/windows/statuswindow.cpp | 5 | ||||
-rw-r--r-- | src/input/inputmanager.cpp | 3 | ||||
-rw-r--r-- | src/settings.h | 4 |
9 files changed, 45 insertions, 47 deletions
diff --git a/src/actionmanager.cpp b/src/actionmanager.cpp index e46517a96..9aed163d6 100644 --- a/src/actionmanager.cpp +++ b/src/actionmanager.cpp @@ -26,6 +26,7 @@ #include "game.h" #include "gamemodifiers.h" #include "itemshortcut.h" +#include "settings.h" #include "soundmanager.h" #include "being/attributes.h" @@ -99,7 +100,7 @@ return false; #define callYellowBarCond(name) \ - if (modifiers && !player_node->getDisableGameModifiers()) \ + if (modifiers && !settings.disableGameModifiers) \ { \ modifiers->name(!inputManager.isActionActive( \ InputAction::STOP_ATTACK)); \ @@ -562,7 +563,7 @@ impHandler0(changeGameModifier) { if (player_node) { - player_node->switchGameModifiers(); + modifiers->changeGameModifiers(); return true; } return false; diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp index d7580b552..54dd93ff9 100644 --- a/src/being/localplayer.cpp +++ b/src/being/localplayer.cpp @@ -160,7 +160,6 @@ LocalPlayer::LocalPlayer(const int id, const uint16_t subtype) : mEnableAdvert(config.getBoolValue("enableAdvert")), mTradebot(config.getBoolValue("tradebot")), mTargetOnlyReachable(config.getBoolValue("targetOnlyReachable")), - mDisableGameModifiers(config.getBoolValue("disableGameModifiers")), mIsServerBuggy(serverConfig.getValueBool("enableBuggyServers", true)), mSyncPlayerMove(config.getBoolValue("syncPlayerMove")), mDrawPath(config.getBoolValue("drawPath")), @@ -1357,36 +1356,6 @@ std::string LocalPlayer::getCameraModeString() viewport->getCameraMode(), cameraModeSize)); } -const unsigned gameModifiersSize = 2; - -void LocalPlayer::switchGameModifiers() -{ - mDisableGameModifiers = !mDisableGameModifiers; - config.setValue("disableGameModifiers", mDisableGameModifiers); - UpdateStatusListener::distributeEvent(); - - const std::string str = getGameModifiersString(); - if (str.size() > 4) - debugMsg(str.substr(4)); -} - -static const char *const gameModifiersStrings[] = -{ - // TRANSLATORS: game modifiers state in status bar - N_("Game modifiers are enabled"), - // TRANSLATORS: game modifiers state in status bar - N_("Game modifiers are disabled"), - // TRANSLATORS: game modifiers state in status bar - N_("Game modifiers are unknown") -}; - -std::string LocalPlayer::getGameModifiersString() -{ - return gettext(getVarItem(&gameModifiersStrings[0], - mDisableGameModifiers, gameModifiersSize)); -} - - void LocalPlayer::changeEquipmentBeforeAttack(const Being *const target) const { if (settings.attackWeaponType == 1 || !target || !PlayerInfo::getInventory()) @@ -3391,7 +3360,8 @@ void LocalPlayer::resetYellowBar() if (mMap) mMap->setDrawLayersFlags(0); settings.imitationMode = config.resetIntValue("imitationMode"); - mDisableGameModifiers = config.resetBoolValue("disableGameModifiers"); + settings.disableGameModifiers = config.resetBoolValue( + "disableGameModifiers"); UpdateStatusListener::distributeEvent(); } diff --git a/src/being/localplayer.h b/src/being/localplayer.h index b7b071c46..8e32b8d14 100644 --- a/src/being/localplayer.h +++ b/src/being/localplayer.h @@ -198,15 +198,10 @@ class LocalPlayer final : public Being, void setCrazyMoveState(const unsigned int n) { mCrazyMoveState = n; } - int getDisableGameModifiers() const A_WARN_UNUSED - { return mDisableGameModifiers; } - std::string getPingTime() const A_WARN_UNUSED; void tryPingRequest(); - void switchGameModifiers(); - void magicAttack() const; void specialMove(const unsigned char direction); @@ -403,8 +398,6 @@ class LocalPlayer final : public Being, static std::string getCameraModeString(); - std::string getGameModifiersString(); - int getLastAttackX() const override final { return mTarget ? mTarget->getTileX() : mLastAttackX; } @@ -527,7 +520,6 @@ class LocalPlayer final : public Being, bool mEnableAdvert; bool mTradebot; bool mTargetOnlyReachable; - bool mDisableGameModifiers; bool mIsServerBuggy; bool mSyncPlayerMove; bool mDrawPath; diff --git a/src/gamemodifiers.cpp b/src/gamemodifiers.cpp index bb1907a37..777d7e9f0 100644 --- a/src/gamemodifiers.cpp +++ b/src/gamemodifiers.cpp @@ -47,6 +47,8 @@ GameModifiers::GameModifiers() settings.magicAttackType = config.getIntValue("magicAttackType"); settings.pvpAttackType = config.getIntValue("pvpAttackType"); settings.imitationMode = config.getIntValue("imitationMode"); + settings.disableGameModifiers = config.getBoolValue( + "disableGameModifiers"); } GameModifiers::~GameModifiers() @@ -435,3 +437,28 @@ std::string GameModifiers::getImitationModeString() return gettext(getVarItem(&imitationModeStrings[0], settings.imitationMode, imitationModeSize)); } + +const unsigned gameModifiersSize = 2; + +void GameModifiers::changeGameModifiers() +{ + settings.disableGameModifiers = !settings.disableGameModifiers; + config.setValue("disableGameModifiers", settings.disableGameModifiers); + UpdateStatusListener::distributeEvent(); +} + +static const char *const gameModifiersStrings[] = +{ + // TRANSLATORS: game modifiers state in status bar + N_("Game modifiers are enabled"), + // TRANSLATORS: game modifiers state in status bar + N_("Game modifiers are disabled"), + // TRANSLATORS: game modifiers state in status bar + N_("Game modifiers are unknown") +}; + +std::string GameModifiers::getGameModifiersString() +{ + return gettext(getVarItem(&gameModifiersStrings[0], + settings.disableGameModifiers, gameModifiersSize)); +} diff --git a/src/gamemodifiers.h b/src/gamemodifiers.h index 01416d794..283ebb4bb 100644 --- a/src/gamemodifiers.h +++ b/src/gamemodifiers.h @@ -64,6 +64,8 @@ class GameModifiers final void changeImitationMode(const bool forward); + void changeGameModifiers(); + void setQuickDropCounter(const int n); std::string getMoveTypeString(); @@ -88,6 +90,8 @@ class GameModifiers final std::string getImitationModeString(); + std::string getGameModifiersString(); + protected: static const char *getVarItem(const char *const *const arr, const unsigned index, diff --git a/src/gui/popups/statuspopup.cpp b/src/gui/popups/statuspopup.cpp index 69aec1f8a..b1fcb2b20 100644 --- a/src/gui/popups/statuspopup.cpp +++ b/src/gui/popups/statuspopup.cpp @@ -162,7 +162,7 @@ void StatusPopup::updateLabels() const InputAction::SWITCH_MAGIC_ATTACK); setLabelText(10, modifiers->getPvpAttackTypeString(), InputAction::SWITCH_PVP_ATTACK); - setLabelText(11, player_node->getGameModifiersString(), + setLabelText(11, modifiers->getGameModifiersString(), InputAction::DISABLE_GAME_MODIFIERS); setLabelText(12, modifiers->getImitationModeString(), InputAction::CHANGE_IMITATION_MODE); diff --git a/src/gui/windows/statuswindow.cpp b/src/gui/windows/statuswindow.cpp index b2d2c2ff8..aac148d42 100644 --- a/src/gui/windows/statuswindow.cpp +++ b/src/gui/windows/statuswindow.cpp @@ -27,6 +27,7 @@ #include "gamemodifiers.h" #include "inventory.h" #include "item.h" +#include "settings.h" #include "units.h" #include "gui/windows/chatwindow.h" @@ -639,7 +640,7 @@ std::string StatusWindow::translateLetter2(const std::string &letters) void StatusWindow::updateStatusBar(ProgressBar *const bar, const bool percent A_UNUSED) const { - if (!player_node || !viewport) + if (!player_node || !viewport || !modifiers) return; bar->setText(translateLetter2(modifiers->getMoveTypeString()) @@ -662,7 +663,7 @@ void StatusWindow::updateStatusBar(ProgressBar *const bar, .append(translateLetter2(player_node->getAwayModeString()))); bar->setProgress(50); - if (player_node->getDisableGameModifiers()) + if (settings.disableGameModifiers) bar->setBackgroundColor(getThemeColor(Theme::STATUSBAR_ON)); else bar->setBackgroundColor(getThemeColor(Theme::STATUSBAR_OFF)); diff --git a/src/input/inputmanager.cpp b/src/input/inputmanager.cpp index 22ea7f85b..f8d3f7505 100644 --- a/src/input/inputmanager.cpp +++ b/src/input/inputmanager.cpp @@ -22,6 +22,7 @@ #include "configuration.h" #include "game.h" +#include "settings.h" #include "touchmanager.h" #include "input/inputactionmap.h" @@ -674,7 +675,7 @@ void InputManager::updateConditionMask() mMask |= InputCondition::NOTALKING; } - if (!player_node || !player_node->getDisableGameModifiers()) + if (!settings.disableGameModifiers) mMask |= InputCondition::EMODS; if (!isActionActive0(InputAction::STOP_ATTACK) diff --git a/src/settings.h b/src/settings.h index cd9c319ec..e64a4fba3 100644 --- a/src/settings.h +++ b/src/settings.h @@ -66,7 +66,8 @@ class Settings final persistentIp(true), limitFps(false), inputFocused(true), - mouseFocused(true) + mouseFocused(true), + disableGameModifiers(false) { } std::string updateHost; @@ -104,6 +105,7 @@ class Settings final bool limitFps; bool inputFocused; bool mouseFocused; + bool disableGameModifiers; }; extern Settings settings; |