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  *
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() override final;
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)
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
ConfigListener
Definition: configlistener.h:36
Viewport::mPixelViewX
int mPixelViewX
Definition: viewport.h:194
Viewport::getCameraRelativeX
int getCameraRelativeX() const
Definition: viewport.h:139
Viewport::mLongMouseClick
bool mLongMouseClick
Definition: viewport.h:206
mouselistener.h
Viewport::mScrollRadius
int mScrollRadius
Definition: viewport.h:188
Viewport::mouseReleased
void mouseReleased(MouseEvent &event)
Definition: viewport.cpp:197
Viewport::~Viewport
~Viewport()
Definition: viewport.cpp:82
MapItem
Definition: mapitem.h:31
Viewport::mScrollCenterOffsetX
int mScrollCenterOffsetX
Definition: viewport.h:190
Viewport::safeDraw
void safeDraw(Graphics *const graphics)
Definition: viewport.cpp:110
Viewport::mScrollLaziness
int mScrollLaziness
Definition: viewport.h:189
A_DELETE_COPY
#define A_DELETE_COPY(func)
Definition: localconsts.h:52
Path
std::list< Position > Path
Definition: position.h:48
Viewport::mMousePressY
int mMousePressY
Definition: viewport.h:193
Viewport
Definition: viewport.h:43
Viewport::mShowBeingPopup
bool mShowBeingPopup
Definition: viewport.h:202
Viewport::mMouseClicked
bool mMouseClicked
Definition: viewport.h:207
Viewport::setCameraRelativeY
void setCameraRelativeY(const int n)
Definition: viewport.h:148
Viewport::mCameraRelativeY
int mCameraRelativeY
Definition: viewport.h:200
Viewport::mouseDragged
void mouseDragged(MouseEvent &event)
Definition: viewport.cpp:178
Graphics
Definition: graphics.h:107
Viewport::drawDebugPath
void drawDebugPath(Graphics *const graphics)
Definition: viewport.cpp:128
Viewport::mMouseY
int mMouseY
Definition: viewport.h:154
Viewport::toggleCameraMode
void toggleCameraMode()
Definition: viewport.cpp:254
Viewport::moveCamera
void moveCamera(const int dx, const int dy)
Definition: viewport.cpp:1069
viewport
Viewport * viewport
Definition: viewport.cpp:35
noexcept2
#define noexcept2
Definition: localconsts.h:49
Viewport::toggleMapDrawType
void toggleMapDrawType()
Definition: viewport.cpp:250
Viewport::getCameraY
int getCameraY() const
Definition: viewport.h:120
Viewport::drawPath
void drawPath(Graphics *const graphics, const Path &path, const Color &color) const
Definition: viewport.cpp:353
FloorItem
Definition: flooritem.h:43
final
#define final
Definition: localconsts.h:45
Viewport::setMap
void setMap(Map *const map)
Definition: viewport.cpp:88
Viewport::mEnableLazyScrolling
bool mEnableLazyScrolling
Definition: viewport.h:204
Viewport::mLocalWalkTime
int mLocalWalkTime
Definition: viewport.h:197
Viewport::mHoverSign
MapItem * mHoverSign
Definition: viewport.h:186
ActorSprite
Definition: actorsprite.h:54
Viewport::mMouseX
int mMouseX
Definition: viewport.h:153
Viewport::mSelfMouseHeal
bool mSelfMouseHeal
Definition: viewport.h:203
x
x
Definition: graphics_calcImageRect.hpp:72
WindowContainer
Definition: windowcontainer.h:34
Being
Definition: being.h:93
Viewport::mouseMoved
void mouseMoved(MouseEvent &event)
Definition: viewport.cpp:246
Viewport::getCameraRelativeY
int getCameraRelativeY() const
Definition: viewport.h:142
position.h
Viewport::mMousePressX
int mMousePressX
Definition: viewport.h:192
Viewport::mPlayerFollowMouse
bool mPlayerFollowMouse
Definition: viewport.h:208
Viewport::leftMouseAction
bool leftMouseAction()
Definition: viewport.cpp:265
MouseListener
Definition: mouselistener.h:76
Viewport::getMap
Map * getMap() const
Definition: viewport.h:134
Viewport::mMap
Map * mMap
Definition: viewport.h:182
Viewport::mPixelViewY
int mPixelViewY
Definition: viewport.h:195
Viewport::mScrollCenterOffsetY
int mScrollCenterOffsetY
Definition: viewport.h:191
Viewport::mousePressed
void mousePressed(MouseEvent &event)
Definition: viewport.cpp:137
Viewport::logic
void logic()
Definition: viewport.cpp:115
Viewport::mHoverItem
FloorItem * mHoverItem
Definition: viewport.h:185
windowcontainer.h
Viewport::optionChanged
void optionChanged(const std::string &name)
Definition: viewport.cpp:228
Viewport::videoResized
void videoResized()
Definition: viewport.cpp:270
Map
Definition: map.h:71
Viewport::cleanHoverItems
void cleanHoverItems()
Definition: viewport.cpp:258
Viewport::scrollBy
void scrollBy(const int x, const int y)
Definition: viewport.h:126
A_WARN_UNUSED
#define A_WARN_UNUSED
Definition: localconsts.h:160
Viewport::getCameraX
int getCameraX() const
Definition: viewport.h:114
Viewport::walkByMouse
void walkByMouse(const MouseEvent &event)
Definition: viewport.cpp:174
Viewport::mMouseDirectionMove
bool mMouseDirectionMove
Definition: viewport.h:205
Viewport::setCameraRelativeX
void setCameraRelativeX(const int n)
Definition: viewport.h:145
Viewport::draw
void draw(Graphics *const graphics)
Definition: viewport.cpp:92
MouseEvent
Definition: mouseevent.h:79
Viewport::mCameraRelativeX
int mCameraRelativeX
Definition: viewport.h:199
Color
Definition: color.h:74
y
y
Definition: graphics_calcImageRect.hpp:72
A_NONNULL
#define A_NONNULL(...)
Definition: localconsts.h:167
Viewport::mHoverBeing
Being * mHoverBeing
Definition: viewport.h:184
Viewport::followMouse
void followMouse()
Definition: viewport.cpp:124
Viewport::Viewport
Viewport()
Definition: viewport.cpp:39
Viewport::openContextMenu
bool openContextMenu(const MouseEvent &event)
Definition: viewport.cpp:132