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-2019 The ManaPlus Developers
6  * Copyright (C) 2019-2021 Andrei Karas
7  *
8  * This file is part of The ManaPlus Client.
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  */
23 
24 #ifndef PROGS_DYECMD_GUI_VIEWPORT_H
25 #define PROGS_DYECMD_GUI_VIEWPORT_H
26 
27 #include "position.h"
28 
30 
32 
33 class ActorSprite;
34 class Being;
35 class FloorItem;
36 class Graphics;
37 class Map;
38 class MapItem;
39 
45  public MouseListener,
46  public ConfigListener
47 {
48  public:
52  Viewport();
53 
55 
56 
59  ~Viewport() override final;
60 
64  void setMap(Map *const map);
65 
69  void draw(Graphics *const graphics) override final A_NONNULL(2);
70 
71  void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
72 
76  void logic() override final;
77 
83  void toggleMapDrawType();
84 
85  void toggleCameraMode();
86 
90  void mousePressed(MouseEvent &event) override final;
91 
95  void mouseDragged(MouseEvent &event) override final;
96 
100  void mouseReleased(MouseEvent &event) override final;
101 
105  void mouseMoved(MouseEvent &event) override final;
106 
110  void optionChanged(const std::string &name) override final;
111 
116  { return mPixelViewX; }
117 
122  { return mPixelViewY; }
123 
127  void scrollBy(const int x, const int y)
128  { mPixelViewX += x; mPixelViewY += y; }
129 
133  void cleanHoverItems();
134 
136  { return mMap; }
137 
138  void moveCamera(const int dx, const int dy);
139 
141  { return mCameraRelativeX; }
142 
144  { return mCameraRelativeY; }
145 
146  void setCameraRelativeX(const int n) noexcept2
147  { mCameraRelativeX = n; }
148 
149  void setCameraRelativeY(const int n) noexcept2
150  { mCameraRelativeY = n; }
151 
152  void videoResized();
153 
154  int mMouseX;
155  int mMouseY;
157  private:
162  void drawDebugPath(Graphics *const graphics) A_NONNULL(2);
163 
167  void drawPath(Graphics *const graphics,
168  const Path &path,
169  const Color &color)
170  const A_NONNULL(2);
171 
172  bool leftMouseAction();
173 
174  bool openContextMenu(const MouseEvent &event);
175 
176  void walkByMouse(const MouseEvent &event);
177 
181  void followMouse();
182 
202 
210 };
211 
212 extern Viewport *viewport;
214 #endif // PROGS_DYECMD_GUI_VIEWPORT_H
Definition: being.h:96
Definition: color.h:76
Definition: map.h:75
int mMouseX
Definition: viewport.h:154
void setCameraRelativeX(const int n)
Definition: viewport.h:146
void scrollBy(const int x, const int y)
Definition: viewport.h:127
~Viewport()
Definition: viewport.cpp:83
Being * mHoverBeing
Definition: viewport.h:185
void logic()
Definition: viewport.cpp:116
int mScrollLaziness
Definition: viewport.h:190
void toggleMapDrawType()
Definition: viewport.cpp:251
int mMousePressX
Definition: viewport.h:193
Map * mMap
Definition: viewport.h:183
int mCameraRelativeY
Definition: viewport.h:201
int mPixelViewX
Definition: viewport.h:195
bool openContextMenu(const MouseEvent &event)
Definition: viewport.cpp:133
bool mLongMouseClick
Definition: viewport.h:207
bool mMouseClicked
Definition: viewport.h:208
bool leftMouseAction()
Definition: viewport.cpp:266
void moveCamera(const int dx, const int dy)
Definition: viewport.cpp:1070
bool mPlayerFollowMouse
Definition: viewport.h:209
Map * getMap() const
Definition: viewport.h:135
void toggleCameraMode()
Definition: viewport.cpp:255
int mScrollCenterOffsetX
Definition: viewport.h:191
void followMouse()
Definition: viewport.cpp:125
bool mEnableLazyScrolling
Definition: viewport.h:205
bool mShowBeingPopup
Definition: viewport.h:203
void optionChanged(const std::string &name)
Definition: viewport.cpp:229
void drawPath(Graphics *const graphics, const Path &path, const Color &color) const
Definition: viewport.cpp:354
void mouseMoved(MouseEvent &event)
Definition: viewport.cpp:247
void mousePressed(MouseEvent &event)
Definition: viewport.cpp:138
void videoResized()
Definition: viewport.cpp:271
Viewport()
Definition: viewport.cpp:40
int mLocalWalkTime
Definition: viewport.h:198
FloorItem * mHoverItem
Definition: viewport.h:186
void draw(Graphics *const graphics)
Definition: viewport.cpp:93
int getCameraY() const
Definition: viewport.h:121
bool mMouseDirectionMove
Definition: viewport.h:206
bool mSelfMouseHeal
Definition: viewport.h:204
int mCameraRelativeX
Definition: viewport.h:200
void walkByMouse(const MouseEvent &event)
Definition: viewport.cpp:175
void mouseDragged(MouseEvent &event)
Definition: viewport.cpp:179
MapItem * mHoverSign
Definition: viewport.h:187
int mPixelViewY
Definition: viewport.h:196
void setCameraRelativeY(const int n)
Definition: viewport.h:149
int mScrollRadius
Definition: viewport.h:189
void setMap(Map *const map)
Definition: viewport.cpp:89
void drawDebugPath(Graphics *const graphics)
Definition: viewport.cpp:129
int getCameraRelativeY() const
Definition: viewport.h:143
void safeDraw(Graphics *const graphics)
Definition: viewport.cpp:111
void cleanHoverItems()
Definition: viewport.cpp:259
int mScrollCenterOffsetY
Definition: viewport.h:192
int getCameraRelativeX() const
Definition: viewport.h:140
int getCameraX() const
Definition: viewport.h:115
void mouseReleased(MouseEvent &event)
Definition: viewport.cpp:198
int mMouseY
Definition: viewport.h:155
int mMousePressY
Definition: viewport.h:194
#define A_WARN_UNUSED
Definition: localconsts.h:161
#define A_NONNULL(...)
Definition: localconsts.h:168
#define noexcept2
Definition: localconsts.h:50
#define final
Definition: localconsts.h:46
#define A_DELETE_COPY(func)
Definition: localconsts.h:53
std::list< Position > Path
Definition: position.h:49
Viewport * viewport
Definition: viewport.cpp:36