ManaPlus
viewport.h
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2004-2009 The Mana World Development Team
4  * Copyright (C) 2009-2010 The Mana Developers
5  * Copyright (C) 2011-2017 The ManaPlus Developers
6  *
7  * This file is part of The ManaPlus Client.
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #ifndef PROGS_DYECMD_GUI_VIEWPORT_H
24 #define PROGS_DYECMD_GUI_VIEWPORT_H
25 
26 #include "position.h"
27 
29 
31 
32 class ActorSprite;
33 class Being;
34 class FloorItem;
35 class Graphics;
36 class Map;
37 class MapItem;
38 
44  public MouseListener,
45  public ConfigListener
46 {
47  public:
51  Viewport();
52 
54 
55 
58  ~Viewport();
59 
63  void setMap(Map *const map);
64 
68  void draw(Graphics *const graphics) override final A_NONNULL(2);
69 
70  void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
71 
75  void logic() override final;
76 
82  void toggleMapDrawType();
83 
84  void toggleCameraMode();
85 
89  void mousePressed(MouseEvent &event) override final;
90 
94  void mouseDragged(MouseEvent &event) override final;
95 
99  void mouseReleased(MouseEvent &event) override final;
100 
104  void mouseMoved(MouseEvent &event) override final;
105 
109  void optionChanged(const std::string &name) override final;
110 
115  { return mPixelViewX; }
116 
121  { return mPixelViewY; }
122 
126  void scrollBy(const int x, const int y)
127  { mPixelViewX += x; mPixelViewY += y; }
128 
132  void cleanHoverItems();
133 
135  { return mMap; }
136 
137  void moveCamera(const int dx, const int dy);
138 
140  { return mCameraRelativeX; }
141 
143  { return mCameraRelativeY; }
144 
145  void setCameraRelativeX(const int n) noexcept2
146  { mCameraRelativeX = n; }
147 
148  void setCameraRelativeY(const int n) noexcept2
149  { mCameraRelativeY = n; }
150 
151  void videoResized();
152 
153  int mMouseX;
154  int mMouseY;
156  private:
161  void drawDebugPath(Graphics *const graphics) A_NONNULL(2);
162 
166  void drawPath(Graphics *const graphics,
167  const Path &path,
168  const Color &color = Color(255, 0, 0))
169  const A_NONNULL(2);
170 
171  bool leftMouseAction();
172 
173  bool openContextMenu(const MouseEvent &event);
174 
175  void walkByMouse(const MouseEvent &event);
176 
180  void followMouse();
181 
201 
209 };
210 
211 extern Viewport *viewport;
213 #endif // PROGS_DYECMD_GUI_VIEWPORT_H
#define A_DELETE_COPY(func)
Definition: localconsts.h:52
void setCameraRelativeY(const int n)
Definition: viewport.h:148
int mPixelViewX
Definition: viewport.h:194
void toggleMapDrawType()
Definition: viewport.cpp:250
int mLocalWalkTime
Definition: viewport.h:197
void walkByMouse(const MouseEvent &event)
Definition: viewport.cpp:174
bool mMouseDirectionMove
Definition: viewport.h:205
void followMouse()
Definition: viewport.cpp:124
void mouseDragged(MouseEvent &event)
Definition: viewport.cpp:178
~Viewport()
Definition: viewport.cpp:82
Being * mHoverBeing
Definition: viewport.h:184
void mouseReleased(MouseEvent &event)
Definition: viewport.cpp:197
int mCameraRelativeX
Definition: viewport.h:199
#define A_WARN_UNUSED
Definition: localconsts.h:172
int mScrollCenterOffsetX
Definition: viewport.h:190
#define final
Definition: localconsts.h:45
bool mMouseClicked
Definition: viewport.h:207
int getCameraRelativeY() const
Definition: viewport.h:142
void toggleCameraMode()
Definition: viewport.cpp:254
int mMouseX
Definition: viewport.h:153
#define A_NONNULL(...)
Definition: localconsts.h:179
int mCameraRelativeY
Definition: viewport.h:200
bool mPlayerFollowMouse
Definition: viewport.h:208
int mScrollRadius
Definition: viewport.h:188
Viewport()
Definition: viewport.cpp:39
void scrollBy(const int x, const int y)
Definition: viewport.h:126
FloorItem * mHoverItem
Definition: viewport.h:185
void safeDraw(Graphics *const graphics)
Definition: viewport.cpp:110
void videoResized()
Definition: viewport.cpp:270
bool mShowBeingPopup
Definition: viewport.h:202
int getCameraY() const
Definition: viewport.h:120
void moveCamera(const int dx, const int dy)
Definition: viewport.cpp:1067
int mMousePressY
Definition: viewport.h:193
int mScrollCenterOffsetY
Definition: viewport.h:191
void setMap(Map *const map)
Definition: viewport.cpp:88
void cleanHoverItems()
Definition: viewport.cpp:258
bool mSelfMouseHeal
Definition: viewport.h:203
int mScrollLaziness
Definition: viewport.h:189
Definition: map.h:68
bool mLongMouseClick
Definition: viewport.h:206
int mPixelViewY
Definition: viewport.h:195
int mMouseY
Definition: viewport.h:154
int getCameraX() const
Definition: viewport.h:114
void drawPath(Graphics *const graphics, const Path &path, const Color &color=Color(255, 0, 0)) const
Definition: viewport.cpp:353
MapItem * mHoverSign
Definition: viewport.h:186
Map * mMap
Definition: viewport.h:182
void mouseMoved(MouseEvent &event)
Definition: viewport.cpp:246
void logic()
Definition: viewport.cpp:115
bool mEnableLazyScrolling
Definition: viewport.h:204
void drawDebugPath(Graphics *const graphics)
Definition: viewport.cpp:128
int getCameraRelativeX() const
Definition: viewport.h:139
std::list< Position > Path
Definition: position.h:48
bool openContextMenu(const MouseEvent &event)
Definition: viewport.cpp:132
Definition: color.h:74
void optionChanged(const std::string &name)
Definition: viewport.cpp:228
void setCameraRelativeX(const int n)
Definition: viewport.h:145
Map * getMap() const
Definition: viewport.h:134
void mousePressed(MouseEvent &event)
Definition: viewport.cpp:137
bool leftMouseAction()
Definition: viewport.cpp:265
Definition: being.h:93
void draw(Graphics *const graphics)
Definition: viewport.cpp:92
#define noexcept2
Definition: localconsts.h:49
int mMousePressX
Definition: viewport.h:192
Viewport * viewport
Definition: viewport.cpp:35