diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-02-15 17:01:46 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-02-15 17:01:46 +0300 |
commit | 382067b05c4fe97bcf0da0143405375ec295f7c6 (patch) | |
tree | f668cd2595ac0c85f0942f88729d3ff1956676fa /src | |
parent | ee8191705826d978b7793497fdd307536c709bff (diff) | |
parent | 9b329556e748050c4300174e9bdc72b15e5b8cc5 (diff) | |
download | plus-382067b05c4fe97bcf0da0143405375ec295f7c6.tar.gz plus-382067b05c4fe97bcf0da0143405375ec295f7c6.tar.bz2 plus-382067b05c4fe97bcf0da0143405375ec295f7c6.tar.xz plus-382067b05c4fe97bcf0da0143405375ec295f7c6.zip |
Merge branch 'master' into stable
Diffstat (limited to 'src')
179 files changed, 1030 insertions, 748 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 059eef64f..29e5afcb0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -335,8 +335,8 @@ SET(SRCS gui/windows/selldialog.h gui/windows/serverdialog.cpp gui/windows/serverdialog.h - gui/windows/setup.cpp - gui/windows/setup.h + gui/windows/setupwindow.cpp + gui/windows/setupwindow.h gui/widgets/tabs/setup_audio.cpp gui/widgets/tabs/setup_audio.h gui/widgets/tabs/setup_colors.cpp @@ -725,6 +725,7 @@ SET(SRCS being/playerinfo.h being/playerrelations.cpp being/playerrelations.h + being/playerrelationslistener.h position.cpp position.h properties.h diff --git a/src/Makefile.am b/src/Makefile.am index ba0fbc800..7fb4541a1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -469,8 +469,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/windows/selldialog.h \ gui/windows/serverdialog.cpp \ gui/windows/serverdialog.h \ - gui/windows/setup.cpp \ - gui/windows/setup.h \ + gui/windows/setupwindow.cpp \ + gui/windows/setupwindow.h \ gui/widgets/tabs/setup_audio.cpp \ gui/widgets/tabs/setup_audio.h \ gui/widgets/tabs/setup_colors.cpp \ @@ -861,6 +861,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ being/playerinfo.h \ being/playerrelations.cpp \ being/playerrelations.h \ + being/playerrelationslistener.h \ position.cpp \ position.h \ properties.h \ diff --git a/src/actionmanager.cpp b/src/actionmanager.cpp index bc7be23a9..1c7dbce14 100644 --- a/src/actionmanager.cpp +++ b/src/actionmanager.cpp @@ -40,6 +40,7 @@ #include "gui/windows/skilldialog.h" #include "gui/windows/socialwindow.h" #include "gui/windows/statuswindow.h" +#include "gui/windows/tradewindow.h" #include "gui/windows/questswindow.h" #include "gui/windows/quitdialog.h" #include "gui/windows/whoisonline.h" @@ -57,7 +58,7 @@ #include "gui/windows/ministatuswindow.h" #include "gui/windows/npcdialog.h" #include "gui/windows/outfitwindow.h" -#include "gui/windows/setup.h" +#include "gui/windows/setupwindow.h" #include "gui/windows/shopwindow.h" #include "gui/windows/shortcutwindow.h" @@ -67,6 +68,7 @@ #include "net/net.h" #include "net/playerhandler.h" +#include "net/tradehandler.h" #include "utils/gettext.h" @@ -82,6 +84,7 @@ #define impHandler0(name) bool name(const InputEvent &event A_UNUSED) extern ShortcutWindow *spellShortcutWindow; +extern std::string tradePartnerName; extern QuitDialog *quitDialog; namespace ActionManager @@ -215,7 +218,7 @@ impHandler0(mouseClick) return false; int mouseX, mouseY; - gui->getMouseState(&mouseX, &mouseY); + Gui::getMouseState(&mouseX, &mouseY); guiInput->simulateMouseClick(mouseX, mouseY, gcn::MouseEvent::RIGHT); return true; } @@ -1149,4 +1152,58 @@ impHandler0(showWindows) return false; } +impHandler0(nextShortcutsTab) +{ + if (itemShortcutWindow) + { + itemShortcutWindow->nextTab(); + return true; + } + return false; +} + +impHandler0(prevShortcutsTab) +{ + if (itemShortcutWindow) + { + itemShortcutWindow->prevTab(); + return true; + } + return false; +} + +impHandler0(nextCommandsTab) +{ + if (spellShortcutWindow) + { + spellShortcutWindow->nextTab(); + return true; + } + return false; +} + +impHandler0(prevCommandsTab) +{ + if (spellShortcutWindow) + { + spellShortcutWindow->prevTab(); + return true; + } + return false; +} + +impHandler0(openTrade) +{ + const Being *const being = player_node->getTarget(); + if (being && being->getType() == ActorSprite::PLAYER) + { + Net::getTradeHandler()->request(being); + tradePartnerName = being->getName(); + if (tradeWindow) + tradeWindow->clear(); + return true; + } + return false; +} + } // namespace ActionManager diff --git a/src/actionmanager.h b/src/actionmanager.h index a2df14202..ca8c3e2b9 100644 --- a/src/actionmanager.h +++ b/src/actionmanager.h @@ -94,6 +94,11 @@ namespace ActionManager decHandler(stopSit); decHandler(showKeyboard); decHandler(showWindows); + decHandler(nextShortcutsTab); + decHandler(prevShortcutsTab); + decHandler(nextCommandsTab); + decHandler(prevCommandsTab); + decHandler(openTrade); decHandler(hideWindows); decHandler(helpWindowShow); diff --git a/src/actormanager.cpp b/src/actormanager.cpp index f55875351..9661dc2fe 100644 --- a/src/actormanager.cpp +++ b/src/actormanager.cpp @@ -37,6 +37,8 @@ #include "gui/windows/equipmentwindow.h" #include "gui/windows/socialwindow.h" +#include "input/inputmanager.h" + #include "utils/checkutils.h" #include "utils/gettext.h" @@ -327,6 +329,7 @@ Being *ActorManager::findBeingByPixel(const int x, const int y, return nullptr; const bool targetDead = mTargetDeadPlayers; + const bool modActive = inputManager.isActionActive(Input::KEY_STOP_ATTACK); if (mExtMouseTargeting) { @@ -360,8 +363,11 @@ Being *ActorManager::findBeingByPixel(const int x, const int y, Being *const being = static_cast<Being*>(*it); - if (being->getInfo() && !being->getInfo()->isTargetSelection()) + if (being->getInfo() && !(being->getInfo()->isTargetSelection() + || modActive)) + { continue; + } if ((being->isAlive() || (targetDead && being->getType() == Being::PLAYER)) @@ -406,8 +412,11 @@ Being *ActorManager::findBeingByPixel(const int x, const int y, Being *const being = static_cast<Being*>(*it); - if (being->getInfo() && !being->getInfo()->isTargetSelection()) + if (being->getInfo() && !(being->getInfo()->isTargetSelection() + || modActive)) + { continue; + } if ((being->getPixelX() - mapTileSize / 2 <= x) && (being->getPixelX() + mapTileSize / 2 > x) && @@ -430,6 +439,7 @@ void ActorManager::findBeingsByPixel(std::vector<ActorSprite*> &beings, const int xtol = mapTileSize / 2; const int uptol = mapTileSize; + const bool modActive = inputManager.isActionActive(Input::KEY_STOP_ATTACK); for_actors { @@ -442,7 +452,7 @@ void ActorManager::findBeingsByPixel(std::vector<ActorSprite*> &beings, const Being *const being = dynamic_cast<const Being*>(*it); if (being && being->getInfo() - && !being->getInfo()->isTargetSelection()) + && !(being->getInfo()->isTargetSelection() || modActive)) { continue; } @@ -879,6 +889,7 @@ Being *ActorManager::findNearestLivingBeing(const Being *const aroundBeing, const bool filtered = config.getBoolValue("enableAttackFilter") && type == Being::MONSTER; + const bool modActive = inputManager.isActionActive(Input::KEY_STOP_ATTACK); bool ignoreDefault = false; if (filtered) @@ -935,8 +946,11 @@ Being *ActorManager::findNearestLivingBeing(const Being *const aroundBeing, } } - if (being->getInfo() && !being->getInfo()->isTargetSelection()) + if (being->getInfo() + && !(being->getInfo()->isTargetSelection() || modActive)) + { continue; + } if (validateBeing(aroundBeing, being, type, nullptr, maxDist)) { @@ -1029,8 +1043,11 @@ Being *ActorManager::findNearestLivingBeing(const Being *const aroundBeing, } } - if (being->getInfo() && !being->getInfo()->isTargetSelection()) + if (being->getInfo() + && !(being->getInfo()->isTargetSelection() || modActive)) + { continue; + } const bool valid = validateBeing(aroundBeing, being, type, excluded, 50); @@ -1556,7 +1573,7 @@ void ActorManager::rebuildPickupItems() } int ActorManager::getIndexByName(const std::string &name, - const std::map<std::string, int> &map) const + const std::map<std::string, int> &map) { const std::map<std::string, int>::const_iterator i = map.find(name); diff --git a/src/actormanager.h b/src/actormanager.h index 9ccd5eaa6..17bd696d6 100644 --- a/src/actormanager.h +++ b/src/actormanager.h @@ -296,8 +296,9 @@ class ActorManager final: public ConfigListener int getPickupItemIndex(const std::string &name) const A_WARN_UNUSED; - int getIndexByName(const std::string &name, const std::map<std::string, - int> &map) const A_WARN_UNUSED; + static int getIndexByName(const std::string &name, + const std::map<std::string, int> &map) + A_WARN_UNUSED; bool checkForPickup(const FloorItem *const item) const A_WARN_UNUSED; diff --git a/src/being/being.cpp b/src/being/being.cpp index f9667ca33..fef3ca53a 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -2964,7 +2964,7 @@ int Being::searchSlotValue(const std::vector<int> &slotRemap, void Being::searchSlotValueItr(std::vector<int>::iterator &it, int &idx, std::vector<int> &slotRemap, - const int val) const + const int val) { // logger->log("searching %d", val); it = slotRemap.begin(); @@ -3052,7 +3052,7 @@ std::string Being::loadComment(const std::string &name, const int type) str.append(stringToHexPath(name)).append("/comment.txt"); const ResourceManager *const resman = ResourceManager::getInstance(); - if (resman->existsLocal(str)) + if (ResourceManager::existsLocal(str)) { StringVect lines; resman->loadTextFileLocal(str, lines); @@ -3078,8 +3078,7 @@ void Being::saveComment(const std::string &restrict name, return; } dir.append(stringToHexPath(name)); - const ResourceManager *const resman = ResourceManager::getInstance(); - resman->saveTextFile(dir, "comment.txt", + ResourceManager::saveTextFile(dir, "comment.txt", (name + "\n").append(comment)); } diff --git a/src/being/being.h b/src/being/being.h index d3dfe2cc1..b9039bce3 100644 --- a/src/being/being.h +++ b/src/being/being.h @@ -1025,9 +1025,10 @@ class Being : public ActorSprite, public ConfigListener int searchSlotValue(const std::vector<int> &slotRemap, const int val) const A_WARN_UNUSED; - void searchSlotValueItr(std::vector<int>::iterator &it, int &idx, - std::vector<int> &slotRemap, - const int val) const; + static void searchSlotValueItr(std::vector<int>::iterator &it, + int &idx, + std::vector<int> &slotRemap, + const int val); void dumpSprites() const; diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp index 41688cbf3..86db69d8d 100644 --- a/src/being/localplayer.cpp +++ b/src/being/localplayer.cpp @@ -62,10 +62,13 @@ #include "net/chathandler.h" #include "net/inventoryhandler.h" #include "net/net.h" +#include "net/pethandler.h" #include "net/playerhandler.h" #include "resources/iteminfo.h" +#include "resources/db/emotedb.h" + #include "utils/gettext.h" #include "utils/timer.h" @@ -2118,7 +2121,7 @@ static const char *const debugPathStrings[] = N_("(b) black & white map view") }; -std::string LocalPlayer::getDebugPathString() const +std::string LocalPlayer::getDebugPathString() { return gettext(getVarItem(&debugPathStrings[0], viewport->getDebugPath(), debugPathSize)); @@ -2274,7 +2277,7 @@ static const char *const cameraModeStrings[] = N_("(?) away") }; -std::string LocalPlayer::getCameraModeString() const +std::string LocalPlayer::getCameraModeString() { return gettext(getVarItem(&cameraModeStrings[0], viewport->getCameraMode(), cameraModeSize)); @@ -2793,9 +2796,9 @@ void LocalPlayer::crazyMoveA() signed char param = mMoveProgram[mCrazyMoveState++]; if (param == '?') { - const char cmd[] = {'l', 'r', 'u', 'd'}; + const char cmd[] = {'l', 'r', 'u', 'd', 'L', 'R', 'U', 'D'}; srand(tick_time); - param = cmd[rand() % 4]; + param = cmd[rand() % 8]; } switch (param) { @@ -2811,26 +2814,38 @@ void LocalPlayer::crazyMoveA() case 'r': move(1, 0); break; + case 'D': + move(1, 1); + break; + case 'U': + move(-1, -1); + break; + case 'L': + move(-1, 1); + break; + case 'R': + move(1, -1); + break; case 'f': - switch (mDirection) - { - case UP : dy = -1; break; - case DOWN : dy = 1; break; - case LEFT : dx = -1; break; - case RIGHT: dx = 1; break; - default: break; - } + if (mDirection | UP) + dy = -1; + else if (mDirection | DOWN) + dy = 1; + if (mDirection | LEFT) + dx = -1; + else if (mDirection | RIGHT) + dx = 1; move(dx, dy); break; case 'b': - switch (mDirection) - { - case UP : dy = 1; break; - case DOWN : dy = -1; break; - case LEFT : dx = 1; break; - case RIGHT: dx = -1; break; - default: break; - } + if (mDirection | UP) + dy = 1; + else if (mDirection | DOWN) + dy = -1; + if (mDirection | LEFT) + dx = 1; + else if (mDirection | RIGHT) + dx = -1; move(dx, dy); break; default: @@ -2981,22 +2996,31 @@ void LocalPlayer::crazyMoveA() pickUpItems(); } // emote - else if (mMoveProgram[mCrazyMoveState] == 'e') + else if (mMoveProgram[mCrazyMoveState] == 'e' + || mMoveProgram[mCrazyMoveState] == 'E') { mCrazyMoveState ++; const signed char emo = mMoveProgram[mCrazyMoveState]; + unsigned char emoteId = 0; if (emo == '?') { srand(tick_time); - emote(static_cast<unsigned char>(1 + (rand() % 13))); + emoteId = static_cast<unsigned char>( + 1 + (rand() % EmoteDB::size())); } else { if (emo >= '0' && emo <= '9') - emote(static_cast<unsigned char>(emo - '0' + 1)); - else if (emo >= 'a' && emo <= 'd') - emote(static_cast<unsigned char>(emo - 'a' + 11)); + emoteId = static_cast<unsigned char>(emo - '0' + 1); + else if (emo >= 'a' && emo <= 'z') + emoteId = static_cast<unsigned char>(emo - 'a' + 11); + else if (emo >= 'A' && emo <= 'Z') + emoteId = static_cast<unsigned char>(emo - 'A' + 37); } + if (mMoveProgram[mCrazyMoveState] == 'e') + emote(emoteId); + else + Net::getPetHandler()->emote(emoteId, 0); mCrazyMoveState ++; } @@ -3229,7 +3253,7 @@ void LocalPlayer::specialMove(const unsigned char direction) } } -void LocalPlayer::debugMsg(const std::string &str) const +void LocalPlayer::debugMsg(const std::string &str) { if (debugChatTab) debugChatTab->chatLog(str); @@ -4317,7 +4341,7 @@ bool LocalPlayer::checAttackPermissions(const Being *const target) const const char *LocalPlayer::getVarItem(const char *const *const arr, const unsigned index, - const unsigned sz) const + const unsigned sz) { if (index < sz) return arr[index]; diff --git a/src/being/localplayer.h b/src/being/localplayer.h index 88a6f6754..6ba12bd56 100644 --- a/src/being/localplayer.h +++ b/src/being/localplayer.h @@ -297,7 +297,7 @@ class LocalPlayer final : public Being, void moveToHome(); - void debugMsg(const std::string &str) const; + static void debugMsg(const std::string &str); bool isReachable(Being *const being, const int maxCost = 0) A_WARN_UNUSED; @@ -331,7 +331,7 @@ class LocalPlayer final : public Being, void afkRespond(ChatTab *const tab, const std::string &nick); - void setAfkMessage(std::string message); + static void setAfkMessage(std::string message); bool navigateTo(const int x, const int y); @@ -489,7 +489,7 @@ class LocalPlayer final : public Being, std::string getPickUpTypeString(); - std::string getDebugPathString() const; + static std::string getDebugPathString(); std::string getMagicAttackString(); @@ -499,7 +499,7 @@ class LocalPlayer final : public Being, std::string getAwayModeString(); - std::string getCameraModeString() const; + static std::string getCameraModeString(); std::string getGameModifiersString(); @@ -522,11 +522,12 @@ class LocalPlayer final : public Being, static void tryMagic(const std::string &spell, const int baseMagic, const int schoolMagic, const int mana); - const char *getVarItem(const char *const *const arr, - const unsigned index, - const unsigned sz) const A_WARN_UNUSED; + static const char *getVarItem(const char *const *const arr, + const unsigned index, + const unsigned sz) A_WARN_UNUSED; - void changeMode(unsigned *restrict const var, const unsigned limit, + void changeMode(unsigned *restrict const var, + const unsigned limit, const char *restrict const conf, std::string (LocalPlayer::*const func)(), const unsigned def = 0, diff --git a/src/being/playerrelations.cpp b/src/being/playerrelations.cpp index f3e921be3..a04c77e76 100644 --- a/src/being/playerrelations.cpp +++ b/src/being/playerrelations.cpp @@ -600,7 +600,7 @@ bool PlayerRelationsManager::isGoodName(Being *const being) const return status; } -bool PlayerRelationsManager::checkName(const std::string &name) const +bool PlayerRelationsManager::checkName(const std::string &name) { const size_t size = name.size(); const std::string check = config.getStringValue("unsecureChars"); diff --git a/src/being/playerrelations.h b/src/being/playerrelations.h index f37e33d89..360930879 100644 --- a/src/being/playerrelations.h +++ b/src/being/playerrelations.h @@ -25,6 +25,8 @@ #include "utils/stringvector.h" +#include "being/playerrelationslistener.h" + #include <list> #include <map> @@ -97,21 +99,6 @@ class PlayerIgnoreStrategy } }; -class PlayerRelationsListener -{ - public: - virtual ~PlayerRelationsListener() - { } - - virtual void updatedPlayer(const std::string &name) = 0; - - virtual void updateAll() = 0; - - protected: - PlayerRelationsListener() - { } -}; - /** * Player relations class, represents any particular relations and/or * preferences the user of the local client has wrt other players (identified @@ -270,7 +257,7 @@ class PlayerRelationsManager final // ignored data upon reloading unsigned int mDefaultPermissions; - bool checkName(const std::string &name) const A_WARN_UNUSED; + static bool checkName(const std::string &name) A_WARN_UNUSED; PlayerIgnoreStrategy *mIgnoreStrategy; std::map<std::string, PlayerRelation *> mRelations; diff --git a/src/being/playerrelationslistener.h b/src/being/playerrelationslistener.h new file mode 100644 index 000000000..983f731e4 --- /dev/null +++ b/src/being/playerrelationslistener.h @@ -0,0 +1,43 @@ +/* + * The ManaPlus Client + * Copyright (C) 2008-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef BEING_PLAYERRELATIONSLISTENER_H +#define BEING_PLAYERRELATIONSLISTENER_H + +#include <string> + +class PlayerRelationsListener +{ + public: + virtual ~PlayerRelationsListener() + { } + + virtual void updatedPlayer(const std::string &name) = 0; + + virtual void updateAll() = 0; + + protected: + PlayerRelationsListener() + { } +}; + +#endif // BEING_PLAYERRELATIONSLISTENER_H diff --git a/src/chatlogger.cpp b/src/chatlogger.cpp index c3da6e0b1..2bfe4933b 100644 --- a/src/chatlogger.cpp +++ b/src/chatlogger.cpp @@ -131,7 +131,7 @@ std::string ChatLogger::getDir() const return date; } -std::string ChatLogger::secureName(std::string &name) const +std::string ChatLogger::secureName(std::string &name) { const unsigned int sz = name.length(); for (unsigned int f = 0; f < sz; f ++) @@ -151,7 +151,8 @@ std::string ChatLogger::secureName(std::string &name) const return name; } -void ChatLogger::writeTo(std::ofstream &file, const std::string &str) const +void ChatLogger::writeTo(std::ofstream &file, + const std::string &str) { file << str << std::endl; } diff --git a/src/chatlogger.h b/src/chatlogger.h index c95cea7fe..ae0e21388 100644 --- a/src/chatlogger.h +++ b/src/chatlogger.h @@ -55,7 +55,7 @@ class ChatLogger final std::string getDir() const A_WARN_UNUSED; - std::string secureName(std::string &str) const; + static std::string secureName(std::string &str); void setServerName(const std::string &serverName); @@ -72,7 +72,7 @@ class ChatLogger final void setLogDir(const std::string &logDir); - void writeTo(std::ofstream &file, const std::string &str) const; + static void writeTo(std::ofstream &file, const std::string &str); std::ofstream mLogFile; std::string mLogDir; diff --git a/src/client.cpp b/src/client.cpp index 4d301ccfe..ab3add135 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -66,7 +66,7 @@ #include "gui/windows/registerdialog.h" #include "gui/windows/selldialog.h" #include "gui/windows/serverdialog.h" -#include "gui/windows/setup.h" +#include "gui/windows/setupwindow.h" #include "gui/windows/unregisterdialog.h" #include "gui/windows/updaterwindow.h" #include "gui/windows/quitdialog.h" @@ -527,7 +527,7 @@ void Client::initSoundManager() void Client::createWindows() { userPalette = new UserPalette; - setupWindow = new Setup; + setupWindow = new SetupWindow; setupWindow->postInit(); helpWindow = new HelpWindow; didYouKnowWindow = new DidYouKnowWindow; @@ -2106,7 +2106,7 @@ void Client::initServerConfig(std::string serverName) dropShortcut = new DropShortcut; } -void Client::initFeatures() const +void Client::initFeatures() { features.init(paths.getStringValue("featuresFile"), true); features.setDefaultValues(getFeaturesDefaults()); @@ -2337,7 +2337,7 @@ void Client::initScreenshotDir() logger->log("screenshotDirectory: " + mScreenshotDir); } -void Client::accountLogin(LoginData *const data) const +void Client::accountLogin(LoginData *const data) { if (!data) return; @@ -2758,7 +2758,7 @@ bool Client::limitPackets(const int type) return true; } -void Client::setFramerate(const int fpsLimit) +void Client::setFramerate(const int fpsLimit) const { if (!fpsLimit) return; @@ -3012,7 +3012,7 @@ void Client::setIcon() #else iconFile.append(".png"); #endif - iconFile = ResourceManager::getInstance()->getPath(iconFile); + iconFile = ResourceManager::getPath(iconFile); logger->log("Loading icon from file: %s", iconFile.c_str()); #ifdef WIN32 diff --git a/src/client.h b/src/client.h index 92daff44b..22567ae94 100644 --- a/src/client.h +++ b/src/client.h @@ -285,7 +285,7 @@ public: static void closeDialogs(); - void setFramerate(const int fpsLimit); + void setFramerate(const int fpsLimit) const; int getFramerate() const A_WARN_UNUSED; @@ -335,9 +335,9 @@ public: const bool modal); private: - void createWindows(); + static void createWindows(); - void initLang(); + static void initLang(); void initSoundManager(); @@ -347,7 +347,7 @@ private: void initTitle(); - void extractDataDir(); + static void extractDataDir(); void mountDataDir(); @@ -369,9 +369,9 @@ private: void initServerConfig(std::string serverName); - void initFeatures() const; + static void initFeatures(); - void accountLogin(LoginData *const data) const; + static void accountLogin(LoginData *const data); #ifndef ANDROID void storeSafeParameters() const; @@ -383,9 +383,9 @@ private: void testsClear(); - void logVars(); + static void logVars(); - void checkConfigVersion(); + static void checkConfigVersion(); void setIcon(); diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index 8409b8d58..6d3881432 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -68,7 +68,7 @@ void CommandHandler::handleCommands(const std::string &command, } void CommandHandler::handleCommand(const std::string &command, - ChatTab *const tab) + ChatTab *const tab) const { const size_t pos = command.find(' '); const std::string type(command, 0, pos); diff --git a/src/commandhandler.h b/src/commandhandler.h index 02ced5630..de1561d74 100644 --- a/src/commandhandler.h +++ b/src/commandhandler.h @@ -62,7 +62,7 @@ class CommandHandler final * Parse and handle the given command. */ void handleCommand(const std::string &command, - ChatTab *const tab = localChatTab); + ChatTab *const tab = localChatTab) const; void handleCommands(const std::string &command, ChatTab *const tab = localChatTab); diff --git a/src/dragdrop.h b/src/dragdrop.h index 42d01c238..99cfb1ee7 100644 --- a/src/dragdrop.h +++ b/src/dragdrop.h @@ -75,10 +75,10 @@ class DragDrop final mItemImage->decRef(); } - int getItem() + int getItem() const { return mItem; } - int getItemColor() + int getItemColor() const { return mItemColor; } Image *getItemImage() diff --git a/src/dropshortcut.h b/src/dropshortcut.h index b4450127f..85c0b6620 100644 --- a/src/dropshortcut.h +++ b/src/dropshortcut.h @@ -71,7 +71,7 @@ class DropShortcut final /** * Returns the amount of shortcut items. */ - int getItemCount() const A_WARN_UNUSED + static int getItemCount() A_WARN_UNUSED { return DROP_SHORTCUT_ITEMS; } /** diff --git a/src/dyetool/dyemain.cpp b/src/dyetool/dyemain.cpp index c11cdd162..0699ce1ff 100644 --- a/src/dyetool/dyemain.cpp +++ b/src/dyetool/dyemain.cpp @@ -95,6 +95,9 @@ int main(int argc, char **argv) printf("Error loading image\n"); return 1; } - ImageWriter::writePNG(image->getSDLSurface(), dst); + SDL_Surface *const surface = imageHelper->convertTo32Bit( + image->getSDLSurface()); + ImageWriter::writePNG(surface, dst); + SDL_FreeSurface(surface); return 0; } diff --git a/src/emoteshortcut.h b/src/emoteshortcut.h index 0b5859fe9..3e03a18f5 100644 --- a/src/emoteshortcut.h +++ b/src/emoteshortcut.h @@ -60,7 +60,7 @@ class EmoteShortcut final /** * Returns the amount of shortcut Emotes. */ - unsigned int getEmoteCount() const A_WARN_UNUSED + static unsigned int getEmoteCount() A_WARN_UNUSED { return SHORTCUT_EMOTES; } /** diff --git a/src/eventsmanager.cpp b/src/eventsmanager.cpp index 237e7bf68..3062ac3d2 100644 --- a/src/eventsmanager.cpp +++ b/src/eventsmanager.cpp @@ -60,7 +60,7 @@ void EventsManager::shutdown() config.removeListeners(this); } -bool EventsManager::handleCommonEvents(const SDL_Event &event) +bool EventsManager::handleCommonEvents(const SDL_Event &event) const { if (mLogInput) logEvent(event); @@ -100,7 +100,7 @@ bool EventsManager::handleCommonEvents(const SDL_Event &event) return false; } -bool EventsManager::handleEvents() +bool EventsManager::handleEvents() const { if (Game::instance()) { @@ -157,7 +157,7 @@ bool EventsManager::handleEvents() return false; } -void EventsManager::handleGameEvents() +void EventsManager::handleGameEvents() const { Game *const game = Game::instance(); diff --git a/src/eventsmanager.h b/src/eventsmanager.h index 7bf1eea24..5433a83fb 100644 --- a/src/eventsmanager.h +++ b/src/eventsmanager.h @@ -42,11 +42,11 @@ class EventsManager final : public ConfigListener void shutdown(); - bool handleEvents(); + bool handleEvents() const; - bool handleCommonEvents(const SDL_Event &event); + bool handleCommonEvents(const SDL_Event &event) const; - void handleGameEvents(); + void handleGameEvents() const; #ifdef USE_SDL2 static void handleSDL2WindowEvent(const SDL_Event &event); diff --git a/src/game.cpp b/src/game.cpp index 6e4341372..26807b8b6 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -68,7 +68,7 @@ #include "gui/windows/npcdialog.h" #include "gui/windows/okdialog.h" #include "gui/windows/outfitwindow.h" -#include "gui/windows/setup.h" +#include "gui/windows/setupwindow.h" #include "gui/windows/shopwindow.h" #include "gui/windows/shortcutwindow.h" #include "gui/windows/skilldialog.h" @@ -962,7 +962,7 @@ void Game::handleInput() } handleMove(); - inputManager.handleRepeat(); + InputManager::handleRepeat(); BLOCK_END("Game::handleInput 1") } @@ -1175,7 +1175,7 @@ void Game::closeDialogs() } } -void Game::videoResized(const int width, const int height) const +void Game::videoResized(const int width, const int height) { if (viewport) viewport->setSize(width, height); diff --git a/src/game.h b/src/game.h index 08349cdaa..023796290 100644 --- a/src/game.h +++ b/src/game.h @@ -107,12 +107,12 @@ class Game final static void closeDialogs(); - void videoResized(const int width, const int height) const; + static void videoResized(const int width, const int height); bool getValidSpeed() const A_WARN_UNUSED { return mValidSpeed; } - void moveInDirection(const unsigned char direction); + static void moveInDirection(const unsigned char direction); static bool createScreenshot(); diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp index 00cceb22f..b40f8df57 100644 --- a/src/graphicsmanager.cpp +++ b/src/graphicsmanager.cpp @@ -546,7 +546,7 @@ bool GraphicsManager::supportExtension(const std::string &ext) const return mExtensions.find(ext) != mExtensions.end(); } -void GraphicsManager::updateTextureFormat() +void GraphicsManager::updateTextureFormat() const { const int compressionFormat = config.getIntValue("compresstextures"); if (compressionFormat) diff --git a/src/graphicsmanager.h b/src/graphicsmanager.h index 744514ed2..8e5aba51f 100644 --- a/src/graphicsmanager.h +++ b/src/graphicsmanager.h @@ -78,7 +78,7 @@ class GraphicsManager final void initGraphics(const bool noOpenGL); - void setVideoMode(); + static void setVideoMode(); SDL_Window *createWindow(const int w, const int h, const int bpp, const int flags); @@ -94,7 +94,7 @@ class GraphicsManager final std::string getDensityString() const; - int getDensity() + int getDensity() const { return mDensity; } #ifdef USE_OPENGL @@ -104,7 +104,7 @@ class GraphicsManager final bool supportExtension(const std::string &ext) const A_WARN_UNUSED; - void updateTextureFormat(); + void updateTextureFormat() const; bool checkGLVersion(const int major, const int minor) const A_WARN_UNUSED; @@ -154,7 +154,7 @@ class GraphicsManager final void updateDebugLog() const; - std::string getGLVersion() + std::string getGLVersion() const { return mGlVersionString; } #endif diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index dcd4d82ea..126fc9a3b 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -940,7 +940,7 @@ void Gui::removeDragged(gcn::Widget *widget) mFocusHandler->setDraggedWidget(nullptr); } -uint32_t Gui::getMouseState(int *const x, int *const y) const +uint32_t Gui::getMouseState(int *const x, int *const y) { const uint32_t res = SDL_GetMouseState(x, y); const int scale = mainGraphics->getScale(); diff --git a/src/gui/gui.h b/src/gui/gui.h index 033a71282..5fddc7df7 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -147,8 +147,9 @@ class Gui final : public gcn::Gui MouseEvent *createMouseEvent(Window *const widget) A_WARN_UNUSED; - void getAbsolutePosition(gcn::Widget *restrict widget, - int &restrict x, int &restrict y); + static void getAbsolutePosition(gcn::Widget *restrict widget, + int &restrict x, + int &restrict y); void addGlobalFocusListener(gcn::FocusListener* focusListener); @@ -164,7 +165,7 @@ class Gui final : public gcn::Gui int getLastMouseY() const { return mLastMouseY; } - uint32_t getMouseState(int *const x, int *const y) const; + static uint32_t getMouseState(int *const x, int *const y); protected: void handleMouseMoved(const gcn::MouseInput &mouseInput); diff --git a/src/gui/popups/statuspopup.cpp b/src/gui/popups/statuspopup.cpp index 7944d1400..1d696fe82 100644 --- a/src/gui/popups/statuspopup.cpp +++ b/src/gui/popups/statuspopup.cpp @@ -154,7 +154,7 @@ void StatusPopup::updateLabels() const Input::KEY_SWITCH_QUICK_DROP); setLabelText(7, player_node->getPickUpTypeString(), Input::KEY_CHANGE_PICKUP_TYPE); - setLabelText(8, player_node->getDebugPathString(), + setLabelText(8, LocalPlayer::getDebugPathString(), Input::KEY_PATHFIND); setLabelText(9, player_node->getMagicAttackString(), Input::KEY_SWITCH_MAGIC_ATTACK); @@ -166,6 +166,6 @@ void StatusPopup::updateLabels() const Input::KEY_CHANGE_IMITATION_MODE); setLabelText(13, player_node->getAwayModeString(), Input::KEY_AWAY); - setLabelText(14, player_node->getCameraModeString(), + setLabelText(14, LocalPlayer::getCameraModeString(), Input::KEY_CAMERA); } diff --git a/src/gui/sdlfont.cpp b/src/gui/sdlfont.cpp index 8ef78c262..f97970a26 100644 --- a/src/gui/sdlfont.cpp +++ b/src/gui/sdlfont.cpp @@ -404,8 +404,8 @@ TTF_Font *SDLFont::openFont(const char *const name, const int size) // return nullptr; // return TTF_OpenFontIndexRW(rw, 1, size, 0); // #else - return TTF_OpenFontIndex(ResourceManager::getInstance()->getPath( - name).c_str(), size, 0); + return TTF_OpenFontIndex(ResourceManager::getPath(name).c_str(), + size, 0); // #endif } diff --git a/src/gui/setupactiondata.h b/src/gui/setupactiondata.h index 2b9d694a8..1b767516d 100644 --- a/src/gui/setupactiondata.h +++ b/src/gui/setupactiondata.h @@ -162,6 +162,12 @@ static SetupActionData setupActionData0[] = }, { // TRANSLATORS: input action name + N_("Open trade window"), + Input::KEY_OPEN_TRADE, + "", + }, + { + // TRANSLATORS: input action name N_("Change Map View Mode"), Input::KEY_PATHFIND, "", @@ -497,6 +503,30 @@ static SetupActionData setupActionData2[] = "", }, { + // TRANSLATORS: input action name + N_("Previous Shortcuts tab"), + Input::KEY_PREV_SHORTCUTS_TAB, + "", + }, + { + // TRANSLATORS: input action name + N_("Next Shortcuts tab"), + Input::KEY_NEXT_SHORTCUTS_TAB, + "", + }, + { + // TRANSLATORS: input action name + N_("Previous Commands tab"), + Input::KEY_PREV_COMMANDS_TAB, + "", + }, + { + // TRANSLATORS: input action name + N_("Next Commands tab"), + Input::KEY_NEXT_COMMANDS_TAB, + "", + }, + { "", Input::KEY_NO_VALUE, "" diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp index 44f2ca24e..4218aff7c 100644 --- a/src/gui/theme.cpp +++ b/src/gui/theme.cpp @@ -1179,7 +1179,7 @@ Skin *Theme::loadSkinRect(ImageRect &image, const std::string &name, } void Theme::unloadRect(const ImageRect &rect, const int start, - const int end) const + const int end) { for (int f = start; f <= end; f ++) { diff --git a/src/gui/theme.h b/src/gui/theme.h index 910964bdf..b40be2881 100644 --- a/src/gui/theme.h +++ b/src/gui/theme.h @@ -502,8 +502,9 @@ class Theme final : public Palette, public ConfigListener const std::string &name2, const int start = 0, const int end = 8); - void unloadRect(const ImageRect &rect, const int start = 0, - const int end = 8) const; + static void unloadRect(const ImageRect &rect, + const int start = 0, + const int end = 8); static Image *getImageFromThemeXml(const std::string &name, const std::string &name2) diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 5206b7424..341af1f0b 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -277,7 +277,7 @@ void Viewport::_followMouse() { if (!gui) return; - const uint8_t button = gui->getMouseState(&mMouseX, &mMouseY); + const uint8_t button = Gui::getMouseState(&mMouseX, &mMouseY); // If the left button is dragged if (mPlayerFollowMouse && (button & SDL_BUTTON(1))) { @@ -302,7 +302,7 @@ void Viewport::_drawDebugPath(Graphics *const graphics) if (!player_node || !userPalette || !actorManager || !mMap || !gui) return; - gui->getMouseState(&mMouseX, &mMouseY); + Gui::getMouseState(&mMouseX, &mMouseY); static Path debugPath; static Vector lastMouseDestination = Vector(0.0F, 0.0F); @@ -1034,7 +1034,7 @@ void Viewport::returnCamera() mCameraRelativeY = 0; } -void Viewport::validateSpeed() const +void Viewport::validateSpeed() { if (!inputManager.isActionActive(static_cast<int>( Input::KEY_TARGET_ATTACK)) && !inputManager.isActionActive( diff --git a/src/gui/viewport.h b/src/gui/viewport.h index 2ccb5ddac..dcddc003c 100644 --- a/src/gui/viewport.h +++ b/src/gui/viewport.h @@ -284,7 +284,7 @@ class Viewport final : public WindowContainer, /// Clears any matching hovers void clearHover(const ActorSprite *const actor); - void validateSpeed() const; + static void validateSpeed(); private: /** diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h index a2333d581..3dd783e52 100644 --- a/src/gui/widgets/button.h +++ b/src/gui/widgets/button.h @@ -107,7 +107,7 @@ class Button final : public gcn::Button, /** * Update the alpha value to the button components. */ - void updateAlpha(); + static void updateAlpha(); void mouseReleased(gcn::MouseEvent& mouseEvent) override final; diff --git a/src/gui/widgets/characterdisplay.cpp b/src/gui/widgets/characterdisplay.cpp index bd3f042f9..5ae4e2f5b 100644 --- a/src/gui/widgets/characterdisplay.cpp +++ b/src/gui/widgets/characterdisplay.cpp @@ -127,7 +127,7 @@ void CharacterDisplay::mouseMoved(gcn::MouseEvent &event A_UNUSED) int mouseX = 0; int mouseY = 0; - gui->getMouseState(&mouseX, &mouseY); + Gui::getMouseState(&mouseX, &mouseY); const std::string &name = mName->getCaption(); if (!name.empty()) { diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 068ffe1fc..59cdec6fb 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -183,7 +183,7 @@ DropDown::~DropDown() if (theme) { theme->unload(mSkin); - theme->unloadRect(skinRect); + Theme::unloadRect(skinRect); } } } diff --git a/src/gui/widgets/emotepage.h b/src/gui/widgets/emotepage.h index 8cef8f058..132cfb8e9 100644 --- a/src/gui/widgets/emotepage.h +++ b/src/gui/widgets/emotepage.h @@ -53,7 +53,7 @@ class EmotePage final : public gcn::Widget, void resetAction(); - int getSelectedIndex() + int getSelectedIndex() const { return mSelectedIndex; } private: diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h index 272536c87..f4a73af9f 100644 --- a/src/gui/widgets/itemcontainer.h +++ b/src/gui/widgets/itemcontainer.h @@ -134,7 +134,7 @@ class ItemContainer final : public gcn::Widget, void updateMatrix(); - bool getClickCount() A_WARN_UNUSED + bool getClickCount() const A_WARN_UNUSED { return mClicks; } private: diff --git a/src/gui/widgets/listbox.h b/src/gui/widgets/listbox.h index 83a33eb62..b1a2f0da5 100644 --- a/src/gui/widgets/listbox.h +++ b/src/gui/widgets/listbox.h @@ -97,7 +97,7 @@ class ListBox : public gcn::ListBox, void setCenter(const bool b) { mCenterText = b; } - int getPressedIndex() + int getPressedIndex() const { return mPressedIndex; } unsigned int getRowHeight() const override A_WARN_UNUSED diff --git a/src/gui/widgets/namesmodel.h b/src/gui/widgets/namesmodel.h index 76f668f10..f70dd2571 100644 --- a/src/gui/widgets/namesmodel.h +++ b/src/gui/widgets/namesmodel.h @@ -43,12 +43,15 @@ class NamesModel : public gcn::ListModel StringVect &getNames() A_WARN_UNUSED { return mNames; } - size_t size() A_WARN_UNUSED + size_t size() const A_WARN_UNUSED { return mNames.size(); } void clear() { mNames.clear(); } + void add(const std::string &str) + { mNames.push_back(str); } + void fillFromArray(const char *const *const arr, std::size_t size); protected: diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp index 2e078c088..6fda932bf 100644 --- a/src/gui/widgets/playerbox.cpp +++ b/src/gui/widgets/playerbox.cpp @@ -70,13 +70,8 @@ PlayerBox::~PlayerBox() if (gui) gui->removeDragged(this); - Theme *const theme = Theme::instance(); - if (theme) - { - theme->unloadRect(mBackground); - theme->unloadRect(mSelectedBackground); - } - + Theme::unloadRect(mBackground); + Theme::unloadRect(mSelectedBackground); mBeing = nullptr; } diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp index aecb323f8..38257e0a8 100644 --- a/src/gui/widgets/progressbar.cpp +++ b/src/gui/widgets/progressbar.cpp @@ -101,8 +101,7 @@ ProgressBar::~ProgressBar() theme->unload(mSkin); mSkin = nullptr; } - if (theme) - theme->unloadRect(mFillRect); + Theme::unloadRect(mFillRect); delete mVertexes; mVertexes = nullptr; } diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index 6d7695198..a260142a1 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -96,23 +96,19 @@ ScrollArea::~ScrollArea() delete getContent(); instances--; - const Theme *const theme = Theme::instance(); - if (theme) + if (instances == 0) { - if (instances == 0) + Theme::unloadRect(background); + Theme::unloadRect(vMarker); + Theme::unloadRect(vMarkerHi); + Theme::unloadRect(vBackground); + Theme::unloadRect(hBackground); + for (int i = 0; i < 2; i ++) { - theme->unloadRect(background); - theme->unloadRect(vMarker); - theme->unloadRect(vMarkerHi); - theme->unloadRect(vBackground); - theme->unloadRect(hBackground); - for (int i = 0; i < 2; i ++) + for (int f = UP; f < BUTTONS_DIR; f ++) { - for (int f = UP; f < BUTTONS_DIR; f ++) - { - if (buttons[f][i]) - buttons[f][i]->decRef(); - } + if (buttons[f][i]) + buttons[f][i]->decRef(); } } } diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index b9ea91f76..2cb7f60d1 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -1139,3 +1139,41 @@ void SetupItemSound::action(const gcn::ActionEvent &event) SetupItemSliderList::action(event); } } + +SetupItemSliderInt::SetupItemSliderInt(const std::string &restrict text, + const std::string &restrict description, + const std::string &restrict keyName, + SetupTabScroll *restrict const parent, + const std::string &restrict eventName, + gcn::ListModel *restrict const model, + const int min, + const int width, + const bool onTheFly, + const bool mainConfig) : + SetupItemSliderList(text, description, keyName, parent, eventName, + model, width, onTheFly, mainConfig), + mMin(min) +{ + createControls(); +} + +void SetupItemSliderInt::addMoreControls() +{ + toWidget(); +} + +void SetupItemSliderInt::fromWidget() +{ + if (!mSlider) + return; + + mValue = toString(mSlider->getSelected() + mMin); +} + +void SetupItemSliderInt::toWidget() +{ + if (!mSlider) + return; + + mSlider->setSelected(atoi(mValue.c_str()) - mMin); +} diff --git a/src/gui/widgets/setupitem.h b/src/gui/widgets/setupitem.h index 689f62fdf..c72bb39ef 100644 --- a/src/gui/widgets/setupitem.h +++ b/src/gui/widgets/setupitem.h @@ -466,9 +466,9 @@ class SetupItemSliderList : public SetupItem void createControls(); - void fromWidget() override final; + void fromWidget() override; - void toWidget() override final; + void toWidget() override; virtual void action(const gcn::ActionEvent &event) override; @@ -528,4 +528,30 @@ class SetupItemSound final : public SetupItemSliderList Button *mButton; }; +class SetupItemSliderInt final : public SetupItemSliderList +{ + public: + SetupItemSliderInt(const std::string &restrict text, + const std::string &restrict description, + const std::string &restrict keyName, + SetupTabScroll *restrict const parent, + const std::string &restrict eventName, + gcn::ListModel *restrict const model, + const int min, + const int width = 150, + const bool onTheFly = false, + const bool mainConfig = true); + + A_DELETE_COPY(SetupItemSliderInt) + + void addMoreControls() override final; + + void fromWidget() override final; + + void toWidget() override final; + + protected: + int mMin; +}; + #endif // GUI_WIDGETS_SETUPITEM_H diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp index 37b696a4e..750b58528 100644 --- a/src/gui/widgets/slider.cpp +++ b/src/gui/widgets/slider.cpp @@ -72,9 +72,8 @@ Slider::~Slider() mInstances--; if (mInstances == 0 && Theme::instance()) { - const Theme *const theme = Theme::instance(); for (int mode = 0; mode < 2; mode ++) - theme->unloadRect(buttons[mode]); + Theme::unloadRect(buttons[mode]); } } diff --git a/src/gui/widgets/sliderlist.cpp b/src/gui/widgets/sliderlist.cpp index 6dd968eef..60d7926d1 100644 --- a/src/gui/widgets/sliderlist.cpp +++ b/src/gui/widgets/sliderlist.cpp @@ -77,8 +77,7 @@ SliderList::~SliderList() void SliderList::updateAlpha() { - mButtons[0]->updateAlpha(); - mButtons[1]->updateAlpha(); + Button::updateAlpha(); } void SliderList::mouseWheelMovedUp(gcn::MouseEvent& mouseEvent) diff --git a/src/gui/widgets/sliderlist.h b/src/gui/widgets/sliderlist.h index 4ef673b83..73f8c6f5c 100644 --- a/src/gui/widgets/sliderlist.h +++ b/src/gui/widgets/sliderlist.h @@ -67,7 +67,7 @@ class SliderList final : public Container, void adjustSize(); - int getSelected() A_WARN_UNUSED + int getSelected() const A_WARN_UNUSED { return mSelectedIndex; } protected: diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp index c4e4b0671..bf14f21fe 100644 --- a/src/gui/widgets/spellshortcutcontainer.cpp +++ b/src/gui/widgets/spellshortcutcontainer.cpp @@ -321,7 +321,7 @@ void SpellShortcutContainer::widgetHidden(const gcn::Event &event A_UNUSED) mSpellPopup->setVisible(false); } -int SpellShortcutContainer::getItemByIndex(const int index) +int SpellShortcutContainer::getItemByIndex(const int index) const { return spellShortcut->getItem( (mNumber * SPELL_SHORTCUT_ITEMS) + index); diff --git a/src/gui/widgets/spellshortcutcontainer.h b/src/gui/widgets/spellshortcutcontainer.h index 31e98a592..37e7b5660 100644 --- a/src/gui/widgets/spellshortcutcontainer.h +++ b/src/gui/widgets/spellshortcutcontainer.h @@ -75,7 +75,7 @@ class SpellShortcutContainer final : public ShortcutContainer void setWidget2(const Widget2 *const widget) override final; - int getItemByIndex(const int index); + int getItemByIndex(const int index) const A_WARN_UNUSED; private: SpellPopup *mSpellPopup; diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index da6c89d1a..3b0cf1db5 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -725,3 +725,22 @@ void TabbedArea::death(const gcn::Event &event) else gcn::BasicContainer::death(event); } + +void TabbedArea::selectNextTab() +{ + int tab = getSelectedTabIndex(); + tab++; + if (tab == static_cast<int>(mTabs.size())) + tab = 0; + setSelectedTab(mTabs[tab].first); +} + +void TabbedArea::selectPrevTab() +{ + int tab = getSelectedTabIndex(); + + if (tab == 0) + tab = static_cast<int>(mTabs.size()); + tab--; + setSelectedTab(mTabs[tab].first); +} diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h index eaac7a6d5..d0f97b688 100644 --- a/src/gui/widgets/tabbedarea.h +++ b/src/gui/widgets/tabbedarea.h @@ -189,6 +189,10 @@ class TabbedArea final : public Widget2, void adjustWidget(gcn::Widget *const widget) const; + void selectNextTab(); + + void selectPrevTab(); + private: typedef std::vector <std::pair<Tab*, gcn::Widget*> > TabContainer; diff --git a/src/gui/widgets/tabs/chattab.cpp b/src/gui/widgets/tabs/chattab.cpp index 1795fd03e..331101209 100644 --- a/src/gui/widgets/tabs/chattab.cpp +++ b/src/gui/widgets/tabs/chattab.cpp @@ -418,15 +418,8 @@ void ChatTab::clearText() void ChatTab::handleInput(const std::string &msg) { - if (chatWindow) - { - Net::getChatHandler()->talk(chatWindow->doReplace(msg), - mChannelName); - } - else - { - Net::getChatHandler()->talk(msg, mChannelName); - } + Net::getChatHandler()->talk(ChatWindow::doReplace(msg), + mChannelName); } void ChatTab::handleCommand(const std::string &msg) diff --git a/src/gui/widgets/tabs/chattab.h b/src/gui/widgets/tabs/chattab.h index 9790c33e4..651e69d6b 100644 --- a/src/gui/widgets/tabs/chattab.h +++ b/src/gui/widgets/tabs/chattab.h @@ -109,13 +109,6 @@ class ChatTab : public Tab void clearText(); /** - * Add any extra help text to the output. Allows tabs to define help - * for commands defined by the tab itself. - */ - virtual void showHelp() - { } - - /** * Handle special commands. Allows a tab to handle commands it * defines itself. * @@ -195,6 +188,9 @@ class ChatTab : public Tab virtual void getAutoCompleteList(StringVect&) const {} + virtual void getAutoCompleteCommands(StringVect&) const + {} + void addRow(std::string &line); BrowserBox *mTextOutput; diff --git a/src/gui/widgets/tabs/guildchattab.cpp b/src/gui/widgets/tabs/guildchattab.cpp index 364b83968..da1a651e1 100644 --- a/src/gui/widgets/tabs/guildchattab.cpp +++ b/src/gui/widgets/tabs/guildchattab.cpp @@ -55,50 +55,16 @@ GuildChatTab::~GuildChatTab() bool GuildChatTab::handleCommand(const std::string &restrict type, const std::string &restrict args) { - if (type == "help") - { - if (args == "invite") - { - // TRANSLATORS: guild chat tab help - chatLog(_("Command: /invite <nick>")); - // TRANSLATORS: guild chat tab help - chatLog(_("This command invites <nick> to the guild you're in.")); - // TRANSLATORS: guild chat tab help - chatLog(_("If the <nick> has spaces in it, enclose it in " - "double quotes (\").")); - } - else if (args == "leave") - { - // TRANSLATORS: guild chat tab help - chatLog(_("Command: /leave")); - // TRANSLATORS: guild chat tab help - chatLog(_("This command causes the player to leave the guild.")); - } - else - { - return false; - } - } - else if (type == "invite" && guildManager) - { + if (type == "invite" && guildManager) guildManager->invite(args); - } else if (type == "leave" && guildManager) - { guildManager->leave(); - } else if (type == "kick" && guildManager) - { guildManager->kick(args); - } else if (type == "notice" && guildManager) - { guildManager->notice(args); - } else - { return false; - } return true; } @@ -107,23 +73,7 @@ void GuildChatTab::handleInput(const std::string &msg) { if (!guildManager) return; - - if (chatWindow) - guildManager->chat(chatWindow->doReplace(msg)); - else - guildManager->chat(msg); -} - -void GuildChatTab::showHelp() -{ - // TRANSLATORS: guild chat tab help - chatLog(_("/help > Display this help.")); - // TRANSLATORS: guild chat tab help - chatLog(_("/invite > Invite a player to your guild")); - // TRANSLATORS: guild chat tab help - chatLog(_("/leave > Leave the guild you are in")); - // TRANSLATORS: guild chat tab help - chatLog(_("/kick > Kick someone from the guild you are in")); + guildManager->chat(ChatWindow::doReplace(msg)); } void GuildChatTab::getAutoCompleteList(StringVect &names) const @@ -132,6 +82,14 @@ void GuildChatTab::getAutoCompleteList(StringVect &names) const return; guildManager->getNames(names); +} + +void GuildChatTab::getAutoCompleteCommands(StringVect &names) const +{ + names.push_back("/help"); + names.push_back("/invite "); + names.push_back("/leave"); + names.push_back("/kick "); names.push_back("/notice "); } diff --git a/src/gui/widgets/tabs/guildchattab.h b/src/gui/widgets/tabs/guildchattab.h index 7fac06843..fbfd3a032 100644 --- a/src/gui/widgets/tabs/guildchattab.h +++ b/src/gui/widgets/tabs/guildchattab.h @@ -40,8 +40,6 @@ class GuildChatTab final : public ChatTab, public ConfigListener bool handleCommand(const std::string &restrict type, const std::string &restrict args) override final; - void showHelp() override; - void saveToLogFile(const std::string &msg) const override final; int getType() const override A_WARN_UNUSED @@ -55,6 +53,8 @@ class GuildChatTab final : public ChatTab, public ConfigListener void handleInput(const std::string &msg) override final; void getAutoCompleteList(StringVect &names) const override final; + + void getAutoCompleteCommands(StringVect &names) const override final; }; #endif // GUI_WIDGETS_TABS_GUILDCHATTAB_H diff --git a/src/gui/widgets/tabs/setup_input.cpp b/src/gui/widgets/tabs/setup_input.cpp index 2ce99d971..9ce6fd616 100644 --- a/src/gui/widgets/tabs/setup_input.cpp +++ b/src/gui/widgets/tabs/setup_input.cpp @@ -270,7 +270,7 @@ void Setup_Input::action(const gcn::ActionEvent &event) else if (id == "resetkeys") { inputManager.resetKeys(); - inputManager.update(); + InputManager::update(); refreshKeys(); } else if (id == "default") @@ -378,8 +378,9 @@ void Setup_Input::keyUnresolved() } void Setup_Input::fixTranslation(SetupActionData *const actionDatas, - const int actionStart, const int actionEnd, - const std::string &text) const + const int actionStart, + const int actionEnd, + const std::string &text) { int k = 0; @@ -397,7 +398,7 @@ void Setup_Input::fixTranslation(SetupActionData *const actionDatas, } } -void Setup_Input::fixTranslations() const +void Setup_Input::fixTranslations() { fixTranslation(setupActionData1, static_cast<int>(Input::KEY_SHORTCUT_1), static_cast<int>(Input::KEY_SHORTCUT_20), "Item Shortcut %d"); diff --git a/src/gui/widgets/tabs/setup_input.h b/src/gui/widgets/tabs/setup_input.h index cb2e5cac0..135cb3339 100644 --- a/src/gui/widgets/tabs/setup_input.h +++ b/src/gui/widgets/tabs/setup_input.h @@ -82,11 +82,12 @@ class Setup_Input final : public SetupTab std::string keyToString(const int index) const A_WARN_UNUSED; private: - void fixTranslations() const; + static void fixTranslations(); - void fixTranslation(SetupActionData *const actionDatas, - const int actionStart, const int actionEnd, - const std::string &text) const; + static void fixTranslation(SetupActionData *const actionDatas, + const int actionStart, + const int actionEnd, + const std::string &text); KeyListModel *mKeyListModel; ListBox *mKeyList; diff --git a/src/gui/widgets/tabs/setup_visual.cpp b/src/gui/widgets/tabs/setup_visual.cpp index 8d79fdaa0..ac608f756 100644 --- a/src/gui/widgets/tabs/setup_visual.cpp +++ b/src/gui/widgets/tabs/setup_visual.cpp @@ -88,7 +88,7 @@ Setup_Visual::Setup_Visual(const Widget2 *const widget) : mParticleList(new SetupItemNames), mParticleTypeList(new NamesModel), mVSyncList(new NamesModel), - mScaleList(new SetupItemNames) + mScaleList(new NamesModel) { // TRANSLATORS: settings tab name setName(_("Visual")); @@ -105,11 +105,11 @@ Setup_Visual::Setup_Visual(const Widget2 *const widget) : for (int f = 1; f <= 7; f ++) { // TRANSLATORS: particle details - mScaleList->push_back(toString(f) + "x"); + mScaleList->add(toString(f) + "x"); } - new SetupItemSlider2(_("Scale "), "", "scale", - this, "scaleEvent", 1, 7, - mScaleList, true); + // TRANSLATORS: settings option + new SetupItemSliderInt(_("Scale"), "", + "scale", this, "scaleEvent", mScaleList, 1); // TRANSLATORS: settings option new SetupItemLabel(_("Notifications"), "", this); diff --git a/src/gui/widgets/tabs/setup_visual.h b/src/gui/widgets/tabs/setup_visual.h index 8aef0d294..2d40d3a08 100644 --- a/src/gui/widgets/tabs/setup_visual.h +++ b/src/gui/widgets/tabs/setup_visual.h @@ -43,7 +43,7 @@ class Setup_Visual final : public SetupTabScroll SetupItemNames *mParticleList; NamesModel *mParticleTypeList; NamesModel *mVSyncList; - SetupItemNames *mScaleList; + NamesModel *mScaleList; }; #endif // GUI_WIDGETS_TABS_SETUP_VISUAL_H diff --git a/src/gui/widgets/tabs/setuptabscroll.h b/src/gui/widgets/tabs/setuptabscroll.h index e3d495690..fb7de574d 100644 --- a/src/gui/widgets/tabs/setuptabscroll.h +++ b/src/gui/widgets/tabs/setuptabscroll.h @@ -60,7 +60,7 @@ class SetupTabScroll : public SetupTab override final { } - int getPreferredFirstItemSize() A_WARN_UNUSED + int getPreferredFirstItemSize() const A_WARN_UNUSED { return mPreferredFirstItemSize; } void widgetResized(const gcn::Event &event) override final; diff --git a/src/gui/widgets/tabs/whispertab.cpp b/src/gui/widgets/tabs/whispertab.cpp index 659704638..ec02bb70f 100644 --- a/src/gui/widgets/tabs/whispertab.cpp +++ b/src/gui/widgets/tabs/whispertab.cpp @@ -32,8 +32,6 @@ #include "gui/widgets/windowcontainer.h" -#include "utils/gettext.h" - #include "debug.h" WhisperTab::WhisperTab(const Widget2 *const widget, const std::string &nick) : @@ -52,10 +50,7 @@ WhisperTab::~WhisperTab() void WhisperTab::handleInput(const std::string &msg) { std::string newMsg; - if (chatWindow) - newMsg = chatWindow->doReplace(msg); - else - newMsg = msg; + newMsg = ChatWindow::doReplace(msg); Net::getChatHandler()->privateMessage(mNick, newMsg); if (player_node) @@ -92,50 +87,10 @@ void WhisperTab::handleCommand(const std::string &msg) } } -void WhisperTab::showHelp() -{ - // TRANSLATORS: whisper tab help - chatLog(_("/ignore > Ignore the other player")); - // TRANSLATORS: whisper tab help - chatLog(_("/unignore > Stop ignoring the other player")); - // TRANSLATORS: whisper tab help - chatLog(_("/close > Close the whisper tab")); -} - bool WhisperTab::handleCommand(const std::string &restrict type, - const std::string &restrict args) + const std::string &restrict args A_UNUSED) { - if (type == "help") - { - if (args == "close") - { - // TRANSLATORS: whisper tab help - chatLog(_("Command: /close")); - // TRANSLATORS: whisper tab help - chatLog(_("This command closes the current whisper tab.")); - } - else if (args == "ignore") - { - // TRANSLATORS: whisper tab help - chatLog(_("Command: /ignore")); - // TRANSLATORS: whisper tab help - chatLog(_("This command ignores the other player regardless of " - "current relations.")); - } - else if (args == "unignore") - { - // TRANSLATORS: whisper tab help - chatLog(_("Command: /unignore <player>")); - // TRANSLATORS: whisper tab help - chatLog(_("This command stops ignoring the other player if they " - "are being ignored.")); - } - else - { - return false; - } - } - else if (type == "close") + if (type == "close") { if (windowContainer) windowContainer->scheduleDelete(this); diff --git a/src/gui/widgets/tabs/whispertab.h b/src/gui/widgets/tabs/whispertab.h index b3936ab01..5dbb05a4e 100644 --- a/src/gui/widgets/tabs/whispertab.h +++ b/src/gui/widgets/tabs/whispertab.h @@ -36,8 +36,6 @@ class WhisperTab final : public ChatTab const std::string &getNick() const A_WARN_UNUSED { return mNick; } - void showHelp() override final; - bool handleCommand(const std::string &restrict type, const std::string &restrict args) override final; diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index 41084c867..269ace775 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -116,7 +116,7 @@ TextField::~TextField() if (theme) { theme->unload(mSkin); - theme->unloadRect(skin); + Theme::unloadRect(skin); } } } @@ -745,7 +745,7 @@ void TextField::mousePressed(gcn::MouseEvent &mouseEvent) { int x = 0; int y = 0; - gui->getMouseState(&x, &y); + Gui::getMouseState(&x, &y); mPopupMenu->showTextFieldPopup(x, y, this); } } diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index cd00d2568..36372dcaa 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -1059,6 +1059,28 @@ void Window::adjustPositionAfterResize(const int oldScreenWidth, } ensureOnScreen(); + adjustSizeToScreen(); +} + +void Window::adjustSizeToScreen() +{ + if (!mGrip) + return; + + const int screenWidth = mainGraphics->mWidth; + const int screenHeight = mainGraphics->mHeight; + const int oldWidth = mDimension.width; + const int oldHeight = mDimension.height; + if (oldWidth + mDimension.x > screenWidth) + mDimension.x = 0; + if (oldHeight + mDimension.y > screenHeight) + mDimension.x = 0; + if (mDimension.width > screenWidth) + mDimension.width = screenWidth; + if (mDimension.height > screenHeight) + mDimension.height = screenHeight; + if (oldWidth != mDimension.width || oldHeight != mDimension.height) + widgetResized(gcn::Event(this)); } int Window::getResizeHandles(const gcn::MouseEvent &event) diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index 757ec8c58..bb0f19bb3 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -465,6 +465,8 @@ class Window : public gcn::Window, */ void ensureOnScreen(); + void adjustSizeToScreen(); + /** * Determines if the mouse is in a resize area and returns appropriate * resize handles. Also initializes drag offset in case the resize diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index 6af18ff06..26f665052 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -43,7 +43,8 @@ #include "gui/viewport.h" #include "gui/windows/emotewindow.h" -#include "gui/windows/setup.h" +#include "gui/windows/setupwindow.h" +#include "gui/widgets/tabbedarea.h" #include "gui/windows/whoisonline.h" #include "gui/widgets/tabs/battletab.h" @@ -452,7 +453,7 @@ ChatTab *ChatWindow::getFocused() const return static_cast<ChatTab*>(mChatTabs->getSelectedTab()); } -void ChatWindow::clearTab(ChatTab *const tab) const +void ChatWindow::clearTab(ChatTab *const tab) { if (tab) tab->clearText(); @@ -1312,7 +1313,6 @@ void ChatWindow::autoComplete() const int caretPos = mChatInput->getCaretPosition(); int startName = 0; const std::string inputText = mChatInput->getText(); - bool needSecure(false); std::string name = inputText.substr(0, caretPos); for (int f = caretPos - 1; f > -1; f --) @@ -1335,15 +1335,21 @@ void ChatWindow::autoComplete() if (cTab) cTab->getAutoCompleteList(nameList); std::string newName = autoComplete(nameList, name); - if (!newName.empty()) - needSecure = true; + if (!newName.empty() && !startName) + secureChatCommand(newName); + + if (cTab && newName.empty()) + { + cTab->getAutoCompleteCommands(nameList); + newName = autoComplete(nameList, name); + } if (newName.empty() && actorManager) { actorManager->getPlayerNames(nameList, true); newName = autoComplete(nameList, name); - if (!newName.empty()) - needSecure = true; + if (!newName.empty() && !startName) + secureChatCommand(newName); } if (newName.empty()) newName = autoCompleteHistory(name); @@ -1366,11 +1372,6 @@ void ChatWindow::autoComplete() if (!newName.empty()) { - if (!startName && needSecure && (newName[0] == '/' - || newName[0] == '@' || newName[0] == '#')) - { - newName = "_" + newName; - } mChatInput->setText(inputText.substr(0, startName).append(newName) .append(inputText.substr(caretPos, inputText.length() - caretPos))); @@ -1386,7 +1387,7 @@ void ChatWindow::autoComplete() } std::string ChatWindow::autoComplete(StringVect &names, - std::string partName) const + std::string partName) { StringVectCIter i = names.begin(); const StringVectCIter i_end = names.end(); @@ -1770,7 +1771,7 @@ void ChatWindow::saveState() const } } -std::string ChatWindow::doReplace(const std::string &msg) const +std::string ChatWindow::doReplace(const std::string &msg) { std::string str = msg; replaceSpecialChars(str); @@ -1918,7 +1919,7 @@ void ChatWindow::updateVisibility() int mouseY = 0; int x = 0; int y = 0; - gui->getMouseState(&mouseX, &mouseY); + Gui::getMouseState(&mouseX, &mouseY); getAbsolutePosition(x, y); if (mChatInput->isVisible()) { diff --git a/src/gui/windows/chatwindow.h b/src/gui/windows/chatwindow.h index c000215f1..3093c52e9 100644 --- a/src/gui/windows/chatwindow.h +++ b/src/gui/windows/chatwindow.h @@ -109,7 +109,7 @@ class ChatWindow final : public Window, /** * Clear the given tab. */ - void clearTab(ChatTab *const tab) const; + static void clearTab(ChatTab *const tab); /** * Clear the current tab. @@ -253,7 +253,7 @@ class ChatWindow final : public Window, void loadGMCommands(); - std::string doReplace(const std::string &msg) const A_WARN_UNUSED; + static std::string doReplace(const std::string &msg) A_WARN_UNUSED; void adjustTabSize(); @@ -328,8 +328,8 @@ class ChatWindow final : public Window, std::string autoComplete(const std::string &partName, History *const words) const; - std::string autoComplete(StringVect &names, - std::string partName) const; + static std::string autoComplete(StringVect &names, + std::string partName); /** Used for showing item popup on clicking links **/ ItemLinkHandler *mItemLinkHandler; diff --git a/src/gui/windows/debugwindow.cpp b/src/gui/windows/debugwindow.cpp index 02a79d0de..30d202054 100644 --- a/src/gui/windows/debugwindow.cpp +++ b/src/gui/windows/debugwindow.cpp @@ -31,11 +31,12 @@ #include "gui/viewport.h" -#include "gui/windows/setup.h" +#include "gui/windows/setupwindow.h" #include "gui/widgets/label.h" #include "gui/widgets/layout.h" #include "gui/widgets/layouthelper.h" +#include "gui/widgets/tabbedarea.h" #include "resources/imagehelper.h" diff --git a/src/gui/windows/didyouknowwindow.cpp b/src/gui/windows/didyouknowwindow.cpp index 37c970562..93166e6fa 100644 --- a/src/gui/windows/didyouknowwindow.cpp +++ b/src/gui/windows/didyouknowwindow.cpp @@ -26,7 +26,7 @@ #include "gui/sdlfont.h" -#include "gui/windows/setup.h" +#include "gui/windows/setupwindow.h" #include "gui/widgets/button.h" #include "gui/widgets/browserbox.h" diff --git a/src/gui/windows/equipmentwindow.cpp b/src/gui/windows/equipmentwindow.cpp index 621f5e537..3b97e12d7 100644 --- a/src/gui/windows/equipmentwindow.cpp +++ b/src/gui/windows/equipmentwindow.cpp @@ -36,7 +36,7 @@ #include "gui/popups/itempopup.h" -#include "gui/windows/setup.h" +#include "gui/windows/setupwindow.h" #include "gui/widgets/button.h" #include "gui/widgets/playerbox.h" @@ -552,7 +552,7 @@ void EquipmentWindow::loadSlot(const XmlNodePtr slotNode, mMaxY = y + mBoxSize; } -int EquipmentWindow::parseSlotName(const std::string &name) const +int EquipmentWindow::parseSlotName(const std::string &name) { int id = -1; if (name == "shoes" || name == "boot" || name == "boots") diff --git a/src/gui/windows/equipmentwindow.h b/src/gui/windows/equipmentwindow.h index d291a5f81..7387fb249 100644 --- a/src/gui/windows/equipmentwindow.h +++ b/src/gui/windows/equipmentwindow.h @@ -122,7 +122,7 @@ class EquipmentWindow final : public Window, public gcn::ActionListener void loadSlot(const XmlNodePtr slotNode, const ImageSet *const imageset); - int parseSlotName(const std::string &name) const A_WARN_UNUSED; + static int parseSlotName(const std::string &name) A_WARN_UNUSED; Equipment *mEquipment; diff --git a/src/gui/windows/helpwindow.cpp b/src/gui/windows/helpwindow.cpp index 854ac8cbd..eb2300e0e 100644 --- a/src/gui/windows/helpwindow.cpp +++ b/src/gui/windows/helpwindow.cpp @@ -27,7 +27,7 @@ #include "gui/sdlfont.h" #include "gui/windows/didyouknowwindow.h" -#include "gui/windows/setup.h" +#include "gui/windows/setupwindow.h" #include "gui/widgets/button.h" #include "gui/widgets/browserbox.h" diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp index 02b30aed7..6fd2ab95b 100644 --- a/src/gui/windows/inventorywindow.cpp +++ b/src/gui/windows/inventorywindow.cpp @@ -38,7 +38,7 @@ #include "gui/windows/equipmentwindow.h" #include "gui/windows/itemamountwindow.h" #include "gui/windows/outfitwindow.h" -#include "gui/windows/setup.h" +#include "gui/windows/setupwindow.h" #include "gui/windows/shopwindow.h" #include "gui/windows/tradewindow.h" diff --git a/src/gui/windows/minimap.cpp b/src/gui/windows/minimap.cpp index 177be8a74..02be64a13 100644 --- a/src/gui/windows/minimap.cpp +++ b/src/gui/windows/minimap.cpp @@ -33,7 +33,7 @@ #include "gui/popups/textpopup.h" -#include "gui/windows/setup.h" +#include "gui/windows/setupwindow.h" #include "resources/image.h" #include "resources/imagehelper.h" diff --git a/src/gui/windows/outfitwindow.cpp b/src/gui/windows/outfitwindow.cpp index c5df4b652..d686056ac 100644 --- a/src/gui/windows/outfitwindow.cpp +++ b/src/gui/windows/outfitwindow.cpp @@ -524,7 +524,7 @@ void OutfitWindow::unequipNotInOutfit(const int outfit) const } } -std::string OutfitWindow::keyName(const int number) const +std::string OutfitWindow::keyName(const int number) { if (number < 0 || number >= SHORTCUT_EMOTES) return ""; diff --git a/src/gui/windows/outfitwindow.h b/src/gui/windows/outfitwindow.h index 4f6e5c0bf..eeedc2ec6 100644 --- a/src/gui/windows/outfitwindow.h +++ b/src/gui/windows/outfitwindow.h @@ -89,7 +89,7 @@ class OutfitWindow final : public Window, void showCurrentOutfit(); - std::string keyName(const int number) const A_WARN_UNUSED; + static std::string keyName(const int number) A_WARN_UNUSED; void clearCurrentOutfit(); diff --git a/src/gui/windows/setup.cpp b/src/gui/windows/setupwindow.cpp index d0ecc2d6d..0780865aa 100644 --- a/src/gui/windows/setup.cpp +++ b/src/gui/windows/setupwindow.cpp @@ -20,7 +20,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "gui/windows/setup.h" +#include "gui/windows/setupwindow.h" #include "configuration.h" #include "game.h" @@ -45,6 +45,7 @@ #include "gui/widgets/tabs/setup_visual.h" #include "gui/widgets/label.h" +#include "gui/widgets/tabbedarea.h" #include "utils/dtor.h" #include "utils/gettext.h" @@ -52,9 +53,9 @@ #include "debug.h" extern Window *statusWindow; -Setup *setupWindow = nullptr; +SetupWindow *setupWindow = nullptr; -Setup::Setup() : +SetupWindow::SetupWindow() : // TRANSLATORS: setup window name Window(_("Setup"), false, nullptr, "setup.xml"), gcn::ActionListener(), @@ -72,7 +73,7 @@ Setup::Setup() : setStickyButtonLock(true); } -void Setup::postInit() +void SetupWindow::postInit() { int width = 620; const int height = 450; @@ -153,13 +154,13 @@ void Setup::postInit() enableVisibleSound(true); } -Setup::~Setup() +SetupWindow::~SetupWindow() { delete_all(mTabs); mButtons.clear(); } -void Setup::action(const gcn::ActionEvent &event) +void SetupWindow::action(const gcn::ActionEvent &event) { if (Game::instance()) Game::instance()->resetAdjustLevel(); @@ -196,12 +197,12 @@ void Setup::action(const gcn::ActionEvent &event) } } -void Setup::setInGame(const bool inGame) +void SetupWindow::setInGame(const bool inGame) { mResetWindows->setEnabled(inGame); } -void Setup::externalUpdate() +void SetupWindow::externalUpdate() { unloadModTab(); mModsTab = new Setup_Mods(this); @@ -214,7 +215,7 @@ void Setup::externalUpdate() } } -void Setup::unloadModTab() +void SetupWindow::unloadModTab() { if (mModsTab) { @@ -226,7 +227,7 @@ void Setup::unloadModTab() } } -void Setup::externalUnload() +void SetupWindow::externalUnload() { FOR_EACH (std::list<SetupTab*>::const_iterator, it, mTabs) { @@ -236,30 +237,30 @@ void Setup::externalUnload() unloadModTab(); } -void Setup::registerWindowForReset(Window *const window) +void SetupWindow::registerWindowForReset(Window *const window) { mWindowsToReset.push_back(window); } -void Setup::doCancel() +void SetupWindow::doCancel() { setVisible(false); for_each(mTabs.begin(), mTabs.end(), std::mem_fun(&SetupTab::cancel)); } -void Setup::activateTab(const std::string &name) +void SetupWindow::activateTab(const std::string &name) { std::string tmp = gettext(name.c_str()); mPanel->setSelectedTabByName(tmp); } -void Setup::setVisible(bool visible) +void SetupWindow::setVisible(bool visible) { touchManager.setTempHide(visible); Window::setVisible(visible); } -void Setup::widgetResized(const gcn::Event &event) +void SetupWindow::widgetResized(const gcn::Event &event) { Window::widgetResized(event); diff --git a/src/gui/windows/setup.h b/src/gui/windows/setupwindow.h index 4c9ab2fb7..f5406e8ac 100644 --- a/src/gui/windows/setup.h +++ b/src/gui/windows/setupwindow.h @@ -20,10 +20,8 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef GUI_WINDOWS_SETUP_H -#define GUI_WINDOWS_SETUP_H - -#include "gui/widgets/tabbedarea.h" +#ifndef GUI_WINDOWS_SETUPWINDOW_H +#define GUI_WINDOWS_SETUPWINDOW_H #include "gui/widgets/window.h" @@ -31,8 +29,10 @@ #include <list> +class Button; class Label; class SetupTab; +class TabbedArea; /** * The setup dialog. Displays several tabs for configuring different aspects @@ -40,14 +40,15 @@ class SetupTab; * * \ingroup GUI */ -class Setup final : public Window, public gcn::ActionListener +class SetupWindow final : public Window, + public gcn::ActionListener { public: - Setup(); + SetupWindow(); - A_DELETE_COPY(Setup) + A_DELETE_COPY(SetupWindow) - ~Setup(); + ~SetupWindow(); void postInit() override final; @@ -84,6 +85,6 @@ class Setup final : public Window, public gcn::ActionListener Label *mVersion; }; -extern Setup* setupWindow; +extern SetupWindow* setupWindow; -#endif // GUI_WINDOWS_SETUP_H +#endif // GUI_WINDOWS_SETUPWINDOW_H diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp index 48bfedb06..a940e4cdb 100644 --- a/src/gui/windows/shopwindow.cpp +++ b/src/gui/windows/shopwindow.cpp @@ -632,7 +632,7 @@ void ShopWindow::sendMessage(const std::string &nick, chatWindow->addWhisper(nick, data, BY_PLAYER); } -void ShopWindow::showList(const std::string &nick, std::string data) const +void ShopWindow::showList(const std::string &nick, std::string data) { BuyDialog *buyDialog = nullptr; SellDialog *sellDialog = nullptr; diff --git a/src/gui/windows/shopwindow.h b/src/gui/windows/shopwindow.h index 590a05dcc..95eee1e05 100644 --- a/src/gui/windows/shopwindow.h +++ b/src/gui/windows/shopwindow.h @@ -121,7 +121,7 @@ class ShopWindow final : public Window, void sendMessage(const std::string &nick, std::string data, const bool random = false); - void showList(const std::string &nick, std::string data) const; + static void showList(const std::string &nick, std::string data); void processRequest(const std::string &nick, std::string data, const int mode); diff --git a/src/gui/windows/shortcutwindow.cpp b/src/gui/windows/shortcutwindow.cpp index 1d9fa88c2..96ec8c93c 100644 --- a/src/gui/windows/shortcutwindow.cpp +++ b/src/gui/windows/shortcutwindow.cpp @@ -22,7 +22,8 @@ #include "gui/windows/shortcutwindow.h" -#include "gui/windows/setup.h" +#include "gui/windows/setupwindow.h" +#include "gui/widgets/tabbedarea.h" #include "gui/widgets/layout.h" #include "gui/widgets/scrollarea.h" @@ -234,6 +235,18 @@ void ShortcutWindow::widgetMoved(const gcn::Event& event) (*it)->setRedraw(true); } +void ShortcutWindow::nextTab() +{ + if (mTabs) + mTabs->selectNextTab(); +} + +void ShortcutWindow::prevTab() +{ + if (mTabs) + mTabs->selectPrevTab(); +} + #ifdef USE_PROFILER void ShortcutWindow::logicChildren() { diff --git a/src/gui/windows/shortcutwindow.h b/src/gui/windows/shortcutwindow.h index b7d7f70a1..f4c417c94 100644 --- a/src/gui/windows/shortcutwindow.h +++ b/src/gui/windows/shortcutwindow.h @@ -68,6 +68,10 @@ class ShortcutWindow final : public Window void mouseDragged(gcn::MouseEvent &event) override final; + void nextTab(); + + void prevTab(); + #ifdef USE_PROFILER void logicChildren(); #endif diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp index 197c60a90..04baad26a 100644 --- a/src/gui/windows/skilldialog.cpp +++ b/src/gui/windows/skilldialog.cpp @@ -33,7 +33,7 @@ #include "gui/popups/textpopup.h" -#include "gui/windows/setup.h" +#include "gui/windows/setupwindow.h" #include "gui/windows/shortcutwindow.h" #include "gui/widgets/button.h" diff --git a/src/gui/windows/socialwindow.cpp b/src/gui/windows/socialwindow.cpp index 1c6b85153..2385066be 100644 --- a/src/gui/windows/socialwindow.cpp +++ b/src/gui/windows/socialwindow.cpp @@ -35,7 +35,7 @@ #include "gui/windows/confirmdialog.h" #include "gui/windows/okdialog.h" -#include "gui/windows/setup.h" +#include "gui/windows/setupwindow.h" #include "gui/windows/textdialog.h" #include "gui/windows/whoisonline.h" @@ -46,6 +46,7 @@ #include "gui/widgets/label.h" #include "gui/widgets/popup.h" #include "gui/widgets/scrollarea.h" +#include "gui/widgets/tabbedarea.h" #include "gui/widgets/tabs/chattab.h" @@ -1276,6 +1277,7 @@ SocialWindow::SocialWindow() : // TRANSLATORS: social window name Window(_("Social"), false, nullptr, "social.xml"), gcn::ActionListener(), + PlayerRelationsListener(), mGuildInvited(0), mGuildAcceptDialog(nullptr), mGuildCreateDialog(nullptr), @@ -1372,10 +1374,12 @@ void SocialWindow::postInit() enableVisibleSound(true); updateButtons(); + player_relations.addListener(this); } SocialWindow::~SocialWindow() { + player_relations.removeListener(this); if (mGuildAcceptDialog) { mGuildAcceptDialog->close(); @@ -1740,6 +1744,7 @@ void SocialWindow::slowLogic() const unsigned int nowTime = cur_time; if (mNeedUpdate && nowTime - mLastUpdateTime > 1) { + logger->log("soc update"); mPlayers->updateList(); mFriends->updateList(); mNeedUpdate = false; @@ -1819,30 +1824,14 @@ void SocialWindow::removePortal(const int x, const int y) void SocialWindow::nextTab() { - if (!mTabs) - return; - - int tab = mTabs->getSelectedTabIndex(); - - tab++; - if (tab == mTabs->getNumberOfTabs()) - tab = 0; - - mTabs->setSelectedTabByIndex(tab); + if (mTabs) + mTabs->selectNextTab(); } void SocialWindow::prevTab() { - if (!mTabs) - return; - - int tab = mTabs->getSelectedTabIndex(); - - if (tab == 0) - tab = mTabs->getNumberOfTabs(); - tab--; - - mTabs->setSelectedTabByIndex(tab); + if (mTabs) + mTabs->selectPrevTab(); } void SocialWindow::updateAttackFilter() @@ -1908,6 +1897,16 @@ void SocialWindow::updateGuildCounter(const int online, const int total) } } +void SocialWindow::updatedPlayer(const std::string &name A_UNUSED) +{ + mNeedUpdate = true; +} + +void SocialWindow::updateAll() +{ + mNeedUpdate = true; +} + #ifdef USE_PROFILER void SocialWindow::logicChildren() { diff --git a/src/gui/windows/socialwindow.h b/src/gui/windows/socialwindow.h index 018b5f32c..e8dc44043 100644 --- a/src/gui/windows/socialwindow.h +++ b/src/gui/windows/socialwindow.h @@ -24,6 +24,8 @@ #include "gui/widgets/window.h" +#include "being/playerrelationslistener.h" + #include <guichan/actionlistener.hpp> #include <string> @@ -45,7 +47,9 @@ class TextDialog; * * \ingroup Interface */ -class SocialWindow final : public Window, private gcn::ActionListener +class SocialWindow final : public Window, + private gcn::ActionListener, + public PlayerRelationsListener { public: SocialWindow(); @@ -125,6 +129,10 @@ public: void updateGuildCounter(const int online = 0, const int total = 0); + void updatedPlayer(const std::string &name); + + void updateAll(); + #ifdef USE_PROFILER void logicChildren(); #endif diff --git a/src/gui/windows/statuswindow.cpp b/src/gui/windows/statuswindow.cpp index 567460927..80e86e66f 100644 --- a/src/gui/windows/statuswindow.cpp +++ b/src/gui/windows/statuswindow.cpp @@ -36,7 +36,7 @@ #include "gui/viewport.h" #include "gui/windows/equipmentwindow.h" -#include "gui/windows/setup.h" +#include "gui/windows/setupwindow.h" #include "gui/widgets/button.h" #include "gui/widgets/label.h" @@ -606,7 +606,7 @@ void StatusWindow::updateJobBar(ProgressBar *const bar, const bool percent) } void StatusWindow::updateProgressBar(ProgressBar *const bar, const int id, - const bool percent) const + const bool percent) { const std::pair<int, int> exp = PlayerInfo::getStatExperience(id); updateProgressBar(bar, exp.first, exp.second, percent); @@ -733,10 +733,10 @@ void StatusWindow::updateStatusBar(ProgressBar *const bar, player_node->getQuickDropCounterString())) .append(translateLetter2(player_node->getPickUpTypeString())) .append(" ").append(translateLetter2( - player_node->getDebugPathString())) + LocalPlayer::getDebugPathString())) .append(" ").append(translateLetter2( player_node->getImitationModeString())) - .append(translateLetter2(player_node->getCameraModeString())) + .append(translateLetter2(LocalPlayer::getCameraModeString())) .append(translateLetter2(player_node->getAwayModeString()))); bar->setProgress(50); diff --git a/src/gui/windows/statuswindow.h b/src/gui/windows/statuswindow.h index 414449df0..94f1aaa65 100644 --- a/src/gui/windows/statuswindow.h +++ b/src/gui/windows/statuswindow.h @@ -79,8 +79,9 @@ class StatusWindow final : public Window, const bool percent = true); static void updateProgressBar(ProgressBar *const bar, const int value, const int max, const bool percent); - void updateProgressBar(ProgressBar *const bar, const int id, - const bool percent = true) const; + static void updateProgressBar(ProgressBar *const bar, + const int id, + const bool percent = true); void action(const gcn::ActionEvent &event) override; diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp index dfdc53a5c..a379f0f28 100644 --- a/src/gui/windows/tradewindow.cpp +++ b/src/gui/windows/tradewindow.cpp @@ -35,7 +35,7 @@ #include "gui/windows/inventorywindow.h" #include "gui/windows/itemamountwindow.h" -#include "gui/windows/setup.h" +#include "gui/windows/setupwindow.h" #include "gui/widgets/button.h" #include "gui/widgets/itemcontainer.h" diff --git a/src/gui/windows/whoisonline.h b/src/gui/windows/whoisonline.h index 1057f1898..10a8be4b5 100644 --- a/src/gui/windows/whoisonline.h +++ b/src/gui/windows/whoisonline.h @@ -153,7 +153,7 @@ public: void readFromWeb(); - void setNeutralColor(OnlinePlayer *const player); + static void setNeutralColor(OnlinePlayer *const player); void getPlayerNames(StringVect &names); diff --git a/src/input/inputmanager.cpp b/src/input/inputmanager.cpp index 090629aea..cc37001cc 100644 --- a/src/input/inputmanager.cpp +++ b/src/input/inputmanager.cpp @@ -44,7 +44,7 @@ #include "gui/windows/npcdialog.h" #include "gui/windows/npcpostdialog.h" #include "gui/windows/selldialog.h" -#include "gui/windows/setup.h" +#include "gui/windows/setupwindow.h" #include "gui/windows/textdialog.h" #include "gui/windows/tradewindow.h" #include "gui/windows/quitdialog.h" @@ -102,7 +102,7 @@ void InputManager::init() update(); } -void InputManager::update() const +void InputManager::update() { keyboard.update(); if (joystick) @@ -347,7 +347,7 @@ bool InputManager::isActionActive(const int index) const return true; } -bool InputManager::isActionActive0(const int index) const +bool InputManager::isActionActive0(const int index) { if (keyboard.isActionActive(index)) return true; @@ -497,7 +497,7 @@ void InputManager::setNewKey(const SDL_Event &event, const int type) { int val = -1; if (type == INPUT_KEYBOARD) - val = keyboard.getKeyValueFromEvent(event); + val = KeyboardConfig::getKeyValueFromEvent(event); else if (type == INPUT_JOYSTICK && joystick) val = joystick->getButtonFromEvent(event); @@ -651,7 +651,7 @@ bool InputManager::handleEvent(const SDL_Event &event) return false; } -void InputManager::handleRepeat() const +void InputManager::handleRepeat() { const int time = tick_time; keyboard.handleRepeat(time); diff --git a/src/input/inputmanager.h b/src/input/inputmanager.h index ce662611a..630b52948 100644 --- a/src/input/inputmanager.h +++ b/src/input/inputmanager.h @@ -164,14 +164,14 @@ class InputManager final bool handleAssignKey(const SDL_Event &event, const int type); - void handleRepeat() const; + static void handleRepeat(); bool triggerAction(const KeysVector *const ptrs); int getKeyIndex(const int value, const int grp, const int type) const A_WARN_UNUSED; - void update() const; + static void update(); void updateConditionMask(); @@ -180,7 +180,7 @@ class InputManager final void executeAction(const int keyNum); protected: - bool isActionActive0(const int index) const A_WARN_UNUSED; + static bool isActionActive0(const int index) A_WARN_UNUSED; Setup_Input *mSetupInput; /**< Reference to setup window */ diff --git a/src/input/keyboardconfig.cpp b/src/input/keyboardconfig.cpp index 6cf524842..3756e27fb 100644 --- a/src/input/keyboardconfig.cpp +++ b/src/input/keyboardconfig.cpp @@ -59,7 +59,7 @@ void KeyboardConfig::deinit() mActiveKeys2 = nullptr; } -int KeyboardConfig::getKeyValueFromEvent(const SDL_Event &event) const +int KeyboardConfig::getKeyValueFromEvent(const SDL_Event &event) { #ifdef USE_SDL2 return event.key.keysym.scancode; @@ -72,7 +72,7 @@ int KeyboardConfig::getKeyValueFromEvent(const SDL_Event &event) const return 0; } -int KeyboardConfig::getKeyIndex(const SDL_Event &event, const int grp) const +int KeyboardConfig::getKeyIndex(const SDL_Event &event, const int grp) { const int keyValue = getKeyValueFromEvent(event); return inputManager.getKeyIndex(keyValue, grp, INPUT_KEYBOARD); diff --git a/src/input/keyboardconfig.h b/src/input/keyboardconfig.h index 5e8232508..7f7102964 100644 --- a/src/input/keyboardconfig.h +++ b/src/input/keyboardconfig.h @@ -56,8 +56,8 @@ class KeyboardConfig final /** * Get the key function index by providing the keys value. */ - int getKeyIndex(const SDL_Event &event, - const int grp = 1) const A_WARN_UNUSED; + static int getKeyIndex(const SDL_Event &event, + const int grp = 1) A_WARN_UNUSED; /** * Set the enable flag, which will stop the user from doing actions. @@ -75,7 +75,7 @@ class KeyboardConfig final static SDLKey getKeyFromEvent(const SDL_Event &event) A_WARN_UNUSED; - int getKeyValueFromEvent(const SDL_Event &event) const A_WARN_UNUSED; + static int getKeyValueFromEvent(const SDL_Event &event) A_WARN_UNUSED; KeysVector *getActionVector(const SDL_Event &event) A_WARN_UNUSED; diff --git a/src/input/keyboarddata.h b/src/input/keyboarddata.h index c250b759e..e6bafb61b 100644 --- a/src/input/keyboarddata.h +++ b/src/input/keyboarddata.h @@ -2051,7 +2051,42 @@ static const KeyData keyData[Input::KEY_TOTAL] = { Input::GRP_GUICHAN, nullptr, Input::KEY_NO_VALUE, 50, - COND_DEFAULT} + COND_DEFAULT}, + {"keyShortcutsPrevTab", + INPUT_UNKNOWN, Input::KEY_NO_VALUE, + INPUT_UNKNOWN, Input::KEY_NO_VALUE, + Input::GRP_DEFAULT | Input::GRP_GUI, + &ActionManager::prevShortcutsTab, + Input::KEY_NO_VALUE, 50, + COND_NOINPUT | COND_INGAME}, + {"keyShortcutsNextTab", + INPUT_UNKNOWN, Input::KEY_NO_VALUE, + INPUT_UNKNOWN, Input::KEY_NO_VALUE, + Input::GRP_DEFAULT | Input::GRP_GUI, + &ActionManager::nextShortcutsTab, + Input::KEY_NO_VALUE, 50, + COND_NOINPUT | COND_INGAME}, + {"keyCommandsPrevTab", + INPUT_UNKNOWN, Input::KEY_NO_VALUE, + INPUT_UNKNOWN, Input::KEY_NO_VALUE, + Input::GRP_DEFAULT | Input::GRP_GUI, + &ActionManager::prevCommandsTab, + Input::KEY_NO_VALUE, 50, + COND_NOINPUT | COND_INGAME}, + {"keyCommandsNextTab", + INPUT_UNKNOWN, Input::KEY_NO_VALUE, + INPUT_UNKNOWN, Input::KEY_NO_VALUE, + Input::GRP_DEFAULT | Input::GRP_GUI, + &ActionManager::nextCommandsTab, + Input::KEY_NO_VALUE, 50, + COND_NOINPUT | COND_INGAME}, + {"keyOpenTrade", + INPUT_UNKNOWN, Input::KEY_NO_VALUE, + INPUT_UNKNOWN, Input::KEY_NO_VALUE, + Input::GRP_DEFAULT, + &ActionManager::openTrade, + Input::KEY_NO_VALUE, 50, + COND_GAME | COND_NOTARGET}, }; #endif // INPUT_KEYBOARDDATA_H diff --git a/src/input/keydata.h b/src/input/keydata.h index a0fb8341b..2ceb957c5 100644 --- a/src/input/keydata.h +++ b/src/input/keydata.h @@ -353,6 +353,11 @@ namespace Input KEY_GUI_U, KEY_GUI_V, KEY_GUI_W, + KEY_PREV_SHORTCUTS_TAB, + KEY_NEXT_SHORTCUTS_TAB, + KEY_PREV_COMMANDS_TAB, + KEY_NEXT_COMMANDS_TAB, + KEY_OPEN_TRADE, KEY_TOTAL }; } // namespace Input diff --git a/src/itemshortcut.h b/src/itemshortcut.h index 2293a1583..b40ae87f1 100644 --- a/src/itemshortcut.h +++ b/src/itemshortcut.h @@ -72,7 +72,7 @@ class ItemShortcut final /** * Returns the amount of shortcut items. */ - int getItemCount() const A_WARN_UNUSED + static int getItemCount() A_WARN_UNUSED { return SHORTCUT_ITEMS; } /** diff --git a/src/main.h b/src/main.h index 976b4e584..2035338a6 100644 --- a/src/main.h +++ b/src/main.h @@ -45,8 +45,8 @@ * different interfaces, which have different implementations for each server. */ -#define SMALL_VERSION "1.4.2.1" -#define CHECK_VERSION "01.04.02.01" +#define SMALL_VERSION "1.4.2.15" +#define CHECK_VERSION "01.04.02.15" #ifdef HAVE_CONFIG_H #include "../config.h" diff --git a/src/map.cpp b/src/map.cpp index 0bbb21271..5dc1bfc0f 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -290,6 +290,8 @@ void Map::initializeAmbientLayers() mForegrounds.push_back(new AmbientLayer(img, getFloatProperty(name + "parallaxX", parallax), getFloatProperty(name + "parallaxY", parallax), + getFloatProperty(name + "posX"), + getFloatProperty(name + "posY"), getFloatProperty(name + "scrollX"), getFloatProperty(name + "scrollY"), getBoolProperty(name + "keepratio"), @@ -317,6 +319,8 @@ void Map::initializeAmbientLayers() mForegrounds.push_back(new AmbientLayer(img, getFloatProperty(name + "parallaxX", parallax), getFloatProperty(name + "parallaxY", parallax), + getFloatProperty(name + "posX"), + getFloatProperty(name + "posY"), getFloatProperty(name + "scrollX"), getFloatProperty(name + "scrollY"), getBoolProperty(name + "keepratio"), @@ -738,7 +742,7 @@ bool Map::getWalk(const int x, const int y, const unsigned char walkmask) const return !(mMetaTiles[x + y * mWidth].blockmask & walkmask); } -unsigned char Map::getBlockMask(const int x, const int y) +unsigned char Map::getBlockMask(const int x, const int y) const { // You can't walk outside of the map if (x < 0 || y < 0 || x >= mWidth || y >= mHeight) @@ -240,7 +240,7 @@ class Map final : public Properties, public ConfigListener void setWalk(const int x, const int y, const bool walkable); - unsigned char getBlockMask(const int x, const int y); + unsigned char getBlockMask(const int x, const int y) const; /** * Returns the width of this map in tiles. diff --git a/src/maplayer.cpp b/src/maplayer.cpp index 2bb7884d8..3da8ba7d9 100644 --- a/src/maplayer.cpp +++ b/src/maplayer.cpp @@ -548,7 +548,8 @@ void MapLayer::drawFringe(Graphics *const graphics, int startX, int startY, } int MapLayer::getTileDrawWidth(const Image *img, - const int endX, int &width) const + const int endX, + int &width) { BLOCK_START("MapLayer::getTileDrawWidth") const Image *const img1 = img; diff --git a/src/maplayer.h b/src/maplayer.h index 697f52c89..dcfdb991e 100644 --- a/src/maplayer.h +++ b/src/maplayer.h @@ -177,8 +177,9 @@ class MapLayer final: public ConfigListener void optionChanged(const std::string &value) override final; - int getTileDrawWidth(const Image *img, - const int endX, int &width) const A_WARN_UNUSED; + static int getTileDrawWidth(const Image *img, + const int endX, + int &width) A_WARN_UNUSED; private: int mX; diff --git a/src/mumblemanager.cpp b/src/mumblemanager.cpp index 43b10b76b..7a2337b7e 100644 --- a/src/mumblemanager.cpp +++ b/src/mumblemanager.cpp @@ -56,7 +56,7 @@ MumbleManager::~MumbleManager() } } -uint16_t MumbleManager::getMapId(std::string mapName) const +uint16_t MumbleManager::getMapId(std::string mapName) { uint16_t res = 0; if (mapName.size() != 5 || mapName[3] != '-') diff --git a/src/mumblemanager.h b/src/mumblemanager.h index 12de869e4..4d76f0f54 100644 --- a/src/mumblemanager.h +++ b/src/mumblemanager.h @@ -60,7 +60,7 @@ class MumbleManager final void setServer(const std::string &serverName); private: - uint16_t getMapId(std::string mapName) const A_WARN_UNUSED; + static uint16_t getMapId(std::string mapName) A_WARN_UNUSED; void setMapBase(uint16_t mapid); diff --git a/src/net/ea/gui/guildtab.cpp b/src/net/ea/gui/guildtab.cpp index 6a801bba4..46b1f1649 100644 --- a/src/net/ea/gui/guildtab.cpp +++ b/src/net/ea/gui/guildtab.cpp @@ -63,28 +63,6 @@ GuildTab::~GuildTab() bool GuildTab::handleCommand(const std::string &restrict type, const std::string &restrict args) { - if (type == "help") - { - if (args == "invite") - { - // TRANSLATORS: guild chat help - chatLog(_("Command: /invite <nick>")); - // TRANSLATORS: guild chat help - chatLog(_("This command invites <nick> to the guild you're in.")); - // TRANSLATORS: guild chat help - chatLog(_("If the <nick> has spaces in it, enclose it in " - "double quotes (\").")); - } - else if (args == "leave") - { - // TRANSLATORS: guild chat help - chatLog(_("Command: /leave")); - // TRANSLATORS: guild chat help - chatLog(_("This command causes the player to leave the guild.")); - } - else - return false; - } /* else if (type == "create" || type == "new") { @@ -94,7 +72,7 @@ bool GuildTab::handleCommand(const std::string &restrict type, Net::getGuildHandler()->create(args); } */ - else if (type == "invite" && taGuild) + if (type == "invite" && taGuild) { Net::getGuildHandler()->invite(taGuild->getId(), args); } @@ -127,34 +105,23 @@ void GuildTab::handleInput(const std::string &msg) if (!taGuild) return; - if (chatWindow) - { - Net::getGuildHandler()->chat(taGuild->getId(), - chatWindow->doReplace(msg)); - } - else - { - Net::getGuildHandler()->chat(taGuild->getId(), msg); - } -} - -void GuildTab::showHelp() -{ - // TRANSLATORS: guild chat help - chatLog(_("/help > Display this help.")); - // TRANSLATORS: guild chat help - chatLog(_("/invite > Invite a player to your guild")); - // TRANSLATORS: guild chat help - chatLog(_("/leave > Leave the guild you are in")); - // TRANSLATORS: guild chat help - chatLog(_("/kick > Kick someone from the guild you are in")); + Net::getGuildHandler()->chat(taGuild->getId(), + ChatWindow::doReplace(msg)); } void GuildTab::getAutoCompleteList(StringVect &names) const { if (taGuild) taGuild->getNames(names); +} + +void GuildTab::getAutoCompleteCommands(StringVect &names) const +{ + names.push_back("/help"); + names.push_back("/invite "); + names.push_back("/kick "); names.push_back("/notice "); + names.push_back("/leave"); } void GuildTab::saveToLogFile(const std::string &msg) const diff --git a/src/net/ea/gui/guildtab.h b/src/net/ea/gui/guildtab.h index 442ad62d0..2b6a4bd1a 100644 --- a/src/net/ea/gui/guildtab.h +++ b/src/net/ea/gui/guildtab.h @@ -43,8 +43,6 @@ class GuildTab : public ChatTab, public ConfigListener bool handleCommand(const std::string &restrict type, const std::string &restrict args) override final; - void showHelp() override; - void saveToLogFile(const std::string &msg) const override final; int getType() const override final A_WARN_UNUSED @@ -58,6 +56,8 @@ class GuildTab : public ChatTab, public ConfigListener void handleInput(const std::string &msg) override final; void getAutoCompleteList(StringVect &names) const override final; + + void getAutoCompleteCommands(StringVect &names) const override final; }; } // namespace Ea diff --git a/src/net/ea/gui/partytab.cpp b/src/net/ea/gui/partytab.cpp index 76e204205..79a9a8897 100644 --- a/src/net/ea/gui/partytab.cpp +++ b/src/net/ea/gui/partytab.cpp @@ -64,90 +64,13 @@ PartyTab::~PartyTab() void PartyTab::handleInput(const std::string &msg) { - if (chatWindow) - Net::getPartyHandler()->chat(chatWindow->doReplace(msg)); - else - Net::getPartyHandler()->chat(msg); -} - -void PartyTab::showHelp() -{ - // TRANSLATORS: party help message - chatLog(_("/help > Display this help.")); - // TRANSLATORS: party help message - chatLog(_("/invite > Invite a player to your party")); - // TRANSLATORS: party help message - chatLog(_("/leave > Leave the party you are in")); - // TRANSLATORS: party help message - chatLog(_("/kick > Kick someone from the party you are in")); - // TRANSLATORS: party help message - chatLog(_("/item > Show/change party item sharing options")); - // TRANSLATORS: party help message - chatLog(_("/exp > Show/change party experience sharing options")); + Net::getPartyHandler()->chat(ChatWindow::doReplace(msg)); } bool PartyTab::handleCommand(const std::string &restrict type, const std::string &restrict args) { - if (type == "help") - { - if (args == "invite") - { - // TRANSLATORS: party help message - chatLog(_("Command: /invite <nick>")); - // TRANSLATORS: party help message - chatLog(_("This command invites <nick> to party with you.")); - // TRANSLATORS: party help message - chatLog(_("If the <nick> has spaces in it, enclose it in " - "double quotes (\").")); - } - else if (args == "leave") - { - // TRANSLATORS: party help message - chatLog(_("Command: /leave")); - // TRANSLATORS: party help message - chatLog(_("This command causes the player to leave the party.")); - } - else if (args == "item") - { - // TRANSLATORS: party help message - chatLog(_("Command: /item <policy>")); - // TRANSLATORS: party help message - chatLog( - _("This command changes the party's item sharing policy.")); - // TRANSLATORS: party help message - chatLog(_("<policy> can be one of \"1\", \"yes\", \"true\" to " - "enable item sharing, or \"0\", \"no\", \"false\" to " - "disable item sharing.")); - // TRANSLATORS: party help message - chatLog(_("Command: /item")); - // TRANSLATORS: party help message - chatLog(_("This command displays the party's" - " current item sharing policy.")); - } - else if (args == "exp") - { - // TRANSLATORS: party help message - chatLog(_("Command: /exp <policy>")); - // TRANSLATORS: party help message - chatLog(_("This command changes the party's " - "experience sharing policy.")); - // TRANSLATORS: party help message - chatLog(_("<policy> can be one of \"1\", \"yes\", \"true\" to " - "enable experience sharing, or \"0\"," - " \"no\", \"false\" to disable experience sharing.")); - // TRANSLATORS: party help message - chatLog(_("Command: /exp")); - // TRANSLATORS: party help message - chatLog(_("This command displays the party's current " - "experience sharing policy.")); - } - else - { - return false; - } - } - else if (type == "create" || type == "new") + if (type == "create" || type == "new") { if (args.empty()) { @@ -278,6 +201,16 @@ void PartyTab::getAutoCompleteList(StringVect &names) const p->getNames(names); } +void PartyTab::getAutoCompleteCommands(StringVect &names) const +{ + names.push_back("/help"); + names.push_back("/invite "); + names.push_back("/leave"); + names.push_back("/kick "); + names.push_back("/item"); + names.push_back("/exp"); +} + void PartyTab::saveToLogFile(const std::string &msg) const { if (chatLogger) diff --git a/src/net/ea/gui/partytab.h b/src/net/ea/gui/partytab.h index a73fbaaeb..d141452d0 100644 --- a/src/net/ea/gui/partytab.h +++ b/src/net/ea/gui/partytab.h @@ -40,8 +40,6 @@ class PartyTab : public ChatTab, public ConfigListener virtual ~PartyTab(); - void showHelp() override final; - bool handleCommand(const std::string &restrict type, const std::string &restrict args) override final; @@ -57,7 +55,9 @@ class PartyTab : public ChatTab, public ConfigListener protected: void handleInput(const std::string &msg) override final; - virtual void getAutoCompleteList(StringVect&) const override final; + void getAutoCompleteList(StringVect&) const override final; + + void getAutoCompleteCommands(StringVect &names) const override final; }; extern PartyTab *partyTab; diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp index 94b81adb0..74f0a4ba7 100644 --- a/src/net/ea/inventoryhandler.cpp +++ b/src/net/ea/inventoryhandler.cpp @@ -337,7 +337,7 @@ void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg) } } -void InventoryHandler::processPlayerInventoryRemove(Net::MessageIn &msg) const +void InventoryHandler::processPlayerInventoryRemove(Net::MessageIn &msg) { Inventory *const inventory = player_node ? PlayerInfo::getInventory() : nullptr; @@ -357,7 +357,7 @@ void InventoryHandler::processPlayerInventoryRemove(Net::MessageIn &msg) const } } -void InventoryHandler::processPlayerInventoryUse(Net::MessageIn &msg) const +void InventoryHandler::processPlayerInventoryUse(Net::MessageIn &msg) { Inventory *const inventory = player_node ? PlayerInfo::getInventory() : nullptr; @@ -380,7 +380,7 @@ void InventoryHandler::processPlayerInventoryUse(Net::MessageIn &msg) const } } -void InventoryHandler::processItemUseResponse(Net::MessageIn &msg) const +void InventoryHandler::processItemUseResponse(Net::MessageIn &msg) { Inventory *const inventory = player_node ? PlayerInfo::getInventory() : nullptr; diff --git a/src/net/ea/inventoryhandler.h b/src/net/ea/inventoryhandler.h index eea4dde12..6e8ecec38 100644 --- a/src/net/ea/inventoryhandler.h +++ b/src/net/ea/inventoryhandler.h @@ -180,11 +180,11 @@ class InventoryHandler : public Net::InventoryHandler void processPlayerInventoryAdd(Net::MessageIn &msg); - void processPlayerInventoryRemove(Net::MessageIn &msg) const; + static void processPlayerInventoryRemove(Net::MessageIn &msg); - void processPlayerInventoryUse(Net::MessageIn &msg) const; + static void processPlayerInventoryUse(Net::MessageIn &msg); - void processItemUseResponse(Net::MessageIn &msg) const; + static void processItemUseResponse(Net::MessageIn &msg); void processPlayerStorageStatus(Net::MessageIn &msg); diff --git a/src/net/ea/itemhandler.cpp b/src/net/ea/itemhandler.cpp index aaab0ca3e..9ce85a59b 100644 --- a/src/net/ea/itemhandler.cpp +++ b/src/net/ea/itemhandler.cpp @@ -37,7 +37,7 @@ ItemHandler::~ItemHandler() { } -void ItemHandler::processItemVisible(Net::MessageIn &msg) const +void ItemHandler::processItemVisible(Net::MessageIn &msg) { const int id = msg.readInt32(); const int itemId = msg.readInt16(); @@ -55,7 +55,7 @@ void ItemHandler::processItemVisible(Net::MessageIn &msg) const } } -void ItemHandler::processItemDropped(Net::MessageIn &msg) const +void ItemHandler::processItemDropped(Net::MessageIn &msg) { const int id = msg.readInt32(); const int itemId = msg.readInt16(); @@ -73,7 +73,7 @@ void ItemHandler::processItemDropped(Net::MessageIn &msg) const } } -void ItemHandler::processItemRemove(Net::MessageIn &msg) const +void ItemHandler::processItemRemove(Net::MessageIn &msg) { if (actorManager) { diff --git a/src/net/ea/itemhandler.h b/src/net/ea/itemhandler.h index 8b07789f9..6bc23fb10 100644 --- a/src/net/ea/itemhandler.h +++ b/src/net/ea/itemhandler.h @@ -37,11 +37,11 @@ class ItemHandler virtual ~ItemHandler(); - void processItemVisible(Net::MessageIn &msg) const; + static void processItemVisible(Net::MessageIn &msg); - void processItemRemove(Net::MessageIn &msg) const; + static void processItemRemove(Net::MessageIn &msg); - void processItemDropped(Net::MessageIn &msg) const; + static void processItemDropped(Net::MessageIn &msg); }; } // namespace Ea diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp index c6d20573d..3e5db9169 100644 --- a/src/net/ea/playerhandler.cpp +++ b/src/net/ea/playerhandler.cpp @@ -124,7 +124,7 @@ Vector PlayerHandler::getDefaultWalkSpeed() const return Vector(150, 150, 0); } -void PlayerHandler::processWalkResponse(Net::MessageIn &msg) const +void PlayerHandler::processWalkResponse(Net::MessageIn &msg) { BLOCK_START("PlayerHandler::processWalkResponse") /* @@ -140,7 +140,7 @@ void PlayerHandler::processWalkResponse(Net::MessageIn &msg) const BLOCK_END("PlayerHandler::processWalkResponse") } -void PlayerHandler::processPlayerWarp(Net::MessageIn &msg) const +void PlayerHandler::processPlayerWarp(Net::MessageIn &msg) { BLOCK_START("PlayerHandler::processPlayerWarp") std::string mapPath = msg.readString(16); @@ -216,7 +216,7 @@ void PlayerHandler::processPlayerWarp(Net::MessageIn &msg) const BLOCK_END("PlayerHandler::processPlayerWarp") } -void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg) const +void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg) { BLOCK_START("PlayerHandler::processPlayerStatUpdate1") const int type = msg.readInt16(); @@ -405,7 +405,7 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg) const BLOCK_END("PlayerHandler::processPlayerStatUpdate1") } -void PlayerHandler::processPlayerStatUpdate2(Net::MessageIn &msg) const +void PlayerHandler::processPlayerStatUpdate2(Net::MessageIn &msg) { BLOCK_START("PlayerHandler::processPlayerStatUpdate2") const int type = msg.readInt16(); @@ -450,7 +450,7 @@ void PlayerHandler::processPlayerStatUpdate2(Net::MessageIn &msg) const BLOCK_END("PlayerHandler::processPlayerStatUpdate2") } -void PlayerHandler::processPlayerStatUpdate3(Net::MessageIn &msg) const +void PlayerHandler::processPlayerStatUpdate3(Net::MessageIn &msg) { BLOCK_START("PlayerHandler::processPlayerStatUpdate3") const int type = msg.readInt32(); @@ -464,7 +464,7 @@ void PlayerHandler::processPlayerStatUpdate3(Net::MessageIn &msg) const BLOCK_END("PlayerHandler::processPlayerStatUpdate3") } -void PlayerHandler::processPlayerStatUpdate4(Net::MessageIn &msg) const +void PlayerHandler::processPlayerStatUpdate4(Net::MessageIn &msg) { BLOCK_START("PlayerHandler::processPlayerStatUpdate4") const int type = msg.readInt16(); @@ -484,7 +484,7 @@ void PlayerHandler::processPlayerStatUpdate4(Net::MessageIn &msg) const BLOCK_END("PlayerHandler::processPlayerStatUpdate4") } -void PlayerHandler::processPlayerStatUpdate5(Net::MessageIn &msg) const +void PlayerHandler::processPlayerStatUpdate5(Net::MessageIn &msg) { BLOCK_START("PlayerHandler::processPlayerStatUpdate5") PlayerInfo::setAttribute(PlayerInfo::CHAR_POINTS, msg.readInt16()); @@ -558,7 +558,7 @@ void PlayerHandler::processPlayerStatUpdate5(Net::MessageIn &msg) const BLOCK_END("PlayerHandler::processPlayerStatUpdate5") } -void PlayerHandler::processPlayerStatUpdate6(Net::MessageIn &msg) const +void PlayerHandler::processPlayerStatUpdate6(Net::MessageIn &msg) { BLOCK_START("PlayerHandler::processPlayerStatUpdate6") const int type = msg.readInt16(); @@ -593,7 +593,7 @@ void PlayerHandler::processPlayerStatUpdate6(Net::MessageIn &msg) const BLOCK_END("PlayerHandler::processPlayerStatUpdate6") } -void PlayerHandler::processPlayerArrowMessage(Net::MessageIn &msg) const +void PlayerHandler::processPlayerArrowMessage(Net::MessageIn &msg) { BLOCK_START("PlayerHandler::processPlayerArrowMessage") const int type = msg.readInt16(); diff --git a/src/net/ea/playerhandler.h b/src/net/ea/playerhandler.h index 2bac97ac1..589874e2e 100644 --- a/src/net/ea/playerhandler.h +++ b/src/net/ea/playerhandler.h @@ -53,23 +53,23 @@ class PlayerHandler : public Net::PlayerHandler int getAttackLocation() const override final A_WARN_UNUSED; - void processWalkResponse(Net::MessageIn &msg) const; + static void processWalkResponse(Net::MessageIn &msg); - void processPlayerWarp(Net::MessageIn &msg) const; + static void processPlayerWarp(Net::MessageIn &msg); - void processPlayerStatUpdate1(Net::MessageIn &msg) const; + static void processPlayerStatUpdate1(Net::MessageIn &msg); - void processPlayerStatUpdate2(Net::MessageIn &msg) const; + static void processPlayerStatUpdate2(Net::MessageIn &msg); - void processPlayerStatUpdate3(Net::MessageIn &msg) const; + static void processPlayerStatUpdate3(Net::MessageIn &msg); - void processPlayerStatUpdate4(Net::MessageIn &msg) const; + static void processPlayerStatUpdate4(Net::MessageIn &msg); - void processPlayerStatUpdate5(Net::MessageIn &msg) const; + static void processPlayerStatUpdate5(Net::MessageIn &msg); - void processPlayerStatUpdate6(Net::MessageIn &msg) const; + static void processPlayerStatUpdate6(Net::MessageIn &msg); - void processPlayerArrowMessage(Net::MessageIn &msg) const; + static void processPlayerArrowMessage(Net::MessageIn &msg); }; } // namespace Ea diff --git a/src/net/ea/skillhandler.cpp b/src/net/ea/skillhandler.cpp index 3f5b38c68..3a5a1ab75 100644 --- a/src/net/ea/skillhandler.cpp +++ b/src/net/ea/skillhandler.cpp @@ -71,7 +71,7 @@ SkillHandler::SkillHandler() { } -void SkillHandler::processPlayerSkills(Net::MessageIn &msg) const +void SkillHandler::processPlayerSkills(Net::MessageIn &msg) { msg.readInt16(); // length const int skillCount = (msg.getLength() - 4) / 37; @@ -101,7 +101,7 @@ void SkillHandler::processPlayerSkills(Net::MessageIn &msg) const skillDialog->playUpdateEffect(updateSkill); } -void SkillHandler::processPlayerSkillUp(Net::MessageIn &msg) const +void SkillHandler::processPlayerSkillUp(Net::MessageIn &msg) { const int skillId = msg.readInt16(); const int level = msg.readInt16(); @@ -119,7 +119,7 @@ void SkillHandler::processPlayerSkillUp(Net::MessageIn &msg) const } } -void SkillHandler::processSkillFailed(Net::MessageIn &msg) const +void SkillHandler::processSkillFailed(Net::MessageIn &msg) { // Action failed (ex. sit because you have not reached the // right level) diff --git a/src/net/ea/skillhandler.h b/src/net/ea/skillhandler.h index 251388969..8dc724e0a 100644 --- a/src/net/ea/skillhandler.h +++ b/src/net/ea/skillhandler.h @@ -36,11 +36,11 @@ class SkillHandler : public Net::SkillHandler A_DELETE_COPY(SkillHandler) - void processPlayerSkills(Net::MessageIn &msg) const; + static void processPlayerSkills(Net::MessageIn &msg); - void processPlayerSkillUp(Net::MessageIn &msg) const; + static void processPlayerSkillUp(Net::MessageIn &msg); - void processSkillFailed(Net::MessageIn &msg) const; + static void processSkillFailed(Net::MessageIn &msg); }; } // namespace Ea diff --git a/src/net/ea/tradehandler.cpp b/src/net/ea/tradehandler.cpp index 45948f963..9457a31db 100644 --- a/src/net/ea/tradehandler.cpp +++ b/src/net/ea/tradehandler.cpp @@ -182,7 +182,7 @@ void TradeHandler::processTradeResponse(Net::MessageIn &msg) const } } -void TradeHandler::processTradeItemAdd(Net::MessageIn &msg) const +void TradeHandler::processTradeItemAdd(Net::MessageIn &msg) { const int amount = msg.readInt32(); const int type = msg.readInt16(); @@ -205,7 +205,7 @@ void TradeHandler::processTradeItemAdd(Net::MessageIn &msg) const } } -void TradeHandler::processTradeItemAddResponse(Net::MessageIn &msg) const +void TradeHandler::processTradeItemAddResponse(Net::MessageIn &msg) { // Trade: New Item add response (was 0x00ea, now 01b1) const int index = msg.readInt16() - INVENTORY_OFFSET; @@ -255,7 +255,7 @@ void TradeHandler::processTradeItemAddResponse(Net::MessageIn &msg) const } } -void TradeHandler::processTradeOk(Net::MessageIn &msg) const +void TradeHandler::processTradeOk(Net::MessageIn &msg) { // 0 means ok from myself, 1 means ok from other; if (tradeWindow) @@ -264,7 +264,7 @@ void TradeHandler::processTradeOk(Net::MessageIn &msg) const msg.readInt8(); } -void TradeHandler::processTradeCancel(Net::MessageIn &msg A_UNUSED) const +void TradeHandler::processTradeCancel(Net::MessageIn &msg A_UNUSED) { NotifyManager::notify(NotifyManager::TRADE_CANCELLED); if (tradeWindow) @@ -275,7 +275,7 @@ void TradeHandler::processTradeCancel(Net::MessageIn &msg A_UNUSED) const PlayerInfo::setTrading(false); } -void TradeHandler::processTradeComplete(Net::MessageIn &msg A_UNUSED) const +void TradeHandler::processTradeComplete(Net::MessageIn &msg A_UNUSED) { NotifyManager::notify(NotifyManager::TRADE_COMPLETE); if (tradeWindow) diff --git a/src/net/ea/tradehandler.h b/src/net/ea/tradehandler.h index c3f759ef4..22a78e9e6 100644 --- a/src/net/ea/tradehandler.h +++ b/src/net/ea/tradehandler.h @@ -43,15 +43,15 @@ class TradeHandler : public Net::TradeHandler void processTradeResponse(Net::MessageIn &msg) const; - void processTradeItemAdd(Net::MessageIn &msg) const; + static void processTradeItemAdd(Net::MessageIn &msg); - void processTradeItemAddResponse(Net::MessageIn &msg) const; + static void processTradeItemAddResponse(Net::MessageIn &msg); - void processTradeOk(Net::MessageIn &msg) const; + static void processTradeOk(Net::MessageIn &msg); - void processTradeCancel(Net::MessageIn &msg) const; + static void processTradeCancel(Net::MessageIn &msg); - void processTradeComplete(Net::MessageIn &msg) const; + static void processTradeComplete(Net::MessageIn &msg); }; } // namespace Ea diff --git a/src/net/eathena/beinghandler.cpp b/src/net/eathena/beinghandler.cpp index c7d903c32..df25f40cf 100644 --- a/src/net/eathena/beinghandler.cpp +++ b/src/net/eathena/beinghandler.cpp @@ -380,7 +380,7 @@ void BeingHandler::processBeingChangeLook(Net::MessageIn &msg, } } -void BeingHandler::processNameResponse2(Net::MessageIn &msg) const +void BeingHandler::processNameResponse2(Net::MessageIn &msg) { if (!actorManager || !player_node) return; diff --git a/src/net/eathena/beinghandler.h b/src/net/eathena/beinghandler.h index 9d288b053..54271edff 100644 --- a/src/net/eathena/beinghandler.h +++ b/src/net/eathena/beinghandler.h @@ -50,7 +50,7 @@ class BeingHandler final : public MessageHandler, public Ea::BeingHandler void processBeingChangeLook(Net::MessageIn &msg, const bool look2) const; - void processNameResponse2(Net::MessageIn &msg) const; + static void processNameResponse2(Net::MessageIn &msg); void processPlayerMoveUpdate(Net::MessageIn &msg, const int type) const; diff --git a/src/net/eathena/buysellhandler.cpp b/src/net/eathena/buysellhandler.cpp index 8a637e435..31a831b25 100644 --- a/src/net/eathena/buysellhandler.cpp +++ b/src/net/eathena/buysellhandler.cpp @@ -107,7 +107,7 @@ void BuySellHandler::processNpcBuy(Net::MessageIn &msg) mBuyDialog->sort(); } -void BuySellHandler::processNpcSellResponse(Net::MessageIn &msg) const +void BuySellHandler::processNpcSellResponse(Net::MessageIn &msg) { switch (msg.readInt8()) { diff --git a/src/net/eathena/buysellhandler.h b/src/net/eathena/buysellhandler.h index b18df810a..38e9f5da1 100644 --- a/src/net/eathena/buysellhandler.h +++ b/src/net/eathena/buysellhandler.h @@ -41,7 +41,7 @@ class BuySellHandler final : public MessageHandler, public Ea::BuySellHandler void processNpcBuy(Net::MessageIn &msg); - void processNpcSellResponse(Net::MessageIn &msg) const; + static void processNpcSellResponse(Net::MessageIn &msg); }; } // namespace EAthena diff --git a/src/net/eathena/gamehandler.cpp b/src/net/eathena/gamehandler.cpp index 75cbf11e8..9c7e84554 100644 --- a/src/net/eathena/gamehandler.cpp +++ b/src/net/eathena/gamehandler.cpp @@ -172,7 +172,7 @@ void GameHandler::disconnect2() const MessageOut outMsg(CMSG_CLIENT_DISCONNECT); } -void GameHandler::processMapCharId(Net::MessageIn &msg) const +void GameHandler::processMapCharId(Net::MessageIn &msg) { msg.readInt32(); // char id } diff --git a/src/net/eathena/gamehandler.h b/src/net/eathena/gamehandler.h index 2307eb089..075bc6f94 100644 --- a/src/net/eathena/gamehandler.h +++ b/src/net/eathena/gamehandler.h @@ -53,7 +53,7 @@ class GameHandler final : public MessageHandler, public Ea::GameHandler void mapLoadedEvent() const override final; - void processMapCharId(Net::MessageIn &msg) const; + static void processMapCharId(Net::MessageIn &msg); bool mustPing() const override final A_WARN_UNUSED { return true; } diff --git a/src/net/eathena/loginhandler.cpp b/src/net/eathena/loginhandler.cpp index 685626d98..5ebec5106 100644 --- a/src/net/eathena/loginhandler.cpp +++ b/src/net/eathena/loginhandler.cpp @@ -153,7 +153,7 @@ ServerInfo *LoginHandler::getCharServer() const return &charServer; } -void LoginHandler::requestUpdateHosts() const +void LoginHandler::requestUpdateHosts() { MessageOut outMsg(CMSG_SEND_CLIENT_INFO); outMsg.writeInt8(CLIENT_PROTOCOL_VERSION); diff --git a/src/net/eathena/loginhandler.h b/src/net/eathena/loginhandler.h index 14d432585..a1d791fdf 100644 --- a/src/net/eathena/loginhandler.h +++ b/src/net/eathena/loginhandler.h @@ -66,7 +66,7 @@ class LoginHandler final : public MessageHandler, public Ea::LoginHandler void processServerVersion(Net::MessageIn &msg); - void requestUpdateHosts() const; + static void requestUpdateHosts(); void processUpdateHost2(Net::MessageIn &msg) const; diff --git a/src/net/eathena/npchandler.cpp b/src/net/eathena/npchandler.cpp index f4f4eada5..75db7396b 100644 --- a/src/net/eathena/npchandler.cpp +++ b/src/net/eathena/npchandler.cpp @@ -242,14 +242,14 @@ int NpcHandler::getNpc(Net::MessageIn &msg, const bool haveLength) } void NpcHandler::processNpcCutin(Net::MessageIn &msg A_UNUSED, - const int npcId A_UNUSED) const + const int npcId A_UNUSED) { msg.readString(64); // image name msg.readInt8(); // type } void NpcHandler::processNpcViewPoint(Net::MessageIn &msg A_UNUSED, - const int npcId A_UNUSED) const + const int npcId A_UNUSED) { msg.readInt32(); // type msg.readInt32(); // x diff --git a/src/net/eathena/npchandler.h b/src/net/eathena/npchandler.h index fd565a5ed..8c2f61b55 100644 --- a/src/net/eathena/npchandler.h +++ b/src/net/eathena/npchandler.h @@ -67,9 +67,9 @@ class NpcHandler final : public MessageHandler, public Ea::NpcHandler int getNpc(Net::MessageIn &msg, const bool haveLength) override final; - void processNpcCutin(Net::MessageIn &msg, const int npcId) const; + static void processNpcCutin(Net::MessageIn &msg, const int npcId); - void processNpcViewPoint(Net::MessageIn &msg, const int npcId) const; + static void processNpcViewPoint(Net::MessageIn &msg, const int npcId); }; } // namespace EAthena diff --git a/src/net/eathena/playerhandler.cpp b/src/net/eathena/playerhandler.cpp index 54b4322d0..f4305f280 100644 --- a/src/net/eathena/playerhandler.cpp +++ b/src/net/eathena/playerhandler.cpp @@ -223,7 +223,7 @@ void PlayerHandler::updateStatus(const uint8_t status) const outMsg.writeInt8(0); } -void PlayerHandler::processPlayerShortcuts(Net::MessageIn &msg) const +void PlayerHandler::processPlayerShortcuts(Net::MessageIn &msg) { for (int f = 0; f < 27; f ++) { @@ -233,7 +233,7 @@ void PlayerHandler::processPlayerShortcuts(Net::MessageIn &msg) const } } -void PlayerHandler::processPlayerShowEquip(Net::MessageIn &msg) const +void PlayerHandler::processPlayerShowEquip(Net::MessageIn &msg) { msg.readInt8(); // show equip } diff --git a/src/net/eathena/playerhandler.h b/src/net/eathena/playerhandler.h index ee7bd1e39..087c42973 100644 --- a/src/net/eathena/playerhandler.h +++ b/src/net/eathena/playerhandler.h @@ -53,8 +53,8 @@ class PlayerHandler final : public MessageHandler, public Ea::PlayerHandler void changeAction(const Being::Action &action) const override final; void updateStatus(const uint8_t status) const override final; - void processPlayerShortcuts(Net::MessageIn &msg) const; - void processPlayerShowEquip(Net::MessageIn &msg) const; + static void processPlayerShortcuts(Net::MessageIn &msg); + static void processPlayerShowEquip(Net::MessageIn &msg); void requestOnlineList() const override final; void respawn() const override final; diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp index 043321cd5..76efd958e 100644 --- a/src/net/tmwa/beinghandler.cpp +++ b/src/net/tmwa/beinghandler.cpp @@ -389,12 +389,11 @@ void BeingHandler::processBeingChangeLook(Net::MessageIn &msg, } } -void BeingHandler::processNameResponse2(Net::MessageIn &msg) const +void BeingHandler::processNameResponse2(Net::MessageIn &msg) { if (!actorManager || !player_node) return; - const int len = msg.readInt16(); const int beingId = msg.readInt32(); const std::string str = msg.readString(len - 8); @@ -653,7 +652,7 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, dstBeing->setMoveTime(); } -void BeingHandler::processBeingMove3(Net::MessageIn &msg) const +void BeingHandler::processBeingMove3(Net::MessageIn &msg) { if (serverVersion < 10) return; diff --git a/src/net/tmwa/beinghandler.h b/src/net/tmwa/beinghandler.h index f35921256..f3b57b023 100644 --- a/src/net/tmwa/beinghandler.h +++ b/src/net/tmwa/beinghandler.h @@ -47,12 +47,12 @@ class BeingHandler final : public MessageHandler, public Ea::BeingHandler void processBeingChangeLook(Net::MessageIn &msg, const bool look2) const; - void processNameResponse2(Net::MessageIn &msg) const; + static void processNameResponse2(Net::MessageIn &msg); void processPlayerMoveUpdate(Net::MessageIn &msg, const int type) const; - void processBeingMove3(Net::MessageIn &msg) const; + static void processBeingMove3(Net::MessageIn &msg); }; } // namespace TmwAthena diff --git a/src/net/tmwa/buysellhandler.cpp b/src/net/tmwa/buysellhandler.cpp index 71891bdec..0be6839a7 100644 --- a/src/net/tmwa/buysellhandler.cpp +++ b/src/net/tmwa/buysellhandler.cpp @@ -114,7 +114,7 @@ void BuySellHandler::processNpcBuy(Net::MessageIn &msg) mBuyDialog->sort(); } -void BuySellHandler::processNpcSellResponse(Net::MessageIn &msg) const +void BuySellHandler::processNpcSellResponse(Net::MessageIn &msg) { switch (msg.readInt8()) { diff --git a/src/net/tmwa/buysellhandler.h b/src/net/tmwa/buysellhandler.h index 9fa6caddc..a0c99908f 100644 --- a/src/net/tmwa/buysellhandler.h +++ b/src/net/tmwa/buysellhandler.h @@ -41,7 +41,7 @@ class BuySellHandler final : public MessageHandler, public Ea::BuySellHandler void processNpcBuy(Net::MessageIn &msg); - void processNpcSellResponse(Net::MessageIn &msg) const; + static void processNpcSellResponse(Net::MessageIn &msg); }; } // namespace TmwAthena diff --git a/src/net/tmwa/loginhandler.cpp b/src/net/tmwa/loginhandler.cpp index 95dd59350..3797a7a54 100644 --- a/src/net/tmwa/loginhandler.cpp +++ b/src/net/tmwa/loginhandler.cpp @@ -178,7 +178,7 @@ ServerInfo *LoginHandler::getCharServer() const return &charServer; } -void LoginHandler::requestUpdateHosts() const +void LoginHandler::requestUpdateHosts() { MessageOut outMsg(CMSG_SEND_CLIENT_INFO); outMsg.writeInt8(CLIENT_PROTOCOL_VERSION); diff --git a/src/net/tmwa/loginhandler.h b/src/net/tmwa/loginhandler.h index 20ca3f52d..632f02d62 100644 --- a/src/net/tmwa/loginhandler.h +++ b/src/net/tmwa/loginhandler.h @@ -63,7 +63,7 @@ class LoginHandler final : public MessageHandler, public Ea::LoginHandler void processServerVersion(Net::MessageIn &msg); - void requestUpdateHosts() const; + static void requestUpdateHosts(); void processUpdateHost2(Net::MessageIn &msg) const; diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp index 007c29dd6..eea74a2a5 100644 --- a/src/net/tmwa/playerhandler.cpp +++ b/src/net/tmwa/playerhandler.cpp @@ -233,7 +233,7 @@ void PlayerHandler::requestOnlineList() const MessageOut outMsg(CMSG_ONLINE_LIST); } -void PlayerHandler::processOnlineList(Net::MessageIn &msg) const +void PlayerHandler::processOnlineList(Net::MessageIn &msg) { if (!whoIsOnline) return; @@ -309,7 +309,7 @@ void PlayerHandler::updateStatus(const uint8_t status) const outMsg.writeInt8(0); } -void PlayerHandler::processMapMask(Net::MessageIn &msg) const +void PlayerHandler::processMapMask(Net::MessageIn &msg) { const int mask = msg.readInt32(); msg.readInt32(); // unused @@ -318,7 +318,7 @@ void PlayerHandler::processMapMask(Net::MessageIn &msg) const map->setMask(mask); } -void PlayerHandler::processMapMusic(Net::MessageIn &msg) const +void PlayerHandler::processMapMusic(Net::MessageIn &msg) { const int size = msg.readInt16() - 5; const std::string music = msg.readString(size); diff --git a/src/net/tmwa/playerhandler.h b/src/net/tmwa/playerhandler.h index 5e1419119..125eea0ba 100644 --- a/src/net/tmwa/playerhandler.h +++ b/src/net/tmwa/playerhandler.h @@ -51,11 +51,11 @@ class PlayerHandler final : public MessageHandler, public Ea::PlayerHandler void setDestination(const int x, const int y, const int direction) const override final; void changeAction(const Being::Action &action) const override final; - void processOnlineList(Net::MessageIn &msg) const; + static void processOnlineList(Net::MessageIn &msg); void requestOnlineList() const override final; void updateStatus(const uint8_t status) const override final; - void processMapMask(Net::MessageIn &msg) const; - void processMapMusic(Net::MessageIn &msg) const; + static void processMapMask(Net::MessageIn &msg); + static void processMapMusic(Net::MessageIn &msg); void respawn() const override final; }; diff --git a/src/net/tmwa/questhandler.cpp b/src/net/tmwa/questhandler.cpp index 328a379dc..73ba770ea 100644 --- a/src/net/tmwa/questhandler.cpp +++ b/src/net/tmwa/questhandler.cpp @@ -61,7 +61,7 @@ void QuestHandler::handleMessage(Net::MessageIn &msg) BLOCK_END("QuestHandler::handleMessage") } -void QuestHandler::processSetQuestVar(Net::MessageIn &msg) const +void QuestHandler::processSetQuestVar(Net::MessageIn &msg) { const int var = msg.readInt16(); // variable const int val = msg.readInt32(); // value @@ -77,7 +77,7 @@ void QuestHandler::processSetQuestVar(Net::MessageIn &msg) const } } -void QuestHandler::processPlayerQuests(Net::MessageIn &msg) const +void QuestHandler::processPlayerQuests(Net::MessageIn &msg) { const int count = (msg.readInt16() - 4) / 6; for (int f = 0; f < count; f ++) diff --git a/src/net/tmwa/questhandler.h b/src/net/tmwa/questhandler.h index 3e5e8178a..1de4ed24f 100644 --- a/src/net/tmwa/questhandler.h +++ b/src/net/tmwa/questhandler.h @@ -35,9 +35,9 @@ class QuestHandler final : public MessageHandler void handleMessage(Net::MessageIn &msg) override final; - void processSetQuestVar(Net::MessageIn &msg) const; + static void processSetQuestVar(Net::MessageIn &msg); - void processPlayerQuests(Net::MessageIn &msg) const; + static void processPlayerQuests(Net::MessageIn &msg); }; } // namespace TmwAthena diff --git a/src/particle/particleemitter.h b/src/particle/particleemitter.h index 9e149034f..3f771ab57 100644 --- a/src/particle/particleemitter.h +++ b/src/particle/particleemitter.h @@ -83,7 +83,7 @@ class ParticleEmitter final void adjustSize(const int w, const int h); private: - template <typename T> ParticleEmitterProp<T> + template <typename T> static ParticleEmitterProp<T> readParticleEmitterProp(XmlNodePtrConst propertyNode, T def); ImageSet *getImageSet(XmlNodePtrConst node); diff --git a/src/render/graphics.cpp b/src/render/graphics.cpp index 6ad1c67d7..7e3687006 100644 --- a/src/render/graphics.cpp +++ b/src/render/graphics.cpp @@ -136,8 +136,21 @@ void Graphics::setScale(int scale) { if (!scale) scale = 1; - if (mActualWidth / scale < 470 || mActualHeight / scale < 320) - scale = 1; + int scaleW = mActualWidth / scale; + int scaleH = mActualHeight / scale; + if (scaleW < 470) + { + scale = mActualWidth / 470; + if (scale < 1) + scale = 1; + scaleH = mActualHeight / scale; + } + if (scaleH < 320) + { + scale = mActualHeight / 320; + if (scale < 1) + scale = 1; + } logger->log("set scale: %d", scale); mScale = scale; mWidth = mActualWidth / mScale; @@ -373,7 +386,7 @@ bool Graphics::videoInfo() mDoubleBuffer = ((mWindow->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF); logger->log("Double buffer mode: %s", mDoubleBuffer ? "yes" : "no"); - imageHelper->dumpSurfaceFormat(mWindow); + ImageHelper::dumpSurfaceFormat(mWindow); const SDL_VideoInfo *const vi = SDL_GetVideoInfo(); if (!vi) @@ -420,11 +433,13 @@ bool Graphics::resizeScreen(const int width, const int height) mRect.h = height / mScale; mWidth = width / mScale; mHeight = height / mScale; + mActualWidth = width; + mActualHeight = height; #ifdef USE_OPENGL // +++ probably this way will not work in windows/mac // Setup OpenGL - glViewport(0, 0, mWidth, mHeight); + glViewport(0, 0, mActualWidth, mActualHeight); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); #else // +++ need impliment resize in soft mode diff --git a/src/render/sdl2softwaregraphics.cpp b/src/render/sdl2softwaregraphics.cpp index 088aba98c..22a66a911 100644 --- a/src/render/sdl2softwaregraphics.cpp +++ b/src/render/sdl2softwaregraphics.cpp @@ -1487,7 +1487,7 @@ bool SDL2SoftwareGraphics::setVideoMode(const int w, const int h, } mSurface = SDL_GetWindowSurface(mWindow); - imageHelper->dumpSurfaceFormat(mSurface); + ImageHelper::dumpSurfaceFormat(mSurface); SDL2SoftwareImageHelper::setFormat(mSurface->format); int w1 = 0; diff --git a/src/resources/ambientlayer.cpp b/src/resources/ambientlayer.cpp index c9574c589..b839064be 100644 --- a/src/resources/ambientlayer.cpp +++ b/src/resources/ambientlayer.cpp @@ -32,14 +32,19 @@ #include "debug.h" AmbientLayer::AmbientLayer(Image *const img, - const float parallaxX, const float parallaxY, - const float speedX, const float speedY, - const bool keepRatio, const int mask) : + const float parallaxX, + const float parallaxY, + const float posX, + const float posY, + const float speedX, + const float speedY, + const bool keepRatio, + const int mask) : mImage(img), mParallaxX(parallaxX), mParallaxY(parallaxY), - mPosX(0), - mPosY(0), + mPosX(posX), + mPosY(posY), mSpeedX(speedX), mSpeedY(speedY), mMask(mask), diff --git a/src/resources/ambientlayer.h b/src/resources/ambientlayer.h index 9a694bb2f..f6dd6d120 100644 --- a/src/resources/ambientlayer.h +++ b/src/resources/ambientlayer.h @@ -44,9 +44,14 @@ class AmbientLayer final * the same ratio than in 800x600 resolution mode. */ AmbientLayer(Image *const img, - const float parallax, const float parallaxY, - const float speedX, const float speedY, - const bool keepRatio, const int mask); + const float parallax, + const float parallaxY, + const float posX, + const float posY, + const float speedX, + const float speedY, + const bool keepRatio, + const int mask); A_DELETE_COPY(AmbientLayer) diff --git a/src/resources/beingcommon.cpp b/src/resources/beingcommon.cpp index 7b7a57d9e..388312b34 100644 --- a/src/resources/beingcommon.cpp +++ b/src/resources/beingcommon.cpp @@ -49,7 +49,9 @@ void BeingCommon::readBasicAttributes(BeingInfo *const info, info->setHpBarOffsetY(XML::getProperty(node, "hpBarOffsetY", 0)); } -void BeingCommon::getIncludeFiles(const std::string &dir, StringVect &list) +void BeingCommon::getIncludeFiles(const std::string &dir, + StringVect &list, + const std::string &ext) { const std::string path = dir + "/"; StringVect tempList; @@ -57,7 +59,7 @@ void BeingCommon::getIncludeFiles(const std::string &dir, StringVect &list) FOR_EACH (StringVectCIter, it, tempList) { const std::string &str = *it; - if (findLast(str, ".xml")) + if (findLast(str, ext)) list.push_back(str); } std::sort(list.begin(), list.end()); diff --git a/src/resources/beingcommon.h b/src/resources/beingcommon.h index 6124de5a1..2c9741a2c 100644 --- a/src/resources/beingcommon.h +++ b/src/resources/beingcommon.h @@ -30,11 +30,21 @@ class BeingInfo; #define loadXmlDir(name, function) \ - StringVect listVect; \ - BeingCommon::getIncludeFiles(paths.getStringValue( \ - name), listVect); \ - FOR_EACH (StringVectCIter, itVect, listVect) \ - function(*itVect); + { \ + StringVect listVect; \ + BeingCommon::getIncludeFiles(paths.getStringValue( \ + name), listVect, ".xml"); \ + FOR_EACH (StringVectCIter, itVect, listVect) \ + function(*itVect); \ + } + +#define loadXmlDir2(name, function, ext) \ + { \ + StringVect listVect; \ + BeingCommon::getIncludeFiles(name, listVect, ext); \ + FOR_EACH (StringVectCIter, itVect, listVect) \ + function(*itVect); \ + } namespace BeingCommon { @@ -42,7 +52,9 @@ namespace BeingCommon XmlNodePtrConst node, const std::string &hoverCursor); - void getIncludeFiles(const std::string &dir, StringVect &list); + void getIncludeFiles(const std::string &dir, + StringVect &list, + const std::string &ext); } #endif // RESOURCES_BEINGCOMMON_H diff --git a/src/resources/db/colordb.cpp b/src/resources/db/colordb.cpp index 630c1c902..a358bebe7 100644 --- a/src/resources/db/colordb.cpp +++ b/src/resources/db/colordb.cpp @@ -53,7 +53,7 @@ void ColorDB::load() loadHair(paths.getStringValue("hairColorPatchFile"), colors); StringVect list; BeingCommon::getIncludeFiles(paths.getStringValue( - "hairColorPatchDir"), list); + "hairColorPatchDir"), list, ".xml"); FOR_EACH (StringVectCIter, it2, list) loadHair(*it2, colors); diff --git a/src/resources/db/emotedb.cpp b/src/resources/db/emotedb.cpp index 97ea95aa0..943628978 100644 --- a/src/resources/db/emotedb.cpp +++ b/src/resources/db/emotedb.cpp @@ -295,3 +295,18 @@ const int &EmoteDB::getLast() { return mLastEmote; } + +int EmoteDB::size() +{ + return static_cast<signed int>(mEmoteInfos.size()); +} + +int EmoteDB::getIdByIndex(const int index) +{ + if (index < 0 || index >= static_cast<signed int>(mEmoteInfos.size())) + return 0; + EmoteInfos::const_iterator it = mEmoteInfos.begin(); + for (int f = 0; f < index; f ++) + ++ it; + return (*it).first; +} diff --git a/src/resources/db/emotedb.h b/src/resources/db/emotedb.h index 02683a99a..29a2a8de4 100644 --- a/src/resources/db/emotedb.h +++ b/src/resources/db/emotedb.h @@ -87,6 +87,10 @@ namespace EmoteDB const int &getLast() A_WARN_UNUSED; + int getIdByIndex(const int index); + + int size(); + typedef EmoteInfos::iterator EmoteInfosIterator; } // namespace EmoteDB diff --git a/src/resources/db/itemdb.cpp b/src/resources/db/itemdb.cpp index abc164493..931377639 100644 --- a/src/resources/db/itemdb.cpp +++ b/src/resources/db/itemdb.cpp @@ -217,7 +217,9 @@ void ItemDB::load() loadXmlFile(paths.getStringValue("itemsPatchFile"), tagNum); StringVect list; - BeingCommon::getIncludeFiles(paths.getStringValue("itemsPatchDir"), list); + BeingCommon::getIncludeFiles(paths.getStringValue("itemsPatchDir"), + list, + ".xml"); FOR_EACH (StringVectCIter, it, list) loadXmlFile(*it, tagNum); } diff --git a/src/resources/imagehelper.cpp b/src/resources/imagehelper.cpp index a089dc248..ff7c196c4 100644 --- a/src/resources/imagehelper.cpp +++ b/src/resources/imagehelper.cpp @@ -94,7 +94,7 @@ SDL_Surface* ImageHelper::convertTo32Bit(SDL_Surface *const tmpImage) return MSDL_ConvertSurface(tmpImage, &RGBAFormat, SDL_SWSURFACE); } -void ImageHelper::dumpSurfaceFormat(const SDL_Surface *const image) const +void ImageHelper::dumpSurfaceFormat(const SDL_Surface *const image) { if (image->format) { diff --git a/src/resources/imagehelper.h b/src/resources/imagehelper.h index 27cf1df14..2e3b96771 100644 --- a/src/resources/imagehelper.h +++ b/src/resources/imagehelper.h @@ -82,7 +82,7 @@ class ImageHelper static SDL_Surface *convertTo32Bit(SDL_Surface *const tmpImage) A_WARN_UNUSED; - void dumpSurfaceFormat(const SDL_Surface *const image) const; + static void dumpSurfaceFormat(const SDL_Surface *const image); virtual SDL_Surface *create32BitSurface(int width, int height) const A_WARN_UNUSED = 0; diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp index afe9ff027..b7fc0f4ac 100644 --- a/src/resources/iteminfo.cpp +++ b/src/resources/iteminfo.cpp @@ -253,8 +253,10 @@ const SpriteToItemMap *ItemInfo::getSpriteToItemReplaceMap(const int direction) return nullptr; } -void ItemInfo::setSpriteOrder(int *const ptr, const int direction, - const int n, const int def) const +void ItemInfo::setSpriteOrder(int *const ptr, + const int direction, + const int n, + const int def) { switch (direction) { diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h index 43dcbf9e9..d3df1c448 100644 --- a/src/resources/iteminfo.h +++ b/src/resources/iteminfo.h @@ -229,8 +229,10 @@ class ItemInfo final void setDrawPriority(const int direction, const int n); - void setSpriteOrder(int *const ptr, const int direction, - const int n, const int def = -1) const; + static void setSpriteOrder(int *const ptr, + const int direction, + const int n, + const int def = -1); const std::map<int, int> &getTags() const A_WARN_UNUSED { return mTags; } diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index bcafe4bb7..e053e0035 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -30,6 +30,7 @@ #include "tileset.h" #include "resources/animation.h" +#include "resources/beingcommon.h" #include "resources/image.h" #include "resources/resourcemanager.h" @@ -42,6 +43,15 @@ #include "debug.h" +typedef std::map<std::string, XmlNodePtr>::iterator LayerInfoIterator; +typedef std::set<XML::Document*>::iterator DocIterator; + +namespace +{ + std::map<std::string, XmlNodePtr> mKnownLayers; + std::set<XML::Document*> mKnownDocs; +} // namespace + static int inflateMemory(unsigned char *restrict const in, const unsigned int inLength, unsigned char *&restrict out, @@ -182,53 +192,46 @@ int inflateMemory(unsigned char *restrict const in, return outLength; } +void MapReader::addLayerToList(const std::string &fileName) +{ + XML::Document *doc = new XML::Document(fileName); + XmlNodePtrConst node = doc->rootNode(); + if (!node) + { + delete doc; + return; + } + + for_each_xml_child_node(childNode, node) + { + if (!xmlNameEqual(childNode, "layer")) + continue; + std::string name = XML::getProperty(childNode, "name", ""); + if (name.empty()) + continue; + name = toLower(name); + logger->log("found patch layer: " + name); + mKnownLayers[name] = childNode; + mKnownDocs.insert(doc); + } +} + Map *MapReader::readMap(const std::string &restrict filename, const std::string &restrict realFilename) { BLOCK_START("MapReader::readMap") logger->log("Attempting to read map %s", realFilename.c_str()); - // Load the file through resource manager - const ResourceManager *const resman = ResourceManager::getInstance(); - int fileSize; - void *buffer = resman->loadFile(realFilename, fileSize); - Map *map = nullptr; - if (!buffer) + XML::Document doc(realFilename); + if (!doc.isLoaded()) { BLOCK_END("MapReader::readMap") return createEmptyMap(filename, realFilename); } - unsigned char *inflated = nullptr; - unsigned int inflatedSize; - - if (realFilename.find(".gz", realFilename.length() - 3) - != std::string::npos) - { - // Inflate the gzipped map data - inflatedSize = inflateMemory(static_cast<unsigned char*>(buffer), - fileSize, inflated); - free(buffer); - - if (!inflated) - { - logger->log("Could not decompress map file (%s)", - realFilename.c_str()); - BLOCK_END("MapReader::readMap") - return nullptr; - } - } - else - { - inflated = static_cast<unsigned char*>(buffer); - inflatedSize = fileSize; - } - - XML::Document doc(reinterpret_cast<char*>(inflated), inflatedSize); - free(inflated); - XmlNodePtrConst node = doc.rootNode(); + Map *map = nullptr; // Parse the inflated map data if (node) { @@ -256,6 +259,24 @@ Map *MapReader::readMap(const std::string &restrict filename, return map; } +void MapReader::loadLayers(const std::string &path) +{ + loadXmlDir2(path, addLayerToList, ".tmx"); +} + +void MapReader::unloadTempLayers() +{ + FOR_EACH (DocIterator, it, mKnownDocs) + delete (*it); + mKnownLayers.clear(); + mKnownDocs.clear(); +} + +static void loadReplaceLayer(LayerInfoIterator &it, Map *const map) +{ + MapReader::readLayer((*it).second, map); +} + Map *MapReader::readMap(XmlNodePtrConst node, const std::string &path) { if (!node) @@ -281,6 +302,9 @@ Map *MapReader::readMap(XmlNodePtrConst node, const std::string &path) return nullptr; } + logger->log("loading replace layer list"); + loadLayers(path + "_replace.d"); + Map *const map = new Map(w, h, tilew, tileh); const std::string fileName = path.substr(path.rfind("/") + 1); @@ -309,7 +333,18 @@ Map *MapReader::readMap(XmlNodePtrConst node, const std::string &path) } else if (xmlNameEqual(childNode, "layer")) { - readLayer(childNode, map); + std::string name = XML::getProperty(childNode, "name", ""); + name = toLower(name); + LayerInfoIterator it = mKnownLayers.find(name); + if (it == mKnownLayers.end()) + { + readLayer(childNode, map); + } + else + { + logger->log("load replace layer: " + name); + loadReplaceLayer(it, map); + } } else if (xmlNameEqual(childNode, "properties")) { @@ -402,6 +437,7 @@ Map *MapReader::readMap(XmlNodePtrConst node, const std::string &path) map->setActorsFix(0, atoi(map->getProperty("actorsfix").c_str())); map->reduce(); map->setWalkLayer(resman->getWalkLayer(fileName, map)); + unloadTempLayers(); return map; } diff --git a/src/resources/mapreader.h b/src/resources/mapreader.h index 4f84f1a1a..27cbd665b 100644 --- a/src/resources/mapreader.h +++ b/src/resources/mapreader.h @@ -59,6 +59,11 @@ class MapReader final const std::string &restrict realFilename) A_WARN_UNUSED; + /** + * Reads a map layer and adds it to the given map. + */ + static void readLayer(const XmlNodePtr node, Map *const map); + private: /** * Reads the properties element. @@ -70,11 +75,6 @@ class MapReader final static void readProperties(const XmlNodePtrConst node, Properties *const props); - /** - * Reads a map layer and adds it to the given map. - */ - static void readLayer(const XmlNodePtr node, Map *const map); - static bool readBase64Layer(const XmlNodePtrConst childNode, Map *const map, MapLayer *const layer, @@ -100,6 +100,12 @@ class MapReader final Map *const map) A_WARN_UNUSED; static void updateMusic(Map *const map); + + static void addLayerToList(const std::string &fileName); + + static void loadLayers(const std::string &path); + + static void unloadTempLayers(); }; #endif // RESOURCES_MAPREADER_H diff --git a/src/resources/openglimagehelper.cpp b/src/resources/openglimagehelper.cpp index d855323d1..5a0a91fc1 100644 --- a/src/resources/openglimagehelper.cpp +++ b/src/resources/openglimagehelper.cpp @@ -110,7 +110,7 @@ Image *OpenGLImageHelper::createTextSurface(SDL_Surface *const tmpImage, return img; } -int OpenGLImageHelper::powerOfTwo(const int input) const +int OpenGLImageHelper::powerOfTwo(const int input) { int value; if (mTextureType == GL_TEXTURE_2D) diff --git a/src/resources/openglimagehelper.h b/src/resources/openglimagehelper.h index 6c6492eb4..2f203a00a 100644 --- a/src/resources/openglimagehelper.h +++ b/src/resources/openglimagehelper.h @@ -123,7 +123,7 @@ class OpenGLImageHelper final : public ImageHelper /** * Returns the first power of two equal or bigger than the input. */ - int powerOfTwo(const int input) const A_WARN_UNUSED; + static int powerOfTwo(const int input) A_WARN_UNUSED; Image *glLoad(SDL_Surface *tmpImage, int width = 0, int height = 0) const A_WARN_UNUSED; diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index 4cc7a4574..954930b64 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -399,7 +399,7 @@ bool ResourceManager::exists(const std::string &path) const return PhysFs::exists(path.c_str()); } -bool ResourceManager::existsLocal(const std::string &path) const +bool ResourceManager::existsLocal(const std::string &path) { bool flg(false); std::fstream file; @@ -415,7 +415,7 @@ bool ResourceManager::isDirectory(const std::string &path) const return PhysFs::isDirectory(path.c_str()); } -std::string ResourceManager::getPath(const std::string &file) const +std::string ResourceManager::getPath(const std::string &file) { // get the real path to the file const char *const tmp = PhysFs::getRealDir(file.c_str()); @@ -982,7 +982,7 @@ void *ResourceManager::loadFile(const std::string &fileName, int &fileSize) } bool ResourceManager::copyFile(const std::string &restrict src, - const std::string &restrict dst) const + const std::string &restrict dst) { PHYSFS_file *const srcFile = PhysFs::openRead(src.c_str()); if (!srcFile) @@ -1054,7 +1054,7 @@ bool ResourceManager::loadTextFileLocal(const std::string &fileName, void ResourceManager::saveTextFile(std::string path, const std::string &restrict name, - const std::string &restrict text) const + const std::string &restrict text) { if (!mkdir_r(path.c_str())) { diff --git a/src/resources/resourcemanager.h b/src/resources/resourcemanager.h index 72cad5988..2398cf212 100644 --- a/src/resources/resourcemanager.h +++ b/src/resources/resourcemanager.h @@ -122,7 +122,7 @@ class ResourceManager final /** * Checks whether the given file or directory exists */ - bool existsLocal(const std::string &path) const A_WARN_UNUSED; + static bool existsLocal(const std::string &path) A_WARN_UNUSED; /** * Checks whether the given path is a directory. @@ -136,7 +136,7 @@ class ResourceManager final * @param file The file to get the real path to. * @return The real path. */ - std::string getPath(const std::string &file) const A_WARN_UNUSED; + static std::string getPath(const std::string &file) A_WARN_UNUSED; /** * Creates a resource and adds it to the resource map. @@ -184,8 +184,8 @@ class ResourceManager final * @return true on success, false on failure. An error message should be * in the log file. */ - bool copyFile(const std::string &restrict src, - const std::string &restrict dst) const; + static bool copyFile(const std::string &restrict src, + const std::string &restrict dst); /** * Convenience wrapper around ResourceManager::get for loading @@ -274,8 +274,9 @@ class ResourceManager final static bool loadTextFileLocal(const std::string &fileName, StringVect &lines); - void saveTextFile(std::string path, const std::string &restrict name, - const std::string &restrict text) const; + static void saveTextFile(std::string path, + const std::string &restrict name, + const std::string &restrict text); Image *getRescaled(Image *const image, const int width, const int height) A_WARN_UNUSED; diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp index e37aa1aa8..5265a1a96 100644 --- a/src/resources/spritedef.cpp +++ b/src/resources/spritedef.cpp @@ -493,12 +493,16 @@ void SpriteDef::addAction(const unsigned hp, const std::string &name, (*mActions[hp])[name] = action; } -bool SpriteDef::addSequence(const int start, const int end, const int delay, - const int offsetX, const int offsetY, +bool SpriteDef::addSequence(const int start, + const int end, + const int delay, + const int offsetX, + const int offsetY, const int variant_offset, - int repeat, const int rand, + int repeat, + const int rand, const ImageSet *const imageSet, - Animation *const animation) const + Animation *const animation) { if (!imageSet || !animation) return true; diff --git a/src/resources/spritedef.h b/src/resources/spritedef.h index ecedde507..b9f5d2b19 100644 --- a/src/resources/spritedef.h +++ b/src/resources/spritedef.h @@ -159,12 +159,16 @@ class SpriteDef final : public Resource void addAction(const unsigned hp, const std::string &name, Action *const action); - bool addSequence(const int start, const int end, const int delay, - const int offsetX, const int offsetY, - const int variant_offset, - int repeat, const int rand, - const ImageSet *const imageSet, - Animation *const animation) const; + static bool addSequence(const int start, + const int end, + const int delay, + const int offsetX, + const int offsetY, + const int variant_offset, + int repeat, + const int rand, + const ImageSet *const imageSet, + Animation *const animation); private: /** diff --git a/src/soundmanager.cpp b/src/soundmanager.cpp index f106b6623..e9fd3fea0 100644 --- a/src/soundmanager.cpp +++ b/src/soundmanager.cpp @@ -170,7 +170,7 @@ void SoundManager::init() playMusic(mCurrentMusicFile); } -void SoundManager::info() const +void SoundManager::info() { SDL_version compiledVersion; const char *format = "Unknown"; diff --git a/src/soundmanager.h b/src/soundmanager.h index 3ed5b6fc0..9eb1ea8a2 100644 --- a/src/soundmanager.h +++ b/src/soundmanager.h @@ -94,7 +94,7 @@ class SoundManager final : public ConfigListener void fadeOutAndPlayMusic(const std::string &fileName, const int ms = 1000); - int getMaxVolume() const A_WARN_UNUSED + static int getMaxVolume() A_WARN_UNUSED { return MIX_MAX_VOLUME; } void setMusicVolume(const int volume); @@ -138,7 +138,7 @@ class SoundManager final : public ConfigListener private: /** Logs various info about sound device. */ - void info() const; + static void info(); /** Halts and frees currently playing music. */ void haltMusic(); diff --git a/src/spellmanager.cpp b/src/spellmanager.cpp index 85ac4bf22..b1fad932a 100644 --- a/src/spellmanager.cpp +++ b/src/spellmanager.cpp @@ -165,7 +165,7 @@ void SpellManager::invoke(const int spellId) const } } -void SpellManager::invokeSpell(const TextCommand *const spell) const +void SpellManager::invokeSpell(const TextCommand *const spell) { if (!chatWindow || !spell) return; @@ -173,7 +173,7 @@ void SpellManager::invokeSpell(const TextCommand *const spell) const } void SpellManager::invokeSpell(const TextCommand *const spell, - const Being *const target) const + const Being *const target) { if (!chatWindow || !spell || !target) return; @@ -181,7 +181,7 @@ void SpellManager::invokeSpell(const TextCommand *const spell, } std::string SpellManager::parseCommand(std::string command, - const Being *const target) const + const Being *const target) { if (!player_node) return command; diff --git a/src/spellmanager.h b/src/spellmanager.h index c30fa645f..f2830edb6 100644 --- a/src/spellmanager.h +++ b/src/spellmanager.h @@ -70,14 +70,14 @@ class SpellManager final private: void fillSpells(); - void invokeSpell(const TextCommand *const spell, - const Being *const target) const; + static void invokeSpell(const TextCommand *const spell, + const Being *const target); - void invokeSpell(const TextCommand *const spell) const; + static void invokeSpell(const TextCommand *const spell); - std::string parseCommand(std::string command, - const Being *const target) - const A_WARN_UNUSED; + static std::string parseCommand(std::string command, + const Being *const target) + A_WARN_UNUSED; std::map<unsigned int, TextCommand*> mSpells; std::vector<TextCommand*> mSpellsVector; diff --git a/src/touchmanager.cpp b/src/touchmanager.cpp index 2f93a4ddc..b7b926383 100644 --- a/src/touchmanager.cpp +++ b/src/touchmanager.cpp @@ -52,6 +52,8 @@ TouchManager::TouchManager() : mButtonsSize(1), mJoystickSize(1), mButtonsFormat(0), + mWidth(0), + mHeight(0), mShow(false), mInGame(false), mTempHideButtons(false) @@ -99,6 +101,8 @@ void TouchManager::init() loadPad(); if (mShowButtons) loadButtons(); + mWidth = mainGraphics->mWidth; + mHeight = mainGraphics->mHeight; } void TouchManager::loadTouchItem(TouchItem **item, const std::string &name, @@ -309,8 +313,8 @@ bool TouchManager::isActionActive(const int index) const void TouchManager::resize(const int width, const int height) { mRedraw = true; - const int maxHeight = mainGraphics->mHeight; - const int diffW = width - mainGraphics->mWidth; + const int maxHeight = mHeight; + const int diffW = width - mWidth; const int diffH = height - maxHeight; FOR_EACH (TouchItemVectorCIter, it, mObjects) { @@ -323,8 +327,8 @@ void TouchManager::resize(const int width, const int height) case LEFT: if (height != maxHeight) { - item->y += (height - item->height) / 2; - item->rect.y += (height - item->rect.y) / 2; + item->y = (height - item->height) / 2; + item->rect.y = (height - item->rect.y) / 2; } break; case RIGHT: @@ -340,18 +344,17 @@ void TouchManager::resize(const int width, const int height) break; } } + mWidth = mainGraphics->mWidth; + mHeight = mainGraphics->mHeight; } void TouchManager::unload(TouchItem *const item) { if (item) { - Theme *const theme = Theme::instance(); - if (!theme) - return; if (item->images) { - theme->unloadRect(*item->images); + Theme::unloadRect(*item->images); delete item->images; item->images = nullptr; if (item->icon) diff --git a/src/touchmanager.h b/src/touchmanager.h index 8668654ec..6f7b96a6d 100644 --- a/src/touchmanager.h +++ b/src/touchmanager.h @@ -151,7 +151,7 @@ class TouchManager final : public ConfigListener void loadKeyboard(); - int getPadSize() + int getPadSize() const { return (mJoystickSize + 2) * 50; } void setInGame(const bool b); @@ -160,7 +160,7 @@ class TouchManager final : public ConfigListener void shutdown(); - void executeAction(const std::string &event); + static void executeAction(const std::string &event); private: TouchItem *mKeyboard; @@ -176,6 +176,8 @@ class TouchManager final : public ConfigListener int mButtonsSize; int mJoystickSize; int mButtonsFormat; + int mWidth; + int mHeight; bool mShow; bool mInGame; bool mTempHideButtons; diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index 8e657bb93..224c2a8e8 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -721,3 +721,9 @@ bool isDigit(const std::string &str) } return true; } + +void secureChatCommand(std::string &str) +{ + if (str[0] == '/' || str[0] == '@' || str[0] == '#') + str = "_" + str; +} diff --git a/src/utils/stringutils.h b/src/utils/stringutils.h index 02b1aa031..4a73b3e58 100644 --- a/src/utils/stringutils.h +++ b/src/utils/stringutils.h @@ -236,4 +236,6 @@ std::string decodeLinkText(std::string data); bool isDigit(const std::string &str); +void secureChatCommand(std::string &str); + #endif // UTILS_STRINGUTILS_H diff --git a/src/utils/translation/poparser.cpp b/src/utils/translation/poparser.cpp index 76dae99a5..f0ab95005 100644 --- a/src/utils/translation/poparser.cpp +++ b/src/utils/translation/poparser.cpp @@ -214,7 +214,7 @@ bool PoParser::readMsgStr() return false; } -bool PoParser::checkLine() +bool PoParser::checkLine() const { const size_t sz = mLine.size(); // check is line in format: "text" @@ -226,14 +226,14 @@ PoDict *PoParser::getEmptyDict() return new PoDict(""); } -bool PoParser::checkLang(std::string lang) const +bool PoParser::checkLang(std::string lang) { // check is po file exists const ResourceManager *const resman = ResourceManager::getInstance(); return resman->exists(getFileName(lang)); } -std::string PoParser::getFileName(std::string lang) const +std::string PoParser::getFileName(std::string lang) { // get po file name from lang name // logger->log("getFileName: translations/%s.po", lang.c_str()); @@ -245,7 +245,7 @@ PoDict *PoParser::getDict() const return new PoDict(mLang); } -void PoParser::convertStr(std::string &str) const +void PoParser::convertStr(std::string &str) { if (str.empty()) return; diff --git a/src/utils/translation/poparser.h b/src/utils/translation/poparser.h index dbf87b531..08a6ac7b1 100644 --- a/src/utils/translation/poparser.h +++ b/src/utils/translation/poparser.h @@ -39,7 +39,7 @@ class PoParser final const std::string &restrict fileName = "", PoDict *restrict const dict = nullptr); - bool checkLang(std::string lang) const; + static bool checkLang(std::string lang); static PoDict *getEmptyDict(); @@ -55,13 +55,13 @@ class PoParser final bool readMsgStr(); - bool checkLine(); + bool checkLine() const; - std::string getFileName(std::string lang) const; + static std::string getFileName(std::string lang); PoDict *getDict() const; - void convertStr(std::string &str) const; + static void convertStr(std::string &str); // current lang std::string mLang; diff --git a/src/utils/xml.h b/src/utils/xml.h index 5c1fb7605..48d60cda7 100644 --- a/src/utils/xml.h +++ b/src/utils/xml.h @@ -90,6 +90,9 @@ namespace XML */ XmlNodePtr rootNode() A_WARN_UNUSED; + bool isLoaded() const + { return mDoc != nullptr; } + private: xmlDocPtr mDoc; }; |