diff options
Diffstat (limited to 'src/gui/viewport.h')
-rw-r--r-- | src/gui/viewport.h | 49 |
1 files changed, 31 insertions, 18 deletions
diff --git a/src/gui/viewport.h b/src/gui/viewport.h index 616b88be..d8687219 100644 --- a/src/gui/viewport.h +++ b/src/gui/viewport.h @@ -22,14 +22,16 @@ #ifndef VIEWPORT_H #define VIEWPORT_H -#include "beingmanager.h" -#include "configlistener.h" +#include "eventlistener.h" #include "position.h" #include "gui/widgets/windowcontainer.h" #include <guichan/mouselistener.hpp> +#include <list> + +class ActorSprite; class Being; class BeingPopup; class FloorItem; @@ -52,17 +54,11 @@ const int walkingMouseDelay = 500; * coordinates. */ class Viewport : public WindowContainer, public gcn::MouseListener, - public ConfigListener + public EventListener { public: - /** - * Constructor. - */ Viewport(); - /** - * Destructor. - */ ~Viewport(); /** @@ -119,11 +115,6 @@ class Viewport : public WindowContainer, public gcn::MouseListener, void closePopupMenu(); /** - * A relevant config option changed. - */ - void optionChanged(const std::string &name); - - /** * Returns camera x offset in pixels. */ int getCameraX() const { return (int) mPixelViewX; } @@ -158,11 +149,23 @@ class Viewport : public WindowContainer, public gcn::MouseListener, */ void hideBeingPopup(); - protected: - friend class BeingManager; + /** + * Makes the screen shake in a random direction + */ + void shakeScreen(int intensity); + + /** + * Makes the screen shake in a specific direction + */ + void shakeScreen(float x, float y, float decay = 0.95f, unsigned duration = 0); - /// Clears the hovered being if it matches - void clearHoverBeing(Being *being); + /** + * Stops all active screen shake effects + */ + void shakeScreenStop() + { mShakeEffects.clear(); } + + void event(Event::Channel channel, const Event &event); private: /** @@ -199,6 +202,16 @@ class Viewport : public WindowContainer, public gcn::MouseListener, float mPixelViewY; /**< Current viewpoint in pixels. */ int mShowDebugPath; /**< Show a path from player to pointer. */ + struct ShakeEffect + { + float x; + float y; + float decay; + unsigned duration; + }; + typedef std::list<ShakeEffect> ShakeEffects; + ShakeEffects mShakeEffects; + bool mPlayerFollowMouse; int mLocalWalkTime; /**< Timestamp before the next walk can be sent. */ |