ManaPlus
|
#include <game.h>
Public Member Functions | |
Game () | |
~Game () | |
void | logic () |
void | slowLogic () |
void | handleInput () |
void | handleMove () |
void | changeMap (const std::string &mapName) |
void | updateFrameRate (int fpsLimit) |
Map * | getCurrentMap () const |
const std::string & | getCurrentMapName () const |
void | setValidSpeed () |
void | adjustPerfomance () |
void | resetAdjustLevel () |
void | setAdjustLevel (const int n) |
bool | getValidSpeed () const |
void | updateHistory (const SDL_Event &event) |
void | checkKeys () |
Static Public Member Functions | |
static Game * | instance () |
static void | clearInstance () |
static void | videoResized (const int width, const int height) |
static void | moveInDirection (const unsigned char direction) |
static bool | createScreenshot (const std::string &prefix) |
static void | addWatermark () |
static bool | saveScreenshot (SDL_Surface *const screenshot, const std::string &prefix) |
Private Member Functions | |
void | clearKeysArray () |
Private Attributes | |
Map * | mCurrentMap |
std::string | mMapName |
bool | mValidSpeed |
LastKey | mLastKeys [MAX_LASTKEYS] |
time_t | mNextAdjustTime |
int | mAdjustLevel |
bool | mAdjustPerfomance |
int | mLowerCounter |
int | mPing |
time_t | mTime |
time_t | mTime2 |
Static Private Attributes | |
static Game * | mInstance = 0 |
The main class responsible for running the game. The game starts after you have selected your character.
Game::Game | ( | ) |
Constructs the game, creating all the managers, handlers, engines and GUI windows that make up the game.
Definition at line 405 of file game.cpp.
References actorManager, BasicContainer2::add(), chatWindow, PlayerInfo::clear(), clearKeysArray(), config, createGuiWindows(), Settings::disableLoggingInGame, disconnectedDialog, emptyBeingSlot, gameHandler, Configuration::getBoolValue(), GuildManager::getEnableGuildBot(), Graphics::getOpenGL(), Gui::getTop(), gui, guildManager, Configuration::incValue(), initEngines(), MapReader::loadEmptyAtlas(), localPlayer, Logger::log(), logger, mailWindow, mainGraphics, Graphics::mHeight, mInstance, Graphics::mWidth, Net::GameHandler::ping(), ChatWindow::postConnection(), MailWindow::postConnection(), RENDER_SOFTWARE, GuildManager::requestGuildInfo(), Widget::requestMoveToBottom(), AnimatedSprite::setEnableCache(), CompoundSprite::setEnableDelay(), TouchManager::setInGame(), SetupWindow::setInGame(), ActorManager::setPlayer(), Widget::setSize(), settings, setupWindow, tick_time, top, touchManager, viewport, windowContainer, and windowMenu.
Game::~Game | ( | ) |
Destructor, cleans up the game.
Definition at line 481 of file game.cpp.
References actorManager, State::CHANGE_MAP, EffectManager::clear(), Being::clearCache(), client, config, crazyMoves, delete2, destroyGuiWindows(), Settings::disableLoggingInGame, effectManager, emptyBeingSlot, PlayerInfo::gameDestroyed(), Client::getState(), guildManager, localPlayer, mCurrentMap, mInstance, particleEngine, resetAdjustLevel(), serverConfig, AnimatedSprite::setEnableCache(), TouchManager::setInGame(), settings, touchManager, MapReader::unloadEmptyAtlas(), viewport, and Configuration::write().
|
static |
Definition at line 520 of file game.cpp.
References boldFont, config, Font::drawString(), Configuration::getBoolValue(), Theme::getColor(), mainGraphics, Settings::serverName, settings, QuestType::TEXT, and theme.
Referenced by createScreenshot().
void Game::adjustPerfomance | ( | ) |
Definition at line 782 of file game.cpp.
References _, adjustDelay, Settings::awayMode, ChatMsgType::BY_SERVER, ChatTab::chatLog(), config, cur_time, ParticleEngine::emitterSkip, fps, FUNC_BLOCK, Configuration::getBoolValue(), WindowManager::getFramerate(), LocalPlayer::getHalfAway(), Configuration::getIntValue(), IgnoreRecord_false, localChatTab, localPlayer, mAdjustLevel, mLowerCounter, mNextAdjustTime, Configuration::setSilent(), settings, Configuration::setValue(), and TryRemoveColors_true.
Referenced by slowLogic().
void Game::changeMap | ( | const std::string & | mapPath | ) |
Changes the currently active map. Should only be called while the game is running.
Definition at line 1093 of file game.cpp.
References actorManager, Map::addExtraLayer(), BLOCK_END, BLOCK_START, Viewport::cleanHoverItems(), ResourceManager::cleanProtected(), ActorManager::clear(), ParticleEngine::clear(), PopupManager::clearPopup(), PopupManager::closePopupMenu(), VirtFs::exists(), SoundManager::fadeOutAndPlayMusic(), SoundManager::fadeOutMusic(), gameHandler, MapDB::getMapName(), Map::getMusicFile(), ConfigurationObject::getValue(), Perf::init(), Map::initializeParticleEffects(), localPlayer, Net::GameHandler::mapLoadedEvent(), mCurrentMap, minimap, mMapName, particleEngine, pathJoin(), paths, questsWindow, MapReader::readMap(), Being::recreateItemParticles(), resetAdjustLevel(), Map::saveExtraLayer(), Minimap::setMap(), QuestsWindow::setMap(), ActorManager::setMap(), LocalPlayer::setMap(), SocialWindow::setMap(), ParticleEngine::setMap(), Viewport::setMap(), skipPerfFrames, socialWindow, soundManager, and viewport.
Referenced by Ea::GameHandler::initEngines(), and Ea::PlayerRecv::processPlayerWarp().
void Game::checkKeys | ( | ) |
Definition at line 1249 of file game.cpp.
References Settings::attackType, LastKey::cnt, cur_time, LastKey::key, localPlayer, MAX_LASTKEYS, mLastKeys, mValidSpeed, InputAction::NO_VALUE, settings, and LastKey::time.
|
inlinestatic |
|
private |
Definition at line 1279 of file game.cpp.
References LastKey::cnt, LastKey::key, MAX_LASTKEYS, mLastKeys, InputAction::NO_VALUE, and LastKey::time.
Referenced by Game(), and setValidSpeed().
|
static |
Definition at line 535 of file game.cpp.
References addWatermark(), config, Gui::draw(), Configuration::getBoolValue(), ScreenshotHelper::getScreenshot(), gui, mainGraphics, ScreenshotHelper::prepare(), saveScreenshot(), screenshortHelper, Actions::screenshot(), and Graphics::setSecure().
Referenced by TradeWindow::completeTrade().
|
inline |
Returns the currently active map.
Definition at line 107 of file game.h.
References mCurrentMap.
Referenced by ActorManager::findNearestPvpPlayer(), MapDebugTab::logic(), Ea::PlayerRecv::processMapMask(), EAthena::BeingRecv::processMapTypeProperty(), Ea::PlayerRecv::processPlayerWarp(), Ea::BeingRecv::processPvpMapMode(), and CompoundSprite::redraw().
|
inline |
Definition at line 110 of file game.h.
References mMapName.
Referenced by Ea::PlayerRecv::processPlayerWarp().
|
inline |
void Game::handleInput | ( | ) |
The huge input handling method.
Definition at line 1060 of file game.cpp.
References Settings::awayMode, BLOCK_END, BLOCK_START, InputAction::COPY_OUTFIT, eventsManager, EventsManager::handleGameEvents(), handleMove(), InputManager::handleRepeat(), inputManager, InputManager::isActionActive(), KeyboardConfig::isEnabled(), Window::isWindowVisible(), joystick, keyboard, Joystick::logic(), settings, setupWindow, and InputAction::WEAR_OUTFIT.
Referenced by EventsManager::handleEvents(), and logic().
void Game::handleMove | ( | ) |
Definition at line 920 of file game.cpp.
References BLOCK_END, BLOCK_START, LocalPlayer::cancelFollow(), LocalPlayer::canMove(), chatWindow, BeingDirection::DOWN, InputAction::EMOTE, NpcDialog::getActive(), Being::getDirection(), InputAction::HOMUN_EMOTE, InputAction::IGNORE_INPUT_1, InputAction::IGNORE_INPUT_2, inputManager, InputManager::isActionActive(), InventoryWindow::isAnyInputFocused(), Joystick::isDown(), ChatWindow::isInputFocused(), Joystick::isLeft(), Popup::isPopupVisible(), Joystick::isRight(), Joystick::isUp(), joystick, BeingDirection::LEFT, localPlayer, InputAction::MOVE_DOWN, InputAction::MOVE_FORWARD, InputAction::MOVE_LEFT, InputAction::MOVE_RIGHT, InputAction::MOVE_UP, moveInDirection(), InputAction::PET_EMOTE, popupMenu, quitDialog, BeingDirection::RIGHT, setValidSpeed(), InputAction::STOP_ATTACK, and BeingDirection::UP.
Referenced by handleInput().
|
inlinestatic |
Provides access to the game instance.
Definition at line 82 of file game.h.
References mInstance.
Referenced by OutfitWindow::action(), SetupWindow::action(), GameModifiers::changeAwayMode(), ChatWindow::chatInput(), ActorManager::findNearestPvpPlayer(), EventsManager::handleActive(), EventsManager::handleEvents(), EventsManager::handleGameEvents(), Ea::GameHandler::initEngines(), MapDebugTab::logic(), Ea::PlayerRecv::processMapMask(), EAthena::BeingRecv::processMapTypeProperty(), Ea::PlayerRecv::processPlayerWarp(), Ea::BeingRecv::processPvpMapMode(), CompoundSprite::redraw(), WindowManager::resizeVideo(), TmwAthena::AdminHandler::slide(), InputManager::updateConditionMask(), and Viewport::validateSpeed().
void Game::logic | ( | ) |
This method takes the game a small step further. It is called 100 times per second.
Definition at line 663 of file game.cpp.
References actorManager, BLOCK_END, BLOCK_START, handleInput(), ActorManager::logic(), mCurrentMap, particleEngine, ParticleEngine::update(), and Map::update().
|
static |
Definition at line 1005 of file game.cpp.
References Settings::cameraMode, BeingDirection::DOWN, BeingDirection::LEFT, localPlayer, Viewport::moveCamera(), BeingDirection::RIGHT, settings, LocalPlayer::specialMove(), BeingDirection::UP, and viewport.
Referenced by handleMove().
void Game::resetAdjustLevel | ( | ) |
Definition at line 889 of file game.cpp.
References adjustDelay, config, cur_time, ParticleEngine::emitterSkip, Configuration::getBoolValue(), Configuration::getIntValue(), mAdjustLevel, mAdjustPerfomance, mNextAdjustTime, and Configuration::setValue().
Referenced by SetupWindow::action(), changeMap(), and ~Game().
|
static |
Definition at line 563 of file game.cpp.
References _, branding, ChatMsgType::BY_SERVER, ChatTab::chatLog(), cutFirst(), VirtFs::getUserDir(), ConfigurationObject::getValue(), IgnoreRecord_false, localChatTab, Logger::log(), Logger::log1(), logger, mkdir_r(), MSDL_FreeSurface, Actions::screenshot(), Settings::screenshotDir, Settings::serverName, settings, strprintf(), TryRemoveColors_true, and PngLib::writePNG().
Referenced by createScreenshot().
|
inline |
void Game::setValidSpeed | ( | ) |
Definition at line 1273 of file game.cpp.
References clearKeysArray(), and mValidSpeed.
Referenced by OutfitWindow::action(), ChatWindow::chatInput(), handleMove(), and Viewport::validateSpeed().
void Game::slowLogic | ( | ) |
Definition at line 679 of file game.cpp.
References _, Widget::addActionListener(), adjustDelay, adjustPerfomance(), BLOCK_END, BLOCK_START, State::CHANGE_MAP, client, DialogsManager::closeDialogs(), config, cur_time, debugWindow, DelayedManager::delayedLoad(), disconnectedDialog, effectManager, State::ERROR, errorListener, errorMessage, gameHandler, get_elapsed_time1(), Configuration::getIntValue(), Viewport::getMap(), Graphics::getOpenGL(), Client::getState(), guildManager, Net::GameHandler::isConnected(), killStats, localPlayer, EffectManager::logic(), mAdjustPerfomance, mainGraphics, mNextAdjustTime, Modal_false, mPing, mTime, mTime2, Net::GameHandler::mustPing(), mValidSpeed, DialogsManager::openErrorDialog(), Net::GameHandler::ping(), KillStats::recalcStats(), RENDER_SOFTWARE, Widget::requestMoveToTop(), Being::reReadConfig(), Map::saveExtraLayer(), Window::scheduleDelete(), serverConfig, WindowManager::setFramerate(), shopWindow, skillDialog, LocalPlayer::slowLogic(), DebugWindow::slowLogic(), SkillDialog::slowLogic(), SocialWindow::slowLogic(), WhoIsOnline::slowLogic(), GuildManager::slowLogic(), socialWindow, tick_time, KillStats::update(), PacketCounters::update(), ShopWindow::updateTimes(), valTest, viewport, whoIsOnline, and Configuration::writeUpdated().
void Game::updateFrameRate | ( | int | fpsLimit | ) |
Definition at line 1032 of file game.cpp.
References adjustDelay, Settings::awayMode, config, cur_time, Configuration::getIntValue(), Settings::inputFocused, mNextAdjustTime, Settings::mouseFocused, WindowManager::setFramerate(), settings, and KeyboardFocus::Unfocused.
Referenced by GameModifiers::changeAwayMode(), and EventsManager::handleActive().
void Game::updateHistory | ( | const SDL_Event & | event | ) |
Definition at line 1192 of file game.cpp.
References Settings::attackType, CAST_S32, LastKey::cnt, cur_time, KeyboardConfig::getKeyIndex(), LastKey::key, localPlayer, MAX_LASTKEYS, mLastKeys, InputAction::NO_VALUE, settings, and LastKey::time.
|
static |
Definition at line 1289 of file game.cpp.
References Widget::getWidth(), Widget::setPosition(), Widget::setSize(), viewport, and windowMenu.
Referenced by WindowManager::resizeVideo().
|
private |
Definition at line 148 of file game.h.
Referenced by adjustPerfomance(), resetAdjustLevel(), and setAdjustLevel().
|
private |
Definition at line 149 of file game.h.
Referenced by resetAdjustLevel(), and slowLogic().
|
private |
Definition at line 143 of file game.h.
Referenced by changeMap(), getCurrentMap(), logic(), and ~Game().
|
staticprivate |
Definition at line 155 of file game.h.
Referenced by clearInstance(), Game(), instance(), and ~Game().
|
private |
Definition at line 146 of file game.h.
Referenced by checkKeys(), clearKeysArray(), and updateHistory().
|
private |
Definition at line 150 of file game.h.
Referenced by adjustPerfomance().
|
private |
Definition at line 144 of file game.h.
Referenced by changeMap(), and getCurrentMapName().
|
private |
Definition at line 147 of file game.h.
Referenced by adjustPerfomance(), resetAdjustLevel(), slowLogic(), and updateFrameRate().
|
private |
Definition at line 151 of file game.h.
Referenced by slowLogic().
|
private |
Definition at line 152 of file game.h.
Referenced by slowLogic().
|
private |
Definition at line 153 of file game.h.
Referenced by slowLogic().
|
private |
Definition at line 145 of file game.h.
Referenced by checkKeys(), getValidSpeed(), setValidSpeed(), and slowLogic().