summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-09-04 20:05:48 +0300
committerAndrei Karas <akaras@inbox.ru>2011-09-04 20:05:48 +0300
commit62ec17f6e489ec50f17219444468aeb8969dc961 (patch)
tree350d7edb5c26c282a4e1906544536d68831228ac /src
parent71d924d7dcdac067f02a317e9353ee067dbd0bde (diff)
parentfd484fc70fca32ff9065b91c175089b65aa3fd26 (diff)
downloadplus-62ec17f6e489ec50f17219444468aeb8969dc961.tar.gz
plus-62ec17f6e489ec50f17219444468aeb8969dc961.tar.bz2
plus-62ec17f6e489ec50f17219444468aeb8969dc961.tar.xz
plus-62ec17f6e489ec50f17219444468aeb8969dc961.zip
Merge branch 'master' into strippedstripped1.1.9.4
Conflicts: data/fonts/mplus-1p-bold.ttf data/fonts/mplus-1p-regular.ttf src/guichan/basiccontainer.cpp src/guichan/include/guichan/basiccontainer.hpp src/guichan/widgets/window.cpp
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt6
-rw-r--r--src/Makefile.am6
-rw-r--r--src/actorsprite.cpp4
-rw-r--r--src/animatedsprite.cpp4
-rw-r--r--src/auctionmanager.cpp89
-rw-r--r--src/auctionmanager.h58
-rw-r--r--src/being.cpp41
-rw-r--r--src/client.cpp24
-rw-r--r--src/client.h2
-rw-r--r--src/commandhandler.cpp12
-rw-r--r--src/compoundsprite.cpp4
-rw-r--r--src/defaults.cpp1
-rw-r--r--src/game.cpp39
-rw-r--r--src/graphics.cpp2
-rw-r--r--src/gui/botcheckerwindow.cpp2
-rw-r--r--src/gui/buydialog.cpp1
-rw-r--r--src/gui/charcreatedialog.cpp3
-rw-r--r--src/gui/charselectdialog.cpp5
-rw-r--r--src/gui/chatwindow.cpp30
-rw-r--r--src/gui/chatwindow.h5
-rw-r--r--src/gui/debugwindow.cpp2
-rw-r--r--src/gui/didyouknowwindow.cpp2
-rw-r--r--src/gui/equipmentwindow.cpp14
-rw-r--r--src/gui/equipmentwindow.h2
-rw-r--r--src/gui/helpwindow.cpp2
-rw-r--r--src/gui/inventorywindow.cpp1
-rw-r--r--src/gui/itemamountwindow.cpp2
-rw-r--r--src/gui/itempopup.cpp3
-rw-r--r--src/gui/killstats.cpp1
-rw-r--r--src/gui/minimap.cpp49
-rw-r--r--src/gui/npcdialog.cpp1
-rw-r--r--src/gui/outfitwindow.cpp10
-rw-r--r--src/gui/outfitwindow.h2
-rw-r--r--src/gui/popupmenu.cpp90
-rw-r--r--src/gui/quitdialog.cpp15
-rw-r--r--src/gui/selldialog.cpp1
-rw-r--r--src/gui/serverdialog.cpp24
-rw-r--r--src/gui/setup.cpp1
-rw-r--r--src/gui/setup_chat.cpp8
-rw-r--r--src/gui/setup_other.cpp9
-rw-r--r--src/gui/setup_players.cpp3
-rw-r--r--src/gui/shopwindow.cpp25
-rw-r--r--src/gui/shopwindow.h2
-rw-r--r--src/gui/skilldialog.cpp13
-rw-r--r--src/gui/socialwindow.cpp175
-rw-r--r--src/gui/specialswindow.cpp1
-rw-r--r--src/gui/spellpopup.cpp5
-rw-r--r--src/gui/statuspopup.cpp29
-rw-r--r--src/gui/statuswindow.cpp7
-rw-r--r--src/gui/textcommandeditor.cpp2
-rw-r--r--src/gui/textpopup.cpp10
-rw-r--r--src/gui/theme.cpp16
-rw-r--r--src/gui/theme.h14
-rw-r--r--src/gui/tradewindow.cpp1
-rw-r--r--src/gui/updaterwindow.cpp76
-rw-r--r--src/gui/updaterwindow.h13
-rw-r--r--src/gui/viewport.cpp48
-rw-r--r--src/gui/viewport.h1
-rw-r--r--src/gui/whoisonline.cpp1
-rw-r--r--src/gui/widgets/avatarlistbox.cpp13
-rw-r--r--src/gui/widgets/avatarlistbox.h1
-rw-r--r--src/gui/widgets/browserbox.cpp37
-rw-r--r--src/gui/widgets/browserbox.h34
-rw-r--r--src/gui/widgets/button.cpp9
-rw-r--r--src/gui/widgets/button.h2
-rw-r--r--src/gui/widgets/chattab.cpp4
-rw-r--r--src/gui/widgets/checkbox.cpp4
-rw-r--r--src/gui/widgets/container.cpp2
-rw-r--r--src/gui/widgets/container.h4
-rw-r--r--src/gui/widgets/desktop.cpp11
-rw-r--r--src/gui/widgets/desktop.h2
-rw-r--r--src/gui/widgets/dropdown.cpp22
-rw-r--r--src/gui/widgets/dropdown.h3
-rw-r--r--src/gui/widgets/dropshortcutcontainer.cpp14
-rw-r--r--src/gui/widgets/dropshortcutcontainer.h2
-rw-r--r--src/gui/widgets/emoteshortcutcontainer.cpp14
-rw-r--r--src/gui/widgets/guildchattab.cpp128
-rw-r--r--src/gui/widgets/guildchattab.h52
-rw-r--r--src/gui/widgets/guitable.cpp16
-rw-r--r--src/gui/widgets/guitable.h3
-rw-r--r--src/gui/widgets/itemcontainer.cpp9
-rw-r--r--src/gui/widgets/itemcontainer.h2
-rw-r--r--src/gui/widgets/itemshortcutcontainer.cpp14
-rw-r--r--src/gui/widgets/itemshortcutcontainer.h3
-rw-r--r--src/gui/widgets/label.cpp1
-rw-r--r--src/gui/widgets/layout.cpp7
-rw-r--r--src/gui/widgets/listbox.cpp8
-rw-r--r--src/gui/widgets/listbox.h1
-rw-r--r--src/gui/widgets/radiobutton.cpp1
-rw-r--r--src/gui/widgets/scrollarea.cpp14
-rw-r--r--src/gui/widgets/scrollarea.h3
-rw-r--r--src/gui/widgets/shoplistbox.cpp40
-rw-r--r--src/gui/widgets/shoplistbox.h6
-rw-r--r--src/gui/widgets/spellshortcutcontainer.cpp4
-rw-r--r--src/gui/widgets/tab.cpp8
-rw-r--r--src/gui/widgets/tab.h2
-rw-r--r--src/gui/widgets/textfield.cpp4
-rw-r--r--src/gui/widgets/window.cpp73
-rw-r--r--src/gui/widgets/window.h15
-rw-r--r--src/guild.cpp21
-rw-r--r--src/guild.h9
-rw-r--r--src/guildmanager.cpp477
-rw-r--r--src/guildmanager.h94
-rw-r--r--src/joystick.cpp5
-rw-r--r--src/localplayer.cpp2
-rw-r--r--src/main.h4
-rw-r--r--src/map.cpp5
-rw-r--r--src/net/ea/beinghandler.cpp4
-rw-r--r--src/net/ea/chathandler.cpp7
-rw-r--r--src/net/ea/guildhandler.cpp1
-rw-r--r--src/net/ea/partyhandler.cpp4
-rw-r--r--src/net/ea/playerhandler.cpp14
-rw-r--r--src/net/ea/playerhandler.h2
-rw-r--r--src/net/manaserv/adminhandler.cpp3
-rw-r--r--src/net/manaserv/adminhandler.h1
-rw-r--r--src/net/manaserv/messagehandler.cpp2
-rw-r--r--src/net/manaserv/playerhandler.cpp5
-rw-r--r--src/net/manaserv/playerhandler.h1
-rw-r--r--src/net/playerhandler.h2
-rw-r--r--src/net/tmwa/beinghandler.cpp5
-rw-r--r--src/net/tmwa/generalhandler.cpp5
-rw-r--r--src/particlecontainer.cpp2
-rw-r--r--src/party.h6
-rw-r--r--src/playerinfo.cpp20
-rw-r--r--src/playerinfo.h7
-rw-r--r--src/resources/imageloader.cpp4
-rw-r--r--src/resources/itemdb.cpp116
-rw-r--r--src/resources/iteminfo.cpp19
-rw-r--r--src/resources/mapreader.cpp6
-rw-r--r--src/resources/resource.cpp2
-rw-r--r--src/utils/stringutils.cpp79
-rw-r--r--src/utils/stringutils.h15
132 files changed, 2157 insertions, 403 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 554fcfbf5..d15b6131a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -139,6 +139,8 @@ SET(SRCS
gui/widgets/emoteshortcutcontainer.h
gui/widgets/flowcontainer.cpp
gui/widgets/flowcontainer.h
+ gui/widgets/guildchattab.cpp
+ gui/widgets/guildchattab.h
gui/widgets/horizontcontainer.cpp
gui/widgets/horizontcontainer.h
gui/widgets/icon.cpp
@@ -468,6 +470,8 @@ SET(SRCS
animatedsprite.h
animationparticle.cpp
animationparticle.h
+ auctionmanager.cpp
+ auctionmanager.h
avatar.cpp
avatar.h
being.cpp
@@ -510,6 +514,8 @@ SET(SRCS
guichanfwd.h
guild.cpp
guild.h
+ guildmanager.cpp
+ guildmanager.h
imageparticle.cpp
imageparticle.h
imagesprite.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index 7263592ff..a0c96a8ec 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -45,6 +45,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
gui/widgets/emoteshortcutcontainer.h \
gui/widgets/flowcontainer.cpp \
gui/widgets/flowcontainer.h \
+ gui/widgets/guildchattab.cpp \
+ gui/widgets/guildchattab.h \
gui/widgets/horizontcontainer.cpp \
gui/widgets/horizontcontainer.h \
gui/widgets/icon.cpp \
@@ -378,6 +380,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
animatedsprite.h \
animationparticle.cpp \
animationparticle.h \
+ auctionmanager.cpp \
+ auctionmanager.h \
avatar.cpp \
avatar.h \
being.cpp \
@@ -420,6 +424,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
guichanfwd.h \
guild.cpp \
guild.h \
+ guildmanager.cpp \
+ guildmanager.h \
imageparticle.cpp \
imageparticle.h \
imagesprite.cpp \
diff --git a/src/actorsprite.cpp b/src/actorsprite.cpp
index 848e84e0f..2b133eca5 100644
--- a/src/actorsprite.cpp
+++ b/src/actorsprite.cpp
@@ -477,9 +477,6 @@ void ActorSprite::loadTargetCursor(const std::string &filename,
if (size < TC_SMALL || size >= NUM_TC)
return;
-// assert(size > -1);
-// assert(size < 3);
-
ResourceManager *resman = ResourceManager::getInstance();
ImageSet *currentImageSet = resman->getImageSet(filename, width, height);
@@ -493,7 +490,6 @@ void ActorSprite::loadTargetCursor(const std::string &filename,
for (unsigned int i = 0; i < currentImageSet->size(); ++i)
{
-// anim->addFrame(currentImageSet->get(i), 0,
anim->addFrame(currentImageSet->get(i), 75,
(16 - (currentImageSet->getWidth() / 2)),
(16 - (currentImageSet->getHeight() / 2)),
diff --git a/src/animatedsprite.cpp b/src/animatedsprite.cpp
index 7414c94bc..27be02e36 100644
--- a/src/animatedsprite.cpp
+++ b/src/animatedsprite.cpp
@@ -32,8 +32,6 @@
#include "utils/xml.h"
-#include <cassert>
-
#include "debug.h"
AnimatedSprite::AnimatedSprite(SpriteDef *sprite):
@@ -46,8 +44,6 @@ AnimatedSprite::AnimatedSprite(SpriteDef *sprite):
mAnimation(0),
mFrame(0)
{
-// assert(mSprite);
-
mAlpha = 1.0f;
// Take possession of the sprite
diff --git a/src/auctionmanager.cpp b/src/auctionmanager.cpp
new file mode 100644
index 000000000..b360279ba
--- /dev/null
+++ b/src/auctionmanager.cpp
@@ -0,0 +1,89 @@
+/*
+ * The ManaPlus Client
+ * 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 "auctionmanager.h"
+
+#include "actorspritemanager.h"
+#include "client.h"
+#include "configuration.h"
+#include "localplayer.h"
+
+#include "net/chathandler.h"
+#include "net/net.h"
+
+#include "utils/gettext.h"
+#include "utils/stringutils.h"
+
+#include "debug.h"
+
+bool AuctionManager::mEnableAuctionBot = false;
+
+AuctionManager::AuctionManager()
+{
+}
+
+AuctionManager::~AuctionManager()
+{
+}
+
+void AuctionManager::init()
+{
+ if (auctionManager)
+ return;
+
+ int val = serverConfig.getValue("enableAuctionBot", -1);
+ if (val == -1)
+ {
+ if (Client::isTmw())
+ val = 1;
+ else
+ val = 0;
+ serverConfig.setValue("enableAuctionBot", val);
+ }
+ mEnableAuctionBot = val;
+ if (mEnableAuctionBot)
+ auctionManager = new AuctionManager();
+}
+
+void AuctionManager::send(std::string msg)
+{
+ Net::getChatHandler()->privateMessage("AuctionBot", msg);
+}
+
+bool AuctionManager::processAuctionMessage(std::string msg)
+{
+ if (msg.size() > 4 && msg[0] == '#' && msg[1] == '#')
+ msg = msg.substr(3);
+
+ return false;
+}
+
+void AuctionManager::clear()
+{
+}
+
+void AuctionManager::reload()
+{
+}
+
+void AuctionManager::sendMail(std::string mail)
+{
+ Net::getChatHandler()->privateMessage("AuctionBot", "!mail " + mail);
+}
diff --git a/src/auctionmanager.h b/src/auctionmanager.h
new file mode 100644
index 000000000..bdc0497ae
--- /dev/null
+++ b/src/auctionmanager.h
@@ -0,0 +1,58 @@
+/*
+ * The ManaPlus Client
+ * 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 AUCTIONMANAGER_H
+#define AUCTIONMANAGER_H
+
+#include "utils/dtor.h"
+
+#include <map>
+#include <string>
+#include <vector>
+
+class AuctionManager
+{
+ public:
+ AuctionManager();
+
+ ~AuctionManager();
+
+ static void init();
+
+ void send(std::string msg);
+
+ bool processAuctionMessage(std::string msg);
+
+ static bool getEnableAuctionBot()
+ { return mEnableAuctionBot; }
+
+ void clear();
+
+ void reload();
+
+ void sendMail(std::string mail);
+
+ private:
+ static bool mEnableAuctionBot;
+};
+
+extern AuctionManager *auctionManager;
+
+#endif // AUCTIONMANAGER_H
diff --git a/src/being.cpp b/src/being.cpp
index d3181c32a..b4c97f15d 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -79,7 +79,6 @@
#include "utils/stringutils.h"
#include "utils/xml.h"
-#include <cassert>
#include <cmath>
#include "debug.h"
@@ -97,6 +96,7 @@ class BeingCacheEntry
mId(id),
mName(""),
mPartyName(""),
+ mGuildName(""),
mLevel(0),
mPvpRank(0),
mTime(0),
@@ -129,9 +129,15 @@ class BeingCacheEntry
void setPartyName(const std::string &name)
{ mPartyName = name; }
+ void setGuildName(const std::string &name)
+ { mGuildName = name; }
+
const std::string &getPartyName() const
{ return mPartyName; }
+ const std::string &getGuildName() const
+ { return mGuildName; }
+
void setLevel(int n)
{ mLevel = n; }
@@ -172,6 +178,7 @@ class BeingCacheEntry
int mId; /**< Unique sprite id */
std::string mName; /**< Name of character */
std::string mPartyName;
+ std::string mGuildName;
int mLevel;
unsigned int mPvpRank;
int mTime;
@@ -752,7 +759,6 @@ void Being::setGuildName(const std::string &name)
mGuildName = name;
}
-
void Being::setGuildPos(const std::string &pos A_UNUSED)
{
// logger->log("Got guild position \"%s\" for being %s(%i)", pos.c_str(), mName.c_str(), mId);
@@ -871,7 +877,11 @@ void Being::updateGuild()
return;
}
if (guild->getMember(getName()))
+ {
setGuild(guild);
+ if (!guild->getName().empty())
+ mGuildName = guild->getName();
+ }
updateColors();
}
@@ -1443,6 +1453,11 @@ int Being::getOffset(char pos, char neg) const
if (mDirection & pos)
offset = -offset;
+ if (offset > 32)
+ offset = 32;
+ if (offset < -32)
+ offset = -32;
+
return offset;
}
@@ -1769,6 +1784,7 @@ bool Being::updateFromCache()
if (!entry->getName().empty())
setName(entry->getName());
setPartyName(entry->getPartyName());
+ setGuildName(entry->getGuildName());
setLevel(entry->getLevel());
setPvpRank(entry->getPvpRank());
setIp(entry->getIp());
@@ -1820,6 +1836,7 @@ void Being::addToCache()
entry->setName(getName());
entry->setLevel(getLevel());
entry->setPartyName(getPartyName());
+ entry->setGuildName(getGuildName());
entry->setTime(cur_time);
entry->setPvpRank(getPvpRank());
entry->setIp(getIp());
@@ -2039,14 +2056,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(
diff --git a/src/client.cpp b/src/client.cpp
index 0e871ed91..ab176c00b 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -23,6 +23,7 @@
#include "client.h"
#include "main.h"
+#include "auctionmanager.h"
#include "chatlogger.h"
#include "configuration.h"
#include "dropshortcut.h"
@@ -30,6 +31,7 @@
#include "event.h"
#include "game.h"
#include "guild.h"
+#include "guildmanager.h"
#include "graphicsvertexes.h"
#include "itemshortcut.h"
#include "keyboardconfig.h"
@@ -112,7 +114,6 @@
#endif
#include <sys/stat.h>
-#include <cassert>
#include <iostream>
#include <fstream>
@@ -254,9 +255,10 @@ Client::Client(const Options &options):
mLimitFps(false),
mConfigAutoSaved(false),
mIsMinimized(false),
+ mInputFocused(true),
+ mMouseFocused(true),
mGuiAlpha(1.0f)
{
- assert(!mInstance);
mInstance = this;
logger = new Logger;
@@ -540,7 +542,7 @@ Client::Client(const Options &options):
loginData.username = mOptions.username;
loginData.password = mOptions.password;
- loginData.remember = serverConfig.getValue("remember", 0);
+ loginData.remember = serverConfig.getValue("remember", 1);
loginData.registerLogin = false;
if (mCurrentServer.hostname.empty())
@@ -786,13 +788,16 @@ int Client::exec()
else
loginData.username = mOptions.username;
- loginData.remember = serverConfig.getValue("remember", 0);
+ loginData.remember = serverConfig.getValue("remember", 1);
Net::connectToServer(mCurrentServer);
if (mumbleManager)
mumbleManager->setServer(mCurrentServer.hostname);
+ GuildManager::init();
+ AuctionManager::init();
+
if (!mConfigAutoSaved)
{
mConfigAutoSaved = true;
@@ -2180,3 +2185,14 @@ void Client::closeDialogs()
NpcDialog::closeAll();
SellDialog::closeAll();
}
+
+bool Client::isTmw()
+{
+ if (getServerName() == "server.themanaworld.org"
+ || Client::getServerName() == "themanaworld.org"
+ || Client::getServerName() == "81.161.192.4")
+ {
+ return true;
+ }
+ return false;
+}
diff --git a/src/client.h b/src/client.h
index 986e06cfb..3edf12674 100644
--- a/src/client.h
+++ b/src/client.h
@@ -260,6 +260,8 @@ public:
static void setFramerate(int fpsLimit);
+ static bool isTmw();
+
void optionChanged(const std::string &name);
void action(const gcn::ActionEvent &event);
diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp
index f650ac8d1..dc962a17d 100644
--- a/src/commandhandler.cpp
+++ b/src/commandhandler.cpp
@@ -22,10 +22,12 @@
#include "commandhandler.h"
+#include "auctionmanager.h"
#include "actorspritemanager.h"
#include "channelmanager.h"
#include "channel.h"
#include "game.h"
+#include "guildmanager.h"
#include "localplayer.h"
#include "logger.h"
#include "main.h"
@@ -497,7 +499,12 @@ void CommandHandler::handleMe(const std::string &args, ChatTab *tab)
return;
const Guild *guild = player_node->getGuild();
if (guild)
- Net::getGuildHandler()->chat(guild->getId(), str);
+ {
+ if (guild->getServerGuild())
+ Net::getGuildHandler()->chat(guild->getId(), str);
+ else if (guildManager)
+ guildManager->chat(str);
+ }
break;
}
default:
@@ -859,7 +866,8 @@ void CommandHandler::handleHack(const std::string &args, ChatTab *tab A_UNUSED)
void CommandHandler::handleMail(const std::string &args, ChatTab *tab A_UNUSED)
{
- Net::getChatHandler()->privateMessage("AuctionBot", "!mail " + args);
+ if (auctionManager && auctionManager->getEnableAuctionBot())
+ auctionManager->sendMail(args);
}
void CommandHandler::handlePriceLoad(const std::string &args A_UNUSED,
diff --git a/src/compoundsprite.cpp b/src/compoundsprite.cpp
index 99fae4f88..c6921b2e8 100644
--- a/src/compoundsprite.cpp
+++ b/src/compoundsprite.cpp
@@ -410,7 +410,11 @@ void CompoundSprite::setAlpha(float alpha)
{
if (alpha != mAlpha)
{
+#ifdef USE_OPENGL
if (mEnableAlphaFix && Image::mUseOpenGL == 0 && size() > 3)
+#else
+ if (mEnableAlphaFix && size() > 3)
+#endif
{
SpriteConstIterator it, it_end;
for (it = begin(), it_end = end(); it != it_end; ++ it)
diff --git a/src/defaults.cpp b/src/defaults.cpp
index 16f4620d4..7c0d8148c 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -216,6 +216,7 @@ DefaultsData* getConfigDefaults()
AddDEF(configData, "disableBeingCaching", false);
AddDEF(configData, "enableReorderSprites", true);
AddDEF(configData, "showip", false);
+ AddDEF(configData, "seflMouseHeal", true);
return configData;
}
diff --git a/src/game.cpp b/src/game.cpp
index 82f919976..5a372a6bd 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -26,19 +26,19 @@
#include "actorspritemanager.h"
#include "actorsprite.h"
+#include "auctionmanager.h"
#include "being.h"
#include "channelmanager.h"
#include "client.h"
#include "commandhandler.h"
#include "configuration.h"
+#include "dropshortcut.h"
#include "effectmanager.h"
-#include "event.h"
-#include "spellmanager.h"
#include "emoteshortcut.h"
+#include "event.h"
+#include "guildmanager.h"
#include "graphics.h"
#include "itemshortcut.h"
-#include "dropshortcut.h"
-#include "spellshortcut.h"
#include "joystick.h"
#include "keyboardconfig.h"
#include "localplayer.h"
@@ -47,6 +47,8 @@
#include "particle.h"
#include "playerrelations.h"
#include "sound.h"
+#include "spellmanager.h"
+#include "spellshortcut.h"
#include "gui/botcheckerwindow.h"
#include "gui/buyselldialog.h"
@@ -156,6 +158,8 @@ Particle *particleEngine = NULL;
EffectManager *effectManager = NULL;
SpellManager *spellManager = NULL;
Viewport *viewport = NULL; /**< Viewport on the map. */
+GuildManager *guildManager = NULL;
+AuctionManager *auctionManager = NULL;
ChatTab *localChatTab = NULL;
ChatTab *debugChatTab = NULL;
@@ -175,6 +179,8 @@ static void initEngines()
commandHandler = new CommandHandler;
channelManager = new ChannelManager;
effectManager = new EffectManager;
+ AuctionManager::init();
+ GuildManager::init();
particleEngine = new Particle(NULL);
particleEngine->setupEngine();
@@ -295,6 +301,12 @@ static void destroyGuiWindows()
if (whoIsOnline)
whoIsOnline->setAllowUpdate(false);
+ if (auctionManager)
+ auctionManager->clear();
+
+ if (guildManager)
+ guildManager->clear();
+
del_0(windowMenu);
del_0(localChatTab) // Need to do this first, so it can remove itself
del_0(debugChatTab)
@@ -327,6 +339,12 @@ static void destroyGuiWindows()
del_0(didYouKnowWindow);
Mana::Event::trigger(CHANNEL_GAME, Mana::Event(EVENT_GUIWINDOWSUNLOADED));
+
+ if (auctionManager && AuctionManager::getEnableAuctionBot())
+ auctionManager->reload();
+
+ if (guildManager && GuildManager::getEnableGuildBot())
+ guildManager->reload();
}
Game *Game::mInstance = 0;
@@ -393,6 +411,9 @@ Game::Game():
setupWindow->setInGame(true);
clearKeysArray();
+ if (guildManager && GuildManager::getEnableGuildBot())
+ guildManager->requestGuildInfo();
+
Mana::Event::trigger(CHANNEL_GAME, Mana::Event(EVENT_CONSTRUCTED));
}
@@ -413,14 +434,16 @@ Game::~Game()
del_0(player_node)
del_0(channelManager)
del_0(commandHandler)
- del_0(effectManager);
+ del_0(effectManager)
del_0(joystick)
del_0(particleEngine)
del_0(viewport)
del_0(mCurrentMap)
- del_0(spellManager);
- del_0(spellShortcut);
- del_0(mumbleManager);
+ del_0(spellManager)
+ del_0(spellShortcut)
+ del_0(auctionManager)
+ del_0(guildManager)
+ del_0(mumbleManager)
Being::clearCache();
diff --git a/src/graphics.cpp b/src/graphics.cpp
index c5dc38b72..abd7341e2 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -20,8 +20,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <cassert>
-
#include "graphics.h"
#include "graphicsvertexes.h"
diff --git a/src/gui/botcheckerwindow.cpp b/src/gui/botcheckerwindow.cpp
index 2851d3d1d..7c0339ead 100644
--- a/src/gui/botcheckerwindow.cpp
+++ b/src/gui/botcheckerwindow.cpp
@@ -290,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")));
@@ -303,6 +302,7 @@ BotCheckerWindow::BotCheckerWindow():
setWindowName("BotCheckerWindow");
setCloseButton(true);
+ setStickyButtonLock(true);
setDefaultSize(w, h, ImageRect::CENTER);
playersScrollArea = new ScrollArea(mTable);
diff --git a/src/gui/buydialog.cpp b/src/gui/buydialog.cpp
index 04dd425c1..8c1ad62ce 100644
--- a/src/gui/buydialog.cpp
+++ b/src/gui/buydialog.cpp
@@ -72,6 +72,7 @@ void BuyDialog::init()
setWindowName("Buy");
setResizable(true);
setCloseButton(true);
+ setStickyButtonLock(true);
setMinWidth(260);
setMinHeight(230);
setDefaultSize(260, 230, ImageRect::CENTER);
diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp
index 91c284985..d1773e7f3 100644
--- a/src/gui/charcreatedialog.cpp
+++ b/src/gui/charcreatedialog.cpp
@@ -60,6 +60,9 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot):
mRace(0),
mSlot(slot)
{
+ setStickyButtonLock(true);
+ setSticky(true);
+
mPlayer = new Being(0, ActorSprite::PLAYER, mRace, NULL);
mPlayer->setGender(GENDER_MALE);
diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp
index 28c7a083c..1942ebaeb 100644
--- a/src/gui/charselectdialog.cpp
+++ b/src/gui/charselectdialog.cpp
@@ -60,7 +60,6 @@
#include <guichan/font.hpp>
#include <string>
-#include <cassert>
#include "debug.h"
@@ -342,8 +341,8 @@ void CharSelectDialog::setCharacters(const Net::Characters &characters)
void CharSelectDialog::lock()
{
- assert(!mLocked);
- setLocked(true);
+ if (!mLocked)
+ setLocked(true);
}
void CharSelectDialog::unlock()
diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp
index 1ef3139db..784fb812a 100644
--- a/src/gui/chatwindow.cpp
+++ b/src/gui/chatwindow.cpp
@@ -167,6 +167,8 @@ ChatWindow::ChatWindow():
setResizable(true);
setDefaultVisible(true);
setSaveVisible(true);
+ setStickyButtonLock(true);
+
setDefaultSize(600, 123, ImageRect::LOWER_LEFT);
setMinWidth(150);
setMinHeight(90);
@@ -211,6 +213,7 @@ ChatWindow::ChatWindow():
fillCommands();
initTradeFilter();
loadCustomList();
+ parseHighlights();
}
ChatWindow::~ChatWindow()
@@ -659,7 +662,7 @@ void ChatWindow::mouseDragged(gcn::MouseEvent &event)
if (event.isConsumed())
return;
- if (isMovable() && mMoved)
+ if (canMove() && isMovable() && mMoved)
{
int newX = std::max(0, getX() + event.getX() - mDragOffsetX);
int newY = std::max(0, getY() + event.getY() - mDragOffsetY);
@@ -1458,12 +1461,8 @@ void ChatWindow::saveState()
std::string ChatWindow::doReplace(const std::string &msg)
{
- if (Client::getServerName() == "server.themanaworld.org"
- || Client::getServerName() == "themanaworld.org"
- || Client::getServerName() == "81.161.192.4")
- {
+ if (Client::isTmw())
return msg;
- }
std::string str = msg;
replaceSpecialChars(str);
@@ -1503,7 +1502,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);
}
@@ -1520,3 +1519,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/debugwindow.cpp b/src/gui/debugwindow.cpp
index 0b84dda1e..dc540a782 100644
--- a/src/gui/debugwindow.cpp
+++ b/src/gui/debugwindow.cpp
@@ -60,6 +60,8 @@ DebugWindow::DebugWindow():
setResizable(true);
setCloseButton(true);
setSaveVisible(true);
+ setStickyButtonLock(true);
+
setDefaultSize(400, 150, ImageRect::CENTER);
mTabs = new TabbedArea;
diff --git a/src/gui/didyouknowwindow.cpp b/src/gui/didyouknowwindow.cpp
index 4d89bd924..d62417fc4 100644
--- a/src/gui/didyouknowwindow.cpp
+++ b/src/gui/didyouknowwindow.cpp
@@ -51,6 +51,8 @@ DidYouKnowWindow::DidYouKnowWindow():
setContentSize(455, 350);
setWindowName("DidYouKnow");
setResizable(true);
+ setStickyButtonLock(true);
+
setupWindow->registerWindowForReset(this);
setDefaultSize(500, 400, ImageRect::CENTER);
diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp
index 67ec78e49..0375d096f 100644
--- a/src/gui/equipmentwindow.cpp
+++ b/src/gui/equipmentwindow.cpp
@@ -80,6 +80,8 @@ EquipmentWindow::EquipmentWindow(Equipment *equipment, Being *being,
setCloseButton(true);
setSaveVisible(true);
+ setStickyButtonLock(true);
+
setDefaultSize(180, 345, ImageRect::CENTER);
mBoxes.reserve(13);
@@ -99,6 +101,9 @@ EquipmentWindow::EquipmentWindow(Equipment *equipment, Being *being,
add(mPlayerBox);
add(mUnequip);
+ mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT);
+ mBorderColor = Theme::getThemeColor(Theme::BORDER);
+ setForegroundColor(Theme::getThemeColor(Theme::TEXT));
}
EquipmentWindow::~EquipmentWindow()
@@ -138,16 +143,15 @@ void EquipmentWindow::draw(gcn::Graphics *graphics)
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->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(box->first, box->second,
BOX_WIDTH, BOX_HEIGHT));
@@ -167,7 +171,7 @@ void EquipmentWindow::draw(gcn::Graphics *graphics)
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()),
box->first + (BOX_WIDTH / 2),
box->second - fontHeight,
diff --git a/src/gui/equipmentwindow.h b/src/gui/equipmentwindow.h
index c59600dd8..cadf27620 100644
--- a/src/gui/equipmentwindow.h
+++ b/src/gui/equipmentwindow.h
@@ -116,6 +116,8 @@ class EquipmentWindow : public Window, public gcn::ActionListener
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/helpwindow.cpp b/src/gui/helpwindow.cpp
index 368049389..b772ea36a 100644
--- a/src/gui/helpwindow.cpp
+++ b/src/gui/helpwindow.cpp
@@ -47,6 +47,8 @@ HelpWindow::HelpWindow():
setContentSize(455, 350);
setWindowName("Help");
setResizable(true);
+ setStickyButtonLock(true);
+
setupWindow->registerWindowForReset(this);
setDefaultSize(500, 400, ImageRect::CENTER);
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index 3b7b7b273..d0454c4e1 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -89,6 +89,7 @@ InventoryWindow::InventoryWindow(Inventory *inventory):
setResizable(true);
setCloseButton(true);
setSaveVisible(true);
+ setStickyButtonLock(true);
setDefaultSize(387, 307, ImageRect::CENTER);
setMinWidth(316);
diff --git a/src/gui/itemamountwindow.cpp b/src/gui/itemamountwindow.cpp
index a3f591634..059f3d785 100644
--- a/src/gui/itemamountwindow.cpp
+++ b/src/gui/itemamountwindow.cpp
@@ -63,7 +63,7 @@ public:
if (i->first < 0)
continue;
- ItemInfo info = (*i->second);
+ const ItemInfo &info = (*i->second);
std::string name = info.getName();
if (name != "unnamed" && !info.getName().empty()
&& info.getName() != "unnamed")
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 05a265da7..b9ce7c2a7 100644
--- a/src/gui/killstats.cpp
+++ b/src/gui/killstats.cpp
@@ -55,6 +55,7 @@ KillStats::KillStats():
setWindowName("Kill stats");
setCloseButton(true);
setResizable(true);
+ setStickyButtonLock(true);
setDefaultSize(250, 250, 350, 300);
listen(Mana::CHANNEL_ATTRIBUTES);
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp
index c735eec82..c3a4417f6 100644
--- a/src/gui/minimap.cpp
+++ b/src/gui/minimap.cpp
@@ -29,6 +29,7 @@
#include "localplayer.h"
#include "logger.h"
#include "map.h"
+#include "party.h"
#include "gui/userpalette.h"
#include "gui/setup.h"
@@ -275,9 +276,10 @@ void Minimap::draw(gcn::Graphics *graphics)
{
type = UserPalette::GM;
}
- else if (being->isInParty())
+ else if (being->getGuild() == player_node->getGuild()
+ || being->getGuildName() == player_node->getGuildName())
{
- type = UserPalette::PARTY;
+ type = UserPalette::GUILD;
}
else if (being)
{
@@ -317,6 +319,49 @@ void Minimap::draw(gcn::Graphics *graphics)
dotSize, dotSize));
}
+ if (player_node->isInParty())
+ {
+ Party *party = player_node->getParty();
+ if (party)
+ {
+ PartyMember *m = party->getMember(player_node->getName());
+ Party::MemberList *members = party->getMembers();
+ if (m && members)
+ {
+ const std::string curMap = m->getMap();
+ Party::MemberList::const_iterator it = members->begin();
+ const Party::MemberList::const_iterator
+ it_end = members->end();
+ while (it != it_end)
+ {
+ PartyMember *member = *it;
+ if (member && member->getMap() == curMap
+ && member->getOnline() && member != m)
+ {
+ if (userPalette)
+ {
+ graphics->setColor(userPalette->getColor(
+ UserPalette::PARTY));
+ }
+
+ const int offsetHeight = static_cast<int>(
+ mHeightProportion);
+ const int offsetWidth = static_cast<int>(
+ mWidthProportion);
+
+ graphics->fillRectangle(gcn::Rectangle(
+ static_cast<int>(member->getX()
+ * mWidthProportion) + mapOriginX - offsetWidth,
+ static_cast<int>(member->getY()
+ * mHeightProportion) + mapOriginY - offsetHeight,
+ 2, 2));
+ }
+ ++ it;
+ }
+ }
+ }
+ }
+
const Vector &pos = player_node->getPosition();
// logger->log("width:" + toString(graph->getWidth()));
diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp
index 36677446d..0db618d69 100644
--- a/src/gui/npcdialog.cpp
+++ b/src/gui/npcdialog.cpp
@@ -69,6 +69,7 @@ NpcDialog::NpcDialog(int npcId)
setResizable(true);
//setupWindow->registerWindowForReset(this);
setFocusable(true);
+ setStickyButtonLock(true);
setMinWidth(200);
setMinHeight(150);
diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp
index 09e75856f..9601e3ca5 100644
--- a/src/gui/outfitwindow.cpp
+++ b/src/gui/outfitwindow.cpp
@@ -32,6 +32,7 @@
#include "playerinfo.h"
#include "gui/chatwindow.h"
+#include "gui/theme.h"
#include "gui/viewport.h"
#include "gui/widgets/button.h"
@@ -71,11 +72,14 @@ OutfitWindow::OutfitWindow():
setWindowName("Outfits");
setResizable(true);
setCloseButton(true);
+ setStickyButtonLock(true);
+
setDefaultSize(250, 400, 150, 230);
setMinWidth(145);
setMinHeight(220);
- addMouseListener(this);
+ mBorderColor = Theme::getThemeColor(Theme::BORDER, 64);
+ mBackgroundColor = Theme::getThemeColor(Theme::BACKGROUND, 32);
mPreviousButton = new Button(_("<"), "previous", this);
mNextButton = new Button(_(">"), "next", this);
@@ -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/popupmenu.cpp b/src/gui/popupmenu.cpp
index eefa83500..0eac0a4f9 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -27,6 +27,7 @@
#include "being.h"
#include "dropshortcut.h"
#include "guild.h"
+#include "guildmanager.h"
#include "flooritem.h"
#include "graphics.h"
#include "item.h"
@@ -77,8 +78,6 @@
#include "utils/gettext.h"
#include "utils/stringutils.h"
-#include <cassert>
-
#include "debug.h"
std::string tradePartnerName("");
@@ -224,14 +223,33 @@ void PopupMenu::showPopup(int x, int y, Being *being)
{
mBrowserBox->addRow(strprintf(
"@@guild-kick|%s@@", _("Kick from guild")));
- mBrowserBox->addRow(strprintf("@@guild-pos|%s >@@",
+ if (guild2->getServerGuild())
+ {
+ mBrowserBox->addRow(strprintf(
+ "@@guild-pos|%s >@@",
+ _("Change pos in guild")));
+ }
+ }
+ }
+ else if (guild2->getMember(mNick))
+ {
+ mBrowserBox->addRow(strprintf(
+ "@@guild-kick|%s@@", _("Kick from guild")));
+ if (guild2->getServerGuild())
+ {
+ mBrowserBox->addRow(strprintf(
+ "@@guild-pos|%s >@@",
_("Change pos in guild")));
}
}
else
{
- mBrowserBox->addRow(strprintf(
- "@@guild|%s@@", _("Invite to guild")));
+ if (guild2->getServerGuild()
+ || (guildManager && guildManager->havePower()))
+ {
+ mBrowserBox->addRow(strprintf(
+ "@@guild|%s@@", _("Invite to guild")));
+ }
}
}
@@ -435,15 +453,26 @@ void PopupMenu::showPlayerPopup(int x, int y, std::string nick)
{
if (guild2->getMember(mNick))
{
- mBrowserBox->addRow(strprintf(
- "@@guild-kick|%s@@", _("Kick from guild")));
- mBrowserBox->addRow(strprintf(
- "@@guild-pos|%s >@@", _("Change pos in guild")));
+ if (guild2->getServerGuild() || (guildManager
+ && guildManager->havePower()))
+ {
+ mBrowserBox->addRow(strprintf(
+ "@@guild-kick|%s@@", _("Kick from guild")));
+ }
+ if (guild2->getServerGuild())
+ {
+ mBrowserBox->addRow(strprintf(
+ "@@guild-pos|%s >@@", _("Change pos in guild")));
+ }
}
else
{
- mBrowserBox->addRow(strprintf(
- "@@guild|%s@@", _("Invite to guild")));
+ if (guild2->getServerGuild() || (guildManager
+ && guildManager->havePower()))
+ {
+ mBrowserBox->addRow(strprintf(
+ "@@guild|%s@@", _("Invite to guild")));
+ }
}
}
@@ -574,7 +603,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
{
@@ -725,16 +754,27 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab)
{
if (guild1->getId() == guild2->getId())
{
- mBrowserBox->addRow(strprintf(
- "@@guild-kick|%s@@", _("Kick from guild")));
- mBrowserBox->addRow(strprintf(
- "@@guild-pos|%s >@@", _("Change pos in guild")));
+ if (guild2->getServerGuild() || (guildManager
+ && guildManager->havePower()))
+ {
+ mBrowserBox->addRow(strprintf(
+ "@@guild-kick|%s@@", _("Kick from guild")));
+ }
+ if (guild2->getServerGuild())
+ {
+ mBrowserBox->addRow(strprintf("@@guild-pos|%s >@@",
+ _("Change pos in guild")));
+ }
}
}
else
{
- mBrowserBox->addRow(strprintf(
- "@@guild|%s@@", _("Invite to guild")));
+ if (guild2->getServerGuild() || (guildManager
+ && guildManager->havePower()))
+ {
+ mBrowserBox->addRow(strprintf(
+ "@@guild|%s@@", _("Invite to guild")));
+ }
}
}
}
@@ -897,7 +937,12 @@ void PopupMenu::handleLink(const std::string &link,
{
const Guild *guild = player_node->getGuild();
if (guild)
- Net::getGuildHandler()->invite(guild->getId(), mNick);
+ {
+ if (guild->getServerGuild())
+ Net::getGuildHandler()->invite(guild->getId(), mNick);
+ else if (guildManager)
+ guildManager->invite(mNick);
+ }
}
}
else if (link == "nuke" && being)
@@ -1263,7 +1308,12 @@ void PopupMenu::handleLink(const std::string &link,
{
const Guild *guild = player_node->getGuild();
if (guild)
- Net::getGuildHandler()->kick(guild->getMember(mNick));
+ {
+ if (guild->getServerGuild())
+ Net::getGuildHandler()->kick(guild->getMember(mNick));
+ else if (guildManager)
+ guildManager->kick(mNick);
+ }
}
}
else if (link == "enable highlight" && mTab)
diff --git a/src/gui/quitdialog.cpp b/src/gui/quitdialog.cpp
index f66872b5d..04f43fb88 100644
--- a/src/gui/quitdialog.cpp
+++ b/src/gui/quitdialog.cpp
@@ -41,23 +41,17 @@
#include "utils/gettext.h"
-#include <assert.h>
-
#include "debug.h"
QuitDialog::QuitDialog(QuitDialog** pointerToMe):
Window(_("Quit"), true, NULL), mMyPointer(pointerToMe)
{
-// int width = 200;
-// int height = 120;
-
mForceQuit = new RadioButton(_("Quit"), "quitdialog");
mLogoutQuit = new RadioButton(_("Quit"), "quitdialog");
mSwitchAccountServer = new RadioButton(_("Switch server"), "quitdialog");
mSwitchCharacter = new RadioButton(_("Switch character"), "quitdialog");
mOkButton = new Button(_("OK"), "ok", this);
mCancelButton = new Button(_("Cancel"), "cancel", this);
-// setContentSize(width, height);
addKeyListener(this);
@@ -149,10 +143,11 @@ void QuitDialog::action(const gcn::ActionEvent &event)
}
else if (mSwitchCharacter->isSelected())
{
- assert(Client::getState() == STATE_GAME);
-
- Net::getCharHandler()->switchCharacter();
- Client::closeDialogs();
+ if (Client::getState() == STATE_GAME)
+ {
+ Net::getCharHandler()->switchCharacter();
+ Client::closeDialogs();
+ }
}
}
scheduleDelete();
diff --git a/src/gui/selldialog.cpp b/src/gui/selldialog.cpp
index cf9bfb667..d9030e3fb 100644
--- a/src/gui/selldialog.cpp
+++ b/src/gui/selldialog.cpp
@@ -69,6 +69,7 @@ void SellDialog::init()
//setupWindow->registerWindowForReset(this);
setResizable(true);
setCloseButton(true);
+ setStickyButtonLock(true);
setMinWidth(260);
setMinHeight(230);
setDefaultSize(260, 230, ImageRect::CENTER);
diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp
index 143d3e5a3..763c190d6 100644
--- a/src/gui/serverdialog.cpp
+++ b/src/gui/serverdialog.cpp
@@ -158,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)
@@ -169,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
@@ -191,7 +193,7 @@ public:
{
ServerInfo info = model->getServer(i);
- graphics->setColor(Theme::getThemeColor(Theme::TEXT));
+ graphics->setColor(mTextColor);
int top;
@@ -212,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);
@@ -224,6 +226,10 @@ public:
{
return 2 * getFont()->getHeight();
}
+private:
+ gcn::Color mHighlightColor;
+ gcn::Color mTextColor;
+ gcn::Color mNotSupportedColor;
};
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp
index 690871189..76e3936c2 100644
--- a/src/gui/setup.cpp
+++ b/src/gui/setup.cpp
@@ -55,6 +55,7 @@ Setup::Setup():
{
setCloseButton(true);
setResizable(true);
+ setStickyButtonLock(true);
int width = 620;
int height = 450;
diff --git a/src/gui/setup_chat.cpp b/src/gui/setup_chat.cpp
index 722a3f8b2..9e75b9c0a 100644
--- a/src/gui/setup_chat.cpp
+++ b/src/gui/setup_chat.cpp
@@ -120,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));
}
@@ -128,5 +133,8 @@ void Setup_Chat::apply()
SetupTabScroll::apply();
if (chatWindow)
+ {
chatWindow->adjustTabSize();
+ chatWindow->parseHighlights();
+ }
}
diff --git a/src/gui/setup_other.cpp b/src/gui/setup_other.cpp
index b405f5045..1cad4c594 100644
--- a/src/gui/setup_other.cpp
+++ b/src/gui/setup_other.cpp
@@ -145,6 +145,15 @@ Setup_Other::Setup_Other()
this, "logNpcInGuiEvent");
+ new SetupItemLabel(_("Bots support"), "", this);
+
+ new SetupItemCheckBox(_("Enable auction bot support"), "",
+ "enableAuctionBot", this, "enableAuctionBotEvent", false);
+
+ new SetupItemCheckBox(_("Enable guild bot support and disable native "
+ "guild support"), "", "enableGuildBot", this,
+ "enableGuildBotEvent", false);
+
new SetupItemLabel(_("Other"), "", this);
new SetupItemCheckBox(_("Enable server side attack"), "",
diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp
index 78c77f6f1..670fc3635 100644
--- a/src/gui/setup_players.cpp
+++ b/src/gui/setup_players.cpp
@@ -78,6 +78,9 @@ Setup_Players::Setup_Players()
new SetupItemCheckBox(_("Show ip addresses on screenshots"), "",
"showip", this, "showipEvent");
+ new SetupItemCheckBox(_("Allow self heal with mouse click"), "",
+ "selfMouseHeal", this, "selfMouseHealEvent");
+
setDimension(gcn::Rectangle(0, 0, 550, 350));
}
diff --git a/src/gui/shopwindow.cpp b/src/gui/shopwindow.cpp
index 4311a04d2..9aaf88bf3 100644
--- a/src/gui/shopwindow.cpp
+++ b/src/gui/shopwindow.cpp
@@ -40,6 +40,7 @@
#include "gui/widgets/tradetab.h"
#include "actorspritemanager.h"
+#include "auctionmanager.h"
#include "configuration.h"
#include "confirmdialog.h"
#include "inventory.h"
@@ -85,6 +86,7 @@ ShopWindow::ShopWindow():
setWindowName("Personal Shop");
setResizable(true);
setCloseButton(true);
+ setStickyButtonLock(true);
setMinWidth(260);
setMinHeight(230);
setDefaultSize(380, 300, ImageRect::CENTER);
@@ -141,6 +143,19 @@ ShopWindow::ShopWindow():
place(0, 7, mAnnounceLinks, 8);
place(15, 7, mCloseButton);
+ if (auctionManager && auctionManager->getEnableAuctionBot())
+ {
+ mBuyAuctionButton = new Button(_("Auction"), "auction buy", this);
+ mSellAuctionButton = new Button(_("Auction"), "auction sell", this);
+ place(4, 6, mBuyAuctionButton);
+ place(12, 6, mSellAuctionButton);
+ }
+ else
+ {
+ mBuyAuctionButton = 0;
+ mSellAuctionButton = 0;
+ }
+
Layout &layout = getLayout();
layout.setRowHeight(0, Layout::AUTO_SET);
@@ -207,6 +222,16 @@ void ShopWindow::action(const gcn::ActionEvent &event)
{
announce(mSellShopItems, SELL);
}
+ else if (event.getId() == "auction buy" && mBuyShopItems
+ && mBuyShopItems->getNumberOfElements() > 0)
+ {
+ Net::getChatHandler()->privateMessage("AuctionBot", "!pull4144 seek");
+ }
+ else if (event.getId() == "auction sell" && mSellShopItems
+ && mSellShopItems->getNumberOfElements() > 0)
+ {
+ Net::getChatHandler()->privateMessage("AuctionBot", "!pull4144 offer");
+ }
if (mSelectedItem < 1)
return;
diff --git a/src/gui/shopwindow.h b/src/gui/shopwindow.h
index e3fd9a5ca..8b170f31e 100644
--- a/src/gui/shopwindow.h
+++ b/src/gui/shopwindow.h
@@ -151,9 +151,11 @@ class ShopWindow : public Window, public gcn::ActionListener,
gcn::Button *mBuyAddButton;
gcn::Button *mBuyDeleteButton;
gcn::Button *mBuyAnnounceButton;
+ gcn::Button *mBuyAuctionButton;
gcn::Button *mSellAddButton;
gcn::Button *mSellDeleteButton;
gcn::Button *mSellAnnounceButton;
+ gcn::Button *mSellAuctionButton;
gcn::CheckBox *mAnnounceLinks;
ShopItems *mBuyShopItems;
diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp
index 896f06cab..bf87e804d 100644
--- a/src/gui/skilldialog.cpp
+++ b/src/gui/skilldialog.cpp
@@ -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
@@ -275,6 +279,7 @@ SkillDialog::SkillDialog():
setCloseButton(true);
setResizable(true);
setSaveVisible(true);
+ setStickyButtonLock(true);
setDefaultSize(windowContainer->getWidth() - 280, 30, 275, 425);
setupWindow->registerWindowForReset(this);
diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp
index e3aa69b30..749f26f85 100644
--- a/src/gui/socialwindow.cpp
+++ b/src/gui/socialwindow.cpp
@@ -23,6 +23,7 @@
#include "actorspritemanager.h"
#include "guild.h"
+#include "guildmanager.h"
#include "keyboardconfig.h"
#include "localplayer.h"
#include "logger.h"
@@ -108,10 +109,10 @@ protected:
AvatarListBox *mList;
};
-class GuildTab : public SocialTab, public gcn::ActionListener
+class SocialGuildTab : public SocialTab, public gcn::ActionListener
{
public:
- GuildTab(Guild *guild):
+ SocialGuildTab(Guild *guild):
mGuild(guild)
{
setCaption(_("Guild"));
@@ -125,7 +126,7 @@ public:
mScroll->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_ALWAYS);
}
- ~GuildTab()
+ ~SocialGuildTab()
{
delete mList;
mList = 0;
@@ -206,10 +207,113 @@ private:
Guild *mGuild;
};
-class PartyTab : public SocialTab, public gcn::ActionListener
+class SocialGuildTab2 : public SocialTab, public gcn::ActionListener
{
public:
- PartyTab(Party *party):
+ SocialGuildTab2(Guild *guild):
+ mGuild(guild)
+ {
+ setCaption(_("Guild"));
+
+ setTabColor(&Theme::getThemeColor(Theme::GUILD_SOCIAL_TAB));
+
+ mList = new AvatarListBox(guild);
+ mScroll = new ScrollArea(mList);
+
+ mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_AUTO);
+ mScroll->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_ALWAYS);
+ }
+
+ ~SocialGuildTab2()
+ {
+ delete mList;
+ mList = 0;
+ delete mScroll;
+ mScroll = 0;
+ }
+
+ void action(const gcn::ActionEvent &event)
+ {
+/*
+ if (event.getId() == "do invite")
+ {
+ std::string name = mInviteDialog->getText();
+ Net::getGuildHandler()->invite(mGuild->getId(), name);
+
+ if (localChatTab)
+ {
+ localChatTab->chatLog(strprintf(
+ _("Invited user %s to guild %s."),
+ name.c_str(), mGuild->getName().c_str()), BY_SERVER);
+ }
+ mInviteDialog = 0;
+ }
+ else if (event.getId() == "~do invite")
+ {
+ mInviteDialog = 0;
+ }
+ else if (event.getId() == "yes")
+ {
+ Net::getGuildHandler()->leave(mGuild->getId());
+ if (localChatTab)
+ {
+ localChatTab->chatLog(strprintf(_("Guild %s quit requested."),
+ mGuild->getName().c_str()), BY_SERVER);
+ }
+ mConfirmDialog = 0;
+ }
+ else if (event.getId() == "~yes")
+ {
+ mConfirmDialog = 0;
+ }
+*/
+ }
+
+ void updateList()
+ {
+ }
+
+ void updateAvatar(std::string name A_UNUSED)
+ {
+ }
+
+ void resetDamage(std::string name A_UNUSED)
+ {
+ }
+
+protected:
+ void invite()
+ {
+/*
+ mInviteDialog = new TextDialog(_("Member Invite to Guild"),
+ strprintf(_("Who would you like to invite to guild %s?"),
+ mGuild->getName().c_str()),
+ socialWindow);
+ mInviteDialog->setActionEventId("do invite");
+ mInviteDialog->addActionListener(this);
+*/
+ }
+
+ void leave()
+ {
+/*
+ mConfirmDialog = new ConfirmDialog(_("Leave Guild?"),
+ strprintf(_("Are you sure you want to leave guild %s?"),
+ mGuild->getName().c_str()),
+ socialWindow);
+
+ mConfirmDialog->addActionListener(this);
+*/
+ }
+
+private:
+ Guild *mGuild;
+};
+
+class SocialPartyTab : public SocialTab, public gcn::ActionListener
+{
+public:
+ SocialPartyTab(Party *party):
mParty(party)
{
setCaption(_("Party"));
@@ -223,7 +327,7 @@ public:
mScroll->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_ALWAYS);
}
- ~PartyTab()
+ ~SocialPartyTab()
{
delete mList;
mList = 0;
@@ -340,10 +444,10 @@ public:
std::vector<Avatar*> mMembers;
};
-class PlayersTab : public SocialTab
+class SocialPlayersTab : public SocialTab
{
public:
- PlayersTab(std::string name)
+ SocialPlayersTab(std::string name)
{
mBeings = new BeingsListModal();
@@ -358,7 +462,7 @@ public:
setCaption(name);
}
- ~PlayersTab()
+ ~SocialPlayersTab()
{
delete mList;
mList = 0;
@@ -505,10 +609,10 @@ private:
};
-class NavigationTab : public SocialTab
+class SocialNavigationTab : public SocialTab
{
public:
- NavigationTab()
+ SocialNavigationTab()
{
mBeings = new BeingsListModal();
@@ -522,7 +626,7 @@ public:
}
- ~NavigationTab()
+ ~SocialNavigationTab()
{
delete mList;
mList = 0;
@@ -783,10 +887,10 @@ protected:
};
-class AttackTab : public SocialTab
+class SocialAttackTab : public SocialTab
{
public:
- AttackTab()
+ SocialAttackTab()
{
mBeings = new BeingsListModal();
@@ -799,7 +903,7 @@ public:
setCaption(_("Atk"));
}
- ~AttackTab()
+ ~SocialAttackTab()
{
delete mList;
mList = 0;
@@ -1025,6 +1129,8 @@ SocialWindow::SocialWindow() :
setResizable(true);
setSaveVisible(true);
setCloseButton(true);
+ setStickyButtonLock(true);
+
setMinWidth(120);
setMinHeight(55);
setDefaultSize(590, 200, 150, 120);
@@ -1046,15 +1152,15 @@ SocialWindow::SocialWindow() :
loadWindowState();
- mPlayers = new PlayersTab("P");
+ mPlayers = new SocialPlayersTab("P");
mTabs->addTab(mPlayers, mPlayers->mScroll);
- mNavigation = new NavigationTab();
+ mNavigation = new SocialNavigationTab();
mTabs->addTab(mNavigation, mNavigation->mScroll);
if (config.getBoolValue("enableAttackFilter"))
{
- mAttackFilter = new AttackTab();
+ mAttackFilter = new SocialAttackTab();
mTabs->addTab(mAttackFilter, mAttackFilter->mScroll);
}
else
@@ -1106,9 +1212,13 @@ bool SocialWindow::addTab(Guild *guild)
if (mGuilds.find(guild) != mGuilds.end())
return false;
- GuildTab *tab = new GuildTab(guild);
- mGuilds[guild] = tab;
+ SocialTab *tab = 0;
+ if (guild->getServerGuild())
+ tab = new SocialGuildTab(guild);
+ else
+ tab = new SocialGuildTab2(guild);
+ mGuilds[guild] = tab;
mTabs->addTab(tab, tab->mScroll);
updateButtons();
@@ -1136,7 +1246,7 @@ bool SocialWindow::addTab(Party *party)
if (mParties.find(party) != mParties.end())
return false;
- PartyTab *tab = new PartyTab(party);
+ SocialPartyTab *tab = new SocialPartyTab(party);
mParties[party] = tab;
mTabs->addTab(tab, tab->mScroll);
@@ -1203,7 +1313,10 @@ void SocialWindow::action(const gcn::ActionEvent &event)
strprintf(_("Accepted guild invite from %s."),
mPartyInviter.c_str()));
}
- Net::getGuildHandler()->inviteResponse(mGuildInvited, true);
+ if (!guildManager || !GuildManager::getEnableGuildBot())
+ Net::getGuildHandler()->inviteResponse(mGuildInvited, true);
+ else
+ guildManager->inviteResponse(true);
}
else if (eventId == "no")
{
@@ -1213,7 +1326,10 @@ void SocialWindow::action(const gcn::ActionEvent &event)
strprintf(_("Rejected guild invite from %s."),
mPartyInviter.c_str()));
}
- Net::getGuildHandler()->inviteResponse(mGuildInvited, false);
+ if (!guildManager || !GuildManager::getEnableGuildBot())
+ Net::getGuildHandler()->inviteResponse(mGuildInvited, false);
+ else
+ guildManager->inviteResponse(false);
}
mGuildInvited = 0;
@@ -1449,7 +1565,7 @@ void SocialWindow::updatePortals()
void SocialWindow::updatePortalNames()
{
if (mNavigation)
- static_cast<NavigationTab*>(mNavigation)->updateNames();
+ static_cast<SocialNavigationTab*>(mNavigation)->updateNames();
}
void SocialWindow::selectPortal(unsigned num)
@@ -1461,21 +1577,26 @@ void SocialWindow::selectPortal(unsigned num)
int SocialWindow::getPortalIndex(int x, int y)
{
if (mNavigation)
- return static_cast<NavigationTab*>(mNavigation)->getPortalIndex(x, y);
+ {
+ return static_cast<SocialNavigationTab*>(
+ mNavigation)->getPortalIndex(x, y);
+ }
else
+ {
return -1;
+ }
}
void SocialWindow::addPortal(int x, int y)
{
if (mNavigation)
- static_cast<NavigationTab*>(mNavigation)->addPortal(x, y);
+ static_cast<SocialNavigationTab*>(mNavigation)->addPortal(x, y);
}
void SocialWindow::removePortal(int x, int y)
{
if (mNavigation)
- static_cast<NavigationTab*>(mNavigation)->removePortal(x, y);
+ static_cast<SocialNavigationTab*>(mNavigation)->removePortal(x, y);
}
void SocialWindow::nextTab()
diff --git a/src/gui/specialswindow.cpp b/src/gui/specialswindow.cpp
index a5d95c7ff..702c31718 100644
--- a/src/gui/specialswindow.cpp
+++ b/src/gui/specialswindow.cpp
@@ -82,6 +82,7 @@ SpecialsWindow::SpecialsWindow():
setCloseButton(true);
setResizable(true);
setSaveVisible(true);
+ setStickyButtonLock(true);
setDefaultSize(windowContainer->getWidth() - 280, 30, 275, 425);
setupWindow->registerWindowForReset(this);
diff --git a/src/gui/spellpopup.cpp b/src/gui/spellpopup.cpp
index 86aeb2206..a918e037d 100644
--- a/src/gui/spellpopup.cpp
+++ b/src/gui/spellpopup.cpp
@@ -27,6 +27,8 @@
#include "gui/gui.h"
#include "gui/palette.h"
+#include "gui/widgets/label.h"
+
#include "textcommand.h"
#include "graphics.h"
@@ -36,7 +38,6 @@
#include "utils/stringutils.h"
#include <guichan/font.hpp>
-#include <guichan/widgets/label.hpp>
#include "debug.h"
@@ -44,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/statuspopup.cpp b/src/gui/statuspopup.cpp
index 08400a916..bb7a295ab 100644
--- a/src/gui/statuspopup.cpp
+++ b/src/gui/statuspopup.cpp
@@ -28,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"
@@ -50,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/statuswindow.cpp b/src/gui/statuswindow.cpp
index fcc324730..d1fde2dd1 100644
--- a/src/gui/statuswindow.cpp
+++ b/src/gui/statuswindow.cpp
@@ -132,6 +132,7 @@ StatusWindow::StatusWindow():
setResizable(true);
setCloseButton(true);
setSaveVisible(true);
+ setStickyButtonLock(true);
setDefaultSize((windowContainer->getWidth() - 365) / 2,
(windowContainer->getHeight() - 255) / 2, 365, 275);
@@ -356,7 +357,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)
{
@@ -372,7 +373,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;
@@ -889,7 +890,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
@@ -898,7 +898,6 @@ 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);
}
}
diff --git a/src/gui/textcommandeditor.cpp b/src/gui/textcommandeditor.cpp
index 8cf9fa398..9d759c4a2 100644
--- a/src/gui/textcommandeditor.cpp
+++ b/src/gui/textcommandeditor.cpp
@@ -71,7 +71,7 @@ public:
if (i->first < 0)
continue;
- ItemInfo info = (*i->second);
+ const ItemInfo &info = (*i->second);
std::string name = info.getName();
if (name != "unnamed" && !info.getName().empty()
&& info.getName() != "unnamed")
diff --git a/src/gui/textpopup.cpp b/src/gui/textpopup.cpp
index 7f1e0e6b8..1ff601154 100644
--- a/src/gui/textpopup.cpp
+++ b/src/gui/textpopup.cpp
@@ -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/theme.cpp b/src/gui/theme.cpp
index 056eafc0f..0607564f9 100644
--- a/src/gui/theme.cpp
+++ b/src/gui/theme.cpp
@@ -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",
@@ -639,7 +644,16 @@ static int readColorType(const std::string &type)
"SERVER_VERSION_NOT_SUPPORTED",
"WARNING",
"CHARM",
- "PLAYER_ADVANCED"
+ "PLAYER_ADVANCED",
+ "RED",
+ "GREEN",
+ "BLUE",
+ "ORANGE",
+ "YELLOW",
+ "PINK",
+ "PURPLE",
+ "GRAY",
+ "BROWN"
};
if (type.empty())
diff --git a/src/gui/theme.h b/src/gui/theme.h
index 120214232..fbc6f13da 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,
@@ -184,6 +189,15 @@ class Theme : public Palette, public ConfigListener
WARNING,
CHARM,
PLAYER_ADVANCED,
+ RED,
+ GREEN,
+ BLUE,
+ ORANGE,
+ YELLOW,
+ PINK,
+ PURPLE,
+ GRAY,
+ BROWN,
THEME_COLORS_END
};
diff --git a/src/gui/tradewindow.cpp b/src/gui/tradewindow.cpp
index d00fb61f4..3c19ee9c2 100644
--- a/src/gui/tradewindow.cpp
+++ b/src/gui/tradewindow.cpp
@@ -78,6 +78,7 @@ TradeWindow::TradeWindow():
setWindowName("Trade");
setResizable(true);
setCloseButton(true);
+ setStickyButtonLock(true);
setDefaultSize(386, 180, ImageRect::CENTER);
setMinWidth(386);
setMinHeight(180);
diff --git a/src/gui/updaterwindow.cpp b/src/gui/updaterwindow.cpp
index 7534b12a9..4ba1c9179 100644
--- a/src/gui/updaterwindow.cpp
+++ b/src/gui/updaterwindow.cpp
@@ -54,6 +54,8 @@
const std::string xmlUpdateFile = "resources.xml";
const std::string txtUpdateFile = "resources2.txt";
+const std::string updateServer2
+ = "http://download.evolonline.org/manaplus/updates/";
std::vector<updateFile> loadXMLFile(const std::string &fileName);
std::vector<updateFile> loadTxtFile(const std::string &fileName);
@@ -137,6 +139,7 @@ UpdaterWindow::UpdaterWindow(const std::string &updateHost,
mDownloadStatus(UPDATE_NEWS),
mUpdateHost(updateHost),
mUpdatesDir(updatesDir),
+ mUpdatesDirReal(updatesDir),
mCurrentFile("news.txt"),
mDownloadProgress(0.0f),
mCurrentChecksum(0),
@@ -147,6 +150,7 @@ UpdaterWindow::UpdaterWindow(const std::string &updateHost,
mMemoryBuffer(NULL),
mDownload(NULL),
mUpdateIndex(0),
+ mUpdateIndexOffset(0),
mLoadUpdates(applyUpdates),
mUpdateType(updateType)
{
@@ -181,6 +185,9 @@ UpdaterWindow::UpdaterWindow(const std::string &updateHost,
setVisible(true);
mCancelButton->requestFocus();
+ mUpdateServerPath = mUpdateHost;
+ removeProtocol(mUpdateServerPath);
+
// Try to download the updates list
download();
}
@@ -539,8 +546,9 @@ void UpdaterWindow::logic()
mProgressBar->setProgress(mDownloadProgress);
if (mUpdateFiles.size() && mUpdateIndex <= mUpdateFiles.size())
{
- mProgressBar->setText(strprintf("%d/%d",
- mUpdateIndex + 1, (int)mUpdateFiles.size() + 1));
+ mProgressBar->setText(strprintf("%d/%d", mUpdateIndex
+ + mUpdateIndexOffset + 1, (int)mUpdateFiles.size()
+ + (int)mTempUpdateFiles.size() + 1));
}
else
{
@@ -582,13 +590,12 @@ void UpdaterWindow::logic()
// Parse current memory buffer as news and dispose of the data
loadPatch();
-/*
- mCurrentFile = "news.txt";
- mStoreInMemory = true;
- mDownloadStatus = UPDATE_NEWS;
- download(); // download() changes mDownloadComplete to false
-*/
- mDownloadStatus = UPDATE_COMPLETE;
+ mUpdateHost = updateServer2 + mUpdateServerPath;
+ mUpdatesDir += "/fix";
+ mCurrentFile = xmlUpdateFile;
+ mStoreInMemory = false;
+ mDownloadStatus = UPDATE_LIST2;
+ download();
}
break;
@@ -681,7 +688,58 @@ void UpdaterWindow::logic()
}
}
break;
+ case UPDATE_LIST2:
+ if (mDownloadComplete)
+ {
+ if (mCurrentFile == xmlUpdateFile)
+ {
+ mTempUpdateFiles = loadXMLFile(
+ mUpdatesDir + "/" + xmlUpdateFile);
+ }
+ mUpdateIndexOffset = mUpdateIndex;
+ mUpdateIndex = 0;
+ mStoreInMemory = false;
+ mDownloadStatus = UPDATE_RESOURCES2;
+ download();
+ }
+ break;
+ case UPDATE_RESOURCES2:
+ if (mDownloadComplete)
+ {
+ if (mUpdateIndex < mTempUpdateFiles.size())
+ {
+ updateFile thisFile = mTempUpdateFiles[mUpdateIndex];
+ mCurrentFile = thisFile.name;
+ std::string checksum;
+ checksum = thisFile.hash;
+ std::stringstream ss(checksum);
+ ss >> std::hex >> mCurrentChecksum;
+
+ std::ifstream temp(
+ (mUpdatesDir + "/" + mCurrentFile).c_str());
+
+ if (!temp.is_open() || !validateFile(mUpdatesDir + "/"
+ + mCurrentFile, mCurrentChecksum))
+ {
+ temp.close();
+ download();
+ }
+ else
+ {
+ temp.close();
+ logger->log("%s already here", mCurrentFile.c_str());
+ }
+ mUpdateIndex++;
+ }
+ else
+ {
+ mUpdatesDir = mUpdatesDirReal;
+ mDownloadStatus = UPDATE_COMPLETE;
+ }
+ }
+ break;
case UPDATE_COMPLETE:
+ mUpdatesDir = mUpdatesDirReal;
enable();
setLabel(_("Completed"));
break;
diff --git a/src/gui/updaterwindow.h b/src/gui/updaterwindow.h
index a1dc556d5..e9a45241f 100644
--- a/src/gui/updaterwindow.h
+++ b/src/gui/updaterwindow.h
@@ -146,7 +146,9 @@ private:
UPDATE_COMPLETE,
UPDATE_NEWS,
UPDATE_RESOURCES,
- UPDATE_PATCH
+ UPDATE_PATCH,
+ UPDATE_LIST2,
+ UPDATE_RESOURCES2
};
/** Status of the current download. */
@@ -158,6 +160,8 @@ private:
/** Place where the updates are stored (absolute path). */
std::string mUpdatesDir;
+ std::string mUpdatesDirReal;
+
/** The file currently downloading. */
std::string mCurrentFile;
@@ -194,9 +198,15 @@ private:
/** List of files to download. */
std::vector<updateFile> mUpdateFiles;
+ /** List of temp files to download. */
+ std::vector<updateFile> mTempUpdateFiles;
+
/** Index of the file to be downloaded. */
unsigned int mUpdateIndex;
+ /** Index offset for disaplay downloaded file. */
+ unsigned int mUpdateIndexOffset;
+
/** Tells ~UpdaterWindow() if it should load updates */
bool mLoadUpdates;
@@ -208,6 +218,7 @@ private:
ProgressBar *mProgressBar; /**< Update progress bar. */
BrowserBox *mBrowserBox; /**< Box to display news. */
ScrollArea *mScrollArea; /**< Used to scroll news box. */
+ std::string mUpdateServerPath;
};
#endif
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 70d02b016..b6e09c011 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -79,10 +79,12 @@ Viewport::Viewport():
mScrollCenterOffsetX = config.getIntValue("ScrollCenterOffsetX");
mScrollCenterOffsetY = config.getIntValue("ScrollCenterOffsetY");
mShowBeingPopup = config.getBoolValue("showBeingPopup");
+ mSelfMouseHeal = config.getBoolValue("selfMouseHeal");
config.addListener("ScrollLaziness", this);
config.addListener("ScrollRadius", this);
config.addListener("showBeingPopup", this);
+ config.addListener("selfMouseHeal", this);
mPopupMenu = new PopupMenu;
mBeingPopup = new BeingPopup;
@@ -96,6 +98,7 @@ Viewport::~Viewport()
config.removeListener("ScrollLaziness", this);
config.removeListener("ScrollRadius", this);
config.removeListener("showBeingPopup", this);
+ config.removeListener("selfMouseHeal", this);
delete mPopupMenu;
mPopupMenu = 0;
@@ -145,8 +148,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,17 +177,29 @@ 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)
{
+ if (player_x <= 0 || player_y <= 0)
+ {
+ if (debugChatTab)
+ debugChatTab->chatLog("incorrect player position!");
+ logger->log("incorrect player position: %d, %d, %d, %d",
+ player_x, player_y, (int)mPixelViewX, (int)mPixelViewY);
+ if (player_node)
+ {
+ logger->log("tile position: %d, %d",
+ player_node->getTileX(), player_node->getTileY());
+ }
+ }
mPixelViewX = static_cast<float>(player_x);
mPixelViewY = static_cast<float>(player_y);
};
@@ -459,17 +476,24 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
if (mHoverBeing->getType() == ActorSprite::PLAYER)
{
if (actorSpriteManager)
- actorSpriteManager->heal(player_node, mHoverBeing);
+ {
+ if (player_node != mHoverBeing || mSelfMouseHeal)
+ actorSpriteManager->heal(player_node, mHoverBeing);
+ }
}
else if (player_node->withinAttackRange(mHoverBeing) ||
keyboard.isKeyActive(keyboard.KEY_ATTACK))
{
- player_node->attack(mHoverBeing,
- !keyboard.isKeyActive(keyboard.KEY_TARGET));
+ if (player_node != mHoverBeing)
+ {
+ player_node->attack(mHoverBeing,
+ !keyboard.isKeyActive(keyboard.KEY_TARGET));
+ }
}
else if (!keyboard.isKeyActive(keyboard.KEY_ATTACK))
{
- player_node->setGotoTarget(mHoverBeing);
+ if (player_node != mHoverBeing)
+ player_node->setGotoTarget(mHoverBeing);
}
}
// Picks up a item if we clicked on one
diff --git a/src/gui/viewport.h b/src/gui/viewport.h
index d6ee54834..50c81aff4 100644
--- a/src/gui/viewport.h
+++ b/src/gui/viewport.h
@@ -285,6 +285,7 @@ class Viewport : public WindowContainer, public gcn::MouseListener,
int mScrollRadius;
int mScrollLaziness;
bool mShowBeingPopup;
+ bool mSelfMouseHeal;
int mScrollCenterOffsetX;
int mScrollCenterOffsetY;
int mMouseX; /**< Current mouse position in pixels. */
diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp
index 99da53c66..1e9f686e4 100644
--- a/src/gui/whoisonline.cpp
+++ b/src/gui/whoisonline.cpp
@@ -97,6 +97,7 @@ WhoIsOnline::WhoIsOnline():
// setContentSize(w, h);
setCloseButton(true);
setResizable(true);
+ setStickyButtonLock(true);
mUpdateButton = new Button(_("Update"), "update", this);
mUpdateButton->setEnabled(false);
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp
index 0d35ad188..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;
@@ -283,7 +286,7 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics)
}
}
- graphics->setColor(Theme::getThemeColor(Theme::TEXT));
+ graphics->setColor(getForegroundColor());
// Draw Name
if (a->getType() == MapItem::SEPARATOR)
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/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index 7df70bd04..65a25363d 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -64,6 +64,19 @@ 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);
+ mColors[RED] = Theme::getThemeColor(Theme::RED);
+ mColors[GREEN] = Theme::getThemeColor(Theme::GREEN);
+ mColors[BLUE] = Theme::getThemeColor(Theme::BLUE);
+ mColors[ORANGE] = Theme::getThemeColor(Theme::ORANGE);
+ mColors[YELLOW] = Theme::getThemeColor(Theme::YELLOW);
+ mColors[PINK] = Theme::getThemeColor(Theme::PINK);
+ mColors[PURPLE] = Theme::getThemeColor(Theme::PURPLE);
+ mColors[GRAY] = Theme::getThemeColor(Theme::GRAY);
+ mColors[BROWN] = Theme::getThemeColor(Theme::BROWN);
}
BrowserBox::~BrowserBox()
@@ -310,7 +323,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 +332,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 +343,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,
@@ -474,15 +487,15 @@ int BrowserBox::calcHeight()
switch (c)
{
- case '1': selColor = RED; break;
- case '2': selColor = GREEN; break;
- case '3': selColor = BLUE; break;
- case '4': selColor = ORANGE; break;
- case '5': selColor = YELLOW; break;
- case '6': selColor = PINK; break;
- case '7': selColor = PURPLE; break;
- case '8': selColor = GRAY; break;
- case '9': selColor = BROWN; break;
+ case '1': selColor = mColors[RED]; break;
+ case '2': selColor = mColors[GREEN]; break;
+ case '3': selColor = mColors[BLUE]; break;
+ case '4': selColor = mColors[ORANGE]; break;
+ case '5': selColor = mColors[YELLOW]; break;
+ case '6': selColor = mColors[PINK]; break;
+ case '7': selColor = mColors[PURPLE]; break;
+ case '8': selColor = mColors[GRAY]; break;
+ case '9': selColor = mColors[BROWN]; break;
case '0':
default:
selColor = textColor;
diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h
index 6fdb40042..cd69ce56f 100644
--- a/src/gui/widgets/browserbox.h
+++ b/src/gui/widgets/browserbox.h
@@ -147,27 +147,18 @@ class BrowserBox : public gcn::Widget,
AUTO_WRAP /**< Maybe it needs a fix or to be redone. */
};
- /**
- * BrowserBox colors.
- *
- * NOTES (by Javila):
- * - color values is "0x" prefix followed by HTML color style.
- * - we can add up to 10 different colors: [0..9].
- * - not all colors will be fine with all backgrounds due transparent
- * windows and widgets. So, I think it's better keep BrowserBox
- * opaque (white background) by default.
- */
enum
{
- RED = 0xff0000, /**< Color 1 */
- GREEN = 0x009000, /**< Color 2 */
- BLUE = 0x0000ff, /**< Color 3 */
- ORANGE = 0xe0980e, /**< Color 4 */
- YELLOW = 0xf1dc27, /**< Color 5 */
- PINK = 0xff00d8, /**< Color 6 */
- PURPLE = 0x8415e2, /**< Color 7 */
- GRAY = 0x919191, /**< Color 8 */
- BROWN = 0x8e4c17 /**< Color 9 */
+ RED = 0,
+ GREEN = 1,
+ BLUE = 2,
+ ORANGE = 3,
+ YELLOW = 4,
+ PINK = 5,
+ PURPLE = 6,
+ GRAY = 7,
+ BROWN = 8,
+ COLORS_MAX = 9
};
/**
@@ -225,6 +216,11 @@ class BrowserBox : public gcn::Widget,
bool mAlwaysUpdate;
bool mProcessVersion;
bool mEnableImages;
+
+ gcn::Color mBackgroundColor;
+ gcn::Color mHighlightColor;
+ gcn::Color mHyperLinkColor;
+ gcn::Color mColors[COLORS_MAX];
};
#endif
diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp
index 2d9678a53..7c46ae9df 100644
--- a/src/gui/widgets/button.cpp
+++ b/src/gui/widgets/button.cpp
@@ -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 785bdd6be..81c0d277f 100644
--- a/src/gui/widgets/chattab.cpp
+++ b/src/gui/widgets/chattab.cpp
@@ -283,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/container.cpp b/src/gui/widgets/container.cpp
index 96cea7119..558257507 100644
--- a/src/gui/widgets/container.cpp
+++ b/src/gui/widgets/container.cpp
@@ -37,7 +37,7 @@ Container::~Container()
bool Container::safeRemove(gcn::Widget* widget)
{
- WidgetListIterator iter;
+ WidgetListConstIterator iter;
for (iter = mWidgets.begin(); iter != mWidgets.end(); ++iter)
{
if (*iter == widget)
diff --git a/src/gui/widgets/container.h b/src/gui/widgets/container.h
index 1d8872477..c011b8925 100644
--- a/src/gui/widgets/container.h
+++ b/src/gui/widgets/container.h
@@ -26,6 +26,10 @@
#include <guichan/widget.hpp>
#include <guichan/widgets/container.hpp>
+#if !defined USE_INTERNALGUICHAN
+typedef std::list<gcn::Widget *>::const_iterator WidgetListConstIterator;
+#endif
+
/**
* A widget container.
*
diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp
index cfb757638..46240f76d 100644
--- a/src/gui/widgets/desktop.cpp
+++ b/src/gui/widgets/desktop.cpp
@@ -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 92f02c78f..b628cf2d4 100644
--- a/src/gui/widgets/dropshortcutcontainer.cpp
+++ b/src/gui/widgets/dropshortcutcontainer.cpp
@@ -73,6 +73,8 @@ DropShortcutContainer::DropShortcutContainer():
mBoxHeight = 1;
mBoxWidth = 1;
}
+ mEquipedColor = Theme::getThemeColor(Theme::ITEM_EQUIPPED);
+ mUnEquipedColor = Theme::getThemeColor(Theme::ITEM_NOT_EQUIPPED);
}
DropShortcutContainer::~DropShortcutContainer()
@@ -110,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;
@@ -142,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 723b215cf..b2d63a7dd 100644
--- a/src/gui/widgets/dropshortcutcontainer.h
+++ b/src/gui/widgets/dropshortcutcontainer.h
@@ -84,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 5bb972adc..5aced193f 100644
--- a/src/gui/widgets/emoteshortcutcontainer.cpp
+++ b/src/gui/widgets/emoteshortcutcontainer.cpp
@@ -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/guildchattab.cpp b/src/gui/widgets/guildchattab.cpp
new file mode 100644
index 000000000..0353ac23f
--- /dev/null
+++ b/src/gui/widgets/guildchattab.cpp
@@ -0,0 +1,128 @@
+/*
+ * 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/widgets/guildchattab.h"
+
+#include "chatlogger.h"
+#include "commandhandler.h"
+#include "guild.h"
+#include "guildmanager.h"
+#include "localplayer.h"
+
+#include "gui/theme.h"
+
+#include "resources/iteminfo.h"
+#include "resources/itemdb.h"
+
+#include "utils/dtor.h"
+#include "utils/gettext.h"
+#include "utils/stringutils.h"
+
+#include "debug.h"
+
+GuildChatTab::GuildChatTab() :
+ ChatTab(_("Guild"))
+{
+ setTabColor(&Theme::getThemeColor(Theme::GUILD_CHAT_TAB));
+}
+
+GuildChatTab::~GuildChatTab()
+{
+}
+
+bool GuildChatTab::handleCommand(const std::string &type,
+ const std::string &args)
+{
+ if (type == "help")
+ {
+ if (args == "invite")
+ {
+ chatLog(_("Command: /invite <nick>"));
+ chatLog(_("This command invites <nick> to the guild you're in."));
+ chatLog(_("If the <nick> has spaces in it, enclose it in "
+ "double quotes (\")."));
+ }
+ else if (args == "leave")
+ {
+ chatLog(_("Command: /leave"));
+ chatLog(_("This command causes the player to leave the guild."));
+ }
+ else
+ return false;
+ }
+ else if (type == "invite" && guildManager)
+ {
+ guildManager->invite(args);
+ }
+ else if (type == "leave" && guildManager)
+ {
+ guildManager->leave();
+ }
+ else if (type == "kick" && guildManager)
+ {
+ guildManager->kick(args);
+ }
+ else if (type == "notice" && guildManager)
+ {
+ guildManager->notice(args);
+ }
+ else
+ {
+ return false;
+ }
+
+ return true;
+}
+
+void GuildChatTab::handleInput(const std::string &msg)
+{
+ if (!guildManager)
+ return;
+
+ if (chatWindow)
+ guildManager->chat(chatWindow->doReplace(msg));
+ else
+ guildManager->chat(msg);
+}
+
+void GuildChatTab::showHelp()
+{
+ chatLog(_("/help > Display this help."));
+ chatLog(_("/invite > Invite a player to your guild"));
+ chatLog(_("/leave > Leave the guild you are in"));
+ chatLog(_("/kick > Kick some one from the guild you are in"));
+}
+
+void GuildChatTab::getAutoCompleteList(std::vector<std::string> &names) const
+{
+ if (!guildManager)
+ return;
+
+ guildManager->getNames(names);
+ names.push_back("/notice ");
+}
+
+void GuildChatTab::saveToLogFile(std::string &msg)
+{
+ if (chatLogger)
+ chatLogger->log("#Guild", msg);
+}
diff --git a/src/gui/widgets/guildchattab.h b/src/gui/widgets/guildchattab.h
new file mode 100644
index 000000000..4f5ee3a8e
--- /dev/null
+++ b/src/gui/widgets/guildchattab.h
@@ -0,0 +1,52 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 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_GUILDTAB_H
+#define GUI_GUILDTAB_H
+
+#include "gui/widgets/chattab.h"
+
+/**
+ * A tab for a guild chat channel.
+ */
+class GuildChatTab : public ChatTab
+{
+ public:
+ GuildChatTab();
+
+ ~GuildChatTab();
+
+ bool handleCommand(const std::string &type, const std::string &args);
+
+ void showHelp();
+
+ void saveToLogFile(std::string &msg);
+
+ int getType() const { return ChatTab::TAB_GUILD; }
+
+ protected:
+ void handleInput(const std::string &msg);
+
+ void getAutoCompleteList(std::vector<std::string> &names) const;
+};
+
+#endif
diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp
index e25e0bb8c..e02eda88c 100644
--- a/src/gui/widgets/guitable.cpp
+++ b/src/gui/widgets/guitable.cpp
@@ -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/guitable.h b/src/gui/widgets/guitable.h
index c4fab6a0d..d248c4820 100644
--- a/src/gui/widgets/guitable.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/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index b79f26226..91b674018 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -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 382d169dc..a14b416ce 100644
--- a/src/gui/widgets/layout.cpp
+++ b/src/gui/widgets/layout.cpp
@@ -68,7 +68,9 @@ LayoutArray &LayoutCell::getArray()
void LayoutCell::reflow(int nx, int ny, int nw, int nh)
{
- assert(mType != NONE);
+ if (mType == NONE)
+ return;
+
nx += mHPadding;
ny += mVPadding;
nw -= 2 * mHPadding;
@@ -81,7 +83,8 @@ void LayoutCell::reflow(int nx, int ny, int nw, int nh)
void LayoutCell::computeSizes()
{
- assert(mType == ARRAY);
+ if (mType != ARRAY)
+ return;
std::vector< std::vector< LayoutCell * > >::iterator
i = mArray->mCells.begin();
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/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 08f0b5a70..2796d3ab2 100644
--- a/src/gui/widgets/scrollarea.cpp
+++ b/src/gui/widgets/scrollarea.cpp
@@ -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/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 8d5b563bb..8abe727b5 100644
--- a/src/gui/widgets/spellshortcutcontainer.cpp
+++ b/src/gui/widgets/spellshortcutcontainer.cpp
@@ -81,6 +81,7 @@ SpellShortcutContainer::SpellShortcutContainer(unsigned number):
mBoxHeight = 1;
mBoxWidth = 1;
}
+ setForegroundColor(Theme::getThemeColor(Theme::TEXT));
}
SpellShortcutContainer::~SpellShortcutContainer()
@@ -106,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/tab.cpp b/src/gui/widgets/tab.cpp
index b7d6b4458..530f1ac82 100644
--- a/src/gui/widgets/tab.cpp
+++ b/src/gui/widgets/tab.cpp
@@ -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/textfield.cpp b/src/gui/widgets/textfield.cpp
index f80039650..2729e5407 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -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/window.cpp b/src/gui/widgets/window.cpp
index 9a7c689e6..4435496a7 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -60,6 +60,7 @@ Window::Window(const std::string &caption, bool modal, Window *parent,
mSaveVisible(false),
mStickyButton(false),
mSticky(false),
+ mStickyButtonLock(false),
mMinWinWidth(100),
mMinWinHeight(40),
mMaxWinWidth(graphics->mWidth),
@@ -95,6 +96,7 @@ Window::Window(const std::string &caption, bool modal, Window *parent,
addWidgetListener(this);
mCaptionFont = getFont();
+ setForegroundColor(Theme::getThemeColor(Theme::TEXT));
}
Window::~Window()
@@ -146,15 +148,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);
}
@@ -162,9 +159,9 @@ void Window::draw(gcn::Graphics *graphics)
// Draw Close Button
if (mCloseButton && mSkin->getCloseImage())
{
- g->drawImage(mSkin->getCloseImage(),
- getWidth() - mSkin->getCloseImage()->getWidth() - getPadding(),
- getPadding());
+ Image *button = mSkin->getCloseImage();
+ const int x = getWidth() - button->getWidth() - getPadding();
+ g->drawImage(button, x, getPadding());
}
// Draw Sticky Button
@@ -175,7 +172,7 @@ void Window::draw(gcn::Graphics *graphics)
{
int x = getWidth() - button->getWidth() - getPadding();
if (mCloseButton && mSkin->getCloseImage())
- x -= mSkin->getCloseImage()->getWidth();
+ x -= mSkin->getCloseImage()->getWidth() + getPadding();
g->drawImage(button, x, getPadding());
}
@@ -371,7 +368,7 @@ void Window::widgetHidden(const gcn::Event &event A_UNUSED)
if (gui)
gui->setCursorType(Gui::CURSOR_POINTER);
- WidgetListIterator it;
+ WidgetListConstIterator it;
if (!mFocusHandler)
return;
@@ -403,6 +400,13 @@ void Window::setSticky(bool sticky)
mSticky = sticky;
}
+void Window::setStickyButtonLock(bool lock)
+{
+ mStickyButtonLock = lock;
+ mStickyButton = lock;
+// mMovable = false;
+}
+
void Window::setVisible(bool visible)
{
setVisible(visible, false);
@@ -417,7 +421,10 @@ void Window::setVisible(bool visible, bool forceSticky)
if (visible)
checkIfIsOffScreen();
- gcn::Window::setVisible((!forceSticky && isSticky()) || visible);
+ if (isStickyButtonLock())
+ gcn::Window::setVisible(visible);
+ else
+ gcn::Window::setVisible((!forceSticky && isSticky()) || visible);
}
void Window::scheduleDelete()
@@ -483,7 +490,10 @@ void Window::mousePressed(gcn::MouseEvent &event)
// Handle window resizing
mouseResize = getResizeHandles(event);
- mMoved = !mouseResize;
+ if (canMove())
+ mMoved = !mouseResize;
+ else
+ mMoved = false;
}
}
@@ -545,10 +555,24 @@ void Window::mouseMoved(gcn::MouseEvent &event)
viewport->hideBeingPopup();
}
+bool Window::canMove()
+{
+ return !mStickyButtonLock || !mSticky;
+}
+
void Window::mouseDragged(gcn::MouseEvent &event)
{
- // Let Guichan handle title bar drag
- gcn::Window::mouseDragged(event);
+ if (canMove())
+ {
+ // Let Guichan handle title bar drag
+ gcn::Window::mouseDragged(event);
+ }
+ else
+ {
+ if (!event.isConsumed() && event.getSource() == this)
+ event.consume();
+ return;
+ }
// Keep guichan window inside screen when it may be moved
if (isMovable() && mMoved)
@@ -639,21 +663,22 @@ void Window::setModal(bool modal)
void Window::loadWindowState()
{
const std::string &name = mWindowName;
- assert(!name.empty());
+ if (name.empty())
+ return;
setPosition(config.getValueInt(name + "WinX", mDefaultX),
- config.getValueInt(name + "WinY", mDefaultY));
+ config.getValueInt(name + "WinY", mDefaultY));
if (mSaveVisible)
{
setVisible(config.getValueBool(name
- + "Visible", mDefaultVisible));
+ + "Visible", mDefaultVisible));
}
if (mStickyButton)
{
setSticky(config.getValueBool(name
- + "Sticky", isSticky()));
+ + "Sticky", isSticky()));
}
if (mGrip)
@@ -685,10 +710,10 @@ void Window::loadWindowState()
int width = getWidth();
int height = getHeight();
- if (getX() + width >= viewport->getWidth())
- width = viewport->getWidth() - getX() - 1;
- if (getY() + height >= viewport->getHeight())
- height = viewport->getHeight() - getY() - 1;
+ if (getX() + width > viewport->getWidth())
+ width = viewport->getWidth() - getX();
+ if (getY() + height > viewport->getHeight())
+ height = viewport->getHeight() - getY();
if (width < 0)
width = 0;
if (height < 0)
@@ -815,7 +840,7 @@ void Window::resetToDefaultSize()
int Window::getResizeHandles(gcn::MouseEvent &event)
{
- if (event.getX() < 0 || event.getY() < 0)
+ if ((mStickyButtonLock && mSticky) || event.getX() < 0 || event.getY() < 0)
return 0;
int resizeHandles = 0;
diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h
index d36d6c5ad..b9f65dceb 100644
--- a/src/gui/widgets/window.h
+++ b/src/gui/widgets/window.h
@@ -189,6 +189,17 @@ class Window : public gcn::Window, gcn::WidgetListener
{ return mSticky; }
/**
+ * Sets whether the window sticky mean window locked or not.
+ */
+ void setStickyButtonLock(bool sticky);
+
+ /**
+ * Returns whether the window sticky locking window.
+ */
+ bool isStickyButtonLock() const
+ { return mStickyButtonLock; }
+
+ /**
* Overloads window setVisible by Guichan to allow sticky window
* handling.
*/
@@ -387,6 +398,9 @@ class Window : public gcn::Window, gcn::WidgetListener
void setCaptionFont(gcn::Font *font)
{ mCaptionFont = font; }
+ protected:
+ bool canMove();
+
private:
enum ResizeHandles
{
@@ -423,6 +437,7 @@ class Window : public gcn::Window, gcn::WidgetListener
bool mSaveVisible; /**< Window will save visibility */
bool mStickyButton; /**< Window has a sticky button */
bool mSticky; /**< Window resists hiding*/
+ bool mStickyButtonLock; /**< Window locked if sticky enabled*/
int mMinWinWidth; /**< Minimum window width */
int mMinWinHeight; /**< Minimum window height */
int mMaxWinWidth; /**< Maximum window width */
diff --git a/src/guild.cpp b/src/guild.cpp
index b84602858..98e5bb519 100644
--- a/src/guild.cpp
+++ b/src/guild.cpp
@@ -24,6 +24,8 @@
#include "actorspritemanager.h"
+#include "utils/stringutils.h"
+
#include "debug.h"
class SortGuildFunctor
@@ -33,10 +35,22 @@ class SortGuildFunctor
{
if (!m1 || !m2)
return false;
+
+ if (m1->getOnline() != m2->getOnline())
+ return m1->getOnline() > m2->getOnline();
+
if (m1->getPos() != m2->getPos())
- return m1->getPos() < m2->getPos();
+ return m1->getPos() > m2->getPos();
- return m1->getName() < m2->getName();
+ if (m1->getName() != m2->getName())
+ {
+ std::string s1 = m1->getName();
+ std::string s2 = m2->getName();
+ toLower(s1);
+ toLower(s2);
+ return s1 < s2;
+ }
+ return false;
}
} guildSorter;
@@ -66,7 +80,8 @@ Guild::GuildMap Guild::guilds;
Guild::Guild(short id):
mId(id),
mCanInviteUsers(false),
- mEmblemId(0)
+ mEmblemId(0),
+ mServerGuild(true)
{
guilds[id] = this;
}
diff --git a/src/guild.h b/src/guild.h
index 7986eb5d3..62135e9ad 100644
--- a/src/guild.h
+++ b/src/guild.h
@@ -178,11 +178,17 @@ public:
void setEmblemId(int id)
{ mEmblemId = id; }
- int getEmblemId()
+ int getEmblemId() const
{ return mEmblemId; }
static void clearGuilds();
+ void setServerGuild(bool b)
+ { mServerGuild = b; }
+
+ bool getServerGuild() const
+ { return mServerGuild; }
+
private:
typedef std::map<int, Guild*> GuildMap;
static GuildMap guilds;
@@ -199,6 +205,7 @@ private:
bool mCanInviteUsers;
int mEmblemId;
PositionsMap mPositions;
+ bool mServerGuild;
};
#endif // GUILD_H
diff --git a/src/guildmanager.cpp b/src/guildmanager.cpp
new file mode 100644
index 000000000..1a8d5b433
--- /dev/null
+++ b/src/guildmanager.cpp
@@ -0,0 +1,477 @@
+/*
+ * The ManaPlus Client
+ * 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 "guildmanager.h"
+
+#include "actorspritemanager.h"
+#include "client.h"
+#include "configuration.h"
+#include "guild.h"
+#include "localplayer.h"
+
+#include "gui/socialwindow.h"
+
+#include "gui/widgets/guildchattab.h"
+
+#include "net/chathandler.h"
+#include "net/net.h"
+
+#include "utils/gettext.h"
+#include "utils/stringutils.h"
+
+#include "debug.h"
+
+bool GuildManager::mEnableGuildBot = false;
+
+GuildManager::GuildManager() :
+ mGotInfo(false),
+ mGotName(false),
+ mHavePower(false),
+ mTab(0),
+ mRequest(false)
+{
+}
+
+GuildManager::~GuildManager()
+{
+ delete mTab;
+ mTab = 0;
+}
+
+void GuildManager::init()
+{
+ if (guildManager)
+ return;
+
+ int val = serverConfig.getValue("enableGuildBot", -1);
+ if (val == -1)
+ {
+ if (Client::isTmw())
+ val = 1;
+ else
+ val = 0;
+ serverConfig.setValue("enableGuildBot", val);
+ }
+ mEnableGuildBot = val;
+ if (mEnableGuildBot)
+ guildManager = new GuildManager();
+}
+
+void GuildManager::reload()
+{
+ mGotInfo = false;
+ mGotName = false;
+ mHavePower = false;
+ mRequest = false;
+ mTempList.clear();
+
+ if (socialWindow)
+ {
+ Guild *guild = Guild::getGuild(1);
+ if (guild)
+ socialWindow->removeTab(guild);
+ }
+ delete mTab;
+ mTab = 0;
+}
+
+void GuildManager::send(std::string msg)
+{
+ Net::getChatHandler()->privateMessage("guild", msg);
+}
+
+void GuildManager::chat(std::string msg)
+{
+ if (!player_node || !mTab)
+ return;
+
+ Net::getChatHandler()->privateMessage("guild", msg);
+ mTab->chatLog(player_node->getName(), msg);
+}
+
+void GuildManager::getNames(std::vector<std::string> &names)
+{
+ Guild *guild = createGuild();
+ guild->getNames(names);
+}
+
+void GuildManager::requestGuildInfo()
+{
+ if (mRequest)
+ return;
+
+ if (!mGotName)
+ {
+ send("!info " + toString(tick_time));
+ mRequest = true;
+ }
+ else if (!mGotInfo)
+ {
+ send("!getonlineinfo " + toString(tick_time));
+ mRequest = true;
+ }
+}
+
+void GuildManager::updateList()
+{
+ Guild *guild = Guild::getGuild(1);
+ if (guild)
+ {
+ guild->setServerGuild(false);
+ std::vector<std::string>::iterator it = mTempList.begin();
+ std::vector<std::string>::iterator it_end = mTempList.end();
+ int i = 0;
+ while (it != it_end)
+ {
+ std::string name = *it;
+ if (name.size() > 1)
+ {
+ int status = atoi(name.substr(name.size() - 1).c_str());
+
+ name = name.substr(0, name.size() - 1);
+ GuildMember *m = guild->addMember(i, 0, name);
+ if (m)
+ {
+ m->setOnline(status & 1);
+ m->setGender(GENDER_UNSPECIFIED);
+ if (status & 2)
+ m->setPos(10);
+ else
+ m->setPos(0);
+ if (player_node && name == player_node->getName())
+ {
+ mHavePower = (status & 2);
+ m->setOnline(true);
+ }
+ }
+ }
+ ++ it;
+ i ++;
+ }
+ guild->sort();
+ createTab(guild);
+ if (actorSpriteManager)
+ {
+ actorSpriteManager->updatePlayerGuild();
+ actorSpriteManager->updatePlayerColors();
+ }
+ }
+ mTempList.clear();
+ mGotInfo = true;
+}
+
+void GuildManager::createTab(Guild *guild)
+{
+ if (!mTab)
+ {
+ mTab = new GuildChatTab();
+ mTab->loadFromLogFile("#Guild");
+ if (player_node)
+ player_node->addGuild(guild);
+ }
+}
+
+Guild *GuildManager::createGuild()
+{
+ Guild *guild = Guild::getGuild(1);
+ if (!guild)
+ return 0;
+
+ guild->setServerGuild(false);
+ return guild;
+}
+
+bool GuildManager::processGuildMessage(std::string msg)
+{
+ bool res = process(msg);
+
+ if (!mRequest)
+ requestGuildInfo();
+
+ return res;
+}
+
+bool GuildManager::process(std::string msg)
+{
+ if (msg.size() > 4 && msg[0] == '#' && msg[1] == '#')
+ msg = msg.substr(3);
+
+ bool haveNick = (msg.find(": ") != std::string::npos);
+
+ if (!haveNick && findCutLast(msg, " is now Offline."))
+ {
+ Guild *guild = createGuild();
+ if (!guild)
+ return false;
+ if (msg.size() < 4)
+ return false;
+ if (msg[0] == '#' && msg[1] == '#')
+ msg = msg.substr(3);
+
+ GuildMember *m = guild->addMember(msg);
+ if (m)
+ m->setOnline(false);
+ guild->sort();
+ mRequest = false;
+ return true;
+ }
+ else if (!haveNick && findCutLast(msg, " is now Online."))
+ {
+ Guild *guild = createGuild();
+ if (!guild)
+ return false;
+ if (msg.size() < 4)
+ return false;
+ if (msg[0] == '#' && msg[1] == '#')
+ msg = msg.substr(3);
+ GuildMember *m = guild->addMember(msg);
+ if (m)
+ m->setOnline(true);
+ guild->sort();
+ mRequest = false;
+ return true;
+ }
+ else if (findCutFirst(msg, "Welcome to the "))
+ {
+ Guild *guild = createGuild();
+ if (!guild)
+ return false;
+// logger->log("welcome message: %s", msg.c_str());
+ int pos = msg.find("! (");
+ if (pos == (int)std::string::npos)
+ return false;
+ msg = msg.substr(0, pos);
+ guild->setName(msg);
+ if (player_node)
+ player_node->setGuildName(msg);
+ mGotName = true;
+ mRequest = false;
+ return true;
+ }
+ else if (findCutFirst(msg, "Player name: "))
+ {
+ Guild *guild = createGuild();
+ if (!guild)
+ return false;
+ int pos = msg.find("Access Level: ");
+ if (pos == (int)std::string::npos)
+ return false;
+
+ msg = msg.substr(pos);
+ if (!findCutFirst(msg, "Access Level: "))
+ return false;
+
+ pos = msg.find(", Guild:");
+ if (pos == (int)std::string::npos)
+ return false;
+
+ int level = atoi(msg.substr(0, pos).c_str());
+ if (level >= 10)
+ mHavePower = true;
+ else
+ mHavePower = false;
+
+ msg = msg.substr(pos + strlen(", Guild:"));
+ pos = msg.find(", No. Of Online Players: ");
+ if (pos == (int)std::string::npos)
+ return false;
+
+ msg = msg.substr(0, pos);
+// logger->log("guild name: %s", msg.c_str());
+
+ guild->setName(msg);
+ if (player_node)
+ player_node->setGuildName(msg);
+ mGotName = true;
+ mRequest = false;
+ return true;
+ }
+ else if (findCutFirst(msg, "OL#"))
+ {
+// logger->log("OL");
+ mTempList.clear();
+ splitToStringVector(mTempList, msg, '#');
+ if (msg.size() < 1 || msg[msg.size() - 1] != '#')
+ updateList();
+ mRequest = false;
+ return true;
+ }
+ else if (findCutFirst(msg, "oL#"))
+ {
+// logger->log("oL");
+ splitToStringVector(mTempList, msg, '#');
+ if (msg.size() < 1 || msg[msg.size() - 1] != '#')
+ updateList();
+ mRequest = false;
+ return true;
+ }
+ else if (msg == "You are currently not in a guild. For more information "
+ "or to discuss the possibility of adding you own guild "
+ "please contact Jero.")
+ {
+ mRequest = true;
+ return true;
+ }
+ else if (findCutFirst(msg, "You have been invited to the ")
+ && findCutLast(msg, " guild chat. If you would like to accept "
+ "this invitation please reply \"yes\" and if not then \"no\" ."))
+ {
+ if (socialWindow)
+ socialWindow->showGuildInvite(msg, 1, "");
+ return true;
+ }
+ else if (!haveNick && (findCutLast(msg, " has been removed "
+ "from the Guild.") || findCutLast(msg," has left the Guild.")))
+ {
+ Guild *guild = createGuild();
+ if (!guild)
+ return false;
+ if (msg.size() < 4)
+ return false;
+ if (msg[0] == '#' && msg[1] == '#')
+ msg = msg.substr(3);
+
+ if (actorSpriteManager)
+ {
+ Being *b = actorSpriteManager->findBeingByName(
+ msg, Being::PLAYER);
+
+ if (b)
+ {
+ b->clearGuilds();
+ b->setGuildName("");
+ b->updateColors();
+ }
+ }
+
+ guild->removeMember(msg);
+ return true;
+ }
+ else if (msg == "You have been removed from the Guild"
+ || msg == "You have left the Guild")
+ {
+ return afterRemove();
+ }
+ else
+ {
+ Guild *guild = createGuild();
+ if (!guild)
+ return false;
+ if (!mTab)
+ {
+ createTab(guild);
+ }
+ if (mTab)
+ {
+ std::string::size_type pos = msg.find(": ", 0);
+ if (pos != std::string::npos)
+ {
+ std::string sender_name = ((pos == std::string::npos)
+ ? "" : msg.substr(0, pos));
+ if (!guild->getMember(sender_name))
+ {
+ mTab->chatLog(msg);
+ return true;
+ }
+
+ msg.erase(0, pos + 2);
+ if (msg.size() > 3 && msg[0] == '#' && msg[1] == '#')
+ msg.erase(0, 3);
+
+ trim(msg);
+ mTab->chatLog(sender_name, msg);
+ }
+ else
+ {
+ mTab->chatLog(msg);
+ }
+ return true;
+ }
+ }
+ return false;
+}
+
+void GuildManager::kick(std::string msg)
+{
+ send("!remove " + msg);
+}
+
+void GuildManager::invite(std::string msg)
+{
+ send("!invite " + msg);
+}
+
+void GuildManager::leave()
+{
+ send("!leave");
+}
+
+void GuildManager::notice(std::string msg)
+{
+ if (msg.empty())
+ send("!removemotd");
+ else
+ send("!setmotd " + msg);
+}
+
+void GuildManager::clear()
+{
+ if (socialWindow)
+ {
+ Guild *guild = Guild::getGuild(1);
+ if (guild)
+ socialWindow->removeTab(guild);
+ }
+}
+
+void GuildManager::inviteResponse(bool response)
+{
+ if (response)
+ send("yes");
+ else
+ send("no");
+}
+
+bool GuildManager::afterRemove()
+{
+ Guild *guild = createGuild();
+ if (!guild)
+ return false;
+ guild->removeFromMembers();
+ guild->clearMembers();
+ if (player_node)
+ {
+ player_node->setGuildName("");
+ player_node->clearGuilds();
+ }
+ SERVER_NOTICE(_("You have left the guild."))
+ delete mTab;
+ mTab = 0;
+
+ if (socialWindow)
+ socialWindow->removeTab(guild);
+ if (actorSpriteManager)
+ {
+ actorSpriteManager->updatePlayerGuild();
+ actorSpriteManager->updatePlayerColors();
+ }
+ reload();
+ return true;
+}
diff --git a/src/guildmanager.h b/src/guildmanager.h
new file mode 100644
index 000000000..80014e352
--- /dev/null
+++ b/src/guildmanager.h
@@ -0,0 +1,94 @@
+/*
+ * The ManaPlus Client
+ * 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 GUILDMANAGER_H
+#define GUILDMANAGER_H
+
+#include "utils/dtor.h"
+
+#include <map>
+#include <string>
+#include <vector>
+
+class Guild;
+class GuildChatTab;
+
+class GuildManager
+{
+ public:
+ GuildManager();
+
+ ~GuildManager();
+
+ static void init();
+
+ void chat(std::string msg);
+
+ void send(std::string msg);
+
+ bool processGuildMessage(std::string msg);
+
+ void getNames(std::vector<std::string> &names);
+
+ void requestGuildInfo();
+
+ void updateList();
+
+ static bool getEnableGuildBot()
+ { return mEnableGuildBot; }
+
+ void kick(std::string msg);
+
+ void invite(std::string msg);
+
+ void leave();
+
+ void notice(std::string msg);
+
+ void createTab(Guild *guild);
+
+ Guild *createGuild();
+
+ void clear();
+
+ void reload();
+
+ void inviteResponse(bool response);
+
+ bool afterRemove();
+
+ bool havePower()
+ { return mHavePower; }
+
+ private:
+ bool process(std::string msg);
+
+ static bool mEnableGuildBot;
+ bool mGotInfo;
+ bool mGotName;
+ bool mHavePower;
+ std::vector<std::string> mTempList;
+ GuildChatTab *mTab;
+ bool mRequest;
+};
+
+extern GuildManager *guildManager;
+
+#endif // GUILDMANAGER_H
diff --git a/src/joystick.cpp b/src/joystick.cpp
index 8f808a2d1..f45729351 100644
--- a/src/joystick.cpp
+++ b/src/joystick.cpp
@@ -24,8 +24,6 @@
#include "joystick.h"
#include "logger.h"
-#include <cassert>
-
#include "debug.h"
int Joystick::joystickCount = 0;
@@ -48,7 +46,8 @@ Joystick::Joystick(int no):
mCalibrating(false),
mEnabled(false)
{
- assert(no < joystickCount);
+ if (no >= joystickCount)
+ no = joystickCount;
mJoystick = SDL_JoystickOpen(no);
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 5192390bc..e9386a5ee 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -78,8 +78,6 @@
#include "utils/gettext.h"
#include "utils/stringutils.h"
-#include <cassert>
-
#include "mumblemanager.h"
#include "debug.h"
diff --git a/src/main.h b/src/main.h
index 9f8bbc6ac..f8b6d97ba 100644
--- a/src/main.h
+++ b/src/main.h
@@ -85,8 +85,8 @@
//define DEBUG_ALPHA_CACHE 1
//define DEBUG_OPENGL_LEAKS 1
-#define SMALL_VERSION "1.1.8.21"
-#define CHECK_VERSION "01.01.08.21"
+#define SMALL_VERSION "1.1.9.4"
+#define CHECK_VERSION "01.01.09.04"
#define PACKAGE_EXTENDED_VERSION "ManaPlus (" PACKAGE_OS \
diff --git a/src/map.cpp b/src/map.cpp
index 700f6d0d2..947bb8f09 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -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
@@ -2015,7 +2015,10 @@ void Map::reduce()
{
MapLayer *layer = *ri;
if (x >= layer->mWidth || y >= layer->mHeight)
+ {
+ ++ ri;
continue;
+ }
Image *img = layer->mTiles[x + y * layer->mWidth];
if (img && !img->isAlphaVisible())
diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp
index 06e86f8a4..4a5cfb841 100644
--- a/src/net/ea/beinghandler.cpp
+++ b/src/net/ea/beinghandler.cpp
@@ -29,6 +29,7 @@
#include "client.h"
#include "effectmanager.h"
#include "guild.h"
+#include "guildmanager.h"
#include "keyboardconfig.h"
#include "localplayer.h"
#include "logger.h"
@@ -661,7 +662,8 @@ void BeingHandler::processPlayerGuilPartyInfo(Net::MessageIn &msg)
if ((dstBeing = actorSpriteManager->findBeing(msg.readInt32())))
{
dstBeing->setPartyName(msg.readString(24));
- dstBeing->setGuildName(msg.readString(24));
+ if (!guildManager || !GuildManager::getEnableGuildBot())
+ dstBeing->setGuildName(msg.readString(24));
dstBeing->setGuildPos(msg.readString(24));
dstBeing->addToCache();
msg.readString(24); // Discard this
diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp
index c188a2204..5737cc2b2 100644
--- a/src/net/ea/chathandler.cpp
+++ b/src/net/ea/chathandler.cpp
@@ -25,6 +25,7 @@
#include "actorspritemanager.h"
#include "being.h"
#include "configuration.h"
+#include "guildmanager.h"
#include "localplayer.h"
#include "playerrelations.h"
#include "logger.h"
@@ -161,6 +162,12 @@ void ChatHandler::processWhisper(Net::MessageIn &msg)
if (nick != "Server")
{
+ if (guildManager && GuildManager::getEnableGuildBot()
+ && nick == "guild" && guildManager->processGuildMessage(chatMsg))
+ {
+ return;
+ }
+
if (player_relations.hasPermission(
nick, PlayerRelation::WHISPER))
{
diff --git a/src/net/ea/guildhandler.cpp b/src/net/ea/guildhandler.cpp
index 0210a76ff..2accb1f1d 100644
--- a/src/net/ea/guildhandler.cpp
+++ b/src/net/ea/guildhandler.cpp
@@ -125,6 +125,7 @@ void GuildHandler::processGuildPositionInfo(Net::MessageIn &msg)
if (!guildTab && chatWindow)
{
guildTab = new GuildTab();
+ guildTab->loadFromLogFile("#Guild");
if (player_node)
player_node->addGuild(taGuild);
memberList(guildId);
diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp
index 045a2332b..bd6f19d97 100644
--- a/src/net/ea/partyhandler.cpp
+++ b/src/net/ea/partyhandler.cpp
@@ -359,6 +359,7 @@ void PartyHandler::processPartyLeave(Net::MessageIn &msg)
if (socialWindow && Ea::taParty)
socialWindow->removeTab(Ea::taParty);
+ player_node->setPartyName("");
}
else
{
@@ -372,7 +373,10 @@ void PartyHandler::processPartyLeave(Net::MessageIn &msg)
{
Being *b = actorSpriteManager->findBeing(id);
if (b && b->getType() == Being::PLAYER)
+ {
b->setParty(0);
+ b->setPartyName("");
+ }
}
if (Ea::taParty)
Ea::taParty->removeMember(id);
diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp
index 4198c14ad..3af237b5b 100644
--- a/src/net/ea/playerhandler.cpp
+++ b/src/net/ea/playerhandler.cpp
@@ -359,9 +359,11 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg)
case 0x0029:
PlayerInfo::setStatBase(EA_ATK, value);
+ PlayerInfo::updateAttrs();
break;
case 0x002a:
PlayerInfo::setStatMod(EA_ATK, value);
+ PlayerInfo::updateAttrs();
break;
case 0x002b:
@@ -402,8 +404,9 @@ void PlayerHandler::processPlayerStatUpdate1(Net::MessageIn &msg)
case 0x0035:
player_node->setAttackSpeed(value);
- PlayerInfo::setStatBase(ATTACK_SPEED, value);
- PlayerInfo::setStatMod(ATTACK_SPEED, 0);
+ PlayerInfo::setStatBase(ATTACK_DELAY, value);
+ PlayerInfo::setStatMod(ATTACK_DELAY, 0);
+ PlayerInfo::updateAttrs();
break;
case 0x0037:
@@ -484,6 +487,8 @@ void PlayerHandler::processPlayerStatUpdate3(Net::MessageIn &msg)
PlayerInfo::setStatBase(type, base, false);
PlayerInfo::setStatMod(type, bonus);
+ if (type == EA_ATK || type == ATTACK_DELAY)
+ PlayerInfo::updateAttrs();
}
void PlayerHandler::processPlayerStatUpdate4(Net::MessageIn &msg)
@@ -552,6 +557,7 @@ void PlayerHandler::processPlayerStatUpdate5(Net::MessageIn &msg)
PlayerInfo::setStatBase(EA_ATK, msg.readInt16(), false);
PlayerInfo::setStatMod(EA_ATK, msg.readInt16());
+ PlayerInfo::updateAttrs();
val = msg.readInt16();
PlayerInfo::setStatBase(EA_MATK, val, false);
@@ -636,4 +642,8 @@ int PlayerHandler::getJobLocation() const
return EA_JOB;
}
+int PlayerHandler::getAttackLocation() const
+{
+ return EA_ATK;
+}
} // namespace Ea
diff --git a/src/net/ea/playerhandler.h b/src/net/ea/playerhandler.h
index 8b8751630..57bcbdcd5 100644
--- a/src/net/ea/playerhandler.h
+++ b/src/net/ea/playerhandler.h
@@ -55,6 +55,8 @@ class PlayerHandler : public Net::PlayerHandler
int getJobLocation() const;
+ int getAttackLocation() const;
+
void processWalkResponse(Net::MessageIn &msg);
void processPlayerWarp(Net::MessageIn &msg);
diff --git a/src/net/manaserv/adminhandler.cpp b/src/net/manaserv/adminhandler.cpp
index 2c76e99a3..a8860d73b 100644
--- a/src/net/manaserv/adminhandler.cpp
+++ b/src/net/manaserv/adminhandler.cpp
@@ -91,7 +91,8 @@ void AdminHandler::mute(int playerId A_UNUSED, int type A_UNUSED,
// TODO
}
-void AdminHandler::warp(std::string map, int x, int y)
+void AdminHandler::warp(std::string map A_UNUSED,
+ int x A_UNUSED, int y A_UNUSED)
{
// TODO
}
diff --git a/src/net/manaserv/adminhandler.h b/src/net/manaserv/adminhandler.h
index 65e9ea2b0..17d296bd6 100644
--- a/src/net/manaserv/adminhandler.h
+++ b/src/net/manaserv/adminhandler.h
@@ -24,6 +24,7 @@
#define NET_MANASERV_ADMINHANDLER_H
#include "net/adminhandler.h"
+#include "string"
#ifdef __GNUC__
#define A_UNUSED __attribute__ ((unused))
diff --git a/src/net/manaserv/messagehandler.cpp b/src/net/manaserv/messagehandler.cpp
index 7524c95e8..2e9603f19 100644
--- a/src/net/manaserv/messagehandler.cpp
+++ b/src/net/manaserv/messagehandler.cpp
@@ -24,8 +24,6 @@
#include "net/manaserv/network.h"
-#include <cassert>
-
namespace ManaServ
{
diff --git a/src/net/manaserv/playerhandler.cpp b/src/net/manaserv/playerhandler.cpp
index 3dfddb436..da8958044 100644
--- a/src/net/manaserv/playerhandler.cpp
+++ b/src/net/manaserv/playerhandler.cpp
@@ -432,6 +432,11 @@ int PlayerHandler::getJobLocation() const
return -1;
}
+int PlayerHandler::getAttackLocation() const
+{
+ return -1;
+}
+
Vector PlayerHandler::getDefaultWalkSpeed() const
{
// Return translation in pixels per ticks.
diff --git a/src/net/manaserv/playerhandler.h b/src/net/manaserv/playerhandler.h
index dcd05d5fc..f00fea42a 100644
--- a/src/net/manaserv/playerhandler.h
+++ b/src/net/manaserv/playerhandler.h
@@ -74,6 +74,7 @@ class PlayerHandler : public MessageHandler, public Net::PlayerHandler
bool canCorrectAttributes() const;
int getJobLocation() const;
+ int getAttackLocation() const;
Vector getDefaultWalkSpeed() const;
diff --git a/src/net/playerhandler.h b/src/net/playerhandler.h
index 2abd12d57..47d666036 100644
--- a/src/net/playerhandler.h
+++ b/src/net/playerhandler.h
@@ -68,6 +68,8 @@ class PlayerHandler
virtual int getJobLocation() const = 0;
+ virtual int getAttackLocation() const = 0;
+
virtual Vector getDefaultWalkSpeed() const = 0;
};
diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp
index 17503a406..ce2db733f 100644
--- a/src/net/tmwa/beinghandler.cpp
+++ b/src/net/tmwa/beinghandler.cpp
@@ -331,6 +331,9 @@ void BeingHandler::processBeingChangeLook(Net::MessageIn &msg, bool look2)
dstBeing->setSpriteColor(SPRITE_HAIR,
ColorDB::getHairColor(id));
break;
+ case 7: // Clothes color
+ // ignoring it
+ break;
case 8: // eAthena LOOK_SHIELD
if (!config.getBoolValue("hideShield"))
{
@@ -552,7 +555,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/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp
index 746cb6620..e1b565399 100644
--- a/src/net/tmwa/generalhandler.cpp
+++ b/src/net/tmwa/generalhandler.cpp
@@ -67,7 +67,6 @@
#include "utils/gettext.h"
-#include <assert.h>
#include <list>
#include "debug.h"
@@ -273,12 +272,14 @@ void GeneralHandler::event(Mana::Channels channel,
statusWindow->addAttribute(FLEE, _("% Evade"), false, "");
// xgettext:no-c-format
statusWindow->addAttribute(CRIT, _("% Critical"), false, "");
- statusWindow->addAttribute(ATTACK_SPEED, _("Attack Delay"),
+ statusWindow->addAttribute(ATTACK_DELAY, _("Attack Delay"),
false, "");
statusWindow->addAttribute(WALK_SPEED, _("Walk Delay"),
false, "");
statusWindow->addAttribute(ATTACK_RANGE, _("Attack Range"),
false, "");
+ statusWindow->addAttribute(ATTACK_SPEED, _("Damage per sec."),
+ false, "");
}
else if (event.getName() == Mana::EVENT_GUIWINDOWSUNLOADING)
{
diff --git a/src/particlecontainer.cpp b/src/particlecontainer.cpp
index d00c68a63..70b1e2c84 100644
--- a/src/particlecontainer.cpp
+++ b/src/particlecontainer.cpp
@@ -20,8 +20,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <cassert>
-
#include "particle.h"
#include "particlecontainer.h"
diff --git a/src/party.h b/src/party.h
index 466f63a19..e286a794a 100644
--- a/src/party.h
+++ b/src/party.h
@@ -149,6 +149,11 @@ public:
void sort();
+ typedef std::vector<PartyMember*> MemberList;
+
+ MemberList *getMembers()
+ { return &mMembers; }
+
static Party *getParty(short id);
static void clearParties();
@@ -164,7 +169,6 @@ private:
~Party();
- typedef std::vector<PartyMember*> MemberList;
MemberList mMembers;
std::string mName;
short mId;
diff --git a/src/playerinfo.cpp b/src/playerinfo.cpp
index 3bb196921..769d24a16 100644
--- a/src/playerinfo.cpp
+++ b/src/playerinfo.cpp
@@ -31,6 +31,9 @@
#include "resources/itemdb.h"
#include "resources/iteminfo.h"
+#include "net/net.h"
+#include "net/playerhandler.h"
+
#include "debug.h"
namespace PlayerInfo
@@ -280,6 +283,23 @@ void setTrading(bool trading)
}
}
+void updateAttrs()
+{
+ int attr = Net::getPlayerHandler()->getAttackLocation();
+ if (attr != -1 && getStatBase(ATTACK_DELAY))
+ {
+ setStatBase(ATTACK_SPEED, getStatBase(attr) * 1000 / getStatBase(
+ ATTACK_DELAY), false);
+ setStatMod(ATTACK_SPEED, getStatMod(attr) * 1000 / getStatBase(
+ ATTACK_DELAY), true);
+ }
+ else
+ {
+ setStatBase(ATTACK_SPEED, 0, false);
+ setStatMod(ATTACK_SPEED, 0, true);
+ }
+}
+
class PlayerInfoListener : Mana::Listener
{
public:
diff --git a/src/playerinfo.h b/src/playerinfo.h
index 401dd26e0..b90e47ce9 100644
--- a/src/playerinfo.h
+++ b/src/playerinfo.h
@@ -45,9 +45,10 @@ enum Attribute
SKILL_POINTS,
CHAR_POINTS,
CORR_POINTS,
- ATTACK_SPEED = 100,
+ ATTACK_DELAY = 100,
ATTACK_RANGE = 101,
- WALK_SPEED = 102
+ WALK_SPEED = 102,
+ ATTACK_SPEED = 103
};
/**
@@ -218,6 +219,8 @@ namespace PlayerInfo
*/
void setTrading(bool trading);
+ void updateAttrs();
+
/**
* Initializes some internals.
*/
diff --git a/src/resources/imageloader.cpp b/src/resources/imageloader.cpp
index c63d33c00..72a839573 100644
--- a/src/resources/imageloader.cpp
+++ b/src/resources/imageloader.cpp
@@ -29,8 +29,6 @@
#include <guichan/sdl/sdlpixel.hpp>
-#include <cassert>
-
#include "debug.h"
#ifdef free
@@ -79,12 +77,10 @@ int ProxyImage::getHeight() const
return mImage->mBounds.h;
else
return 0;
-// return mSDLImage ? mSDLImage->h : mImage->getHeight();
}
gcn::Color ProxyImage::getPixel(int x, int y)
{
- assert(mSDLImage);
return gcn::SDLgetPixel(mSDLImage, x, y);
}
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp
index e60127997..733c12958 100644
--- a/src/resources/itemdb.cpp
+++ b/src/resources/itemdb.cpp
@@ -36,8 +36,6 @@
#include <libxml/tree.h>
-#include <cassert>
-
#include "debug.h"
namespace
@@ -435,7 +433,8 @@ void ItemDB::unload()
bool ItemDB::exists(int id)
{
- assert(mLoaded);
+ if (!mLoaded)
+ return false;
ItemInfos::const_iterator i = mItemInfos.find(id);
@@ -444,7 +443,8 @@ bool ItemDB::exists(int id)
const ItemInfo &ItemDB::get(int id)
{
- assert(mLoaded);
+ if (!mLoaded)
+ load();
ItemInfos::const_iterator i = mItemInfos.find(id);
@@ -459,7 +459,8 @@ const ItemInfo &ItemDB::get(int id)
const ItemInfo &ItemDB::get(const std::string &name)
{
- assert(mLoaded);
+ if (!mLoaded)
+ load();
NamedItemInfos::const_iterator i = mNamedItemInfos.find(normalize(name));
@@ -560,6 +561,10 @@ int parseDirectionName(std::string name)
id = DIRECTION_RIGHT;
else if (name == "downright" || name == "rightdown")
id = DIRECTION_DOWNRIGHT;
+ else if (name == "downall")
+ id = -2;
+ else if (name == "upall")
+ id = -3;
return id;
}
@@ -593,7 +598,7 @@ void loadSoundRef(ItemInfo *itemInfo, xmlNodePtr node)
else
{
logger->log("ItemDB: Ignoring unknown sound event '%s'",
- event.c_str());
+ event.c_str());
}
}
@@ -624,21 +629,100 @@ void loadReplaceSprite(ItemInfo *itemInfo, xmlNodePtr replaceNode)
std::string removeSprite = XML::getProperty(replaceNode, "sprite", "");
int direction = parseDirectionName(XML::getProperty(
replaceNode, "direction", "all"));
- std::map<int, int> *mapList = itemInfo->addReplaceSprite(
- parseSpriteName(removeSprite), direction);
-
- if (!mapList)
- return;
itemInfo->setRemoveSprites();
- for_each_xml_child_node(itemNode, replaceNode)
+ switch (direction)
{
- if (xmlStrEqual(itemNode->name, BAD_CAST "item"))
+ case -1:
{
- int from = XML::getProperty(itemNode, "from", 0);
- int to = XML::getProperty(itemNode, "to", 1);
- (*mapList)[from] = to;
+ for_each_xml_child_node(itemNode, replaceNode)
+ {
+ if (xmlStrEqual(itemNode->name, BAD_CAST "item"))
+ {
+ int from = XML::getProperty(itemNode, "from", 0);
+ int to = XML::getProperty(itemNode, "to", 1);
+ for (int f = 0; f < 9; f ++)
+ {
+ std::map<int, int> *mapList
+ = itemInfo->addReplaceSprite(
+ parseSpriteName(removeSprite), f);
+ if (!mapList)
+ continue;
+ (*mapList)[from] = to;
+ }
+ }
+ }
+ break;
+ }
+ case -2:
+ {
+ for_each_xml_child_node(itemNode, replaceNode)
+ {
+ if (xmlStrEqual(itemNode->name, BAD_CAST "item"))
+ {
+ int from = XML::getProperty(itemNode, "from", 0);
+ int to = XML::getProperty(itemNode, "to", 1);
+ std::map<int, int> *mapList = itemInfo->addReplaceSprite(
+ parseSpriteName(removeSprite), DIRECTION_DOWN);
+ if (mapList)
+ (*mapList)[from] = to;
+
+ mapList = itemInfo->addReplaceSprite(parseSpriteName(
+ removeSprite), DIRECTION_DOWNLEFT);
+ if (mapList)
+ (*mapList)[from] = to;
+
+ mapList = itemInfo->addReplaceSprite(parseSpriteName(
+ removeSprite), DIRECTION_DOWNRIGHT);
+ if (mapList)
+ (*mapList)[from] = to;
+ }
+ }
+ break;
+ }
+ case -3:
+ {
+ for_each_xml_child_node(itemNode, replaceNode)
+ {
+ if (xmlStrEqual(itemNode->name, BAD_CAST "item"))
+ {
+ int from = XML::getProperty(itemNode, "from", 0);
+ int to = XML::getProperty(itemNode, "to", 1);
+ std::map<int, int> *mapList = itemInfo->addReplaceSprite(
+ parseSpriteName(removeSprite), DIRECTION_UP);
+ if (mapList)
+ (*mapList)[from] = to;
+
+ mapList = itemInfo->addReplaceSprite(parseSpriteName(
+ removeSprite), DIRECTION_UPLEFT);
+ if (mapList)
+ (*mapList)[from] = to;
+
+ mapList = itemInfo->addReplaceSprite(parseSpriteName(
+ removeSprite), DIRECTION_UPRIGHT);
+ if (mapList)
+ (*mapList)[from] = to;
+ }
+ }
+ break;
+ }
+ default:
+ {
+ std::map<int, int> *mapList = itemInfo->addReplaceSprite(
+ parseSpriteName(removeSprite), direction);
+ if (!mapList)
+ return;
+ for_each_xml_child_node(itemNode, replaceNode)
+ {
+ if (xmlStrEqual(itemNode->name, BAD_CAST "item"))
+ {
+ int from = XML::getProperty(itemNode, "from", 0);
+ int to = XML::getProperty(itemNode, "to", 1);
+ (*mapList)[from] = to;
+ }
+ }
+ break;
}
}
}
diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp
index 56cfc01f6..fb4b8ed5e 100644
--- a/src/resources/iteminfo.cpp
+++ b/src/resources/iteminfo.cpp
@@ -144,25 +144,6 @@ const std::string &ItemInfo::getSound(EquipmentSoundEvent event) const
std::map<int, int> *ItemInfo::addReplaceSprite(int sprite, int direction)
{
- if (direction == -1)
- {
- SpriteToItemMap *spMap = new SpriteToItemMap();
- for (int f = 0; f < 9; f ++)
- {
- if (!mSpriteToItemReplaceMap[f])
- {
- mSpriteToItemReplaceMap[f] = spMap;
- direction = f;
- }
- }
- if (direction >= 0)
- mSpriteToItemReplaceList.push_back(spMap);
- else
- delete spMap;
- if (direction == -1)
- direction = 1;
- }
-
if (direction < 0 || direction >= 9)
return 0;
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index 70c45054f..685d415ff 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -37,7 +37,6 @@
#include "utils/stringutils.h"
#include "utils/xml.h"
-#include <cassert>
#include <iostream>
#include <zlib.h>
@@ -110,7 +109,8 @@ int inflateMemory(unsigned char *in, unsigned int inLength,
}
ret = inflate(&strm, Z_NO_FLUSH);
- assert(ret != Z_STREAM_ERROR);
+ if (ret == Z_STREAM_ERROR)
+ return ret;
switch (ret)
{
@@ -140,7 +140,7 @@ int inflateMemory(unsigned char *in, unsigned int inLength,
}
}
while (ret != Z_STREAM_END);
- assert(strm.avail_in == 0);
+// assert(strm.avail_in == 0);
outLength = bufferSize - strm.avail_out;
(void) inflateEnd(&strm);
diff --git a/src/resources/resource.cpp b/src/resources/resource.cpp
index b180712c1..552af06ec 100644
--- a/src/resources/resource.cpp
+++ b/src/resources/resource.cpp
@@ -27,8 +27,6 @@
#include "resources/resourcemanager.h"
-#include <cassert>
-
#include "debug.h"
Resource::~Resource()
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
index 13170092e..176c5499c 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())
@@ -511,3 +524,65 @@ void deleteCharLeft(std::string &str, unsigned *pos)
break;
}
}
+
+bool findLast(std::string &str1, std::string str2)
+{
+ const unsigned s1 = str1.size();
+ const unsigned s2 = str2.size();
+ if (s1 < s2)
+ return false;
+ std::string tmp = str1.substr(s1 - s2);
+ if (tmp == str2)
+ return true;
+ return false;
+}
+
+bool findFirst(std::string &str1, std::string str2)
+{
+ const unsigned s1 = str1.size();
+ const unsigned s2 = str2.size();
+ if (s1 < s2)
+ return false;
+ std::string tmp = str1.substr(0, s2);
+ if (tmp == str2)
+ return true;
+ return false;
+}
+
+bool findCutLast(std::string &str1, std::string str2)
+{
+ const unsigned s1 = str1.size();
+ const unsigned s2 = str2.size();
+ if (s1 < s2)
+ return false;
+ std::string tmp = str1.substr(s1 - s2);
+ if (tmp == str2)
+ {
+ str1 = str1.substr(0, s1 - s2);
+ return true;
+ }
+ return false;
+}
+
+bool findCutFirst(std::string &str1, std::string str2)
+{
+ const unsigned s1 = str1.size();
+ const unsigned s2 = str2.size();
+ if (s1 < s2)
+ return false;
+ std::string tmp = str1.substr(0, s2);
+ if (tmp == str2)
+ {
+ str1 = str1.substr(s2);
+ return true;
+ }
+ return false;
+}
+
+std::string &removeProtocol(std::string &url)
+{
+ int i = url.find("://");
+ if (i != (int)std::string::npos)
+ url = url.substr(i + 3);
+ return url;
+}
diff --git a/src/utils/stringutils.h b/src/utils/stringutils.h
index 94747d2fe..25fe11e2d 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);
@@ -190,4 +193,14 @@ std::string stringToHexPath(const std::string &str);
void deleteCharLeft(std::string &str, unsigned *pos);
+bool findLast(std::string &str1, std::string str2);
+
+bool findFirst(std::string &str1, std::string str2);
+
+bool findCutLast(std::string &str1, std::string str2);
+
+bool findCutFirst(std::string &str1, std::string str2);
+
+std::string &removeProtocol(std::string &url);
+
#endif // UTILS_STRINGUTILS_H