diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/npcdialog.cpp | 39 | ||||
-rw-r--r-- | src/gui/npcdialog.h | 7 | ||||
-rw-r--r-- | src/gui/viewport.h | 6 |
3 files changed, 50 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; +} diff --git a/src/gui/npcdialog.h b/src/gui/npcdialog.h index e76897499..4d919a3f2 100644 --- a/src/gui/npcdialog.h +++ b/src/gui/npcdialog.h @@ -172,6 +172,10 @@ class NpcDialog : public Window, public gcn::ActionListener, */ static void destroyAll(); + void saveCamera(); + + void restoreCamera(); + private: typedef std::list<NpcDialog*> DialogList; static DialogList instances; @@ -230,6 +234,9 @@ class NpcDialog : public Window, public gcn::ActionListener, NpcInputState mInputState; NpcActionState mActionState; int mLastNextTime; + int mCameraMode; + int mCameraX; + int mCameraY; }; #endif // NPCDIALOG_H diff --git a/src/gui/viewport.h b/src/gui/viewport.h index 0f56e9426..4ed80ed32 100644 --- a/src/gui/viewport.h +++ b/src/gui/viewport.h @@ -248,6 +248,12 @@ class Viewport : public WindowContainer, public gcn::MouseListener, int getCameraRelativeY() { return mCameraRelativeY; } + void setCameraRelativeX(int n) + { mCameraRelativeX = n; } + + void setCameraRelativeY(int n) + { mCameraRelativeY = n; } + bool isPopupMenuVisible(); void moveCameraToActor(int actorId, int x = 0, int y = 0); |