diff options
author | Reid <reidyaro@gmail.com> | 2011-08-24 22:42:17 +0200 |
---|---|---|
committer | Reid <reidyaro@gmail.com> | 2011-08-24 22:42:17 +0200 |
commit | 43c19a8321bd0c4bcf36655d74e895397aff7eea (patch) | |
tree | c8f7933367ae1e757a3166a04772274896d58c9c /src | |
parent | c1ec2b921389cb5c44d9ae572ea4851891cf8bc9 (diff) | |
parent | 9505e3789cc9db6a10a68b9794a586604271b76f (diff) | |
download | plus-43c19a8321bd0c4bcf36655d74e895397aff7eea.tar.gz plus-43c19a8321bd0c4bcf36655d74e895397aff7eea.tar.bz2 plus-43c19a8321bd0c4bcf36655d74e895397aff7eea.tar.xz plus-43c19a8321bd0c4bcf36655d74e895397aff7eea.zip |
Merge branch 'master' of gitorious.org:manaplus/manaplus
Diffstat (limited to 'src')
260 files changed, 2307 insertions, 1478 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4d230c18f..413a72f65 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -181,6 +181,8 @@ SET(SRCS gui/widgets/resizegrip.h gui/widgets/scrollarea.cpp gui/widgets/scrollarea.h + gui/widgets/setupitem.cpp + gui/widgets/setupitem.h gui/widgets/setuptab.cpp gui/widgets/setuptab.h gui/widgets/setuptabscroll.cpp @@ -197,8 +199,8 @@ SET(SRCS gui/widgets/tab.h gui/widgets/tabbedarea.cpp gui/widgets/tabbedarea.h - gui/widgets/table.cpp - gui/widgets/table.h + gui/widgets/guitable.cpp + gui/widgets/guitable.h gui/widgets/tablemodel.cpp gui/widgets/tablemodel.h gui/widgets/textbox.cpp @@ -267,8 +269,8 @@ SET(SRCS gui/logindialog.h gui/minimap.cpp gui/minimap.h - gui/ministatus.cpp - gui/ministatus.h + gui/ministatuswindow.cpp + gui/ministatuswindow.h gui/npcdialog.cpp gui/npcdialog.h gui/npcpostdialog.cpp @@ -299,8 +301,6 @@ SET(SRCS gui/serverdialog.h gui/setup.cpp gui/setup.h - gui/setupitem.cpp - gui/setupitem.h gui/setup_audio.cpp gui/setup_audio.h gui/setup_colors.cpp @@ -315,6 +315,10 @@ SET(SRCS gui/setup_chat.h gui/setup_keyboard.cpp gui/setup_keyboard.h + gui/setup_perfomance.cpp + gui/setup_perfomance.h + gui/setup_relations.cpp + gui/setup_relations.h gui/setup_players.cpp gui/setup_players.h gui/setup_video.cpp @@ -345,8 +349,8 @@ SET(SRCS gui/tradewindow.h gui/unregisterdialog.cpp gui/unregisterdialog.h - gui/updatewindow.cpp - gui/updatewindow.h + gui/updaterwindow.cpp + gui/updaterwindow.h gui/userpalette.cpp gui/userpalette.h gui/viewport.cpp @@ -468,8 +472,8 @@ SET(SRCS being.h spellmanager.cpp spellmanager.h - chatlog.cpp - chatlog.h + chatlogger.cpp + chatlogger.h client.cpp client.h channel.cpp @@ -528,8 +532,8 @@ SET(SRCS listener.h localplayer.cpp localplayer.h - log.cpp - log.h + logger.cpp + logger.h main.cpp main.h map.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 18ae560b8..57bb4e620 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -184,6 +184,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/widgets/resizegrip.h \ gui/widgets/scrollarea.cpp \ gui/widgets/scrollarea.h \ + gui/widgets/setupitem.cpp \ + gui/widgets/setupitem.h \ gui/widgets/setuptab.cpp \ gui/widgets/setuptab.h \ gui/widgets/setuptabscroll.cpp \ @@ -200,8 +202,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/widgets/tab.h \ gui/widgets/tabbedarea.cpp \ gui/widgets/tabbedarea.h \ - gui/widgets/table.cpp \ - gui/widgets/table.h \ + gui/widgets/guitable.cpp \ + gui/widgets/guitable.h \ gui/widgets/tablemodel.cpp \ gui/widgets/tablemodel.h \ gui/widgets/textbox.cpp \ @@ -270,8 +272,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/logindialog.h \ gui/minimap.cpp \ gui/minimap.h \ - gui/ministatus.cpp \ - gui/ministatus.h \ + gui/ministatuswindow.cpp \ + gui/ministatuswindow.h \ gui/npcdialog.cpp \ gui/npcdialog.h \ gui/npcpostdialog.cpp \ @@ -302,8 +304,6 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/serverdialog.h \ gui/setup.cpp \ gui/setup.h \ - gui/setupitem.cpp \ - gui/setupitem.h \ gui/setup_audio.cpp \ gui/setup_audio.h \ gui/setup_colors.cpp \ @@ -318,8 +318,12 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/setup_chat.h \ gui/setup_keyboard.cpp \ gui/setup_keyboard.h \ + gui/setup_perfomance.cpp \ + gui/setup_perfomance.h \ gui/setup_players.cpp \ gui/setup_players.h \ + gui/setup_relations.cpp \ + gui/setup_relations.h \ gui/setup_video.cpp \ gui/setup_video.h \ gui/sdlfont.cpp \ @@ -348,8 +352,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/tradewindow.h \ gui/unregisterdialog.cpp \ gui/unregisterdialog.h \ - gui/updatewindow.cpp \ - gui/updatewindow.h \ + gui/updaterwindow.cpp \ + gui/updaterwindow.h \ gui/userpalette.cpp \ gui/userpalette.h \ gui/viewport.cpp \ @@ -475,8 +479,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ being.h \ spellmanager.cpp \ spellmanager.h \ - chatlog.cpp \ - chatlog.h \ + chatlogger.cpp \ + chatlogger.h \ client.cpp \ client.h \ channel.cpp \ @@ -535,8 +539,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ listener.h \ localplayer.cpp \ localplayer.h \ - log.cpp \ - log.h \ + logger.cpp \ + logger.h \ main.cpp \ main.h \ map.cpp\ diff --git a/src/actorsprite.cpp b/src/actorsprite.cpp index 5f71c6bbb..848e84e0f 100644 --- a/src/actorsprite.cpp +++ b/src/actorsprite.cpp @@ -26,7 +26,7 @@ #include "effectmanager.h" #include "imagesprite.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "simpleanimation.h" #include "sound.h" #include "statuseffect.h" diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp index 61534c340..e8244bc30 100644 --- a/src/actorspritemanager.cpp +++ b/src/actorspritemanager.cpp @@ -24,7 +24,7 @@ #include "configuration.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "main.h" #include "playerinfo.h" #include "playerrelations.h" diff --git a/src/animatedsprite.cpp b/src/animatedsprite.cpp index 41aabf60c..7414c94bc 100644 --- a/src/animatedsprite.cpp +++ b/src/animatedsprite.cpp @@ -23,7 +23,7 @@ #include "animatedsprite.h" #include "graphics.h" -#include "log.h" +#include "logger.h" #include "resources/action.h" #include "resources/animation.h" diff --git a/src/being.cpp b/src/being.cpp index 47e1f03fc..cc88d8f6e 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -31,7 +31,7 @@ #include "guild.h" #include "item.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "map.h" #include "particle.h" #include "party.h" @@ -196,6 +196,7 @@ bool Being::mShowOwnHP = false; bool Being::mShowGender = false; bool Being::mShowLevel = false; bool Being::mShowPlayersStatus = false; +bool Being::mEnableReorderSprites = true; std::list<BeingCacheEntry*> beingInfoCache; @@ -262,7 +263,7 @@ Being::Being(int id, Type type, Uint16 subtype, Map *map): if (mType == PLAYER) mShowName = config.getBoolValue("visiblenames"); - else + else if (mType != NPC) mGotComment = true; config.addListener("visiblenames", this); @@ -475,7 +476,7 @@ void Being::setSpeech(const std::string &text, int time) mSpeech = mSpeech.substr(0, lineLim); trim(mSpeech); - if (mSpeech.length() < 1) + if (mSpeech.empty()) return; if (!time && mSpeech.size() < 200) @@ -1362,7 +1363,7 @@ void Being::drawEmotion(Graphics *graphics, int offsetX, int offsetY) void Being::drawSpeech(int offsetX, int offsetY) { - if (!mSpeechBubble) + if (!mSpeechBubble || mSpeech.empty()) return; const int px = getPixelX() - offsetX; @@ -1553,6 +1554,9 @@ void Being::showName() font = gui->getSecureFont(); } + if (mDisplayName.empty()) + return; + mDispName = new FlashText(mDisplayName, getPixelX(), getPixelY(), gcn::Graphics::CENTER, mNameColor, font); @@ -1750,6 +1754,7 @@ void Being::reReadConfig() mShowGender = config.getBoolValue("showgender"); mShowLevel = config.getBoolValue("showlevel"); mShowPlayersStatus = config.getBoolValue("showPlayersStatus"); + mEnableReorderSprites = config.getBoolValue("enableReorderSprites"); mUpdateConfigTime = cur_time; } @@ -2034,14 +2039,28 @@ void Being::drawHpBar(Graphics *graphics, int maxHP, int hp, int damage, int dx = static_cast<int>(static_cast<float>(width) / p); + if (!damage || (!hp && maxHP == damage)) + { + graphics->setColor(userPalette->getColorWithAlpha(color1)); + + graphics->fillRectangle(gcn::Rectangle( + x, y, dx, height)); + return; + } + else if (width - dx <= 0) + { + graphics->setColor(userPalette->getColorWithAlpha(color2)); + + graphics->fillRectangle(gcn::Rectangle( + x, y, width, height)); + return; + } + graphics->setColor(userPalette->getColorWithAlpha(color1)); graphics->fillRectangle(gcn::Rectangle( x, y, dx, height)); - if (width - dx <= 0) - return; - graphics->setColor(userPalette->getColorWithAlpha(color2)); graphics->fillRectangle(gcn::Rectangle( @@ -2073,6 +2092,9 @@ void Being::resetCounters() void Being::recalcSpritesOrder() { + if (!mEnableReorderSprites) + return; + // logger->log("recalcSpritesOrder"); unsigned sz = static_cast<unsigned>(size()); if (sz < 1) @@ -2358,13 +2380,26 @@ void Being::updateComment() return; mGotComment = true; - mComment = loadComment(mName); + mComment = loadComment(mName, mType); } -std::string Being::loadComment(const std::string &name) +std::string Being::loadComment(const std::string &name, int type) { - std::string str = Client::getUsersDirectory() - + stringToHexPath(name) + "/comment.txt"; + std::string str; + switch (type) + { + case PLAYER: + str = Client::getUsersDirectory(); + break; + case NPC: + str = Client::getNpcsDirectory(); + break; + default: + return ""; + } + + str += stringToHexPath(name) + "/comment.txt"; + logger->log("load from: %s", str.c_str()); std::vector<std::string> lines; ResourceManager *resman = ResourceManager::getInstance(); @@ -2378,10 +2413,22 @@ std::string Being::loadComment(const std::string &name) } void Being::saveComment(const std::string &name, - const std::string &comment) + const std::string &comment, int type) { - std::string dir = Client::getUsersDirectory() - + stringToHexPath(name); + std::string dir; + switch (type) + { + case PLAYER: + dir = Client::getUsersDirectory(); + break; + case NPC: + dir = Client::getNpcsDirectory(); + break; + default: + return; + } + dir += stringToHexPath(name); + logger->log("save to: %s", dir.c_str()); ResourceManager *resman = ResourceManager::getInstance(); resman->saveTextFile(dir, "comment.txt", name + "\n" + comment); } diff --git a/src/being.h b/src/being.h index 092e324e4..2c37ffeb5 100644 --- a/src/being.h +++ b/src/being.h @@ -741,10 +741,10 @@ class Being : public ActorSprite, public ConfigListener static void clearCache(); - static std::string loadComment(const std::string &name); + static std::string loadComment(const std::string &name, int type); static void saveComment(const std::string &name, - const std::string &comment); + const std::string &comment, int type); bool isAdvanced() { return mAdvanced; } @@ -873,6 +873,7 @@ class Being : public ActorSprite, public ConfigListener static bool mShowGender; static bool mShowLevel; static bool mShowPlayersStatus; + static bool mEnableReorderSprites; unsigned int mMoveTime; unsigned int mAttackTime; diff --git a/src/chatlog.cpp b/src/chatlogger.cpp index b0ff14479..067265138 100644 --- a/src/chatlog.cpp +++ b/src/chatlogger.cpp @@ -1,10 +1,10 @@ /* - * The Mana World + * The ManaPlus Client * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011 The ManaPlus Developers * Copyright (C) 2009-2010 Andrei Karas + * Copyright (C) 2011 The ManaPlus Developers * - * This file is part of The Mana World. + * 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 @@ -21,7 +21,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "chatlog.h" +#include "chatlogger.h" #include <iostream> #include <sstream> @@ -37,7 +37,7 @@ #include <Carbon/Carbon.h> #endif -#include "log.h" +#include "logger.h" #include "configuration.h" #include "utils/stringutils.h" diff --git a/src/chatlog.h b/src/chatlogger.h index c3e8b2e27..6e096ac89 100644 --- a/src/chatlog.h +++ b/src/chatlogger.h @@ -1,10 +1,10 @@ /* - * The Mana World + * The ManaPlus Client * Copyright (C) 2009-2010 The Mana Developers * Copyright (C) 2011 The ManaPlus Developers * Copyright (C) 2009-2010 Andrei Karas * - * This file is part of The Mana World. + * 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 @@ -21,8 +21,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef M_CHATLOG_H -#define M_CHATLOG_H +#ifndef M_CHATLOGGER_H +#define M_CHATLOGGER_H #include <fstream> #include <list> diff --git a/src/client.cpp b/src/client.cpp index 01543d8be..0e871ed91 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -23,7 +23,7 @@ #include "client.h" #include "main.h" -#include "chatlog.h" +#include "chatlogger.h" #include "configuration.h" #include "dropshortcut.h" #include "emoteshortcut.h" @@ -61,7 +61,7 @@ #include "gui/setup.h" #include "gui/theme.h" #include "gui/unregisterdialog.h" -#include "gui/updatewindow.h" +#include "gui/updaterwindow.h" #include "gui/userpalette.h" #include "gui/worldselectdialog.h" @@ -240,6 +240,7 @@ Client::Client(const Options &options): mOptions(options), mServerConfigDir(""), mUsersDir(""), + mNpcsDir(""), mRootDir(""), mCurrentDialog(0), mQuitDialog(0), @@ -1289,8 +1290,6 @@ int Client::exec() case STATE_ERROR: logger->log1("State: ERROR"); logger->log("Error: %s\n", errorMessage.c_str()); - if (chatWindow) - chatWindow->saveState(); mCurrentDialog = new OkDialog(_("Error"), errorMessage); mCurrentDialog->addActionListener(&errorListener); mCurrentDialog = NULL; // OkDialog deletes itself @@ -1803,6 +1802,7 @@ void Client::storeSafeParameters() std::string particleFont; std::string helpFont; std::string secureFont; + std::string japanFont; bool showBackground; bool enableMumble; bool enableMapReduce; @@ -1830,6 +1830,7 @@ void Client::storeSafeParameters() particleFont = config.getStringValue("particleFont"); helpFont = config.getStringValue("helpFont"); secureFont = config.getStringValue("secureFont"); + japanFont = config.getStringValue("japanFont"); showBackground = config.getBoolValue("showBackground"); enableMumble = config.getBoolValue("enableMumble"); @@ -1848,6 +1849,7 @@ void Client::storeSafeParameters() config.setValue("particleFont", "fonts/dejavusans.ttf"); config.setValue("helpFont", "fonts/dejavusansmono.ttf"); config.setValue("secureFont", "fonts/dejavusansmono.ttf"); + config.setValue("japanFont", "fonts/mplus-1p-regular.ttf"); config.setValue("showBackground", false); config.setValue("enableMumble", false); config.setValue("enableMapReduce", false); @@ -1873,6 +1875,7 @@ void Client::storeSafeParameters() config.setValue("particleFont", particleFont); config.setValue("helpFont", helpFont); config.setValue("secureFont", secureFont); + config.setValue("japanFont", japanFont); config.setValue("showBackground", showBackground); config.setValue("enableMumble", enableMumble); config.setValue("enableMapReduce", enableMapReduce); @@ -1919,6 +1922,13 @@ void Client::initUsersDir() logger->error(strprintf(_("%s doesn't exist and can't be created! " "Exiting."), mUsersDir.c_str())); } + + mNpcsDir = Client::getServerConfigDirectory() + "/npcs/"; + if (mkdir_r(mNpcsDir.c_str())) + { + logger->error(strprintf(_("%s doesn't exist and can't be created! " + "Exiting."), mNpcsDir.c_str())); + } } void Client::initPacketLimiter() @@ -2139,6 +2149,11 @@ const std::string Client::getUsersDirectory() return instance()->mUsersDir; } +const std::string Client::getNpcsDirectory() +{ + return instance()->mNpcsDir; +} + void Client::setGuiAlpha(float n) { instance()->mGuiAlpha = n; diff --git a/src/client.h b/src/client.h index 75b3c03fe..986e06cfb 100644 --- a/src/client.h +++ b/src/client.h @@ -226,6 +226,8 @@ public: static const std::string getUsersDirectory(); + static const std::string getNpcsDirectory(); + static bool getIsMinimized() { return instance()->mIsMinimized; } @@ -303,6 +305,7 @@ private: std::string mScreenshotDir; std::string mServerConfigDir; std::string mUsersDir; + std::string mNpcsDir; std::string mRootDir; std::string mServerName; diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index b87dcf583..f650ac8d1 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -27,7 +27,7 @@ #include "channel.h" #include "game.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "main.h" #include "gui/chatwindow.h" @@ -403,8 +403,14 @@ void CommandHandler::handleMsg(const std::string &args, ChatTab *tab) void CommandHandler::handleQuery(const std::string &args, ChatTab *tab) { - if (chatWindow && chatWindow->addWhisperTab(args, true)) - return; + if (chatWindow) + { + if (chatWindow->addWhisperTab(args, true)) + { + chatWindow->saveState(); + return; + } + } tab->chatLog(strprintf(_("Cannot create a whisper tab for nick \"%s\"! " "It either already exists, or is you."), @@ -736,14 +742,20 @@ void CommandHandler::handleCloseAll(const std::string &args A_UNUSED, ChatTab *tab A_UNUSED) { if (chatWindow) + { chatWindow->removeAllWhispers(); + chatWindow->saveState(); + } } void CommandHandler::handleIgnoreAll(const std::string &args A_UNUSED, ChatTab *tab A_UNUSED) { if (chatWindow) + { chatWindow->ignoreAllWhispers(); + chatWindow->saveState(); + } } void CommandHandler::handleOutfit(const std::string &args, diff --git a/src/compoundsprite.cpp b/src/compoundsprite.cpp index 1642416ea..99fae4f88 100644 --- a/src/compoundsprite.cpp +++ b/src/compoundsprite.cpp @@ -21,6 +21,7 @@ #include "compoundsprite.h" +#include "configuration.h" #include "game.h" #include "graphics.h" #ifdef USE_OPENGL @@ -52,6 +53,9 @@ CompoundSprite::CompoundSprite(): mNeedsRedraw(false) { mAlpha = 1.0f; + mEnableAlphaFix = config.getBoolValue("enableAlphaFix"); + mDisableAdvBeingCaching = config.getBoolValue("disableAdvBeingCaching"); + mDisableBeingCaching = config.getBoolValue("disableBeingCaching"); } CompoundSprite::~CompoundSprite() @@ -406,7 +410,7 @@ void CompoundSprite::setAlpha(float alpha) { if (alpha != mAlpha) { - if (Image::mUseOpenGL == 0 && size() > 3) + if (mEnableAlphaFix && Image::mUseOpenGL == 0 && size() > 3) { SpriteConstIterator it, it_end; for (it = begin(), it_end = end(); it != it_end; ++ it) @@ -426,18 +430,28 @@ void CompoundSprite::updateImages() const return; #endif - if (size() <= 3) - return; - mNeedsRedraw = false; - if (updateFromCache()) - return; + if (!mDisableBeingCaching) + { + if (size() <= 3) + return; + + if (!mDisableAdvBeingCaching) + { + if (updateFromCache()) + return; - redraw(); + redraw(); - if (mImage) - initCurrentCacheItem(); + if (mImage) + initCurrentCacheItem(); + } + else + { + redraw(); + } + } } bool CompoundSprite::updateFromCache() const diff --git a/src/compoundsprite.h b/src/compoundsprite.h index 0841bcfb8..2211cb80c 100644 --- a/src/compoundsprite.h +++ b/src/compoundsprite.h @@ -135,6 +135,10 @@ private: mutable int mOffsetX, mOffsetY; mutable bool mNeedsRedraw; + + bool mEnableAlphaFix; + bool mDisableAdvBeingCaching; + bool mDisableBeingCaching; }; #endif // COMPOUNDSPRITE_H diff --git a/src/configuration.cpp b/src/configuration.cpp index 7d1f41fe5..2524d6b93 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -23,7 +23,7 @@ #include "configuration.h" #include "configlistener.h" -#include "log.h" +#include "logger.h" #include "utils/paths.h" #include "utils/stringutils.h" diff --git a/src/defaults.cpp b/src/defaults.cpp index 7b5f5255a..16f4620d4 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -159,6 +159,7 @@ DefaultsData* getConfigDefaults() AddDEF(configData, "particleFont", "fonts/dejavusans.ttf"); AddDEF(configData, "helpFont", "fonts/dejavusansmono.ttf"); AddDEF(configData, "secureFont", "fonts/dejavusansmono.ttf"); + AddDEF(configData, "japanFont", "fonts/mplus-1p-regular.ttf"); AddDEF(configData, "showBackground", true); AddDEF(configData, "enableTradeTab", true); AddDEF(configData, "logToChat", false); @@ -167,9 +168,9 @@ DefaultsData* getConfigDefaults() AddDEF(configData, "floorItemsHighlight", true); AddDEF(configData, "enableBotCheker", true); AddDEF(configData, "removeColors", true); - AddDEF(configData, "showMagicInDebug", false); + AddDEF(configData, "showMagicInDebug", true); AddDEF(configData, "allowCommandsInChatTabs", true); - AddDEF(configData, "serverMsgInDebug", false); + AddDEF(configData, "serverMsgInDebug", true); AddDEF(configData, "hideShopMessages", true); AddDEF(configData, "showChatHistory", true); AddDEF(configData, "showChatColorsList", true); @@ -210,6 +211,11 @@ DefaultsData* getConfigDefaults() AddDEF(configData, "showPlayersStatus", true); AddDEF(configData, "beingopacity", false); AddDEF(configData, "adjustPerfomance", true); + AddDEF(configData, "enableAlphaFix", false); + AddDEF(configData, "disableAdvBeingCaching", false); + AddDEF(configData, "disableBeingCaching", false); + AddDEF(configData, "enableReorderSprites", true); + AddDEF(configData, "showip", false); return configData; } @@ -237,6 +243,7 @@ DefaultsData* getBrandingDefaults() AddDEF(brandingData, "particleFont", "fonts/dejavusans.ttf"); AddDEF(brandingData, "helpFont", "fonts/dejavusansmono.ttf"); AddDEF(brandingData, "secureFont", "fonts/dejavusansmono.ttf"); + AddDEF(brandingData, "japanFont", "fonts/mplus-1p-regular.ttf"); AddDEF(brandingData, "guiPath", "graphics/gui/"); AddDEF(brandingData, "guiThemePath", "themes/"); diff --git a/src/dropshortcut.cpp b/src/dropshortcut.cpp index ef67fca12..48eed92bc 100644 --- a/src/dropshortcut.cpp +++ b/src/dropshortcut.cpp @@ -1,9 +1,10 @@ /* - * The Mana World + * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas + * Copyright (C) 2011 ManaPlus developers * - * This file is part of The Mana World. + * 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 diff --git a/src/dropshortcut.h b/src/dropshortcut.h index ffaf40ccf..31c20677d 100644 --- a/src/dropshortcut.h +++ b/src/dropshortcut.h @@ -1,9 +1,10 @@ /* - * The Mana World + * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas + * Copyright (C) 2011 ManaPlus developers * - * This file is part of The Mana World. + * 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 diff --git a/src/effectmanager.cpp b/src/effectmanager.cpp index bb54ced99..36e7aac16 100644 --- a/src/effectmanager.cpp +++ b/src/effectmanager.cpp @@ -21,7 +21,7 @@ #include "being.h" #include "effectmanager.h" -#include "log.h" +#include "logger.h" #include "particle.h" #include "sound.h" diff --git a/src/filefilter.txt b/src/filefilter.txt index b2b1e7d0c..0dde8e90c 100644 --- a/src/filefilter.txt +++ b/src/filefilter.txt @@ -1,5 +1,6 @@ ~ RULE_3_1_A_do_not_start_filename_with_underbar ~ RULE_3_2_CD_do_not_use_special_characters_in_filename +~ RULE_3_2_F_use_representitive_classname_for_cpp_filename ~ RULE_3_2_H_do_not_use_uppercase_for_c_filename ~ RULE_3_3_A_start_function_name_with_lowercase_unix ~ RULE_4_1_A_B_use_space_for_indentation @@ -23,3 +24,4 @@ ~ RULE_8_1_A_provide_file_info_comment ~ RULE_9_1_A_do_not_use_hardcorded_include_path ~ RULE_9_2_D_use_reentrant_function + diff --git a/src/game.cpp b/src/game.cpp index 9a5128f37..82f919976 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -42,7 +42,7 @@ #include "joystick.h" #include "keyboardconfig.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "map.h" #include "particle.h" #include "playerrelations.h" @@ -60,7 +60,7 @@ #include "gui/inventorywindow.h" #include "gui/killstats.h" #include "gui/minimap.h" -#include "gui/ministatus.h" +#include "gui/ministatuswindow.h" #include "gui/npcpostdialog.h" #include "gui/okdialog.h" #include "gui/outfitwindow.h" @@ -338,7 +338,8 @@ Game::Game(): mValidSpeed(true), mLastAction(0), mNextAdjustTime(cur_time + adjustDelay), - mAdjustLevel(0) + mAdjustLevel(0), + mLowerCounter(0) { spellManager = new SpellManager; spellShortcut = new SpellShortcut; @@ -431,8 +432,20 @@ Game::~Game() static bool saveScreenshot() { static unsigned int screenshotCount = 0; + SDL_Surface *screenshot = 0; + + if (!config.getBoolValue("showip")) + { + graphics->setSecure(true); + gui->draw(); + screenshot = graphics->getScreenshot(); + graphics->setSecure(false); + } + else + { + screenshot = graphics->getScreenshot(); + } - SDL_Surface *screenshot = graphics->getScreenshot(); if (!screenshot) return false; @@ -532,8 +545,6 @@ void Game::logic() map->saveExtraLayer(); } Client::closeDialogs(); - if (chatWindow) - chatWindow->saveState(); disconnectedDialog = new OkDialog(_("Network Error"), errorMessage, false); disconnectedDialog->addActionListener(&errorListener); @@ -558,7 +569,7 @@ void Game::adjustPerfomance() { mNextAdjustTime = cur_time + adjustDelay; } - else if (mNextAdjustTime < cur_time) + else if (mNextAdjustTime < (unsigned)cur_time) { mNextAdjustTime = cur_time + adjustDelay; @@ -576,6 +587,13 @@ void Game::adjustPerfomance() if (fps < maxFps - 10) { + if (mLowerCounter < 2) + { + mLowerCounter ++; + mNextAdjustTime = cur_time + 1; + return; + } + mLowerCounter = 0; mAdjustLevel ++; switch (mAdjustLevel) { @@ -594,6 +612,7 @@ void Game::adjustPerfomance() else { mNextAdjustTime = cur_time + 1; + mLowerCounter = 2; } break; } @@ -611,6 +630,7 @@ void Game::adjustPerfomance() else { mNextAdjustTime = cur_time + 1; + mLowerCounter = 2; } break; case 3: @@ -1041,174 +1061,184 @@ void Game::handleInput() if (keyboard.isEnabled() && !chatWindow->isInputFocused() && !NpcDialog::isAnyInputFocused() - && !setupWindow->isVisible() && !player_node->getAwayMode() && !keyboard.isKeyActive(keyboard.KEY_TARGET)) { const int tKey = keyboard.getKeyIndex(event.key.keysym.sym); - // Do not activate shortcuts if tradewindow is visible - if (itemShortcutWindow && !tradeWindow->isVisible() - && !setupWindow->isVisible()) + if (setupWindow->isVisible()) { - int num = itemShortcutWindow->getTabIndex(); - if (num >= 0 && num < SHORTCUT_TABS) + if (tKey == KeyboardConfig::KEY_WINDOW_SETUP) { - // Checks if any item shortcut is pressed. - for (int i = KeyboardConfig::KEY_SHORTCUT_1; - i <= KeyboardConfig::KEY_SHORTCUT_20; - i++) + setupWindow->doCancel(); + used = true; + } + } + else + { + // Do not activate shortcuts if tradewindow is visible + if (itemShortcutWindow && !tradeWindow->isVisible() + && !setupWindow->isVisible()) + { + int num = itemShortcutWindow->getTabIndex(); + if (num >= 0 && num < SHORTCUT_TABS) { - if (tKey == i && !used) + // Checks if any item shortcut is pressed. + for (int i = KeyboardConfig::KEY_SHORTCUT_1; + i <= KeyboardConfig::KEY_SHORTCUT_20; + i ++) { - itemShortcut[num]->useItem( - i - KeyboardConfig::KEY_SHORTCUT_1); - break; + if (tKey == i && !used) + { + itemShortcut[num]->useItem( + i - KeyboardConfig::KEY_SHORTCUT_1); + break; + } } } } - } - switch (tKey) - { - case KeyboardConfig::KEY_PICKUP: - player_node->pickUpItems(); - used = true; - break; - case KeyboardConfig::KEY_SIT: - // Player sit action - if (keyboard.isKeyActive(keyboard.KEY_EMOTE)) - player_node->updateSit(); - else - player_node->toggleSit(); - used = true; - break; - case KeyboardConfig::KEY_HIDE_WINDOWS: - // Hide certain windows - if (!chatWindow->isInputFocused()) - { - statusWindow->setVisible(false); - inventoryWindow->setVisible(false); - shopWindow->setVisible(false); - skillDialog->setVisible(false); - setupWindow->setVisible(false); - equipmentWindow->setVisible(false); - helpWindow->setVisible(false); - debugWindow->setVisible(false); - outfitWindow->setVisible(false); - dropShortcutWindow->setVisible(false); - spellShortcutWindow->setVisible(false); - botCheckerWindow->setVisible(false); - socialWindow->setVisible(false); - } - break; - case KeyboardConfig::KEY_WINDOW_STATUS: - requestedWindow = statusWindow; - break; - case KeyboardConfig::KEY_WINDOW_INVENTORY: - requestedWindow = inventoryWindow; - break; - case KeyboardConfig::KEY_WINDOW_SHOP: - requestedWindow = shopWindow; - break; - case KeyboardConfig::KEY_WINDOW_EQUIPMENT: - requestedWindow = equipmentWindow; - break; - case KeyboardConfig::KEY_WINDOW_SKILL: - requestedWindow = skillDialog; - break; - case KeyboardConfig::KEY_WINDOW_KILLS: - requestedWindow = killStats; - break; - case KeyboardConfig::KEY_WINDOW_MINIMAP: - minimap->toggle(); - break; - case KeyboardConfig::KEY_WINDOW_CHAT: - requestedWindow = chatWindow; - break; - case KeyboardConfig::KEY_WINDOW_SHORTCUT: - requestedWindow = itemShortcutWindow; - break; - case KeyboardConfig::KEY_WINDOW_SETUP: - requestedWindow = setupWindow; - break; - case KeyboardConfig::KEY_WINDOW_DEBUG: - requestedWindow = debugWindow; - break; - case KeyboardConfig::KEY_WINDOW_SOCIAL: - requestedWindow = socialWindow; - break; - case KeyboardConfig::KEY_WINDOW_EMOTE_SHORTCUT: - requestedWindow = emoteShortcutWindow; - break; - case KeyboardConfig::KEY_WINDOW_OUTFIT: - requestedWindow = outfitWindow; - break; - case KeyboardConfig::KEY_WINDOW_DROP: - requestedWindow = dropShortcutWindow; - break; - case KeyboardConfig::KEY_WINDOW_SPELLS: - requestedWindow = spellShortcutWindow; - break; - case KeyboardConfig::KEY_WINDOW_BOT_CHECKER: - requestedWindow = botCheckerWindow; - break; - case KeyboardConfig::KEY_WINDOW_ONLINE: - requestedWindow = whoIsOnline; - break; - case KeyboardConfig::KEY_SCREENSHOT: - // Screenshot (picture, hence the p) - saveScreenshot(); - used = true; - break; - case KeyboardConfig::KEY_PATHFIND: - // Find path to mouse (debug purpose) - if (!player_node->getDisableGameModifiers()) - { - if (viewport) - viewport->toggleDebugPath(); - if (miniStatusWindow) - miniStatusWindow->updateStatus(); - if (mCurrentMap) - mCurrentMap->redrawMap(); - used = true; - } - break; - case KeyboardConfig::KEY_TRADE: + switch (tKey) { - // Toggle accepting of incoming trade requests - unsigned int deflt = player_relations.getDefault(); - if (deflt & PlayerRelation::TRADE) - { - localChatTab->chatLog( - _("Ignoring incoming trade requests"), - BY_SERVER); - deflt &= ~PlayerRelation::TRADE; - } - else + case KeyboardConfig::KEY_PICKUP: + player_node->pickUpItems(); + used = true; + break; + case KeyboardConfig::KEY_SIT: + // Player sit action + if (keyboard.isKeyActive(keyboard.KEY_EMOTE)) + player_node->updateSit(); + else + player_node->toggleSit(); + used = true; + break; + case KeyboardConfig::KEY_HIDE_WINDOWS: + // Hide certain windows + if (!chatWindow->isInputFocused()) + { + statusWindow->setVisible(false); + inventoryWindow->setVisible(false); + shopWindow->setVisible(false); + skillDialog->setVisible(false); + setupWindow->setVisible(false); + equipmentWindow->setVisible(false); + helpWindow->setVisible(false); + debugWindow->setVisible(false); + outfitWindow->setVisible(false); + dropShortcutWindow->setVisible(false); + spellShortcutWindow->setVisible(false); + botCheckerWindow->setVisible(false); + socialWindow->setVisible(false); + } + break; + case KeyboardConfig::KEY_WINDOW_STATUS: + requestedWindow = statusWindow; + break; + case KeyboardConfig::KEY_WINDOW_INVENTORY: + requestedWindow = inventoryWindow; + break; + case KeyboardConfig::KEY_WINDOW_SHOP: + requestedWindow = shopWindow; + break; + case KeyboardConfig::KEY_WINDOW_EQUIPMENT: + requestedWindow = equipmentWindow; + break; + case KeyboardConfig::KEY_WINDOW_SKILL: + requestedWindow = skillDialog; + break; + case KeyboardConfig::KEY_WINDOW_KILLS: + requestedWindow = killStats; + break; + case KeyboardConfig::KEY_WINDOW_MINIMAP: + minimap->toggle(); + break; + case KeyboardConfig::KEY_WINDOW_CHAT: + requestedWindow = chatWindow; + break; + case KeyboardConfig::KEY_WINDOW_SHORTCUT: + requestedWindow = itemShortcutWindow; + break; + case KeyboardConfig::KEY_WINDOW_SETUP: + requestedWindow = setupWindow; + break; + case KeyboardConfig::KEY_WINDOW_DEBUG: + requestedWindow = debugWindow; + break; + case KeyboardConfig::KEY_WINDOW_SOCIAL: + requestedWindow = socialWindow; + break; + case KeyboardConfig::KEY_WINDOW_EMOTE_SHORTCUT: + requestedWindow = emoteShortcutWindow; + break; + case KeyboardConfig::KEY_WINDOW_OUTFIT: + requestedWindow = outfitWindow; + break; + case KeyboardConfig::KEY_WINDOW_DROP: + requestedWindow = dropShortcutWindow; + break; + case KeyboardConfig::KEY_WINDOW_SPELLS: + requestedWindow = spellShortcutWindow; + break; + case KeyboardConfig::KEY_WINDOW_BOT_CHECKER: + requestedWindow = botCheckerWindow; + break; + case KeyboardConfig::KEY_WINDOW_ONLINE: + requestedWindow = whoIsOnline; + break; + case KeyboardConfig::KEY_SCREENSHOT: + // Screenshot (picture, hence the p) + saveScreenshot(); + used = true; + break; + case KeyboardConfig::KEY_PATHFIND: + // Find path to mouse (debug purpose) + if (!player_node->getDisableGameModifiers()) + { + if (viewport) + viewport->toggleDebugPath(); + if (miniStatusWindow) + miniStatusWindow->updateStatus(); + if (mCurrentMap) + mCurrentMap->redrawMap(); + used = true; + } + break; + case KeyboardConfig::KEY_TRADE: { - localChatTab->chatLog( - _("Accepting incoming trade requests"), - BY_SERVER); - deflt |= PlayerRelation::TRADE; - } + // Toggle accepting of incoming trade requests + unsigned int deflt = player_relations.getDefault(); + if (deflt & PlayerRelation::TRADE) + { + localChatTab->chatLog( + _("Ignoring incoming trade requests"), + BY_SERVER); + deflt &= ~PlayerRelation::TRADE; + } + else + { + localChatTab->chatLog( + _("Accepting incoming trade requests"), + BY_SERVER); + deflt |= PlayerRelation::TRADE; + } - player_relations.setDefault(deflt); + player_relations.setDefault(deflt); - used = true; + used = true; + } + break; + default: + break; } - break; - default: - break; } - } - if (requestedWindow) - { - requestedWindow->setVisible(!requestedWindow->isVisible()); - if (requestedWindow->isVisible()) - requestedWindow->requestMoveToTop(); - used = true; + if (requestedWindow) + { + requestedWindow->setVisible(!requestedWindow->isVisible()); + if (requestedWindow->isVisible()) + requestedWindow->requestMoveToTop(); + used = true; + } } } // Active event diff --git a/src/game.h b/src/game.h index 88dc9166b..84dca08e9 100644 --- a/src/game.h +++ b/src/game.h @@ -117,6 +117,7 @@ class Game unsigned mNextAdjustTime; int mAdjustLevel; bool mAdjustPerfomance; + int mLowerCounter; static Game *mInstance; }; diff --git a/src/graphics.cpp b/src/graphics.cpp index 6a6760c36..c5dc38b72 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -25,7 +25,7 @@ #include "graphics.h" #include "graphicsvertexes.h" -#include "log.h" +#include "logger.h" #include "map.h" #include "resources/image.h" @@ -48,7 +48,8 @@ Graphics::Graphics(): mHWAccel(false), mBlitMode(BLIT_NORMAL), mRedraw(false), - mDoubleBuffer(false) + mDoubleBuffer(false), + mSecure(false) { mRect.x = 0; mRect.y = 0; diff --git a/src/graphics.h b/src/graphics.h index 237d16dc2..a2e25b5a8 100644 --- a/src/graphics.h +++ b/src/graphics.h @@ -269,6 +269,12 @@ class Graphics : public gcn::SDLGraphics bool getRedraw() { return mRedraw; } + void setSecure(bool n) + { mSecure = n; } + + bool getSecure() + { return mSecure; } + int mWidth; int mHeight; @@ -283,6 +289,7 @@ class Graphics : public gcn::SDLGraphics bool mRedraw; bool mDoubleBuffer; SDL_Rect mRect; + bool mSecure; }; extern Graphics *graphics; diff --git a/src/gui/beingpopup.cpp b/src/gui/beingpopup.cpp index e5dc602a0..8d7b26c1b 100644 --- a/src/gui/beingpopup.cpp +++ b/src/gui/beingpopup.cpp @@ -89,6 +89,12 @@ void BeingPopup::show(int x, int y, Being *b) b->updateComment(); + if (b->getType() == Being::NPC && b->getComment().empty()) + { + setVisible(false); + return; + } + mBeingName->setCaption(b->getName() + b->getGenderSignWithSpace()); if (gui) { diff --git a/src/gui/botcheckerwindow.cpp b/src/gui/botcheckerwindow.cpp index ac845adc1..4a8f8cf0d 100644 --- a/src/gui/botcheckerwindow.cpp +++ b/src/gui/botcheckerwindow.cpp @@ -1,9 +1,10 @@ /* - * The Mana World + * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas + * Copyright (C) 2011 ManaPlus developers * - * This file is part of The Mana World. + * 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 @@ -35,7 +36,7 @@ #include "gui/widgets/label.h" #include "gui/widgets/layout.h" #include "gui/widgets/layouthelper.h" -#include "gui/widgets/table.h" +#include "gui/widgets/guitable.h" #include "actorspritemanager.h" #include "configuration.h" @@ -289,7 +290,6 @@ BotCheckerWindow::BotCheckerWindow(): } mPlayerTitleTable = new GuiTable(mPlayerTableTitleModel); - //mPlayerTitleTable->setBackgroundColor(gcn::Color(0xbf, 0xbf, 0xbf)); mPlayerTitleTable->setHeight(1); mPlayerTableTitleModel->set(0, 0, new Label(_("Name"))); diff --git a/src/gui/botcheckerwindow.h b/src/gui/botcheckerwindow.h index e378fffb0..a69781865 100644 --- a/src/gui/botcheckerwindow.h +++ b/src/gui/botcheckerwindow.h @@ -1,9 +1,10 @@ /* - * The Mana World + * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas + * Copyright (C) 2011 ManaPlus developers * - * This file is part of The Mana World. + * 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 diff --git a/src/gui/changeemaildialog.cpp b/src/gui/changeemaildialog.cpp index d424fff91..c24624bc2 100644 --- a/src/gui/changeemaildialog.cpp +++ b/src/gui/changeemaildialog.cpp @@ -23,7 +23,7 @@ #include "gui/changeemaildialog.h" #include "client.h" -#include "log.h" +#include "logger.h" #include "gui/register.h" #include "gui/okdialog.h" diff --git a/src/gui/changepassworddialog.cpp b/src/gui/changepassworddialog.cpp index dc640841a..30012ae52 100644 --- a/src/gui/changepassworddialog.cpp +++ b/src/gui/changepassworddialog.cpp @@ -23,7 +23,7 @@ #include "changepassworddialog.h" #include "client.h" -#include "log.h" +#include "logger.h" #include "gui/register.h" #include "gui/okdialog.h" diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp index 264df06e3..28c7a083c 100644 --- a/src/gui/charselectdialog.cpp +++ b/src/gui/charselectdialog.cpp @@ -26,7 +26,7 @@ #include "game.h" #include "localplayer.h" #include "units.h" -#include "log.h" +#include "logger.h" #include "gui/changeemaildialog.h" #include "gui/changepassworddialog.h" diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index c266374ef..8896ca028 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -211,10 +211,12 @@ ChatWindow::ChatWindow(): fillCommands(); initTradeFilter(); loadCustomList(); + parseHighlights(); } ChatWindow::~ChatWindow() { + saveState(); config.setValue("ReturnToggles", mReturnToggles); removeAllWhispers(); delete mItemLinkHandler; @@ -935,7 +937,11 @@ void ChatWindow::whisper(const std::string &nick, if (i != mWhispers.end()) tab = i->second; else if (config.getBoolValue("whispertab")) + { tab = addWhisperTab(nick); + if (tab) + saveState(); + } if (tab) { @@ -1414,15 +1420,6 @@ void ChatWindow::loadState() tab->setRemoveNames((flags & 2) / 2); tab->setNoAway((flags & 4) / 4); } - serverConfig.deleteKey("chatWhisper" + toString(num)); - serverConfig.deleteKey("chatWhisperFlags" + toString(num)); - num ++; - } - - while (num < 50) - { - serverConfig.deleteKey("chatWhisper" + toString(num)); - serverConfig.deleteKey("chatWhisperFlags" + toString(num)); num ++; } } @@ -1507,7 +1504,7 @@ void ChatWindow::addToAwayLog(std::string line) if (mAwayLog.size() > 20) mAwayLog.pop_front(); - if (line.find(player_node->getName()) != std::string::npos) + if (findI(line, mHighlights) != std::string::npos) mAwayLog.push_back("##9away:" + line); } @@ -1524,3 +1521,20 @@ void ChatWindow::displayAwayLog() ++i; } } + +void ChatWindow::parseHighlights() +{ + mHighlights.clear(); + if (!player_node) + return; + + splitToStringVector(mHighlights, config.getStringValue( + "highlightWords"), ','); + + mHighlights.push_back(player_node->getName()); +} + +bool ChatWindow::findHighlight(std::string &str) +{ + return findI(str, mHighlights) != std::string::npos; +}
\ No newline at end of file diff --git a/src/gui/chatwindow.h b/src/gui/chatwindow.h index b6a37ef79..6e1d548a3 100644 --- a/src/gui/chatwindow.h +++ b/src/gui/chatwindow.h @@ -260,6 +260,10 @@ class ChatWindow : public Window, void clearAwayLog() { mAwayLog.clear(); } + void parseHighlights(); + + bool findHighlight(std::string &str); + protected: friend class ChatTab; friend class WhisperTab; @@ -329,6 +333,7 @@ class ChatWindow : public Window, int mChatColor; unsigned int mChatHistoryIndex; std::list<std::string> mAwayLog; + std::vector<std::string> mHighlights; }; extern ChatWindow *chatWindow; diff --git a/src/gui/connectiondialog.cpp b/src/gui/connectiondialog.cpp index 157398297..da98ea5ac 100644 --- a/src/gui/connectiondialog.cpp +++ b/src/gui/connectiondialog.cpp @@ -22,7 +22,7 @@ #include "connectiondialog.h" -#include "log.h" +#include "logger.h" #include "gui/widgets/button.h" #include "gui/widgets/label.h" diff --git a/src/gui/didyouknowwindow.cpp b/src/gui/didyouknowwindow.cpp index 03188907f..4d89bd924 100644 --- a/src/gui/didyouknowwindow.cpp +++ b/src/gui/didyouknowwindow.cpp @@ -22,7 +22,7 @@ #include "gui/didyouknowwindow.h" -#include "log.h" +#include "logger.h" #include "gui/gui.h" #include "gui/setup.h" diff --git a/src/gui/editdialog.cpp b/src/gui/editdialog.cpp index bb80f07ed..da1d98e81 100644 --- a/src/gui/editdialog.cpp +++ b/src/gui/editdialog.cpp @@ -1,9 +1,10 @@ /* - * The Mana World + * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas + * Copyright (C) 2011 ManaPlus developers * - * This file is part of The Mana World. + * 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 diff --git a/src/gui/editdialog.h b/src/gui/editdialog.h index 55947b23d..dc0d1cc63 100644 --- a/src/gui/editdialog.h +++ b/src/gui/editdialog.h @@ -1,9 +1,10 @@ /* - * The Mana World + * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas + * Copyright (C) 2011 ManaPlus developers * - * This file is part of The Mana World. + * 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 diff --git a/src/gui/emotepopup.cpp b/src/gui/emotepopup.cpp index 3a754d0e3..348a97952 100644 --- a/src/gui/emotepopup.cpp +++ b/src/gui/emotepopup.cpp @@ -28,7 +28,7 @@ #include "emoteshortcut.h" #include "graphics.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "gui/theme.h" diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp index 5a2820550..3abd97c73 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -45,6 +45,7 @@ #include "resources/iteminfo.h" #include "resources/resourcemanager.h" +#include "utils/dtor.h" #include "utils/gettext.h" #include "utils/stringutils.h" @@ -55,24 +56,6 @@ static const int BOX_WIDTH = 36; static const int BOX_HEIGHT = 36; -// Positions of the boxes, 2nd dimension is X and Y respectively. -static const int boxPosition[][2] = -{ - { 90, 40 }, // EQUIP_TORSO_SLOT - { 8, 78 }, // EQUIP_GLOVES_SLOT - { 70, 0 }, // EQUIP_HEAD_SLOT - { 50, 253 }, // EQUIP_LEGS_SLOT - { 90, 253 }, // EQUIP_FEET_SLOT - { 8, 213 }, // EQUIP_RING1_SLOT - { 129, 213 }, // EQUIP_RING2_SLOT - { 50, 40 }, // EQUIP_NECK_SLOT - { 8, 168 }, // EQUIP_FIGHT1_SLOT - { 129, 168 }, // EQUIP_FIGHT2_SLOT - { 129, 78 }, // EQUIP_PROJECTILE_SLOT - { 8, 123 }, // EQUIP_EVOL_RING1_SLOT - { 129, 123 }, // EQUIP_EVOL_RING2_SLOT -}; - EquipmentWindow::EquipmentWindow(Equipment *equipment, Being *being, bool foring): Window(_("Equipment")), @@ -98,6 +81,13 @@ EquipmentWindow::EquipmentWindow(Equipment *equipment, Being *being, setCloseButton(true); setSaveVisible(true); setDefaultSize(180, 345, ImageRect::CENTER); + + mBoxes.reserve(13); + for (int f = 0; f < 13; f ++) + mBoxes.push_back(0); + + fillBoxes(); + loadWindowState(); mUnequip = new Button(_("Unequip"), "unequip", this); @@ -109,11 +99,9 @@ EquipmentWindow::EquipmentWindow(Equipment *equipment, Being *being, add(mPlayerBox); add(mUnequip); - for (int i = 0; i < Equipment::EQUIP_VECTOREND; i++) - { - mEquipBox[i].posX = boxPosition[i][0] + getPadding(); - mEquipBox[i].posY = boxPosition[i][1] + getTitleBarHeight(); - } + mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT); + mBorderColor = Theme::getThemeColor(Theme::BORDER); + setForegroundColor(Theme::getThemeColor(Theme::TEXT)); } EquipmentWindow::~EquipmentWindow() @@ -127,6 +115,8 @@ EquipmentWindow::~EquipmentWindow() delete mEquipment; mEquipment = 0; } + delete_all(mBoxes); + mBoxes.clear(); } void EquipmentWindow::draw(gcn::Graphics *graphics) @@ -138,23 +128,31 @@ void EquipmentWindow::draw(gcn::Graphics *graphics) Window::drawChildren(graphics); - for (int i = 0; i < Equipment::EQUIP_VECTOREND; i++) + int i = 0; + const int fontHeight = getFont()->getHeight(); + + std::vector<std::pair<int, int>*>::const_iterator it; + std::vector<std::pair<int, int>*>::const_iterator it_end = mBoxes.end(); + + for (it = mBoxes.begin(); it != it_end; ++ it, ++ i) { + std::pair<int, int> *box = *it; + if (!box) + continue; if (i == mSelected) { - const gcn::Color color = Theme::getThemeColor(Theme::HIGHLIGHT); - + mHighlightColor.a = getGuiAlpha(); // Set color to the highlight color - g->setColor(gcn::Color(color.r, color.g, color.b, getGuiAlpha())); - g->fillRectangle(gcn::Rectangle(mEquipBox[i].posX, - mEquipBox[i].posY, BOX_WIDTH, BOX_HEIGHT)); + g->setColor(mHighlightColor); + g->fillRectangle(gcn::Rectangle(box->first, + box->second, BOX_WIDTH, BOX_HEIGHT)); } // Set color black - g->setColor(gcn::Color(0, 0, 0)); + g->setColor(mBorderColor); // Draw box border - g->drawRectangle(gcn::Rectangle(mEquipBox[i].posX, mEquipBox[i].posY, - BOX_WIDTH, BOX_HEIGHT)); + g->drawRectangle(gcn::Rectangle(box->first, box->second, + BOX_WIDTH, BOX_HEIGHT)); if (!mEquipment) continue; @@ -168,15 +166,13 @@ void EquipmentWindow::draw(gcn::Graphics *graphics) { image->setAlpha(1.0f); // Ensure the image is drawn // with maximum opacity - g->drawImage(image, - mEquipBox[i].posX + 2, - mEquipBox[i].posY + 2); + g->drawImage(image, box->first + 2, box->second + 2); if (i == EQUIP_PROJECTILE_SLOT) { - g->setColor(Theme::getThemeColor(Theme::TEXT)); + g->setColor(getForegroundColor()); graphics->drawText(toString(item->getQuantity()), - mEquipBox[i].posX + (BOX_WIDTH / 2), - mEquipBox[i].posY - getFont()->getHeight(), + box->first + (BOX_WIDTH / 2), + box->second - fontHeight, gcn::Graphics::CENTER); } } @@ -202,10 +198,17 @@ Item *EquipmentWindow::getItem(int x, int y) const if (!mEquipment) return 0; - for (int i = 0; i < Equipment::EQUIP_VECTOREND; i++) + std::vector<std::pair<int, int>*>::const_iterator it; + std::vector<std::pair<int, int>*>::const_iterator it_end = mBoxes.end(); + int i = 0; + + for (it = mBoxes.begin(); it != it_end; ++ it, ++ i) { - gcn::Rectangle tRect(mEquipBox[i].posX, mEquipBox[i].posY, - BOX_WIDTH, BOX_HEIGHT); + std::pair<int, int> *box = *it; + if (!box) + continue; + const gcn::Rectangle tRect(box->first, box->second, + BOX_WIDTH, BOX_HEIGHT); if (tRect.isPointInRect(x, y)) return mEquipment->getEquipment(i); @@ -228,11 +231,19 @@ void EquipmentWindow::mousePressed(gcn::MouseEvent& mouseEvent) if (mForing) return; // Checks if any of the presses were in the equip boxes. - for (int i = 0; i < Equipment::EQUIP_VECTOREND; i++) + std::vector<std::pair<int, int>*>::const_iterator it; + std::vector<std::pair<int, int>*>::const_iterator + it_end = mBoxes.end(); + int i = 0; + + for (it = mBoxes.begin(); it != it_end; ++ it, ++ i) { + std::pair<int, int> *box = *it; + if (!box) + continue; Item *item = mEquipment->getEquipment(i); - gcn::Rectangle tRect(mEquipBox[i].posX, mEquipBox[i].posY, - BOX_WIDTH, BOX_HEIGHT); + const gcn::Rectangle tRect(box->first, box->second, + BOX_WIDTH, BOX_HEIGHT); if (tRect.isPointInRect(x, y) && item) setSelected(i); @@ -326,3 +337,145 @@ void EquipmentWindow::resetBeing(Being *being) if (being == mBeing) setBeing(0); } + +void EquipmentWindow::fillBoxes() +{ + XML::Document *doc = new XML::Document("equipmentwindow.xml"); + xmlNodePtr root = doc->rootNode(); + if (!root) + { + delete doc; + fillDefault(); + return; + } + + for_each_xml_child_node(node, root) + { + if (xmlStrEqual(node->name, BAD_CAST "window")) + loadWindow(node); + else if (xmlStrEqual(node->name, BAD_CAST "playerbox")) + loadPlayerBox(node); + else if (xmlStrEqual(node->name, BAD_CAST "slot")) + loadSlot(node); + } + delete doc; +} + +void EquipmentWindow::loadWindow(xmlNodePtr windowNode) +{ + setDefaultSize(XML::getProperty(windowNode, "width", 180), + XML::getProperty(windowNode, "height", 345), ImageRect::CENTER); +} + +void EquipmentWindow::loadPlayerBox(xmlNodePtr playerBoxNode) +{ + mPlayerBox->setDimension(gcn::Rectangle( + XML::getProperty(playerBoxNode, "x", 50), + XML::getProperty(playerBoxNode, "y", 80), + XML::getProperty(playerBoxNode, "width", 74), + XML::getProperty(playerBoxNode, "height", 168))); +} + +void EquipmentWindow::loadSlot(xmlNodePtr slotNode) +{ + int slot = parseSlotName(XML::getProperty(slotNode, "name", "")); + if (slot < 0) + return; + + const int x = XML::getProperty(slotNode, "x", 0) + getPadding(); + const int y = XML::getProperty(slotNode, "y", 0) + getTitleBarHeight(); + + if (mBoxes[slot]) + { + std::pair<int, int> *pair = mBoxes[slot]; + pair->first = x; + pair->second = y; + } + else + { + mBoxes[slot] = new std::pair<int, int>(x, y); + } +} + +int EquipmentWindow::parseSlotName(std::string name) +{ + int id = -1; + if (name == "shoes" || name == "boot" || name == "boots") + { + id = 4; + } + else if (name == "bottomclothes" || name == "bottom" || name == "pants") + { + id = 3; + } + else if (name == "topclothes" || name == "top" + || name == "torso" || name == "body") + { + id = 0; + } + else if (name == "free" || name == "misc1") + { + id = 5; + } + else if (name == "misc2" || name == "scarf" || name == "scarfs") + { + id = 7; + } + else if (name == "hat" || name == "hats") + { + id = 2; + } + else if (name == "wings") + { + id = 6; + } + else if (name == "glove" || name == "gloves") + { + id = 1; + } + else if (name == "weapon" || name == "weapons") + { + id = 8; + } + else if (name == "shield" || name == "shields") + { + id = 9; + } + else if (name == "amulet" || name == "amulets") + { + id = 11; + } + else if (name == "ring" || name == "rings") + { + id = 12; + } + else if (name == "arrow" || name == "arrows" || name == "ammo") + { + id = 10; + } + + return id; +} + +void EquipmentWindow::fillDefault() +{ + addBox(0, 90, 40); // torso + addBox(1, 8, 78); // gloves + addBox(2, 70, 0); // hat + addBox(3, 50, 253); // pants + addBox(4, 90, 253); // boots + addBox(5, 8, 213); // FREE + addBox(6, 129, 213); // wings + addBox(7, 50, 40); // scarf + addBox(8, 8, 168); // weapon + addBox(9, 129, 168); // shield + addBox(10, 129, 78); // ammo + addBox(11, 8, 123); // amulet + addBox(12, 129, 123); // ring +} + +void EquipmentWindow::addBox(int idx, int x, int y) +{ + mBoxes[idx] = new std::pair<int, int>( + x + getPadding(), y + getTitleBarHeight()); +} diff --git a/src/gui/equipmentwindow.h b/src/gui/equipmentwindow.h index 84353dfd2..cadf27620 100644 --- a/src/gui/equipmentwindow.h +++ b/src/gui/equipmentwindow.h @@ -28,8 +28,12 @@ #include "gui/widgets/window.h" +#include "utils/xml.h" + #include <guichan/actionlistener.hpp> +#include <vector> + #ifdef __GNUC__ #define A_UNUSED __attribute__ ((unused)) #else @@ -81,24 +85,28 @@ class EquipmentWindow : public Window, public gcn::ActionListener private: void mouseExited(gcn::MouseEvent &event); + void mouseMoved(gcn::MouseEvent &event); Item *getItem(int x, int y) const; void setSelected(int index); - Equipment *mEquipment; + void fillBoxes(); - /** - * Equipment box. - */ - struct EquipBox - { - int posX; - int posY; - }; + void fillDefault(); - EquipBox mEquipBox[Equipment::EQUIP_VECTOREND]; /**<Equipment Boxes. */ + void addBox(int idx, int x, int y); + + void loadWindow(xmlNodePtr windowNode); + + void loadPlayerBox(xmlNodePtr playerBoxNode); + + void loadSlot(xmlNodePtr slotNode); + + int parseSlotName(std::string name); + + Equipment *mEquipment; ItemPopup *mItemPopup; PlayerBox *mPlayerBox; @@ -107,6 +115,9 @@ class EquipmentWindow : public Window, public gcn::ActionListener int mSelected; /**< Index of selected item. */ bool mForing; Being *mBeing; + std::vector<std::pair<int, int>*> mBoxes; + gcn::Color mHighlightColor; + gcn::Color mBorderColor; }; extern EquipmentWindow *equipmentWindow; diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 0bea1d0d7..7d38b1025 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -35,7 +35,7 @@ #include "configlistener.h" #include "configuration.h" #include "graphics.h" -#include "log.h" +#include "logger.h" #include "resources/image.h" #include "resources/imageset.h" @@ -107,9 +107,18 @@ Gui::Gui(Graphics *graphics): // Set global font const int fontSize = config.getIntValue("fontSize"); + std::string fontFile = config.getValue("font", ""); -// may be here need get paths from paths.getValue? -// std::string path = resman->getPath(fontFile); + + std::vector<std::string> langs = getLang(); + if (!langs.empty() && langs[0].size() > 3 + && langs[0].substr(0, 3) == "ja_") + { + fontFile = config.getValue("japanFont", ""); + if (fontFile.empty()) + fontFile = branding.getStringValue("japanFont"); + } + if (fontFile.empty()) fontFile = branding.getStringValue("font"); diff --git a/src/gui/helpwindow.cpp b/src/gui/helpwindow.cpp index ae0a432ea..368049389 100644 --- a/src/gui/helpwindow.cpp +++ b/src/gui/helpwindow.cpp @@ -22,7 +22,7 @@ #include "gui/helpwindow.h" -#include "log.h" +#include "logger.h" #include "gui/gui.h" #include "gui/setup.h" diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index 27fbf7760..3b7b7b273 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -427,7 +427,7 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event) else { if (tradeWindow) - tradeWindow->tradeItem(item, item->getQuantity()); + tradeWindow->tradeItem(item, item->getQuantity(), true); } } } diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp index f5117ed5a..4d401a627 100644 --- a/src/gui/itempopup.cpp +++ b/src/gui/itempopup.cpp @@ -32,6 +32,7 @@ #include "gui/theme.h" #include "gui/widgets/icon.h" +#include "gui/widgets/label.h" #include "gui/widgets/textbox.h" #include "utils/gettext.h" @@ -54,7 +55,7 @@ ItemPopup::ItemPopup(): mLastColor(1) { // Item Name - mItemName = new gcn::Label; + mItemName = new Label; mItemName->setFont(boldFont); mItemName->setPosition(getPadding(), getPadding()); diff --git a/src/gui/killstats.cpp b/src/gui/killstats.cpp index 95e16127a..05a265da7 100644 --- a/src/gui/killstats.cpp +++ b/src/gui/killstats.cpp @@ -1,9 +1,10 @@ /* - * The Mana World + * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas + * Copyright (C) 2011 ManaPlus developers * - * This file is part of The Mana World. + * 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 diff --git a/src/gui/killstats.h b/src/gui/killstats.h index 3c7679ca9..ff2a8f010 100644 --- a/src/gui/killstats.h +++ b/src/gui/killstats.h @@ -1,9 +1,10 @@ /* - * The Mana World + * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas + * Copyright (C) 2011 ManaPlus developers * - * This file is part of The Mana World. + * 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 diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index 5022f9210..c735eec82 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -27,7 +27,7 @@ #include "configuration.h" #include "graphics.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "map.h" #include "gui/userpalette.h" diff --git a/src/gui/ministatus.cpp b/src/gui/ministatuswindow.cpp index 817cd74a5..08e3d0053 100644 --- a/src/gui/ministatus.cpp +++ b/src/gui/ministatuswindow.cpp @@ -20,7 +20,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "gui/ministatus.h" +#include "gui/ministatuswindow.h" #include "animatedsprite.h" #include "configuration.h" diff --git a/src/gui/ministatus.h b/src/gui/ministatuswindow.h index f19055305..19517326b 100644 --- a/src/gui/ministatus.h +++ b/src/gui/ministatuswindow.h @@ -20,8 +20,8 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef MINISTATUS_H -#define MINISTATUS_H +#ifndef MINISTATUSWINDOW_H +#define MINISTATUSWINDOW_H #include "inventory.h" #include "listener.h" diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp index 9dd41a643..d3bc6a302 100644 --- a/src/gui/outfitwindow.cpp +++ b/src/gui/outfitwindow.cpp @@ -28,10 +28,11 @@ #include "inventory.h" #include "item.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "playerinfo.h" #include "gui/chatwindow.h" +#include "gui/theme.h" #include "gui/viewport.h" #include "gui/widgets/button.h" @@ -77,6 +78,9 @@ OutfitWindow::OutfitWindow(): addMouseListener(this); + mBorderColor = Theme::getThemeColor(Theme::BORDER, 64); + mBackgroundColor = Theme::getThemeColor(Theme::BACKGROUND, 32); + mPreviousButton = new Button(_("<"), "previous", this); mNextButton = new Button(_(">"), "next", this); mCurrentLabel = new Label(strprintf(_("Outfit: %d"), 1)); @@ -303,9 +307,9 @@ void OutfitWindow::draw(gcn::Graphics *graphics) const int itemX = 10 + ((i % mGridWidth) * mBoxWidth); const int itemY = 25 + ((i / mGridWidth) * mBoxHeight); - graphics->setColor(gcn::Color(0, 0, 0, 64)); + graphics->setColor(mBorderColor); graphics->drawRectangle(gcn::Rectangle(itemX, itemY, 32, 32)); - graphics->setColor(gcn::Color(255, 255, 255, 32)); + graphics->setColor(mBackgroundColor); graphics->fillRectangle(gcn::Rectangle(itemX, itemY, 32, 32)); if (mItems[mCurrentOutfit][i] < 0) diff --git a/src/gui/outfitwindow.h b/src/gui/outfitwindow.h index 60634dbdd..8dd5fd6a3 100644 --- a/src/gui/outfitwindow.h +++ b/src/gui/outfitwindow.h @@ -137,6 +137,8 @@ class OutfitWindow : public Window, gcn::ActionListener int mAwayOutfit; Image *mBackgroundImg; + gcn::Color mBorderColor; + gcn::Color mBackgroundColor; static float mAlpha; }; diff --git a/src/gui/palette.h b/src/gui/palette.h index 9409bfc06..1cebe236f 100644 --- a/src/gui/palette.h +++ b/src/gui/palette.h @@ -24,7 +24,7 @@ #ifndef PALETTE_H #define PALETTE_H -#include "log.h" +#include "logger.h" #include "utils/stringutils.h" #include <guichan/color.hpp> diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 79618ad04..61769bc7e 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -22,6 +22,7 @@ #include "gui/popupmenu.h" +#include "actorsprite.h" #include "actorspritemanager.h" #include "being.h" #include "dropshortcut.h" @@ -31,7 +32,7 @@ #include "item.h" #include "itemshortcut.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "map.h" #include "party.h" #include "playerinfo.h" @@ -43,7 +44,7 @@ #include "gui/equipmentwindow.h" #include "gui/inventorywindow.h" #include "gui/itemamountwindow.h" -#include "gui/ministatus.h" +#include "gui/ministatuswindow.h" #include "gui/outfitwindow.h" #include "gui/selldialog.h" #include "gui/socialwindow.h" @@ -94,7 +95,8 @@ PopupMenu::PopupMenu(): mSpell(0), mDialog(0), mButton(0), - mNick("") + mNick(""), + mType(Being::UNKNOWN) { mBrowserBox = new BrowserBox; mBrowserBox->setPosition(4, 4); @@ -105,6 +107,7 @@ PopupMenu::PopupMenu(): mRenameListener.setDialog(0); mPlayerListener.setNick(""); mPlayerListener.setDialog(0); + mPlayerListener.setType(Being::UNKNOWN); add(mBrowserBox); } @@ -116,6 +119,7 @@ void PopupMenu::showPopup(int x, int y, Being *being) mBeingId = being->getId(); mNick = being->getName(); + mType = being->getType(); mBrowserBox->clearRows(); const std::string &name = mNick; @@ -278,6 +282,8 @@ void PopupMenu::showPopup(int x, int y, Being *being) mBrowserBox->addRow(strprintf("@@sell|%s@@", _("Sell"))); mBrowserBox->addRow("##3---"); mBrowserBox->addRow(strprintf("@@move|%s@@", _("Move"))); + mBrowserBox->addRow(strprintf("@@addcomment|%s@@", + _("Add comment"))); break; case ActorSprite::MONSTER: @@ -359,6 +365,7 @@ void PopupMenu::showPlayerPopup(int x, int y, std::string nick) mNick = nick; mBeingId = 0; + mType = Being::PLAYER; mBrowserBox->clearRows(); const std::string &name = mNick; @@ -495,6 +502,11 @@ void PopupMenu::showPopup(int x, int y, MapItem *mapItem) mBrowserBox->addRow(strprintf("@@rename map|%s@@", _("Rename"))); mBrowserBox->addRow(strprintf("@@remove map|%s@@", _("Remove"))); + if (player_node && player_node->isGM()) + { + mBrowserBox->addRow("##3---"); + mBrowserBox->addRow(strprintf("@@warp map|%s@@", _("Warp"))); + } mBrowserBox->addRow("##3---"); mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel"))); @@ -562,7 +574,7 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab) if (tab->getRemoveNames()) { mBrowserBox->addRow(strprintf("@@dont remove name|%s@@", - _("Dont remove name"))); + _("Don't remove name"))); } else { @@ -599,6 +611,7 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab) { mBeingId = being->getId(); mNick = being->getName(); + mType = being->getType(); mBrowserBox->addRow(strprintf("@@trade|%s@@", _("Trade"))); mBrowserBox->addRow(strprintf("@@attack|%s@@", _("Attack"))); @@ -728,6 +741,7 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab) else { mNick = name; + mType = Being::PLAYER; mBrowserBox->addRow(strprintf( "@@addcomment|%s@@", _("Add comment"))); mBrowserBox->addRow("##3---"); @@ -768,6 +782,7 @@ void PopupMenu::showChangePos(int x, int y) mItem = 0; mMapItem = 0; mNick = ""; + mType = Being::UNKNOWN; setVisible(false); } } @@ -1051,18 +1066,18 @@ void PopupMenu::handleLink(const std::string &link, int cnt = 10; if (cnt > mItem->getQuantity()) cnt = mItem->getQuantity(); - tradeWindow->tradeItem(mItem, cnt); + tradeWindow->tradeItem(mItem, cnt, true); } } else if (link == "addtrade half" && mItem) { if (tradeWindow) - tradeWindow->tradeItem(mItem, mItem->getQuantity() / 2); + tradeWindow->tradeItem(mItem, mItem->getQuantity() / 2, true); } else if (link == "addtrade all" && mItem) { if (tradeWindow) - tradeWindow->tradeItem(mItem, mItem->getQuantity()); + tradeWindow->tradeItem(mItem, mItem->getQuantity(), true); } else if (link == "retrieve" && mItem) { @@ -1134,6 +1149,14 @@ void PopupMenu::handleLink(const std::string &link, if (chatWindow) chatWindow->clearTab(); } + else if (link == "warp map" && mMapItem) + { + if (Game::instance()) + { + Net::getAdminHandler()->warp(Game::instance()->getCurrentMapName(), + mMapItem->getX(), mMapItem->getY()); + } + } else if (link == "remove map" && mMapItem) { if (viewport) @@ -1220,6 +1243,7 @@ void PopupMenu::handleLink(const std::string &link, _("Comment: ")); mPlayerListener.setDialog(dialog); mPlayerListener.setNick(mNick); + mPlayerListener.setType(mType); if (being) { @@ -1228,7 +1252,7 @@ void PopupMenu::handleLink(const std::string &link, } else { - dialog->setText(Being::loadComment(mNick)); + dialog->setText(Being::loadComment(mNick, mType)); } dialog->setActionEventId("ok"); dialog->addActionListener(&mPlayerListener); @@ -1245,26 +1269,38 @@ void PopupMenu::handleLink(const std::string &link, else if (link == "enable highlight" && mTab) { mTab->setAllowHighlight(true); + if (chatWindow) + chatWindow->saveState(); } else if (link == "disable highlight" && mTab) { mTab->setAllowHighlight(false); + if (chatWindow) + chatWindow->saveState(); } else if (link == "dont remove name" && mTab) { mTab->setRemoveNames(false); + if (chatWindow) + chatWindow->saveState(); } else if (link == "remove name" && mTab) { mTab->setRemoveNames(true); + if (chatWindow) + chatWindow->saveState(); } else if (link == "disable away" && mTab) { mTab->setNoAway(true); + if (chatWindow) + chatWindow->saveState(); } else if (link == "enable away" && mTab) { mTab->setNoAway(false); + if (chatWindow) + chatWindow->saveState(); } else if (link == "remove attack" && being) { @@ -1548,6 +1584,7 @@ void PopupMenu::handleLink(const std::string &link, mItemColor = 1; mMapItem = 0; mNick = ""; + mType = Being::UNKNOWN; } void PopupMenu::showPopup(Window *parent, int x, int y, Item *item, @@ -1858,6 +1895,7 @@ void PopupMenu::showAttackMonsterPopup(int x, int y, std::string name, return; mNick = name; + mType = Being::MONSTER; mBrowserBox->clearRows(); @@ -1989,7 +2027,8 @@ void RenameListener::action(const gcn::ActionEvent &event) PlayerListener::PlayerListener() : mNick(""), - mDialog(0) + mDialog(0), + mType(Being::UNKNOWN) { } @@ -1999,10 +2038,10 @@ void PlayerListener::action(const gcn::ActionEvent &event) { std::string comment = mDialog->getText(); Being* being = actorSpriteManager->findBeingByName( - mNick, Being::PLAYER); + mNick, (ActorSprite::Type)mType); if (being) being->setComment(comment); - Being::saveComment(mNick, comment); + Being::saveComment(mNick, comment, mType); } mDialog = 0; } diff --git a/src/gui/popupmenu.h b/src/gui/popupmenu.h index afa4bdfa2..3a7f27d4b 100644 --- a/src/gui/popupmenu.h +++ b/src/gui/popupmenu.h @@ -78,9 +78,13 @@ class PlayerListener : public gcn::ActionListener void setDialog(TextDialog *dialog) { mDialog = dialog; } + void setType(int type) + { mType = type; } + private: std::string mNick; TextDialog *mDialog; + int mType; }; /** @@ -171,6 +175,7 @@ class PopupMenu : public Popup, public LinkHandler TextDialog *mDialog; Button *mButton; std::string mNick; + int mType; /** * Shared code for the various showPopup functions. diff --git a/src/gui/quitdialog.cpp b/src/gui/quitdialog.cpp index 28a3332bf..f66872b5d 100644 --- a/src/gui/quitdialog.cpp +++ b/src/gui/quitdialog.cpp @@ -53,7 +53,6 @@ QuitDialog::QuitDialog(QuitDialog** pointerToMe): mForceQuit = new RadioButton(_("Quit"), "quitdialog"); mLogoutQuit = new RadioButton(_("Quit"), "quitdialog"); - mSaveState = new CheckBox(_("Save state"), true); mSwitchAccountServer = new RadioButton(_("Switch server"), "quitdialog"); mSwitchCharacter = new RadioButton(_("Switch character"), "quitdialog"); mOkButton = new Button(_("OK"), "ok", this); @@ -91,9 +90,8 @@ QuitDialog::QuitDialog(QuitDialog** pointerToMe): place = getPlacer(0, 1); - place(0, 0, mSaveState, 3); - place(1, 1, mOkButton, 1); - place(2, 1, mCancelButton, 1); + place(1, 0, mOkButton, 1); + place(2, 0, mCancelButton, 1); reflowLayout(200, 0); setLocationRelativeTo(getParent()); @@ -133,8 +131,6 @@ void QuitDialog::action(const gcn::ActionEvent &event) if (map) map->saveExtraLayer(); } - if (chatWindow && mSaveState->isSelected()) - chatWindow->saveState(); if (mForceQuit->isSelected()) { diff --git a/src/gui/quitdialog.h b/src/gui/quitdialog.h index d68910596..380a85528 100644 --- a/src/gui/quitdialog.h +++ b/src/gui/quitdialog.h @@ -65,7 +65,6 @@ class QuitDialog : public Window, public gcn::ActionListener, std::vector<gcn::RadioButton*> mOptions; gcn::RadioButton *mLogoutQuit; - gcn::CheckBox *mSaveState; gcn::RadioButton *mForceQuit; gcn::RadioButton *mSwitchAccountServer; gcn::RadioButton *mSwitchCharacter; diff --git a/src/gui/register.cpp b/src/gui/register.cpp index 80ddb7469..913c958f2 100644 --- a/src/gui/register.cpp +++ b/src/gui/register.cpp @@ -24,7 +24,7 @@ #include "client.h" #include "configuration.h" -#include "log.h" +#include "logger.h" #include "gui/logindialog.h" #include "gui/okdialog.h" diff --git a/src/gui/sdlfont.cpp b/src/gui/sdlfont.cpp index a0f8699f8..8dd7f929d 100644 --- a/src/gui/sdlfont.cpp +++ b/src/gui/sdlfont.cpp @@ -25,7 +25,7 @@ #include "client.h" #include "graphics.h" -#include "log.h" +#include "logger.h" #include "main.h" #include "resources/image.h" diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index 140e4b629..763c190d6 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -22,10 +22,10 @@ #include "gui/serverdialog.h" -#include "chatlog.h" +#include "chatlogger.h" #include "client.h" #include "configuration.h" -#include "log.h" +#include "logger.h" #include "main.h" #include "gui/gui.h" @@ -124,6 +124,9 @@ std::string ServersListModel::getElementAt(int elementIndex) void ServersListModel::setVersionString(int index, const std::string &version) { + if (index >= (int)mVersionStrings.size()) + return; + if (version.empty()) { mVersionStrings[index] = VersionString(0, ""); @@ -155,6 +158,10 @@ public: ServersListBox(ServersListModel *model): ListBox(model) { + mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT); + mTextColor = Theme::getThemeColor(Theme::TEXT); + mNotSupportedColor = Theme::getThemeColor( + Theme::SERVER_VERSION_NOT_SUPPORTED); } void draw(gcn::Graphics *graphics) @@ -166,20 +173,18 @@ public: updateAlpha(); - graphics->setColor(Theme::getThemeColor(Theme::HIGHLIGHT, - static_cast<int>(mAlpha * 255.0f))); + mHighlightColor.a = static_cast<int>(mAlpha * 255.0f); + graphics->setColor(mHighlightColor); graphics->setFont(getFont()); const int height = getRowHeight(); - const gcn::Color unsupported = - Theme::getThemeColor(Theme::SERVER_VERSION_NOT_SUPPORTED, - static_cast<int>(mAlpha * 255.0f)); + mNotSupportedColor.a = static_cast<int>(mAlpha * 255.0f); // Draw filled rectangle around the selected list element if (mSelected >= 0) { - graphics->fillRectangle(gcn::Rectangle(0, height * mSelected, - getWidth(), height)); + graphics->fillRectangle(gcn::Rectangle(0, + height * mSelected, getWidth(), height)); } // Draw the list elements @@ -188,7 +193,7 @@ public: { ServerInfo info = model->getServer(i); - graphics->setColor(Theme::getThemeColor(Theme::TEXT)); + graphics->setColor(mTextColor); int top; @@ -209,7 +214,7 @@ public: if (info.version.first > 0) { - graphics->setColor(unsupported); + graphics->setColor(mNotSupportedColor); graphics->drawText(info.version.second, getWidth() - info.version.first - 2, top); @@ -221,6 +226,10 @@ public: { return 2 * getFont()->getHeight(); } +private: + gcn::Color mHighlightColor; + gcn::Color mTextColor; + gcn::Color mNotSupportedColor; }; @@ -604,6 +613,13 @@ void ServerDialog::downloadServerList() if (listFile.empty()) listFile = "http://manasource.org/serverlist.xml"; + if (mDownload) + { + mDownload->cancel(); + delete mDownload; + mDownload = 0; + } + mDownload = new Net::Download(this, listFile, &downloadUpdate); mDownload->setFile(mDir + "/serverlist.xml"); mDownload->start(); @@ -702,7 +718,6 @@ void ServerDialog::loadServers(bool addNew) break; } } - if (!found && addNew) mServers.push_back(server); } diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index 33ff6ddb7..690871189 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -22,19 +22,22 @@ #include "gui/setup.h" +#include "chatwindow.h" #include "configuration.h" #include "game.h" #include "main.h" #include "gui/setup_audio.h" +#include "gui/setup_chat.h" #include "gui/setup_colors.h" #include "gui/setup_joystick.h" #include "gui/setup_other.h" #include "gui/setup_theme.h" #include "gui/setup_keyboard.h" +#include "gui/setup_perfomance.h" #include "gui/setup_players.h" +#include "gui/setup_relations.h" #include "gui/setup_video.h" -#include "gui/setup_chat.h" #include "gui/widgets/button.h" #include "gui/widgets/label.h" @@ -85,14 +88,17 @@ Setup::Setup(): mPanel = new TabbedArea; mPanel->setDimension(gcn::Rectangle(5, 5, width - 10, height - 40)); + mPanel->enableScrollButtons(true); mTabs.push_back(new Setup_Video); mTabs.push_back(new Setup_Audio); + mTabs.push_back(new Setup_Perfomance); mTabs.push_back(new Setup_Joystick); mTabs.push_back(new Setup_Keyboard); mTabs.push_back(new Setup_Colors); mTabs.push_back(new Setup_Chat); mTabs.push_back(new Setup_Players); + mTabs.push_back(new Setup_Relations); mTabs.push_back(new Setup_Theme); mTabs.push_back(new Setup_Other); @@ -139,11 +145,12 @@ void Setup::action(const gcn::ActionEvent &event) } else if (event.getId() == "Cancel") { - setVisible(false); - for_each(mTabs.begin(), mTabs.end(), std::mem_fun(&SetupTab::cancel)); + doCancel(); } else if (event.getId() == "Store") { + if (chatWindow) + chatWindow->saveState(); config.write(); serverConfig.write(); } @@ -181,4 +188,10 @@ void Setup::registerWindowForReset(Window *window) mWindowsToReset.push_back(window); } +void Setup::doCancel() +{ + setVisible(false); + for_each(mTabs.begin(), mTabs.end(), std::mem_fun(&SetupTab::cancel)); +} + Setup *setupWindow; diff --git a/src/gui/setup.h b/src/gui/setup.h index ad5ba53d9..cdaf7db99 100644 --- a/src/gui/setup.h +++ b/src/gui/setup.h @@ -71,6 +71,8 @@ class Setup : public Window, public gcn::ActionListener void clearWindowsForReset() { mWindowsToReset.clear(); } + void doCancel(); + private: std::list<SetupTab*> mTabs; std::list<Window*> mWindowsToReset; diff --git a/src/gui/setup_audio.cpp b/src/gui/setup_audio.cpp index 28e6d8cfa..1737e9004 100644 --- a/src/gui/setup_audio.cpp +++ b/src/gui/setup_audio.cpp @@ -23,7 +23,7 @@ #include "gui/setup_audio.h" #include "configuration.h" -#include "log.h" +#include "logger.h" #include "sound.h" #include "gui/okdialog.h" diff --git a/src/gui/setup_chat.cpp b/src/gui/setup_chat.cpp index 7db61542a..9e75b9c0a 100644 --- a/src/gui/setup_chat.cpp +++ b/src/gui/setup_chat.cpp @@ -1,10 +1,10 @@ /* - * The Mana World + * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas * Copyright (C) 2011 The ManaPlus Developers * - * This file is part of The Mana World. + * 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 @@ -25,7 +25,6 @@ #include "gui/chatwindow.h" #include "gui/editdialog.h" -#include "gui/setupitem.h" #include "gui/widgets/button.h" #include "gui/widgets/chattab.h" @@ -34,10 +33,11 @@ #include "gui/widgets/label.h" #include "gui/widgets/layouthelper.h" #include "gui/widgets/scrollarea.h" +#include "gui/widgets/setupitem.h" #include "configuration.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "utils/gettext.h" @@ -93,6 +93,9 @@ Setup_Chat::Setup_Chat() new SetupItemLabel(_("Tabs"), "", this); + new SetupItemCheckBox(_("Put all whispers in tabs"), "", + "whispertab", this, "whispertabEvent"); + new SetupItemCheckBox(_("Log magic messages in debug tab"), "", "showMagicInDebug", this, "showMagicInDebugEvent"); @@ -117,6 +120,11 @@ Setup_Chat::Setup_Chat() new SetupItemCheckBox(_("Use local time"), "", "useLocalTime", this, "useLocalTimeEvent"); + new SetupItemLabel(_("Other"), "", this); + + new SetupItemTextField(_("Highlight words (separated by comma)"), "", + "highlightWords", this, "highlightWordsEvent"); + setDimension(gcn::Rectangle(0, 0, 550, 350)); } @@ -125,5 +133,8 @@ void Setup_Chat::apply() SetupTabScroll::apply(); if (chatWindow) + { chatWindow->adjustTabSize(); + chatWindow->parseHighlights(); + } } diff --git a/src/gui/setup_chat.h b/src/gui/setup_chat.h index 0b69984c8..402235d99 100644 --- a/src/gui/setup_chat.h +++ b/src/gui/setup_chat.h @@ -1,10 +1,10 @@ /* - * The Mana World + * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas * Copyright (C) 2011 The ManaPlus Developers * - * This file is part of The Mana World. + * 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 diff --git a/src/gui/setup_other.cpp b/src/gui/setup_other.cpp index ac047e34b..b405f5045 100644 --- a/src/gui/setup_other.cpp +++ b/src/gui/setup_other.cpp @@ -1,10 +1,10 @@ /* - * The Mana World + * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas * Copyright (C) 2011 The ManaPlus Developers * - * This file is part of The Mana World. + * 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 @@ -23,13 +23,12 @@ #include "gui/setup_other.h" -#include "gui/setupitem.h" - #include "gui/widgets/layouthelper.h" #include "gui/widgets/scrollarea.h" +#include "gui/widgets/setupitem.h" #include "configuration.h" -#include "log.h" +#include "logger.h" #include "utils/gettext.h" diff --git a/src/gui/setup_other.h b/src/gui/setup_other.h index 945a2de46..a13bf4ba3 100644 --- a/src/gui/setup_other.h +++ b/src/gui/setup_other.h @@ -1,10 +1,10 @@ /* - * The Mana World + * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas * Copyright (C) 2011 The ManaPlus Developers * - * This file is part of The Mana World. + * 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 diff --git a/src/gui/setup_perfomance.cpp b/src/gui/setup_perfomance.cpp new file mode 100644 index 000000000..dfb119b91 --- /dev/null +++ b/src/gui/setup_perfomance.cpp @@ -0,0 +1,98 @@ +/* + * The ManaPlus Client + * Copyright (C) 2009 The Mana World Development Team + * Copyright (C) 2009-2010 Andrei Karas + * Copyright (C) 2011 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "gui/setup_perfomance.h" + +#include "gui/chatwindow.h" +#include "gui/editdialog.h" + +#include "gui/widgets/button.h" +#include "gui/widgets/chattab.h" +#include "gui/widgets/checkbox.h" +#include "gui/widgets/inttextfield.h" +#include "gui/widgets/label.h" +#include "gui/widgets/layouthelper.h" +#include "gui/widgets/scrollarea.h" +#include "gui/widgets/setupitem.h" + +#include "configuration.h" +#include "localplayer.h" +#include "logger.h" + +#include "utils/gettext.h" + +#include "debug.h" + +Setup_Perfomance::Setup_Perfomance() +{ + setName(_("Perfomance")); + + // Do the layout + LayoutHelper h(this); + ContainerPlacer place = h.getPlacer(0, 0); + place(0, 0, mScroll, 10, 10); + + new SetupItemLabel(_("Better perfomance (enable for better perfomance)"), + "", this); + + new SetupItemCheckBox(_("Auto adjust perfomance"), "", + "adjustPerfomance", this, "adjustPerfomanceEvent"); + + new SetupItemCheckBox(_("Show beings transparency"), "", + "beingopacity", this, "beingopacityEvent"); + + new SetupItemCheckBox(_("Hw acceleration"), "", + "hwaccel", this, "hwaccelEvent"); + + new SetupItemCheckBox(_("Enable opacity cache (Software, can " + "use many memory)"), "", "alphaCache", this, "alphaCacheEvent"); + + new SetupItemCheckBox(_("Enable map reduce (Software)"), "", + "enableMapReduce", this, "enableMapReduceEvent"); + + new SetupItemLabel(_("Better quality (disable for better perfomance)"), + "", this); + + new SetupItemCheckBox(_("Enable alpha channel fix (Software, can " + "be very slow)"), "Can slow down drawing", "enableAlphaFix", + this, "enableAlphaFixEvent"); + + new SetupItemCheckBox(_("Enable reorder sprites."), "", + "enableReorderSprites", this, "enableReorderSpritesEvent"); + + new SetupItemLabel(_("Small memory (enable for lower memory usage)"), + "", this); + + new SetupItemCheckBox(_("Disable advanced beings caching (Software)"), "", + "disableAdvBeingCaching", this, "disableAdvBeingCachingEvent"); + + new SetupItemCheckBox(_("Disable beings caching (Software)"), "", + "disableBeingCaching", this, "disableBeingCachingEvent"); + + setDimension(gcn::Rectangle(0, 0, 550, 350)); +} + +void Setup_Perfomance::apply() +{ + SetupTabScroll::apply(); +} diff --git a/src/gui/setup_perfomance.h b/src/gui/setup_perfomance.h new file mode 100644 index 000000000..f355c9691 --- /dev/null +++ b/src/gui/setup_perfomance.h @@ -0,0 +1,44 @@ +/* + * The ManaPlus Client + * Copyright (C) 2009 The Mana World Development Team + * Copyright (C) 2009-2010 Andrei Karas + * Copyright (C) 2011 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef GUI_SETUP_PERFOMANCE_H +#define GUI_SETUP_PERFOMANCE_H + +#include "guichanfwd.h" + +#include "gui/widgets/setuptabscroll.h" + +#include <guichan/actionlistener.hpp> + +class IntTextField; +class EditDialog; + +class Setup_Perfomance : public SetupTabScroll +{ + public: + Setup_Perfomance(); + + void apply(); +}; + +#endif diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp index 67ec053ea..78c77f6f1 100644 --- a/src/gui/setup_players.cpp +++ b/src/gui/setup_players.cpp @@ -1,7 +1,7 @@ /* * The ManaPlus Client - * Copyright (C) 2008-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2009 The Mana World Development Team + * Copyright (C) 2009-2010 Andrei Karas * Copyright (C) 2011 The ManaPlus Developers * * This file is part of The ManaPlus Client. @@ -17,565 +17,71 @@ * 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/>. + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "gui/setup_players.h" -#include "actorspritemanager.h" -#include "configuration.h" -#include "localplayer.h" -#include "log.h" - +#include "gui/chatwindow.h" #include "gui/editdialog.h" -#include "gui/okdialog.h" #include "gui/widgets/button.h" +#include "gui/widgets/chattab.h" #include "gui/widgets/checkbox.h" -#include "gui/widgets/dropdown.h" +#include "gui/widgets/inttextfield.h" #include "gui/widgets/label.h" #include "gui/widgets/layouthelper.h" #include "gui/widgets/scrollarea.h" -#include "gui/widgets/table.h" -#include "gui/widgets/textfield.h" - -#include "utils/dtor.h" -#include "utils/gettext.h" - -#include <string> -#include <vector> +#include "gui/widgets/setupitem.h" -#define COLUMNS_NR 2 // name plus listbox -#define NAME_COLUMN 0 -#define RELATION_CHOICE_COLUMN 1 - -#define ROW_HEIGHT 12 -// The following column widths really shouldn't be hardcoded but should scale with the size of the widget... except -// that, right now, the widget doesn't exactly scale either. -#define NAME_COLUMN_WIDTH 230 -#define RELATION_CHOICE_COLUMN_WIDTH 80 +#include "configuration.h" +#include "localplayer.h" +#include "logger.h" -#define WIDGET_AT(row, column) (((row) * COLUMNS_NR) + column) +#include "utils/gettext.h" #include "debug.h" -static const char *table_titles[COLUMNS_NR] = -{ - N_("Name"), - N_("Relation") -}; - -static const char *RELATION_NAMES[PlayerRelation::RELATIONS_NR] = -{ - N_("Neutral"), - N_("Friend"), - N_("Disregarded"), - N_("Ignored"), - N_("Erased") -}; - -class PlayerRelationListModel : public gcn::ListModel -{ -public: - virtual ~PlayerRelationListModel() { } - - virtual int getNumberOfElements() - { - return PlayerRelation::RELATIONS_NR; - } - - virtual std::string getElementAt(int i) - { - if (i >= getNumberOfElements() || i < 0) - return ""; - return gettext(RELATION_NAMES[i]); - } -}; - -class PlayerTableModel : public TableModel -{ -public: - PlayerTableModel() : - mPlayers(NULL), - mListModel(new PlayerRelationListModel) - { - playerRelationsUpdated(); - } - - virtual ~PlayerTableModel() - { - freeWidgets(); - delete mListModel; - mListModel = 0; - delete mPlayers; - mPlayers = 0; - } - - virtual int getRows() const - { - if (mPlayers) - return static_cast<int>(mPlayers->size()); - else - return 0; - } - - virtual int getColumns() const - { - return COLUMNS_NR; - } - - virtual int getRowHeight() const - { - return ROW_HEIGHT; - } - - virtual int getColumnWidth(int index) const - { - if (index == NAME_COLUMN) - return NAME_COLUMN_WIDTH; - else - return RELATION_CHOICE_COLUMN_WIDTH; - } - - virtual void playerRelationsUpdated() - { - signalBeforeUpdate(); - - freeWidgets(); - std::vector<std::string> *player_names = player_relations.getPlayers(); - - if (!player_names) - return; - - delete mPlayers; - mPlayers = player_names; - - // set up widgets - for (unsigned int r = 0; r < player_names->size(); ++r) - { - std::string name = (*player_names)[r]; - gcn::Widget *widget = new Label(name); - mWidgets.push_back(widget); - - gcn::DropDown *choicebox = new DropDown(mListModel); - choicebox->setSelected(player_relations.getRelation(name)); - mWidgets.push_back(choicebox); - } - - signalAfterUpdate(); - } - - virtual void updateModelInRow(int row) - { - gcn::DropDown *choicebox = static_cast<gcn::DropDown *>( - getElementAt(row, RELATION_CHOICE_COLUMN)); - player_relations.setRelation(getPlayerAt(row), - static_cast<PlayerRelation::Relation>( - choicebox->getSelected())); - } - - - virtual gcn::Widget *getElementAt(int row, int column) const - { - return mWidgets[WIDGET_AT(row, column)]; - } - - virtual void freeWidgets() - { - delete mPlayers; - mPlayers = 0; - - delete_all(mWidgets); - mWidgets.clear(); - } - - std::string getPlayerAt(int index) const - { - return (*mPlayers)[index]; - } - -protected: - std::vector<std::string> *mPlayers; - std::vector<gcn::Widget *> mWidgets; - PlayerRelationListModel *mListModel; -}; - -/** - * Class for choosing one of the various `what to do when ignoring a player' options - */ -class IgnoreChoicesListModel : public gcn::ListModel -{ -public: - virtual ~IgnoreChoicesListModel() { } - - virtual int getNumberOfElements() - { - return static_cast<int>(player_relations.getPlayerIgnoreStrategies() - ->size()); - } - - virtual std::string getElementAt(int i) - { - if (i >= getNumberOfElements() || i < 0) - return _("???"); - - return (*player_relations.getPlayerIgnoreStrategies()) - [i]->mDescription; - } -}; - -#define ACTION_DELETE "delete" -#define ACTION_OLD "old" -#define ACTION_TABLE "table" -#define ACTION_STRATEGY "strategy" -#define ACTION_WHISPER_TAB "whisper tab" -#define ACTION_SHOW_GENDER "show gender" -#define ACTION_SHOW_LEVEL "show level" -#define ACTION_TARGET_DEAD "target dead" -#define ACTION_SHOW_OWN_NAME "show own name" -#define ACTION_SECURE_TRADES "secure trades" -#define ACTION_UNSECURE "unsecure" -#define ACTION_EDIT_UNSECURE "edit unsecure" -#define ACTION_EDIT_UNSECURE_OK "edit unsecure ok" - -Setup_Players::Setup_Players(): - mPlayerTableTitleModel(new StaticTableModel(1, COLUMNS_NR)), - mPlayerTableModel(new PlayerTableModel), - mPlayerTable(new GuiTable(mPlayerTableModel)), - mPlayerTitleTable(new GuiTable(mPlayerTableTitleModel)), - mPlayerScrollArea(new ScrollArea(mPlayerTable)), - mDefaultTrading(new CheckBox(_("Allow trading"), - player_relations.getDefault() & PlayerRelation::TRADE)), - mDefaultWhisper(new CheckBox(_("Allow whispers"), - player_relations.getDefault() & PlayerRelation::WHISPER)), - mDeleteButton(new Button(_("Delete"), ACTION_DELETE, this)), - mOldButton(new Button(_("Old"), ACTION_OLD, this)), - mWhisperTab(config.getBoolValue("whispertab")), - mWhisperTabCheckBox(new CheckBox(_("Put all whispers in tabs"), - mWhisperTab)), - mShowGender(config.getBoolValue("showgender")), - mShowGenderCheckBox(new CheckBox(_("Show gender"), mShowGender)), - mShowLevel(config.getBoolValue("showlevel")), - mShowOwnName(config.getBoolValue("showownname")), - mTargetDead(config.getBoolValue("targetDeadPlayers")), - mSecureTrades(config.getBoolValue("securetrades")), - mUnsecureChars(config.getStringValue("unsecureChars")), - mVisibleNamesEnabled(config.getBoolValue("visiblenames")), - mShowPlayersStatus(config.getBoolValue("showPlayersStatus")), - mEditDialog(0) +Setup_Players::Setup_Players() { setName(_("Players")); - mPlayerTable->setOpaque(false); - - mPlayerTableTitleModel->fixColumnWidth(NAME_COLUMN, NAME_COLUMN_WIDTH); - mPlayerTableTitleModel->fixColumnWidth(RELATION_CHOICE_COLUMN, - RELATION_CHOICE_COLUMN_WIDTH); - mPlayerTitleTable->setBackgroundColor(gcn::Color(0xbf, 0xbf, 0xbf)); - - mIgnoreActionChoicesModel = new IgnoreChoicesListModel; - mIgnoreActionChoicesBox = new DropDown(mIgnoreActionChoicesModel); - - for (int i = 0; i < COLUMNS_NR; i++) - { - mPlayerTableTitleModel->set(0, i, - new Label(gettext(table_titles[i]))); - } - - mPlayerTitleTable->setLinewiseSelection(true); - - mPlayerScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); - mPlayerTable->setActionEventId(ACTION_TABLE); - mPlayerTable->setLinewiseSelection(true); - mPlayerTable->addActionListener(this); - - gcn::Label *ignore_action_label = new Label(_("When ignoring:")); - - mIgnoreActionChoicesBox->setActionEventId(ACTION_STRATEGY); - mIgnoreActionChoicesBox->addActionListener(this); - - int ignore_strategy_index = 0; // safe default - - if (player_relations.getPlayerIgnoreStrategy()) - { - ignore_strategy_index = player_relations.getPlayerIgnoreStrategyIndex( - player_relations.getPlayerIgnoreStrategy()->mShortName); - if (ignore_strategy_index < 0) - ignore_strategy_index = 0; - } - mIgnoreActionChoicesBox->setSelected(ignore_strategy_index); - mIgnoreActionChoicesBox->adjustHeight(); - - mWhisperTabCheckBox->setActionEventId(ACTION_WHISPER_TAB); - mWhisperTabCheckBox->addActionListener(this); - - mShowGenderCheckBox->setActionEventId(ACTION_SHOW_GENDER); - mShowGenderCheckBox->addActionListener(this); - - mShowLevelCheckBox = new CheckBox(_("Show level"), mShowLevel); - mShowLevelCheckBox->setActionEventId(ACTION_SHOW_LEVEL); - mShowLevelCheckBox->addActionListener(this); - - mShowOwnNameCheckBox = new CheckBox(_("Show own name"), mShowOwnName); - mShowOwnNameCheckBox->setActionEventId(ACTION_SHOW_OWN_NAME); - mShowOwnNameCheckBox->addActionListener(this); - - mTargetDeadCheckBox = new CheckBox(_("Target dead players"), mTargetDead); - mTargetDeadCheckBox->setActionEventId(ACTION_TARGET_DEAD); - mTargetDeadCheckBox->addActionListener(this); - - mSecureTradesCheckBox = new CheckBox(_("Secure trades"), mSecureTrades); - mSecureTradesCheckBox->setActionEventId(ACTION_SECURE_TRADES); - mSecureTradesCheckBox->addActionListener(this); - - mUnsecureCharsLabel = new Label(_("Unsecure chars in names")); - mUnsecureCharsField = new TextField(mUnsecureChars, - true, this, ACTION_UNSECURE); - mUnsecureCharsButton = new Button(_("Edit"), ACTION_EDIT_UNSECURE, this); - - mVisibleNamesCheckBox = new CheckBox(_("Visible names"), - mVisibleNamesEnabled); - mVisibleNamesCheckBox->setActionEventId("visiblenames"); - mVisibleNamesCheckBox->addActionListener(this); - - mShowPlayersStatusCheckBox = new CheckBox(_("Show statuses"), - mShowPlayersStatus); - mShowPlayersStatusCheckBox->setActionEventId("showPlayersStatus"); - mShowPlayersStatusCheckBox->addActionListener(this); - - reset(); - - // Do the layout LayoutHelper h(this); ContainerPlacer place = h.getPlacer(0, 0); + place(0, 0, mScroll, 10, 10); - place(0, 0, mPlayerTitleTable, 6); - place(0, 1, mPlayerScrollArea, 6, 4).setPadding(2); - place(0, 5, mDeleteButton); - place(0, 6, mShowGenderCheckBox, 3).setPadding(2); - place(0, 7, mShowLevelCheckBox, 3).setPadding(2); - place(0, 8, mShowOwnNameCheckBox, 3).setPadding(2); - place(1, 5, mOldButton, 1); - place(3, 5, ignore_action_label, 1); - place(4, 5, mIgnoreActionChoicesBox, 2).setPadding(2); - place(3, 6, mDefaultTrading, 3); - place(3, 7, mDefaultWhisper, 3); - place(3, 8, mSecureTradesCheckBox, 3); - place(3, 9, mUnsecureCharsLabel, 3); - place(3, 10, mUnsecureCharsField, 2); - place(3, 11, mShowPlayersStatusCheckBox, 2); - place(5, 10, mUnsecureCharsButton, 1); - place(0, 9, mWhisperTabCheckBox, 3).setPadding(4); - place(0, 10, mTargetDeadCheckBox, 3).setPadding(4); - place(0, 11, mVisibleNamesCheckBox, 3).setPadding(4); + new SetupItemCheckBox(_("Show gender"), "", + "showgender", this, "showgenderEvent"); - player_relations.addListener(this); + new SetupItemCheckBox(_("Show level"), "", + "showlevel", this, "showlevelEvent"); - setDimension(gcn::Rectangle(0, 0, 500, 350)); -} + new SetupItemCheckBox(_("Show own name"), "", + "showownname", this, "showownnameEvent"); -Setup_Players::~Setup_Players() -{ - player_relations.removeListener(this); - delete mIgnoreActionChoicesModel; - mIgnoreActionChoicesModel = 0; -} + new SetupItemCheckBox(_("Target dead players"), "", + "targetDeadPlayers", this, "targetDeadPlayersEvent"); + new SetupItemCheckBox(_("Visible names"), "", + "visiblenames", this, "visiblenamesEvent"); -void Setup_Players::reset() -{ - // We now have to search through the list of ignore choices to find the - // current selection. We could use an index into the table of config - // options in player_relations instead of strategies to sidestep this. - int selection = 0; - for (unsigned int i = 0; - i < player_relations.getPlayerIgnoreStrategies()->size(); - ++i) - if ((*player_relations.getPlayerIgnoreStrategies())[i] == - player_relations.getPlayerIgnoreStrategy()) - { + new SetupItemCheckBox(_("Secure trades"), "", + "securetrades", this, "securetradesEvent"); - selection = i; - break; - } + new SetupItemTextField(_("Unsecure chars in names"), "", + "unsecureChars", this, "unsecureCharsEvent"); - mIgnoreActionChoicesBox->setSelected(selection); -} + new SetupItemCheckBox(_("Show statuses"), "", + "showPlayersStatus", this, "showPlayersStatusEvent"); -void Setup_Players::apply() -{ - player_relations.store(); - - unsigned int old_default_relations = player_relations.getDefault() & - ~(PlayerRelation::TRADE | - PlayerRelation::WHISPER); - player_relations.setDefault(old_default_relations - | (mDefaultTrading->isSelected() ? - PlayerRelation::TRADE : 0) - | (mDefaultWhisper->isSelected() ? - PlayerRelation::WHISPER : 0)); - config.setValue("whispertab", mWhisperTab); - config.setValue("showlevel", mShowLevel); - config.setValue("showownname", mShowOwnName); - config.setValue("targetDeadPlayers", mTargetDead); - config.setValue("showgender", mShowGender); - config.setValue("securetrades", mSecureTrades); - config.setValue("unsecureChars", mUnsecureCharsField->getText()); - config.setValue("visiblenames", mVisibleNamesEnabled); - config.setValue("showPlayersStatus", mShowPlayersStatus); - - if (actorSpriteManager) - actorSpriteManager->updatePlayerNames(); - - if (player_node) - player_node->setCheckNameSetting(true); -} + new SetupItemCheckBox(_("Show ip addresses on screenshots"), "", + "showip", this, "showipEvent"); -void Setup_Players::cancel() -{ - mWhisperTab = config.getBoolValue("whispertab"); - mWhisperTabCheckBox->setSelected(mWhisperTab); - mShowGender = config.getBoolValue("showgender"); - mShowGenderCheckBox->setSelected(mShowGender); - mShowLevel = config.getBoolValue("showlevel"); - mShowLevelCheckBox->setSelected(mShowLevel); - mShowOwnName = config.getBoolValue("showownname"); - mShowOwnNameCheckBox->setSelected(mShowOwnName); - mTargetDead = config.getBoolValue("targetDeadPlayers"); - mTargetDeadCheckBox->setSelected(mTargetDead); - mSecureTrades = config.getBoolValue("securetrades"); - mSecureTradesCheckBox->setSelected(mSecureTrades); - mUnsecureChars = config.getStringValue("unsecureChars"); - mUnsecureCharsField->setText(mUnsecureChars); - mVisibleNamesEnabled = config.getBoolValue("visiblenames"); - mVisibleNamesCheckBox->setSelected(mVisibleNamesEnabled); - mShowPlayersStatus = config.getBoolValue("showPlayersStatus"); - mShowPlayersStatusCheckBox->setSelected(mShowPlayersStatus); + setDimension(gcn::Rectangle(0, 0, 550, 350)); } -void Setup_Players::action(const gcn::ActionEvent &event) -{ - if (event.getId() == ACTION_TABLE) - { - // temporarily eliminate ourselves: we are fully aware of this change, - // so there is no need for asynchronous updates. (In fact, thouse - // might destroy the widet that triggered them, which would be rather - // embarrassing.) - player_relations.removeListener(this); - - int row = mPlayerTable->getSelectedRow(); - if (row >= 0) - mPlayerTableModel->updateModelInRow(row); - - player_relations.addListener(this); - - } - else if (event.getId() == ACTION_DELETE) - { - int player_index = mPlayerTable->getSelectedRow(); - - if (player_index < 0) - return; - - std::string name = mPlayerTableModel->getPlayerAt(player_index); - - player_relations.removePlayer(name); - } - else if (event.getId() == ACTION_OLD) - { - player_relations.load(true); - updateAll(); - } - else if (event.getId() == ACTION_STRATEGY) - { - PlayerIgnoreStrategy *s = - (*player_relations.getPlayerIgnoreStrategies())[ - mIgnoreActionChoicesBox->getSelected()]; - - player_relations.setPlayerIgnoreStrategy(s); - } - else if (event.getId() == ACTION_WHISPER_TAB) - { - mWhisperTab = mWhisperTabCheckBox->isSelected(); - } - else if (event.getId() == ACTION_SHOW_GENDER) - { - mShowGender = mShowGenderCheckBox->isSelected(); - } - else if (event.getId() == ACTION_SHOW_LEVEL) - { - mShowLevel = mShowLevelCheckBox->isSelected(); - } - else if (event.getId() == ACTION_SHOW_OWN_NAME) - { - mShowOwnName = mShowOwnNameCheckBox->isSelected(); - } - else if (event.getId() == ACTION_TARGET_DEAD) - { - mTargetDead = mTargetDeadCheckBox->isSelected(); - } - else if (event.getId() == ACTION_SECURE_TRADES) - { - mSecureTrades = mSecureTradesCheckBox->isSelected(); - } - else if (event.getId() == ACTION_EDIT_UNSECURE) - { - mEditDialog = new EditDialog(_("Unsecure chars in names"), - mUnsecureCharsField->getText(), ACTION_EDIT_UNSECURE_OK); - mEditDialog->addActionListener(this); - } - else if (event.getId() == ACTION_EDIT_UNSECURE_OK) - { - mUnsecureCharsField->setText(mEditDialog->getMsg()); - } - else if (event.getId() == ACTION_UNSECURE) - { - mUnsecureChars = mUnsecureCharsField->getText(); - } - else if (event.getId() == "visiblenames") - { - mVisibleNamesEnabled = mVisibleNamesCheckBox->isSelected(); - } - else if (event.getId() == "showPlayersStatus") - { - mShowPlayersStatus = mShowPlayersStatusCheckBox->isSelected(); - } -} - -void Setup_Players::updatedPlayer(const std::string &name A_UNUSED) -{ - mPlayerTableModel->playerRelationsUpdated(); - mDefaultTrading->setSelected( - player_relations.getDefault() & PlayerRelation::TRADE); - mDefaultWhisper->setSelected( - player_relations.getDefault() & PlayerRelation::WHISPER); - if (player_node) - player_node->updateName(); -} - -void Setup_Players::updateAll() +void Setup_Players::apply() { - PlayerTableModel *model = new PlayerTableModel(); - mPlayerTable->setModel(model); - delete mPlayerTableModel; - mPlayerTableModel = model; - int ignore_strategy_index = 0; // safe default - - if (player_relations.getPlayerIgnoreStrategy()) - { - ignore_strategy_index = player_relations.getPlayerIgnoreStrategyIndex( - player_relations.getPlayerIgnoreStrategy()->mShortName); - if (ignore_strategy_index < 0) - ignore_strategy_index = 0; - } - mIgnoreActionChoicesBox->setSelected(ignore_strategy_index); - mIgnoreActionChoicesBox->adjustHeight(); - reset(); + SetupTabScroll::apply(); } -void Setup_Players::externalUpdated() -{ - mDefaultTrading->setSelected( - player_relations.getDefault() & PlayerRelation::TRADE); - mDefaultWhisper->setSelected( - player_relations.getDefault() & PlayerRelation::WHISPER); -}
\ No newline at end of file diff --git a/src/gui/setup_players.h b/src/gui/setup_players.h index 9f35d1600..c9ce7b3b3 100644 --- a/src/gui/setup_players.h +++ b/src/gui/setup_players.h @@ -1,7 +1,7 @@ /* * The ManaPlus Client - * Copyright (C) 2008-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2009 The Mana World Development Team + * Copyright (C) 2009-2010 Andrei Karas * Copyright (C) 2011 The ManaPlus Developers * * This file is part of The ManaPlus Client. @@ -17,96 +17,28 @@ * 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/>. + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef GUI_SETUP_PLAYERS_H #define GUI_SETUP_PLAYERS_H #include "guichanfwd.h" -#include "playerrelations.h" -#include "gui/widgets/setuptab.h" +#include "gui/widgets/setuptabscroll.h" #include <guichan/actionlistener.hpp> -#ifdef __GNUC__ -#define A_UNUSED __attribute__ ((unused)) -#else -#define A_UNUSED -#endif - +class IntTextField; class EditDialog; -class GuiTable; -class PlayerTableModel; -class StaticTableModel; -class Setup_Players : public SetupTab, - public PlayerRelationsListener +class Setup_Players : public SetupTabScroll { -public: - Setup_Players(); - virtual ~Setup_Players(); - - void apply(); - void cancel(); - - void reset(); - - void action(const gcn::ActionEvent &event); - - virtual void updatedPlayer(const std::string &name); - - virtual void updateAll(); - - virtual void externalUpdated(); - -private: - StaticTableModel *mPlayerTableTitleModel; - PlayerTableModel *mPlayerTableModel; - GuiTable *mPlayerTable; - GuiTable *mPlayerTitleTable; - gcn::ScrollArea *mPlayerScrollArea; - - gcn::CheckBox *mDefaultTrading; - gcn::CheckBox *mDefaultWhisper; - - gcn::Button *mDeleteButton; - gcn::Button *mOldButton; - - gcn::ListModel *mIgnoreActionChoicesModel; - gcn::DropDown *mIgnoreActionChoicesBox; - - bool mWhisperTab; - gcn::CheckBox *mWhisperTabCheckBox; - - bool mShowGender; - gcn::CheckBox *mShowGenderCheckBox; - - bool mShowLevel; - gcn::CheckBox *mShowLevelCheckBox; - - bool mShowOwnName; - gcn::CheckBox *mShowOwnNameCheckBox; - - bool mTargetDead; - gcn::CheckBox *mTargetDeadCheckBox; - - bool mSecureTrades; - gcn::CheckBox *mSecureTradesCheckBox; - - gcn::Label *mUnsecureCharsLabel; - gcn::TextField *mUnsecureCharsField; - gcn::Button *mUnsecureCharsButton; - std::string mUnsecureChars; - - bool mVisibleNamesEnabled; - gcn::CheckBox *mVisibleNamesCheckBox; - - bool mShowPlayersStatus; - gcn::CheckBox *mShowPlayersStatusCheckBox; + public: + Setup_Players(); - EditDialog *mEditDialog; + void apply(); }; #endif diff --git a/src/gui/setup_relations.cpp b/src/gui/setup_relations.cpp new file mode 100644 index 000000000..489d5a818 --- /dev/null +++ b/src/gui/setup_relations.cpp @@ -0,0 +1,439 @@ +/* + * The ManaPlus Client + * Copyright (C) 2008-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011 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/>. + */ + +#include "gui/setup_relations.h" + +#include "actorspritemanager.h" +#include "configuration.h" +#include "localplayer.h" +#include "logger.h" + +#include "gui/editdialog.h" +#include "gui/okdialog.h" + +#include "gui/widgets/button.h" +#include "gui/widgets/checkbox.h" +#include "gui/widgets/dropdown.h" +#include "gui/widgets/label.h" +#include "gui/widgets/layouthelper.h" +#include "gui/widgets/scrollarea.h" +#include "gui/widgets/guitable.h" +#include "gui/widgets/textfield.h" + +#include "utils/dtor.h" +#include "utils/gettext.h" + +#include <string> +#include <vector> + +#define COLUMNS_NR 2 // name plus listbox +#define NAME_COLUMN 0 +#define RELATION_CHOICE_COLUMN 1 + +#define ROW_HEIGHT 12 +// The following column widths really shouldn't be hardcoded but should scale with the size of the widget... except +// that, right now, the widget doesn't exactly scale either. +#define NAME_COLUMN_WIDTH 230 +#define RELATION_CHOICE_COLUMN_WIDTH 80 + +#define WIDGET_AT(row, column) (((row) * COLUMNS_NR) + column) + +#include "debug.h" + +static const char *table_titles[COLUMNS_NR] = +{ + N_("Name"), + N_("Relation") +}; + +static const char *RELATION_NAMES[PlayerRelation::RELATIONS_NR] = +{ + N_("Neutral"), + N_("Friend"), + N_("Disregarded"), + N_("Ignored"), + N_("Erased") +}; + +class PlayerRelationListModel : public gcn::ListModel +{ +public: + virtual ~PlayerRelationListModel() { } + + virtual int getNumberOfElements() + { + return PlayerRelation::RELATIONS_NR; + } + + virtual std::string getElementAt(int i) + { + if (i >= getNumberOfElements() || i < 0) + return ""; + return gettext(RELATION_NAMES[i]); + } +}; + +class PlayerTableModel : public TableModel +{ +public: + PlayerTableModel() : + mPlayers(NULL), + mListModel(new PlayerRelationListModel) + { + playerRelationsUpdated(); + } + + virtual ~PlayerTableModel() + { + freeWidgets(); + delete mListModel; + mListModel = 0; + delete mPlayers; + mPlayers = 0; + } + + virtual int getRows() const + { + if (mPlayers) + return static_cast<int>(mPlayers->size()); + else + return 0; + } + + virtual int getColumns() const + { + return COLUMNS_NR; + } + + virtual int getRowHeight() const + { + return ROW_HEIGHT; + } + + virtual int getColumnWidth(int index) const + { + if (index == NAME_COLUMN) + return NAME_COLUMN_WIDTH; + else + return RELATION_CHOICE_COLUMN_WIDTH; + } + + virtual void playerRelationsUpdated() + { + signalBeforeUpdate(); + + freeWidgets(); + std::vector<std::string> *player_names = player_relations.getPlayers(); + + if (!player_names) + return; + + delete mPlayers; + mPlayers = player_names; + + // set up widgets + for (unsigned int r = 0; r < player_names->size(); ++r) + { + std::string name = (*player_names)[r]; + gcn::Widget *widget = new Label(name); + mWidgets.push_back(widget); + + gcn::DropDown *choicebox = new DropDown(mListModel); + choicebox->setSelected(player_relations.getRelation(name)); + mWidgets.push_back(choicebox); + } + + signalAfterUpdate(); + } + + virtual void updateModelInRow(int row) + { + gcn::DropDown *choicebox = static_cast<gcn::DropDown *>( + getElementAt(row, RELATION_CHOICE_COLUMN)); + player_relations.setRelation(getPlayerAt(row), + static_cast<PlayerRelation::Relation>( + choicebox->getSelected())); + } + + + virtual gcn::Widget *getElementAt(int row, int column) const + { + return mWidgets[WIDGET_AT(row, column)]; + } + + virtual void freeWidgets() + { + delete mPlayers; + mPlayers = 0; + + delete_all(mWidgets); + mWidgets.clear(); + } + + std::string getPlayerAt(int index) const + { + return (*mPlayers)[index]; + } + +protected: + std::vector<std::string> *mPlayers; + std::vector<gcn::Widget *> mWidgets; + PlayerRelationListModel *mListModel; +}; + +/** + * Class for choosing one of the various `what to do when ignoring a player' options + */ +class IgnoreChoicesListModel : public gcn::ListModel +{ +public: + virtual ~IgnoreChoicesListModel() { } + + virtual int getNumberOfElements() + { + return static_cast<int>(player_relations.getPlayerIgnoreStrategies() + ->size()); + } + + virtual std::string getElementAt(int i) + { + if (i >= getNumberOfElements() || i < 0) + return _("???"); + + return (*player_relations.getPlayerIgnoreStrategies()) + [i]->mDescription; + } +}; + +#define ACTION_DELETE "delete" +#define ACTION_OLD "old" +#define ACTION_TABLE "table" +#define ACTION_STRATEGY "strategy" +#define ACTION_WHISPER_TAB "whisper tab" + +Setup_Relations::Setup_Relations(): + mPlayerTableTitleModel(new StaticTableModel(1, COLUMNS_NR)), + mPlayerTableModel(new PlayerTableModel), + mPlayerTable(new GuiTable(mPlayerTableModel)), + mPlayerTitleTable(new GuiTable(mPlayerTableTitleModel)), + mPlayerScrollArea(new ScrollArea(mPlayerTable)), + mDefaultTrading(new CheckBox(_("Allow trading"), + player_relations.getDefault() & PlayerRelation::TRADE)), + mDefaultWhisper(new CheckBox(_("Allow whispers"), + player_relations.getDefault() & PlayerRelation::WHISPER)), + mDeleteButton(new Button(_("Delete"), ACTION_DELETE, this)), + mOldButton(new Button(_("Old"), ACTION_OLD, this)) +{ + setName(_("Relations")); + + mPlayerTable->setOpaque(false); + + mPlayerTableTitleModel->fixColumnWidth(NAME_COLUMN, NAME_COLUMN_WIDTH); + mPlayerTableTitleModel->fixColumnWidth(RELATION_CHOICE_COLUMN, + RELATION_CHOICE_COLUMN_WIDTH); + mPlayerTitleTable->setBackgroundColor(gcn::Color(0xbf, 0xbf, 0xbf)); + + mIgnoreActionChoicesModel = new IgnoreChoicesListModel; + mIgnoreActionChoicesBox = new DropDown(mIgnoreActionChoicesModel); + + for (int i = 0; i < COLUMNS_NR; i++) + { + mPlayerTableTitleModel->set(0, i, + new Label(gettext(table_titles[i]))); + } + + mPlayerTitleTable->setLinewiseSelection(true); + + mPlayerScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); + mPlayerTable->setActionEventId(ACTION_TABLE); + mPlayerTable->setLinewiseSelection(true); + mPlayerTable->addActionListener(this); + + gcn::Label *ignore_action_label = new Label(_("When ignoring:")); + + mIgnoreActionChoicesBox->setActionEventId(ACTION_STRATEGY); + mIgnoreActionChoicesBox->addActionListener(this); + + int ignore_strategy_index = 0; // safe default + + if (player_relations.getPlayerIgnoreStrategy()) + { + ignore_strategy_index = player_relations.getPlayerIgnoreStrategyIndex( + player_relations.getPlayerIgnoreStrategy()->mShortName); + if (ignore_strategy_index < 0) + ignore_strategy_index = 0; + } + mIgnoreActionChoicesBox->setSelected(ignore_strategy_index); + mIgnoreActionChoicesBox->adjustHeight(); + + reset(); + + // Do the layout + LayoutHelper h(this); + ContainerPlacer place = h.getPlacer(0, 0); + + place(0, 0, mPlayerTitleTable, 6); + place(0, 1, mPlayerScrollArea, 6, 4).setPadding(2); + place(0, 5, mDeleteButton); + place(1, 5, mOldButton, 1); + place(3, 5, ignore_action_label, 1); + place(4, 5, mIgnoreActionChoicesBox, 2).setPadding(2); + place(3, 6, mDefaultTrading, 3); + place(3, 7, mDefaultWhisper, 3); + + player_relations.addListener(this); + + setDimension(gcn::Rectangle(0, 0, 500, 350)); +} + +Setup_Relations::~Setup_Relations() +{ + player_relations.removeListener(this); + delete mIgnoreActionChoicesModel; + mIgnoreActionChoicesModel = 0; +} + + +void Setup_Relations::reset() +{ + // We now have to search through the list of ignore choices to find the + // current selection. We could use an index into the table of config + // options in player_relations instead of strategies to sidestep this. + int selection = 0; + for (unsigned int i = 0; + i < player_relations.getPlayerIgnoreStrategies()->size(); + ++i) + if ((*player_relations.getPlayerIgnoreStrategies())[i] == + player_relations.getPlayerIgnoreStrategy()) + { + + selection = i; + break; + } + + mIgnoreActionChoicesBox->setSelected(selection); +} + +void Setup_Relations::apply() +{ + player_relations.store(); + + unsigned int old_default_relations = player_relations.getDefault() & + ~(PlayerRelation::TRADE | + PlayerRelation::WHISPER); + player_relations.setDefault(old_default_relations + | (mDefaultTrading->isSelected() ? + PlayerRelation::TRADE : 0) + | (mDefaultWhisper->isSelected() ? + PlayerRelation::WHISPER : 0)); + + if (actorSpriteManager) + actorSpriteManager->updatePlayerNames(); + + if (player_node) + player_node->setCheckNameSetting(true); +} + +void Setup_Relations::cancel() +{ +} + +void Setup_Relations::action(const gcn::ActionEvent &event) +{ + if (event.getId() == ACTION_TABLE) + { + // temporarily eliminate ourselves: we are fully aware of this change, + // so there is no need for asynchronous updates. (In fact, thouse + // might destroy the widet that triggered them, which would be rather + // embarrassing.) + player_relations.removeListener(this); + + int row = mPlayerTable->getSelectedRow(); + if (row >= 0) + mPlayerTableModel->updateModelInRow(row); + + player_relations.addListener(this); + + } + else if (event.getId() == ACTION_DELETE) + { + int player_index = mPlayerTable->getSelectedRow(); + + if (player_index < 0) + return; + + std::string name = mPlayerTableModel->getPlayerAt(player_index); + + player_relations.removePlayer(name); + } + else if (event.getId() == ACTION_OLD) + { + player_relations.load(true); + updateAll(); + } + else if (event.getId() == ACTION_STRATEGY) + { + PlayerIgnoreStrategy *s = + (*player_relations.getPlayerIgnoreStrategies())[ + mIgnoreActionChoicesBox->getSelected()]; + + player_relations.setPlayerIgnoreStrategy(s); + } +} + +void Setup_Relations::updatedPlayer(const std::string &name A_UNUSED) +{ + mPlayerTableModel->playerRelationsUpdated(); + mDefaultTrading->setSelected( + player_relations.getDefault() & PlayerRelation::TRADE); + mDefaultWhisper->setSelected( + player_relations.getDefault() & PlayerRelation::WHISPER); + if (player_node) + player_node->updateName(); +} + +void Setup_Relations::updateAll() +{ + PlayerTableModel *model = new PlayerTableModel(); + mPlayerTable->setModel(model); + delete mPlayerTableModel; + mPlayerTableModel = model; + int ignore_strategy_index = 0; // safe default + + if (player_relations.getPlayerIgnoreStrategy()) + { + ignore_strategy_index = player_relations.getPlayerIgnoreStrategyIndex( + player_relations.getPlayerIgnoreStrategy()->mShortName); + if (ignore_strategy_index < 0) + ignore_strategy_index = 0; + } + mIgnoreActionChoicesBox->setSelected(ignore_strategy_index); + mIgnoreActionChoicesBox->adjustHeight(); + reset(); +} +void Setup_Relations::externalUpdated() +{ + mDefaultTrading->setSelected( + player_relations.getDefault() & PlayerRelation::TRADE); + mDefaultWhisper->setSelected( + player_relations.getDefault() & PlayerRelation::WHISPER); +} diff --git a/src/gui/setup_relations.h b/src/gui/setup_relations.h new file mode 100644 index 000000000..a6627a06d --- /dev/null +++ b/src/gui/setup_relations.h @@ -0,0 +1,81 @@ +/* + * The ManaPlus Client + * Copyright (C) 2008-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011 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 GUI_SETUP_RELATIONS_H +#define GUI_SETUP_RELATIONS_H + +#include "guichanfwd.h" +#include "playerrelations.h" + +#include "gui/widgets/setuptab.h" + +#include <guichan/actionlistener.hpp> + +#ifdef __GNUC__ +#define A_UNUSED __attribute__ ((unused)) +#else +#define A_UNUSED +#endif + +class EditDialog; +class GuiTable; +class PlayerTableModel; +class StaticTableModel; + +class Setup_Relations : public SetupTab, + public PlayerRelationsListener +{ +public: + Setup_Relations(); + virtual ~Setup_Relations(); + + void apply(); + void cancel(); + + void reset(); + + void action(const gcn::ActionEvent &event); + + virtual void updatedPlayer(const std::string &name); + + virtual void updateAll(); + + virtual void externalUpdated(); + +private: + StaticTableModel *mPlayerTableTitleModel; + PlayerTableModel *mPlayerTableModel; + GuiTable *mPlayerTable; + GuiTable *mPlayerTitleTable; + gcn::ScrollArea *mPlayerScrollArea; + + gcn::CheckBox *mDefaultTrading; + gcn::CheckBox *mDefaultWhisper; + + gcn::Button *mDeleteButton; + gcn::Button *mOldButton; + + gcn::ListModel *mIgnoreActionChoicesModel; + gcn::DropDown *mIgnoreActionChoicesBox; +}; + +#endif diff --git a/src/gui/setup_theme.cpp b/src/gui/setup_theme.cpp index 515e15611..05f8c7315 100644 --- a/src/gui/setup_theme.cpp +++ b/src/gui/setup_theme.cpp @@ -1,9 +1,10 @@ /* - * The Mana World + * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2010 Andrei Karas + * Copyright (C) 2011 ManaPlus developers * - * This file is part of The Mana World. + * 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 @@ -36,7 +37,7 @@ #include "configuration.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "utils/gettext.h" @@ -50,6 +51,7 @@ const char* ACTION_BOLD_FONT = "bold font"; const char* ACTION_PARTICLE_FONT = "particle font"; const char* ACTION_HELP_FONT = "help font"; const char* ACTION_SECURE_FONT = "secure font"; +const char* ACTION_JAPAN_FONT = "japan font"; class NamesModel : public gcn::ListModel { @@ -135,6 +137,7 @@ Setup_Theme::Setup_Theme(): mParticleFont(config.getStringValue("particleFont")), mHelpFont(config.getStringValue("helpFont")), mSecureFont(config.getStringValue("secureFont")), + mJapanFont(config.getStringValue("japanFont")), mFontSize(config.getIntValue("fontSize")) { setName(_("Theme")); @@ -145,6 +148,7 @@ Setup_Theme::Setup_Theme(): mParticleFontLabel = new Label(_("Particle font")); mHelpFontLabel = new Label(_("Help font")); mSecureFontLabel = new Label(_("Secure font")); + mJapanFontLabel = new Label(_("Japanese font")); mThemesModel = new ThemesModel(); mFontsModel = new FontsModel(); @@ -172,6 +176,10 @@ Setup_Theme::Setup_Theme(): mSecureFontDropDown->setActionEventId(ACTION_SECURE_FONT); mSecureFontDropDown->addActionListener(this); + mJapanFontDropDown = new DropDown(mFontsModel); + mJapanFontDropDown->setActionEventId(ACTION_JAPAN_FONT); + mJapanFontDropDown->addActionListener(this); + fontSizeLabel = new Label(_("Font size")); mFontSizeListModel = new FontSizeChoiceListModel; mFontSizeDropDown = new DropDown(mFontSizeListModel); @@ -194,25 +202,30 @@ Setup_Theme::Setup_Theme(): config.getStringValue("helpFont"))); mSecureFontDropDown->setSelectedString(getFileName( config.getStringValue("secureFont"))); + mJapanFontDropDown->setSelectedString(getFileName( + config.getStringValue("japanFont"))); // Do the layout LayoutHelper h(this); ContainerPlacer place = h.getPlacer(0, 0); - place(0, 0, mThemeLabel, 10); - place(0, 1, mThemeDropDown, 6); - place(0, 2, fontSizeLabel, 10); - place(0, 3, mFontSizeDropDown, 6); - place(0, 4, mFontLabel, 10); - place(0, 5, mFontDropDown, 6); - place(0, 6, mBoldFontLabel, 10); - place(0, 7, mBoldFontDropDown, 6); - place(0, 8, mParticleFontLabel, 10); - place(0, 9, mParticleFontDropDown, 6); - place(0, 10, mHelpFontLabel, 10); - place(0, 11, mHelpFontDropDown, 6); - place(0, 12, mSecureFontLabel, 10); - place(0, 13, mSecureFontDropDown, 6); + place(0, 0, mThemeLabel, 5); + place(0, 1, fontSizeLabel, 5); + place(0, 2, mFontLabel, 5); + place(0, 3, mBoldFontLabel, 5); + place(0, 4, mParticleFontLabel, 5); + place(0, 5, mHelpFontLabel, 5); + place(0, 6, mSecureFontLabel, 5); + place(0, 7, mJapanFontLabel, 5); + + place(6, 0, mThemeDropDown, 10); + place(6, 1, mFontSizeDropDown, 10); + place(6, 2, mFontDropDown, 10); + place(6, 3, mBoldFontDropDown, 10); + place(6, 4, mParticleFontDropDown, 10); + place(6, 5, mHelpFontDropDown, 10); + place(6, 6, mSecureFontDropDown, 10); + place(6, 7, mJapanFontDropDown, 10); place.getCell().matchColWidth(0, 0); place = h.getPlacer(0, 1); @@ -261,6 +274,10 @@ void Setup_Theme::action(const gcn::ActionEvent &event) { mSecureFont = mSecureFontDropDown->getSelectedString(); } + else if (event.getId() == ACTION_JAPAN_FONT) + { + mJapanFont = mJapanFontDropDown->getSelectedString(); + } } void Setup_Theme::cancel() @@ -271,6 +288,7 @@ void Setup_Theme::cancel() mParticleFont = getFileName(config.getStringValue("particleFont")); mHelpFont = getFileName(config.getStringValue("helpFont")); mSecureFont = getFileName(config.getStringValue("secureFont")); + mJapanFont = getFileName(config.getStringValue("japanFont")); } void Setup_Theme::apply() @@ -289,6 +307,7 @@ void Setup_Theme::apply() || config.getValue("particleFont", "dejavusans.ttf") != mParticleFont || config.getValue("helpFont", "dejavusansmono.ttf") != mHelpFont || config.getValue("secureFont", "dejavusansmono.ttf") != mSecureFont + || config.getValue("japanFont", "mplus-1p-regular.ttf") != mJapanFont || config.getIntValue("fontSize") != static_cast<int>(mFontSizeDropDown->getSelected()) + 10) { @@ -297,6 +316,7 @@ void Setup_Theme::apply() config.setValue("particleFont", "fonts/" + getFileName(mParticleFont)); config.setValue("helpFont", "fonts/" + getFileName(mHelpFont)); config.setValue("secureFont", "fonts/" + getFileName(mSecureFont)); + config.setValue("japanFont", "fonts/" + getFileName(mJapanFont)); config.setValue("fontSize", mFontSizeDropDown->getSelected() + 10); gui->updateFonts(); } diff --git a/src/gui/setup_theme.h b/src/gui/setup_theme.h index 0d141c0a5..c803cc296 100644 --- a/src/gui/setup_theme.h +++ b/src/gui/setup_theme.h @@ -1,9 +1,10 @@ /* - * The Mana World + * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas + * Copyright (C) 2011 ManaPlus developers * - * This file is part of The Mana World. + * 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 @@ -73,6 +74,10 @@ class Setup_Theme : public SetupTab DropDown *mSecureFontDropDown; std::string mSecureFont; + gcn::Label *mJapanFontLabel; + DropDown *mJapanFontDropDown; + std::string mJapanFont; + FontSizeChoiceListModel *mFontSizeListModel; gcn::Label *fontSizeLabel; int mFontSize; diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index 3e5c56f64..03b485097 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -26,7 +26,7 @@ #include "game.h" #include "graphics.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "main.h" #include "particle.h" @@ -274,7 +274,6 @@ const char *Setup_Video::particleDetailToString(int detail) Setup_Video::Setup_Video(): mFullScreenEnabled(config.getBoolValue("screen")), mOpenGLEnabled(config.getIntValue("opengl")), - mHwAccelEnabled(config.getBoolValue("hwaccel")), mCustomCursorEnabled(config.getBoolValue("customcursor")), mParticleEffectsEnabled(config.getBoolValue("particleeffects")), mPickupChatEnabled(config.getBoolValue("showpickupchat")), @@ -282,16 +281,11 @@ Setup_Video::Setup_Video(): mOpacity(config.getFloatValue("guialpha")), mFps(config.getIntValue("fpslimit")), mAltFps(config.getIntValue("altfpslimit")), - mAlphaCache(config.getBoolValue("alphaCache")), - mEnableMapReduce(config.getBoolValue("enableMapReduce")), - mAdjustPerfomance(config.getBoolValue("adjustPerfomance")), - mBeingOpacity(config.getBoolValue("beingopacity")), mSpeechMode(static_cast<Being::Speech>( config.getIntValue("speech"))), mModeListModel(new ModeListModel), mModeList(new ListBox(mModeListModel)), mFsCheckBox(new CheckBox(_("Full screen"), mFullScreenEnabled)), - mHwAccelCheckBox(new CheckBox(_("Hw acceleration"), mHwAccelEnabled)), mCustomCursorCheckBox(new CheckBox(_("Custom cursor"), mCustomCursorEnabled)), mParticleEffectsCheckBox(new CheckBox(_("Particle effects"), @@ -302,13 +296,6 @@ Setup_Video::Setup_Video(): // TRANSLATORS: Refers to "Show own name" mPickupParticleCheckBox(new CheckBox(_("as particle"), mPickupParticleEnabled)), - mAlphaCacheCheckBox(new CheckBox(_("Enable opacity cache"), mAlphaCache)), - mEnableMapReduceCheckBox(new CheckBox(_("Enable map reduce"), - mEnableMapReduce)), - mAdjustPerfomanceCheckBox(new CheckBox(_("Auto adjust perfomance"), - mAdjustPerfomance)), - mBeingOpacityCheckBox(new CheckBox(_("Show beings transparency"), - mBeingOpacity)), mSpeechSlider(new Slider(0, 3)), mSpeechLabel(new Label("")), mAlphaSlider(new Slider(0.1, 1.0)), @@ -348,8 +335,6 @@ Setup_Video::Setup_Video(): mAlphaSlider->setValue(mOpacity); mAlphaSlider->setWidth(90); - mAlphaCacheCheckBox->setEnabled(mOpenGLDropDown->getSelected() == 0); - mEnableMapReduceCheckBox->setEnabled(mOpenGLDropDown->getSelected() == 0); mFpsLabel->setCaption(mFps > 0 ? toString(mFps) : _("None")); mFpsLabel->setWidth(60); @@ -381,9 +366,6 @@ Setup_Video::Setup_Video(): mOverlayDetailField->setActionEventId("overlaydetailfield"); mParticleDetailSlider->setActionEventId("particledetailslider"); mParticleDetailField->setActionEventId("particledetailfield"); - mAlphaCacheCheckBox->setActionEventId("alphaCache"); - mEnableMapReduceCheckBox->setActionEventId("enableMapReduce"); - mAdjustPerfomanceCheckBox->setActionEventId("adjustPerfomance"); mOpenGLDropDown->setActionEventId("opengl"); mModeList->addActionListener(this); @@ -402,10 +384,6 @@ Setup_Video::Setup_Video(): mParticleDetailField->addKeyListener(this); mOpenGLDropDown->addActionListener(this); - mAlphaCacheCheckBox->addKeyListener(this); - mEnableMapReduceCheckBox->addKeyListener(this); - mAdjustPerfomanceCheckBox->addKeyListener(this); - mSpeechLabel->setCaption(speechModeToString(mSpeechMode)); mSpeechSlider->setValue(mSpeechMode); @@ -422,45 +400,40 @@ Setup_Video::Setup_Video(): place(0, 0, scrollArea, 1, 5).setPadding(2); place(0, 5, mOpenGLDropDown, 1); - place(0, 6, mHwAccelCheckBox, 6); - place(0, 7, mAlphaCacheCheckBox, 6); - place(0, 8, mEnableMapReduceCheckBox, 6); +// place(0, 6, mHwAccelCheckBox, 6); place(1, 0, mFsCheckBox, 2); place(1, 1, mCustomCursorCheckBox, 3); - place(1, 2, mBeingOpacityCheckBox); - place(1, 3, mParticleEffectsCheckBox, 2); - - place(1, 4, mPickupNotifyLabel, 4); + place(1, 2, mParticleEffectsCheckBox, 2); - place(1, 5, mPickupChatCheckBox, 1); - place(2, 5, mPickupParticleCheckBox, 2); + place(1, 3, mPickupNotifyLabel, 4); - place(0, 9, mAdjustPerfomanceCheckBox, 6); + place(1, 4, mPickupChatCheckBox, 1); + place(2, 4, mPickupParticleCheckBox, 2); - place(0, 10, mAlphaSlider); - place(1, 10, alphaLabel, 3); + place(0, 6, mAlphaSlider); + place(1, 6, alphaLabel, 3); - place(0, 11, mFpsSlider); - place(1, 11, mFpsCheckBox).setPadding(3); - place(2, 11, mFpsLabel).setPadding(1); + place(0, 7, mFpsSlider); + place(1, 7, mFpsCheckBox).setPadding(3); + place(2, 7, mFpsLabel).setPadding(1); - place(0, 12, mAltFpsSlider); - place(1, 12, mAltFpsLabel).setPadding(3); + place(0, 8, mAltFpsSlider); + place(1, 8, mAltFpsLabel).setPadding(3); - place(0, 13, mSpeechSlider); - place(1, 13, speechLabel); - place(2, 13, mSpeechLabel, 3).setPadding(2); + place(0, 9, mSpeechSlider); + place(1, 9, speechLabel); + place(2, 9, mSpeechLabel, 3).setPadding(2); - place(0, 14, mOverlayDetailSlider); - place(1, 14, overlayDetailLabel); - place(2, 14, mOverlayDetailField, 3).setPadding(2); + place(0, 10, mOverlayDetailSlider); + place(1, 10, overlayDetailLabel); + place(2, 10, mOverlayDetailField, 3).setPadding(2); - place(0, 15, mParticleDetailSlider); - place(1, 15, particleDetailLabel); - place(2, 15, mParticleDetailField, 3).setPadding(2); + place(0, 11, mParticleDetailSlider); + place(1, 11, particleDetailLabel); + place(2, 11, mParticleDetailField, 3).setPadding(2); int width = 600; @@ -551,33 +524,20 @@ void Setup_Video::apply() mAltFpsSlider->setEnabled(mAltFps > 0); - config.setValue("hwaccel", mHwAccelCheckBox->isSelected()); - // FPS change config.setValue("fpslimit", mFps); config.setValue("altfpslimit", mAltFps); - config.setValue("alphaCache", mAlphaCacheCheckBox->isSelected()); - config.setValue("enableMapReduce", mEnableMapReduceCheckBox->isSelected()); - config.setValue("adjustPerfomance", - mAdjustPerfomanceCheckBox->isSelected()); - config.setValue("beingopacity", mBeingOpacityCheckBox->isSelected()); - // We sync old and new values at apply time mFullScreenEnabled = config.getBoolValue("screen"); mCustomCursorEnabled = config.getBoolValue("customcursor"); mParticleEffectsEnabled = config.getBoolValue("particleeffects"); - mAlphaCache = config.getBoolValue("alphaCache"); - mEnableMapReduce = config.getBoolValue("enableMapReduce"); - mAdjustPerfomance = config.getBoolValue("adjustPerfomance"); - mBeingOpacity = config.getBoolValue("beingopacity"); mSpeechMode = static_cast<Being::Speech>( config.getIntValue("speech")); mOpacity = config.getFloatValue("guialpha"); mOverlayDetail = config.getIntValue("OverlayDetail"); mOpenGLEnabled = config.getIntValue("opengl"); - mHwAccelEnabled = config.getBoolValue("hwaccel"); mPickupChatEnabled = config.getBoolValue("showpickupchat"); mPickupParticleEnabled = config.getBoolValue("showpickupparticle"); } @@ -587,7 +547,6 @@ void Setup_Video::cancel() mFpsCheckBox->setSelected(mFps > 0); mFsCheckBox->setSelected(mFullScreenEnabled); mOpenGLDropDown->setSelected(mOpenGLEnabled); - mHwAccelCheckBox->setSelected(mHwAccelEnabled); mCustomCursorCheckBox->setSelected(mCustomCursorEnabled); mParticleEffectsCheckBox->setSelected(mParticleEffectsEnabled); mFpsSlider->setValue(mFps); @@ -595,10 +554,6 @@ void Setup_Video::cancel() mAltFpsSlider->setValue(mAltFps); mAltFpsSlider->setEnabled(mAltFps > 0); mSpeechSlider->setValue(mSpeechMode); - mAlphaCacheCheckBox->setSelected(mAlphaCache); - mEnableMapReduceCheckBox->setSelected(mEnableMapReduce); - mAdjustPerfomanceCheckBox->setSelected(mAdjustPerfomance); - mBeingOpacityCheckBox->setSelected(mBeingOpacity); mAlphaSlider->setValue(mOpacity); mOverlayDetailSlider->setValue(mOverlayDetail); mParticleDetailSlider->setValue(mParticleDetail); @@ -618,17 +573,11 @@ void Setup_Video::cancel() config.setValue("customcursor", mCustomCursorEnabled); config.setValue("particleeffects", mParticleEffectsEnabled); config.setValue("speech", static_cast<int>(mSpeechMode)); - config.setValue("alphaCache", mAlphaCache); - config.setValue("enableMapReduce", mEnableMapReduce); - config.setValue("adjustPerfomance", mAdjustPerfomance); - config.setValue("beingopacity", mBeingOpacity); config.setValue("guialpha", mOpacity); Image::setEnableAlpha(mOpacity != 1.0f); config.setValue("opengl", mOpenGLEnabled); - config.setValue("hwaccel", mHwAccelEnabled); config.setValue("showpickupchat", mPickupChatEnabled); config.setValue("showpickupparticle", mPickupParticleEnabled); - mAlphaCacheCheckBox->setEnabled(mOpenGLDropDown->getSelected() == 0); } void Setup_Video::action(const gcn::ActionEvent &event) @@ -761,12 +710,6 @@ void Setup_Video::action(const gcn::ActionEvent &event) mAltFpsSlider->setValue(mAltFps); mAltFpsSlider->setEnabled(mAltFps > 0); } - else if (id == "opengl") - { - bool isSoftware = (mOpenGLDropDown->getSelected() == 0); - mAlphaCacheCheckBox->setEnabled(isSoftware); - mEnableMapReduceCheckBox->setEnabled(isSoftware); - } } void Setup_Video::externalUpdated() diff --git a/src/gui/setup_video.h b/src/gui/setup_video.h index 9533877fb..509deb2fd 100644 --- a/src/gui/setup_video.h +++ b/src/gui/setup_video.h @@ -55,7 +55,6 @@ class Setup_Video : public SetupTab, public gcn::KeyListener private: bool mFullScreenEnabled; int mOpenGLEnabled; - bool mHwAccelEnabled; bool mCustomCursorEnabled; bool mParticleEffectsEnabled; bool mPickupChatEnabled; @@ -63,10 +62,6 @@ class Setup_Video : public SetupTab, public gcn::KeyListener float mOpacity; int mFps; int mAltFps; - bool mAlphaCache; - bool mEnableMapReduce; - bool mAdjustPerfomance; - bool mBeingOpacity; Being::Speech mSpeechMode; ModeListModel *mModeListModel; @@ -83,7 +78,6 @@ class Setup_Video : public SetupTab, public gcn::KeyListener gcn::ListBox *mModeList; gcn::CheckBox *mFsCheckBox; gcn::DropDown *mOpenGLDropDown; - gcn::CheckBox *mHwAccelCheckBox; gcn::CheckBox *mCustomCursorCheckBox; gcn::CheckBox *mParticleEffectsCheckBox; @@ -91,10 +85,6 @@ class Setup_Video : public SetupTab, public gcn::KeyListener gcn::CheckBox *mPickupChatCheckBox; gcn::CheckBox *mPickupParticleCheckBox; - gcn::CheckBox *mAlphaCacheCheckBox; - gcn::CheckBox *mEnableMapReduceCheckBox; - gcn::CheckBox *mAdjustPerfomanceCheckBox; - gcn::CheckBox *mBeingOpacityCheckBox; gcn::Slider *mSpeechSlider; gcn::Label *mSpeechLabel; gcn::Slider *mAlphaSlider; diff --git a/src/gui/shopwindow.cpp b/src/gui/shopwindow.cpp index 68ea57314..4311a04d2 100644 --- a/src/gui/shopwindow.cpp +++ b/src/gui/shopwindow.cpp @@ -803,3 +803,12 @@ int ShopWindow::sumAmount(Item *shopItem) } return sum; } + +bool ShopWindow::isShopEmpty() +{ + if (!mBuyShopItems || !mSellShopItems) + return true; + if (mBuyShopItems->empty() && mSellShopItems->empty()) + return true; + return false; +} diff --git a/src/gui/shopwindow.h b/src/gui/shopwindow.h index e07803225..e3fd9a5ca 100644 --- a/src/gui/shopwindow.h +++ b/src/gui/shopwindow.h @@ -133,6 +133,8 @@ class ShopWindow : public Window, public gcn::ActionListener, bool checkFloodCounter(int &counterTime); + bool isShopEmpty(); + private: void startTrade(); diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp index 5b47a5494..ff57195a9 100644 --- a/src/gui/skilldialog.cpp +++ b/src/gui/skilldialog.cpp @@ -22,7 +22,7 @@ #include "gui/skilldialog.h" -#include "log.h" +#include "logger.h" #include "playerinfo.h" #include "configuration.h" @@ -152,7 +152,9 @@ public: SkillListBox(SkillModel *model): ListBox(model), mModel(model), - mPopup(new TextPopup()) + mPopup(new TextPopup()), + mHighlightColor(Theme::getThemeColor(Theme::HIGHLIGHT)), + mTextColor(Theme::getThemeColor(Theme::TEXT)) { } @@ -187,8 +189,8 @@ public: Graphics *graphics = static_cast<Graphics*>(gcnGraphics); - graphics->setColor(Theme::getThemeColor(Theme::HIGHLIGHT, - static_cast<int>(mAlpha * 255.0f))); + mHighlightColor.a = static_cast<int>(mAlpha * 255.0f); + graphics->setColor(mHighlightColor); graphics->setFont(getFont()); // Draw filled rectangle around the selected list element @@ -199,7 +201,7 @@ public: } // Draw the list elements - graphics->setColor(Theme::getThemeColor(Theme::TEXT)); + graphics->setColor(mTextColor); for (int i = 0, y = 1; i < model->getNumberOfElements(); ++i, y += getRowHeight()) @@ -239,6 +241,8 @@ public: private: SkillModel *mModel; TextPopup *mPopup; + gcn::Color mHighlightColor; + gcn::Color mTextColor; }; class SkillTab : public Tab diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp index adcfe4d70..e3aa69b30 100644 --- a/src/gui/socialwindow.cpp +++ b/src/gui/socialwindow.cpp @@ -25,7 +25,7 @@ #include "guild.h" #include "keyboardconfig.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "map.h" #include "party.h" diff --git a/src/gui/specialswindow.cpp b/src/gui/specialswindow.cpp index 1c41752f3..a5d95c7ff 100644 --- a/src/gui/specialswindow.cpp +++ b/src/gui/specialswindow.cpp @@ -21,7 +21,7 @@ #include "gui/specialswindow.h" -#include "log.h" +#include "logger.h" #include "gui/setup.h" #include "gui/theme.h" diff --git a/src/gui/spellpopup.cpp b/src/gui/spellpopup.cpp index e867ec4e8..a918e037d 100644 --- a/src/gui/spellpopup.cpp +++ b/src/gui/spellpopup.cpp @@ -1,10 +1,11 @@ /* - * The Mana World + * The ManaPlus Client * Copyright (C) 2008 The Legend of Mazzeroth Development Team * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas + * Copyright (C) 2011 ManaPlus developers * - * This file is part of The Mana World. + * 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 @@ -26,6 +27,8 @@ #include "gui/gui.h" #include "gui/palette.h" +#include "gui/widgets/label.h" + #include "textcommand.h" #include "graphics.h" @@ -35,7 +38,6 @@ #include "utils/stringutils.h" #include <guichan/font.hpp> -#include <guichan/widgets/label.hpp> #include "debug.h" @@ -43,7 +45,7 @@ SpellPopup::SpellPopup(): Popup("SpellPopup") { // Item Name - mItemName = new gcn::Label; + mItemName = new Label; mItemName->setFont(boldFont); mItemName->setPosition(getPadding(), getPadding()); diff --git a/src/gui/spellpopup.h b/src/gui/spellpopup.h index 1b14e0e4c..69c47bf45 100644 --- a/src/gui/spellpopup.h +++ b/src/gui/spellpopup.h @@ -1,10 +1,11 @@ /* - * The Mana World + * The ManaPlus Client * Copyright (C) 2008 The Legend of Mazzeroth Development Team * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas + * Copyright (C) 2011 ManaPlus developers * - * This file is part of The Mana World. + * 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 diff --git a/src/gui/statuspopup.cpp b/src/gui/statuspopup.cpp index c4216013a..bb7a295ab 100644 --- a/src/gui/statuspopup.cpp +++ b/src/gui/statuspopup.cpp @@ -1,10 +1,11 @@ /* - * The Mana World + * The ManaPlus Client * Copyright (C) 2008 The Legend of Mazzeroth Development Team * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas + * Copyright (C) 2011 ManaPlus developers * - * This file is part of The Mana World. + * 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 @@ -27,6 +28,7 @@ #include "gui/palette.h" #include "gui/viewport.h" +#include "gui/widgets/label.h" #include "gui/widgets/layout.h" #include "gui/widgets/textbox.h" @@ -49,51 +51,51 @@ StatusPopup::StatusPopup(): const int fontHeight = getFont()->getHeight(); - mMoveType = new gcn::Label; + mMoveType = new Label; mMoveType->setPosition(getPadding(), getPadding()); - mCrazyMoveType = new gcn::Label; + mCrazyMoveType = new Label; mCrazyMoveType->setPosition(getPadding(), fontHeight + getPadding()); - mMoveToTargetType = new gcn::Label; + mMoveToTargetType = new Label; mMoveToTargetType->setPosition(getPadding(), 2 * fontHeight + getPadding()); - mFollowMode = new gcn::Label; + mFollowMode = new Label; mFollowMode->setPosition(getPadding(), 3 * fontHeight + getPadding()); - mAttackWeaponType = new gcn::Label; + mAttackWeaponType = new Label; mAttackWeaponType->setPosition(getPadding(), 4 + 4 * fontHeight + getPadding()); - mAttackType = new gcn::Label; + mAttackType = new Label; mAttackType->setPosition(getPadding(), 4 + 5 * fontHeight + getPadding()); - mMagicAttackType = new gcn::Label; + mMagicAttackType = new Label; mMagicAttackType->setPosition(getPadding(), 4 + 6 * fontHeight + getPadding()); - mDropCounter = new gcn::Label; + mDropCounter = new Label; mDropCounter->setPosition(getPadding(), 8 + 7 * fontHeight + getPadding()); - mPickUpType = new gcn::Label; + mPickUpType = new Label; mPickUpType->setPosition(getPadding(), 8 + 8 * fontHeight + getPadding()); - mMapType = new gcn::Label; + mMapType = new Label; mMapType->setPosition(getPadding(), 12 + 9 * fontHeight + getPadding()); - mImitationMode = new gcn::Label; + mImitationMode = new Label; mImitationMode->setPosition(getPadding(), 16 + 10 * fontHeight + getPadding()); - mAwayMode = new gcn::Label; + mAwayMode = new Label; mAwayMode->setPosition(getPadding(), 16 + 11 * fontHeight + getPadding()); - mCameraMode = new gcn::Label; + mCameraMode = new Label; mCameraMode->setPosition(getPadding(), 16 + 12 * fontHeight + getPadding()); - mDisableGameModifiers = new gcn::Label; + mDisableGameModifiers = new Label; mDisableGameModifiers->setPosition(getPadding(), 20 + 13 * fontHeight + getPadding()); diff --git a/src/gui/statuspopup.h b/src/gui/statuspopup.h index d633fb1f6..802b077a6 100644 --- a/src/gui/statuspopup.h +++ b/src/gui/statuspopup.h @@ -1,10 +1,11 @@ /* - * The Mana World + * The ManaPlus Client * Copyright (C) 2008 The Legend of Mazzeroth Development Team * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas + * Copyright (C) 2011 ManaPlus developers * - * This file is part of The Mana World. + * 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 diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp index b96720341..7ab2afa2d 100644 --- a/src/gui/statuswindow.cpp +++ b/src/gui/statuswindow.cpp @@ -22,6 +22,7 @@ #include "gui/statuswindow.h" +#include "chatwindow.h" #include "configuration.h" #include "event.h" #include "equipment.h" @@ -71,6 +72,14 @@ class AttrDisplay : public Container virtual Type getType() { return UNKNOWN; } + std::string getValue() + { + if (!mValue) + return "-"; + else + return mValue->getCaption(); + } + protected: AttrDisplay(int id, const std::string &name); @@ -228,6 +237,10 @@ StatusWindow::StatusWindow(): mCharacterPointsLabel = new Label("C"); place(0, 6, mCharacterPointsLabel, 5); + mCopyButton = new Button(_("Copy to chat"), "copy", this); + + place(0, 5, mCopyButton); + if (Net::getPlayerHandler()->canCorrectAttributes()) { mCorrectionPointsLabel = new Label("C"); @@ -343,7 +356,7 @@ void StatusWindow::event(Mana::Channels channel A_UNUSED, if (!lvl) { - // possible server broken and dont send job level, + // possible server broken and don't send job level, // then we fixing it :) if (exp.second < 20000) { @@ -359,7 +372,7 @@ void StatusWindow::event(Mana::Channels channel A_UNUSED, } if (exp.first < oldExp && exp.second >= 20000) - { // possible job level up. but server broken and dont send + { // possible job level up. but server broken and don't send // new job exp limit, we fixing it lvl ++; blocked = true; @@ -876,7 +889,6 @@ void StatusWindow::updateStatusBar(ProgressBar *bar, bool percent A_UNUSED) col.r = 100; col.g = 100; col.b = 100; -// bar->setColor(new gcn::Color(100, 100, 100)); bar->setColor(col); } else @@ -885,11 +897,31 @@ void StatusWindow::updateStatusBar(ProgressBar *bar, bool percent A_UNUSED) col.r = 255; col.g = 255; col.b = 0; -// bar->setColor(new gcn::Color(255, 255, 0)); bar->setColor(col); } } +void StatusWindow::action(const gcn::ActionEvent &event) +{ + if (!chatWindow) + return; + + if (event.getId() == "copy") + { + Attrs::iterator it = mAttrs.begin(); + Attrs::iterator it_end = mAttrs.end(); + std::string str; + while (it != it_end) + { + ChangeDisplay *attr = dynamic_cast<ChangeDisplay*>((*it).second); + if (attr) + str += attr->getValue() + " "; + ++ it; + } + chatWindow->addInputText(str); + } +} + AttrDisplay::AttrDisplay(int id, const std::string &name): mId(id), mName(name) diff --git a/src/gui/statuswindow.h b/src/gui/statuswindow.h index 74eb2c401..44d052004 100644 --- a/src/gui/statuswindow.h +++ b/src/gui/statuswindow.h @@ -48,7 +48,9 @@ class VertContainer; * * \ingroup Interface */ -class StatusWindow : public Window, public Mana::Listener +class StatusWindow : public Window, + public gcn::ActionListener, + public Mana::Listener { public: /** @@ -77,6 +79,8 @@ class StatusWindow : public Window, public Mana::Listener void updateProgressBar(ProgressBar *bar, int id, bool percent = true); + void action(const gcn::ActionEvent &event); + private: static std::string translateLetter(char* letters); @@ -97,6 +101,7 @@ class StatusWindow : public Window, public Mana::Listener gcn::Label *mCharacterPointsLabel; gcn::Label *mCorrectionPointsLabel; + gcn::Button *mCopyButton; typedef std::map<int, AttrDisplay*> Attrs; Attrs mAttrs; diff --git a/src/gui/textcommandeditor.cpp b/src/gui/textcommandeditor.cpp index b3a1440e1..8cf9fa398 100644 --- a/src/gui/textcommandeditor.cpp +++ b/src/gui/textcommandeditor.cpp @@ -1,9 +1,10 @@ /* - * The Mana World + * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas + * Copyright (C) 2011 ManaPlus developers * - * This file is part of The Mana World. + * 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 @@ -37,7 +38,7 @@ #include "gui/widgets/layout.h" #include "gui/widgets/layouthelper.h" #include "gui/widgets/radiobutton.h" -#include "gui/widgets/table.h" +#include "gui/widgets/guitable.h" #include "gui/widgets/textfield.h" #include "configuration.h" diff --git a/src/gui/textcommandeditor.h b/src/gui/textcommandeditor.h index cb88b8160..236c42320 100644 --- a/src/gui/textcommandeditor.h +++ b/src/gui/textcommandeditor.h @@ -1,9 +1,10 @@ /* - * The Mana World + * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas + * Copyright (C) 2011 ManaPlus developers * - * This file is part of The Mana World. + * 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 diff --git a/src/gui/textpopup.cpp b/src/gui/textpopup.cpp index 4114706a6..1ff601154 100644 --- a/src/gui/textpopup.cpp +++ b/src/gui/textpopup.cpp @@ -1,11 +1,11 @@ /* - * The Mana World + * The ManaPlus Client * Copyright (C) 2008 The Legend of Mazzeroth Development Team * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers * Copyright (C) 2011 The ManaPlus Developers * - * This file is part of The Mana World. + * 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 @@ -26,6 +26,9 @@ #include "gui/gui.h" #include "gui/palette.h" +#include "gui/theme.h" + +#include "gui/widgets/label.h" #include "graphics.h" #include "units.h" @@ -34,7 +37,6 @@ #include "utils/stringutils.h" #include <guichan/font.hpp> -#include <guichan/widgets/label.hpp> #include "debug.h" @@ -43,13 +45,13 @@ TextPopup::TextPopup(): { const int fontHeight = getFont()->getHeight(); - mText1 = new gcn::Label; + mText1 = new Label; mText1->setPosition(getPadding(), getPadding()); - mText2 = new gcn::Label; + mText2 = new Label; mText2->setPosition(getPadding(), fontHeight + 2 * getPadding()); - mText3 = new gcn::Label; + mText3 = new Label; mText3->setPosition(getPadding(), (2 * fontHeight) + 2 * getPadding()); add(mText1); diff --git a/src/gui/textpopup.h b/src/gui/textpopup.h index 898b53555..9ac041389 100644 --- a/src/gui/textpopup.h +++ b/src/gui/textpopup.h @@ -1,11 +1,11 @@ /* - * The Mana World + * The ManaPlus Client * Copyright (C) 2008 The Legend of Mazzeroth Development Team * Copyright (C) 2008-2009 The Mana World Development Team * Copyright (C) 2009-2010 The Mana Developers * Copyright (C) 2011 The ManaPlus Developers * - * This file is part of The Mana World. + * 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 diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp index 92613a3b3..15554044d 100644 --- a/src/gui/theme.cpp +++ b/src/gui/theme.cpp @@ -26,7 +26,7 @@ #include "client.h" #include "configuration.h" -#include "log.h" +#include "logger.h" #include "resources/dye.h" #include "resources/image.h" @@ -599,6 +599,7 @@ static int readColorType(const std::string &type) "TEXT", "SHADOW", "OUTLINE", + "BORDER", "PROGRESS_BAR", "BUTTON", "BUTTON_DISABLED", @@ -608,11 +609,15 @@ static int readColorType(const std::string &type) "GUILD_CHAT_TAB", "GUILD_SOCIAL_TAB", "BACKGROUND", + "BACKGROUND_GRAY", + "SCROLLBAR_GRAY", + "DROPDOWN_SHADOW", "HIGHLIGHT", "TAB_FLASH", "TAB_PLAYER_FLASH", "SHOP_WARNING", "ITEM_EQUIPPED", + "ITEM_NOT_EQUIPPED", "CHAT", "GM", "PLAYER", diff --git a/src/gui/theme.h b/src/gui/theme.h index 120214232..4e6a64a6f 100644 --- a/src/gui/theme.h +++ b/src/gui/theme.h @@ -143,6 +143,7 @@ class Theme : public Palette, public ConfigListener TEXT = 0, SHADOW, OUTLINE, + BORDER, PROGRESS_BAR, BUTTON, BUTTON_DISABLED, @@ -152,11 +153,15 @@ class Theme : public Palette, public ConfigListener GUILD_CHAT_TAB, GUILD_SOCIAL_TAB, BACKGROUND, + BACKGROUND_GRAY, + SCROLLBAR_GRAY, + DROPDOWN_SHADOW, HIGHLIGHT, TAB_FLASH, TAB_PLAYER_FLASH, SHOP_WARNING, ITEM_EQUIPPED, + ITEM_NOT_EQUIPPED, CHAT, GM, PLAYER, diff --git a/src/gui/tradewindow.cpp b/src/gui/tradewindow.cpp index c607636d9..d00fb61f4 100644 --- a/src/gui/tradewindow.cpp +++ b/src/gui/tradewindow.cpp @@ -246,8 +246,11 @@ void TradeWindow::receivedOk(bool own) } } -void TradeWindow::tradeItem(Item *item, int quantity) +void TradeWindow::tradeItem(Item *item, int quantity, bool check) { + if (check && !checkItem(item)) + return; + Net::getTradeHandler()->addItem(item, quantity); } @@ -325,15 +328,9 @@ void TradeWindow::action(const gcn::ActionEvent &event) if (mMyInventory->getFreeSlot() == -1) return; - if (mMyInventory->contains(item)) - { - if (localChatTab) - { - localChatTab->chatLog(_("Failed adding item. You can not " - "overlap one kind of item on the window."), BY_SERVER); - } + + if (!checkItem(item)) return; - } // Choose amount of items to trade ItemAmountWindow::showWindow(ItemAmountWindow::TradeAdd, this, item); @@ -442,3 +439,21 @@ void TradeWindow::initTrade(std::string nick) if (!player_relations.isGoodName(nick)) setCaptionFont(gui->getSecureFont()); } + +bool TradeWindow::checkItem(Item *item) +{ + Item *tradeItem = mMyInventory->findItem( + item->getId(), item->getColor()); + + if (tradeItem && (tradeItem->getQuantity() > 1 + || item->getQuantity() > 1)) + { + if (localChatTab) + { + localChatTab->chatLog(_("Failed adding item. You can not " + "overlap one kind of item on the window."), BY_SERVER); + } + return false; + } + return true; +} diff --git a/src/gui/tradewindow.h b/src/gui/tradewindow.h index 3c5ed56b0..16b3d9d6f 100644 --- a/src/gui/tradewindow.h +++ b/src/gui/tradewindow.h @@ -95,7 +95,7 @@ class TradeWindow : public Window, gcn::ActionListener, gcn::SelectionListener /** * Send trade packet. */ - void tradeItem(Item *item, int quantity); + void tradeItem(Item *item, int quantity, bool check = false); /** * Updates the labels and makes sure only one item is selected in @@ -131,6 +131,8 @@ class TradeWindow : public Window, gcn::ActionListener, gcn::SelectionListener std::string getAutoTradeNick() { return mAutoAddToNick; } + bool checkItem(Item *item); + private: enum Status { diff --git a/src/gui/unregisterdialog.cpp b/src/gui/unregisterdialog.cpp index 8f845e746..568e0613e 100644 --- a/src/gui/unregisterdialog.cpp +++ b/src/gui/unregisterdialog.cpp @@ -23,7 +23,7 @@ #include "gui/unregisterdialog.h" #include "client.h" -#include "log.h" +#include "logger.h" #include "gui/okdialog.h" #include "gui/register.h" diff --git a/src/gui/updatewindow.cpp b/src/gui/updaterwindow.cpp index eb5471e2a..7534b12a9 100644 --- a/src/gui/updatewindow.cpp +++ b/src/gui/updaterwindow.cpp @@ -20,11 +20,11 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "gui/updatewindow.h" +#include "gui/updaterwindow.h" #include "client.h" #include "configuration.h" -#include "log.h" +#include "logger.h" #include "main.h" #include "gui/sdlinput.h" diff --git a/src/gui/updatewindow.h b/src/gui/updaterwindow.h index a1dc556d5..a1dc556d5 100644 --- a/src/gui/updatewindow.h +++ b/src/gui/updaterwindow.h diff --git a/src/gui/userpalette.cpp b/src/gui/userpalette.cpp index 40dddc4f1..eac9559ef 100644 --- a/src/gui/userpalette.cpp +++ b/src/gui/userpalette.cpp @@ -25,7 +25,7 @@ #include "configuration.h" #include "client.h" -#include "log.h" +#include "logger.h" #include "gui/gui.h" diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index ba8414699..a5b541a8e 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -36,7 +36,7 @@ #include "gui/beingpopup.h" #include "gui/chatwindow.h" #include "gui/gui.h" -#include "gui/ministatus.h" +#include "gui/ministatuswindow.h" #include "gui/popupmenu.h" #include "gui/statuspopup.h" #include "gui/textpopup.h" @@ -145,8 +145,10 @@ void Viewport::draw(gcn::Graphics *gcnGraphics) if (mScrollLaziness < 1) mScrollLaziness = 1; // Avoids division by zero + int cnt = 0; + // Apply lazy scrolling - while (lastTick < tick_time) + while (lastTick < tick_time && cnt < 32) { if (player_x > static_cast<int>(mPixelViewX) + mScrollRadius) { @@ -172,19 +174,26 @@ void Viewport::draw(gcn::Graphics *gcnGraphics) - static_cast<int>(mPixelViewY) + mScrollRadius) / static_cast<float>(mScrollLaziness); } - lastTick++; + lastTick ++; + cnt ++; } // Auto center when player is off screen - if (player_x - static_cast<int>(mPixelViewX) > graphics->mWidth / 2 - || static_cast<int>(mPixelViewX) - player_x > graphics->mWidth / 2 - || static_cast<int>(mPixelViewY) - player_y - > graphics->getHeight() / 2 - || player_y - static_cast<int>(mPixelViewY) - > graphics->getHeight() / 2) + if (cnt > 30 || player_x - static_cast<int>(mPixelViewX) + > graphics->mWidth / 2 || static_cast<int>(mPixelViewX) + - player_x > graphics->mWidth / 2 || static_cast<int>(mPixelViewY) + - player_y > graphics->getHeight() / 2 || player_y + - static_cast<int>(mPixelViewY) > graphics->getHeight() / 2) { mPixelViewX = static_cast<float>(player_x); mPixelViewY = static_cast<float>(player_y); + if (player_x <= 0 || player_y <= 0) + { + if (debugChatTab) + debugChatTab->chatLog("incorrect player position!"); + logger->log("incorrect player position: %d, %d", + player_x, player_y); + } }; // Don't move camera so that the end of the map is on screen @@ -684,7 +693,8 @@ void Viewport::mouseMoved(gcn::MouseEvent &event A_UNUSED) const int y = getMouseY() + static_cast<int>(mPixelViewY); mHoverBeing = actorSpriteManager->findBeingByPixel(x, y, true); - if (mHoverBeing && mHoverBeing->getType() == Being::PLAYER) + if (mHoverBeing && (mHoverBeing->getType() == Being::PLAYER + || mHoverBeing->getType() == Being::NPC)) { mTextPopup->setVisible(false); if (mShowBeingPopup) diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp index 9c1a71478..99da53c66 100644 --- a/src/gui/whoisonline.cpp +++ b/src/gui/whoisonline.cpp @@ -1,9 +1,10 @@ /* - * The Mana World + * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas + * Copyright (C) 2011 ManaPlus developers * - * This file is part of The Mana World. + * 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 diff --git a/src/gui/whoisonline.h b/src/gui/whoisonline.h index 644121d08..72063b183 100644 --- a/src/gui/whoisonline.h +++ b/src/gui/whoisonline.h @@ -1,9 +1,10 @@ /* - * The Mana World + * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas + * Copyright (C) 2011 ManaPlus developers * - * This file is part of The Mana World. + * 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 diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index 748e038e2..d4764cba5 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -66,6 +66,9 @@ AvatarListBox::AvatarListBox(AvatarListModel *model): config.addListener("showgender", this); config.addListener("showlevel", this); + + mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT); + setForegroundColor(Theme::getThemeColor(Theme::TEXT)); } AvatarListBox::~AvatarListBox() @@ -102,8 +105,8 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics) Graphics *graphics = static_cast<Graphics*>(gcnGraphics); - graphics->setColor(Theme::getThemeColor(Theme::HIGHLIGHT, - static_cast<int>(mAlpha * 255.0f))); + mHighlightColor.a = static_cast<int>(mAlpha * 255.0f); + graphics->setColor(mHighlightColor); graphics->setFont(getFont()); const int fontHeight = getFont()->getHeight(); @@ -113,7 +116,7 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics) const std::string name = player_node->getName(); // Draw the list elements - graphics->setColor(Theme::getThemeColor(Theme::TEXT)); + graphics->setColor(getForegroundColor()); for (int i = 0, y = 0; i < model->getNumberOfElements(); ++i, y += fontHeight) @@ -206,7 +209,7 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics) if (a->getLevel() > 1) { - graphics->setColor(Theme::getThemeColor(Theme::TEXT)); + graphics->setColor(getForegroundColor()); int minHp = 40 + ((a->getLevel() - 1) * 5); if (minHp < 0) minHp = 40; @@ -242,28 +245,48 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics) } } - if (mShowGender) + if (graphics->getSecure()) { - switch (a->getGender()) + if (mShowGender) { - case GENDER_FEMALE: - text += strprintf(" \u2640 %s", - a->getAdditionString().c_str()); - break; - case GENDER_MALE: - text += strprintf(" \u2642 %s", - a->getAdditionString().c_str()); - break; - default: - break; + switch (a->getGender()) + { + case GENDER_FEMALE: + text += strprintf(" \u2640 "); + break; + case GENDER_MALE: + text += strprintf(" \u2642 "); + break; + default: + break; + } } } else { - text += a->getAdditionString(); + if (mShowGender) + { + switch (a->getGender()) + { + case GENDER_FEMALE: + text += strprintf(" \u2640 %s", + a->getAdditionString().c_str()); + break; + case GENDER_MALE: + text += strprintf(" \u2642 %s", + a->getAdditionString().c_str()); + break; + default: + break; + } + } + else + { + text += a->getAdditionString(); + } } - graphics->setColor(Theme::getThemeColor(Theme::TEXT)); + graphics->setColor(getForegroundColor()); // Draw Name if (a->getType() == MapItem::SEPARATOR) @@ -366,8 +389,10 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event) { if (ava->getType() == AVATAR_PLAYER && chatWindow) { - chatWindow->addWhisperTab(model->getAvatarAt(selected) - ->getName(), true); + ChatTab *tab = chatWindow->addWhisperTab( + model->getAvatarAt(selected)->getName(), true); + if (chatWindow && tab) + chatWindow->saveState(); } } } diff --git a/src/gui/widgets/avatarlistbox.h b/src/gui/widgets/avatarlistbox.h index 2fe1dfe3d..afb4abdf5 100644 --- a/src/gui/widgets/avatarlistbox.h +++ b/src/gui/widgets/avatarlistbox.h @@ -62,6 +62,7 @@ public: private: bool mShowGender; bool mShowLevel; + gcn::Color mHighlightColor; static int instances; static Image *onlineIcon; diff --git a/src/gui/widgets/battletab.cpp b/src/gui/widgets/battletab.cpp index e72c78ee0..c5500e801 100644 --- a/src/gui/widgets/battletab.cpp +++ b/src/gui/widgets/battletab.cpp @@ -22,10 +22,10 @@ #include "gui/widgets/battletab.h" -#include "chatlog.h" +#include "chatlogger.h" #include "commandhandler.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "main.h" #include "gui/theme.h" diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index 140a72770..bb83c1159 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -25,7 +25,7 @@ #include "client.h" #include "graphics.h" -#include "log.h" +#include "logger.h" #include "utils/stringutils.h" @@ -64,6 +64,10 @@ BrowserBox::BrowserBox(unsigned int mode, bool opaque): { setFocusable(true); addMouseListener(this); + + mBackgroundColor = Theme::getThemeColor(Theme::BACKGROUND); + mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT); + mHyperLinkColor = Theme::getThemeColor(Theme::HYPERLINK); } BrowserBox::~BrowserBox() @@ -310,7 +314,7 @@ void BrowserBox::draw(gcn::Graphics *graphics) if (mOpaque) { - graphics->setColor(Theme::getThemeColor(Theme::BACKGROUND)); + graphics->setColor(mBackgroundColor); graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight())); } @@ -319,7 +323,7 @@ void BrowserBox::draw(gcn::Graphics *graphics) { if ((mHighMode & BACKGROUND)) { - graphics->setColor(Theme::getThemeColor(Theme::HIGHLIGHT)); + graphics->setColor(mHighlightColor); graphics->fillRectangle(gcn::Rectangle( mLinks[mSelectedLink].x1, mLinks[mSelectedLink].y1, @@ -330,7 +334,7 @@ void BrowserBox::draw(gcn::Graphics *graphics) if ((mHighMode & UNDERLINE)) { - graphics->setColor(Theme::getThemeColor(Theme::HYPERLINK)); + graphics->setColor(mHyperLinkColor); graphics->drawLine( mLinks[mSelectedLink].x1, mLinks[mSelectedLink].y2, diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h index 6fdb40042..9969bfd3b 100644 --- a/src/gui/widgets/browserbox.h +++ b/src/gui/widgets/browserbox.h @@ -225,6 +225,10 @@ class BrowserBox : public gcn::Widget, bool mAlwaysUpdate; bool mProcessVersion; bool mEnableImages; + + gcn::Color mBackgroundColor; + gcn::Color mHighlightColor; + gcn::Color mHyperLinkColor; }; #endif diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index 0570630c3..7c46ae9df 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -26,7 +26,7 @@ #include "configuration.h" #include "graphics.h" #include "graphicsvertexes.h" -#include "log.h" +#include "logger.h" #include "gui/palette.h" #include "gui/theme.h" @@ -135,6 +135,9 @@ void Button::init() } updateAlpha(); } + mEnabledColor = Theme::getThemeColor(Theme::BUTTON); + mDisabledColor = Theme::getThemeColor(Theme::BUTTON_DISABLED); + mInstances++; } @@ -202,7 +205,7 @@ void Button::draw(gcn::Graphics *graphics) } else { - // because we dont know where parent windows was moved, + // because we don't know where parent windows was moved, // need recalc vertexes gcn::ClipRectangle &rect = static_cast<Graphics*>( graphics)->getTopClip(); @@ -238,9 +241,9 @@ void Button::draw(gcn::Graphics *graphics) // drawImageRect(0, 0, getWidth(), getHeight(), button[mode]); if (mode == BUTTON_DISABLED) - graphics->setColor(Theme::getThemeColor(Theme::BUTTON_DISABLED)); + graphics->setColor(mDisabledColor); else - graphics->setColor(Theme::getThemeColor(Theme::BUTTON)); + graphics->setColor(mEnabledColor); int textX; int textY = getHeight() / 2 - getFont()->getHeight() / 2; diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h index 8c43b6ddd..1b62179b3 100644 --- a/src/gui/widgets/button.h +++ b/src/gui/widgets/button.h @@ -101,6 +101,8 @@ class Button : public gcn::Button, public gcn::WidgetListener int mMode; int mXOffset; int mYOffset; + gcn::Color mEnabledColor; + gcn::Color mDisabledColor; }; #endif diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index 42a39a20f..81c0d277f 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -23,11 +23,11 @@ #include "gui/widgets/chattab.h" #include "actorspritemanager.h" -#include "chatlog.h" +#include "chatlogger.h" #include "commandhandler.h" #include "configuration.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "sound.h" #include "gui/widgets/browserbox.h" @@ -249,12 +249,13 @@ void ChatTab::chatLog(std::string line, Own own, // We look if the Vertical Scroll Bar is set at the max before // adding a row, otherwise the max will always be a row higher // at comparison. - if (mScrollArea->getVerticalScrollAmount() >= + if (mScrollArea->getVerticalScrollAmount() + 2 >= mScrollArea->getVerticalMaxScroll()) { addRow(line); mScrollArea->setVerticalScrollAmount( mScrollArea->getVerticalMaxScroll()); + } else { @@ -282,9 +283,7 @@ void ChatTab::chatLog(std::string line, Own own, { if (player_node) { - std::string::size_type pos - = tmp.text.find(player_node->getName()); - if (pos != std::string::npos) + if (chatWindow && chatWindow->findHighlight(tmp.text)) setFlash(2); else setFlash(1); diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp index 61e5d9118..65d26e196 100644 --- a/src/gui/widgets/checkbox.cpp +++ b/src/gui/widgets/checkbox.cpp @@ -86,6 +86,8 @@ CheckBox::CheckBox(const std::string &caption, bool selected, if (listener) addActionListener(listener); + + setForegroundColor(Theme::getThemeColor(Theme::TEXT)); } CheckBox::~CheckBox() @@ -114,7 +116,7 @@ void CheckBox::draw(gcn::Graphics* graphics) drawBox(graphics); graphics->setFont(getFont()); - graphics->setColor(Theme::getThemeColor(Theme::TEXT)); + graphics->setColor(getForegroundColor()); const int h = getHeight() + getHeight() / 2; diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp index 3ade3b37f..46240f76d 100644 --- a/src/gui/widgets/desktop.cpp +++ b/src/gui/widgets/desktop.cpp @@ -22,7 +22,7 @@ #include "configuration.h" #include "graphics.h" -#include "log.h" +#include "logger.h" #include "main.h" #include "gui/palette.h" @@ -53,8 +53,12 @@ Desktop::Desktop() : mVersionLabel = new Label(strprintf("%s (Mana %s)", appName.c_str(), FULL_VERSION)); - mVersionLabel->setBackgroundColor(gcn::Color(255, 255, 255, 128)); + mVersionLabel->setBackgroundColor( + Theme::getThemeColor(Theme::BACKGROUND, 128)); add(mVersionLabel, 25, 2); + + mBackgroundColor = Theme::getThemeColor(Theme::BACKGROUND, 128); + mBackgroundGrayColor = Theme::getThemeColor(Theme::BACKGROUND_GRAY); } Desktop::~Desktop() @@ -84,8 +88,7 @@ void Desktop::draw(gcn::Graphics *graphics) if (!mWallpaper || (getWidth() > mWallpaper->getWidth() || getHeight() > mWallpaper->getHeight())) { - // TODO: Color from palette - g->setColor(gcn::Color(64, 64, 64)); + g->setColor(mBackgroundGrayColor); g->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight())); } @@ -106,7 +109,7 @@ void Desktop::draw(gcn::Graphics *graphics) } // Draw a thin border under the application version... - g->setColor(gcn::Color(255, 255, 255, 128)); + g->setColor(mBackgroundColor); g->fillRectangle(gcn::Rectangle(mVersionLabel->getDimension())); Container::draw(graphics); diff --git a/src/gui/widgets/desktop.h b/src/gui/widgets/desktop.h index 962cc3c01..6364ecfe9 100644 --- a/src/gui/widgets/desktop.h +++ b/src/gui/widgets/desktop.h @@ -68,6 +68,8 @@ class Desktop : public Container, gcn::WidgetListener Image *mWallpaper; gcn::Label *mVersionLabel; + gcn::Color mBackgroundColor; + gcn::Color mBackgroundGrayColor; }; #endif // DESKTOP_H diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 681d7736e..f01d3fb55 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -101,6 +101,10 @@ DropDown::DropDown(gcn::ListModel *listModel): } instances++; + + mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT); + mShadowColor = Theme::getThemeColor(Theme::DROPDOWN_SHADOW); + setForegroundColor(Theme::getThemeColor(Theme::TEXT)); } DropDown::~DropDown() @@ -163,25 +167,20 @@ void DropDown::draw(gcn::Graphics* graphics) updateAlpha(); const int alpha = static_cast<int>(mAlpha * 255.0f); - gcn::Color faceColor = getBaseColor(); - faceColor.a = alpha; - const gcn::Color *highlightColor = &Theme::getThemeColor(Theme::HIGHLIGHT, - alpha); - gcn::Color shadowColor = faceColor - 0x303030; - shadowColor.a = alpha; + mHighlightColor.a = alpha; + mShadowColor.a = alpha; if (mListBox->getListModel() && mListBox->getSelected() >= 0) { graphics->setFont(getFont()); - graphics->setColor(Theme::getThemeColor(Theme::TEXT)); + graphics->setColor(getForegroundColor()); graphics->drawText(mListBox->getListModel()->getElementAt( mListBox->getSelected()), 1, 0); } if (isFocused()) { - if (highlightColor) - graphics->setColor(*highlightColor); + graphics->setColor(mHighlightColor); graphics->drawRectangle(gcn::Rectangle(0, 0, getWidth() - h, h)); } @@ -193,10 +192,9 @@ void DropDown::draw(gcn::Graphics* graphics) // Draw two lines separating the ListBox with selected // element view. - if (highlightColor) - graphics->setColor(*highlightColor); + graphics->setColor(mHighlightColor); graphics->drawLine(0, h, getWidth(), h); - graphics->setColor(shadowColor); + graphics->setColor(mShadowColor); graphics->drawLine(0, h + 1, getWidth(), h + 1); } } diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index d85c3166c..6a22ba497 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -87,6 +87,9 @@ class DropDown : public gcn::DropDown */ void drawButton(gcn::Graphics *graphics); + gcn::Color mShadowColor; + gcn::Color mHighlightColor; + // Add own Images. static int instances; static Image *buttons[2][2]; diff --git a/src/gui/widgets/dropshortcutcontainer.cpp b/src/gui/widgets/dropshortcutcontainer.cpp index 257f4837c..b628cf2d4 100644 --- a/src/gui/widgets/dropshortcutcontainer.cpp +++ b/src/gui/widgets/dropshortcutcontainer.cpp @@ -1,9 +1,10 @@ /* - * The Mana World + * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas + * Copyright (C) 2011 ManaPlus developers * - * This file is part of The Mana World. + * 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 @@ -72,6 +73,8 @@ DropShortcutContainer::DropShortcutContainer(): mBoxHeight = 1; mBoxWidth = 1; } + mEquipedColor = Theme::getThemeColor(Theme::ITEM_EQUIPPED); + mUnEquipedColor = Theme::getThemeColor(Theme::ITEM_NOT_EQUIPPED); } DropShortcutContainer::~DropShortcutContainer() @@ -109,12 +112,6 @@ void DropShortcutContainer::draw(gcn::Graphics *graphics) if (mBackgroundImg) g->drawImage(mBackgroundImg, itemX, itemY); -/* // Draw item keyboard shortcut. - const char *key = SDL_GetKeyName( - (SDLKey) keyboard.getKeyValue(keyboard.KEY_SHORTCUT_1 + i)); - graphics->setColor(guiPalette->getColor(Palette::TEXT)); - g->drawText(key, itemX + 2, itemY + 2, gcn::Graphics::LEFT); -*/ if (dropShortcut->getItem(i) < 0) continue; @@ -141,11 +138,11 @@ void DropShortcutContainer::draw(gcn::Graphics *graphics) image->setAlpha(1.0f); g->drawImage(image, itemX, itemY); if (item->isEquipped()) - g->setColor(Theme::getThemeColor(Theme::ITEM_EQUIPPED)); + g->setColor(mEquipedColor); else - g->setColor(Theme::getThemeColor(Theme::TEXT)); + g->setColor(mUnEquipedColor); g->drawText(caption, itemX + mBoxWidth / 2, - itemY + mBoxHeight - 14, gcn::Graphics::CENTER); + itemY + mBoxHeight - 14, gcn::Graphics::CENTER); } } } diff --git a/src/gui/widgets/dropshortcutcontainer.h b/src/gui/widgets/dropshortcutcontainer.h index 77de914ea..b2d63a7dd 100644 --- a/src/gui/widgets/dropshortcutcontainer.h +++ b/src/gui/widgets/dropshortcutcontainer.h @@ -1,9 +1,10 @@ /* - * The Mana World + * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas + * Copyright (C) 2011 ManaPlus developers * - * This file is part of The Mana World. + * 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 @@ -83,6 +84,8 @@ class DropShortcutContainer : public ShortcutContainer Item *mItemMoved; ItemPopup *mItemPopup; + gcn::Color mEquipedColor; + gcn::Color mUnEquipedColor; }; #endif diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp index bb5af4b1c..5aced193f 100644 --- a/src/gui/widgets/emoteshortcutcontainer.cpp +++ b/src/gui/widgets/emoteshortcutcontainer.cpp @@ -29,7 +29,7 @@ #include "itemshortcut.h" #include "keyboardconfig.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "gui/palette.h" #include "gui/textpopup.h" @@ -80,6 +80,7 @@ EmoteShortcutContainer::EmoteShortcutContainer(): mBoxHeight = 1; mBoxWidth = 1; } + setForegroundColor(Theme::getThemeColor(Theme::TEXT)); } EmoteShortcutContainer::~EmoteShortcutContainer() @@ -118,20 +119,9 @@ void EmoteShortcutContainer::draw(gcn::Graphics *graphics) std::string key = keyboard.getKeyValueString( keyboard.KEY_EMOTE_1 + i); - graphics->setColor(Theme::getThemeColor(Theme::TEXT)); + graphics->setColor(getForegroundColor()); g->drawText(key, emoteX + 2, emoteY + 2, gcn::Graphics::LEFT); -/* - if (emoteShortcut->getEmote(i) - && static_cast<unsigned>(emoteShortcut->getEmote(i)) - 1 - < mEmoteImg.size() - && mEmoteImg[emoteShortcut->getEmote(i) - 1]) - { - mEmoteImg[emoteShortcut->getEmote(i) - 1]->draw(g, emoteX + 2, - emoteY + 10); - } -*/ - if (i < mEmoteImg.size() && mEmoteImg[i] && mEmoteImg[i]->sprite) mEmoteImg[i]->sprite->draw(g, emoteX + 2, emoteY + 10); } diff --git a/src/gui/widgets/table.cpp b/src/gui/widgets/guitable.cpp index 04ae41ad7..e02eda88c 100644 --- a/src/gui/widgets/table.cpp +++ b/src/gui/widgets/guitable.cpp @@ -20,7 +20,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "gui/widgets/table.h" +#include "gui/widgets/guitable.h" #include "client.h" #include "configuration.h" @@ -88,17 +88,17 @@ void GuiTableActionListener::action(const gcn::ActionEvent } -GuiTable::GuiTable(TableModel *initial_model, gcn::Color background, - bool opacity) : +GuiTable::GuiTable(TableModel *initial_model, bool opacity) : mLinewiseMode(false), mWrappingEnabled(false), mOpaque(opacity), - mBackgroundColor(background), mModel(NULL), mSelectedRow(0), mSelectedColumn(0), mTopWidget(NULL) { + mBackgroundColor = Theme::getThemeColor(Theme::BACKGROUND); + mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT); setModel(initial_model); setFocusable(true); @@ -292,8 +292,8 @@ void GuiTable::draw(gcn::Graphics* graphics) if (mOpaque) { - graphics->setColor(Theme::getThemeColor(Theme::BACKGROUND, - static_cast<int>(mAlpha * 255.0f))); + mBackgroundColor.a = static_cast<int>(mAlpha * 255.0f); + graphics->setColor(mBackgroundColor); graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight())); } @@ -304,7 +304,7 @@ void GuiTable::draw(gcn::Graphics* graphics) first_row = 0; unsigned rows_nr = 1 + (getHeight() / getRowHeight()); // May overestimate - // by one. + // by one. unsigned max_rows_nr; if (mModel->getRows() < first_row) @@ -343,8 +343,8 @@ void GuiTable::draw(gcn::Graphics* graphics) widget->setDimension(bounds); - graphics->setColor(Theme::getThemeColor(Theme::HIGHLIGHT, - static_cast<int>(mAlpha * 255.0f))); + mHighlightColor.a = static_cast<int>(mAlpha * 255.0f); + graphics->setColor(mHighlightColor); if (mSelectedRow > 0) { diff --git a/src/gui/widgets/table.h b/src/gui/widgets/guitable.h index c4fab6a0d..d248c4820 100644 --- a/src/gui/widgets/table.h +++ b/src/gui/widgets/guitable.h @@ -58,7 +58,6 @@ class GuiTable : public gcn::Widget, public: GuiTable(TableModel * initial_model = NULL, - gcn::Color background = 0xffffff, bool opacity = true); virtual ~GuiTable(); @@ -190,6 +189,8 @@ private: /** Vector for compactness; used as a list in practice. */ std::vector<GuiTableActionListener *> mActionListeners; + + gcn::Color mHighlightColor; }; diff --git a/src/gui/widgets/horizontcontainer.h b/src/gui/widgets/horizontcontainer.h index 4a959190e..80014c171 100644 --- a/src/gui/widgets/horizontcontainer.h +++ b/src/gui/widgets/horizontcontainer.h @@ -41,8 +41,11 @@ class HorizontContainer : public Container, public gcn::WidgetListener { public: HorizontContainer(int height, int spacing); + virtual void add(gcn::Widget *widget); + virtual void clear(); + void widgetResized(const gcn::Event &event); protected: diff --git a/src/gui/widgets/inventoryfilter.cpp b/src/gui/widgets/inventoryfilter.cpp index a220fdb98..795f0d31e 100644 --- a/src/gui/widgets/inventoryfilter.cpp +++ b/src/gui/widgets/inventoryfilter.cpp @@ -1,8 +1,8 @@ /* - * The Mana Client + * The ManaPlus Client * Copyright (C) 2011 The ManaPlus Developers * - * This file is part of The Mana Client. + * 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 @@ -23,7 +23,7 @@ #include "gui/widgets/horizontcontainer.h" #include "gui/widgets/radiobutton.h" -#include "log.h" +#include "logger.h" #include "debug.h" diff --git a/src/gui/widgets/inventoryfilter.h b/src/gui/widgets/inventoryfilter.h index da7b7af1e..be69489a8 100644 --- a/src/gui/widgets/inventoryfilter.h +++ b/src/gui/widgets/inventoryfilter.h @@ -1,9 +1,9 @@ /* - * The Mana Client + * The ManaPlus Client * Copyright (C) 2009-2010 The Mana Developers * Copyright (C) 2011 The ManaPlus Developers * - * This file is part of The Mana Client. + * 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 diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 7818432f8..91b674018 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -27,7 +27,7 @@ #include "item.h" #include "itemshortcut.h" #include "dropshortcut.h" -#include "log.h" +#include "logger.h" #include "gui/chatwindow.h" #include "gui/itempopup.h" @@ -118,6 +118,9 @@ ItemContainer::ItemContainer(Inventory *inventory, bool forceQuantity): if (!mSelImg) logger->log1("Error: Unable to load selection.png"); + mEquipedColor = Theme::getThemeColor(Theme::ITEM_EQUIPPED); + mUnEquipedColor = Theme::getThemeColor(Theme::ITEM_NOT_EQUIPPED); + addKeyListener(this); addMouseListener(this); addWidgetListener(this); @@ -204,15 +207,16 @@ void ItemContainer::draw(gcn::Graphics *graphics) caption = "Eq."; if (item->isEquipped()) - g->setColor(Theme::getThemeColor(Theme::ITEM_EQUIPPED)); + g->setColor(mEquipedColor); else - g->setColor(gcn::Color(0, 0, 0)); + g->setColor(mUnEquipedColor); g->drawText(caption, itemX + BOX_WIDTH / 2, itemY + BOX_HEIGHT - 14, gcn::Graphics::CENTER); } } +/* // Draw an orange box around the selected item if (isFocused() && mHighlightedIndex != -1 && mGridColumns) { @@ -221,6 +225,7 @@ void ItemContainer::draw(gcn::Graphics *graphics) g->setColor(gcn::Color(255, 128, 0)); g->drawRectangle(gcn::Rectangle(itemX, itemY, BOX_WIDTH, BOX_HEIGHT)); } +*/ } void ItemContainer::selectNone() diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h index 5fd897a29..df7de63ee 100644 --- a/src/gui/widgets/itemcontainer.h +++ b/src/gui/widgets/itemcontainer.h @@ -202,6 +202,8 @@ class ItemContainer : public gcn::Widget, typedef SelectionListenerList::iterator SelectionListenerIterator; SelectionListenerList mSelectionListeners; + gcn::Color mEquipedColor; + gcn::Color mUnEquipedColor; }; #endif diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp index 328d5ae4d..79685fe45 100644 --- a/src/gui/widgets/itemshortcutcontainer.cpp +++ b/src/gui/widgets/itemshortcutcontainer.cpp @@ -77,6 +77,9 @@ ItemShortcutContainer::ItemShortcutContainer(unsigned number): mBoxHeight = 1; mBoxWidth = 1; } + setForegroundColor(Theme::getThemeColor(Theme::TEXT)); + mEquipedColor = Theme::getThemeColor(Theme::ITEM_EQUIPPED); + mUnEquipedColor = Theme::getThemeColor(Theme::ITEM_NOT_EQUIPPED); } ItemShortcutContainer::~ItemShortcutContainer() @@ -119,7 +122,7 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics) // Draw item keyboard shortcut. std::string key = keyboard.getKeyValueString( keyboard.KEY_SHORTCUT_1 + i); - graphics->setColor(Theme::getThemeColor(Theme::TEXT)); + graphics->setColor(getForegroundColor()); g->drawText(key, itemX + 2, itemY + 2, gcn::Graphics::LEFT); @@ -154,14 +157,9 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics) image->setAlpha(1.0f); g->drawImage(image, itemX, itemY); if (item->isEquipped()) - { - g->setColor(Theme::getThemeColor( - Theme::ITEM_EQUIPPED)); - } + g->setColor(mEquipedColor); else - { - graphics->setColor(Theme::getThemeColor(Theme::TEXT)); - } + g->setColor(mUnEquipedColor); g->drawText(caption, itemX + mBoxWidth / 2, itemY + mBoxHeight - 14, gcn::Graphics::CENTER); } diff --git a/src/gui/widgets/itemshortcutcontainer.h b/src/gui/widgets/itemshortcutcontainer.h index 7eac431ec..e6b32c6f8 100644 --- a/src/gui/widgets/itemshortcutcontainer.h +++ b/src/gui/widgets/itemshortcutcontainer.h @@ -88,7 +88,8 @@ class ItemShortcutContainer : public ShortcutContainer ItemPopup *mItemPopup; SpellPopup *mSpellPopup; + gcn::Color mEquipedColor; + gcn::Color mUnEquipedColor; }; -//extern SpellManager *spellManager; #endif diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp index 16b813dd5..67e8bd12b 100644 --- a/src/gui/widgets/label.cpp +++ b/src/gui/widgets/label.cpp @@ -26,6 +26,7 @@ Label::Label() { + setForegroundColor(Theme::getThemeColor(Theme::TEXT)); } Label::Label(const std::string &caption) : diff --git a/src/gui/widgets/layout.cpp b/src/gui/widgets/layout.cpp index 274c17d61..382d169dc 100644 --- a/src/gui/widgets/layout.cpp +++ b/src/gui/widgets/layout.cpp @@ -22,7 +22,7 @@ #include "gui/widgets/layout.h" -#include "log.h" +#include "logger.h" #include <cassert> diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index de8707406..53299ca46 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -41,6 +41,8 @@ float ListBox::mAlpha = 1.0; ListBox::ListBox(gcn::ListModel *listModel): gcn::ListBox(listModel) { + mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT); + setForegroundColor(Theme::getThemeColor(Theme::TEXT)); } ListBox::~ListBox() @@ -63,8 +65,8 @@ void ListBox::draw(gcn::Graphics *graphics) updateAlpha(); - graphics->setColor(Theme::getThemeColor(Theme::HIGHLIGHT, - static_cast<int>(mAlpha * 255.0f))); + mHighlightColor.a = static_cast<int>(mAlpha * 255.0f); + graphics->setColor(mHighlightColor); graphics->setFont(getFont()); const int height = getRowHeight(); @@ -77,7 +79,7 @@ void ListBox::draw(gcn::Graphics *graphics) } // Draw the list elements - graphics->setColor(Theme::getThemeColor(Theme::TEXT)); + graphics->setColor(getForegroundColor()); for (int i = 0, y = 0; i < mListModel->getNumberOfElements(); ++i, y += height) { diff --git a/src/gui/widgets/listbox.h b/src/gui/widgets/listbox.h index 5f8c20059..418b83f58 100644 --- a/src/gui/widgets/listbox.h +++ b/src/gui/widgets/listbox.h @@ -73,6 +73,7 @@ class ListBox : public gcn::ListBox void mouseDragged(gcn::MouseEvent &event); protected: + gcn::Color mHighlightColor; static float mAlpha; }; diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp index ea51c146a..38088770b 100644 --- a/src/gui/widgets/popup.cpp +++ b/src/gui/widgets/popup.cpp @@ -26,7 +26,7 @@ #include "configuration.h" #include "graphics.h" #include "graphicsvertexes.h" -#include "log.h" +#include "logger.h" #include "gui/theme.h" #include "gui/viewport.h" diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp index a82ec3e8d..e641be323 100644 --- a/src/gui/widgets/radiobutton.cpp +++ b/src/gui/widgets/radiobutton.cpp @@ -46,6 +46,7 @@ RadioButton::RadioButton(const std::string &caption, const std::string &group, gcn::RadioButton(caption, group, marked), mHasMouse(false) { + setForegroundColor(Theme::getThemeColor(Theme::TEXT)); if (instances == 0) { radioNormal = Theme::getImageFromTheme("radioout.png"); diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index df39854da..2796d3ab2 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -26,7 +26,7 @@ #include "configuration.h" #include "graphics.h" #include "graphicsvertexes.h" -#include "log.h" +#include "logger.h" #include "gui/theme.h" @@ -73,7 +73,6 @@ ScrollArea::ScrollArea(gcn::Widget *widget): mDrawWidth(0), mDrawHeight(0) { -// addWidgetListener(this); init(); } @@ -219,6 +218,9 @@ void ScrollArea::init() } instances++; + + mGray = Theme::getThemeColor(Theme::SCROLLBAR_GRAY, 32); + mBackground = Theme::getThemeColor(Theme::BACKGROUND); } void ScrollArea::logic() @@ -336,7 +338,7 @@ void ScrollArea::drawFrame(gcn::Graphics *graphics) } else { - // because we dont know where parent windows was moved, + // because we don't know where parent windows was moved, // need recalc vertexes gcn::ClipRectangle &rect = static_cast<Graphics*>( graphics)->getTopClip(); @@ -439,17 +441,17 @@ void ScrollArea::drawRightButton(gcn::Graphics *graphics) void ScrollArea::drawVBar(gcn::Graphics *graphics) { const gcn::Rectangle dim = getVerticalBarDimension(); - graphics->setColor(gcn::Color(0, 0, 0, 32)); + graphics->setColor(mGray); graphics->fillRectangle(dim); - graphics->setColor(gcn::Color(255, 255, 255)); + graphics->setColor(mBackground); } void ScrollArea::drawHBar(gcn::Graphics *graphics) { const gcn::Rectangle dim = getHorizontalBarDimension(); - graphics->setColor(gcn::Color(0, 0, 0, 32)); + graphics->setColor(mGray); graphics->fillRectangle(dim); - graphics->setColor(gcn::Color(255, 255, 255)); + graphics->setColor(mBackground); } void ScrollArea::drawVMarker(gcn::Graphics *graphics) diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h index 440fcec15..095010f3c 100644 --- a/src/gui/widgets/scrollarea.h +++ b/src/gui/widgets/scrollarea.h @@ -156,6 +156,9 @@ class ScrollArea : public gcn::ScrollArea, public gcn::WidgetListener int mYOffset; int mDrawWidth; int mDrawHeight; + + gcn::Color mGray; + gcn::Color mBackground; }; #endif diff --git a/src/gui/setupitem.cpp b/src/gui/widgets/setupitem.cpp index 182501e72..698e133dd 100644 --- a/src/gui/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -18,16 +18,17 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "gui/setupitem.h" +#include "gui/widgets/setupitem.h" #include "configuration.h" #include "main.h" -#include "log.h" +#include "logger.h" #include "gui/editdialog.h" #include "gui/widgets/button.h" #include "gui/widgets/checkbox.h" +#include "gui/widgets/dropdown.h" #include "gui/widgets/horizontcontainer.h" #include "gui/widgets/inttextfield.h" #include "gui/widgets/label.h" @@ -330,7 +331,6 @@ void SetupItemTextField::apply(std::string eventName) save(); } - SetupItemIntTextField::SetupItemIntTextField(std::string text, std::string description, std::string keyName, @@ -454,6 +454,8 @@ void SetupItemIntTextField::apply(std::string eventName) save(); } + + SetupItemLabel::SetupItemLabel(std::string text, std::string description, SetupTabScroll *parent, bool separator) : SetupItem(text, description, "", parent, "", "", true), @@ -505,3 +507,85 @@ void SetupItemLabel::action(const gcn::ActionEvent &event A_UNUSED) void SetupItemLabel::apply(std::string eventName A_UNUSED) { } + + +SetupItemDropDown::SetupItemDropDown(std::string text, + std::string description, + std::string keyName, + SetupTabScroll *parent, + std::string eventName, + gcn::ListModel *model, + bool mainConfig) : + SetupItem(text, description, keyName, parent, eventName, mainConfig), + mHorizont(0), + mLabel(0), + mModel(model), + mDropDown(0) +{ + mValueType = VSTR; + createControls(); +} + +SetupItemDropDown::SetupItemDropDown(std::string text, + std::string description, + std::string keyName, + SetupTabScroll *parent, + std::string eventName, + gcn::ListModel *model, + std::string def, + bool mainConfig) : + SetupItem(text, description, keyName, parent, eventName, def, mainConfig), + mHorizont(0), + mLabel(0), + mModel(model), + mDropDown(0) +{ + mValueType = VSTR; + createControls(); +} + +SetupItemDropDown::~SetupItemDropDown() +{ + mHorizont = 0; + mWidget = 0; + mModel = 0; + mDropDown = 0; + mLabel = 0; +} + +void SetupItemDropDown::createControls() +{ + load(); + mHorizont = new HorizontContainer(32, 2); + + mLabel = new Label(mText); + mDropDown = new DropDown(mModel); + mDropDown->setActionEventId(mEventName); + mDropDown->addActionListener(mParent); + + mWidget = mDropDown; +// mTextField->setWidth(50); + mHorizont->add(mLabel); + mHorizont->add(mDropDown); + + mParent->getContainer()->add(mHorizont, true, 4); + mParent->addControl(this); + mParent->addActionListener(this); + mWidget->addActionListener(this); +} + +void SetupItemDropDown::fromWidget() +{ + if (!mDropDown) + return; + + mValue = mDropDown->getSelectedString(); +} + +void SetupItemDropDown::toWidget() +{ + if (!mDropDown) + return; + + mDropDown->setSelectedString(mValue); +} diff --git a/src/gui/setupitem.h b/src/gui/widgets/setupitem.h index 3396edea3..15d2d41ea 100644 --- a/src/gui/setupitem.h +++ b/src/gui/widgets/setupitem.h @@ -42,6 +42,7 @@ class CheckBox; class Configuration; class ContainerPlacer; +class DropDown; class EditDialog; class HorizontContainer; class IntTextField; @@ -241,4 +242,32 @@ class SetupItemLabel : public SetupItem bool mIsSeparator; }; +class SetupItemDropDown : public SetupItem +{ + public: + SetupItemDropDown(std::string text, std::string description, + std::string keyName, SetupTabScroll *parent, + std::string eventName, gcn::ListModel *model, + bool mainConfig = true); + + SetupItemDropDown(std::string text, std::string description, + std::string keyName, SetupTabScroll *parent, + std::string eventName, gcn::ListModel *model, + std::string def, bool mainConfig = true); + + ~SetupItemDropDown(); + + void createControls(); + + void fromWidget(); + + void toWidget(); + + protected: + HorizontContainer *mHorizont; + Label *mLabel; + gcn::ListModel *mModel; + DropDown *mDropDown; +}; + #endif diff --git a/src/gui/widgets/setuptabscroll.cpp b/src/gui/widgets/setuptabscroll.cpp index 805c0c8c7..30bb66469 100644 --- a/src/gui/widgets/setuptabscroll.cpp +++ b/src/gui/widgets/setuptabscroll.cpp @@ -20,10 +20,9 @@ #include "gui/widgets/setuptabscroll.h" -#include "gui/setupitem.h" - #include "gui/widgets/layouthelper.h" #include "gui/widgets/scrollarea.h" +#include "gui/widgets/setupitem.h" #include "gui/widgets/vertcontainer.h" #include "debug.h" diff --git a/src/gui/widgets/shopitems.cpp b/src/gui/widgets/shopitems.cpp index c5bcd88c4..e15445b77 100644 --- a/src/gui/widgets/shopitems.cpp +++ b/src/gui/widgets/shopitems.cpp @@ -43,6 +43,11 @@ int ShopItems::getNumberOfElements() return static_cast<int>(mShopItems.size()); } +bool ShopItems::empty() +{ + return mShopItems.empty(); +} + std::string ShopItems::getElementAt(int i) { if (i < 0 || static_cast<unsigned>(i) >= mShopItems.size() diff --git a/src/gui/widgets/shopitems.h b/src/gui/widgets/shopitems.h index abfcffb71..29d24cb64 100644 --- a/src/gui/widgets/shopitems.h +++ b/src/gui/widgets/shopitems.h @@ -76,6 +76,8 @@ class ShopItems : public gcn::ListModel */ int getNumberOfElements(); + bool empty(); + /** * Returns the name of item number i in the shop. * diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp index 2fe28181b..793491808 100644 --- a/src/gui/widgets/shoplistbox.cpp +++ b/src/gui/widgets/shoplistbox.cpp @@ -50,9 +50,7 @@ ShopListBox::ShopListBox(gcn::ListModel *listModel): mShopItems(0) { mRowHeight = getFont()->getHeight(); - mPriceCheck = true; - - mItemPopup = new ItemPopup; + init(); } ShopListBox::ShopListBox(gcn::ListModel *listModel, ShopItems *shopListModel): @@ -61,9 +59,17 @@ ShopListBox::ShopListBox(gcn::ListModel *listModel, ShopItems *shopListModel): mShopItems(shopListModel) { mRowHeight = std::max(getFont()->getHeight(), ITEM_ICON_SIZE); - mPriceCheck = true; + init(); +} +void ShopListBox::init() +{ + mPriceCheck = true; mItemPopup = new ItemPopup; + mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT); + mBackgroundColor = Theme::getThemeColor(Theme::BACKGROUND); + mWarningColor = Theme::getThemeColor(Theme::SHOP_WARNING); + setForegroundColor(Theme::getThemeColor(Theme::TEXT)); } void ShopListBox::setPlayersMoney(int money) @@ -80,8 +86,7 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics) mAlpha = Client::getGuiAlpha(); int alpha = static_cast<int>(mAlpha * 255.0f); - const gcn::Color* highlightColor = - &Theme::getThemeColor(Theme::HIGHLIGHT, alpha); + mHighlightColor.a = alpha; Graphics *graphics = static_cast<Graphics*>(gcnGraphics); @@ -93,29 +98,30 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics) ++i, y += mRowHeight) { gcn::Color temp; - const gcn::Color* backgroundColor = - &Theme::getThemeColor(Theme::BACKGROUND, alpha); + gcn::Color* backgroundColor = &mBackgroundColor; + mBackgroundColor.a = alpha; if (mShopItems && mShopItems->at(i) && mPlayerMoney < mShopItems->at(i)->getPrice() && mPriceCheck) { if (i != mSelected) { - backgroundColor = &Theme::getThemeColor(Theme::SHOP_WARNING, - alpha); + backgroundColor = &mWarningColor; + backgroundColor->a = alpha; } else { - temp = Theme::getThemeColor(Theme::SHOP_WARNING, alpha); - temp.r = (temp.r + highlightColor->r) / 2; - temp.g = (temp.g + highlightColor->g) / 2; - temp.b = (temp.g + highlightColor->b) / 2; + temp = mWarningColor; + temp.r = (temp.r + mHighlightColor.r) / 2; + temp.g = (temp.g + mHighlightColor.g) / 2; + temp.b = (temp.g + mHighlightColor.b) / 2; + temp.a = alpha; backgroundColor = &temp; } } else if (i == mSelected) { - backgroundColor = highlightColor; + backgroundColor = &mHighlightColor; } graphics->setColor(*backgroundColor); @@ -130,9 +136,9 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics) graphics->drawImage(icon, 1, y); } } - graphics->setColor(Theme::getThemeColor(Theme::TEXT)); + graphics->setColor(getForegroundColor()); graphics->drawText(mListModel->getElementAt(i), ITEM_ICON_SIZE + 5, - y + (ITEM_ICON_SIZE - getFont()->getHeight()) / 2); + y + (ITEM_ICON_SIZE - getFont()->getHeight()) / 2); } } diff --git a/src/gui/widgets/shoplistbox.h b/src/gui/widgets/shoplistbox.h index 917f46729..38e238f20 100644 --- a/src/gui/widgets/shoplistbox.h +++ b/src/gui/widgets/shoplistbox.h @@ -85,6 +85,8 @@ class ShopListBox : public ListBox void mouseExited(gcn::MouseEvent& mouseEvent A_UNUSED); private: + void init(); + int mPlayerMoney; /** @@ -100,6 +102,10 @@ class ShopListBox : public ListBox static float mAlpha; bool mPriceCheck; + + gcn::Color mHighlightColor; + gcn::Color mBackgroundColor; + gcn::Color mWarningColor; }; #endif // SHOPLISTBOX_H diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp index 0f4814429..8abe727b5 100644 --- a/src/gui/widgets/spellshortcutcontainer.cpp +++ b/src/gui/widgets/spellshortcutcontainer.cpp @@ -1,9 +1,10 @@ /* - * The Mana World + * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas + * Copyright (C) 2011 ManaPlus developers * - * This file is part of The Mana World. + * 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 @@ -39,7 +40,7 @@ #include "keyboardconfig.h" #include "localplayer.h" #include "spellmanager.h" -#include "log.h" +#include "logger.h" #include "resources/image.h" #include "textcommand.h" @@ -80,6 +81,7 @@ SpellShortcutContainer::SpellShortcutContainer(unsigned number): mBoxHeight = 1; mBoxWidth = 1; } + setForegroundColor(Theme::getThemeColor(Theme::TEXT)); } SpellShortcutContainer::~SpellShortcutContainer() @@ -105,11 +107,10 @@ void SpellShortcutContainer::draw(gcn::Graphics *graphics) Graphics *g = static_cast<Graphics*>(graphics); - graphics->setColor(gcn::Color(0, 0, 0, 255)); graphics->setFont(getFont()); int selectedId = spellShortcut->getSelectedItem(); - g->setColor(Theme::getThemeColor(Theme::TEXT)); + g->setColor(getForegroundColor()); for (unsigned i = 0; i < mMaxItems; i++) { diff --git a/src/gui/widgets/spellshortcutcontainer.h b/src/gui/widgets/spellshortcutcontainer.h index 28016cbad..2155e2a8b 100644 --- a/src/gui/widgets/spellshortcutcontainer.h +++ b/src/gui/widgets/spellshortcutcontainer.h @@ -1,9 +1,10 @@ /* - * The Mana World + * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas + * Copyright (C) 2011 ManaPlus developers * - * This file is part of The Mana World. + * 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 diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp index 1b548a6a3..530f1ac82 100644 --- a/src/gui/widgets/tab.cpp +++ b/src/gui/widgets/tab.cpp @@ -26,7 +26,7 @@ #include "configuration.h" #include "graphics.h" #include "graphicsvertexes.h" -#include "log.h" +#include "logger.h" #include "gui/palette.h" #include "gui/theme.h" @@ -77,6 +77,8 @@ Tab::Tab() : gcn::Tab(), mMode(0) { init(); + mFlashColor = Theme::getThemeColor(Theme::TAB_FLASH); + mPlayerFlashColor = Theme::getThemeColor(Theme::TAB_PLAYER_FLASH); } Tab::~Tab() @@ -177,12 +179,10 @@ void Tab::draw(gcn::Graphics *graphics) switch (mFlash) { case 1: - mLabel->setForegroundColor(Theme::getThemeColor( - Theme::TAB_FLASH)); + mLabel->setForegroundColor(mFlashColor); break; case 2: - mLabel->setForegroundColor(Theme::getThemeColor( - Theme::TAB_PLAYER_FLASH)); + mLabel->setForegroundColor(mPlayerFlashColor); break; default: break; diff --git a/src/gui/widgets/tab.h b/src/gui/widgets/tab.h index 5847bd505..ba51e6c74 100644 --- a/src/gui/widgets/tab.h +++ b/src/gui/widgets/tab.h @@ -91,6 +91,8 @@ class Tab : public gcn::Tab, public gcn::WidgetListener GraphicsVertexes *mVertexes; bool mRedraw; int mMode; + gcn::Color mFlashColor; + gcn::Color mPlayerFlashColor; }; #endif diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index d3539a115..940dad12a 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -25,7 +25,7 @@ #include "gui/widgets/scrollarea.h" #include "gui/widgets/tab.h" -#include "log.h" +#include "logger.h" #include <guichan/widgets/container.hpp> diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index d3108a77f..2729e5407 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -25,7 +25,7 @@ #include "client.h" #include "configuration.h" #include "graphics.h" -#include "log.h" +#include "logger.h" #include "gui/palette.h" #include "gui/sdlinput.h" @@ -59,6 +59,8 @@ TextField::TextField(const std::string &text, bool loseFocusOnTab, mLoseFocusOnTab = loseFocusOnTab; + setForegroundColor(Theme::getThemeColor(Theme::TEXT)); + if (instances == 0) { // Load the skin @@ -136,7 +138,7 @@ void TextField::draw(gcn::Graphics *graphics) mXScroll); } - graphics->setColor(Theme::getThemeColor(Theme::TEXT)); + graphics->setColor(getForegroundColor()); graphics->setFont(getFont()); graphics->drawText(mText, 1 - mXScroll, 1); } diff --git a/src/gui/widgets/tradetab.cpp b/src/gui/widgets/tradetab.cpp index 99a145d86..deec2aea6 100644 --- a/src/gui/widgets/tradetab.cpp +++ b/src/gui/widgets/tradetab.cpp @@ -22,10 +22,10 @@ #include "gui/widgets/tradetab.h" -#include "chatlog.h" +#include "chatlogger.h" #include "commandhandler.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "gui/theme.h" diff --git a/src/gui/widgets/vertcontainer.cpp b/src/gui/widgets/vertcontainer.cpp index d65274f20..ea6b4d520 100644 --- a/src/gui/widgets/vertcontainer.cpp +++ b/src/gui/widgets/vertcontainer.cpp @@ -49,7 +49,7 @@ void VertContainer::add(gcn::Widget *widget, bool resizable, int spacing) widget->setPosition(mLeftSpacing, mNextY); if (resizable) { - widget->setSize(getWidth() - mLeftSpacing, mVerticalItemSize); + widget->setSize(getWidth() - mLeftSpacing, mVerticalItemSize * 5); mResizableWidgets.push_back(widget); } else if (widget->getHeight() > mVerticalItemSize) diff --git a/src/gui/widgets/whispertab.cpp b/src/gui/widgets/whispertab.cpp index bee30b969..c99c4e0c5 100644 --- a/src/gui/widgets/whispertab.cpp +++ b/src/gui/widgets/whispertab.cpp @@ -22,10 +22,10 @@ #include "gui/widgets/whispertab.h" -#include "chatlog.h" +#include "chatlogger.h" #include "commandhandler.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "gui/theme.h" diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 14448ea86..cdb9d3d55 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -25,7 +25,7 @@ #include "client.h" #include "configuration.h" #include "graphicsvertexes.h" -#include "log.h" +#include "logger.h" #include "gui/gui.h" #include "gui/palette.h" @@ -95,6 +95,7 @@ Window::Window(const std::string &caption, bool modal, Window *parent, addWidgetListener(this); mCaptionFont = getFont(); + setForegroundColor(Theme::getThemeColor(Theme::TEXT)); } Window::~Window() @@ -146,15 +147,10 @@ void Window::draw(gcn::Graphics *graphics) g->drawImageRect2(mVertexes, mSkin->getBorder()); -/* - g->drawImageRect(0, 0, getWidth(), - getHeight(), mSkin->getBorder()); -*/ - // Draw title if (mShowTitle) { - g->setColor(Theme::getThemeColor(Theme::TEXT)); + g->setColor(getForegroundColor()); g->setFont(mCaptionFont); g->drawText(getCaption(), 7, 5, gcn::Graphics::LEFT); } diff --git a/src/guichan/include/guichan/basiccontainer.hpp b/src/guichan/include/guichan/basiccontainer.hpp index b63b83cd8..998e1f601 100644 --- a/src/guichan/include/guichan/basiccontainer.hpp +++ b/src/guichan/include/guichan/basiccontainer.hpp @@ -132,7 +132,7 @@ namespace gcn * @see remove, clear */ virtual void clear(); - + /** * Draws the children widgets of the basic container. * diff --git a/src/inventory.cpp b/src/inventory.cpp index 3ff40374a..f907b2cc2 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -22,7 +22,7 @@ #include "inventory.h" #include "item.h" -#include "log.h" +#include "logger.h" #include "net/inventoryhandler.h" #include "net/net.h" @@ -155,6 +155,9 @@ void Inventory::removeItemAt(int index) bool Inventory::contains(Item *item) const { + if (!item) + return false; + for (unsigned i = 0; i < mSize; i++) { if (mItems[i] && mItems[i]->getId() == item->getId()) diff --git a/src/itemshortcut.cpp b/src/itemshortcut.cpp index 464eeda14..625e8d90a 100644 --- a/src/itemshortcut.cpp +++ b/src/itemshortcut.cpp @@ -193,8 +193,8 @@ void ItemShortcut::setItemSelected(Item *item) { if (item) { - logger->log("set selected id: %d", item->getId()); - logger->log("set selected color: %d", item->getColor()); +// logger->log("set selected id: %d", item->getId()); +// logger->log("set selected color: %d", item->getColor()); mItemSelected = item->getId(); mItemColorSelected = item->getColor(); } diff --git a/src/joystick.cpp b/src/joystick.cpp index f1255c4c0..8f808a2d1 100644 --- a/src/joystick.cpp +++ b/src/joystick.cpp @@ -22,7 +22,7 @@ #include "configuration.h" #include "joystick.h" -#include "log.h" +#include "logger.h" #include <cassert> diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp index 8ad38ab76..bf58c518a 100644 --- a/src/keyboardconfig.cpp +++ b/src/keyboardconfig.cpp @@ -20,7 +20,7 @@ #include "configuration.h" #include "keyboardconfig.h" -#include "log.h" +#include "logger.h" #include "gui/sdlinput.h" #include "gui/setup_keyboard.h" diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 0310bb8ad..5192390bc 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -31,7 +31,7 @@ #include "guild.h" #include "item.h" #include "keyboardconfig.h" -#include "log.h" +#include "logger.h" #include "map.h" #include "party.h" #include "particle.h" @@ -46,10 +46,11 @@ #include "gui/gui.h" #include "gui/inventorywindow.h" #include "gui/killstats.h" -#include "gui/ministatus.h" +#include "gui/ministatuswindow.h" #include "gui/okdialog.h" #include "gui/outfitwindow.h" #include "gui/palette.h" +#include "gui/shopwindow.h" #include "gui/skilldialog.h" #include "gui/socialwindow.h" #include "gui/statuswindow.h" @@ -344,7 +345,7 @@ void LocalPlayer::logic() if (mEnableAdvert && !mBlockAdvert && mAdvertTime < cur_time) { Uint8 smile = FLAG_SPECIAL; - if (mTradebot) + if (mTradebot && shopWindow && !shopWindow->isShopEmpty()) smile += FLAG_SHOP; if (mAwayMode) @@ -3463,10 +3464,7 @@ void LocalPlayer::attack2(Being *target, bool keep, bool dontChangeEquipment) if (target && target->getType() != Being::NPC) { mKeepAttacking = true; - if (mAttackWeaponType == 1) - moveToTarget(); - else - moveToTarget(mAttackRange); + moveToTarget(); } } } diff --git a/src/log.cpp b/src/logger.cpp index 9bcf1ea4f..6790d622a 100644 --- a/src/log.cpp +++ b/src/logger.cpp @@ -23,7 +23,7 @@ #include <iostream> #include <sstream> -#include "log.h" +#include "logger.h" #include "configuration.h" diff --git a/src/log.h b/src/logger.h index b8517f696..c2fabb383 100644 --- a/src/log.h +++ b/src/logger.h @@ -20,8 +20,8 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef M_LOG_H -#define M_LOG_H +#ifndef M_LOGGER_H +#define M_LOGGER_H #include "main.h" #include <fstream> diff --git a/src/main.cpp b/src/main.cpp index faeedadaa..5c13b10ec 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -25,7 +25,7 @@ #include "utils/gettext.h" #include "client.h" -#include "log.h" +#include "logger.h" #include <libxml/parser.h> diff --git a/src/main.h b/src/main.h index dbe9b3142..9f8bbc6ac 100644 --- a/src/main.h +++ b/src/main.h @@ -26,12 +26,6 @@ /** * \mainpage * - * \section Introduction Introduction - * - * This is the documentation for the Mana client (http://manasource.org). It is - * always a work in progress, with the intent to make it easier for new - * developers to grow familiar with the source code. - * * \section General General information * * During the game, the current Map is displayed by the main Viewport, which @@ -91,8 +85,8 @@ //define DEBUG_ALPHA_CACHE 1 //define DEBUG_OPENGL_LEAKS 1 -#define SMALL_VERSION "1.1.8.7" -#define CHECK_VERSION "01.01.08.07" +#define SMALL_VERSION "1.1.8.21" +#define CHECK_VERSION "01.01.08.21" #define PACKAGE_EXTENDED_VERSION "ManaPlus (" PACKAGE_OS \ diff --git a/src/map.cpp b/src/map.cpp index 8225aded1..721967b25 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -27,7 +27,7 @@ #include "configuration.h" #include "graphics.h" #include "graphicsvertexes.h" -#include "log.h" +#include "logger.h" #include "particle.h" #include "simpleanimation.h" #include "tileset.h" @@ -918,7 +918,7 @@ void Map::draw(Graphics *graphics, int scrollX, int scrollY) } } - // Dont draw if gui opacity == 1 + // Don't draw if gui opacity == 1 if (mBeingOpacity && mOpacity != 1.0f) { // Draws beings with a lower opacity to make them visible diff --git a/src/mumblemanager.cpp b/src/mumblemanager.cpp index 456606406..bace077cd 100644 --- a/src/mumblemanager.cpp +++ b/src/mumblemanager.cpp @@ -1,9 +1,11 @@ -/* Code taken from: http://mumble.sourceforge.net/Link */ +/* + *Code taken from: http://mumble.sourceforge.net/Link + */ #include "mumblemanager.h" #include "configuration.h" -#include "log.h" +#include "logger.h" #include "utils/mathutils.h" diff --git a/src/mumblemanager.h b/src/mumblemanager.h index a3eddee02..f7617233f 100644 --- a/src/mumblemanager.h +++ b/src/mumblemanager.h @@ -1,4 +1,6 @@ -/* Code taken from: http://mumble.sourceforge.net/Link */ +/* + * Code taken from: http://mumble.sourceforge.net/Link + */ #ifndef MUMBLEMANAGER_H #define MUMBLEMANAGER_H diff --git a/src/net/adminhandler.h b/src/net/adminhandler.h index 2d7eccebf..d063c4eb1 100644 --- a/src/net/adminhandler.h +++ b/src/net/adminhandler.h @@ -53,6 +53,7 @@ class AdminHandler virtual void mute(int playerId, int type, int limit) = 0; + virtual void warp(std::string map, int x, int y) = 0; // TODO }; diff --git a/src/net/beinghandler.h b/src/net/beinghandler.h index 89f972e6d..07279b148 100644 --- a/src/net/beinghandler.h +++ b/src/net/beinghandler.h @@ -1,8 +1,9 @@ /* - * The Mana World + * The ManaPlus Client * Copyright (C) 2004 The Mana World Development Team + * Copyright (C) 2011 ManaPlus developers * - * This file is part of The Mana World. + * 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 diff --git a/src/net/download.cpp b/src/net/download.cpp index c93f33c21..93417197e 100644 --- a/src/net/download.cpp +++ b/src/net/download.cpp @@ -22,7 +22,7 @@ #include "net/download.h" #include "configuration.h" -#include "log.h" +#include "logger.h" #include "main.h" #include "utils/stringutils.h" diff --git a/src/net/ea/adminhandler.cpp b/src/net/ea/adminhandler.cpp index 5440d14d0..bdd43b3f8 100644 --- a/src/net/ea/adminhandler.cpp +++ b/src/net/ea/adminhandler.cpp @@ -63,4 +63,10 @@ void AdminHandler::mute(int playerId A_UNUSED, int type A_UNUSED, return; // Still looking into this } +void AdminHandler::warp(std::string map, int x, int y) +{ + Net::getChatHandler()->talk(strprintf( + "@warp %s %d %d", map.c_str(), x, y)); +} + } // namespace Ea diff --git a/src/net/ea/adminhandler.h b/src/net/ea/adminhandler.h index 6f77c0e18..fcf1e25b2 100644 --- a/src/net/ea/adminhandler.h +++ b/src/net/ea/adminhandler.h @@ -51,6 +51,8 @@ class AdminHandler : public Net::AdminHandler virtual void unban(const std::string &name); virtual void mute(int playerId, int type, int limit); + + virtual void warp(std::string map, int x, int y); }; } // namespace Ea diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp index ee070593f..06e86f8a4 100644 --- a/src/net/ea/beinghandler.cpp +++ b/src/net/ea/beinghandler.cpp @@ -31,7 +31,7 @@ #include "guild.h" #include "keyboardconfig.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "party.h" #include "playerrelations.h" #include "configuration.h" diff --git a/src/net/ea/charserverhandler.cpp b/src/net/ea/charserverhandler.cpp index c69d8a5be..a0e5b392a 100644 --- a/src/net/ea/charserverhandler.cpp +++ b/src/net/ea/charserverhandler.cpp @@ -23,7 +23,7 @@ #include "net/ea/charserverhandler.h" #include "client.h" -#include "log.h" +#include "logger.h" #include "gui/charcreatedialog.h" #include "gui/okdialog.h" diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp index ea9d17798..c188a2204 100644 --- a/src/net/ea/chathandler.cpp +++ b/src/net/ea/chathandler.cpp @@ -27,7 +27,7 @@ #include "configuration.h" #include "localplayer.h" #include "playerrelations.h" -#include "log.h" +#include "logger.h" #include "gui/chatwindow.h" #include "gui/shopwindow.h" diff --git a/src/net/ea/gamehandler.cpp b/src/net/ea/gamehandler.cpp index 0b6b8a040..04c13572f 100644 --- a/src/net/ea/gamehandler.cpp +++ b/src/net/ea/gamehandler.cpp @@ -26,7 +26,7 @@ #include "event.h" #include "game.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "gui/okdialog.h" diff --git a/src/net/ea/gui/guildtab.cpp b/src/net/ea/gui/guildtab.cpp index 037885fd1..ab030be83 100644 --- a/src/net/ea/gui/guildtab.cpp +++ b/src/net/ea/gui/guildtab.cpp @@ -22,7 +22,7 @@ #include "net/ea/gui/guildtab.h" -#include "chatlog.h" +#include "chatlogger.h" #include "commandhandler.h" #include "guild.h" #include "localplayer.h" diff --git a/src/net/ea/gui/partytab.cpp b/src/net/ea/gui/partytab.cpp index 02e0910a7..23eab361c 100644 --- a/src/net/ea/gui/partytab.cpp +++ b/src/net/ea/gui/partytab.cpp @@ -22,7 +22,7 @@ #include "net/ea/gui/partytab.h" -#include "chatlog.h" +#include "chatlogger.h" #include "commandhandler.h" #include "localplayer.h" #include "party.h" diff --git a/src/net/ea/guildhandler.cpp b/src/net/ea/guildhandler.cpp index bb5cbe94b..0210a76ff 100644 --- a/src/net/ea/guildhandler.cpp +++ b/src/net/ea/guildhandler.cpp @@ -25,7 +25,7 @@ #include "guild.h" #include "event.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "gui/socialwindow.h" diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp index acd674d12..01000f8f1 100644 --- a/src/net/ea/inventoryhandler.cpp +++ b/src/net/ea/inventoryhandler.cpp @@ -24,9 +24,9 @@ #include "inventory.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" -#include "gui/ministatus.h" +#include "gui/ministatuswindow.h" #include "net/messagein.h" @@ -275,7 +275,7 @@ void InventoryHandler::processPlayerStorageEquip(Net::MessageIn &msg) void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg) { int index, amount, itemId, equipType, refine; - int cards[4], itemType; +// int cards[4], itemType; unsigned char identified; int floorId; @@ -296,9 +296,9 @@ void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg) msg.readInt8(); // attribute refine = msg.readInt8(); for (int i = 0; i < 4; i++) - cards[i] = msg.readInt16(); + msg.readInt16(); // cards[i] equipType = msg.readInt16(); - itemType = msg.readInt8(); + msg.readInt8(); // itemType const ItemInfo &itemInfo = ItemDB::get(itemId); diff --git a/src/net/ea/inventoryhandler.h b/src/net/ea/inventoryhandler.h index 1f1f8d296..4be4ddaa6 100644 --- a/src/net/ea/inventoryhandler.h +++ b/src/net/ea/inventoryhandler.h @@ -25,7 +25,7 @@ #include "equipment.h" #include "inventory.h" -#include "log.h" +#include "logger.h" #include "playerinfo.h" #include "gui/inventorywindow.h" diff --git a/src/net/ea/loginhandler.cpp b/src/net/ea/loginhandler.cpp index 51502895c..9f7a5f07d 100644 --- a/src/net/ea/loginhandler.cpp +++ b/src/net/ea/loginhandler.cpp @@ -23,7 +23,7 @@ #include "net/ea/loginhandler.h" #include "client.h" -#include "log.h" +#include "logger.h" #include "configuration.h" #include "utils/dtor.h" diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp index f720f9f96..045a2332b 100644 --- a/src/net/ea/partyhandler.cpp +++ b/src/net/ea/partyhandler.cpp @@ -22,7 +22,7 @@ #include "actorspritemanager.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "gui/socialwindow.h" diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp index 05b6cf9e3..4198c14ad 100644 --- a/src/net/ea/playerhandler.cpp +++ b/src/net/ea/playerhandler.cpp @@ -22,7 +22,7 @@ #include "net/ea/playerhandler.h" -#include "log.h" +#include "logger.h" #include "party.h" #include "playerinfo.h" #include "units.h" diff --git a/src/net/ea/specialhandler.cpp b/src/net/ea/specialhandler.cpp index 33fea3b27..4f0f22aed 100644 --- a/src/net/ea/specialhandler.cpp +++ b/src/net/ea/specialhandler.cpp @@ -22,7 +22,7 @@ #include "net/ea/specialhandler.h" -#include "log.h" +#include "logger.h" #include "localplayer.h" #include "playerinfo.h" diff --git a/src/net/ea/tradehandler.cpp b/src/net/ea/tradehandler.cpp index 36a5f8811..a03782db2 100644 --- a/src/net/ea/tradehandler.cpp +++ b/src/net/ea/tradehandler.cpp @@ -25,7 +25,7 @@ #include "event.h" #include "inventory.h" #include "item.h" -#include "log.h" +#include "logger.h" #include "playerinfo.h" #include "playerrelations.h" diff --git a/src/net/manaserv/adminhandler.cpp b/src/net/manaserv/adminhandler.cpp index 72e7c7ca8..2c76e99a3 100644 --- a/src/net/manaserv/adminhandler.cpp +++ b/src/net/manaserv/adminhandler.cpp @@ -91,4 +91,9 @@ void AdminHandler::mute(int playerId A_UNUSED, int type A_UNUSED, // TODO } +void AdminHandler::warp(std::string map, int x, int y) +{ + // TODO +} + } // namespace ManaServ diff --git a/src/net/manaserv/adminhandler.h b/src/net/manaserv/adminhandler.h index a91841085..65e9ea2b0 100644 --- a/src/net/manaserv/adminhandler.h +++ b/src/net/manaserv/adminhandler.h @@ -58,6 +58,8 @@ class AdminHandler : public Net::AdminHandler void unban(const std::string &name); void mute(int playerId, int type, int limit); + + void warp(std::string map, int x, int y); }; } // namespace ManaServ diff --git a/src/net/manaserv/attributes.cpp b/src/net/manaserv/attributes.cpp index b48cc9eff..25c75f9d8 100644 --- a/src/net/manaserv/attributes.cpp +++ b/src/net/manaserv/attributes.cpp @@ -21,7 +21,7 @@ #include "net/manaserv/attributes.h" -#include "log.h" +#include "logger.h" #include "playerinfo.h" #include "gui/statuswindow.h" diff --git a/src/net/manaserv/beinghandler.cpp b/src/net/manaserv/beinghandler.cpp index 23aae1f56..d14cdcadf 100644 --- a/src/net/manaserv/beinghandler.cpp +++ b/src/net/manaserv/beinghandler.cpp @@ -27,7 +27,7 @@ #include "client.h" #include "game.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "particle.h" #include "gui/okdialog.h" diff --git a/src/net/manaserv/charhandler.cpp b/src/net/manaserv/charhandler.cpp index c2611c64b..3b2306feb 100644 --- a/src/net/manaserv/charhandler.cpp +++ b/src/net/manaserv/charhandler.cpp @@ -24,7 +24,7 @@ #include "client.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "gui/charcreatedialog.h" #include "gui/okdialog.h" diff --git a/src/net/manaserv/connection.cpp b/src/net/manaserv/connection.cpp index 7f51aeb98..33d6f28cf 100644 --- a/src/net/manaserv/connection.cpp +++ b/src/net/manaserv/connection.cpp @@ -22,7 +22,7 @@ #include "net/manaserv/connection.h" -#include "log.h" +#include "logger.h" #include "net/manaserv/internal.h" #include "net/manaserv/messageout.h" diff --git a/src/net/manaserv/effecthandler.cpp b/src/net/manaserv/effecthandler.cpp index 3979a0fde..92cf66302 100644 --- a/src/net/manaserv/effecthandler.cpp +++ b/src/net/manaserv/effecthandler.cpp @@ -24,7 +24,7 @@ #include "actorspritemanager.h" #include "effectmanager.h" -#include "log.h" +#include "logger.h" #include "net/messagein.h" diff --git a/src/net/manaserv/guildhandler.cpp b/src/net/manaserv/guildhandler.cpp index dc3dbc616..306a15be4 100644 --- a/src/net/manaserv/guildhandler.cpp +++ b/src/net/manaserv/guildhandler.cpp @@ -24,7 +24,7 @@ #include "event.h" #include "guild.h" -#include "log.h" +#include "logger.h" #include "localplayer.h" #include "channel.h" #include "channelmanager.h" diff --git a/src/net/manaserv/inventoryhandler.cpp b/src/net/manaserv/inventoryhandler.cpp index 5e38354fb..ce837b5e1 100644 --- a/src/net/manaserv/inventoryhandler.cpp +++ b/src/net/manaserv/inventoryhandler.cpp @@ -38,7 +38,7 @@ #include "resources/iteminfo.h" -#include "log.h" // <<< REMOVE ME! +#include "logger.h" // <<< REMOVE ME! extern Net::InventoryHandler *inventoryHandler; diff --git a/src/net/manaserv/itemhandler.cpp b/src/net/manaserv/itemhandler.cpp index 0afd12d21..89826a33f 100644 --- a/src/net/manaserv/itemhandler.cpp +++ b/src/net/manaserv/itemhandler.cpp @@ -29,7 +29,7 @@ #include "game.h" #include "map.h" -#include "log.h" +#include "logger.h" namespace ManaServ { diff --git a/src/net/manaserv/loginhandler.cpp b/src/net/manaserv/loginhandler.cpp index e6109ca28..bf823562f 100644 --- a/src/net/manaserv/loginhandler.cpp +++ b/src/net/manaserv/loginhandler.cpp @@ -23,7 +23,7 @@ #include "net/manaserv/loginhandler.h" #include "client.h" -#include "log.h" +#include "logger.h" #include "net/logindata.h" diff --git a/src/net/manaserv/network.cpp b/src/net/manaserv/network.cpp index e0ab7af78..53e83e4ec 100644 --- a/src/net/manaserv/network.cpp +++ b/src/net/manaserv/network.cpp @@ -22,7 +22,7 @@ #include "net/manaserv/network.h" -#include "log.h" +#include "logger.h" #include "net/manaserv/connection.h" #include "net/manaserv/internal.h" diff --git a/src/net/manaserv/partyhandler.cpp b/src/net/manaserv/partyhandler.cpp index 0e6af4578..987a40dc5 100644 --- a/src/net/manaserv/partyhandler.cpp +++ b/src/net/manaserv/partyhandler.cpp @@ -23,7 +23,7 @@ #include "net/manaserv/partyhandler.h" #include "event.h" -#include "log.h" +#include "logger.h" #include "localplayer.h" #include "gui/socialwindow.h" diff --git a/src/net/manaserv/playerhandler.cpp b/src/net/manaserv/playerhandler.cpp index ca7fe511f..3dfddb436 100644 --- a/src/net/manaserv/playerhandler.cpp +++ b/src/net/manaserv/playerhandler.cpp @@ -27,7 +27,7 @@ #include "effectmanager.h" #include "game.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "particle.h" #include "playerinfo.h" #include "configuration.h" diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp index 8b5f2eee3..5bfeefdb6 100644 --- a/src/net/messagein.cpp +++ b/src/net/messagein.cpp @@ -24,7 +24,7 @@ #include "net/packetcounters.h" -#include "log.h" +#include "logger.h" #include "net.h" #include "utils/stringutils.h" diff --git a/src/net/messageout.cpp b/src/net/messageout.cpp index 3cdcb42e0..a8b66f5ae 100644 --- a/src/net/messageout.cpp +++ b/src/net/messageout.cpp @@ -24,7 +24,7 @@ #include "net/packetcounters.h" -#include "log.h" +#include "logger.h" #include "utils/stringutils.h" diff --git a/src/net/tmwa/adminhandler.cpp b/src/net/tmwa/adminhandler.cpp index a0d996dbf..a332b04fa 100644 --- a/src/net/tmwa/adminhandler.cpp +++ b/src/net/tmwa/adminhandler.cpp @@ -28,7 +28,7 @@ #include "being.h" #include "event.h" #include "game.h" -#include "log.h" +#include "logger.h" #include "playerrelations.h" #include "net/chathandler.h" diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp index d6f67f716..5016b2f8c 100644 --- a/src/net/tmwa/beinghandler.cpp +++ b/src/net/tmwa/beinghandler.cpp @@ -29,7 +29,7 @@ #include "guild.h" #include "keyboardconfig.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "party.h" #include "playerrelations.h" #include "configuration.h" @@ -552,7 +552,7 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, int msgType) dstBeing->setTileCoords(srcX, srcY); dstBeing->setDestination(dstX, dstY); - // because server dont send direction in move packet, + // because server don't send direction in move packet, // we fixing it if (srcX != dstX || srcY != dstY) diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp index fe803dc62..7aa68e617 100644 --- a/src/net/tmwa/charserverhandler.cpp +++ b/src/net/tmwa/charserverhandler.cpp @@ -24,7 +24,7 @@ #include "client.h" #include "configuration.h" -#include "log.h" +#include "logger.h" #include "gui/charcreatedialog.h" diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp index 0f23f6412..90acf0f90 100644 --- a/src/net/tmwa/chathandler.cpp +++ b/src/net/tmwa/chathandler.cpp @@ -29,7 +29,7 @@ #include "game.h" #include "localplayer.h" #include "playerrelations.h" -#include "log.h" +#include "logger.h" #include "gui/chatwindow.h" #include "gui/shopwindow.h" diff --git a/src/net/tmwa/gamehandler.cpp b/src/net/tmwa/gamehandler.cpp index cc0a37c57..242e9f9de 100644 --- a/src/net/tmwa/gamehandler.cpp +++ b/src/net/tmwa/gamehandler.cpp @@ -26,7 +26,7 @@ #include "event.h" #include "game.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "net/messagein.h" #include "net/messageout.h" diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp index 3e46fa66b..746cb6620 100644 --- a/src/net/tmwa/generalhandler.cpp +++ b/src/net/tmwa/generalhandler.cpp @@ -24,7 +24,7 @@ #include "client.h" #include "configuration.h" -#include "log.h" +#include "logger.h" #include "gui/charselectdialog.h" #include "gui/inventorywindow.h" diff --git a/src/net/tmwa/gui/guildtab.cpp b/src/net/tmwa/gui/guildtab.cpp index 99b775089..05a93bff8 100644 --- a/src/net/tmwa/gui/guildtab.cpp +++ b/src/net/tmwa/gui/guildtab.cpp @@ -22,7 +22,7 @@ #include "net/tmwa/gui/guildtab.h" -#include "chatlog.h" +#include "chatlogger.h" #include "commandhandler.h" #include "guild.h" #include "localplayer.h" diff --git a/src/net/tmwa/gui/partytab.cpp b/src/net/tmwa/gui/partytab.cpp index d15f4754f..373fcca31 100644 --- a/src/net/tmwa/gui/partytab.cpp +++ b/src/net/tmwa/gui/partytab.cpp @@ -22,7 +22,7 @@ #include "net/tmwa/gui/partytab.h" -#include "chatlog.h" +#include "chatlogger.h" #include "commandhandler.h" #include "localplayer.h" #include "party.h" diff --git a/src/net/tmwa/guildhandler.cpp b/src/net/tmwa/guildhandler.cpp index 43583971f..640a6fd78 100644 --- a/src/net/tmwa/guildhandler.cpp +++ b/src/net/tmwa/guildhandler.cpp @@ -23,7 +23,7 @@ #include "actorspritemanager.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "playerinfo.h" #include "net/tmwa/messagein.h" diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp index ae79f6842..14a15e59f 100644 --- a/src/net/tmwa/inventoryhandler.cpp +++ b/src/net/tmwa/inventoryhandler.cpp @@ -22,7 +22,7 @@ #include "net/tmwa/inventoryhandler.h" -#include "log.h" +#include "logger.h" #include "net/messagein.h" diff --git a/src/net/tmwa/inventoryhandler.h b/src/net/tmwa/inventoryhandler.h index 405bacc43..9a0978bd0 100644 --- a/src/net/tmwa/inventoryhandler.h +++ b/src/net/tmwa/inventoryhandler.h @@ -23,7 +23,7 @@ #ifndef NET_TA_INVENTORYHANDLER_H #define NET_TA_INVENTORYHANDLER_H -#include "log.h" +#include "logger.h" #include "net/net.h" diff --git a/src/net/tmwa/loginhandler.cpp b/src/net/tmwa/loginhandler.cpp index 15ed2f27c..029c379a0 100644 --- a/src/net/tmwa/loginhandler.cpp +++ b/src/net/tmwa/loginhandler.cpp @@ -23,7 +23,7 @@ #include "net/tmwa/loginhandler.h" #include "client.h" -#include "log.h" +#include "logger.h" #include "configuration.h" #include "net/messagein.h" diff --git a/src/net/tmwa/messagein.cpp b/src/net/tmwa/messagein.cpp index 6e2fcc187..fb1986597 100644 --- a/src/net/tmwa/messagein.cpp +++ b/src/net/tmwa/messagein.cpp @@ -24,7 +24,7 @@ #include "net/packetcounters.h" -#include "log.h" +#include "logger.h" #include "utils/stringutils.h" diff --git a/src/net/tmwa/messageout.cpp b/src/net/tmwa/messageout.cpp index a904b6bbb..6071e0ab6 100644 --- a/src/net/tmwa/messageout.cpp +++ b/src/net/tmwa/messageout.cpp @@ -26,7 +26,7 @@ #include "net/tmwa/network.h" -#include "log.h" +#include "logger.h" #include "utils/stringutils.h" diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp index c2049d3cc..8ecf04d36 100644 --- a/src/net/tmwa/network.cpp +++ b/src/net/tmwa/network.cpp @@ -22,7 +22,7 @@ #include "net/tmwa/network.h" -#include "log.h" +#include "logger.h" #include "net/messagehandler.h" #include "net/messagein.h" diff --git a/src/net/tmwa/partyhandler.cpp b/src/net/tmwa/partyhandler.cpp index 5bbf8baf3..7f942a206 100644 --- a/src/net/tmwa/partyhandler.cpp +++ b/src/net/tmwa/partyhandler.cpp @@ -22,7 +22,7 @@ #include "actorspritemanager.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "net/messagein.h" diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp index f20ea64a0..c34c661e8 100644 --- a/src/net/tmwa/playerhandler.cpp +++ b/src/net/tmwa/playerhandler.cpp @@ -22,7 +22,7 @@ #include "net/tmwa/playerhandler.h" -#include "log.h" +#include "logger.h" #include "net/messagein.h" diff --git a/src/net/tmwa/specialhandler.cpp b/src/net/tmwa/specialhandler.cpp index b175368bd..509c5ecd1 100644 --- a/src/net/tmwa/specialhandler.cpp +++ b/src/net/tmwa/specialhandler.cpp @@ -22,7 +22,7 @@ #include "net/tmwa/specialhandler.h" -#include "log.h" +#include "logger.h" #include "net/messagein.h" diff --git a/src/net/tmwa/tradehandler.cpp b/src/net/tmwa/tradehandler.cpp index 108b544a0..2280079ea 100644 --- a/src/net/tmwa/tradehandler.cpp +++ b/src/net/tmwa/tradehandler.cpp @@ -23,7 +23,7 @@ #include "net/tmwa/tradehandler.h" #include "item.h" -#include "log.h" +#include "logger.h" #include "playerinfo.h" #include "net/messagein.h" diff --git a/src/opengl1graphics.cpp b/src/opengl1graphics.cpp index d40784aff..e93066b96 100644 --- a/src/opengl1graphics.cpp +++ b/src/opengl1graphics.cpp @@ -26,7 +26,7 @@ #include "opengl1graphics.h" #include "graphicsvertexes.h" -#include "log.h" +#include "logger.h" #include "resources/image.h" diff --git a/src/openglgraphics.cpp b/src/openglgraphics.cpp index 6081fa6b3..f918a5c0d 100644 --- a/src/openglgraphics.cpp +++ b/src/openglgraphics.cpp @@ -26,7 +26,7 @@ #include "graphicsvertexes.h" #include "openglgraphics.h" -#include "log.h" +#include "logger.h" #include "resources/image.h" diff --git a/src/particle.cpp b/src/particle.cpp index eca9307ea..7d7a73e9a 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -27,7 +27,7 @@ #include "configuration.h" #include "resources/dye.h" #include "imageparticle.h" -#include "log.h" +#include "logger.h" #include "map.h" #include "particle.h" #include "particleemitter.h" diff --git a/src/particleemitter.cpp b/src/particleemitter.cpp index c04b1b36f..caa48a795 100644 --- a/src/particleemitter.cpp +++ b/src/particleemitter.cpp @@ -22,7 +22,7 @@ #include "animationparticle.h" #include "imageparticle.h" -#include "log.h" +#include "logger.h" #include "particle.h" #include "particleemitter.h" #include "rotationalparticle.h" diff --git a/src/playerinfo.cpp b/src/playerinfo.cpp index 72b091244..3bb196921 100644 --- a/src/playerinfo.cpp +++ b/src/playerinfo.cpp @@ -26,7 +26,7 @@ #include "event.h" #include "inventory.h" #include "listener.h" -#include "log.h" +#include "logger.h" #include "resources/itemdb.h" #include "resources/iteminfo.h" diff --git a/src/properties.h b/src/properties.h index c65e30c22..19354b9ab 100644 --- a/src/properties.h +++ b/src/properties.h @@ -23,7 +23,7 @@ #ifndef PROPERTIES_H #define PROPERTIES_H -#include "log.h" +#include "logger.h" #include <map> #include <sstream> #include <string> diff --git a/src/resources/animation.cpp b/src/resources/animation.cpp index ea7f44199..32b57b3b1 100644 --- a/src/resources/animation.cpp +++ b/src/resources/animation.cpp @@ -22,7 +22,7 @@ #include "resources/animation.h" -#include "log.h" +#include "logger.h" #include "utils/dtor.h" diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp index 6b4f57d81..8beea420d 100644 --- a/src/resources/beinginfo.cpp +++ b/src/resources/beinginfo.cpp @@ -22,7 +22,7 @@ #include "resources/beinginfo.h" -#include "log.h" +#include "logger.h" #include "utils/dtor.h" #include "utils/gettext.h" diff --git a/src/resources/colordb.cpp b/src/resources/colordb.cpp index 72a5e4023..ed8c934dc 100644 --- a/src/resources/colordb.cpp +++ b/src/resources/colordb.cpp @@ -21,7 +21,7 @@ #include "resources/colordb.h" #include "client.h" -#include "log.h" +#include "logger.h" #include "utils/xml.h" diff --git a/src/resources/dye.cpp b/src/resources/dye.cpp index fe7d4bcac..a782b6ec1 100644 --- a/src/resources/dye.cpp +++ b/src/resources/dye.cpp @@ -22,7 +22,7 @@ #include "resources/dye.h" -#include "log.h" +#include "logger.h" #include <math.h> #include <sstream> diff --git a/src/resources/emotedb.cpp b/src/resources/emotedb.cpp index 85a2993dd..b7f7d7901 100644 --- a/src/resources/emotedb.cpp +++ b/src/resources/emotedb.cpp @@ -21,7 +21,7 @@ #include "resources/emotedb.h" #include "animatedsprite.h" -#include "log.h" +#include "logger.h" #include "utils/xml.h" #include "configuration.h" diff --git a/src/resources/image.cpp b/src/resources/image.cpp index b1f83e258..802f2ee12 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -31,7 +31,7 @@ #endif #include "client.h" -#include "log.h" +#include "logger.h" #include "main.h" #include "utils/stringutils.h" diff --git a/src/resources/imageset.cpp b/src/resources/imageset.cpp index 1d41c6e63..5cf3e7d82 100644 --- a/src/resources/imageset.cpp +++ b/src/resources/imageset.cpp @@ -22,7 +22,7 @@ #include "resources/imageset.h" -#include "log.h" +#include "logger.h" #include "resources/image.h" diff --git a/src/resources/imagewriter.cpp b/src/resources/imagewriter.cpp index 5d0bd9d94..e6f3c8c27 100644 --- a/src/resources/imagewriter.cpp +++ b/src/resources/imagewriter.cpp @@ -22,7 +22,7 @@ #include "resources/imagewriter.h" -#include "log.h" +#include "logger.h" #if defined __OpenBSD__ #include <libpng/png.h> diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index 2d14ba687..e60127997 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -23,7 +23,7 @@ #include "resources/itemdb.h" #include "client.h" -#include "log.h" +#include "logger.h" #include "resources/iteminfo.h" #include "resources/resourcemanager.h" @@ -213,7 +213,7 @@ void ItemDB::load() std::string attackAction = XML::getProperty(node, "attack-action", ""); std::string drawBefore = XML::getProperty(node, "drawBefore", ""); std::string drawAfter = XML::getProperty(node, "drawAfter", ""); - std::string removeSprite = XML::getProperty(node, "removeSprite", ""); +// std::string removeSprite = XML::getProperty(node, "removeSprite", ""); std::string colors; if (serverVersion >= 1) colors = XML::getProperty(node, "colors", ""); diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp index 6658236f3..56cfc01f6 100644 --- a/src/resources/iteminfo.cpp +++ b/src/resources/iteminfo.cpp @@ -32,7 +32,7 @@ #include "debug.h" - +/* ItemInfo::ItemInfo(ItemInfo &info) { mMissileParticleFile = info.mMissileParticleFile; @@ -61,6 +61,7 @@ ItemInfo::ItemInfo(ItemInfo &info) mDrawPriority[f] = info.mDrawPriority[f]; } } +*/ ItemInfo::ItemInfo() : mMissileParticleFile(""), diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h index daa9d590c..1fe8f3bad 100644 --- a/src/resources/iteminfo.h +++ b/src/resources/iteminfo.h @@ -107,7 +107,7 @@ class ItemInfo */ ItemInfo(); - ItemInfo(ItemInfo &info); +// ItemInfo(ItemInfo &info); ~ItemInfo(); diff --git a/src/resources/mapdb.cpp b/src/resources/mapdb.cpp index e8aeaf168..e7288e039 100644 --- a/src/resources/mapdb.cpp +++ b/src/resources/mapdb.cpp @@ -23,7 +23,7 @@ #include "configuration.h" #include "client.h" -#include "log.h" +#include "logger.h" #include "utils/xml.h" diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index 35267533f..70c45054f 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -23,7 +23,7 @@ #include "resources/mapreader.h" #include "configuration.h" -#include "log.h" +#include "logger.h" #include "map.h" #include "tileset.h" diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp index 7a0494fc9..dbf9d3e9a 100644 --- a/src/resources/monsterdb.cpp +++ b/src/resources/monsterdb.cpp @@ -22,7 +22,7 @@ #include "resources/monsterdb.h" -#include "log.h" +#include "logger.h" #include "net/net.h" diff --git a/src/resources/music.cpp b/src/resources/music.cpp index ccd1d9280..5ae9a2202 100644 --- a/src/resources/music.cpp +++ b/src/resources/music.cpp @@ -22,7 +22,7 @@ #include "resources/music.h" -#include "log.h" +#include "logger.h" #include "debug.h" diff --git a/src/resources/npcdb.cpp b/src/resources/npcdb.cpp index 49eab5bf2..d04a2518f 100644 --- a/src/resources/npcdb.cpp +++ b/src/resources/npcdb.cpp @@ -22,7 +22,7 @@ #include "resources/npcdb.h" -#include "log.h" +#include "logger.h" #include "resources/beinginfo.h" diff --git a/src/resources/resource.cpp b/src/resources/resource.cpp index 6e986272a..b180712c1 100644 --- a/src/resources/resource.cpp +++ b/src/resources/resource.cpp @@ -23,7 +23,7 @@ #include "resources/resource.h" #include "client.h" -#include "log.h" +#include "logger.h" #include "resources/resourcemanager.h" diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index 92c18fa2a..ee325e253 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -24,7 +24,7 @@ #include "client.h" #include "configuration.h" -#include "log.h" +#include "logger.h" #include "main.h" #include "resources/dye.h" diff --git a/src/resources/soundeffect.cpp b/src/resources/soundeffect.cpp index a01bf21a0..49e7adc31 100644 --- a/src/resources/soundeffect.cpp +++ b/src/resources/soundeffect.cpp @@ -22,7 +22,7 @@ #include "resources/soundeffect.h" -#include "log.h" +#include "logger.h" #include "debug.h" diff --git a/src/resources/specialdb.cpp b/src/resources/specialdb.cpp index 4ab5e2a91..573ffb2a3 100644 --- a/src/resources/specialdb.cpp +++ b/src/resources/specialdb.cpp @@ -21,7 +21,7 @@ #include "resources/specialdb.h" -#include "log.h" +#include "logger.h" #include "utils/dtor.h" #include "utils/xml.h" diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp index b6addba77..dee93e1e7 100644 --- a/src/resources/spritedef.cpp +++ b/src/resources/spritedef.cpp @@ -22,7 +22,7 @@ #include "resources/spritedef.h" -#include "log.h" +#include "logger.h" #include "resources/action.h" #include "resources/animation.h" diff --git a/src/resources/wallpaper.cpp b/src/resources/wallpaper.cpp index 397b87993..09c9f2a04 100644 --- a/src/resources/wallpaper.cpp +++ b/src/resources/wallpaper.cpp @@ -23,7 +23,7 @@ #include "resources/wallpaper.h" #include "resources/resourcemanager.h" -#include "log.h" +#include "logger.h" #include "utils/stringutils.h" #include "configuration.h" diff --git a/src/simpleanimation.cpp b/src/simpleanimation.cpp index e3591f30c..4736b2e57 100644 --- a/src/simpleanimation.cpp +++ b/src/simpleanimation.cpp @@ -23,7 +23,7 @@ #include "simpleanimation.h" #include "graphics.h" -#include "log.h" +#include "logger.h" #include "utils/stringutils.h" diff --git a/src/sound.cpp b/src/sound.cpp index 92a5eaa6f..0a3c75d11 100644 --- a/src/sound.cpp +++ b/src/sound.cpp @@ -24,7 +24,7 @@ #include "configuration.h" #include "localplayer.h" -#include "log.h" +#include "logger.h" #include "sound.h" #include "resources/resourcemanager.h" diff --git a/src/spellmanager.cpp b/src/spellmanager.cpp index 29b99a9a0..a79388350 100644 --- a/src/spellmanager.cpp +++ b/src/spellmanager.cpp @@ -1,9 +1,10 @@ /* - * The Mana World + * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas + * Copyright (C) 2011 ManaPlus developers * - * This file is part of The Mana World. + * 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 @@ -24,7 +25,7 @@ #include "being.h" #include "configuration.h" -#include "log.h" +#include "logger.h" #include "localplayer.h" #include "playerinfo.h" diff --git a/src/spellmanager.h b/src/spellmanager.h index 931302e37..651ada56c 100644 --- a/src/spellmanager.h +++ b/src/spellmanager.h @@ -1,9 +1,10 @@ /* - * The Mana World + * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas + * Copyright (C) 2011 ManaPlus developers * - * This file is part of The Mana World. + * 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 diff --git a/src/spellshortcut.cpp b/src/spellshortcut.cpp index 8a8e55c21..2c5bd253d 100644 --- a/src/spellshortcut.cpp +++ b/src/spellshortcut.cpp @@ -1,9 +1,10 @@ /* - * The Mana World + * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas + * Copyright (C) 2011 ManaPlus developers. * - * This file is part of The Mana World. + * 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 diff --git a/src/spellshortcut.h b/src/spellshortcut.h index 99f899eaa..047ccdef3 100644 --- a/src/spellshortcut.h +++ b/src/spellshortcut.h @@ -1,9 +1,10 @@ /* - * The Mana World + * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas + * Copyright (C) 2011 ManaPlus developers * - * This file is part of The Mana World. + * 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 @@ -24,7 +25,7 @@ #define SPELLSHORTCUT_H #include "spellmanager.h" -#include "log.h" +#include "logger.h" #include "utils/stringutils.h" class TextCommand; diff --git a/src/statuseffect.cpp b/src/statuseffect.cpp index 27e351a45..dccf21f46 100644 --- a/src/statuseffect.cpp +++ b/src/statuseffect.cpp @@ -22,7 +22,7 @@ #include "statuseffect.h" -#include "log.h" +#include "logger.h" #include "sound.h" #include "gui/widgets/chattab.h" diff --git a/src/textcommand.cpp b/src/textcommand.cpp index 836b3c653..665668c7e 100644 --- a/src/textcommand.cpp +++ b/src/textcommand.cpp @@ -1,9 +1,9 @@ /* - * The Mana World + * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas * - * This file is part of The Mana World. + * 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 diff --git a/src/textcommand.h b/src/textcommand.h index dbd621901..5ddbe824d 100644 --- a/src/textcommand.h +++ b/src/textcommand.h @@ -1,9 +1,10 @@ /* - * The Mana World + * The ManaPlus Client * Copyright (C) 2009 The Mana World Development Team * Copyright (C) 2009-2010 Andrei Karas + * Copyright (C) 2011 ManaPlus developers * - * This file is part of The Mana World. + * 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 diff --git a/src/units.cpp b/src/units.cpp index ee0647e2e..db9faadd1 100644 --- a/src/units.cpp +++ b/src/units.cpp @@ -22,7 +22,7 @@ #include "units.h" -#include "log.h" +#include "logger.h" #include "utils/stringutils.h" #include "utils/xml.h" diff --git a/src/utils/mutex.h b/src/utils/mutex.h index f23ddc2aa..03dac2e7a 100644 --- a/src/utils/mutex.h +++ b/src/utils/mutex.h @@ -23,7 +23,7 @@ #ifndef MUTEX_H #define MUTEX_H -#include "log.h" +#include "logger.h" #include <SDL_thread.h> diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index 13170092e..0243c4315 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -181,9 +181,9 @@ unsigned long findI(std::string str, std::string subStr) return str.find(subStr); } -unsigned long findI(std::string str, std::vector<std::string> &list) +unsigned long findI(std::string &text, std::vector<std::string> &list) { - str = toLower(str); + std::string str = toLower(text); unsigned long idx; for (std::vector<std::string>::iterator i = list.begin(); i != list.end(); ++i) @@ -414,6 +414,19 @@ std::list<std::string> splitToStringList(const std::string &text, return tokens; } +void splitToStringVector(std::vector<std::string> &tokens, + const std::string &text, char separator) +{ + std::stringstream ss(text); + std::string item; + while(std::getline(ss, item, separator)) + { + item = trim(item); + if (!item.empty()) + tokens.push_back(item); + } +} + std::string combineDye(std::string file, std::string dye) { if (dye.empty()) diff --git a/src/utils/stringutils.h b/src/utils/stringutils.h index 94747d2fe..4fe6369e9 100644 --- a/src/utils/stringutils.h +++ b/src/utils/stringutils.h @@ -133,7 +133,7 @@ bool isWordSeparator(char chr); unsigned long findI(std::string str, std::string subStr); -unsigned long findI(std::string str, std::vector<std::string> &list); +unsigned long findI(std::string &text, std::vector<std::string> &list); const std::string encodeStr(unsigned int value, unsigned int size = 0); @@ -176,6 +176,9 @@ std::list<int> splitToIntList(const std::string &text, char separator); std::list<std::string> splitToStringList(const std::string &text, char separator); +void splitToStringVector(std::vector<std::string> &tokens, + const std::string &text, char separator); + std::string combineDye(std::string file, std::string dye); std::string combineDye2(std::string file, std::string dye); diff --git a/src/utils/xml.cpp b/src/utils/xml.cpp index b31b60ee1..89457a4e8 100644 --- a/src/utils/xml.cpp +++ b/src/utils/xml.cpp @@ -22,7 +22,7 @@ #include "utils/xml.h" -#include "log.h" +#include "logger.h" #include "resources/resourcemanager.h" |