diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-07-23 02:30:20 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-07-23 02:30:20 +0300 |
commit | 648c85816ca9398dd9c672d5d4230bef030e0274 (patch) | |
tree | 1d897dff70e183cb8c31f558426921be8dcf6ce7 | |
parent | 6336dabcb33ca6b4d417b352fa0b12651b6f4c57 (diff) | |
download | mv-648c85816ca9398dd9c672d5d4230bef030e0274.tar.gz mv-648c85816ca9398dd9c672d5d4230bef030e0274.tar.bz2 mv-648c85816ca9398dd9c672d5d4230bef030e0274.tar.xz mv-648c85816ca9398dd9c672d5d4230bef030e0274.zip |
move "change camera mode" option into gamemodifiers.
-rw-r--r-- | src/being/localplayer.cpp | 20 | ||||
-rw-r--r-- | src/being/localplayer.h | 2 | ||||
-rw-r--r-- | src/game.cpp | 2 | ||||
-rw-r--r-- | src/gamemodifiers.cpp | 18 | ||||
-rw-r--r-- | src/gamemodifiers.h | 2 | ||||
-rw-r--r-- | src/gui/popups/statuspopup.cpp | 4 | ||||
-rw-r--r-- | src/gui/viewport.cpp | 19 | ||||
-rw-r--r-- | src/gui/viewport.h | 4 | ||||
-rw-r--r-- | src/gui/windows/npcdialog.cpp | 14 | ||||
-rw-r--r-- | src/gui/windows/npcdialog.h | 2 | ||||
-rw-r--r-- | src/gui/windows/statuswindow.cpp | 4 | ||||
-rw-r--r-- | src/settings.h | 2 |
12 files changed, 43 insertions, 50 deletions
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp index 77706051c..11102a67f 100644 --- a/src/being/localplayer.cpp +++ b/src/being/localplayer.cpp @@ -1255,24 +1255,6 @@ void LocalPlayer::changeMode(unsigned *restrict const var, debugMsg(str.substr(4)); } -const unsigned cameraModeSize = 2; - -static const char *const cameraModeStrings[] = -{ - // TRANSLATORS: camera mode in status bar - N_("(G) game camera mode"), - // TRANSLATORS: camera mode in status bar - N_("(F) free camera mode"), - // TRANSLATORS: camera mode in status bar - N_("(?) away") -}; - -std::string LocalPlayer::getCameraModeString() -{ - return gettext(getVarItem(&cameraModeStrings[0], - viewport->getCameraMode(), cameraModeSize)); -} - void LocalPlayer::changeEquipmentBeforeAttack(const Being *const target) const { if (settings.attackWeaponType == 1 || !target || !PlayerInfo::getInventory()) @@ -3271,7 +3253,7 @@ void LocalPlayer::resetYellowBar() if (viewport) { settings.mapDrawType = MapType::NORMAL; - if (viewport->getCameraMode()) + if (settings.cameraMode) viewport->toggleCameraMode(); } if (mMap) diff --git a/src/being/localplayer.h b/src/being/localplayer.h index 3aabda22d..96e6efb88 100644 --- a/src/being/localplayer.h +++ b/src/being/localplayer.h @@ -387,8 +387,6 @@ class LocalPlayer final : public Being, void setTestParticle(const std::string &fileName, const bool updateHash = true); - static std::string getCameraModeString(); - int getLastAttackX() const override final { return mTarget ? mTarget->getTileX() : mLastAttackX; } diff --git a/src/game.cpp b/src/game.cpp index aaa0ed9cf..2262e34e5 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -880,7 +880,7 @@ void Game::moveInDirection(const unsigned char direction) if (!viewport) return; - if (!viewport->getCameraMode()) + if (!settings.cameraMode) { if (player_node) player_node->specialMove(direction); diff --git a/src/gamemodifiers.cpp b/src/gamemodifiers.cpp index cd3f1d352..5870993eb 100644 --- a/src/gamemodifiers.cpp +++ b/src/gamemodifiers.cpp @@ -558,3 +558,21 @@ std::string GameModifiers::getAwayModeString() return gettext(getVarItem(&awayModeStrings[0], settings.awayMode, awayModeSize)); } + +const unsigned cameraModeSize = 2; + +static const char *const cameraModeStrings[] = +{ + // TRANSLATORS: camera mode in status bar + N_("(G) game camera mode"), + // TRANSLATORS: camera mode in status bar + N_("(F) free camera mode"), + // TRANSLATORS: camera mode in status bar + N_("(?) away") +}; + +std::string GameModifiers::getCameraModeString() +{ + return gettext(getVarItem(&cameraModeStrings[0], + settings.cameraMode, cameraModeSize)); +} diff --git a/src/gamemodifiers.h b/src/gamemodifiers.h index 76c23003a..972db2e69 100644 --- a/src/gamemodifiers.h +++ b/src/gamemodifiers.h @@ -98,6 +98,8 @@ class GameModifiers final std::string getAwayModeString(); + std::string getCameraModeString(); + 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 776845bfa..16ea93e42 100644 --- a/src/gui/popups/statuspopup.cpp +++ b/src/gui/popups/statuspopup.cpp @@ -137,7 +137,7 @@ void StatusPopup::setLabelText(const int num, void StatusPopup::updateLabels() const { - if (!player_node || !viewport || !modifiers) + if (!modifiers) return; setLabelText(0, modifiers->getMoveTypeString(), @@ -168,6 +168,6 @@ void StatusPopup::updateLabels() const InputAction::CHANGE_IMITATION_MODE); setLabelText(13, modifiers->getAwayModeString(), InputAction::AWAY); - setLabelText(14, LocalPlayer::getCameraModeString(), + setLabelText(14, modifiers->getCameraModeString(), InputAction::CAMERA); } diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 5a2c9cc91..8acc19ca6 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -80,7 +80,6 @@ Viewport::Viewport() : mMousePressY(0), mPixelViewX(0), mPixelViewY(0), - mCameraMode(0), mLocalWalkTime(-1), mCameraRelativeX(0), mCameraRelativeY(0), @@ -410,7 +409,7 @@ bool Viewport::openContextMenu(const MouseEvent &event) mPopupMenu->showPopup(eventX, eventY, mHoverSign); return true; } - else if (mCameraMode) + else if (settings.cameraMode) { if (!mMap) return false; @@ -1012,10 +1011,10 @@ void Viewport::toggleMapDrawType() void Viewport::toggleCameraMode() { - mCameraMode++; - if (mCameraMode > 1) - mCameraMode = 0; - if (!mCameraMode) + settings.cameraMode ++; + if (settings.cameraMode > 1) + settings.cameraMode = 0; + if (!settings.cameraMode) { mCameraRelativeX = 0; mCameraRelativeY = 0; @@ -1069,7 +1068,7 @@ void Viewport::moveCameraToActor(const int actorId, return; const Vector &actorPos = actor->getPosition(); const Vector &playerPos = player_node->getPosition(); - mCameraMode = 1; + settings.cameraMode = 1; mCameraRelativeX = static_cast<int>(actorPos.x - playerPos.x) + x; mCameraRelativeY = static_cast<int>(actorPos.y - playerPos.y) + y; } @@ -1080,7 +1079,7 @@ void Viewport::moveCameraToPosition(const int x, const int y) return; const Vector &playerPos = player_node->getPosition(); - mCameraMode = 1; + settings.cameraMode = 1; mCameraRelativeX = x - static_cast<int>(playerPos.x); mCameraRelativeY = y - static_cast<int>(playerPos.y); @@ -1088,14 +1087,14 @@ void Viewport::moveCameraToPosition(const int x, const int y) void Viewport::moveCameraRelative(const int x, const int y) { - mCameraMode = 1; + settings.cameraMode = 1; mCameraRelativeX += x; mCameraRelativeY += y; } void Viewport::returnCamera() { - mCameraMode = 0; + settings.cameraMode = 0; mCameraRelativeX = 0; mCameraRelativeY = 0; } diff --git a/src/gui/viewport.h b/src/gui/viewport.h index 9ed4b3f7f..579821ce6 100644 --- a/src/gui/viewport.h +++ b/src/gui/viewport.h @@ -242,9 +242,6 @@ class Viewport final : public WindowContainer, void scrollBy(const int x, const int y) { mPixelViewX += x; mPixelViewY += y; } - int getCameraMode() const A_WARN_UNUSED - { return mCameraMode; } - /** * Hides the BeingPopup. */ @@ -338,7 +335,6 @@ class Viewport final : public WindowContainer, int mMousePressY; int mPixelViewX; /**< Current viewpoint in pixels. */ int mPixelViewY; /**< Current viewpoint in pixels. */ - int mCameraMode; /**< Camera mode. */ int mLocalWalkTime; /**< Timestamp before the next walk can be sent. */ diff --git a/src/gui/windows/npcdialog.cpp b/src/gui/windows/npcdialog.cpp index fac7714ed..0ccae687b 100644 --- a/src/gui/windows/npcdialog.cpp +++ b/src/gui/windows/npcdialog.cpp @@ -26,6 +26,7 @@ #include "configuration.h" #include "inventory.h" #include "item.h" +#include "settings.h" #include "soundconsts.h" #include "soundmanager.h" @@ -823,7 +824,7 @@ void NpcDialog::saveCamera() if (!viewport || mCameraMode >= 0) return; - mCameraMode = viewport->getCameraMode(); + mCameraMode = settings.cameraMode; mCameraX = viewport->getCameraRelativeX(); mCameraY = viewport->getCameraRelativeY(); } @@ -833,15 +834,10 @@ void NpcDialog::restoreCamera() if (!viewport || mCameraMode == -1) return; - if (!mCameraMode) + if (settings.cameraMode != mCameraMode) + viewport->toggleCameraMode(); + if (mCameraMode) { - if (viewport->getCameraMode() != mCameraMode) - viewport->toggleCameraMode(); - } - else - { - if (viewport->getCameraMode() != mCameraMode) - viewport->toggleCameraMode(); viewport->setCameraRelativeX(mCameraX); viewport->setCameraRelativeY(mCameraY); } diff --git a/src/gui/windows/npcdialog.h b/src/gui/windows/npcdialog.h index bd9c21678..7c72550c9 100644 --- a/src/gui/windows/npcdialog.h +++ b/src/gui/windows/npcdialog.h @@ -296,7 +296,7 @@ class NpcDialog final : public Window, PlayerBox *mPlayerBox; Being *mAvatarBeing; int mLastNextTime; - int mCameraMode; + unsigned int mCameraMode; int mCameraX; int mCameraY; bool mShowAvatar; diff --git a/src/gui/windows/statuswindow.cpp b/src/gui/windows/statuswindow.cpp index c4b645424..cdbf33fe8 100644 --- a/src/gui/windows/statuswindow.cpp +++ b/src/gui/windows/statuswindow.cpp @@ -640,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 || !modifiers) + if (!modifiers) return; bar->setText(translateLetter2(modifiers->getMoveTypeString()) @@ -659,7 +659,7 @@ void StatusWindow::updateStatusBar(ProgressBar *const bar, modifiers->getMapDrawTypeString())) .append(" ").append(translateLetter2( modifiers->getImitationModeString())) - .append(translateLetter2(LocalPlayer::getCameraModeString())) + .append(translateLetter2(modifiers->getCameraModeString())) .append(translateLetter2(modifiers->getAwayModeString()))); bar->setProgress(50); diff --git a/src/settings.h b/src/settings.h index 1c9a4b8f0..e607aa241 100644 --- a/src/settings.h +++ b/src/settings.h @@ -65,6 +65,7 @@ class Settings final magicAttackType(0U), pvpAttackType(0U), imitationMode(0U), + cameraMode(0U), mapDrawType(MapType::NORMAL), persistentIp(true), limitFps(false), @@ -105,6 +106,7 @@ class Settings final unsigned int magicAttackType; unsigned int pvpAttackType; unsigned int imitationMode; + unsigned int cameraMode; MapType::MapType mapDrawType; bool persistentIp; bool limitFps; |