summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2010-07-19 20:22:59 +0200
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2010-07-19 20:22:59 +0200
commit86eb0c08d233636cd4647649c6542d3cf410e3ab (patch)
tree9721759b41f0256f15c3786c357448a93215440e /src/gui
parent335eec717f6189c01d8217dd2c4f4e74a171d9a5 (diff)
parent2d584d7e8aaeacbcb1036bae5c8deca9b810fe60 (diff)
downloadmana-86eb0c08d233636cd4647649c6542d3cf410e3ab.tar.gz
mana-86eb0c08d233636cd4647649c6542d3cf410e3ab.tar.bz2
mana-86eb0c08d233636cd4647649c6542d3cf410e3ab.tar.xz
mana-86eb0c08d233636cd4647649c6542d3cf410e3ab.zip
Merge branch '1.0'
Conflicts: src/gui/itempopup.cpp src/item.cpp src/monster.cpp src/net/manaserv/playerhandler.cpp src/net/tmwa/partyhandler.cpp src/npc.cpp src/player.cpp src/resources/itemdb.cpp src/resources/monsterdb.cpp src/resources/monsterinfo.cpp src/resources/npcdb.cpp src/resources/spritedef.cpp
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/chat.cpp25
-rw-r--r--src/gui/chat.h2
-rw-r--r--src/gui/gui.cpp1
-rw-r--r--src/gui/help.cpp6
-rw-r--r--src/gui/itempopup.cpp6
-rw-r--r--src/gui/theme.cpp30
-rw-r--r--src/gui/widgets/whispertab.cpp5
7 files changed, 56 insertions, 19 deletions
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index 6ad45fc8..103a2647 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -119,7 +119,7 @@ ChatWindow::~ChatWindow()
{
config.setValue("ReturnToggles", mReturnToggles);
delete mRecorder;
- delete_all(mWhispers);
+ removeAllWhispers();
delete mItemLinkHandler;
}
@@ -235,10 +235,6 @@ bool ChatWindow::isInputFocused() const
void ChatWindow::removeTab(ChatTab *tab)
{
- // Prevent removal of the local chat tab
- if (tab == localChatTab)
- return;
-
mChatTabs->removeTab(tab);
}
@@ -260,6 +256,25 @@ void ChatWindow::removeWhisper(const std::string &nick)
mWhispers.erase(tempNick);
}
+void ChatWindow::removeAllWhispers()
+{
+ TabMap::iterator iter;
+ std::list<ChatTab*> tabs;
+
+ for (iter = mWhispers.begin(); iter != mWhispers.end(); ++iter)
+ {
+ tabs.push_back(iter->second);
+ }
+
+ for (std::list<ChatTab*>::iterator it = tabs.begin();
+ it != tabs.end(); ++it)
+ {
+ delete *it;
+ }
+
+ mWhispers.clear();
+}
+
void ChatWindow::chatInput(const std::string &msg)
{
ChatTab *tab = getFocused();
diff --git a/src/gui/chat.h b/src/gui/chat.h
index d6378907..db5fe293 100644
--- a/src/gui/chat.h
+++ b/src/gui/chat.h
@@ -202,6 +202,8 @@ class ChatWindow : public Window,
void removeWhisper(const std::string &nick);
+ void removeAllWhispers();
+
void autoComplete();
std::string autoCompleteHistory(std::string partName);
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index e2354386..df2ddadf 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -107,6 +107,7 @@ Gui::Gui(Graphics *graphics):
const int fontSize = (int) config.getValue("fontSize", 11);
std::string fontFile = branding.getValue("font", "fonts/dejavusans.ttf");
std::string path = resman->getPath(fontFile);
+
try
{
mGuiFont = new TrueTypeFont(path, fontSize);
diff --git a/src/gui/help.cpp b/src/gui/help.cpp
index 9d237f18..f3c6a0af 100644
--- a/src/gui/help.cpp
+++ b/src/gui/help.cpp
@@ -29,6 +29,7 @@
#include "gui/widgets/scrollarea.h"
#include "resources/resourcemanager.h"
+#include "configuration.h"
#include "utils/gettext.h"
@@ -93,8 +94,11 @@ void HelpWindow::loadHelp(const std::string &helpFile)
void HelpWindow::loadFile(const std::string &file)
{
ResourceManager *resman = ResourceManager::getInstance();
+ std::string helpPath = branding.getValue("helpPath", "");
+ if (helpPath.empty())
+ helpPath = paths.getValue("help", "help/");
std::vector<std::string> lines =
- resman->loadTextFile("help/" + file + ".txt");
+ resman->loadTextFile(helpPath + file + ".txt");
for (unsigned int i = 0; i < lines.size(); ++i)
{
diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp
index 5e89bc35..03e6e380 100644
--- a/src/gui/itempopup.cpp
+++ b/src/gui/itempopup.cpp
@@ -102,8 +102,10 @@ void ItemPopup::setItem(const ItemInfo &item, bool showImage)
if (showImage)
{
ResourceManager *resman = ResourceManager::getInstance();
- Image *image = resman->getImage("graphics/items/" +
- item.getDisplay().image);
+ Image *image = resman->getImage(
+ paths.getValue("itemIcons", "graphics/items/")
+ + item.getDisplay().image);
+
mIcon->setImage(image);
if (image)
{
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp
index e46616e0..12de1f91 100644
--- a/src/gui/theme.cpp
+++ b/src/gui/theme.cpp
@@ -40,11 +40,22 @@
#include <algorithm>
-#define GUI_ROOT "graphics/gui/"
-
+static std::string defaultThemePath;
std::string Theme::mThemePath;
Theme *Theme::mInstance = 0;
+// Set the theme path...
+static void initDefaultThemePath()
+{
+ ResourceManager *resman = ResourceManager::getInstance();
+ defaultThemePath = branding.getValue("guiThemePath", "");
+
+ if (!defaultThemePath.empty() && resman->isDirectory(defaultThemePath))
+ return;
+ else
+ defaultThemePath = "graphics/gui/";
+}
+
Skin::Skin(ImageRect skin, Image *close, Image *stickyUp, Image *stickyDown,
const std::string &filePath,
const std::string &name):
@@ -55,8 +66,7 @@ Skin::Skin(ImageRect skin, Image *close, Image *stickyUp, Image *stickyDown,
mCloseImage(close),
mStickyImageUp(stickyUp),
mStickyImageDown(stickyDown)
-{
-}
+{}
Skin::~Skin()
{
@@ -99,6 +109,8 @@ Theme::Theme():
mMinimumOpacity(-1.0f),
mProgressColors(ProgressColors(THEME_PROG_END))
{
+ initDefaultThemePath();
+
config.addListener("guialpha", this);
loadColors();
@@ -313,7 +325,7 @@ bool Theme::tryThemePath(std::string themePath)
{
if (!themePath.empty())
{
- themePath = GUI_ROOT + themePath;
+ themePath = defaultThemePath + themePath;
if (PHYSFS_exists(themePath.c_str()))
{
mThemePath = themePath;
@@ -331,7 +343,7 @@ void Theme::prepareThemePath()
// Try theme from branding
if (!tryThemePath(branding.getValue("theme", "")))
// Use default
- mThemePath = GUI_ROOT;
+ mThemePath = defaultThemePath;
instance()->loadColors(mThemePath);
}
@@ -356,7 +368,7 @@ std::string Theme::resolveThemePath(const std::string &path)
return getThemePath() + "/" + path;
// Backup
- return std::string(GUI_ROOT) + "/" + path;
+ return std::string(defaultThemePath) + "/" + path;
}
Image *Theme::getImageFromTheme(const std::string &path)
@@ -508,11 +520,11 @@ static int readProgressType(const std::string &type)
void Theme::loadColors(std::string file)
{
- if (file == GUI_ROOT)
+ if (file == defaultThemePath)
return; // No need to reload
if (file == "")
- file = GUI_ROOT;
+ file = defaultThemePath;
file += "/colors.xml";
diff --git a/src/gui/widgets/whispertab.cpp b/src/gui/widgets/whispertab.cpp
index 89ff72d3..685d28ab 100644
--- a/src/gui/widgets/whispertab.cpp
+++ b/src/gui/widgets/whispertab.cpp
@@ -42,7 +42,8 @@ WhisperTab::WhisperTab(const std::string &nick) :
WhisperTab::~WhisperTab()
{
- chatWindow->removeWhisper(mNick);
+ if (chatWindow)
+ chatWindow->removeWhisper(mNick);
}
void WhisperTab::handleInput(const std::string &msg)
@@ -120,4 +121,4 @@ void WhisperTab::saveToLogFile(std::string &msg)
{
if (chatLogger)
chatLogger->log(getNick(), msg);
-} \ No newline at end of file
+}