Viewport Class Reference

#include <viewport.h>

Inheritance diagram for Viewport:

WindowContainer ConfigListener Container

List of all members.


Detailed Description

The viewport on the map.

Displays the current map and handles mouse input and the popup menu.

TODO: This class is planned to be extended to allow floating widgets on top of it such as NPC messages, which are positioned using map pixel coordinates.

Definition at line 51 of file viewport.h.


Public Member Functions

 Viewport ()
 Constructor.
 ~Viewport ()
 Destructor.
void setMap (Map *map)
 Sets the map displayed by the viewport.
void draw (gcn::Graphics *graphics)
 Draws the viewport.
void logic ()
 Implements player to keep following mouse.
void toggleDebugPath ()
 Toggles whether the path debug graphics are shown.
void mousePressed (gcn::MouseEvent &event)
 Handles mouse press on map.
void mouseDragged (gcn::MouseEvent &event)
 Handles mouse move on map.
void mouseReleased (gcn::MouseEvent &event)
 Handles mouse button release on map.
void mouseMoved (gcn::MouseEvent &event)
 Handles mouse move on map.
void showPopup (int x, int y, Item *item)
 Shows a popup for an item.
void closePopupMenu ()
 Closes the popup menu.
void optionChanged (const std::string &name)
 A relevant config option changed.
int getCameraX () const
 Returns camera x offset in pixels.
int getCameraY () const
 Returns camera y offset in pixels.
int getMouseX () const
 Returns mouse x in pixels.
int getMouseY () const
 Returns mouse y in pixels.
void scrollBy (float x, float y)
 Changes viewpoint by relative pixel coordinates.

Private Member Functions

void drawDebugPath (Graphics *graphics)
 Finds a path from the player to the mouse, and draws it.
void drawPath (Graphics *graphics, const Path &path)
 Draws the given path.

Private Attributes

MapmMap
 The current map.
int mScrollRadius
int mScrollLaziness
int mScrollCenterOffsetX
int mScrollCenterOffsetY
int mMouseX
 Current mouse position in pixels.
int mMouseY
 Current mouse position in pixels.
float mPixelViewX
 Current viewpoint in pixels.
float mPixelViewY
 Current viewpoint in pixels.
int mTileViewX
 Current viewpoint in tiles.
int mTileViewY
 Current viewpoint in tiles.
bool mShowDebugPath
 Show a path from player to pointer.
bool mVisibleNames
 Show target names.
bool mPlayerFollowMouse
int mWalkTime
PopupMenumPopupMenu
 Popup menu.
BeingmSelectedBeing
 Current selected being.

Constructor & Destructor Documentation

Viewport::Viewport (  ) 

Constructor.

Definition at line 45 of file viewport.cpp.

Viewport::~Viewport (  ) 

Destructor.

Definition at line 78 of file viewport.cpp.


Member Function Documentation

void Viewport::setMap ( Map map  ) 

Sets the map displayed by the viewport.

Definition at line 85 of file viewport.cpp.

void Viewport::draw ( gcn::Graphics *  graphics  ) 

Draws the viewport.

Definition at line 92 of file viewport.cpp.

void Viewport::logic (  ) 

Implements player to keep following mouse.

Reimplemented from WindowContainer.

Definition at line 232 of file viewport.cpp.

void Viewport::toggleDebugPath (  )  [inline]

Toggles whether the path debug graphics are shown.

Definition at line 83 of file viewport.h.

void Viewport::mousePressed ( gcn::MouseEvent &  event  ) 

Handles mouse press on map.

Definition at line 290 of file viewport.cpp.

void Viewport::mouseDragged ( gcn::MouseEvent &  event  ) 

Handles mouse move on map.

Definition at line 416 of file viewport.cpp.

void Viewport::mouseReleased ( gcn::MouseEvent &  event  ) 

Handles mouse button release on map.

Definition at line 439 of file viewport.cpp.

void Viewport::mouseMoved ( gcn::MouseEvent &  event  ) 

Handles mouse move on map.

Definition at line 464 of file viewport.cpp.

void Viewport::showPopup ( int  x,
int  y,
Item item 
)

Shows a popup for an item.

TODO Find some way to get rid of Item here

Definition at line 444 of file viewport.cpp.

void Viewport::closePopupMenu (  ) 

Closes the popup menu.

Needed for when the player dies or switching maps.

Definition at line 449 of file viewport.cpp.

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

A relevant config option changed.

Implements ConfigListener.

Definition at line 454 of file viewport.cpp.

int Viewport::getCameraX (  )  const [inline]

Returns camera x offset in pixels.

Definition at line 125 of file viewport.h.

int Viewport::getCameraY (  )  const [inline]

Returns camera y offset in pixels.

Definition at line 130 of file viewport.h.

int Viewport::getMouseX (  )  const [inline]

Returns mouse x in pixels.

Definition at line 135 of file viewport.h.

int Viewport::getMouseY (  )  const [inline]

Returns mouse y in pixels.

Definition at line 140 of file viewport.h.

void Viewport::scrollBy ( float  x,
float  y 
) [inline]

Changes viewpoint by relative pixel coordinates.

Definition at line 145 of file viewport.h.

void Viewport::drawDebugPath ( Graphics graphics  )  [private]

Finds a path from the player to the mouse, and draws it.

This is for debug purposes.

Definition at line 258 of file viewport.cpp.

void Viewport::drawPath ( Graphics graphics,
const Path path 
) [private]

Draws the given path.

Definition at line 275 of file viewport.cpp.


Member Data Documentation

Map* Viewport::mMap [private]

The current map.

Definition at line 159 of file viewport.h.

int Viewport::mScrollRadius [private]

Definition at line 161 of file viewport.h.

Definition at line 162 of file viewport.h.

Definition at line 163 of file viewport.h.

Definition at line 164 of file viewport.h.

int Viewport::mMouseX [private]

Current mouse position in pixels.

Definition at line 165 of file viewport.h.

int Viewport::mMouseY [private]

Current mouse position in pixels.

Definition at line 166 of file viewport.h.

float Viewport::mPixelViewX [private]

Current viewpoint in pixels.

Definition at line 167 of file viewport.h.

float Viewport::mPixelViewY [private]

Current viewpoint in pixels.

Definition at line 168 of file viewport.h.

int Viewport::mTileViewX [private]

Current viewpoint in tiles.

Definition at line 169 of file viewport.h.

int Viewport::mTileViewY [private]

Current viewpoint in tiles.

Definition at line 170 of file viewport.h.

bool Viewport::mShowDebugPath [private]

Show a path from player to pointer.

Definition at line 171 of file viewport.h.

bool Viewport::mVisibleNames [private]

Show target names.

Definition at line 172 of file viewport.h.

Definition at line 174 of file viewport.h.

int Viewport::mWalkTime [private]

Definition at line 178 of file viewport.h.

Popup menu.

Definition at line 181 of file viewport.h.

Current selected being.

Definition at line 182 of file viewport.h.


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

Generated on Sun Apr 26 17:30:44 2009 for The Mana World by  doxygen 1.5.5