Mana
|
The viewport on the map. More...
#include <viewport.h>
Classes | |
struct | ShakeEffect |
Public Member Functions | |
Viewport () | |
~Viewport () override | |
void | setMap (Map *map) |
Sets the map displayed by the viewport. | |
void | draw (gcn::Graphics *graphics) override |
Draws the viewport. | |
void | logic () override |
Implements player to keep following mouse. | |
void | setDebugFlags (int debugFlags) |
Sets which debug flags (see Map::DebugFlags) should be enabled. | |
void | mousePressed (gcn::MouseEvent &event) override |
Handles mouse press on map. | |
void | mouseDragged (gcn::MouseEvent &event) override |
Handles mouse move on map. | |
void | mouseReleased (gcn::MouseEvent &event) override |
Handles mouse button release on map. | |
void | mouseMoved (gcn::MouseEvent &event) override |
Handles mouse move on map. | |
void | showPopup (Window *parent, int x, int y, Item *item, bool isInventory=true, bool canDrop=true) |
Shows a popup for an item. | |
void | closePopupMenu () |
Closes the popup menu. | |
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. | |
Map * | getCurrentMap () const |
Returns the current map object. | |
void | hideBeingPopup () |
Hides the BeingPopup. | |
void | shakeScreen (int intensity) |
Makes the screen shake in a random direction. | |
void | shakeScreen (float x, float y, float decay=0.95f, unsigned duration=0) |
Makes the screen shake in a specific direction. | |
void | shakeScreenStop () |
Stops all active screen shake effects. | |
void | event (Event::Channel channel, const Event &event) override |
![]() | |
void | logic () override |
Do GUI logic. | |
void | draw (gcn::Graphics *graphics) override |
Adds debug drawing. | |
void | scheduleDelete (gcn::Widget *widget) |
Schedule a widget for deletion. | |
void | adjustAfterResize (int oldScreenWidth, int oldScreenHeight) |
Ensures that all visible windows are on the screen after the screen has been resized. | |
![]() | |
Container () | |
~Container () override | |
void | drawFrame (gcn::Graphics *graphics) override |
![]() | |
virtual | ~EventListener () |
void | listen (Event::Channel channel) |
void | ignore (Event::Channel channel) |
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, gcn::Color color=gcn::Color(255, 0, 0)) |
Draws the given path. | |
void | _followMouse () |
Make the player go to the mouse position. | |
void | updateCursorType () |
Updates the cursor type. | |
Private Attributes | |
Map * | mMap = nullptr |
The current map. | |
int | mMouseX = 0 |
Current mouse position in pixels. | |
int | mMouseY = 0 |
Current mouse position in pixels. | |
float | mPixelViewX = 0.0f |
Current viewpoint in pixels. | |
float | mPixelViewY = 0.0f |
Current viewpoint in pixels. | |
int | mDebugFlags = 0 |
Flags for showing debug graphics. | |
std::list< ShakeEffect > | mShakeEffects |
bool | mPlayerFollowMouse = false |
Timer | mLocalWalkTimer |
Timer for sending walk messages. | |
PopupMenu * | mPopupMenu |
Popup menu. | |
Being * | mHoverBeing = nullptr |
Being mouse is currently over. | |
FloorItem * | mHoverItem = nullptr |
FloorItem mouse is currently over. | |
BeingPopup * | mBeingPopup |
Being information popup. | |
Additional Inherited Members | |
![]() | |
Layout & | getLayout () |
Gets the layout handler for this container. | |
LayoutCell & | place (int x, int y, gcn::Widget *wg, int w=1, int h=1) |
Adds a widget to the container and sets it at given cell. | |
ContainerPlacer | getPlacer (int x, int y) |
Returns a proxy for adding widgets in an inner table of the layout. | |
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 57 of file viewport.h.
Viewport::Viewport | ( | ) |
Definition at line 46 of file viewport.cpp.
|
override |
Definition at line 60 of file viewport.cpp.
|
private |
Finds a path from the player to the mouse, and draws it.
This is for debug purposes.
Definition at line 300 of file viewport.cpp.
|
private |
Draws the given path.
Definition at line 392 of file viewport.cpp.
|
private |
Make the player go to the mouse position.
Definition at line 271 of file viewport.cpp.
void Viewport::closePopupMenu | ( | ) |
Closes the popup menu.
Needed for when the player dies or switching maps.
Definition at line 544 of file viewport.cpp.
|
override |
Draws the viewport.
Definition at line 75 of file viewport.cpp.
|
overridevirtual |
Implements EventListener.
Definition at line 605 of file viewport.cpp.
|
inline |
Returns camera x offset in pixels.
Definition at line 121 of file viewport.h.
|
inline |
Returns camera y offset in pixels.
Definition at line 126 of file viewport.h.
|
inline |
Returns the current map object.
Definition at line 146 of file viewport.h.
|
inline |
Returns mouse x in pixels.
Definition at line 131 of file viewport.h.
|
inline |
Returns mouse y in pixels.
Definition at line 136 of file viewport.h.
void Viewport::hideBeingPopup | ( | ) |
Hides the BeingPopup.
Definition at line 600 of file viewport.cpp.
|
override |
Implements player to keep following mouse.
Definition at line 262 of file viewport.cpp.
|
override |
Handles mouse move on map.
Definition at line 516 of file viewport.cpp.
|
override |
Handles mouse move on map.
Definition at line 549 of file viewport.cpp.
|
override |
Handles mouse press on map.
Definition at line 411 of file viewport.cpp.
|
override |
Handles mouse button release on map.
Definition at line 533 of file viewport.cpp.
|
inline |
Changes viewpoint by relative pixel coordinates.
Definition at line 141 of file viewport.h.
void Viewport::setDebugFlags | ( | int | debugFlags | ) |
Sets which debug flags (see Map::DebugFlags) should be enabled.
Definition at line 593 of file viewport.cpp.
void Viewport::setMap | ( | Map * | map | ) |
Sets the map displayed by the viewport.
Definition at line 66 of file viewport.cpp.
void Viewport::shakeScreen | ( | float | x, |
float | y, | ||
float | decay = 0.95f , |
||
unsigned | duration = 0 |
||
) |
Makes the screen shake in a specific direction.
Definition at line 251 of file viewport.cpp.
void Viewport::shakeScreen | ( | int | intensity | ) |
Makes the screen shake in a random direction.
Definition at line 243 of file viewport.cpp.
|
inline |
Stops all active screen shake effects.
Definition at line 166 of file viewport.h.
void Viewport::showPopup | ( | Window * | parent, |
int | x, | ||
int | y, | ||
Item * | item, | ||
bool | isInventory = true , |
||
bool | canDrop = true |
||
) |
Shows a popup for an item.
TODO Find some way to get rid of Item here
Definition at line 538 of file viewport.cpp.
|
private |
Updates the cursor type.
Definition at line 567 of file viewport.cpp.
|
private |
Being information popup.
Definition at line 219 of file viewport.h.
|
private |
Flags for showing debug graphics.
Definition at line 200 of file viewport.h.
|
private |
Being mouse is currently over.
Definition at line 217 of file viewport.h.
|
private |
FloorItem mouse is currently over.
Definition at line 218 of file viewport.h.
|
private |
Timer for sending walk messages.
Definition at line 214 of file viewport.h.
|
private |
The current map.
Definition at line 194 of file viewport.h.
|
private |
Current mouse position in pixels.
Definition at line 196 of file viewport.h.
|
private |
Current mouse position in pixels.
Definition at line 197 of file viewport.h.
|
private |
Current viewpoint in pixels.
Definition at line 198 of file viewport.h.
|
private |
Current viewpoint in pixels.
Definition at line 199 of file viewport.h.
|
private |
Definition at line 212 of file viewport.h.
|
private |
Popup menu.
Definition at line 216 of file viewport.h.
|
private |
Definition at line 210 of file viewport.h.