ManaPlus
Public Member Functions | Data Fields | Protected Member Functions | Static Protected Member Functions | Private Member Functions | Private Attributes | Friends
Viewport Class Reference

#include <viewport.h>

Inheritance diagram for Viewport:
WindowContainer MouseListener ConfigListener WindowContainer MouseListener ConfigListener Container Container BasicContainer2 BasicContainer2 BasicContainer BasicContainer Widget WidgetDeathListener Widget WidgetDeathListener Widget2 Widget2

Public Member Functions

 Viewport ()
 
 ~Viewport ()
 
void setMap (Map *const map)
 
void draw (Graphics *const graphics)
 
void safeDraw (Graphics *const graphics)
 
void logic ()
 
void toggleMapDrawType ()
 
void toggleCameraMode ()
 
void mousePressed (MouseEvent &event)
 
void mouseDragged (MouseEvent &event)
 
void mouseReleased (MouseEvent &event)
 
void mouseMoved (MouseEvent &event)
 
void optionChanged (const std::string &name)
 
int getCameraX () const
 
int getCameraY () const
 
void scrollBy (const int x, const int y)
 
void cleanHoverItems ()
 
MapgetMap () const
 
void moveCamera (const int dx, const int dy)
 
int getCameraRelativeX () const
 
int getCameraRelativeY () const
 
void setCameraRelativeX (const int n)
 
void setCameraRelativeY (const int n)
 
void videoResized ()
 
 Viewport ()
 
 ~Viewport ()
 
void setMap (Map *const map)
 
void draw (Graphics *const graphics)
 
void safeDraw (Graphics *const graphics)
 
void logic ()
 
void toggleMapDrawType ()
 
void toggleCameraMode ()
 
void mousePressed (MouseEvent &event)
 
void mouseDragged (MouseEvent &event)
 
void mouseReleased (MouseEvent &event)
 
void mouseMoved (MouseEvent &event)
 
void optionChanged (const std::string &name)
 
int getCameraX () const
 
int getCameraY () const
 
void scrollBy (const int x, const int y)
 
void cleanHoverItems ()
 
MapgetMap () const
 
void moveCamera (const int dx, const int dy)
 
int getCameraRelativeX () const
 
int getCameraRelativeY () const
 
void setCameraRelativeX (const int n)
 
void setCameraRelativeY (const int n)
 
void moveCameraToActor (const BeingId actorId, const int x=0, const int y=0)
 
void moveCameraToPosition (const int x, const int y)
 
void moveCameraRelative (const int x, const int y)
 
void returnCamera ()
 
void getMouseTile (int &destX, int &destY) const
 
void videoResized ()
 
- Public Member Functions inherited from WindowContainer
 WindowContainer (const Widget2 *const widget)
 
void slowLogic ()
 
void scheduleDelete (Widget *const widget)
 
void adjustAfterResize (const int oldScreenWidth, const int oldScreenHeight)
 
void moveWidgetAfter (Widget *const before, Widget *const widget)
 
- Public Member Functions inherited from Container
 Container (const Widget2 *const widget)
 
virtual ~Container ()
 
bool safeRemove (Widget *const widget)
 
void removeControls ()
 
- Public Member Functions inherited from BasicContainer2
 BasicContainer2 (const Widget2 *const widget)
 
virtual ~BasicContainer2 ()
 
void setOpaque (Opaque opaque)
 
bool isOpaque () const
 
virtual void add (Widget *const widget)
 
void addXY (Widget *const widget, const int x, const int y)
 
- Public Member Functions inherited from BasicContainer
 BasicContainer (const Widget2 *const widget)
 
virtual ~BasicContainer ()
 
void showWidgetPart (Widget *const widget, const Rect &area)
 
void moveToTop (Widget *const widget)
 
void moveToBottom (Widget *const widget)
 
Rect getChildrenArea ()
 
void focusNext ()
 
void focusPrevious ()
 
void setFocusHandler (FocusHandler *const focusHandler)
 
void setInternalFocusHandler (FocusHandler *const focusHandler)
 
WidgetgetWidgetAt (int x, int y)
 
void death (const Event &event)
 
WidgetfindFirstWidget (const std::set< Widget *> &list)
 
void add (Widget *const widget)
 
virtual void remove (Widget *const widget)
 
virtual void clear ()
 
- Public Member Functions inherited from Widget
 Widget (const Widget2 *const widget)
 
virtual ~Widget ()
 
virtual void drawFrame (Graphics *graphics)
 
virtual void safeDrawFrame (Graphics *graphics)
 
void setFrameSize (const unsigned int frameSize)
 
unsigned int getFrameSize () const
 
WidgetgetParent () const
 
void setWidth (const int width)
 
int getWidth () const
 
void setHeight (const int height)
 
int getHeight () const
 
void setSize (const int width, const int height)
 
void setX (const int x)
 
int getX () const
 
void setY (const int y)
 
int getY () const
 
void setPosition (const int x, const int y)
 
void setDimension (const Rect &dimension)
 
const RectgetDimension () const
 
void setFocusable (const bool focusable)
 
bool isFocusable () const
 
virtual bool isFocused () const
 
void setEnabled (const bool enabled)
 
bool isEnabled () const
 
void setVisible (Visible visible)
 
bool isVisible () const
 
void setBaseColor (const Color &color)
 
const ColorgetBaseColor () const
 
void setForegroundColor (const Color &color)
 
const ColorgetForegroundColor () const
 
void setBackgroundColor (const Color &color)
 
const ColorgetBackgroundColor () const
 
virtual void requestFocus ()
 
virtual void requestMoveToTop ()
 
virtual void requestMoveToBottom ()
 
FocusHandlergetFocusHandler ()
 
void addActionListener (ActionListener *const actionListener)
 
void removeActionListener (ActionListener *const actionListener)
 
void addDeathListener (WidgetDeathListener *const deathListener)
 
void removeDeathListener (WidgetDeathListener *const deathListener)
 
void addMouseListener (MouseListener *const mouseListener)
 
void removeMouseListener (MouseListener *const mouseListener)
 
void addKeyListener (KeyListener *const keyListener)
 
void removeKeyListener (KeyListener *const keyListener)
 
void addFocusListener (FocusListener *const focusListener)
 
void removeFocusListener (FocusListener *const focusListener)
 
void addWidgetListener (WidgetListener *const widgetListener)
 
void removeWidgetListener (WidgetListener *const widgetListener)
 
void setActionEventId (const std::string &actionEventId)
 
const std::string & getActionEventId () const
 
virtual void getAbsolutePosition (int &x, int &y) const
 
virtual void setParent (Widget *parent)
 
FontgetFont () const
 
void setFont (Font *const font)
 
virtual void fontChanged ()
 
bool isTabInEnabled () const
 
void setTabInEnabled (const bool enabled)
 
bool isTabOutEnabled () const
 
void setTabOutEnabled (const bool enabled)
 
void requestModalFocus ()
 
virtual void requestModalMouseInputFocus ()
 
virtual void releaseModalFocus ()
 
virtual void releaseModalMouseInputFocus ()
 
virtual bool isModalFocused () const
 
virtual bool isModalMouseInputFocused () const
 
const std::list< MouseListener * > & getMouseListeners () const A_CONST
 
const std::list< KeyListener * > & getKeyListeners () const A_CONST
 
const std::list< FocusListener * > & getFocusListeners () const A_CONST
 
virtual FocusHandlergetInternalFocusHandler ()
 
void setInternalFocusHandler (FocusHandler *const internalFocusHandler)
 
void setId (const std::string &id)
 
const std::string & getId () const
 
virtual void showPart (const Rect &rectangle)
 
bool isAllowLogic () const
 
void setMouseConsume (const bool b)
 
bool isMouseConsume () const
 
void setRedraw (const bool b)
 
virtual bool isSelectable () const
 
void setSelectable (const bool selectable)
 
void windowResized ()
 
virtual void postInit ()
 
- Public Member Functions inherited from Widget2
virtual ~Widget2 ()
 
const ColorgetThemeColor (const ThemeColorIdT type, const unsigned int alpha=255U) const A_INLINE
 
const ColorgetThemeCharColor (const signed char c, bool &valid) const A_INLINE
 
virtual void setWidget2 (const Widget2 *const widget)
 
void setPalette (int palette)
 
void checkPalette ()
 
void setForegroundColor2 (const Color &color)
 
WidgetgetWindow () const
 
virtual void setWindow (Widget *const window)
 
- Public Member Functions inherited from WidgetDeathListener
virtual ~WidgetDeathListener ()
 
- Public Member Functions inherited from MouseListener
virtual ~MouseListener ()
 
virtual void mouseEntered (MouseEvent &event)
 
virtual void mouseExited (MouseEvent &event)
 
virtual void mouseClicked (MouseEvent &event)
 
virtual void mouseWheelMovedUp (MouseEvent &event)
 
virtual void mouseWheelMovedDown (MouseEvent &event)
 
- Public Member Functions inherited from ConfigListener
 ConfigListener ()
 
virtual ~ConfigListener ()
 

Data Fields

int mMouseX
 
int mMouseY
 
- Data Fields inherited from Widget
Visible mVisible
 

Protected Member Functions

void clearHover (const ActorSprite *const actor)
 Clears any matching hovers. More...
 
void updateMidVars ()
 
void updateMaxVars ()
 
- Protected Member Functions inherited from BasicContainer
virtual void drawChildren (Graphics *const graphics)
 
virtual void safeDrawChildren (Graphics *const graphics)
 
virtual void logicChildren ()
 
- Protected Member Functions inherited from Widget
void distributeActionEvent ()
 
void distributeResizedEvent ()
 
void distributeMovedEvent ()
 
void distributeHiddenEvent ()
 
void distributeShownEvent ()
 
- Protected Member Functions inherited from Widget2
 Widget2 (const Widget2 *const widget)
 
- Protected Member Functions inherited from WidgetDeathListener
 WidgetDeathListener ()
 
- Protected Member Functions inherited from MouseListener
 MouseListener ()
 

Static Protected Member Functions

static void validateSpeed ()
 

Private Member Functions

void drawDebugPath (Graphics *const graphics)
 
void drawPath (Graphics *const graphics, const Path &path, const Color &color=Color(255, 0, 0)) const
 
bool leftMouseAction ()
 
bool openContextMenu (const MouseEvent &event)
 
void walkByMouse (const MouseEvent &event)
 
void followMouse ()
 
void drawDebugPath (Graphics *const graphics)
 
void drawPath (Graphics *const graphics, const Path &path, const Color &color=Color(255, 0, 0)) const
 
bool leftMouseAction ()
 
bool openContextMenu (const MouseEvent &event)
 
void walkByMouse (const MouseEvent &event)
 
void getMouseTile (const int x, const int y, int &destX, int &destY) const
 
void followMouse ()
 

Private Attributes

MapmMap
 
BeingmHoverBeing
 
FloorItemmHoverItem
 
MapItemmHoverSign
 
int mScrollRadius
 
int mScrollLaziness
 
int mScrollCenterOffsetX
 
int mScrollCenterOffsetY
 
int mMousePressX
 
int mMousePressY
 
int mPixelViewX
 
int mPixelViewY
 
int mLocalWalkTime
 
int mCameraRelativeX
 
int mCameraRelativeY
 
bool mShowBeingPopup
 
bool mSelfMouseHeal
 
bool mEnableLazyScrolling
 
bool mMouseDirectionMove
 
bool mLongMouseClick
 
bool mMouseClicked
 
bool mPlayerFollowMouse
 
int mMidTileX
 
int mMidTileY
 
int mViewXmax
 
int mViewYmax
 
time_t mLocalWalkTime
 
bool mAllowMoveByMouse
 

Friends

class ActorManager
 

Additional Inherited Members

- Static Public Member Functions inherited from Widget
static void setGlobalFont (Font *const font)
 
static FontgetGloablFont ()
 
static void cleanGlobalFont ()
 
static bool widgetExists (const Widget *const widget)
 
static void distributeWindowResizeEvent ()
 
static WidgetcallPostInit (Widget *const widget)
 
- Protected Types inherited from BasicContainer
typedef std::vector< Widget * > WidgetList
 
typedef WidgetList::iterator WidgetListIterator
 
typedef WidgetList::const_iterator WidgetListConstIterator
 
typedef WidgetList::reverse_iterator WidgetListReverseIterator
 
typedef WidgetList::const_reverse_iterator WidgetListCReverseIterator
 
- Protected Types inherited from Widget
typedef std::list< MouseListener * > MouseListenerList
 
typedef MouseListenerList::iterator MouseListenerIterator
 
typedef std::list< KeyListener * > KeyListenerList
 
typedef KeyListenerList::iterator KeyListenerIterator
 
typedef std::list< ActionListener * > ActionListenerList
 
typedef ActionListenerList::iterator ActionListenerIterator
 
typedef std::list< WidgetDeathListener * > WidgetDeathListenerList
 
typedef WidgetDeathListenerList::iterator WidgetDeathListenerIterator
 
typedef std::list< FocusListener * > FocusListenerList
 
typedef FocusListenerList::iterator FocusListenerIterator
 
typedef std::list< WidgetListener * > WidgetListenerList
 
typedef WidgetListenerList::iterator WidgetListenerIterator
 
- Protected Attributes inherited from BasicContainer2
Opaque mOpaque
 
- Protected Attributes inherited from BasicContainer
WidgetList mWidgets
 
WidgetList mLogicWidgets
 
- Protected Attributes inherited from Widget
MouseListenerList mMouseListeners
 
KeyListenerList mKeyListeners
 
ActionListenerList mActionListeners
 
WidgetDeathListenerList mDeathListeners
 
FocusListenerList mFocusListeners
 
WidgetListenerList mWidgetListeners
 
Color mForegroundColor
 
Color mBackgroundColor
 
Color mBaseColor
 
Rect mDimension
 
std::string mActionEventId
 
std::string mId
 
FocusHandlermFocusHandler
 
FocusHandlermInternalFocusHandler
 
WidgetmParent
 
FontmCurrentFont
 
unsigned int mFrameSize
 
bool mFocusable
 
bool mTabIn
 
bool mTabOut
 
bool mEnabled
 
bool mAllowLogic
 
bool mMouseConsume
 
bool mRedraw
 
bool mSelectable
 
- Protected Attributes inherited from Widget2
int mPaletteOffset
 
WidgetmWindow
 
Color mForegroundColor2
 
- Static Protected Attributes inherited from Widget
static FontmGlobalFont = 0
 

Detailed Description

The viewport on the map. Displays the current map and handles mouse input and the popup menu.

Definition at line 43 of file viewport.h.

Constructor & Destructor Documentation

◆ Viewport() [1/2]

Viewport::Viewport ( )

Constructor.

Definition at line 39 of file viewport.cpp.

References Configuration::addListener(), Widget::addMouseListener(), config, Opaque_false, Widget::setFocusable(), and BasicContainer2::setOpaque().

39  :
40  WindowContainer(nullptr),
41  MouseListener(),
43  mMouseX(0),
44  mMouseY(0),
45  mMap(nullptr),
46  mHoverBeing(nullptr),
47  mHoverItem(nullptr),
48  mHoverSign(nullptr),
49  mScrollRadius(config.getIntValue("ScrollRadius")),
50  mScrollLaziness(config.getIntValue("ScrollLaziness")),
51  mScrollCenterOffsetX(config.getIntValue("ScrollCenterOffsetX")),
52  mScrollCenterOffsetY(config.getIntValue("ScrollCenterOffsetY")),
53  mMousePressX(0),
54  mMousePressY(0),
55  mPixelViewX(0),
56  mPixelViewY(0),
57  mLocalWalkTime(-1),
60  mShowBeingPopup(config.getBoolValue("showBeingPopup")),
61  mSelfMouseHeal(config.getBoolValue("selfMouseHeal")),
62  mEnableLazyScrolling(config.getBoolValue("enableLazyScrolling")),
63  mMouseDirectionMove(config.getBoolValue("mouseDirectionMove")),
64  mLongMouseClick(config.getBoolValue("longmouseclick")),
65  mMouseClicked(false),
66  mPlayerFollowMouse(false)
67 {
69  addMouseListener(this);
70 
71  config.addListener("ScrollLaziness", this);
72  config.addListener("ScrollRadius", this);
73  config.addListener("showBeingPopup", this);
74  config.addListener("selfMouseHeal", this);
75  config.addListener("enableLazyScrolling", this);
76  config.addListener("mouseDirectionMove", this);
77  config.addListener("longmouseclick", this);
78 
79  setFocusable(true);
80 }
int mPixelViewX
Definition: viewport.h:194
int mLocalWalkTime
Definition: viewport.h:197
bool mMouseDirectionMove
Definition: viewport.h:205
Being * mHoverBeing
Definition: viewport.h:184
WindowContainer(const Widget2 *const widget)
int mCameraRelativeX
Definition: viewport.h:199
int mScrollCenterOffsetX
Definition: viewport.h:190
Configuration config
bool mMouseClicked
Definition: viewport.h:207
int getIntValue(const std::string &key) const
int mMouseX
Definition: viewport.h:153
int mCameraRelativeY
Definition: viewport.h:200
void addListener(const std::string &key, ConfigListener *const listener)
bool mPlayerFollowMouse
Definition: viewport.h:208
int mScrollRadius
Definition: viewport.h:188
bool getBoolValue(const std::string &key) const
FloorItem * mHoverItem
Definition: viewport.h:185
bool mShowBeingPopup
Definition: viewport.h:202
int mMousePressY
Definition: viewport.h:193
int mScrollCenterOffsetY
Definition: viewport.h:191
void addMouseListener(MouseListener *const mouseListener)
Definition: widget.cpp:291
const bool Opaque_false
Definition: opaque.h:29
bool mSelfMouseHeal
Definition: viewport.h:203
int mScrollLaziness
Definition: viewport.h:189
void setOpaque(Opaque opaque)
bool mLongMouseClick
Definition: viewport.h:206
int mPixelViewY
Definition: viewport.h:195
int mMouseY
Definition: viewport.h:154
MapItem * mHoverSign
Definition: viewport.h:186
Map * mMap
Definition: viewport.h:182
void setFocusable(const bool focusable)
Definition: widget.cpp:191
bool mEnableLazyScrolling
Definition: viewport.h:204
int mMousePressX
Definition: viewport.h:192

◆ ~Viewport() [1/2]

Viewport::~Viewport ( )

Destructor.

Definition at line 82 of file viewport.cpp.

References CHECKLISTENERS, config, and Configuration::removeListeners().

83 {
84  config.removeListeners(this);
86 }
Configuration config
void removeListeners(ConfigListener *const listener)
#define CHECKLISTENERS
Definition: localconsts.h:305

◆ Viewport() [2/2]

Viewport::Viewport ( )

Constructor.

◆ ~Viewport() [2/2]

Viewport::~Viewport ( )

Destructor.

Member Function Documentation

◆ cleanHoverItems() [1/2]

void Viewport::cleanHoverItems ( )

Clear all hover item, being etc

Definition at line 258 of file viewport.cpp.

References mHoverBeing, mHoverItem, and mHoverSign.

Referenced by Game::changeMap(), clearHover(), and scrollBy().

259 {
260  mHoverBeing = nullptr;
261  mHoverItem = nullptr;
262  mHoverSign = nullptr;
263 }
Being * mHoverBeing
Definition: viewport.h:184
FloorItem * mHoverItem
Definition: viewport.h:185
MapItem * mHoverSign
Definition: viewport.h:186

◆ cleanHoverItems() [2/2]

void Viewport::cleanHoverItems ( )

Clear all hover item, being etc

◆ clearHover()

void Viewport::clearHover ( const ActorSprite *const  actor)
protected

Clears any matching hovers.

Definition at line 1051 of file viewport.cpp.

References cleanHoverItems(), mHoverBeing, mHoverItem, and mHoverSign.

Referenced by ActorManager::logic().

1052 {
1053  if (mHoverBeing == actor)
1054  mHoverBeing = nullptr;
1055 
1056  if (mHoverItem == actor)
1057  mHoverItem = nullptr;
1058 }
Being * mHoverBeing
Definition: viewport.h:184
FloorItem * mHoverItem
Definition: viewport.h:185

◆ draw() [1/2]

void Viewport::draw ( Graphics *const  graphics)
virtual

Draws the viewport.

Reimplemented from BasicContainer2.

Definition at line 92 of file viewport.cpp.

References BLOCK_END, BLOCK_START, BasicContainer2::draw(), Graphics::fillRectangle(), Widget::getHeight(), Widget::getWidth(), Graphics::setColor(), and tick_time.

Referenced by safeDraw().

93 {
94  BLOCK_START("Viewport::draw 1")
95  static int lastTick = tick_time;
96 
97  graphics->setColor(Color(64, 64, 64));
98  graphics->fillRectangle(
99  Rect(0, 0, getWidth(), getHeight()));
100 
101  // Avoid freaking out when tick_time overflows
102  if (tick_time < lastTick)
103  lastTick = tick_time;
104 
105  // Draw contained widgets
106  WindowContainer::draw(graphics);
107  BLOCK_END("Viewport::draw 1")
108 }
int getWidth() const
Definition: widget.h:220
void fillRectangle(const Rect &restrict rect) restrict2 override final
Definition: rect.h:72
#define BLOCK_START(name)
Definition: perfomance.h:78
if(!vert) return
#define BLOCK_END(name)
Definition: perfomance.h:79
volatile int tick_time
Definition: timer.cpp:52
void setColor(const Color &restrict color) override final
int getHeight() const
Definition: widget.h:239
Definition: color.h:74
void draw(Graphics *const graphics)
Definition: viewport.cpp:92

◆ draw() [2/2]

void Viewport::draw ( Graphics *const  graphics)
virtual

Draws the viewport.

Reimplemented from BasicContainer2.

◆ drawDebugPath() [1/2]

void Viewport::drawDebugPath ( Graphics *const  graphics)
private

Finds a path from the player to the mouse, and draws it. This is for debug purposes.

Definition at line 128 of file viewport.cpp.

129 {
130 }

◆ drawDebugPath() [2/2]

void Viewport::drawDebugPath ( Graphics *const  graphics)
private

Finds a path from the player to the mouse, and draws it. This is for debug purposes.

◆ drawPath() [1/2]

void Viewport::drawPath ( Graphics *const  graphics,
const Path path,
const Color color = Color(255, 0, 0) 
) const
private

Draws the given path.

Definition at line 353 of file viewport.cpp.

References actorManager, AllPlayers_true, InputAction::ATTACK, LocalPlayer::attack(), ActorType::Avatar, Settings::cameraMode, LocalPlayer::cancelFollow(), LocalPlayer::canMove(), Being::canTalk(), CAST_S32, Font::drawString(), ActorType::Elemental, InputManager::executeChatCommand(), Graphics::fillRectangle(), ActorManager::findBeingsByPixel(), ActorManager::findNearestLivingBeing(), ActorType::FloorItem, followMouse(), ServerCommandType::font, FOR_EACH, Widget::getFont(), Event::getSource(), Map::getTileHeight(), Map::getTileWidth(), Being::getType(), Font::getWidth(), ActorManager::heal(), PopupManager::hidePopupMenu(), ActorType::Homunculus, inputManager, InputManager::isActionActive(), Being::isAlive(), PopupManager::isPopupMenuVisible(), PlayerInfo::isTalking(), MouseButton::LEFT, leftMouseAction(), localPlayer, mAllowMoveByMouse, mapTileSize, ActorType::Mercenary, mHoverBeing, mHoverItem, mHoverSign, MouseButton::MIDDLE, mLongMouseClick, mMap, mMouseClicked, mMousePressX, mMousePressY, mMouseX, mMouseY, ActorType::Monster, mousePressed(), mPixelViewX, mPixelViewY, mPlayerFollowMouse, mSelfMouseHeal, mStatsReUpdated, ActorType::Npc, openContextMenu(), ActorType::Pet, InputAction::PET_MOVE, LocalPlayer::pickUp(), ActorType::Player, popupMenu, ActorType::Portal, reportAlways, MouseButton::RIGHT, Graphics::setColor(), LocalPlayer::setGotoTarget(), LocalPlayer::setTarget(), settings, PopupMenu::showMapPopup(), PopupMenu::showPopup(), ActorType::SkillUnit, InputAction::STOP_ATTACK, Actions::stopAttack(), LocalPlayer::stopAttack(), ServerCommandType::str, strprintf(), Being::talkTo(), Catch::toString(), ActorType::Unknown, validateSpeed(), LocalPlayer::withinAttackRange(), x, and y.

356 {
357  graphics->setColor(color);
358  Font *const font = getFont();
359 
360  int cnt = 1;
361  FOR_EACH (Path::const_iterator, i, path)
362  {
363  const int squareX = i->x * mapTileSize - mPixelViewX + 12;
364  const int squareY = i->y * mapTileSize - mPixelViewY + 12;
365 
366  graphics->fillRectangle(Rect(squareX, squareY, 8, 8));
367  if (mMap != nullptr)
368  {
369  const std::string str = toString(cnt);
370  font->drawString(graphics,
371  color, color,
372  str,
373  squareX + 4 - font->getWidth(str) / 2,
374  squareY + 12);
375  }
376  cnt ++;
377  }
378 }
Font * getFont() const
Definition: widget.cpp:330
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
int mPixelViewX
Definition: viewport.h:194
Definition: font.h:88
Definition: rect.h:72
virtual void setColor(const Color &color)
Definition: graphics.h:319
void drawString(Graphics *const graphics, Color col, const Color &col2, const std::string &text, const int x, const int y)
Definition: font.cpp:253
int mPixelViewY
Definition: viewport.h:195
Map * mMap
Definition: viewport.h:182
std::string toString(T const &value)
converts any type to a string
Definition: catch.hpp:1774
virtual void fillRectangle(const Rect &rectangle)=0
int getWidth(const std::string &text) const
Definition: font.cpp:333
static const int mapTileSize
Definition: map.h:26

◆ drawPath() [2/2]

void Viewport::drawPath ( Graphics *const  graphics,
const Path path,
const Color color = Color(255, 0, 0) 
) const
private

Draws the given path.

◆ followMouse() [1/2]

void Viewport::followMouse ( )
private

Make the player go to the mouse position.

Definition at line 124 of file viewport.cpp.

Referenced by drawPath().

125 {
126 }

◆ followMouse() [2/2]

void Viewport::followMouse ( )
private

Make the player go to the mouse position.

◆ getCameraRelativeX() [1/2]

int Viewport::getCameraRelativeX ( ) const
inline

Definition at line 139 of file viewport.h.

References mCameraRelativeX.

Referenced by Minimap::draw2(), and NpcDialog::saveCamera().

140  { return mCameraRelativeX; }
int mCameraRelativeX
Definition: viewport.h:199

◆ getCameraRelativeX() [2/2]

int Viewport::getCameraRelativeX ( ) const
inline

Definition at line 141 of file viewport.h.

References mCameraRelativeX.

142  { return mCameraRelativeX; }
int mCameraRelativeX
Definition: viewport.h:199

◆ getCameraRelativeY() [1/2]

int Viewport::getCameraRelativeY ( ) const
inline

Definition at line 142 of file viewport.h.

References mCameraRelativeY.

Referenced by Minimap::draw2(), and NpcDialog::saveCamera().

143  { return mCameraRelativeY; }
int mCameraRelativeY
Definition: viewport.h:200

◆ getCameraRelativeY() [2/2]

int Viewport::getCameraRelativeY ( ) const
inline

Definition at line 144 of file viewport.h.

References mCameraRelativeY.

145  { return mCameraRelativeY; }
int mCameraRelativeY
Definition: viewport.h:200

◆ getCameraX() [1/2]

int Viewport::getCameraX ( ) const
inline

Returns camera x offset in pixels.

Definition at line 114 of file viewport.h.

References mPixelViewX.

Referenced by MapDebugTab::logic(), and ParticleEngine::update().

115  { return mPixelViewX; }
int mPixelViewX
Definition: viewport.h:194

◆ getCameraX() [2/2]

int Viewport::getCameraX ( ) const
inline

Returns camera x offset in pixels.

Definition at line 116 of file viewport.h.

References mPixelViewX.

117  { return mPixelViewX; }
int mPixelViewX
Definition: viewport.h:194

◆ getCameraY() [1/2]

int Viewport::getCameraY ( ) const
inline

Returns camera y offset in pixels.

Definition at line 120 of file viewport.h.

References mPixelViewY.

Referenced by MapDebugTab::logic(), and ParticleEngine::update().

121  { return mPixelViewY; }
int mPixelViewY
Definition: viewport.h:195

◆ getCameraY() [2/2]

int Viewport::getCameraY ( ) const
inline

Returns camera y offset in pixels.

Definition at line 122 of file viewport.h.

References mPixelViewY.

123  { return mPixelViewY; }
int mPixelViewY
Definition: viewport.h:195

◆ getMap() [1/2]

Map* Viewport::getMap ( ) const
inline

◆ getMap() [2/2]

Map* Viewport::getMap ( ) const
inline

Definition at line 136 of file viewport.h.

References mMap, and moveCamera().

137  { return mMap; }
Map * mMap
Definition: viewport.h:182

◆ getMouseTile() [1/2]

void Viewport::getMouseTile ( int &  destX,
int &  destY 
) const

Definition at line 611 of file viewport.cpp.

References mMouseX, and mMouseY.

Referenced by getMouseTile(), setCameraRelativeY(), SkillDialog::useSkill(), and SkillDialog::useSkillDefault().

612 {
613  getMouseTile(mMouseX, mMouseY, destX, destY);
614 }
int mMouseX
Definition: viewport.h:153
void getMouseTile(int &destX, int &destY) const
Definition: viewport.cpp:611
int mMouseY
Definition: viewport.h:154

◆ getMouseTile() [2/2]

void Viewport::getMouseTile ( const int  x,
const int  y,
int &  destX,
int &  destY 
) const
private

Definition at line 616 of file viewport.cpp.

References actorManager, BlockMask::AIR, AllPlayers_true, ActorType::Avatar, beingPopup, MapType::BLACKWHITE, Settings::cameraMode, LocalPlayer::canMove(), CAST_S32, config, cur_time, Cursor::CURSOR_POINTER, Cursor::CURSOR_UP, UpdateStatusListener::distributeEvent(), ActorType::Elemental, MapItemType::EMPTY, ActorManager::findBeingByPixel(), ActorManager::findItem(), ActorType::FloorItem, Being::getActionTime(), Configuration::getBoolValue(), MapItem::getComment(), Map::getHeightOffset(), FloorItem::getHoverCursor(), Being::getHoverCursor(), Configuration::getIntValue(), getMouseTile(), Event::getSource(), Map::getSpecialLayer(), SpecialLayer::getTile(), Map::getTileHeight(), Map::getTileWidth(), Being::getTileX(), Being::getTileY(), MapItem::getType(), Being::getType(), Map::getWalk(), MouseEvent::getX(), MouseEvent::getY(), gui, PopupManager::hideBeingPopup(), PopupManager::hideTextPopup(), ActorType::Homunculus, inputManager, InputManager::isActionActive(), InputGuiEvent::isConsumed(), Map::isHeightsPresent(), Gui::isLongPress(), PopupManager::isTextPopupVisible(), MouseButton::LEFT, leftMouseAction(), localPlayer, mainGraphics, mAllowMoveByMouse, Settings::mapDrawType, mCameraRelativeX, mCameraRelativeY, mEnableLazyScrolling, ActorType::Mercenary, Graphics::mHeight, mHoverBeing, mHoverItem, mHoverSign, mLocalWalkTime, mLongMouseClick, mMap, mMouseClicked, mMouseDirectionMove, mMousePressX, mMousePressY, mMouseX, mMouseY, ActorType::Monster, mouseDragged(), mouseMoved(), mouseReleased(), mPixelViewX, mPixelViewY, mPlayerFollowMouse, mScrollLaziness, mScrollRadius, mSelfMouseHeal, mShowBeingPopup, Graphics::mWidth, LocalPlayer::navigateTo(), MapType::NORMAL, ActorType::Npc, openContextMenu(), optionChanged(), ActorType::Pet, ActorType::Player, BlockMask::PLAYERWALL, ActorType::Portal, Gui::resetClickCount(), Gui::setCursorType(), Map::setDrawLayersFlags(), settings, BeingPopup::show(), TextPopup::show(), ActorType::SkillUnit, InputAction::STOP_ATTACK, textPopup, toggleCameraMode(), toggleMapDrawType(), ActorType::Unknown, LocalPlayer::unSetPickUpTarget(), InputAction::UNTARGET, updateMidVars(), walkByMouse(), BlockMask::WALL, BlockMask::WATER, x, and y.

618 {
619  if (mMap == nullptr)
620  return;
621  const int tw = mMap->getTileWidth();
622  const int th = mMap->getTileHeight();
623  destX = CAST_S32(x + mPixelViewX)
624  / static_cast<float>(tw);
625 
626  if (mMap->isHeightsPresent())
627  {
628  const int th2 = th / 2;
629  const int clickY = y + mPixelViewY - th2;
630  destY = y + mPixelViewY;
631  int newDiffY = 1000000;
632  const int heightTiles = mainGraphics->mHeight / th;
633  const int tileViewY = mPixelViewY / th;
634  for (int f = tileViewY; f < tileViewY + heightTiles; f ++)
635  {
636  if (!mMap->getWalk(destX,
637  f,
642  {
643  continue;
644  }
645 
646  const int offset = mMap->getHeightOffset(
647  destX, f) * th2;
648  const int pixelF = f * th;
649  const int diff = abs(clickY + offset - pixelF);
650  if (diff < newDiffY)
651  {
652  destY = pixelF;
653  newDiffY = diff;
654  }
655  }
656  destY /= 32;
657  }
658  else
659  {
660  destY = CAST_S32((y + mPixelViewY) / static_cast<float>(th));
661  }
662 }
int mPixelViewX
Definition: viewport.h:194
int getTileHeight() const
Definition: map.h:180
bool isHeightsPresent() const
Definition: map.h:351
#define CAST_S32
Definition: cast.h:29
Graphics * mainGraphics
Definition: graphics.cpp:108
int mHeight
Definition: graphics.h:484
uint8_t getHeightOffset(const int x, const int y) const
Definition: map.cpp:1612
bool getWalk(const int x, const int y, const unsigned char blockWalkMask) const
Definition: map.cpp:773
int mPixelViewY
Definition: viewport.h:195
Map * mMap
Definition: viewport.h:182
int getTileWidth() const
Definition: map.h:174

◆ leftMouseAction() [1/2]

bool Viewport::leftMouseAction ( )
private

Definition at line 265 of file viewport.cpp.

Referenced by drawPath(), getMouseTile(), mousePressed(), and mouseReleased().

266 {
267  return false;
268 }

◆ leftMouseAction() [2/2]

bool Viewport::leftMouseAction ( )
private

◆ logic() [1/2]

void Viewport::logic ( )
virtual

Implements player to keep following mouse.

Reimplemented from BasicContainer.

Definition at line 115 of file viewport.cpp.

References BLOCK_END, BLOCK_START, Gui::getMouseState(), mMouseX, and mMouseY.

116 {
117  BLOCK_START("Viewport::logic")
118  // Make the player follow the mouse position
119  // if the mouse is dragged elsewhere than in a window.
120  Gui::getMouseState(mMouseX, mMouseY);
122 }
#define BLOCK_START(name)
Definition: perfomance.h:78
#define BLOCK_END(name)
Definition: perfomance.h:79
int mMouseX
Definition: viewport.h:153
Definition: gui.h:115
int mMouseY
Definition: viewport.h:154
void logic()
Definition: viewport.cpp:115

◆ logic() [2/2]

void Viewport::logic ( )
virtual

Implements player to keep following mouse.

Reimplemented from BasicContainer.

◆ mouseDragged() [1/2]

void Viewport::mouseDragged ( MouseEvent event)
virtual

Handles mouse move on map

Reimplemented from MouseListener.

Definition at line 178 of file viewport.cpp.

References Event::getSource(), MouseEvent::getX(), MouseEvent::getY(), mMouseClicked, mMousePressX, mMousePressY, mPlayerFollowMouse, and walkByMouse().

Referenced by getMouseTile().

179 {
180  if (event.getSource() != this || event.isConsumed())
181  {
182  mPlayerFollowMouse = false;
183  return;
184  }
185  if (mMouseClicked)
186  {
187  if (abs(event.getX() - mMousePressX) > 32
188  || abs(event.getY() - mMousePressY) > 32)
189  {
190  mPlayerFollowMouse = true;
191  }
192  }
193 
194  walkByMouse(event);
195 }
void walkByMouse(const MouseEvent &event)
Definition: viewport.cpp:174
bool mMouseClicked
Definition: viewport.h:207
bool mPlayerFollowMouse
Definition: viewport.h:208
Widget * getSource() const
Definition: event.h:103
int mMousePressY
Definition: viewport.h:193
int getY() const
Definition: mouseevent.h:135
int getX() const
Definition: mouseevent.h:124
int mMousePressX
Definition: viewport.h:192

◆ mouseDragged() [2/2]

void Viewport::mouseDragged ( MouseEvent event)
virtual

Handles mouse move on map

Reimplemented from MouseListener.

◆ mouseMoved() [1/2]

void Viewport::mouseMoved ( MouseEvent event)
virtual

Handles mouse move on map.

Reimplemented from MouseListener.

Definition at line 246 of file viewport.cpp.

Referenced by getMouseTile().

247 {
248 }

◆ mouseMoved() [2/2]

void Viewport::mouseMoved ( MouseEvent event)
virtual

Handles mouse move on map.

Reimplemented from MouseListener.

◆ mousePressed() [1/2]

void Viewport::mousePressed ( MouseEvent event)
virtual

Handles mouse press on map.

Reimplemented from MouseListener.

Definition at line 137 of file viewport.cpp.

References Event::getSource(), PopupManager::hidePopupMenu(), PopupManager::isPopupMenuVisible(), MouseButton::LEFT, leftMouseAction(), mLongMouseClick, mMouseClicked, mMousePressX, mMousePressY, mPlayerFollowMouse, openContextMenu(), and MouseButton::RIGHT.

Referenced by drawPath().

138 {
139  if (event.getSource() != this || event.isConsumed())
140  return;
141 
142  mMouseClicked = true;
143 
144  mMousePressX = event.getX();
145  mMousePressY = event.getY();
146  const MouseButtonT eventButton = event.getButton();
147 
148  // Right click might open a popup
149  if (eventButton == MouseButton::RIGHT)
150  {
151  if (openContextMenu(event))
152  return;
153  }
154 
155  // If a popup is active, just remove it
157  {
158  mPlayerFollowMouse = false;
160  return;
161  }
162 
163  // Left click can cause different actions
164  if (!mLongMouseClick && eventButton == MouseButton::LEFT)
165  {
166  if (leftMouseAction())
167  {
168  mPlayerFollowMouse = false;
169  return;
170  }
171  }
172 }
static void hidePopupMenu()
bool mMouseClicked
Definition: viewport.h:207
bool mPlayerFollowMouse
Definition: viewport.h:208
Widget * getSource() const
Definition: event.h:103
int mMousePressY
Definition: viewport.h:193
bool mLongMouseClick
Definition: viewport.h:206
static bool isPopupMenuVisible()
bool openContextMenu(const MouseEvent &event)
Definition: viewport.cpp:132
bool leftMouseAction()
Definition: viewport.cpp:265
MouseButton ::T MouseButtonT
Definition: mousebutton.h:77
int mMousePressX
Definition: viewport.h:192

◆ mousePressed() [2/2]

void Viewport::mousePressed ( MouseEvent event)
virtual

Handles mouse press on map.

Reimplemented from MouseListener.

◆ mouseReleased() [1/2]

void Viewport::mouseReleased ( MouseEvent event)
virtual

Handles mouse button release on map.

Reimplemented from MouseListener.

Definition at line 197 of file viewport.cpp.

References Event::getSource(), gui, Gui::isLongPress(), MouseButton::LEFT, leftMouseAction(), mLocalWalkTime, mLongMouseClick, mMouseClicked, mPlayerFollowMouse, openContextMenu(), Gui::resetClickCount(), and walkByMouse().

Referenced by getMouseTile().

198 {
199  mPlayerFollowMouse = false;
200  mLocalWalkTime = -1;
202  {
203  mMouseClicked = false;
204  if (event.getSource() != this || event.isConsumed())
205  return;
206  const MouseButtonT eventButton = event.getButton();
207  if (eventButton == MouseButton::LEFT)
208  {
209  // long button press
210  if ((gui != nullptr) && gui->isLongPress())
211  {
212  if (openContextMenu(event))
213  {
214  gui->resetClickCount();
215  return;
216  }
217  }
218  else
219  {
220  if (leftMouseAction())
221  return;
222  }
223  walkByMouse(event);
224  }
225  }
226 }
int mLocalWalkTime
Definition: viewport.h:197
Gui * gui
Definition: gui.cpp:110
void walkByMouse(const MouseEvent &event)
Definition: viewport.cpp:174
bool mMouseClicked
Definition: viewport.h:207
bool isLongPress() const
Definition: gui.h:308
bool mPlayerFollowMouse
Definition: viewport.h:208
Widget * getSource() const
Definition: event.h:103
void resetClickCount()
Definition: gui.cpp:968
bool mLongMouseClick
Definition: viewport.h:206
bool openContextMenu(const MouseEvent &event)
Definition: viewport.cpp:132
bool leftMouseAction()
Definition: viewport.cpp:265
MouseButton ::T MouseButtonT
Definition: mousebutton.h:77

◆ mouseReleased() [2/2]

void Viewport::mouseReleased ( MouseEvent event)
virtual

Handles mouse button release on map.

Reimplemented from MouseListener.

◆ moveCamera() [1/2]

void Viewport::moveCamera ( const int  dx,
const int  dy 
)

Definition at line 1067 of file viewport.cpp.

References mCameraRelativeX, mCameraRelativeY, and updateMidVars().

Referenced by getMap(), and Game::moveInDirection().

1068 {
1069  mCameraRelativeX += dx;
1070  mCameraRelativeY += dy;
1071  updateMidVars();
1072 }
int mCameraRelativeX
Definition: viewport.h:199
int mCameraRelativeY
Definition: viewport.h:200
void updateMidVars()
Definition: viewport.cpp:1126

◆ moveCamera() [2/2]

void Viewport::moveCamera ( const int  dx,
const int  dy 
)

◆ moveCameraRelative()

void Viewport::moveCameraRelative ( const int  x,
const int  y 
)

Definition at line 1100 of file viewport.cpp.

References Settings::cameraMode, mCameraRelativeX, mCameraRelativeY, settings, updateMidVars(), x, and y.

Referenced by Ea::NpcRecv::processNpcCommand(), and setCameraRelativeY().

1101 {
1102  settings.cameraMode = 1;
1103  mCameraRelativeX += x;
1104  mCameraRelativeY += y;
1105  updateMidVars();
1106 }
int mCameraRelativeX
Definition: viewport.h:199
int mCameraRelativeY
Definition: viewport.h:200
Settings settings
Definition: settings.cpp:31
void updateMidVars()
Definition: viewport.cpp:1126
unsigned int cameraMode
Definition: settings.h:142

◆ moveCameraToActor()

void Viewport::moveCameraToActor ( const BeingId  actorId,
const int  x = 0,
const int  y = 0 
)

Definition at line 1074 of file viewport.cpp.

References actorManager, Settings::cameraMode, ActorManager::findBeing(), localPlayer, mCameraRelativeX, mCameraRelativeY, Actor::mPixelX, Actor::mPixelY, settings, updateMidVars(), x, and y.

Referenced by Ea::NpcRecv::processNpcCommand(), and setCameraRelativeY().

1076 {
1077  if ((localPlayer == nullptr) || (actorManager == nullptr))
1078  return;
1079 
1080  const Actor *const actor = actorManager->findBeing(actorId);
1081  if (actor == nullptr)
1082  return;
1083  settings.cameraMode = 1;
1086  updateMidVars();
1087 }
int mCameraRelativeX
Definition: viewport.h:199
int mCameraRelativeY
Definition: viewport.h:200
Settings settings
Definition: settings.cpp:31
int mPixelX
Definition: actor.h:132
LocalPlayer * localPlayer
Being * findBeing(const BeingId id) const
void updateMidVars()
Definition: viewport.cpp:1126
int mPixelY
Definition: actor.h:133
unsigned int cameraMode
Definition: settings.h:142
Definition: actor.h:40
ActorManager * actorManager

◆ moveCameraToPosition()

void Viewport::moveCameraToPosition ( const int  x,
const int  y 
)

Definition at line 1089 of file viewport.cpp.

References Settings::cameraMode, localPlayer, mCameraRelativeX, mCameraRelativeY, Actor::mPixelX, Actor::mPixelY, settings, and updateMidVars().

Referenced by Actions::changeRelation(), Ea::NpcRecv::processNpcCommand(), and setCameraRelativeY().

1090 {
1091  if (localPlayer == nullptr)
1092  return;
1093 
1094  settings.cameraMode = 1;
1097  updateMidVars();
1098 }
int mCameraRelativeX
Definition: viewport.h:199
int mCameraRelativeY
Definition: viewport.h:200
Settings settings
Definition: settings.cpp:31
int mPixelX
Definition: actor.h:132
LocalPlayer * localPlayer
void updateMidVars()
Definition: viewport.cpp:1126
int mPixelY
Definition: actor.h:133
unsigned int cameraMode
Definition: settings.h:142

◆ openContextMenu() [1/2]

bool Viewport::openContextMenu ( const MouseEvent event)
private

Definition at line 132 of file viewport.cpp.

Referenced by drawPath(), getMouseTile(), mousePressed(), and mouseReleased().

133 {
134  return false;
135 }

◆ openContextMenu() [2/2]

bool Viewport::openContextMenu ( const MouseEvent event)
private

◆ optionChanged() [1/2]

void Viewport::optionChanged ( const std::string &  name)
virtual

A relevant config option changed.

Implements ConfigListener.

Definition at line 228 of file viewport.cpp.

References config, Configuration::getBoolValue(), Configuration::getIntValue(), mEnableLazyScrolling, mLongMouseClick, mMouseDirectionMove, mScrollLaziness, mScrollRadius, mSelfMouseHeal, and mShowBeingPopup.

Referenced by getMouseTile().

229 {
230  if (name == "ScrollLaziness")
231  mScrollLaziness = config.getIntValue("ScrollLaziness");
232  else if (name == "ScrollRadius")
233  mScrollRadius = config.getIntValue("ScrollRadius");
234  else if (name == "showBeingPopup")
235  mShowBeingPopup = config.getBoolValue("showBeingPopup");
236  else if (name == "selfMouseHeal")
237  mSelfMouseHeal = config.getBoolValue("selfMouseHeal");
238  else if (name == "enableLazyScrolling")
239  mEnableLazyScrolling = config.getBoolValue("enableLazyScrolling");
240  else if (name == "mouseDirectionMove")
241  mMouseDirectionMove = config.getBoolValue("mouseDirectionMove");
242  else if (name == "longmouseclick")
243  mLongMouseClick = config.getBoolValue("longmouseclick");
244 }
bool mMouseDirectionMove
Definition: viewport.h:205
Configuration config
int getIntValue(const std::string &key) const
int mScrollRadius
Definition: viewport.h:188
bool getBoolValue(const std::string &key) const
bool mShowBeingPopup
Definition: viewport.h:202
bool mSelfMouseHeal
Definition: viewport.h:203
int mScrollLaziness
Definition: viewport.h:189
bool mLongMouseClick
Definition: viewport.h:206
bool mEnableLazyScrolling
Definition: viewport.h:204

◆ optionChanged() [2/2]

void Viewport::optionChanged ( const std::string &  name)
virtual

A relevant config option changed.

Implements ConfigListener.

◆ returnCamera()

void Viewport::returnCamera ( )

◆ safeDraw() [1/2]

void Viewport::safeDraw ( Graphics *const  graphics)
virtual

Reimplemented from BasicContainer2.

Definition at line 110 of file viewport.cpp.

References draw().

111 {
112  Viewport::draw(graphics);
113 }
void draw(Graphics *const graphics)
Definition: viewport.cpp:92

◆ safeDraw() [2/2]

void Viewport::safeDraw ( Graphics *const  graphics)
virtual

Reimplemented from BasicContainer2.

◆ scrollBy() [1/2]

void Viewport::scrollBy ( const int  x,
const int  y 
)
inline

Changes viewpoint by relative pixel coordinates.

Definition at line 126 of file viewport.h.

References cleanHoverItems(), mPixelViewX, mPixelViewY, x, and y.

Referenced by Ea::PlayerRecv::processPlayerWarp().

127  { mPixelViewX += x; mPixelViewY += y; }
int mPixelViewX
Definition: viewport.h:194
int mPixelViewY
Definition: viewport.h:195

◆ scrollBy() [2/2]

void Viewport::scrollBy ( const int  x,
const int  y 
)
inline

Changes viewpoint by relative pixel coordinates.

Definition at line 128 of file viewport.h.

References cleanHoverItems(), mPixelViewX, mPixelViewY, x, and y.

129  { mPixelViewX += x; mPixelViewY += y; }
int mPixelViewX
Definition: viewport.h:194
int mPixelViewY
Definition: viewport.h:195

◆ setCameraRelativeX() [1/2]

void Viewport::setCameraRelativeX ( const int  n)
inline

Definition at line 145 of file viewport.h.

References mCameraRelativeX.

Referenced by NpcDialog::restoreCamera().

146  { mCameraRelativeX = n; }
int mCameraRelativeX
Definition: viewport.h:199

◆ setCameraRelativeX() [2/2]

void Viewport::setCameraRelativeX ( const int  n)
inline

Definition at line 147 of file viewport.h.

References mCameraRelativeX, and updateMidVars().

148  { mCameraRelativeX = n; updateMidVars(); }
int mCameraRelativeX
Definition: viewport.h:199
void updateMidVars()
Definition: viewport.cpp:1126

◆ setCameraRelativeY() [1/2]

void Viewport::setCameraRelativeY ( const int  n)
inline

Definition at line 148 of file viewport.h.

References mCameraRelativeY, and videoResized().

Referenced by NpcDialog::restoreCamera().

149  { mCameraRelativeY = n; }
int mCameraRelativeY
Definition: viewport.h:200

◆ setCameraRelativeY() [2/2]

void Viewport::setCameraRelativeY ( const int  n)
inline

◆ setMap() [1/2]

void Viewport::setMap ( Map *const  map)

Sets the map displayed by the viewport.

Definition at line 88 of file viewport.cpp.

Referenced by Game::changeMap().

89 {
90 }

◆ setMap() [2/2]

void Viewport::setMap ( Map *const  map)

Sets the map displayed by the viewport.

◆ toggleCameraMode() [1/2]

void Viewport::toggleCameraMode ( )

◆ toggleCameraMode() [2/2]

void Viewport::toggleCameraMode ( )

◆ toggleMapDrawType() [1/2]

void Viewport::toggleMapDrawType ( )

Toggles whether the path debug graphics are shown. normal, debug with all images and grid, debug with out big images and with out grid.

Definition at line 250 of file viewport.cpp.

Referenced by GameModifiers::changeMapDrawType(), and getMouseTile().

251 {
252 }

◆ toggleMapDrawType() [2/2]

void Viewport::toggleMapDrawType ( )

Toggles whether the path debug graphics are shown. normal, debug with all images and grid, debug with out big images and with out grid.

◆ updateMaxVars()

void Viewport::updateMaxVars ( )
protected

Definition at line 1134 of file viewport.cpp.

References Map::getHeight(), Map::getTileHeight(), Map::getTileWidth(), Map::getWidth(), mainGraphics, Graphics::mHeight, mMap, mViewXmax, mViewYmax, Graphics::mWidth, updateMidVars(), and videoResized().

1135 {
1136  if (mMap == nullptr)
1137  return;
1139  - mainGraphics->mWidth;
1141  - mainGraphics->mHeight;
1142 }
int mViewXmax
Definition: viewport.h:229
int getTileHeight() const
Definition: map.h:180
int mWidth
Definition: graphics.h:483
int getHeight() const
Definition: map.h:168
int mViewYmax
Definition: viewport.h:230
Graphics * mainGraphics
Definition: graphics.cpp:108
int mHeight
Definition: graphics.h:484
int getWidth() const
Definition: map.h:162
Map * mMap
Definition: viewport.h:182
int getTileWidth() const
Definition: map.h:174

◆ updateMidVars()

void Viewport::updateMidVars ( )
protected

◆ validateSpeed()

void Viewport::validateSpeed ( )
staticprotected

Definition at line 1116 of file viewport.cpp.

References InputAction::ATTACK, inputManager, Game::instance(), InputManager::isActionActive(), Game::setValidSpeed(), and InputAction::TARGET_ATTACK.

Referenced by drawPath().

1117 {
1120  {
1121  if (Game::instance() != nullptr)
1123  }
1124 }
void setValidSpeed()
Definition: game.cpp:1238
bool isActionActive(const InputActionT index) const
static Game * instance()
Definition: game.h:81
InputManager inputManager

◆ videoResized() [1/2]

void Viewport::videoResized ( )

Definition at line 270 of file viewport.cpp.

Referenced by setCameraRelativeY(), updateMaxVars(), and Gui::videoResized().

271 {
272 }

◆ videoResized() [2/2]

void Viewport::videoResized ( )

◆ walkByMouse() [1/2]

void Viewport::walkByMouse ( const MouseEvent event)
private

Definition at line 174 of file viewport.cpp.

Referenced by getMouseTile(), mouseDragged(), and mouseReleased().

175 {
176 }

◆ walkByMouse() [2/2]

void Viewport::walkByMouse ( const MouseEvent event)
private

Friends And Related Function Documentation

◆ ActorManager

friend class ActorManager
friend

Definition at line 171 of file viewport.h.

Field Documentation

◆ mAllowMoveByMouse

bool Viewport::mAllowMoveByMouse
private

Definition at line 242 of file viewport.h.

Referenced by drawPath(), and getMouseTile().

◆ mCameraRelativeX

int Viewport::mCameraRelativeX
private

◆ mCameraRelativeY

int Viewport::mCameraRelativeY
private

◆ mEnableLazyScrolling

bool Viewport::mEnableLazyScrolling
private

Definition at line 204 of file viewport.h.

Referenced by getMouseTile(), and optionChanged().

◆ mHoverBeing

Being * Viewport::mHoverBeing
private

Being mouse is currently over.

Definition at line 184 of file viewport.h.

Referenced by cleanHoverItems(), clearHover(), drawPath(), and getMouseTile().

◆ mHoverItem

FloorItem * Viewport::mHoverItem
private

FloorItem mouse is currently over.

Definition at line 185 of file viewport.h.

Referenced by cleanHoverItems(), clearHover(), drawPath(), and getMouseTile().

◆ mHoverSign

MapItem * Viewport::mHoverSign
private

Map sign mouse is currently over.

Definition at line 186 of file viewport.h.

Referenced by cleanHoverItems(), clearHover(), drawPath(), and getMouseTile().

◆ mLocalWalkTime [1/2]

int Viewport::mLocalWalkTime
private

Timestamp before the next walk can be sent.

Definition at line 197 of file viewport.h.

Referenced by getMouseTile(), and mouseReleased().

◆ mLocalWalkTime [2/2]

time_t Viewport::mLocalWalkTime
private

Definition at line 232 of file viewport.h.

◆ mLongMouseClick

bool Viewport::mLongMouseClick
private

Definition at line 206 of file viewport.h.

Referenced by drawPath(), getMouseTile(), mousePressed(), mouseReleased(), and optionChanged().

◆ mMap

Map * Viewport::mMap
private

The current map.

Definition at line 182 of file viewport.h.

Referenced by drawPath(), getMap(), getMouseTile(), and updateMaxVars().

◆ mMidTileX

int Viewport::mMidTileX
private

Definition at line 227 of file viewport.h.

Referenced by updateMidVars().

◆ mMidTileY

int Viewport::mMidTileY
private

Definition at line 228 of file viewport.h.

Referenced by updateMidVars().

◆ mMouseClicked

bool Viewport::mMouseClicked
private

Definition at line 207 of file viewport.h.

Referenced by drawPath(), getMouseTile(), mouseDragged(), mousePressed(), and mouseReleased().

◆ mMouseDirectionMove

bool Viewport::mMouseDirectionMove
private

Definition at line 205 of file viewport.h.

Referenced by getMouseTile(), and optionChanged().

◆ mMousePressX

int Viewport::mMousePressX
private

Definition at line 192 of file viewport.h.

Referenced by drawPath(), getMouseTile(), mouseDragged(), and mousePressed().

◆ mMousePressY

int Viewport::mMousePressY
private

Definition at line 193 of file viewport.h.

Referenced by drawPath(), getMouseTile(), mouseDragged(), and mousePressed().

◆ mMouseX

int Viewport::mMouseX

◆ mMouseY

int Viewport::mMouseY

◆ mPixelViewX

int Viewport::mPixelViewX
private

Current viewpoint in pixels.

Definition at line 194 of file viewport.h.

Referenced by drawPath(), getCameraX(), getMouseTile(), and scrollBy().

◆ mPixelViewY

int Viewport::mPixelViewY
private

Current viewpoint in pixels.

Definition at line 195 of file viewport.h.

Referenced by drawPath(), getCameraY(), getMouseTile(), and scrollBy().

◆ mPlayerFollowMouse

bool Viewport::mPlayerFollowMouse
private

Definition at line 208 of file viewport.h.

Referenced by drawPath(), getMouseTile(), mouseDragged(), mousePressed(), and mouseReleased().

◆ mScrollCenterOffsetX

int Viewport::mScrollCenterOffsetX
private

Definition at line 190 of file viewport.h.

Referenced by updateMidVars().

◆ mScrollCenterOffsetY

int Viewport::mScrollCenterOffsetY
private

Definition at line 191 of file viewport.h.

Referenced by updateMidVars().

◆ mScrollLaziness

int Viewport::mScrollLaziness
private

Definition at line 189 of file viewport.h.

Referenced by getMouseTile(), and optionChanged().

◆ mScrollRadius

int Viewport::mScrollRadius
private

Definition at line 188 of file viewport.h.

Referenced by getMouseTile(), and optionChanged().

◆ mSelfMouseHeal

bool Viewport::mSelfMouseHeal
private

Definition at line 203 of file viewport.h.

Referenced by drawPath(), getMouseTile(), and optionChanged().

◆ mShowBeingPopup

bool Viewport::mShowBeingPopup
private

Definition at line 202 of file viewport.h.

Referenced by getMouseTile(), and optionChanged().

◆ mViewXmax

int Viewport::mViewXmax
private

Definition at line 229 of file viewport.h.

Referenced by updateMaxVars().

◆ mViewYmax

int Viewport::mViewYmax
private

Definition at line 230 of file viewport.h.

Referenced by updateMaxVars().


The documentation for this class was generated from the following files: