diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-01-25 02:35:39 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-01-25 02:35:39 +0300 |
commit | e15445f0f8f95f1547798b886b002146d282c006 (patch) | |
tree | d29b49d8d7d0c8d997cbd58ce3733dba5c2c5a9a /src/gui/npcdialog.cpp | |
parent | 992f105f78fb0e4c42fcc7941e289a2348a3ccaf (diff) | |
download | manaplus-e15445f0f8f95f1547798b886b002146d282c006.tar.gz manaplus-e15445f0f8f95f1547798b886b002146d282c006.tar.bz2 manaplus-e15445f0f8f95f1547798b886b002146d282c006.tar.xz manaplus-e15445f0f8f95f1547798b886b002146d282c006.zip |
Save camera mode before speaking with npc and restore after.
Diffstat (limited to 'src/gui/npcdialog.cpp')
-rw-r--r-- | src/gui/npcdialog.cpp | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp index 265748b6f..eadd99c21 100644 --- a/src/gui/npcdialog.cpp +++ b/src/gui/npcdialog.cpp @@ -26,6 +26,7 @@ #include "client.h" #include "gui/setup.h" +#include "gui/viewport.h" #include "gui/widgets/browserbox.h" #include "gui/widgets/button.h" @@ -62,7 +63,10 @@ NpcDialog::NpcDialog(int npcId) : mDefaultInt(0), mInputState(NPC_INPUT_NONE), mActionState(NPC_ACTION_WAIT), - mLastNextTime(0) + mLastNextTime(0), + mCameraMode(-1), + mCameraX(0), + mCameraY(0) { // Basic Window Setup setWindowName("NpcText"); @@ -301,6 +305,7 @@ void NpcDialog::nextDialog() void NpcDialog::closeDialog() { + restoreCamera(); Net::getNpcHandler()->closeDialog(mNpcId); } @@ -504,4 +509,34 @@ void NpcDialog::buildLayout() redraw(); mScrollArea->setVerticalScrollAmount(mScrollArea->getVerticalMaxScroll()); -}
\ No newline at end of file +} + +void NpcDialog::saveCamera() +{ + if (!viewport || mCameraMode >= 0) + return; + + mCameraMode = viewport->getCameraMode(); + mCameraX = viewport->getCameraRelativeX(); + mCameraY = viewport->getCameraRelativeY(); +} + +void NpcDialog::restoreCamera() +{ + if (!viewport || mCameraMode == -1) + return; + + if (!mCameraMode) + { + if (viewport->getCameraMode() != mCameraMode) + viewport->toggleCameraMode(); + } + else + { + if (viewport->getCameraMode() != mCameraMode) + viewport->toggleCameraMode(); + viewport->setCameraRelativeX(mCameraX); + viewport->setCameraRelativeY(mCameraY); + } + mCameraMode = -1; +} |