Mana
Loading...
Searching...
No Matches
game.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 "game.h"
23
24#include "actorsprite.h"
25#include "actorspritemanager.h"
26#include "channelmanager.h"
27#include "client.h"
28#include "commandhandler.h"
29#include "configuration.h"
30#include "effectmanager.h"
31#include "emoteshortcut.h"
32#include "event.h"
33#include "graphics.h"
34#include "itemshortcut.h"
35#include "joystick.h"
36#include "keyboardconfig.h"
37#include "localplayer.h"
38#include "log.h"
39#include "map.h"
40#include "particle.h"
41#include "playerrelations.h"
42#include "sound.h"
43
44#include "gui/abilitieswindow.h"
45#include "gui/chatwindow.h"
46#include "gui/debugwindow.h"
47#include "gui/equipmentwindow.h"
48#include "gui/gui.h"
49#include "gui/helpwindow.h"
50#include "gui/inventorywindow.h"
51#include "gui/minimap.h"
53#include "gui/npcdialog.h"
54#include "gui/okdialog.h"
55#include "gui/outfitwindow.h"
56#include "gui/questswindow.h"
57#include "gui/quitdialog.h"
58#include "gui/setup.h"
59#include "gui/shortcutwindow.h"
60#include "gui/skilldialog.h"
61#include "gui/socialwindow.h"
62#include "gui/statuswindow.h"
63#include "gui/textdialog.h"
64#include "gui/tradewindow.h"
65#include "gui/viewport.h"
66
67#include "gui/widgets/chattab.h"
70
71#include "net/gamehandler.h"
72#include "net/net.h"
73#include "net/playerhandler.h"
74
76#include "resources/mapreader.h"
77
78#include "utils/filesystem.h"
79#include "utils/gettext.h"
80#include "utils/mkdir.h"
81
82#include <guichan/focushandler.hpp>
83
84#include <fstream>
85#include <sstream>
86
88
92
109
118
122static void initEngines()
123{
125
130
131 particleEngine = new Particle(nullptr);
133
135}
136
140static void createGuiWindows()
141{
143
145
146 // Create dialogs
148 minimap = new Minimap;
158 itemShortcutWindow = new ShortcutWindow("ItemShortcut",
160 emoteShortcutWindow = new ShortcutWindow("EmoteShortcut",
165
166 localChatTab = new ChatTab(_("General"));
167
169
171}
172
173#define del_0(X) { delete X; X = 0; }
174
178static void destroyGuiWindows()
179{
181
182 del_0(localChatTab) // Need to do this first, so it can remove itself
199
200 Event::trigger(Event::NpcChannel, Event::CloseAll); // Cleanup remaining NPC dialogs
201
203}
204
205Game *Game::mInstance = nullptr;
206
208 mLastTarget(ActorSprite::UNKNOWN)
209{
210 assert(!mInstance);
211 mInstance = this;
212
214
215 // Create the viewport
216 viewport = new Viewport;
218
219 auto *top = static_cast<gcn::Container*>(gui->getTop());
220 top->add(viewport);
221 viewport->requestMoveToBottom();
222
223 createGuiWindows();
224
227
228 initEngines();
229
230 // Initialize beings
232
234 // TODO: The user should be able to choose which one to use
235 // Open the first device
237 joystick = new Joystick(0);
238
240}
241
265
266static bool saveScreenshot()
267{
268 static unsigned int screenshotCount = 0;
269
270 // We don't want to show IP addresses in screenshots
271 const bool showip = local_player->getShowIp();
272 if (showip)
273 {
274 local_player->setShowIp(false);
276 gui->draw();
277 }
278
279 SDL_Surface *screenshot = graphics->getScreenshot();
280
281 if (showip)
282 {
283 local_player->setShowIp(true);
285 }
286
287 if (!screenshot)
288 {
289 serverNotice(_("Could not take screenshot!"));
290 Log::error("Could not take screenshot.");
291 return false;
292 }
293
294 // Search for an unused screenshot name
295 std::ostringstream filenameSuffix;
296 std::ostringstream filename;
297 std::ifstream testExists;
298 std::string screenshotDirectory = Client::getScreenshotDirectory();
299 bool found = false;
300
301 if (mkdir_r(screenshotDirectory.c_str()) != 0)
302 {
303 Log::info("Directory %s doesn't exist and can't be created! "
304 "Setting screenshot directory to home.",
305 screenshotDirectory.c_str());
306 screenshotDirectory = FS::getUserDir();
307 }
308
309 do
310 {
311 screenshotCount++;
312 filenameSuffix.str(std::string());
313 filenameSuffix << branding.getValue("appShort", "Mana")
314 << "_Screenshot_" << screenshotCount << ".png";
315 filename.str(std::string());
316 filename << screenshotDirectory << "/" << filenameSuffix.str();
317 testExists.open(filename.str());
318 found = !testExists.is_open();
319 testExists.close();
320 }
321 while (!found);
322
323 const bool success = ImageWriter::writePNG(screenshot, filename.str());
324
325 if (success)
326 {
327 std::string screenshotLink;
328#if SDL_VERSION_ATLEAST(2, 0, 14)
329 screenshotLink = strprintf("@@screenshot:%s|%s@@",
330 filenameSuffix.str().c_str(),
331 filenameSuffix.str().c_str());
332#else
333 screenshotLink = filenameSuffix.str();
334#endif
335 serverNotice(strprintf(_("Screenshot saved as %s"),
336 screenshotLink.c_str()));
337 }
338 else
339 {
340 serverNotice(_("Saving screenshot failed!"));
341 Log::error("Could not save screenshot.");
342 }
343
344 SDL_FreeSurface(screenshot);
345
346 return success;
347}
348
350{
351 // Handle all necessary game logic
353
354 // todo: make Particle::update work with variable time steps
356 {
358 mParticleEngineTimer.extend(MILLISECONDS_IN_A_TICK);
359 }
360
361 if (mCurrentMap)
363
364 // Handle network stuff
365 if (!Net::getGameHandler()->isConnected() && !mDisconnected)
366 {
368 return; // Not a problem here
369
371 return; // Disconnect gets handled by STATE_ERROR
372
373 errorMessage = _("The connection to the server was lost.");
374 Client::instance()->showOkDialog(_("Network Error"),
377 mDisconnected = true;
378 }
379}
380
384static void handleItemPickUp()
385{
386 int x = local_player->getTileX();
387 int y = local_player->getTileY();
388
389 // Let's look for items around until you find one.
390 FloorItem *item = actorSpriteManager->findItem(x, y, 1);
391 if (!item)
392 return;
393
394 local_player->pickUp(item);
395}
396
400bool Game::keyDownEvent(SDL_KeyboardEvent &event)
401{
402 gcn::Window *requestedWindow = nullptr;
403
404 // send straight to gui for certain windows
407 {
408 return false;
409 }
410
412 {
413 int emotion = keyboard.getKeyEmoteOffset(event.keysym.sym);
414 if (emotion != -1)
415 {
416 emoteShortcut->useEmote(emotion);
417 return true;
418 }
419 }
420
422 && !gui->getFocusHandler()->getModalFocused())
423 {
426 && (!dialog || !dialog->isTextInputFocused()))
427 {
428 // Close the Browser if opened
429 if (helpWindow->isVisible())
430 helpWindow->setVisible(false);
431 // Close the config window, cancelling changes if opened
432 else if (setupWindow->isVisible())
433 setupWindow->action(gcn::ActionEvent(nullptr, "cancel"));
434 else if (dialog)
435 dialog->action(gcn::ActionEvent(nullptr, "ok"));
436 }
438 {
440 return true;
441 }
442 if (dialog)
443 {
445 dialog->move(1);
447 dialog->move(-1);
448 }
449 }
450
451 if (!chatWindow->isInputFocused() || (event.keysym.mod & KMOD_ALT))
452 {
454 {
456 return true;
457 }
459 {
461 return true;
462 }
463 }
464
466 {
467 bool wearOutfit = false;
468 bool copyOutfit = false;
469
471 wearOutfit = true;
472
474 copyOutfit = true;
475
476 if (wearOutfit || copyOutfit)
477 {
478 int outfitNum = -1;
479 switch (event.keysym.sym)
480 {
481 case SDLK_1:
482 case SDLK_2:
483 case SDLK_3:
484 case SDLK_4:
485 case SDLK_5:
486 case SDLK_6:
487 case SDLK_7:
488 case SDLK_8:
489 case SDLK_9:
490 outfitNum = event.keysym.sym - SDLK_1;
491 break;
492
493 case SDLK_0:
494 outfitNum = 9;
495 break;
496
497 case SDLK_MINUS:
498 outfitNum = 10;
499 break;
500
501 case SDLK_EQUALS:
502 outfitNum = 11;
503 break;
504
505 case SDLK_BACKSPACE:
506 outfitNum = 12;
507 break;
508
509 case SDLK_INSERT:
510 outfitNum = 13;
511 break;
512
513 case SDLK_HOME:
514 outfitNum = 14;
515 break;
516
517 default:
518 break;
519 }
520 if (outfitNum >= 0)
521 {
522 if (wearOutfit)
523 outfitWindow->wearOutfit(outfitNum);
524 else if (copyOutfit)
525 outfitWindow->copyOutfit(outfitNum);
526 return true;
527 }
528 }
529 }
530
531 const int tKey = keyboard.getKeyIndex(event.keysym.sym);
532 switch (tKey)
533 {
535 if (chatWindow->isVisible())
536 {
538 return true;
539 }
540 break;
542 if (chatWindow->isVisible())
543 {
545 return true;
546 }
547 break;
549 // In-game Help
550 if (helpWindow->isVisible())
551 {
552 helpWindow->setVisible(false);
553 }
554 else
555 {
556 helpWindow->loadHelp("index");
557 helpWindow->requestMoveToTop();
558 }
559 return true;
560
562 {
563 // Close possible stuck NPC dialogs.
564 NpcDialog *npcDialog = NpcDialog::getActive();
565 if (npcDialog && npcDialog->isWaitingForTheServer())
566 {
567 npcDialog->close();
568 return true;
569 }
570
571 // Otherwise, show the quit confirmation dialog.
573 quitDialog->requestMoveToTop();
574 return true;
575 }
576 default:
577 break;
578 }
579
582 {
583 // Do not activate shortcuts if tradewindow is visible
584 if (!tradeWindow->isVisible() && !setupWindow->isVisible())
585 {
586 // Checks if any item shortcut is pressed.
589 i++)
590 {
591 if (tKey == i)
592 {
595 return true;
596 }
597 }
598 }
599
600 switch (tKey)
601 {
603 handleItemPickUp();
604 return true;
605
608 return true;
609
611 // Hide certain windows
612 statusWindow->setVisible(false);
614 skillDialog->setVisible(false);
615 questsWindow->setVisible(false);
616 setupWindow->setVisible(false);
618 helpWindow->setVisible(false);
619 debugWindow->setVisible(false);
620 socialWindow->setVisible(false);
621 break;
622
624 requestedWindow = statusWindow;
625 break;
627 requestedWindow = inventoryWindow;
628 break;
630 requestedWindow = equipmentWindow;
631 break;
633 requestedWindow = skillDialog;
634 break;
636 requestedWindow = questsWindow;
637 break;
639 minimap->toggle();
640 return true;
642 requestedWindow = chatWindow;
643 break;
645 requestedWindow = itemShortcutWindow;
646 break;
648 requestedWindow = setupWindow;
649 break;
651 requestedWindow = debugWindow;
652 break;
654 requestedWindow = socialWindow;
655 break;
657 requestedWindow = emoteShortcutWindow;
658 break;
660 requestedWindow = outfitWindow;
661 break;
663 saveScreenshot();
664 return true;
665
667 {
668 // Toggle accepting of incoming trade requests
669 unsigned int deflt = player_relations.getDefault();
670 if (deflt & PlayerPermissions::TRADE)
671 {
672 serverNotice(_("Ignoring incoming trade requests"));
673 deflt &= ~PlayerPermissions::TRADE;
674 }
675 else
676 {
677 serverNotice(_("Accepting incoming trade requests"));
679 }
680
682
683 return true;
684 }
685
687 if (Being *target = local_player->getTarget())
688 if (target->canTalk())
689 target->talkTo();
690 return true;
691 }
692 }
693
694 if (requestedWindow)
695 {
696 requestedWindow->setVisible(!requestedWindow->isVisible());
697 if (requestedWindow->isVisible())
698 requestedWindow->requestMoveToTop();
699 return true;
700 }
701
702 return false;
703}
704
709{
710 if (joystick)
711 joystick->update();
712
713 // If the user is configuring the keys then don't respond.
714 if (!keyboard.isEnabled())
715 return;
716 if (!local_player->isAlive())
717 return;
719 return;
721 return;
722
723 // Moving player around
724
725 // Get the state of the keyboard keys
727
728 // Ignore input if either "ignore" key is pressed
729 // Stops the character moving about if the user's window manager
730 // uses "ignore+arrow key" to switch virtual desktops.
733 {
734 return;
735 }
736
737 unsigned char direction = 0;
738
739 // Translate pressed keys to movement and direction
741 (joystick && joystick->isUp()))
742 {
743 direction |= Being::UP;
744 }
746 (joystick && joystick->isDown()))
747 {
748 direction |= Being::DOWN;
749 }
750
752 (joystick && joystick->isLeft()))
753 {
754 direction |= Being::LEFT;
755 }
757 (joystick && joystick->isRight()))
758 {
759 direction |= Being::RIGHT;
760 }
761
762 if (keyboard.isKeyActive(KeyboardConfig::KEY_EMOTE) && direction != 0)
763 {
764 if (local_player->getDirection() != direction)
765 {
766 local_player->setDirection(direction);
768 }
769 }
770 else
771 {
772 local_player->setWalkingDir(direction);
773 }
774
775 // Attacking monsters
778 {
779 if (local_player->getTarget())
781 }
782
784 {
785 Being *target = local_player->getTarget();
786
788 // A set target has highest priority
789 if (!target)
790 {
791 // Only auto target Monsters
794 }
795 local_player->attack(target, newTarget);
796 }
797
798 // Target the nearest player/monster/npc
802 (joystick && joystick->buttonPressed(3))) &&
804 {
808 currentTarget = ActorSprite::MONSTER;
810 currentTarget = ActorSprite::PLAYER;
812 currentTarget = ActorSprite::NPC;
813
815 20, currentTarget);
816
817 if (target && (target != local_player->getTarget() ||
818 currentTarget != mLastTarget))
819 {
820 local_player->setTarget(target);
821 mLastTarget = currentTarget;
822 }
823 }
824 else
825 {
826 mLastTarget = ActorSprite::UNKNOWN; // Reset last target
827 }
828
829 // Stop attacking if the right key is pressed
832 {
834 }
835
836 if (joystick)
837 {
838 if (joystick->buttonPressed(1))
839 {
840 const int x = local_player->getTileX();
841 const int y = local_player->getTileY();
842
843 if (FloorItem *item = actorSpriteManager->findItem(x, y))
844 local_player->pickUp(item);
845 }
846 else if (joystick->buttonPressed(2))
847 {
849 }
850 }
851}
852
857void Game::changeMap(const std::string &mapPath)
858{
859 // Clean up floor items, beings and particles
861
862 // Close the popup menu on map change so that invalid options can't be
863 // executed.
865
866 // Unset the map of the player so that its particles are cleared before
867 // being deleted in the next step
868 if (local_player)
869 local_player->setMap(nullptr);
870
872
873 mMapName = mapPath;
874
875 std::string fullMap = paths.getValue("maps", "maps/")
876 + mMapName + ".tmx";
877
878 // Attempt to load the new map
879 Map *newMap = MapReader::readMap(fullMap);
880
881 if (!newMap)
882 {
883 Log::info("Error while loading %s", fullMap.c_str());
884 new OkDialog(_("Could Not Load Map"),
885 strprintf(_("Error while loading %s"), fullMap.c_str()));
886 }
887
888 // Notify the minimap and beingManager about the map change
889 minimap->setMap(newMap);
890 actorSpriteManager->setMap(newMap);
891 particleEngine->setMap(newMap);
892 viewport->setMap(newMap);
893
894 // Initialize map-based particle effects
895 if (newMap)
897
898 // Start playing new music file when necessary
899 std::string oldMusic = mCurrentMap ? mCurrentMap->getMusicFile() : std::string();
900 std::string newMusic = newMap ? newMap->getMusicFile() : std::string();
901 if (newMusic != oldMusic)
902 {
903 if (newMusic.empty())
905 else
906 sound.fadeOutAndPlayMusic(newMusic);
907 }
908
909 delete mCurrentMap;
910 mCurrentMap = newMap;
911
912 Event event(Event::MapLoaded);
913 event.setString("mapPath", mapPath);
914 event.trigger(Event::GameChannel);
915}
916
918{
919 if (mCurrentMap)
920 return mCurrentMap->getTileWidth();
921
922 return DEFAULT_TILE_LENGTH;
923}
924
926{
927 if (mCurrentMap)
928 return mCurrentMap->getTileHeight();
929
930 return DEFAULT_TILE_LENGTH;
931}
932
933void Game::videoResized(int width, int height)
934{
935 viewport->setSize(width, height);
936 mWindowMenu->setPosition(width - 3 - mWindowMenu->getWidth(), 3);
937}
ActorSpriteManager * actorSpriteManager
Definition game.cpp:110
ChannelManager * channelManager
Definition game.cpp:111
#define DEFAULT_CHAT_WINDOW_SCROLL
Definition chatwindow.h:43
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.
void setPlayer(LocalPlayer *player)
Sets the current player.
void setMap(Map *map)
Sets the map on which ActorSprites are created.
void clear()
Destroys all ActorSprites except the local player.
void logic()
Performs ActorSprite logic and deletes ActorSprite scheduled to be deleted.
virtual void setMap(Map *map)
Definition actor.cpp:32
Definition being.h:65
void setDirection(uint8_t direction)
Sets the current direction.
Definition being.cpp:782
void setMap(Map *map) final
Definition being.cpp:1398
uint8_t getDirection() const
Returns the current direction.
Definition being.h:356
int getTileX() const override
Returns the tile x coord.
Definition being.h:146
@ RIGHT
Definition being.h:107
@ DOWN
Definition being.h:104
@ UP
Definition being.h:106
@ LEFT
Definition being.h:105
bool isAlive() const
Returns whether this being is still alive.
Definition being.h:351
int getTileY() const override
Returns the tile y coord.
Definition being.h:152
A tab for the chat window.
Definition chattab.h:36
The chat window.
Definition chatwindow.h:73
bool isInputFocused() const
Checks whether ChatWindow is Focused or not.
bool requestChatFocus()
Request focus for typing chat message.
void scroll(int amount)
Scrolls the chat window.
void nextTab()
Switch to the next tab in order.
void prevTab()
Switch to the previous tab in order.
void showOkDialog(const std::string &title, const std::string &message, State state)
Pops up an OkDialog with the given title and message, and switches to the given state when Ok is pres...
Definition client.cpp:970
static const std::string & getScreenshotDirectory()
Definition client.h:184
static State getState()
Definition client.h:172
static Client * instance()
Provides access to the client instance.
Definition client.h:149
A class to parse and handle user commands.
std::string getValue(const std::string &key, const std::string &deflt) const
Gets a value as string.
The debug window.
Definition debugwindow.h:36
An emote shortcut container.
void useEmote(int index)
Try to use the Emote specified by the index.
Equipment dialog.
Definition event.h:42
@ Destructed
Definition event.h:72
@ GuiWindowsLoading
Definition event.h:83
@ CloseAll
Definition event.h:66
@ EnginesInitializing
Definition event.h:81
@ GuiWindowsLoaded
Definition event.h:82
@ EnginesInitialized
Definition event.h:80
@ MapLoaded
Definition event.h:87
@ GuiWindowsUnloading
Definition event.h:85
@ GuiWindowsUnloaded
Definition event.h:84
@ Destructing
Definition event.h:73
@ Constructed
Definition event.h:69
void trigger(Channel channel) const
Sends this event to all classes listening to the given channel.
Definition event.h:275
@ NpcChannel
Definition event.h:55
@ GameChannel
Definition event.h:52
An item lying on the floor.
Definition flooritem.h:32
The main class responsible for running the game.
Definition game.h:37
bool mDisconnected
Definition game.h:90
Map * mCurrentMap
Definition game.h:94
std::string mMapName
Definition game.h:95
int getCurrentTileWidth() const
Convenience functions used to get the current tile width and height.
Definition game.cpp:917
void videoResized(int width, int height)
Definition game.cpp:933
Timer mParticleEngineTimer
Definition game.h:97
int getCurrentTileHeight() const
Definition game.cpp:925
int mLastTarget
Definition game.h:89
WindowMenu * mWindowMenu
Definition game.h:92
void handleInput()
Continuous input handling.
Definition game.cpp:708
static Game * mInstance
Definition game.h:99
bool keyDownEvent(SDL_KeyboardEvent &event)
Handles an SDL_KEYDOWN event and returns whether it was consumed.
Definition game.cpp:400
Game()
Constructs the game, creating all the managers, handlers, engines and GUI windows that make up the ga...
Definition game.cpp:207
void changeMap(const std::string &mapName)
Changes the currently active map.
Definition game.cpp:857
~Game()
Destructor, cleans up the game.
Definition game.cpp:242
void logic()
This method takes the game a small step further.
Definition game.cpp:349
virtual SDL_Surface * getScreenshot()=0
Takes a screenshot and returns it as SDL surface.
int getHeight() const
Returns the logical height of the screen.
Definition graphics.h:226
int getWidth() const
Returns the logical width of the screen.
Definition graphics.h:221
gcn::FocusHandler * getFocusHandler() const
Definition gui.h:101
The help dialog.
Definition helpwindow.h:37
void loadHelp(const std::string &helpFile)
Loads help in the dialog.
static bool writePNG(SDL_Surface *surface, const std::string &filename)
Inventory dialog.
static bool isAnyInputFocused()
An item shortcut container.
void useItem(int index)
Try to use the item specified by the index.
static void init()
Initializes the joystick subsystem.
Definition joystick.cpp:31
bool isRight() const
Definition joystick.h:86
bool isDown() const
Definition joystick.h:84
void update()
Updates the direction and button information.
Definition joystick.cpp:75
static int getNumberOfJoysticks()
Returns the number of available joysticks.
Definition joystick.h:56
bool isLeft() const
Definition joystick.h:85
bool isUp() const
Definition joystick.h:83
bool buttonPressed(unsigned char no) const
Definition joystick.cpp:143
void refreshActiveKeys()
Takes a snapshot of all the active keys.
int getKeyEmoteOffset(SDL_Keycode keyValue) const
Get the key function index for an emote by providing the offset value.
bool isEnabled() const
Get the enable flag, which will stop the user from doing actions.
int getKeyIndex(SDL_Keycode keyValue) const
Get the key function index by providing the keys value.
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.
Being * getTarget() const
Returns the current target of the player.
void setShowIp(bool show)
void setWalkingDir(int dir)
Sets a new direction to keep walking in, when using the keyboard or the joystick.
void pickUp(FloorItem *item)
void attack(Being *target=nullptr, bool keep=false)
bool getShowIp() const
void stopAttack()
static Map * readMap(const std::string &filename)
Read an XML map from a file.
Definition mapreader.cpp:78
A tile map.
Definition map.h:147
std::string getMusicFile() const
Definition map.cpp:593
void update(int dt)
Updates animations.
Definition map.cpp:299
void initializeParticleEffects(Particle *particleEngine)
Initializes all added particle effects.
Definition map.cpp:964
int getTileHeight() const
Returns the tile height used by this map.
Definition map.h:271
int getTileWidth() const
Returns the tile width of this map.
Definition map.h:265
The player mini-status dialog.
Minimap window.
Definition minimap.h:41
void toggle()
Toggles the displaying of the minimap.
Definition minimap.cpp:130
void setMap(Map *map)
Sets the map image that should be displayed.
Definition minimap.cpp:65
virtual void setDirection(char direction)=0
The npc dialog.
Definition npcdialog.h:49
static bool isAnyInputFocused()
void action(const gcn::ActionEvent &event) override
Called when receiving actions from the widgets.
bool isWaitingForTheServer() const
Definition npcdialog.h:150
bool isTextInputFocused() const
void move(int amount)
static NpcDialog * getActive()
Returns the first active instance.
static void setup()
void close() override
Notifies the server that the client has performed a close action.
An 'Ok' button dialog.
Definition okdialog.h:34
void wearOutfit(int outfit)
void copyOutfit(int outfit)
A particle spawned by a ParticleEmitter.
Definition particle.h:42
static void setupEngine()
Gives a particle the properties of an engine root particle and loads the particle-related config sett...
Definition particle.cpp:71
virtual bool update()
Updates particle position, returns false when the particle should be deleted.
Definition particle.cpp:85
void clear()
Deletes all child particles and emitters.
Definition particle.cpp:423
unsigned int getDefault() const
Retrieves the default permissions.
void setDefault(unsigned int permissions)
Sets the default permissions.
Quests window.
The quit dialog.
Definition quitdialog.h:40
void action(const gcn::ActionEvent &event) override
Event handling method.
Definition setup.cpp:85
void clearWindowsForReset()
Definition setup.cpp:114
A window around a ShortcutContainer.
The skill dialog.
Definition skilldialog.h:48
Party window.
void fadeOutAndPlayMusic(const std::string &fileName, int ms=1000)
Fades out a background music and play a new one.
Definition sound.cpp:218
void fadeOutMusic(int ms=1000)
Fades out currently running background music track.
Definition sound.cpp:197
The player status dialog.
static bool isActive()
Definition textdialog.h:53
bool passed() const
Returns whether the timer has passed.
Definition time.h:88
void extend(uint32_t ms)
Extend the timer by the given number of milliseconds.
Definition time.h:94
void set(uint32_t ms=0)
Sets the timer with an optional duration in milliseconds.
Definition time.h:69
Trade dialog.
Definition tradewindow.h:42
The viewport on the map.
Definition viewport.h:59
void setMap(Map *map)
Sets the map displayed by the viewport.
Definition viewport.cpp:66
void closePopupMenu()
Closes the popup menu.
Definition viewport.cpp:544
The window menu.
Definition windowmenu.h:42
virtual void setVisible(bool visible)
Overloads window setVisible by Guichan to allow sticky window handling.
Definition window.cpp:282
Configuration paths
XML default paths information reader.
Definition client.cpp:99
std::string errorMessage
Definition client.cpp:94
Graphics * graphics
Definition client.cpp:104
Configuration branding
XML branding information reader.
Definition client.cpp:98
KeyboardConfig keyboard
Definition client.cpp:101
Sound sound
Definition client.cpp:109
@ STATE_CHOOSE_SERVER
Definition client.h:62
@ STATE_CHANGE_MAP
Definition client.h:74
@ STATE_ERROR
Definition client.h:60
CommandHandler * commandHandler
Definition game.cpp:112
EffectManager * effectManager
Definition game.cpp:114
EmoteShortcut * emoteShortcut
void serverNotice(const std::string &message)
Definition event.h:319
Minimap * minimap
Definition game.cpp:99
Particle * particleEngine
Definition game.cpp:113
AbilitiesWindow * abilitiesWindow
Definition game.cpp:107
Joystick * joystick
Definition game.cpp:87
InventoryWindow * inventoryWindow
Definition game.cpp:96
OkDialog * deathNotice
Definition game.cpp:90
SocialWindow * socialWindow
Definition game.cpp:108
HelpWindow * helpWindow
Definition game.cpp:102
TradeWindow * tradeWindow
Definition game.cpp:101
OutfitWindow * outfitWindow
Definition game.cpp:106
ChannelManager * channelManager
Definition game.cpp:111
QuestsWindow * questsWindow
Definition game.cpp:98
#define del_0(X)
Definition game.cpp:173
ChatWindow * chatWindow
Definition game.cpp:93
EffectManager * effectManager
Definition game.cpp:114
ChatTab * localChatTab
Definition game.cpp:117
ShortcutWindow * emoteShortcutWindow
Definition game.cpp:105
ShortcutWindow * itemShortcutWindow
Definition game.cpp:104
OkDialog * weightNotice
Definition game.cpp:89
ActorSpriteManager * actorSpriteManager
Definition game.cpp:110
MiniStatusWindow * miniStatusWindow
Definition game.cpp:95
EquipmentWindow * equipmentWindow
Definition game.cpp:100
Viewport * viewport
Viewport on the map.
Definition game.cpp:115
QuitDialog * quitDialog
Definition game.cpp:91
DebugWindow * debugWindow
Definition game.cpp:103
StatusWindow * statusWindow
Definition game.cpp:94
CommandHandler * commandHandler
Definition game.cpp:112
SkillDialog * skillDialog
Definition game.cpp:97
#define _(s)
Definition gettext.h:38
Gui * gui
The GUI system.
Definition gui.cpp:50
ItemShortcut * itemShortcut
LocalPlayer * local_player
const int DEFAULT_TILE_LENGTH
Definition map.h:38
int mkdir_r(const char *pathname)
Create a directory, making leading components first if necessary.
Definition mkdir.cpp:36
const char * getUserDir()
Definition filesystem.h:57
void info(const char *log_text,...) LOG_PRINTF_ATTR
void error(const char *log_text,...) LOG_PRINTF_ATTR
GameHandler * getGameHandler()
Definition net.cpp:75
PlayerHandler * getPlayerHandler()
Definition net.cpp:110
Inventory * getInventory()
Returns the player's inventory.
Equipment * getEquipment()
Returns the player's equipment.
bool isTalking()
Returns true if the player is involved in a NPC interaction, false otherwise.
int getNPCPostCount()
Returns the number of currently open NPC post windows.
unsigned deltaTimeMs()
The time in milliseconds since the last frame, but never more than 1000.
Definition time.cpp:39
PlayerRelationsManager player_relations
Setup * setupWindow
Definition setup.cpp:120
std::string strprintf(char const *format,...)
A safe version of sprintf that returns a std::string of the result.
WindowContainer * windowContainer