Mana
Loading...
Searching...
No Matches
viewport.cpp
Go to the documentation of this file.
1/*
2 * The Mana Client
3 * Copyright (C) 2004-2009 The Mana World Development Team
4 * Copyright (C) 2009-2012 The Mana Developers
5 *
6 * This file is part of The Mana Client.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#include "gui/viewport.h"
23
24#include "actorspritemanager.h"
25#include "client.h"
26#include "configuration.h"
27#include "graphics.h"
28#include "keyboardconfig.h"
29#include "localplayer.h"
30#include "map.h"
31#include "playerinfo.h"
32#include "textmanager.h"
33
34#include "gui/gui.h"
35#include "gui/popupmenu.h"
36#include "gui/beingpopup.h"
37
38#include "net/net.h"
39#include "net/playerhandler.h"
40
41#include "utils/stringutils.h"
42
43#include <algorithm>
44#include <cmath>
45
47{
48 setOpaque(false);
49 addMouseListener(this);
50
53
54 setFocusable(true);
55
58}
59
61{
62 delete mPopupMenu;
63 delete mBeingPopup;
64}
65
67{
68 if (mMap && map)
69 {
71 }
72 mMap = map;
73}
74
75void Viewport::draw(gcn::Graphics *gcnGraphics)
76{
77 // Check whether map was successfully loaded since
78 // the rest of this function relies on it
79 if (!mMap || !local_player)
80 {
81 // Render unicolor background to avoid
82 // rendering issues
83 gcnGraphics->setColor(gcn::Color(64, 64, 64));
84 gcnGraphics->fillRectangle(
85 gcn::Rectangle(0, 0, getWidth(), getHeight()));
86 return;
87 }
88
89 auto *graphics = static_cast<Graphics*>(gcnGraphics);
90
91 // Calculate viewpoint
92 int midTileX = (graphics->getWidth() + config.scrollCenterOffsetX) / 2;
93 int midTileY = (graphics->getHeight() + config.scrollCenterOffsetY) / 2;
94
95 const Vector &playerPos = local_player->getPosition();
96 const int player_x = (int) playerPos.x - midTileX;
97 const int player_y = (int) playerPos.y - midTileY;
98
99 const float ticks = Time::deltaTimeMs() / static_cast<float>(MILLISECONDS_IN_A_TICK);
100 float scrollFraction = 1.0f;
101
102 if (config.scrollLaziness > 1)
103 {
104 // settings.ScrollLaziness defines the fraction of the desired camera movement
105 // that is applied every 10ms. To make this work independently of the
106 // frame duration, we calculate the actual scroll fraction based on the
107 // time delta.
108 scrollFraction = 1.0f - std::pow(1.0f - 1.0f / config.scrollLaziness, ticks);
109 }
110
111 // Apply lazy scrolling
112 if (player_x > mPixelViewX + config.scrollRadius)
113 {
114 mPixelViewX += (player_x - mPixelViewX - config.scrollRadius) *
115 scrollFraction;
116 }
117 if (player_x < mPixelViewX - config.scrollRadius)
118 {
119 mPixelViewX += (player_x - mPixelViewX + config.scrollRadius) *
120 scrollFraction;
121 }
122 if (player_y > mPixelViewY + config.scrollRadius)
123 {
124 mPixelViewY += (player_y - mPixelViewY - config.scrollRadius) *
125 scrollFraction;
126 }
127 if (player_y < mPixelViewY - config.scrollRadius)
128 {
129 mPixelViewY += (player_y - mPixelViewY + config.scrollRadius) *
130 scrollFraction;
131 }
132
133 // Auto center when player is off screen
134 if ( player_x - mPixelViewX > graphics->getWidth() / 2
135 || mPixelViewX - player_x > graphics->getWidth() / 2
136 || mPixelViewY - player_y > graphics->getHeight() / 2
137 || player_y - mPixelViewY > graphics->getHeight() / 2
138 )
139 {
140 mPixelViewX = player_x;
141 mPixelViewY = player_y;
142 };
143
144 // Don't move camera so that the end of the map is on screen
145 // Center camera on map if the map is smaller than the screen
146 const int mapWidthPixels = mMap->getWidth() * mMap->getTileWidth();
147 const int mapHeightPixels = mMap->getHeight() * mMap->getTileHeight();
148 const int viewXmax = mapWidthPixels - graphics->getWidth();
149 const int viewYmax = mapHeightPixels - graphics->getHeight();
150
151 if (viewXmax > 0)
152 mPixelViewX = std::clamp<float>(mPixelViewX, 0, viewXmax);
153 else
154 mPixelViewX = viewXmax / 2;
155
156 if (viewYmax > 0)
157 mPixelViewY = std::clamp<float>(mPixelViewY, 0, viewYmax);
158 else
159 mPixelViewY = viewYmax / 2;
160
161 // Draw black background if map is smaller than the screen
162 if ( mapWidthPixels < graphics->getWidth()
163 || mapHeightPixels < graphics->getHeight())
164 {
165 gcnGraphics->setColor(gcn::Color(0, 0, 0));
166 gcnGraphics->fillRectangle(
167 gcn::Rectangle(0, 0, getWidth(), getHeight()));
168
169 }
170
171 int scrollX = static_cast<int>(mPixelViewX);
172 int scrollY = static_cast<int>(mPixelViewY);
173
174 // manage shake effect
175 for (auto i = mShakeEffects.begin(); i != mShakeEffects.end(); )
176 {
177 ShakeEffect &effect = *i;
178 effect.age += ticks;
179
180 // The decay defines the reduction in amplitude per 10ms. Here
181 // we calculate the strength left over based on the age in ticks.
182 const float strength = std::pow(effect.decay, effect.age);
183 const float phase = std::sin(effect.age);
184
185 // apply the effect to viewport
186 scrollX += strength * phase * effect.x;
187 scrollY += strength * phase * effect.y;
188
189 // check death conditions
190 if (strength < 0.01f || (effect.timer.isSet() && effect.timer.passed()))
191 i = mShakeEffects.erase(i);
192 else
193 ++i;
194 }
195
196 // Draw tiles and sprites
197 mMap->draw(graphics, scrollX, scrollY);
198
199 if (mDebugFlags)
200 {
202 mMap->drawCollision(graphics, scrollX, scrollY, mDebugFlags);
203
205 }
206
207 // Draw text
208 if (textManager)
209 textManager->draw(graphics, scrollX, scrollY);
210
211 // Draw player names, speech, and emotion sprite as needed
212 for (auto actor : actorSpriteManager->getAll())
213 {
214 if (actor->getType() == ActorSprite::FLOOR_ITEM)
215 continue;
216
217 auto *being = static_cast<Being*>(actor);
218 being->drawSpeech(scrollX, scrollY);
219 }
220
222 {
223 graphics->setColor(gcn::Color(255, 0, 255, 255));
224 for (auto actor : actorSpriteManager->getAll())
225 {
226 auto *being = dynamic_cast<Being*>(actor);
227 if (!being)
228 continue;
229
230 const Vector &beingPos = being->getPosition();
231 std::string idString = toString(being->getId());
232 graphics->drawText(idString,
233 beingPos.x - scrollX,
234 beingPos.y - scrollY,
235 gcn::Graphics::CENTER);
236 }
237 }
238
239 // Draw contained widgets
240 WindowContainer::draw(gcnGraphics);
241}
242
243void Viewport::shakeScreen(int intensity)
244{
245 float direction = rand()%628 / 100.0f; // random value between 0 and 2PI
246 float x = std::sin(direction) * intensity;
247 float y = std::cos(direction) * intensity;
248 shakeScreen(x, y);
249}
250
251void Viewport::shakeScreen(float x, float y, float decay, unsigned duration)
252{
253 ShakeEffect &effect = mShakeEffects.emplace_back();
254 effect.x = x;
255 effect.y = y;
256 effect.decay = decay;
257
258 if (duration > 0)
259 effect.timer.set(duration * MILLISECONDS_IN_A_TICK);
260}
261
263{
265
266 // Make the player follow the mouse position
267 // if the mouse is dragged elsewhere than in a window.
268 _followMouse();
269}
270
272{
273 const Uint8 button = SDL_GetMouseState(&mMouseX, &mMouseY);
274 float logicalX;
275 float logicalY;
276 graphics->windowToLogical(mMouseX, mMouseY, logicalX, logicalY);
277 mMouseX = static_cast<int>(logicalX);
278 mMouseY = static_cast<int>(logicalY);
279
280 // If the left button is dragged
281 if (mPlayerFollowMouse && button & SDL_BUTTON_LMASK)
282 {
283 // We create a mouse event and send it to mouseDragged.
284 const Uint8 *keys = SDL_GetKeyboardState(nullptr);
285 gcn::MouseEvent mouseEvent(nullptr,
286 (keys[SDL_SCANCODE_LSHIFT] || keys[SDL_SCANCODE_RSHIFT]),
287 false,
288 false,
289 false,
290 gcn::MouseEvent::DRAGGED,
291 gcn::MouseEvent::LEFT,
292 mMouseX,
293 mMouseY,
294 0);
295
296 mouseDragged(mouseEvent);
297 }
298}
299
301{
303 {
304 // Prepare the walkmask corresponding to the protocol
305 unsigned char walkMask;
306 switch (Net::getNetworkType())
307 {
310 break;
312 default:
313 walkMask = Map::BLOCKMASK_WALL;
314 break;
315 }
316
317 static Path debugPath;
318 static Vector lastMouseDestination = Vector(0.0f, 0.0f);
319 Vector mouseDestination(mMouseX + (int) mPixelViewX,
320 mMouseY + (int) mPixelViewY);
321
322 if (mouseDestination.x != lastMouseDestination.x
323 || mouseDestination.y != lastMouseDestination.y)
324 {
325 const Vector &playerPos = local_player->getPosition();
326
327 // Adapt the path finding to the precision requested
328 if (Net::getPlayerHandler()->usePixelPrecision())
329 {
330 debugPath = mMap->findPixelPath((int) playerPos.x,
331 (int) playerPos.y,
332 mouseDestination.x,
333 mouseDestination.y,
335 walkMask);
336 }
337 else
338 {
339 debugPath = mMap->findTilePath((int) playerPos.x,
340 (int) playerPos.y,
341 mouseDestination.x,
342 mouseDestination.y,
343 walkMask);
344 }
345
346 lastMouseDestination = mouseDestination;
347 }
348
349 _drawPath(graphics, debugPath, gcn::Color(128, 0, 128, 150));
350 }
351
352 // Draw the path debug information for every beings.
353 for (auto actor : actorSpriteManager->getAll())
354 {
355 auto *being = dynamic_cast<Being*>(actor);
356 if (!being)
357 continue;
358
359 const Vector &beingPos = being->getPosition();
360 graphics->setColor(gcn::Color(128, 128, 0, 150));
361
363 {
364 const int radius = being->getCollisionRadius();
365 graphics->fillRectangle(gcn::Rectangle(
366 (int) beingPos.x
367 - (int) mPixelViewX - radius,
368 (int) beingPos.y - (int) mPixelViewY
369 - radius,
370 radius * 2, radius * 2));
371 }
372
374 _drawPath(graphics, being->getPath(), gcn::Color(0, 0, 255, 150));
375
377 {
378 // Draw the absolute x, y position using a cross.
379 graphics->setColor(gcn::Color(0, 0, 255, 255));
380 graphics->drawLine((int) beingPos.x - (int) mPixelViewX - 4,
381 (int) beingPos.y - (int) mPixelViewY - 4,
382 (int) beingPos.x - (int) mPixelViewX + 4,
383 (int) beingPos.y - (int) mPixelViewY + 4);
384 graphics->drawLine((int) beingPos.x - (int) mPixelViewX + 4,
385 (int) beingPos.y - (int) mPixelViewY - 4,
386 (int) beingPos.x - (int) mPixelViewX - 4,
387 (int) beingPos.y - (int) mPixelViewY + 4);
388 }
389 }
390}
391
393 gcn::Color color)
394{
395 graphics->setColor(color);
396
397 for (auto pos : path)
398 {
399 int squareX = pos.x - (int) mPixelViewX;
400 int squareY = pos.y - (int) mPixelViewY;
401
402 graphics->fillRectangle(gcn::Rectangle(squareX - 4, squareY - 4,
403 8, 8));
406 pos.y / mMap->getTileHeight())->Gcost),
407 squareX + 4, squareY + 12, gcn::Graphics::CENTER);
408 }
409}
410
411void Viewport::mousePressed(gcn::MouseEvent &event)
412{
413 if (event.getSource() != this)
414 return;
415
416 // Check if we are alive and kickin'
417 if (!mMap || !local_player || !local_player->isAlive())
418 return;
419
420 // Check if we are busy
422 return;
423
424 mPlayerFollowMouse = false;
425 mBeingPopup->setVisible(false);
426
427 const int pixelX = event.getX() + (int) mPixelViewX;
428 const int pixelY = event.getY() + (int) mPixelViewY;
429
432 pixelY / mMap->getTileHeight());
433
435
436 // Right click might open a popup
437 if (event.getButton() == gcn::MouseEvent::RIGHT)
438 {
440 {
441 mPopupMenu->showPopup(event.getX(), event.getY(), mHoverBeing);
442 return;
443 }
444
445 if (mHoverItem)
446 {
447 mPopupMenu->showPopup(event.getX(), event.getY(), mHoverItem);
448 return;
449 }
450 }
451
452 // If a popup is active, just remove it
453 if (mPopupMenu->isVisible())
454 {
455 mPopupMenu->setVisible(false);
456 return;
457 }
458
459 // Left click can cause different actions
460 if (event.getButton() == gcn::MouseEvent::LEFT)
461 {
462 // Interact with some being
463 if (mHoverBeing)
464 {
465 if (mHoverBeing->canTalk())
467 else
468 {
469 // Ignore it if its dead
470 if (mHoverBeing->isAlive())
471 {
475 {
478 }
479 else
480 {
482 }
483 }
484 }
485 // Picks up a item if we clicked on one
486 }
487 else if (mHoverItem)
488 {
490 }
492 {
493 return;
494 }
495 // Just walk around
496 else
497 {
499 mPlayerFollowMouse = true;
500
501 // Make the player go to the mouse position
502 _followMouse();
503 }
504 }
505 else if (event.getButton() == gcn::MouseEvent::MIDDLE)
506 {
507 // Find the being nearest to the clicked position
509 pixelX, pixelY, 20, ActorSprite::MONSTER);
510
511 if (target)
512 local_player->setTarget(target);
513 }
514}
515
516void Viewport::mouseDragged(gcn::MouseEvent &event)
517{
518 if (!mMap || !local_player)
519 return;
520
521 if (mPlayerFollowMouse && !event.isShiftPressed())
522 {
524 {
527 event.getY() + (int) mPixelViewY);
529 }
530 }
531}
532
533void Viewport::mouseReleased(gcn::MouseEvent &event)
534{
535 mPlayerFollowMouse = false;
536}
537
538void Viewport::showPopup(Window *parent, int x, int y, Item *item,
539 bool isInventory, bool canDrop)
540{
541 mPopupMenu->showPopup(parent, x, y, item, isInventory, canDrop);
542}
543
545{
546 mPopupMenu->handleLink("cancel");
547}
548
549void Viewport::mouseMoved(gcn::MouseEvent &event)
550{
551 // Check if we are on the map
552 if (!mMap || !local_player)
553 return;
554
555 const int x = (event.getX() + (int) mPixelViewX);
556 const int y = (event.getY() + (int) mPixelViewY);
557
560
562 y / mMap->getTileHeight());
563
565}
566
568{
569 if (mHoverBeing)
570 {
571 switch (mHoverBeing->getType())
572 {
573 case ActorSprite::NPC:
576 break;
577 default:
579 break;
580 }
581 // Item mouseover
582 }
583 else if (mHoverItem)
584 {
586 }
587 else
588 {
590 }
591}
592
593void Viewport::setDebugFlags(int debugFlags)
594{
595 mDebugFlags = debugFlags;
596 if (mMap)
597 mMap->setDebugFlags(debugFlags);
598}
599
601{
602 mBeingPopup->setVisible(false);
603}
604
605void Viewport::event(Event::Channel channel, const Event &event)
606{
607 if (channel == Event::ActorSpriteChannel
608 && event.getType() == Event::Destroyed)
609 {
610 ActorSprite *actor = event.getActor("source");
611
612 if (mHoverBeing == actor)
613 mHoverBeing = nullptr;
614
615 if (mHoverItem == actor)
616 mHoverItem = nullptr;
617 }
618}
ActorSpriteManager * actorSpriteManager
Definition game.cpp:110
FloorItem * findItem(int id) const
Returns a specific FloorItem, by id.
Being * findNearestLivingBeing(int x, int y, int maxTileDist, ActorSprite::Type type=Being::UNKNOWN, Being *excluded=nullptr) const
Returns a being nearest to specific coordinates.
Being * findBeingByPixel(int x, int y) const
Returns a being at the specific pixel.
const ActorSprites & getAll() const
Returns the whole list of beings.
const Vector & getPosition() const
Returns the pixel position of this actor.
Definition actor.h:53
A popup that displays information about a being.
Definition beingpopup.h:32
void show(int x, int y, Being *b)
Sets the info to be displayed given a particular player.
Definition being.h:65
Type getType() const final
Returns the type of the ActorSprite.
Definition being.h:122
int getCollisionRadius() const
Returns the being's pixel radius used to detect collisions.
Definition being.cpp:804
void drawSpeech(int offsetX, int offsetY)
Draws the speech text above the being.
Definition being.cpp:963
@ SIT
Definition being.h:77
bool isAlive() const
Returns whether this being is still alive.
Definition being.h:351
void talkTo()
Definition being.cpp:1360
Cursor getHoverCursor() const
Definition being.cpp:158
Action getCurrentAction() const
Get the being's action currently performed.
Definition being.h:346
bool canTalk()
Definition being.cpp:1355
void listen(Event::Channel channel)
Definition event.h:42
@ Destroyed
Definition event.h:71
Channel
Definition event.h:45
@ ActorSpriteChannel
Definition event.h:46
@ ConfigChannel
Definition event.h:51
A central point of control for graphics.
Definition graphics.h:78
int getHeight() const
Returns the logical height of the screen.
Definition graphics.h:226
void drawText(const std::string &text, int x, int y, gcn::Graphics::Alignment alignment, const gcn::Color &color, gcn::Font *font, bool outline=false, bool shadow=false, const std::optional< gcn::Color > &outlineColor={}, const std::optional< gcn::Color > &shadowColor={})
Definition graphics.cpp:176
void setColor(const gcn::Color &color) override
Definition graphics.h:255
virtual void windowToLogical(int windowX, int windowY, float &logicalX, float &logicalY) const =0
Converts a window coordinate to a logical coordinate.
int getWidth() const
Returns the logical width of the screen.
Definition graphics.h:221
void setCursorType(Cursor cursor)
Sets which cursor should be used.
Definition gui.cpp:231
Represents one or more instances of a certain item type.
Definition item.h:35
bool isKeyActive(int index) const
Checks if the key is active, by providing the key function index.
void setTarget(Being *target)
Sets the target being of the player.
int getAttackRange() const
Gets the attack range.
virtual void setDestination(int x, int y)
Sets a new destination for this being to walk to.
void setGotoTarget(Being *target)
Sets going to being to attack.
bool withinRange(Actor *target, int range) const
Returns whether the target is in range (in pixels).
void pickUp(FloorItem *item)
void attack(Being *target=nullptr, bool keep=false)
void pathSetByMouse()
Tells that the path has been set by mouse.
void stopAttack()
A tile map.
Definition map.h:147
Path findPixelPath(int startPixelX, int startPixelY, int destPixelX, int destPixelY, int radius, unsigned char walkmask, int maxCost=20)
Find a pixel path from one location to the next using free offsets.
Definition map.cpp:700
@ BLOCKMASK_CHARACTER
Definition map.h:161
@ BLOCKMASK_WALL
Definition map.h:160
void draw(Graphics *graphics, int scrollX, int scrollY)
Draws the map to the given graphics output.
Definition map.cpp:308
int getHeight() const
Returns the height of this map in tiles.
Definition map.h:260
int getTileHeight() const
Returns the tile height used by this map.
Definition map.h:271
int getDebugFlags() const
Definition map.h:332
MetaTile * getMetaTile(int x, int y) const
Get tile reference.
Definition map.cpp:577
int getWidth() const
Returns the width of this map in tiles.
Definition map.h:255
void setDebugFlags(int flags)
Definition map.h:330
int getTileWidth() const
Returns the tile width of this map.
Definition map.h:265
void drawCollision(Graphics *graphics, int scrollX, int scrollY, int debugFlags) const
Visualizes collision layer for debugging.
Definition map.cpp:371
Path findTilePath(int startPixelX, int startPixelY, int endPixelX, int endPixelY, unsigned char walkMask, int maxCost=20)
Find a tile-centered path in pixel coordinates from one location to the next.
Definition map.cpp:676
@ DEBUG_BEING_IDS
Definition map.h:175
@ DEBUG_BEING_COLLISION_RADIUS
Definition map.h:171
@ DEBUG_MOUSE_PATH
Definition map.h:174
@ DEBUG_BEING_POSITION
Definition map.h:172
@ DEBUG_GRID
Definition map.h:169
@ DEBUG_COLLISION_TILES
Definition map.h:170
@ DEBUG_BEING_PATH
Definition map.h:173
Window showing popup menu.
Definition popupmenu.h:37
void handleLink(const std::string &link) override
Handles link action.
void showPopup(int x, int y, Being *being)
Shows the being related popup menu at the specified mouse coords.
Definition popupmenu.cpp:66
void draw(gcn::Graphics *graphics, int xOff, int yOff)
Draw the text.
bool passed() const
Returns whether the timer has passed.
Definition time.h:88
bool isSet() const
Returns whether the timer has been set.
Definition time.h:81
void set(uint32_t ms=0)
Sets the timer with an optional duration in milliseconds.
Definition time.h:69
Vector class.
Definition vector.h:33
float y
Definition vector.h:172
float x
Definition vector.h:171
int mMouseX
Current mouse position in pixels.
Definition viewport.h:196
int getMouseY() const
Returns mouse y in pixels.
Definition viewport.h:136
void mousePressed(gcn::MouseEvent &event) override
Handles mouse press on map.
Definition viewport.cpp:411
void _drawPath(Graphics *graphics, const Path &path, gcn::Color color=gcn::Color(255, 0, 0))
Draws the given path.
Definition viewport.cpp:392
void logic() override
Implements player to keep following mouse.
Definition viewport.cpp:262
std::list< ShakeEffect > mShakeEffects
Definition viewport.h:210
void mouseMoved(gcn::MouseEvent &event) override
Handles mouse move on map.
Definition viewport.cpp:549
Being * mHoverBeing
Being mouse is currently over.
Definition viewport.h:217
int getMouseX() const
Returns mouse x in pixels.
Definition viewport.h:131
Timer mLocalWalkTimer
Timer for sending walk messages.
Definition viewport.h:214
void setMap(Map *map)
Sets the map displayed by the viewport.
Definition viewport.cpp:66
PopupMenu * mPopupMenu
Popup menu.
Definition viewport.h:216
void event(Event::Channel channel, const Event &event) override
Definition viewport.cpp:605
float mPixelViewY
Current viewpoint in pixels.
Definition viewport.h:199
bool mPlayerFollowMouse
Definition viewport.h:212
void mouseDragged(gcn::MouseEvent &event) override
Handles mouse move on map.
Definition viewport.cpp:516
int mDebugFlags
Flags for showing debug graphics.
Definition viewport.h:200
BeingPopup * mBeingPopup
Being information popup.
Definition viewport.h:219
void closePopupMenu()
Closes the popup menu.
Definition viewport.cpp:544
void draw(gcn::Graphics *graphics) override
Draws the viewport.
Definition viewport.cpp:75
Map * mMap
The current map.
Definition viewport.h:194
float mPixelViewX
Current viewpoint in pixels.
Definition viewport.h:198
void _followMouse()
Make the player go to the mouse position.
Definition viewport.cpp:271
void _drawDebugPath(Graphics *graphics)
Finds a path from the player to the mouse, and draws it.
Definition viewport.cpp:300
void setDebugFlags(int debugFlags)
Sets which debug flags (see Map::DebugFlags) should be enabled.
Definition viewport.cpp:593
~Viewport() override
Definition viewport.cpp:60
void hideBeingPopup()
Hides the BeingPopup.
Definition viewport.cpp:600
void updateCursorType()
Updates the cursor type.
Definition viewport.cpp:567
void mouseReleased(gcn::MouseEvent &event) override
Handles mouse button release on map.
Definition viewport.cpp:533
void showPopup(Window *parent, int x, int y, Item *item, bool isInventory=true, bool canDrop=true)
Shows a popup for an item.
Definition viewport.cpp:538
FloorItem * mHoverItem
FloorItem mouse is currently over.
Definition viewport.h:218
void shakeScreen(int intensity)
Makes the screen shake in a random direction.
Definition viewport.cpp:243
int mMouseY
Current mouse position in pixels.
Definition viewport.h:197
void logic() override
Do GUI logic.
void draw(gcn::Graphics *graphics) override
Adds debug drawing.
A window.
Definition window.h:59
Config config
Global settings (config.xml)
Definition client.cpp:97
Graphics * graphics
Definition client.cpp:104
KeyboardConfig keyboard
Definition client.cpp:101
Gui * gui
The GUI system.
Definition gui.cpp:50
LocalPlayer * local_player
ServerType getNetworkType()
Definition net.cpp:200
PlayerHandler * getPlayerHandler()
Definition net.cpp:110
bool isTalking()
Returns true if the player is involved in a NPC interaction, false otherwise.
unsigned deltaTimeMs()
The time in milliseconds since the last frame, but never more than 1000.
Definition time.cpp:39
std::list< Position > Path
Definition position.h:40
std::string toString(const T &arg)
Converts the given value to a string using std::stringstream.
Definition stringutils.h:68
int scrollCenterOffsetX
int scrollLaziness
int scrollRadius
int scrollCenterOffsetY
TextManager * textManager
const int walkingMouseDelay
Delay between two mouse calls when dragging mouse and move the player.
Definition viewport.h:47