summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorReid <reidyaro@gmail.com>2011-08-24 22:42:17 +0200
committerReid <reidyaro@gmail.com>2011-08-24 22:42:17 +0200
commit43c19a8321bd0c4bcf36655d74e895397aff7eea (patch)
treec8f7933367ae1e757a3166a04772274896d58c9c /src/gui
parentc1ec2b921389cb5c44d9ae572ea4851891cf8bc9 (diff)
parent9505e3789cc9db6a10a68b9794a586604271b76f (diff)
downloadmanaverse-43c19a8321bd0c4bcf36655d74e895397aff7eea.tar.gz
manaverse-43c19a8321bd0c4bcf36655d74e895397aff7eea.tar.bz2
manaverse-43c19a8321bd0c4bcf36655d74e895397aff7eea.tar.xz
manaverse-43c19a8321bd0c4bcf36655d74e895397aff7eea.zip
Merge branch 'master' of gitorious.org:manaplus/manaplus
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/beingpopup.cpp6
-rw-r--r--src/gui/botcheckerwindow.cpp8
-rw-r--r--src/gui/botcheckerwindow.h5
-rw-r--r--src/gui/changeemaildialog.cpp2
-rw-r--r--src/gui/changepassworddialog.cpp2
-rw-r--r--src/gui/charselectdialog.cpp2
-rw-r--r--src/gui/chatwindow.cpp34
-rw-r--r--src/gui/chatwindow.h5
-rw-r--r--src/gui/connectiondialog.cpp2
-rw-r--r--src/gui/didyouknowwindow.cpp2
-rw-r--r--src/gui/editdialog.cpp5
-rw-r--r--src/gui/editdialog.h5
-rw-r--r--src/gui/emotepopup.cpp2
-rw-r--r--src/gui/equipmentwindow.cpp241
-rw-r--r--src/gui/equipmentwindow.h31
-rw-r--r--src/gui/gui.cpp15
-rw-r--r--src/gui/helpwindow.cpp2
-rw-r--r--src/gui/inventorywindow.cpp2
-rw-r--r--src/gui/itempopup.cpp3
-rw-r--r--src/gui/killstats.cpp5
-rw-r--r--src/gui/killstats.h5
-rw-r--r--src/gui/minimap.cpp2
-rw-r--r--src/gui/ministatuswindow.cpp (renamed from src/gui/ministatus.cpp)2
-rw-r--r--src/gui/ministatuswindow.h (renamed from src/gui/ministatus.h)4
-rw-r--r--src/gui/outfitwindow.cpp10
-rw-r--r--src/gui/outfitwindow.h2
-rw-r--r--src/gui/palette.h2
-rw-r--r--src/gui/popupmenu.cpp61
-rw-r--r--src/gui/popupmenu.h5
-rw-r--r--src/gui/quitdialog.cpp8
-rw-r--r--src/gui/quitdialog.h1
-rw-r--r--src/gui/register.cpp2
-rw-r--r--src/gui/sdlfont.cpp2
-rw-r--r--src/gui/serverdialog.cpp39
-rw-r--r--src/gui/setup.cpp19
-rw-r--r--src/gui/setup.h2
-rw-r--r--src/gui/setup_audio.cpp2
-rw-r--r--src/gui/setup_chat.cpp19
-rw-r--r--src/gui/setup_chat.h4
-rw-r--r--src/gui/setup_other.cpp9
-rw-r--r--src/gui/setup_other.h4
-rw-r--r--src/gui/setup_perfomance.cpp98
-rw-r--r--src/gui/setup_perfomance.h44
-rw-r--r--src/gui/setup_players.cpp564
-rw-r--r--src/gui/setup_players.h88
-rw-r--r--src/gui/setup_relations.cpp439
-rw-r--r--src/gui/setup_relations.h81
-rw-r--r--src/gui/setup_theme.cpp54
-rw-r--r--src/gui/setup_theme.h9
-rw-r--r--src/gui/setup_video.cpp101
-rw-r--r--src/gui/setup_video.h10
-rw-r--r--src/gui/shopwindow.cpp9
-rw-r--r--src/gui/shopwindow.h2
-rw-r--r--src/gui/skilldialog.cpp14
-rw-r--r--src/gui/socialwindow.cpp2
-rw-r--r--src/gui/specialswindow.cpp2
-rw-r--r--src/gui/spellpopup.cpp10
-rw-r--r--src/gui/spellpopup.h5
-rw-r--r--src/gui/statuspopup.cpp34
-rw-r--r--src/gui/statuspopup.h5
-rw-r--r--src/gui/statuswindow.cpp40
-rw-r--r--src/gui/statuswindow.h7
-rw-r--r--src/gui/textcommandeditor.cpp7
-rw-r--r--src/gui/textcommandeditor.h5
-rw-r--r--src/gui/textpopup.cpp14
-rw-r--r--src/gui/textpopup.h4
-rw-r--r--src/gui/theme.cpp7
-rw-r--r--src/gui/theme.h5
-rw-r--r--src/gui/tradewindow.cpp33
-rw-r--r--src/gui/tradewindow.h4
-rw-r--r--src/gui/unregisterdialog.cpp2
-rw-r--r--src/gui/updaterwindow.cpp (renamed from src/gui/updatewindow.cpp)4
-rw-r--r--src/gui/updaterwindow.h (renamed from src/gui/updatewindow.h)0
-rw-r--r--src/gui/userpalette.cpp2
-rw-r--r--src/gui/viewport.cpp30
-rw-r--r--src/gui/whoisonline.cpp5
-rw-r--r--src/gui/whoisonline.h5
-rw-r--r--src/gui/widgets/avatarlistbox.cpp65
-rw-r--r--src/gui/widgets/avatarlistbox.h1
-rw-r--r--src/gui/widgets/battletab.cpp4
-rw-r--r--src/gui/widgets/browserbox.cpp12
-rw-r--r--src/gui/widgets/browserbox.h4
-rw-r--r--src/gui/widgets/button.cpp11
-rw-r--r--src/gui/widgets/button.h2
-rw-r--r--src/gui/widgets/chattab.cpp11
-rw-r--r--src/gui/widgets/checkbox.cpp4
-rw-r--r--src/gui/widgets/desktop.cpp13
-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.cpp19
-rw-r--r--src/gui/widgets/dropshortcutcontainer.h7
-rw-r--r--src/gui/widgets/emoteshortcutcontainer.cpp16
-rw-r--r--src/gui/widgets/guitable.cpp (renamed from src/gui/widgets/table.cpp)18
-rw-r--r--src/gui/widgets/guitable.h (renamed from src/gui/widgets/table.h)3
-rw-r--r--src/gui/widgets/horizontcontainer.h3
-rw-r--r--src/gui/widgets/inventoryfilter.cpp6
-rw-r--r--src/gui/widgets/inventoryfilter.h4
-rw-r--r--src/gui/widgets/itemcontainer.cpp11
-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.cpp2
-rw-r--r--src/gui/widgets/listbox.cpp8
-rw-r--r--src/gui/widgets/listbox.h1
-rw-r--r--src/gui/widgets/popup.cpp2
-rw-r--r--src/gui/widgets/radiobutton.cpp1
-rw-r--r--src/gui/widgets/scrollarea.cpp16
-rw-r--r--src/gui/widgets/scrollarea.h3
-rw-r--r--src/gui/widgets/setupitem.cpp (renamed from src/gui/setupitem.cpp)90
-rw-r--r--src/gui/widgets/setupitem.h (renamed from src/gui/setupitem.h)29
-rw-r--r--src/gui/widgets/setuptabscroll.cpp3
-rw-r--r--src/gui/widgets/shopitems.cpp5
-rw-r--r--src/gui/widgets/shopitems.h2
-rw-r--r--src/gui/widgets/shoplistbox.cpp40
-rw-r--r--src/gui/widgets/shoplistbox.h6
-rw-r--r--src/gui/widgets/spellshortcutcontainer.cpp11
-rw-r--r--src/gui/widgets/spellshortcutcontainer.h5
-rw-r--r--src/gui/widgets/tab.cpp10
-rw-r--r--src/gui/widgets/tab.h2
-rw-r--r--src/gui/widgets/tabbedarea.cpp2
-rw-r--r--src/gui/widgets/textfield.cpp6
-rw-r--r--src/gui/widgets/tradetab.cpp4
-rw-r--r--src/gui/widgets/vertcontainer.cpp2
-rw-r--r--src/gui/widgets/whispertab.cpp4
-rw-r--r--src/gui/widgets/window.cpp10
127 files changed, 1745 insertions, 1108 deletions
diff --git a/src/gui/beingpopup.cpp b/src/gui/beingpopup.cpp
index e5dc602a0..8d7b26c1b 100644
--- a/src/gui/beingpopup.cpp
+++ b/src/gui/beingpopup.cpp
@@ -89,6 +89,12 @@ void BeingPopup::show(int x, int y, Being *b)
b->updateComment();
+ if (b->getType() == Being::NPC && b->getComment().empty())
+ {
+ setVisible(false);
+ return;
+ }
+
mBeingName->setCaption(b->getName() + b->getGenderSignWithSpace());
if (gui)
{
diff --git a/src/gui/botcheckerwindow.cpp b/src/gui/botcheckerwindow.cpp
index ac845adc1..4a8f8cf0d 100644
--- a/src/gui/botcheckerwindow.cpp
+++ b/src/gui/botcheckerwindow.cpp
@@ -1,9 +1,10 @@
/*
- * The Mana World
+ * The ManaPlus Client
* Copyright (C) 2009 The Mana World Development Team
* Copyright (C) 2009-2010 Andrei Karas
+ * Copyright (C) 2011 ManaPlus developers
*
- * This file is part of The Mana World.
+ * This file is part of The ManaPlus Client.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -35,7 +36,7 @@
#include "gui/widgets/label.h"
#include "gui/widgets/layout.h"
#include "gui/widgets/layouthelper.h"
-#include "gui/widgets/table.h"
+#include "gui/widgets/guitable.h"
#include "actorspritemanager.h"
#include "configuration.h"
@@ -289,7 +290,6 @@ BotCheckerWindow::BotCheckerWindow():
}
mPlayerTitleTable = new GuiTable(mPlayerTableTitleModel);
- //mPlayerTitleTable->setBackgroundColor(gcn::Color(0xbf, 0xbf, 0xbf));
mPlayerTitleTable->setHeight(1);
mPlayerTableTitleModel->set(0, 0, new Label(_("Name")));
diff --git a/src/gui/botcheckerwindow.h b/src/gui/botcheckerwindow.h
index e378fffb0..a69781865 100644
--- a/src/gui/botcheckerwindow.h
+++ b/src/gui/botcheckerwindow.h
@@ -1,9 +1,10 @@
/*
- * The Mana World
+ * The ManaPlus Client
* Copyright (C) 2009 The Mana World Development Team
* Copyright (C) 2009-2010 Andrei Karas
+ * Copyright (C) 2011 ManaPlus developers
*
- * This file is part of The Mana World.
+ * This file is part of The ManaPlus Client.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/gui/changeemaildialog.cpp b/src/gui/changeemaildialog.cpp
index d424fff91..c24624bc2 100644
--- a/src/gui/changeemaildialog.cpp
+++ b/src/gui/changeemaildialog.cpp
@@ -23,7 +23,7 @@
#include "gui/changeemaildialog.h"
#include "client.h"
-#include "log.h"
+#include "logger.h"
#include "gui/register.h"
#include "gui/okdialog.h"
diff --git a/src/gui/changepassworddialog.cpp b/src/gui/changepassworddialog.cpp
index dc640841a..30012ae52 100644
--- a/src/gui/changepassworddialog.cpp
+++ b/src/gui/changepassworddialog.cpp
@@ -23,7 +23,7 @@
#include "changepassworddialog.h"
#include "client.h"
-#include "log.h"
+#include "logger.h"
#include "gui/register.h"
#include "gui/okdialog.h"
diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp
index 264df06e3..28c7a083c 100644
--- a/src/gui/charselectdialog.cpp
+++ b/src/gui/charselectdialog.cpp
@@ -26,7 +26,7 @@
#include "game.h"
#include "localplayer.h"
#include "units.h"
-#include "log.h"
+#include "logger.h"
#include "gui/changeemaildialog.h"
#include "gui/changepassworddialog.h"
diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp
index c266374ef..8896ca028 100644
--- a/src/gui/chatwindow.cpp
+++ b/src/gui/chatwindow.cpp
@@ -211,10 +211,12 @@ ChatWindow::ChatWindow():
fillCommands();
initTradeFilter();
loadCustomList();
+ parseHighlights();
}
ChatWindow::~ChatWindow()
{
+ saveState();
config.setValue("ReturnToggles", mReturnToggles);
removeAllWhispers();
delete mItemLinkHandler;
@@ -935,7 +937,11 @@ void ChatWindow::whisper(const std::string &nick,
if (i != mWhispers.end())
tab = i->second;
else if (config.getBoolValue("whispertab"))
+ {
tab = addWhisperTab(nick);
+ if (tab)
+ saveState();
+ }
if (tab)
{
@@ -1414,15 +1420,6 @@ void ChatWindow::loadState()
tab->setRemoveNames((flags & 2) / 2);
tab->setNoAway((flags & 4) / 4);
}
- serverConfig.deleteKey("chatWhisper" + toString(num));
- serverConfig.deleteKey("chatWhisperFlags" + toString(num));
- num ++;
- }
-
- while (num < 50)
- {
- serverConfig.deleteKey("chatWhisper" + toString(num));
- serverConfig.deleteKey("chatWhisperFlags" + toString(num));
num ++;
}
}
@@ -1507,7 +1504,7 @@ void ChatWindow::addToAwayLog(std::string line)
if (mAwayLog.size() > 20)
mAwayLog.pop_front();
- if (line.find(player_node->getName()) != std::string::npos)
+ if (findI(line, mHighlights) != std::string::npos)
mAwayLog.push_back("##9away:" + line);
}
@@ -1524,3 +1521,20 @@ void ChatWindow::displayAwayLog()
++i;
}
}
+
+void ChatWindow::parseHighlights()
+{
+ mHighlights.clear();
+ if (!player_node)
+ return;
+
+ splitToStringVector(mHighlights, config.getStringValue(
+ "highlightWords"), ',');
+
+ mHighlights.push_back(player_node->getName());
+}
+
+bool ChatWindow::findHighlight(std::string &str)
+{
+ return findI(str, mHighlights) != std::string::npos;
+} \ No newline at end of file
diff --git a/src/gui/chatwindow.h b/src/gui/chatwindow.h
index b6a37ef79..6e1d548a3 100644
--- a/src/gui/chatwindow.h
+++ b/src/gui/chatwindow.h
@@ -260,6 +260,10 @@ class ChatWindow : public Window,
void clearAwayLog()
{ mAwayLog.clear(); }
+ void parseHighlights();
+
+ bool findHighlight(std::string &str);
+
protected:
friend class ChatTab;
friend class WhisperTab;
@@ -329,6 +333,7 @@ class ChatWindow : public Window,
int mChatColor;
unsigned int mChatHistoryIndex;
std::list<std::string> mAwayLog;
+ std::vector<std::string> mHighlights;
};
extern ChatWindow *chatWindow;
diff --git a/src/gui/connectiondialog.cpp b/src/gui/connectiondialog.cpp
index 157398297..da98ea5ac 100644
--- a/src/gui/connectiondialog.cpp
+++ b/src/gui/connectiondialog.cpp
@@ -22,7 +22,7 @@
#include "connectiondialog.h"
-#include "log.h"
+#include "logger.h"
#include "gui/widgets/button.h"
#include "gui/widgets/label.h"
diff --git a/src/gui/didyouknowwindow.cpp b/src/gui/didyouknowwindow.cpp
index 03188907f..4d89bd924 100644
--- a/src/gui/didyouknowwindow.cpp
+++ b/src/gui/didyouknowwindow.cpp
@@ -22,7 +22,7 @@
#include "gui/didyouknowwindow.h"
-#include "log.h"
+#include "logger.h"
#include "gui/gui.h"
#include "gui/setup.h"
diff --git a/src/gui/editdialog.cpp b/src/gui/editdialog.cpp
index bb80f07ed..da1d98e81 100644
--- a/src/gui/editdialog.cpp
+++ b/src/gui/editdialog.cpp
@@ -1,9 +1,10 @@
/*
- * The Mana World
+ * The ManaPlus Client
* Copyright (C) 2009 The Mana World Development Team
* Copyright (C) 2009-2010 Andrei Karas
+ * Copyright (C) 2011 ManaPlus developers
*
- * This file is part of The Mana World.
+ * This file is part of The ManaPlus Client.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/gui/editdialog.h b/src/gui/editdialog.h
index 55947b23d..dc0d1cc63 100644
--- a/src/gui/editdialog.h
+++ b/src/gui/editdialog.h
@@ -1,9 +1,10 @@
/*
- * The Mana World
+ * The ManaPlus Client
* Copyright (C) 2009 The Mana World Development Team
* Copyright (C) 2009-2010 Andrei Karas
+ * Copyright (C) 2011 ManaPlus developers
*
- * This file is part of The Mana World.
+ * This file is part of The ManaPlus Client.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/gui/emotepopup.cpp b/src/gui/emotepopup.cpp
index 3a754d0e3..348a97952 100644
--- a/src/gui/emotepopup.cpp
+++ b/src/gui/emotepopup.cpp
@@ -28,7 +28,7 @@
#include "emoteshortcut.h"
#include "graphics.h"
#include "localplayer.h"
-#include "log.h"
+#include "logger.h"
#include "gui/theme.h"
diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp
index 5a2820550..3abd97c73 100644
--- a/src/gui/equipmentwindow.cpp
+++ b/src/gui/equipmentwindow.cpp
@@ -45,6 +45,7 @@
#include "resources/iteminfo.h"
#include "resources/resourcemanager.h"
+#include "utils/dtor.h"
#include "utils/gettext.h"
#include "utils/stringutils.h"
@@ -55,24 +56,6 @@
static const int BOX_WIDTH = 36;
static const int BOX_HEIGHT = 36;
-// Positions of the boxes, 2nd dimension is X and Y respectively.
-static const int boxPosition[][2] =
-{
- { 90, 40 }, // EQUIP_TORSO_SLOT
- { 8, 78 }, // EQUIP_GLOVES_SLOT
- { 70, 0 }, // EQUIP_HEAD_SLOT
- { 50, 253 }, // EQUIP_LEGS_SLOT
- { 90, 253 }, // EQUIP_FEET_SLOT
- { 8, 213 }, // EQUIP_RING1_SLOT
- { 129, 213 }, // EQUIP_RING2_SLOT
- { 50, 40 }, // EQUIP_NECK_SLOT
- { 8, 168 }, // EQUIP_FIGHT1_SLOT
- { 129, 168 }, // EQUIP_FIGHT2_SLOT
- { 129, 78 }, // EQUIP_PROJECTILE_SLOT
- { 8, 123 }, // EQUIP_EVOL_RING1_SLOT
- { 129, 123 }, // EQUIP_EVOL_RING2_SLOT
-};
-
EquipmentWindow::EquipmentWindow(Equipment *equipment, Being *being,
bool foring):
Window(_("Equipment")),
@@ -98,6 +81,13 @@ EquipmentWindow::EquipmentWindow(Equipment *equipment, Being *being,
setCloseButton(true);
setSaveVisible(true);
setDefaultSize(180, 345, ImageRect::CENTER);
+
+ mBoxes.reserve(13);
+ for (int f = 0; f < 13; f ++)
+ mBoxes.push_back(0);
+
+ fillBoxes();
+
loadWindowState();
mUnequip = new Button(_("Unequip"), "unequip", this);
@@ -109,11 +99,9 @@ EquipmentWindow::EquipmentWindow(Equipment *equipment, Being *being,
add(mPlayerBox);
add(mUnequip);
- for (int i = 0; i < Equipment::EQUIP_VECTOREND; i++)
- {
- mEquipBox[i].posX = boxPosition[i][0] + getPadding();
- mEquipBox[i].posY = boxPosition[i][1] + getTitleBarHeight();
- }
+ mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT);
+ mBorderColor = Theme::getThemeColor(Theme::BORDER);
+ setForegroundColor(Theme::getThemeColor(Theme::TEXT));
}
EquipmentWindow::~EquipmentWindow()
@@ -127,6 +115,8 @@ EquipmentWindow::~EquipmentWindow()
delete mEquipment;
mEquipment = 0;
}
+ delete_all(mBoxes);
+ mBoxes.clear();
}
void EquipmentWindow::draw(gcn::Graphics *graphics)
@@ -138,23 +128,31 @@ void EquipmentWindow::draw(gcn::Graphics *graphics)
Window::drawChildren(graphics);
- for (int i = 0; i < Equipment::EQUIP_VECTOREND; i++)
+ int i = 0;
+ const int fontHeight = getFont()->getHeight();
+
+ std::vector<std::pair<int, int>*>::const_iterator it;
+ std::vector<std::pair<int, int>*>::const_iterator it_end = mBoxes.end();
+
+ for (it = mBoxes.begin(); it != it_end; ++ it, ++ i)
{
+ std::pair<int, int> *box = *it;
+ if (!box)
+ continue;
if (i == mSelected)
{
- const gcn::Color color = Theme::getThemeColor(Theme::HIGHLIGHT);
-
+ mHighlightColor.a = getGuiAlpha();
// Set color to the highlight color
- g->setColor(gcn::Color(color.r, color.g, color.b, getGuiAlpha()));
- g->fillRectangle(gcn::Rectangle(mEquipBox[i].posX,
- mEquipBox[i].posY, BOX_WIDTH, BOX_HEIGHT));
+ g->setColor(mHighlightColor);
+ g->fillRectangle(gcn::Rectangle(box->first,
+ box->second, BOX_WIDTH, BOX_HEIGHT));
}
// Set color black
- g->setColor(gcn::Color(0, 0, 0));
+ g->setColor(mBorderColor);
// Draw box border
- g->drawRectangle(gcn::Rectangle(mEquipBox[i].posX, mEquipBox[i].posY,
- BOX_WIDTH, BOX_HEIGHT));
+ g->drawRectangle(gcn::Rectangle(box->first, box->second,
+ BOX_WIDTH, BOX_HEIGHT));
if (!mEquipment)
continue;
@@ -168,15 +166,13 @@ void EquipmentWindow::draw(gcn::Graphics *graphics)
{
image->setAlpha(1.0f); // Ensure the image is drawn
// with maximum opacity
- g->drawImage(image,
- mEquipBox[i].posX + 2,
- mEquipBox[i].posY + 2);
+ g->drawImage(image, box->first + 2, box->second + 2);
if (i == EQUIP_PROJECTILE_SLOT)
{
- g->setColor(Theme::getThemeColor(Theme::TEXT));
+ g->setColor(getForegroundColor());
graphics->drawText(toString(item->getQuantity()),
- mEquipBox[i].posX + (BOX_WIDTH / 2),
- mEquipBox[i].posY - getFont()->getHeight(),
+ box->first + (BOX_WIDTH / 2),
+ box->second - fontHeight,
gcn::Graphics::CENTER);
}
}
@@ -202,10 +198,17 @@ Item *EquipmentWindow::getItem(int x, int y) const
if (!mEquipment)
return 0;
- for (int i = 0; i < Equipment::EQUIP_VECTOREND; i++)
+ std::vector<std::pair<int, int>*>::const_iterator it;
+ std::vector<std::pair<int, int>*>::const_iterator it_end = mBoxes.end();
+ int i = 0;
+
+ for (it = mBoxes.begin(); it != it_end; ++ it, ++ i)
{
- gcn::Rectangle tRect(mEquipBox[i].posX, mEquipBox[i].posY,
- BOX_WIDTH, BOX_HEIGHT);
+ std::pair<int, int> *box = *it;
+ if (!box)
+ continue;
+ const gcn::Rectangle tRect(box->first, box->second,
+ BOX_WIDTH, BOX_HEIGHT);
if (tRect.isPointInRect(x, y))
return mEquipment->getEquipment(i);
@@ -228,11 +231,19 @@ void EquipmentWindow::mousePressed(gcn::MouseEvent& mouseEvent)
if (mForing)
return;
// Checks if any of the presses were in the equip boxes.
- for (int i = 0; i < Equipment::EQUIP_VECTOREND; i++)
+ std::vector<std::pair<int, int>*>::const_iterator it;
+ std::vector<std::pair<int, int>*>::const_iterator
+ it_end = mBoxes.end();
+ int i = 0;
+
+ for (it = mBoxes.begin(); it != it_end; ++ it, ++ i)
{
+ std::pair<int, int> *box = *it;
+ if (!box)
+ continue;
Item *item = mEquipment->getEquipment(i);
- gcn::Rectangle tRect(mEquipBox[i].posX, mEquipBox[i].posY,
- BOX_WIDTH, BOX_HEIGHT);
+ const gcn::Rectangle tRect(box->first, box->second,
+ BOX_WIDTH, BOX_HEIGHT);
if (tRect.isPointInRect(x, y) && item)
setSelected(i);
@@ -326,3 +337,145 @@ void EquipmentWindow::resetBeing(Being *being)
if (being == mBeing)
setBeing(0);
}
+
+void EquipmentWindow::fillBoxes()
+{
+ XML::Document *doc = new XML::Document("equipmentwindow.xml");
+ xmlNodePtr root = doc->rootNode();
+ if (!root)
+ {
+ delete doc;
+ fillDefault();
+ return;
+ }
+
+ for_each_xml_child_node(node, root)
+ {
+ if (xmlStrEqual(node->name, BAD_CAST "window"))
+ loadWindow(node);
+ else if (xmlStrEqual(node->name, BAD_CAST "playerbox"))
+ loadPlayerBox(node);
+ else if (xmlStrEqual(node->name, BAD_CAST "slot"))
+ loadSlot(node);
+ }
+ delete doc;
+}
+
+void EquipmentWindow::loadWindow(xmlNodePtr windowNode)
+{
+ setDefaultSize(XML::getProperty(windowNode, "width", 180),
+ XML::getProperty(windowNode, "height", 345), ImageRect::CENTER);
+}
+
+void EquipmentWindow::loadPlayerBox(xmlNodePtr playerBoxNode)
+{
+ mPlayerBox->setDimension(gcn::Rectangle(
+ XML::getProperty(playerBoxNode, "x", 50),
+ XML::getProperty(playerBoxNode, "y", 80),
+ XML::getProperty(playerBoxNode, "width", 74),
+ XML::getProperty(playerBoxNode, "height", 168)));
+}
+
+void EquipmentWindow::loadSlot(xmlNodePtr slotNode)
+{
+ int slot = parseSlotName(XML::getProperty(slotNode, "name", ""));
+ if (slot < 0)
+ return;
+
+ const int x = XML::getProperty(slotNode, "x", 0) + getPadding();
+ const int y = XML::getProperty(slotNode, "y", 0) + getTitleBarHeight();
+
+ if (mBoxes[slot])
+ {
+ std::pair<int, int> *pair = mBoxes[slot];
+ pair->first = x;
+ pair->second = y;
+ }
+ else
+ {
+ mBoxes[slot] = new std::pair<int, int>(x, y);
+ }
+}
+
+int EquipmentWindow::parseSlotName(std::string name)
+{
+ int id = -1;
+ if (name == "shoes" || name == "boot" || name == "boots")
+ {
+ id = 4;
+ }
+ else if (name == "bottomclothes" || name == "bottom" || name == "pants")
+ {
+ id = 3;
+ }
+ else if (name == "topclothes" || name == "top"
+ || name == "torso" || name == "body")
+ {
+ id = 0;
+ }
+ else if (name == "free" || name == "misc1")
+ {
+ id = 5;
+ }
+ else if (name == "misc2" || name == "scarf" || name == "scarfs")
+ {
+ id = 7;
+ }
+ else if (name == "hat" || name == "hats")
+ {
+ id = 2;
+ }
+ else if (name == "wings")
+ {
+ id = 6;
+ }
+ else if (name == "glove" || name == "gloves")
+ {
+ id = 1;
+ }
+ else if (name == "weapon" || name == "weapons")
+ {
+ id = 8;
+ }
+ else if (name == "shield" || name == "shields")
+ {
+ id = 9;
+ }
+ else if (name == "amulet" || name == "amulets")
+ {
+ id = 11;
+ }
+ else if (name == "ring" || name == "rings")
+ {
+ id = 12;
+ }
+ else if (name == "arrow" || name == "arrows" || name == "ammo")
+ {
+ id = 10;
+ }
+
+ return id;
+}
+
+void EquipmentWindow::fillDefault()
+{
+ addBox(0, 90, 40); // torso
+ addBox(1, 8, 78); // gloves
+ addBox(2, 70, 0); // hat
+ addBox(3, 50, 253); // pants
+ addBox(4, 90, 253); // boots
+ addBox(5, 8, 213); // FREE
+ addBox(6, 129, 213); // wings
+ addBox(7, 50, 40); // scarf
+ addBox(8, 8, 168); // weapon
+ addBox(9, 129, 168); // shield
+ addBox(10, 129, 78); // ammo
+ addBox(11, 8, 123); // amulet
+ addBox(12, 129, 123); // ring
+}
+
+void EquipmentWindow::addBox(int idx, int x, int y)
+{
+ mBoxes[idx] = new std::pair<int, int>(
+ x + getPadding(), y + getTitleBarHeight());
+}
diff --git a/src/gui/equipmentwindow.h b/src/gui/equipmentwindow.h
index 84353dfd2..cadf27620 100644
--- a/src/gui/equipmentwindow.h
+++ b/src/gui/equipmentwindow.h
@@ -28,8 +28,12 @@
#include "gui/widgets/window.h"
+#include "utils/xml.h"
+
#include <guichan/actionlistener.hpp>
+#include <vector>
+
#ifdef __GNUC__
#define A_UNUSED __attribute__ ((unused))
#else
@@ -81,24 +85,28 @@ class EquipmentWindow : public Window, public gcn::ActionListener
private:
void mouseExited(gcn::MouseEvent &event);
+
void mouseMoved(gcn::MouseEvent &event);
Item *getItem(int x, int y) const;
void setSelected(int index);
- Equipment *mEquipment;
+ void fillBoxes();
- /**
- * Equipment box.
- */
- struct EquipBox
- {
- int posX;
- int posY;
- };
+ void fillDefault();
- EquipBox mEquipBox[Equipment::EQUIP_VECTOREND]; /**<Equipment Boxes. */
+ void addBox(int idx, int x, int y);
+
+ void loadWindow(xmlNodePtr windowNode);
+
+ void loadPlayerBox(xmlNodePtr playerBoxNode);
+
+ void loadSlot(xmlNodePtr slotNode);
+
+ int parseSlotName(std::string name);
+
+ Equipment *mEquipment;
ItemPopup *mItemPopup;
PlayerBox *mPlayerBox;
@@ -107,6 +115,9 @@ class EquipmentWindow : public Window, public gcn::ActionListener
int mSelected; /**< Index of selected item. */
bool mForing;
Being *mBeing;
+ std::vector<std::pair<int, int>*> mBoxes;
+ gcn::Color mHighlightColor;
+ gcn::Color mBorderColor;
};
extern EquipmentWindow *equipmentWindow;
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 0bea1d0d7..7d38b1025 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -35,7 +35,7 @@
#include "configlistener.h"
#include "configuration.h"
#include "graphics.h"
-#include "log.h"
+#include "logger.h"
#include "resources/image.h"
#include "resources/imageset.h"
@@ -107,9 +107,18 @@ Gui::Gui(Graphics *graphics):
// Set global font
const int fontSize = config.getIntValue("fontSize");
+
std::string fontFile = config.getValue("font", "");
-// may be here need get paths from paths.getValue?
-// std::string path = resman->getPath(fontFile);
+
+ std::vector<std::string> langs = getLang();
+ if (!langs.empty() && langs[0].size() > 3
+ && langs[0].substr(0, 3) == "ja_")
+ {
+ fontFile = config.getValue("japanFont", "");
+ if (fontFile.empty())
+ fontFile = branding.getStringValue("japanFont");
+ }
+
if (fontFile.empty())
fontFile = branding.getStringValue("font");
diff --git a/src/gui/helpwindow.cpp b/src/gui/helpwindow.cpp
index ae0a432ea..368049389 100644
--- a/src/gui/helpwindow.cpp
+++ b/src/gui/helpwindow.cpp
@@ -22,7 +22,7 @@
#include "gui/helpwindow.h"
-#include "log.h"
+#include "logger.h"
#include "gui/gui.h"
#include "gui/setup.h"
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index 27fbf7760..3b7b7b273 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -427,7 +427,7 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event)
else
{
if (tradeWindow)
- tradeWindow->tradeItem(item, item->getQuantity());
+ tradeWindow->tradeItem(item, item->getQuantity(), true);
}
}
}
diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp
index f5117ed5a..4d401a627 100644
--- a/src/gui/itempopup.cpp
+++ b/src/gui/itempopup.cpp
@@ -32,6 +32,7 @@
#include "gui/theme.h"
#include "gui/widgets/icon.h"
+#include "gui/widgets/label.h"
#include "gui/widgets/textbox.h"
#include "utils/gettext.h"
@@ -54,7 +55,7 @@ ItemPopup::ItemPopup():
mLastColor(1)
{
// Item Name
- mItemName = new gcn::Label;
+ mItemName = new Label;
mItemName->setFont(boldFont);
mItemName->setPosition(getPadding(), getPadding());
diff --git a/src/gui/killstats.cpp b/src/gui/killstats.cpp
index 95e16127a..05a265da7 100644
--- a/src/gui/killstats.cpp
+++ b/src/gui/killstats.cpp
@@ -1,9 +1,10 @@
/*
- * The Mana World
+ * The ManaPlus Client
* Copyright (C) 2009 The Mana World Development Team
* Copyright (C) 2009-2010 Andrei Karas
+ * Copyright (C) 2011 ManaPlus developers
*
- * This file is part of The Mana World.
+ * This file is part of The ManaPlus Client.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/gui/killstats.h b/src/gui/killstats.h
index 3c7679ca9..ff2a8f010 100644
--- a/src/gui/killstats.h
+++ b/src/gui/killstats.h
@@ -1,9 +1,10 @@
/*
- * The Mana World
+ * The ManaPlus Client
* Copyright (C) 2009 The Mana World Development Team
* Copyright (C) 2009-2010 Andrei Karas
+ * Copyright (C) 2011 ManaPlus developers
*
- * This file is part of The Mana World.
+ * This file is part of The ManaPlus Client.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp
index 5022f9210..c735eec82 100644
--- a/src/gui/minimap.cpp
+++ b/src/gui/minimap.cpp
@@ -27,7 +27,7 @@
#include "configuration.h"
#include "graphics.h"
#include "localplayer.h"
-#include "log.h"
+#include "logger.h"
#include "map.h"
#include "gui/userpalette.h"
diff --git a/src/gui/ministatus.cpp b/src/gui/ministatuswindow.cpp
index 817cd74a5..08e3d0053 100644
--- a/src/gui/ministatus.cpp
+++ b/src/gui/ministatuswindow.cpp
@@ -20,7 +20,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "gui/ministatus.h"
+#include "gui/ministatuswindow.h"
#include "animatedsprite.h"
#include "configuration.h"
diff --git a/src/gui/ministatus.h b/src/gui/ministatuswindow.h
index f19055305..19517326b 100644
--- a/src/gui/ministatus.h
+++ b/src/gui/ministatuswindow.h
@@ -20,8 +20,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef MINISTATUS_H
-#define MINISTATUS_H
+#ifndef MINISTATUSWINDOW_H
+#define MINISTATUSWINDOW_H
#include "inventory.h"
#include "listener.h"
diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp
index 9dd41a643..d3bc6a302 100644
--- a/src/gui/outfitwindow.cpp
+++ b/src/gui/outfitwindow.cpp
@@ -28,10 +28,11 @@
#include "inventory.h"
#include "item.h"
#include "localplayer.h"
-#include "log.h"
+#include "logger.h"
#include "playerinfo.h"
#include "gui/chatwindow.h"
+#include "gui/theme.h"
#include "gui/viewport.h"
#include "gui/widgets/button.h"
@@ -77,6 +78,9 @@ OutfitWindow::OutfitWindow():
addMouseListener(this);
+ mBorderColor = Theme::getThemeColor(Theme::BORDER, 64);
+ mBackgroundColor = Theme::getThemeColor(Theme::BACKGROUND, 32);
+
mPreviousButton = new Button(_("<"), "previous", this);
mNextButton = new Button(_(">"), "next", this);
mCurrentLabel = new Label(strprintf(_("Outfit: %d"), 1));
@@ -303,9 +307,9 @@ void OutfitWindow::draw(gcn::Graphics *graphics)
const int itemX = 10 + ((i % mGridWidth) * mBoxWidth);
const int itemY = 25 + ((i / mGridWidth) * mBoxHeight);
- graphics->setColor(gcn::Color(0, 0, 0, 64));
+ graphics->setColor(mBorderColor);
graphics->drawRectangle(gcn::Rectangle(itemX, itemY, 32, 32));
- graphics->setColor(gcn::Color(255, 255, 255, 32));
+ graphics->setColor(mBackgroundColor);
graphics->fillRectangle(gcn::Rectangle(itemX, itemY, 32, 32));
if (mItems[mCurrentOutfit][i] < 0)
diff --git a/src/gui/outfitwindow.h b/src/gui/outfitwindow.h
index 60634dbdd..8dd5fd6a3 100644
--- a/src/gui/outfitwindow.h
+++ b/src/gui/outfitwindow.h
@@ -137,6 +137,8 @@ class OutfitWindow : public Window, gcn::ActionListener
int mAwayOutfit;
Image *mBackgroundImg;
+ gcn::Color mBorderColor;
+ gcn::Color mBackgroundColor;
static float mAlpha;
};
diff --git a/src/gui/palette.h b/src/gui/palette.h
index 9409bfc06..1cebe236f 100644
--- a/src/gui/palette.h
+++ b/src/gui/palette.h
@@ -24,7 +24,7 @@
#ifndef PALETTE_H
#define PALETTE_H
-#include "log.h"
+#include "logger.h"
#include "utils/stringutils.h"
#include <guichan/color.hpp>
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index 79618ad04..61769bc7e 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -22,6 +22,7 @@
#include "gui/popupmenu.h"
+#include "actorsprite.h"
#include "actorspritemanager.h"
#include "being.h"
#include "dropshortcut.h"
@@ -31,7 +32,7 @@
#include "item.h"
#include "itemshortcut.h"
#include "localplayer.h"
-#include "log.h"
+#include "logger.h"
#include "map.h"
#include "party.h"
#include "playerinfo.h"
@@ -43,7 +44,7 @@
#include "gui/equipmentwindow.h"
#include "gui/inventorywindow.h"
#include "gui/itemamountwindow.h"
-#include "gui/ministatus.h"
+#include "gui/ministatuswindow.h"
#include "gui/outfitwindow.h"
#include "gui/selldialog.h"
#include "gui/socialwindow.h"
@@ -94,7 +95,8 @@ PopupMenu::PopupMenu():
mSpell(0),
mDialog(0),
mButton(0),
- mNick("")
+ mNick(""),
+ mType(Being::UNKNOWN)
{
mBrowserBox = new BrowserBox;
mBrowserBox->setPosition(4, 4);
@@ -105,6 +107,7 @@ PopupMenu::PopupMenu():
mRenameListener.setDialog(0);
mPlayerListener.setNick("");
mPlayerListener.setDialog(0);
+ mPlayerListener.setType(Being::UNKNOWN);
add(mBrowserBox);
}
@@ -116,6 +119,7 @@ void PopupMenu::showPopup(int x, int y, Being *being)
mBeingId = being->getId();
mNick = being->getName();
+ mType = being->getType();
mBrowserBox->clearRows();
const std::string &name = mNick;
@@ -278,6 +282,8 @@ void PopupMenu::showPopup(int x, int y, Being *being)
mBrowserBox->addRow(strprintf("@@sell|%s@@", _("Sell")));
mBrowserBox->addRow("##3---");
mBrowserBox->addRow(strprintf("@@move|%s@@", _("Move")));
+ mBrowserBox->addRow(strprintf("@@addcomment|%s@@",
+ _("Add comment")));
break;
case ActorSprite::MONSTER:
@@ -359,6 +365,7 @@ void PopupMenu::showPlayerPopup(int x, int y, std::string nick)
mNick = nick;
mBeingId = 0;
+ mType = Being::PLAYER;
mBrowserBox->clearRows();
const std::string &name = mNick;
@@ -495,6 +502,11 @@ void PopupMenu::showPopup(int x, int y, MapItem *mapItem)
mBrowserBox->addRow(strprintf("@@rename map|%s@@", _("Rename")));
mBrowserBox->addRow(strprintf("@@remove map|%s@@", _("Remove")));
+ if (player_node && player_node->isGM())
+ {
+ mBrowserBox->addRow("##3---");
+ mBrowserBox->addRow(strprintf("@@warp map|%s@@", _("Warp")));
+ }
mBrowserBox->addRow("##3---");
mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
@@ -562,7 +574,7 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab)
if (tab->getRemoveNames())
{
mBrowserBox->addRow(strprintf("@@dont remove name|%s@@",
- _("Dont remove name")));
+ _("Don't remove name")));
}
else
{
@@ -599,6 +611,7 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab)
{
mBeingId = being->getId();
mNick = being->getName();
+ mType = being->getType();
mBrowserBox->addRow(strprintf("@@trade|%s@@", _("Trade")));
mBrowserBox->addRow(strprintf("@@attack|%s@@", _("Attack")));
@@ -728,6 +741,7 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab)
else
{
mNick = name;
+ mType = Being::PLAYER;
mBrowserBox->addRow(strprintf(
"@@addcomment|%s@@", _("Add comment")));
mBrowserBox->addRow("##3---");
@@ -768,6 +782,7 @@ void PopupMenu::showChangePos(int x, int y)
mItem = 0;
mMapItem = 0;
mNick = "";
+ mType = Being::UNKNOWN;
setVisible(false);
}
}
@@ -1051,18 +1066,18 @@ void PopupMenu::handleLink(const std::string &link,
int cnt = 10;
if (cnt > mItem->getQuantity())
cnt = mItem->getQuantity();
- tradeWindow->tradeItem(mItem, cnt);
+ tradeWindow->tradeItem(mItem, cnt, true);
}
}
else if (link == "addtrade half" && mItem)
{
if (tradeWindow)
- tradeWindow->tradeItem(mItem, mItem->getQuantity() / 2);
+ tradeWindow->tradeItem(mItem, mItem->getQuantity() / 2, true);
}
else if (link == "addtrade all" && mItem)
{
if (tradeWindow)
- tradeWindow->tradeItem(mItem, mItem->getQuantity());
+ tradeWindow->tradeItem(mItem, mItem->getQuantity(), true);
}
else if (link == "retrieve" && mItem)
{
@@ -1134,6 +1149,14 @@ void PopupMenu::handleLink(const std::string &link,
if (chatWindow)
chatWindow->clearTab();
}
+ else if (link == "warp map" && mMapItem)
+ {
+ if (Game::instance())
+ {
+ Net::getAdminHandler()->warp(Game::instance()->getCurrentMapName(),
+ mMapItem->getX(), mMapItem->getY());
+ }
+ }
else if (link == "remove map" && mMapItem)
{
if (viewport)
@@ -1220,6 +1243,7 @@ void PopupMenu::handleLink(const std::string &link,
_("Comment: "));
mPlayerListener.setDialog(dialog);
mPlayerListener.setNick(mNick);
+ mPlayerListener.setType(mType);
if (being)
{
@@ -1228,7 +1252,7 @@ void PopupMenu::handleLink(const std::string &link,
}
else
{
- dialog->setText(Being::loadComment(mNick));
+ dialog->setText(Being::loadComment(mNick, mType));
}
dialog->setActionEventId("ok");
dialog->addActionListener(&mPlayerListener);
@@ -1245,26 +1269,38 @@ void PopupMenu::handleLink(const std::string &link,
else if (link == "enable highlight" && mTab)
{
mTab->setAllowHighlight(true);
+ if (chatWindow)
+ chatWindow->saveState();
}
else if (link == "disable highlight" && mTab)
{
mTab->setAllowHighlight(false);
+ if (chatWindow)
+ chatWindow->saveState();
}
else if (link == "dont remove name" && mTab)
{
mTab->setRemoveNames(false);
+ if (chatWindow)
+ chatWindow->saveState();
}
else if (link == "remove name" && mTab)
{
mTab->setRemoveNames(true);
+ if (chatWindow)
+ chatWindow->saveState();
}
else if (link == "disable away" && mTab)
{
mTab->setNoAway(true);
+ if (chatWindow)
+ chatWindow->saveState();
}
else if (link == "enable away" && mTab)
{
mTab->setNoAway(false);
+ if (chatWindow)
+ chatWindow->saveState();
}
else if (link == "remove attack" && being)
{
@@ -1548,6 +1584,7 @@ void PopupMenu::handleLink(const std::string &link,
mItemColor = 1;
mMapItem = 0;
mNick = "";
+ mType = Being::UNKNOWN;
}
void PopupMenu::showPopup(Window *parent, int x, int y, Item *item,
@@ -1858,6 +1895,7 @@ void PopupMenu::showAttackMonsterPopup(int x, int y, std::string name,
return;
mNick = name;
+ mType = Being::MONSTER;
mBrowserBox->clearRows();
@@ -1989,7 +2027,8 @@ void RenameListener::action(const gcn::ActionEvent &event)
PlayerListener::PlayerListener() :
mNick(""),
- mDialog(0)
+ mDialog(0),
+ mType(Being::UNKNOWN)
{
}
@@ -1999,10 +2038,10 @@ void PlayerListener::action(const gcn::ActionEvent &event)
{
std::string comment = mDialog->getText();
Being* being = actorSpriteManager->findBeingByName(
- mNick, Being::PLAYER);
+ mNick, (ActorSprite::Type)mType);
if (being)
being->setComment(comment);
- Being::saveComment(mNick, comment);
+ Being::saveComment(mNick, comment, mType);
}
mDialog = 0;
}
diff --git a/src/gui/popupmenu.h b/src/gui/popupmenu.h
index afa4bdfa2..3a7f27d4b 100644
--- a/src/gui/popupmenu.h
+++ b/src/gui/popupmenu.h
@@ -78,9 +78,13 @@ class PlayerListener : public gcn::ActionListener
void setDialog(TextDialog *dialog)
{ mDialog = dialog; }
+ void setType(int type)
+ { mType = type; }
+
private:
std::string mNick;
TextDialog *mDialog;
+ int mType;
};
/**
@@ -171,6 +175,7 @@ class PopupMenu : public Popup, public LinkHandler
TextDialog *mDialog;
Button *mButton;
std::string mNick;
+ int mType;
/**
* Shared code for the various showPopup functions.
diff --git a/src/gui/quitdialog.cpp b/src/gui/quitdialog.cpp
index 28a3332bf..f66872b5d 100644
--- a/src/gui/quitdialog.cpp
+++ b/src/gui/quitdialog.cpp
@@ -53,7 +53,6 @@ QuitDialog::QuitDialog(QuitDialog** pointerToMe):
mForceQuit = new RadioButton(_("Quit"), "quitdialog");
mLogoutQuit = new RadioButton(_("Quit"), "quitdialog");
- mSaveState = new CheckBox(_("Save state"), true);
mSwitchAccountServer = new RadioButton(_("Switch server"), "quitdialog");
mSwitchCharacter = new RadioButton(_("Switch character"), "quitdialog");
mOkButton = new Button(_("OK"), "ok", this);
@@ -91,9 +90,8 @@ QuitDialog::QuitDialog(QuitDialog** pointerToMe):
place = getPlacer(0, 1);
- place(0, 0, mSaveState, 3);
- place(1, 1, mOkButton, 1);
- place(2, 1, mCancelButton, 1);
+ place(1, 0, mOkButton, 1);
+ place(2, 0, mCancelButton, 1);
reflowLayout(200, 0);
setLocationRelativeTo(getParent());
@@ -133,8 +131,6 @@ void QuitDialog::action(const gcn::ActionEvent &event)
if (map)
map->saveExtraLayer();
}
- if (chatWindow && mSaveState->isSelected())
- chatWindow->saveState();
if (mForceQuit->isSelected())
{
diff --git a/src/gui/quitdialog.h b/src/gui/quitdialog.h
index d68910596..380a85528 100644
--- a/src/gui/quitdialog.h
+++ b/src/gui/quitdialog.h
@@ -65,7 +65,6 @@ class QuitDialog : public Window, public gcn::ActionListener,
std::vector<gcn::RadioButton*> mOptions;
gcn::RadioButton *mLogoutQuit;
- gcn::CheckBox *mSaveState;
gcn::RadioButton *mForceQuit;
gcn::RadioButton *mSwitchAccountServer;
gcn::RadioButton *mSwitchCharacter;
diff --git a/src/gui/register.cpp b/src/gui/register.cpp
index 80ddb7469..913c958f2 100644
--- a/src/gui/register.cpp
+++ b/src/gui/register.cpp
@@ -24,7 +24,7 @@
#include "client.h"
#include "configuration.h"
-#include "log.h"
+#include "logger.h"
#include "gui/logindialog.h"
#include "gui/okdialog.h"
diff --git a/src/gui/sdlfont.cpp b/src/gui/sdlfont.cpp
index a0f8699f8..8dd7f929d 100644
--- a/src/gui/sdlfont.cpp
+++ b/src/gui/sdlfont.cpp
@@ -25,7 +25,7 @@
#include "client.h"
#include "graphics.h"
-#include "log.h"
+#include "logger.h"
#include "main.h"
#include "resources/image.h"
diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp
index 140e4b629..763c190d6 100644
--- a/src/gui/serverdialog.cpp
+++ b/src/gui/serverdialog.cpp
@@ -22,10 +22,10 @@
#include "gui/serverdialog.h"
-#include "chatlog.h"
+#include "chatlogger.h"
#include "client.h"
#include "configuration.h"
-#include "log.h"
+#include "logger.h"
#include "main.h"
#include "gui/gui.h"
@@ -124,6 +124,9 @@ std::string ServersListModel::getElementAt(int elementIndex)
void ServersListModel::setVersionString(int index, const std::string &version)
{
+ if (index >= (int)mVersionStrings.size())
+ return;
+
if (version.empty())
{
mVersionStrings[index] = VersionString(0, "");
@@ -155,6 +158,10 @@ public:
ServersListBox(ServersListModel *model):
ListBox(model)
{
+ mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT);
+ mTextColor = Theme::getThemeColor(Theme::TEXT);
+ mNotSupportedColor = Theme::getThemeColor(
+ Theme::SERVER_VERSION_NOT_SUPPORTED);
}
void draw(gcn::Graphics *graphics)
@@ -166,20 +173,18 @@ public:
updateAlpha();
- graphics->setColor(Theme::getThemeColor(Theme::HIGHLIGHT,
- static_cast<int>(mAlpha * 255.0f)));
+ mHighlightColor.a = static_cast<int>(mAlpha * 255.0f);
+ graphics->setColor(mHighlightColor);
graphics->setFont(getFont());
const int height = getRowHeight();
- const gcn::Color unsupported =
- Theme::getThemeColor(Theme::SERVER_VERSION_NOT_SUPPORTED,
- static_cast<int>(mAlpha * 255.0f));
+ mNotSupportedColor.a = static_cast<int>(mAlpha * 255.0f);
// Draw filled rectangle around the selected list element
if (mSelected >= 0)
{
- graphics->fillRectangle(gcn::Rectangle(0, height * mSelected,
- getWidth(), height));
+ graphics->fillRectangle(gcn::Rectangle(0,
+ height * mSelected, getWidth(), height));
}
// Draw the list elements
@@ -188,7 +193,7 @@ public:
{
ServerInfo info = model->getServer(i);
- graphics->setColor(Theme::getThemeColor(Theme::TEXT));
+ graphics->setColor(mTextColor);
int top;
@@ -209,7 +214,7 @@ public:
if (info.version.first > 0)
{
- graphics->setColor(unsupported);
+ graphics->setColor(mNotSupportedColor);
graphics->drawText(info.version.second,
getWidth() - info.version.first - 2, top);
@@ -221,6 +226,10 @@ public:
{
return 2 * getFont()->getHeight();
}
+private:
+ gcn::Color mHighlightColor;
+ gcn::Color mTextColor;
+ gcn::Color mNotSupportedColor;
};
@@ -604,6 +613,13 @@ void ServerDialog::downloadServerList()
if (listFile.empty())
listFile = "http://manasource.org/serverlist.xml";
+ if (mDownload)
+ {
+ mDownload->cancel();
+ delete mDownload;
+ mDownload = 0;
+ }
+
mDownload = new Net::Download(this, listFile, &downloadUpdate);
mDownload->setFile(mDir + "/serverlist.xml");
mDownload->start();
@@ -702,7 +718,6 @@ void ServerDialog::loadServers(bool addNew)
break;
}
}
-
if (!found && addNew)
mServers.push_back(server);
}
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp
index 33ff6ddb7..690871189 100644
--- a/src/gui/setup.cpp
+++ b/src/gui/setup.cpp
@@ -22,19 +22,22 @@
#include "gui/setup.h"
+#include "chatwindow.h"
#include "configuration.h"
#include "game.h"
#include "main.h"
#include "gui/setup_audio.h"
+#include "gui/setup_chat.h"
#include "gui/setup_colors.h"
#include "gui/setup_joystick.h"
#include "gui/setup_other.h"
#include "gui/setup_theme.h"
#include "gui/setup_keyboard.h"
+#include "gui/setup_perfomance.h"
#include "gui/setup_players.h"
+#include "gui/setup_relations.h"
#include "gui/setup_video.h"
-#include "gui/setup_chat.h"
#include "gui/widgets/button.h"
#include "gui/widgets/label.h"
@@ -85,14 +88,17 @@ Setup::Setup():
mPanel = new TabbedArea;
mPanel->setDimension(gcn::Rectangle(5, 5, width - 10, height - 40));
+ mPanel->enableScrollButtons(true);
mTabs.push_back(new Setup_Video);
mTabs.push_back(new Setup_Audio);
+ mTabs.push_back(new Setup_Perfomance);
mTabs.push_back(new Setup_Joystick);
mTabs.push_back(new Setup_Keyboard);
mTabs.push_back(new Setup_Colors);
mTabs.push_back(new Setup_Chat);
mTabs.push_back(new Setup_Players);
+ mTabs.push_back(new Setup_Relations);
mTabs.push_back(new Setup_Theme);
mTabs.push_back(new Setup_Other);
@@ -139,11 +145,12 @@ void Setup::action(const gcn::ActionEvent &event)
}
else if (event.getId() == "Cancel")
{
- setVisible(false);
- for_each(mTabs.begin(), mTabs.end(), std::mem_fun(&SetupTab::cancel));
+ doCancel();
}
else if (event.getId() == "Store")
{
+ if (chatWindow)
+ chatWindow->saveState();
config.write();
serverConfig.write();
}
@@ -181,4 +188,10 @@ void Setup::registerWindowForReset(Window *window)
mWindowsToReset.push_back(window);
}
+void Setup::doCancel()
+{
+ setVisible(false);
+ for_each(mTabs.begin(), mTabs.end(), std::mem_fun(&SetupTab::cancel));
+}
+
Setup *setupWindow;
diff --git a/src/gui/setup.h b/src/gui/setup.h
index ad5ba53d9..cdaf7db99 100644
--- a/src/gui/setup.h
+++ b/src/gui/setup.h
@@ -71,6 +71,8 @@ class Setup : public Window, public gcn::ActionListener
void clearWindowsForReset()
{ mWindowsToReset.clear(); }
+ void doCancel();
+
private:
std::list<SetupTab*> mTabs;
std::list<Window*> mWindowsToReset;
diff --git a/src/gui/setup_audio.cpp b/src/gui/setup_audio.cpp
index 28e6d8cfa..1737e9004 100644
--- a/src/gui/setup_audio.cpp
+++ b/src/gui/setup_audio.cpp
@@ -23,7 +23,7 @@
#include "gui/setup_audio.h"
#include "configuration.h"
-#include "log.h"
+#include "logger.h"
#include "sound.h"
#include "gui/okdialog.h"
diff --git a/src/gui/setup_chat.cpp b/src/gui/setup_chat.cpp
index 7db61542a..9e75b9c0a 100644
--- a/src/gui/setup_chat.cpp
+++ b/src/gui/setup_chat.cpp
@@ -1,10 +1,10 @@
/*
- * The Mana World
+ * The ManaPlus Client
* Copyright (C) 2009 The Mana World Development Team
* Copyright (C) 2009-2010 Andrei Karas
* Copyright (C) 2011 The ManaPlus Developers
*
- * This file is part of The Mana World.
+ * This file is part of The ManaPlus Client.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -25,7 +25,6 @@
#include "gui/chatwindow.h"
#include "gui/editdialog.h"
-#include "gui/setupitem.h"
#include "gui/widgets/button.h"
#include "gui/widgets/chattab.h"
@@ -34,10 +33,11 @@
#include "gui/widgets/label.h"
#include "gui/widgets/layouthelper.h"
#include "gui/widgets/scrollarea.h"
+#include "gui/widgets/setupitem.h"
#include "configuration.h"
#include "localplayer.h"
-#include "log.h"
+#include "logger.h"
#include "utils/gettext.h"
@@ -93,6 +93,9 @@ Setup_Chat::Setup_Chat()
new SetupItemLabel(_("Tabs"), "", this);
+ new SetupItemCheckBox(_("Put all whispers in tabs"), "",
+ "whispertab", this, "whispertabEvent");
+
new SetupItemCheckBox(_("Log magic messages in debug tab"), "",
"showMagicInDebug", this, "showMagicInDebugEvent");
@@ -117,6 +120,11 @@ Setup_Chat::Setup_Chat()
new SetupItemCheckBox(_("Use local time"), "",
"useLocalTime", this, "useLocalTimeEvent");
+ new SetupItemLabel(_("Other"), "", this);
+
+ new SetupItemTextField(_("Highlight words (separated by comma)"), "",
+ "highlightWords", this, "highlightWordsEvent");
+
setDimension(gcn::Rectangle(0, 0, 550, 350));
}
@@ -125,5 +133,8 @@ void Setup_Chat::apply()
SetupTabScroll::apply();
if (chatWindow)
+ {
chatWindow->adjustTabSize();
+ chatWindow->parseHighlights();
+ }
}
diff --git a/src/gui/setup_chat.h b/src/gui/setup_chat.h
index 0b69984c8..402235d99 100644
--- a/src/gui/setup_chat.h
+++ b/src/gui/setup_chat.h
@@ -1,10 +1,10 @@
/*
- * The Mana World
+ * The ManaPlus Client
* Copyright (C) 2009 The Mana World Development Team
* Copyright (C) 2009-2010 Andrei Karas
* Copyright (C) 2011 The ManaPlus Developers
*
- * This file is part of The Mana World.
+ * This file is part of The ManaPlus Client.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/gui/setup_other.cpp b/src/gui/setup_other.cpp
index ac047e34b..b405f5045 100644
--- a/src/gui/setup_other.cpp
+++ b/src/gui/setup_other.cpp
@@ -1,10 +1,10 @@
/*
- * The Mana World
+ * The ManaPlus Client
* Copyright (C) 2009 The Mana World Development Team
* Copyright (C) 2009-2010 Andrei Karas
* Copyright (C) 2011 The ManaPlus Developers
*
- * This file is part of The Mana World.
+ * This file is part of The ManaPlus Client.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -23,13 +23,12 @@
#include "gui/setup_other.h"
-#include "gui/setupitem.h"
-
#include "gui/widgets/layouthelper.h"
#include "gui/widgets/scrollarea.h"
+#include "gui/widgets/setupitem.h"
#include "configuration.h"
-#include "log.h"
+#include "logger.h"
#include "utils/gettext.h"
diff --git a/src/gui/setup_other.h b/src/gui/setup_other.h
index 945a2de46..a13bf4ba3 100644
--- a/src/gui/setup_other.h
+++ b/src/gui/setup_other.h
@@ -1,10 +1,10 @@
/*
- * The Mana World
+ * The ManaPlus Client
* Copyright (C) 2009 The Mana World Development Team
* Copyright (C) 2009-2010 Andrei Karas
* Copyright (C) 2011 The ManaPlus Developers
*
- * This file is part of The Mana World.
+ * This file is part of The ManaPlus Client.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/gui/setup_perfomance.cpp b/src/gui/setup_perfomance.cpp
new file mode 100644
index 000000000..dfb119b91
--- /dev/null
+++ b/src/gui/setup_perfomance.cpp
@@ -0,0 +1,98 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 Andrei Karas
+ * Copyright (C) 2011 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "gui/setup_perfomance.h"
+
+#include "gui/chatwindow.h"
+#include "gui/editdialog.h"
+
+#include "gui/widgets/button.h"
+#include "gui/widgets/chattab.h"
+#include "gui/widgets/checkbox.h"
+#include "gui/widgets/inttextfield.h"
+#include "gui/widgets/label.h"
+#include "gui/widgets/layouthelper.h"
+#include "gui/widgets/scrollarea.h"
+#include "gui/widgets/setupitem.h"
+
+#include "configuration.h"
+#include "localplayer.h"
+#include "logger.h"
+
+#include "utils/gettext.h"
+
+#include "debug.h"
+
+Setup_Perfomance::Setup_Perfomance()
+{
+ setName(_("Perfomance"));
+
+ // Do the layout
+ LayoutHelper h(this);
+ ContainerPlacer place = h.getPlacer(0, 0);
+ place(0, 0, mScroll, 10, 10);
+
+ new SetupItemLabel(_("Better perfomance (enable for better perfomance)"),
+ "", this);
+
+ new SetupItemCheckBox(_("Auto adjust perfomance"), "",
+ "adjustPerfomance", this, "adjustPerfomanceEvent");
+
+ new SetupItemCheckBox(_("Show beings transparency"), "",
+ "beingopacity", this, "beingopacityEvent");
+
+ new SetupItemCheckBox(_("Hw acceleration"), "",
+ "hwaccel", this, "hwaccelEvent");
+
+ new SetupItemCheckBox(_("Enable opacity cache (Software, can "
+ "use many memory)"), "", "alphaCache", this, "alphaCacheEvent");
+
+ new SetupItemCheckBox(_("Enable map reduce (Software)"), "",
+ "enableMapReduce", this, "enableMapReduceEvent");
+
+ new SetupItemLabel(_("Better quality (disable for better perfomance)"),
+ "", this);
+
+ new SetupItemCheckBox(_("Enable alpha channel fix (Software, can "
+ "be very slow)"), "Can slow down drawing", "enableAlphaFix",
+ this, "enableAlphaFixEvent");
+
+ new SetupItemCheckBox(_("Enable reorder sprites."), "",
+ "enableReorderSprites", this, "enableReorderSpritesEvent");
+
+ new SetupItemLabel(_("Small memory (enable for lower memory usage)"),
+ "", this);
+
+ new SetupItemCheckBox(_("Disable advanced beings caching (Software)"), "",
+ "disableAdvBeingCaching", this, "disableAdvBeingCachingEvent");
+
+ new SetupItemCheckBox(_("Disable beings caching (Software)"), "",
+ "disableBeingCaching", this, "disableBeingCachingEvent");
+
+ setDimension(gcn::Rectangle(0, 0, 550, 350));
+}
+
+void Setup_Perfomance::apply()
+{
+ SetupTabScroll::apply();
+}
diff --git a/src/gui/setup_perfomance.h b/src/gui/setup_perfomance.h
new file mode 100644
index 000000000..f355c9691
--- /dev/null
+++ b/src/gui/setup_perfomance.h
@@ -0,0 +1,44 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 Andrei Karas
+ * Copyright (C) 2011 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef GUI_SETUP_PERFOMANCE_H
+#define GUI_SETUP_PERFOMANCE_H
+
+#include "guichanfwd.h"
+
+#include "gui/widgets/setuptabscroll.h"
+
+#include <guichan/actionlistener.hpp>
+
+class IntTextField;
+class EditDialog;
+
+class Setup_Perfomance : public SetupTabScroll
+{
+ public:
+ Setup_Perfomance();
+
+ void apply();
+};
+
+#endif
diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp
index 67ec053ea..78c77f6f1 100644
--- a/src/gui/setup_players.cpp
+++ b/src/gui/setup_players.cpp
@@ -1,7 +1,7 @@
/*
* The ManaPlus Client
- * Copyright (C) 2008-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 Andrei Karas
* Copyright (C) 2011 The ManaPlus Developers
*
* This file is part of The ManaPlus Client.
@@ -17,565 +17,71 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "gui/setup_players.h"
-#include "actorspritemanager.h"
-#include "configuration.h"
-#include "localplayer.h"
-#include "log.h"
-
+#include "gui/chatwindow.h"
#include "gui/editdialog.h"
-#include "gui/okdialog.h"
#include "gui/widgets/button.h"
+#include "gui/widgets/chattab.h"
#include "gui/widgets/checkbox.h"
-#include "gui/widgets/dropdown.h"
+#include "gui/widgets/inttextfield.h"
#include "gui/widgets/label.h"
#include "gui/widgets/layouthelper.h"
#include "gui/widgets/scrollarea.h"
-#include "gui/widgets/table.h"
-#include "gui/widgets/textfield.h"
-
-#include "utils/dtor.h"
-#include "utils/gettext.h"
-
-#include <string>
-#include <vector>
+#include "gui/widgets/setupitem.h"
-#define COLUMNS_NR 2 // name plus listbox
-#define NAME_COLUMN 0
-#define RELATION_CHOICE_COLUMN 1
-
-#define ROW_HEIGHT 12
-// The following column widths really shouldn't be hardcoded but should scale with the size of the widget... except
-// that, right now, the widget doesn't exactly scale either.
-#define NAME_COLUMN_WIDTH 230
-#define RELATION_CHOICE_COLUMN_WIDTH 80
+#include "configuration.h"
+#include "localplayer.h"
+#include "logger.h"
-#define WIDGET_AT(row, column) (((row) * COLUMNS_NR) + column)
+#include "utils/gettext.h"
#include "debug.h"
-static const char *table_titles[COLUMNS_NR] =
-{
- N_("Name"),
- N_("Relation")
-};
-
-static const char *RELATION_NAMES[PlayerRelation::RELATIONS_NR] =
-{
- N_("Neutral"),
- N_("Friend"),
- N_("Disregarded"),
- N_("Ignored"),
- N_("Erased")
-};
-
-class PlayerRelationListModel : public gcn::ListModel
-{
-public:
- virtual ~PlayerRelationListModel() { }
-
- virtual int getNumberOfElements()
- {
- return PlayerRelation::RELATIONS_NR;
- }
-
- virtual std::string getElementAt(int i)
- {
- if (i >= getNumberOfElements() || i < 0)
- return "";
- return gettext(RELATION_NAMES[i]);
- }
-};
-
-class PlayerTableModel : public TableModel
-{
-public:
- PlayerTableModel() :
- mPlayers(NULL),
- mListModel(new PlayerRelationListModel)
- {
- playerRelationsUpdated();
- }
-
- virtual ~PlayerTableModel()
- {
- freeWidgets();
- delete mListModel;
- mListModel = 0;
- delete mPlayers;
- mPlayers = 0;
- }
-
- virtual int getRows() const
- {
- if (mPlayers)
- return static_cast<int>(mPlayers->size());
- else
- return 0;
- }
-
- virtual int getColumns() const
- {
- return COLUMNS_NR;
- }
-
- virtual int getRowHeight() const
- {
- return ROW_HEIGHT;
- }
-
- virtual int getColumnWidth(int index) const
- {
- if (index == NAME_COLUMN)
- return NAME_COLUMN_WIDTH;
- else
- return RELATION_CHOICE_COLUMN_WIDTH;
- }
-
- virtual void playerRelationsUpdated()
- {
- signalBeforeUpdate();
-
- freeWidgets();
- std::vector<std::string> *player_names = player_relations.getPlayers();
-
- if (!player_names)
- return;
-
- delete mPlayers;
- mPlayers = player_names;
-
- // set up widgets
- for (unsigned int r = 0; r < player_names->size(); ++r)
- {
- std::string name = (*player_names)[r];
- gcn::Widget *widget = new Label(name);
- mWidgets.push_back(widget);
-
- gcn::DropDown *choicebox = new DropDown(mListModel);
- choicebox->setSelected(player_relations.getRelation(name));
- mWidgets.push_back(choicebox);
- }
-
- signalAfterUpdate();
- }
-
- virtual void updateModelInRow(int row)
- {
- gcn::DropDown *choicebox = static_cast<gcn::DropDown *>(
- getElementAt(row, RELATION_CHOICE_COLUMN));
- player_relations.setRelation(getPlayerAt(row),
- static_cast<PlayerRelation::Relation>(
- choicebox->getSelected()));
- }
-
-
- virtual gcn::Widget *getElementAt(int row, int column) const
- {
- return mWidgets[WIDGET_AT(row, column)];
- }
-
- virtual void freeWidgets()
- {
- delete mPlayers;
- mPlayers = 0;
-
- delete_all(mWidgets);
- mWidgets.clear();
- }
-
- std::string getPlayerAt(int index) const
- {
- return (*mPlayers)[index];
- }
-
-protected:
- std::vector<std::string> *mPlayers;
- std::vector<gcn::Widget *> mWidgets;
- PlayerRelationListModel *mListModel;
-};
-
-/**
- * Class for choosing one of the various `what to do when ignoring a player' options
- */
-class IgnoreChoicesListModel : public gcn::ListModel
-{
-public:
- virtual ~IgnoreChoicesListModel() { }
-
- virtual int getNumberOfElements()
- {
- return static_cast<int>(player_relations.getPlayerIgnoreStrategies()
- ->size());
- }
-
- virtual std::string getElementAt(int i)
- {
- if (i >= getNumberOfElements() || i < 0)
- return _("???");
-
- return (*player_relations.getPlayerIgnoreStrategies())
- [i]->mDescription;
- }
-};
-
-#define ACTION_DELETE "delete"
-#define ACTION_OLD "old"
-#define ACTION_TABLE "table"
-#define ACTION_STRATEGY "strategy"
-#define ACTION_WHISPER_TAB "whisper tab"
-#define ACTION_SHOW_GENDER "show gender"
-#define ACTION_SHOW_LEVEL "show level"
-#define ACTION_TARGET_DEAD "target dead"
-#define ACTION_SHOW_OWN_NAME "show own name"
-#define ACTION_SECURE_TRADES "secure trades"
-#define ACTION_UNSECURE "unsecure"
-#define ACTION_EDIT_UNSECURE "edit unsecure"
-#define ACTION_EDIT_UNSECURE_OK "edit unsecure ok"
-
-Setup_Players::Setup_Players():
- mPlayerTableTitleModel(new StaticTableModel(1, COLUMNS_NR)),
- mPlayerTableModel(new PlayerTableModel),
- mPlayerTable(new GuiTable(mPlayerTableModel)),
- mPlayerTitleTable(new GuiTable(mPlayerTableTitleModel)),
- mPlayerScrollArea(new ScrollArea(mPlayerTable)),
- mDefaultTrading(new CheckBox(_("Allow trading"),
- player_relations.getDefault() & PlayerRelation::TRADE)),
- mDefaultWhisper(new CheckBox(_("Allow whispers"),
- player_relations.getDefault() & PlayerRelation::WHISPER)),
- mDeleteButton(new Button(_("Delete"), ACTION_DELETE, this)),
- mOldButton(new Button(_("Old"), ACTION_OLD, this)),
- mWhisperTab(config.getBoolValue("whispertab")),
- mWhisperTabCheckBox(new CheckBox(_("Put all whispers in tabs"),
- mWhisperTab)),
- mShowGender(config.getBoolValue("showgender")),
- mShowGenderCheckBox(new CheckBox(_("Show gender"), mShowGender)),
- mShowLevel(config.getBoolValue("showlevel")),
- mShowOwnName(config.getBoolValue("showownname")),
- mTargetDead(config.getBoolValue("targetDeadPlayers")),
- mSecureTrades(config.getBoolValue("securetrades")),
- mUnsecureChars(config.getStringValue("unsecureChars")),
- mVisibleNamesEnabled(config.getBoolValue("visiblenames")),
- mShowPlayersStatus(config.getBoolValue("showPlayersStatus")),
- mEditDialog(0)
+Setup_Players::Setup_Players()
{
setName(_("Players"));
- mPlayerTable->setOpaque(false);
-
- mPlayerTableTitleModel->fixColumnWidth(NAME_COLUMN, NAME_COLUMN_WIDTH);
- mPlayerTableTitleModel->fixColumnWidth(RELATION_CHOICE_COLUMN,
- RELATION_CHOICE_COLUMN_WIDTH);
- mPlayerTitleTable->setBackgroundColor(gcn::Color(0xbf, 0xbf, 0xbf));
-
- mIgnoreActionChoicesModel = new IgnoreChoicesListModel;
- mIgnoreActionChoicesBox = new DropDown(mIgnoreActionChoicesModel);
-
- for (int i = 0; i < COLUMNS_NR; i++)
- {
- mPlayerTableTitleModel->set(0, i,
- new Label(gettext(table_titles[i])));
- }
-
- mPlayerTitleTable->setLinewiseSelection(true);
-
- mPlayerScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
- mPlayerTable->setActionEventId(ACTION_TABLE);
- mPlayerTable->setLinewiseSelection(true);
- mPlayerTable->addActionListener(this);
-
- gcn::Label *ignore_action_label = new Label(_("When ignoring:"));
-
- mIgnoreActionChoicesBox->setActionEventId(ACTION_STRATEGY);
- mIgnoreActionChoicesBox->addActionListener(this);
-
- int ignore_strategy_index = 0; // safe default
-
- if (player_relations.getPlayerIgnoreStrategy())
- {
- ignore_strategy_index = player_relations.getPlayerIgnoreStrategyIndex(
- player_relations.getPlayerIgnoreStrategy()->mShortName);
- if (ignore_strategy_index < 0)
- ignore_strategy_index = 0;
- }
- mIgnoreActionChoicesBox->setSelected(ignore_strategy_index);
- mIgnoreActionChoicesBox->adjustHeight();
-
- mWhisperTabCheckBox->setActionEventId(ACTION_WHISPER_TAB);
- mWhisperTabCheckBox->addActionListener(this);
-
- mShowGenderCheckBox->setActionEventId(ACTION_SHOW_GENDER);
- mShowGenderCheckBox->addActionListener(this);
-
- mShowLevelCheckBox = new CheckBox(_("Show level"), mShowLevel);
- mShowLevelCheckBox->setActionEventId(ACTION_SHOW_LEVEL);
- mShowLevelCheckBox->addActionListener(this);
-
- mShowOwnNameCheckBox = new CheckBox(_("Show own name"), mShowOwnName);
- mShowOwnNameCheckBox->setActionEventId(ACTION_SHOW_OWN_NAME);
- mShowOwnNameCheckBox->addActionListener(this);
-
- mTargetDeadCheckBox = new CheckBox(_("Target dead players"), mTargetDead);
- mTargetDeadCheckBox->setActionEventId(ACTION_TARGET_DEAD);
- mTargetDeadCheckBox->addActionListener(this);
-
- mSecureTradesCheckBox = new CheckBox(_("Secure trades"), mSecureTrades);
- mSecureTradesCheckBox->setActionEventId(ACTION_SECURE_TRADES);
- mSecureTradesCheckBox->addActionListener(this);
-
- mUnsecureCharsLabel = new Label(_("Unsecure chars in names"));
- mUnsecureCharsField = new TextField(mUnsecureChars,
- true, this, ACTION_UNSECURE);
- mUnsecureCharsButton = new Button(_("Edit"), ACTION_EDIT_UNSECURE, this);
-
- mVisibleNamesCheckBox = new CheckBox(_("Visible names"),
- mVisibleNamesEnabled);
- mVisibleNamesCheckBox->setActionEventId("visiblenames");
- mVisibleNamesCheckBox->addActionListener(this);
-
- mShowPlayersStatusCheckBox = new CheckBox(_("Show statuses"),
- mShowPlayersStatus);
- mShowPlayersStatusCheckBox->setActionEventId("showPlayersStatus");
- mShowPlayersStatusCheckBox->addActionListener(this);
-
- reset();
-
- // Do the layout
LayoutHelper h(this);
ContainerPlacer place = h.getPlacer(0, 0);
+ place(0, 0, mScroll, 10, 10);
- place(0, 0, mPlayerTitleTable, 6);
- place(0, 1, mPlayerScrollArea, 6, 4).setPadding(2);
- place(0, 5, mDeleteButton);
- place(0, 6, mShowGenderCheckBox, 3).setPadding(2);
- place(0, 7, mShowLevelCheckBox, 3).setPadding(2);
- place(0, 8, mShowOwnNameCheckBox, 3).setPadding(2);
- place(1, 5, mOldButton, 1);
- place(3, 5, ignore_action_label, 1);
- place(4, 5, mIgnoreActionChoicesBox, 2).setPadding(2);
- place(3, 6, mDefaultTrading, 3);
- place(3, 7, mDefaultWhisper, 3);
- place(3, 8, mSecureTradesCheckBox, 3);
- place(3, 9, mUnsecureCharsLabel, 3);
- place(3, 10, mUnsecureCharsField, 2);
- place(3, 11, mShowPlayersStatusCheckBox, 2);
- place(5, 10, mUnsecureCharsButton, 1);
- place(0, 9, mWhisperTabCheckBox, 3).setPadding(4);
- place(0, 10, mTargetDeadCheckBox, 3).setPadding(4);
- place(0, 11, mVisibleNamesCheckBox, 3).setPadding(4);
+ new SetupItemCheckBox(_("Show gender"), "",
+ "showgender", this, "showgenderEvent");
- player_relations.addListener(this);
+ new SetupItemCheckBox(_("Show level"), "",
+ "showlevel", this, "showlevelEvent");
- setDimension(gcn::Rectangle(0, 0, 500, 350));
-}
+ new SetupItemCheckBox(_("Show own name"), "",
+ "showownname", this, "showownnameEvent");
-Setup_Players::~Setup_Players()
-{
- player_relations.removeListener(this);
- delete mIgnoreActionChoicesModel;
- mIgnoreActionChoicesModel = 0;
-}
+ new SetupItemCheckBox(_("Target dead players"), "",
+ "targetDeadPlayers", this, "targetDeadPlayersEvent");
+ new SetupItemCheckBox(_("Visible names"), "",
+ "visiblenames", this, "visiblenamesEvent");
-void Setup_Players::reset()
-{
- // We now have to search through the list of ignore choices to find the
- // current selection. We could use an index into the table of config
- // options in player_relations instead of strategies to sidestep this.
- int selection = 0;
- for (unsigned int i = 0;
- i < player_relations.getPlayerIgnoreStrategies()->size();
- ++i)
- if ((*player_relations.getPlayerIgnoreStrategies())[i] ==
- player_relations.getPlayerIgnoreStrategy())
- {
+ new SetupItemCheckBox(_("Secure trades"), "",
+ "securetrades", this, "securetradesEvent");
- selection = i;
- break;
- }
+ new SetupItemTextField(_("Unsecure chars in names"), "",
+ "unsecureChars", this, "unsecureCharsEvent");
- mIgnoreActionChoicesBox->setSelected(selection);
-}
+ new SetupItemCheckBox(_("Show statuses"), "",
+ "showPlayersStatus", this, "showPlayersStatusEvent");
-void Setup_Players::apply()
-{
- player_relations.store();
-
- unsigned int old_default_relations = player_relations.getDefault() &
- ~(PlayerRelation::TRADE |
- PlayerRelation::WHISPER);
- player_relations.setDefault(old_default_relations
- | (mDefaultTrading->isSelected() ?
- PlayerRelation::TRADE : 0)
- | (mDefaultWhisper->isSelected() ?
- PlayerRelation::WHISPER : 0));
- config.setValue("whispertab", mWhisperTab);
- config.setValue("showlevel", mShowLevel);
- config.setValue("showownname", mShowOwnName);
- config.setValue("targetDeadPlayers", mTargetDead);
- config.setValue("showgender", mShowGender);
- config.setValue("securetrades", mSecureTrades);
- config.setValue("unsecureChars", mUnsecureCharsField->getText());
- config.setValue("visiblenames", mVisibleNamesEnabled);
- config.setValue("showPlayersStatus", mShowPlayersStatus);
-
- if (actorSpriteManager)
- actorSpriteManager->updatePlayerNames();
-
- if (player_node)
- player_node->setCheckNameSetting(true);
-}
+ new SetupItemCheckBox(_("Show ip addresses on screenshots"), "",
+ "showip", this, "showipEvent");
-void Setup_Players::cancel()
-{
- mWhisperTab = config.getBoolValue("whispertab");
- mWhisperTabCheckBox->setSelected(mWhisperTab);
- mShowGender = config.getBoolValue("showgender");
- mShowGenderCheckBox->setSelected(mShowGender);
- mShowLevel = config.getBoolValue("showlevel");
- mShowLevelCheckBox->setSelected(mShowLevel);
- mShowOwnName = config.getBoolValue("showownname");
- mShowOwnNameCheckBox->setSelected(mShowOwnName);
- mTargetDead = config.getBoolValue("targetDeadPlayers");
- mTargetDeadCheckBox->setSelected(mTargetDead);
- mSecureTrades = config.getBoolValue("securetrades");
- mSecureTradesCheckBox->setSelected(mSecureTrades);
- mUnsecureChars = config.getStringValue("unsecureChars");
- mUnsecureCharsField->setText(mUnsecureChars);
- mVisibleNamesEnabled = config.getBoolValue("visiblenames");
- mVisibleNamesCheckBox->setSelected(mVisibleNamesEnabled);
- mShowPlayersStatus = config.getBoolValue("showPlayersStatus");
- mShowPlayersStatusCheckBox->setSelected(mShowPlayersStatus);
+ setDimension(gcn::Rectangle(0, 0, 550, 350));
}
-void Setup_Players::action(const gcn::ActionEvent &event)
-{
- if (event.getId() == ACTION_TABLE)
- {
- // temporarily eliminate ourselves: we are fully aware of this change,
- // so there is no need for asynchronous updates. (In fact, thouse
- // might destroy the widet that triggered them, which would be rather
- // embarrassing.)
- player_relations.removeListener(this);
-
- int row = mPlayerTable->getSelectedRow();
- if (row >= 0)
- mPlayerTableModel->updateModelInRow(row);
-
- player_relations.addListener(this);
-
- }
- else if (event.getId() == ACTION_DELETE)
- {
- int player_index = mPlayerTable->getSelectedRow();
-
- if (player_index < 0)
- return;
-
- std::string name = mPlayerTableModel->getPlayerAt(player_index);
-
- player_relations.removePlayer(name);
- }
- else if (event.getId() == ACTION_OLD)
- {
- player_relations.load(true);
- updateAll();
- }
- else if (event.getId() == ACTION_STRATEGY)
- {
- PlayerIgnoreStrategy *s =
- (*player_relations.getPlayerIgnoreStrategies())[
- mIgnoreActionChoicesBox->getSelected()];
-
- player_relations.setPlayerIgnoreStrategy(s);
- }
- else if (event.getId() == ACTION_WHISPER_TAB)
- {
- mWhisperTab = mWhisperTabCheckBox->isSelected();
- }
- else if (event.getId() == ACTION_SHOW_GENDER)
- {
- mShowGender = mShowGenderCheckBox->isSelected();
- }
- else if (event.getId() == ACTION_SHOW_LEVEL)
- {
- mShowLevel = mShowLevelCheckBox->isSelected();
- }
- else if (event.getId() == ACTION_SHOW_OWN_NAME)
- {
- mShowOwnName = mShowOwnNameCheckBox->isSelected();
- }
- else if (event.getId() == ACTION_TARGET_DEAD)
- {
- mTargetDead = mTargetDeadCheckBox->isSelected();
- }
- else if (event.getId() == ACTION_SECURE_TRADES)
- {
- mSecureTrades = mSecureTradesCheckBox->isSelected();
- }
- else if (event.getId() == ACTION_EDIT_UNSECURE)
- {
- mEditDialog = new EditDialog(_("Unsecure chars in names"),
- mUnsecureCharsField->getText(), ACTION_EDIT_UNSECURE_OK);
- mEditDialog->addActionListener(this);
- }
- else if (event.getId() == ACTION_EDIT_UNSECURE_OK)
- {
- mUnsecureCharsField->setText(mEditDialog->getMsg());
- }
- else if (event.getId() == ACTION_UNSECURE)
- {
- mUnsecureChars = mUnsecureCharsField->getText();
- }
- else if (event.getId() == "visiblenames")
- {
- mVisibleNamesEnabled = mVisibleNamesCheckBox->isSelected();
- }
- else if (event.getId() == "showPlayersStatus")
- {
- mShowPlayersStatus = mShowPlayersStatusCheckBox->isSelected();
- }
-}
-
-void Setup_Players::updatedPlayer(const std::string &name A_UNUSED)
-{
- mPlayerTableModel->playerRelationsUpdated();
- mDefaultTrading->setSelected(
- player_relations.getDefault() & PlayerRelation::TRADE);
- mDefaultWhisper->setSelected(
- player_relations.getDefault() & PlayerRelation::WHISPER);
- if (player_node)
- player_node->updateName();
-}
-
-void Setup_Players::updateAll()
+void Setup_Players::apply()
{
- PlayerTableModel *model = new PlayerTableModel();
- mPlayerTable->setModel(model);
- delete mPlayerTableModel;
- mPlayerTableModel = model;
- int ignore_strategy_index = 0; // safe default
-
- if (player_relations.getPlayerIgnoreStrategy())
- {
- ignore_strategy_index = player_relations.getPlayerIgnoreStrategyIndex(
- player_relations.getPlayerIgnoreStrategy()->mShortName);
- if (ignore_strategy_index < 0)
- ignore_strategy_index = 0;
- }
- mIgnoreActionChoicesBox->setSelected(ignore_strategy_index);
- mIgnoreActionChoicesBox->adjustHeight();
- reset();
+ SetupTabScroll::apply();
}
-void Setup_Players::externalUpdated()
-{
- mDefaultTrading->setSelected(
- player_relations.getDefault() & PlayerRelation::TRADE);
- mDefaultWhisper->setSelected(
- player_relations.getDefault() & PlayerRelation::WHISPER);
-} \ No newline at end of file
diff --git a/src/gui/setup_players.h b/src/gui/setup_players.h
index 9f35d1600..c9ce7b3b3 100644
--- a/src/gui/setup_players.h
+++ b/src/gui/setup_players.h
@@ -1,7 +1,7 @@
/*
* The ManaPlus Client
- * Copyright (C) 2008-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 Andrei Karas
* Copyright (C) 2011 The ManaPlus Developers
*
* This file is part of The ManaPlus Client.
@@ -17,96 +17,28 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef GUI_SETUP_PLAYERS_H
#define GUI_SETUP_PLAYERS_H
#include "guichanfwd.h"
-#include "playerrelations.h"
-#include "gui/widgets/setuptab.h"
+#include "gui/widgets/setuptabscroll.h"
#include <guichan/actionlistener.hpp>
-#ifdef __GNUC__
-#define A_UNUSED __attribute__ ((unused))
-#else
-#define A_UNUSED
-#endif
-
+class IntTextField;
class EditDialog;
-class GuiTable;
-class PlayerTableModel;
-class StaticTableModel;
-class Setup_Players : public SetupTab,
- public PlayerRelationsListener
+class Setup_Players : public SetupTabScroll
{
-public:
- Setup_Players();
- virtual ~Setup_Players();
-
- void apply();
- void cancel();
-
- void reset();
-
- void action(const gcn::ActionEvent &event);
-
- virtual void updatedPlayer(const std::string &name);
-
- virtual void updateAll();
-
- virtual void externalUpdated();
-
-private:
- StaticTableModel *mPlayerTableTitleModel;
- PlayerTableModel *mPlayerTableModel;
- GuiTable *mPlayerTable;
- GuiTable *mPlayerTitleTable;
- gcn::ScrollArea *mPlayerScrollArea;
-
- gcn::CheckBox *mDefaultTrading;
- gcn::CheckBox *mDefaultWhisper;
-
- gcn::Button *mDeleteButton;
- gcn::Button *mOldButton;
-
- gcn::ListModel *mIgnoreActionChoicesModel;
- gcn::DropDown *mIgnoreActionChoicesBox;
-
- bool mWhisperTab;
- gcn::CheckBox *mWhisperTabCheckBox;
-
- bool mShowGender;
- gcn::CheckBox *mShowGenderCheckBox;
-
- bool mShowLevel;
- gcn::CheckBox *mShowLevelCheckBox;
-
- bool mShowOwnName;
- gcn::CheckBox *mShowOwnNameCheckBox;
-
- bool mTargetDead;
- gcn::CheckBox *mTargetDeadCheckBox;
-
- bool mSecureTrades;
- gcn::CheckBox *mSecureTradesCheckBox;
-
- gcn::Label *mUnsecureCharsLabel;
- gcn::TextField *mUnsecureCharsField;
- gcn::Button *mUnsecureCharsButton;
- std::string mUnsecureChars;
-
- bool mVisibleNamesEnabled;
- gcn::CheckBox *mVisibleNamesCheckBox;
-
- bool mShowPlayersStatus;
- gcn::CheckBox *mShowPlayersStatusCheckBox;
+ public:
+ Setup_Players();
- EditDialog *mEditDialog;
+ void apply();
};
#endif
diff --git a/src/gui/setup_relations.cpp b/src/gui/setup_relations.cpp
new file mode 100644
index 000000000..489d5a818
--- /dev/null
+++ b/src/gui/setup_relations.cpp
@@ -0,0 +1,439 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2008-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "gui/setup_relations.h"
+
+#include "actorspritemanager.h"
+#include "configuration.h"
+#include "localplayer.h"
+#include "logger.h"
+
+#include "gui/editdialog.h"
+#include "gui/okdialog.h"
+
+#include "gui/widgets/button.h"
+#include "gui/widgets/checkbox.h"
+#include "gui/widgets/dropdown.h"
+#include "gui/widgets/label.h"
+#include "gui/widgets/layouthelper.h"
+#include "gui/widgets/scrollarea.h"
+#include "gui/widgets/guitable.h"
+#include "gui/widgets/textfield.h"
+
+#include "utils/dtor.h"
+#include "utils/gettext.h"
+
+#include <string>
+#include <vector>
+
+#define COLUMNS_NR 2 // name plus listbox
+#define NAME_COLUMN 0
+#define RELATION_CHOICE_COLUMN 1
+
+#define ROW_HEIGHT 12
+// The following column widths really shouldn't be hardcoded but should scale with the size of the widget... except
+// that, right now, the widget doesn't exactly scale either.
+#define NAME_COLUMN_WIDTH 230
+#define RELATION_CHOICE_COLUMN_WIDTH 80
+
+#define WIDGET_AT(row, column) (((row) * COLUMNS_NR) + column)
+
+#include "debug.h"
+
+static const char *table_titles[COLUMNS_NR] =
+{
+ N_("Name"),
+ N_("Relation")
+};
+
+static const char *RELATION_NAMES[PlayerRelation::RELATIONS_NR] =
+{
+ N_("Neutral"),
+ N_("Friend"),
+ N_("Disregarded"),
+ N_("Ignored"),
+ N_("Erased")
+};
+
+class PlayerRelationListModel : public gcn::ListModel
+{
+public:
+ virtual ~PlayerRelationListModel() { }
+
+ virtual int getNumberOfElements()
+ {
+ return PlayerRelation::RELATIONS_NR;
+ }
+
+ virtual std::string getElementAt(int i)
+ {
+ if (i >= getNumberOfElements() || i < 0)
+ return "";
+ return gettext(RELATION_NAMES[i]);
+ }
+};
+
+class PlayerTableModel : public TableModel
+{
+public:
+ PlayerTableModel() :
+ mPlayers(NULL),
+ mListModel(new PlayerRelationListModel)
+ {
+ playerRelationsUpdated();
+ }
+
+ virtual ~PlayerTableModel()
+ {
+ freeWidgets();
+ delete mListModel;
+ mListModel = 0;
+ delete mPlayers;
+ mPlayers = 0;
+ }
+
+ virtual int getRows() const
+ {
+ if (mPlayers)
+ return static_cast<int>(mPlayers->size());
+ else
+ return 0;
+ }
+
+ virtual int getColumns() const
+ {
+ return COLUMNS_NR;
+ }
+
+ virtual int getRowHeight() const
+ {
+ return ROW_HEIGHT;
+ }
+
+ virtual int getColumnWidth(int index) const
+ {
+ if (index == NAME_COLUMN)
+ return NAME_COLUMN_WIDTH;
+ else
+ return RELATION_CHOICE_COLUMN_WIDTH;
+ }
+
+ virtual void playerRelationsUpdated()
+ {
+ signalBeforeUpdate();
+
+ freeWidgets();
+ std::vector<std::string> *player_names = player_relations.getPlayers();
+
+ if (!player_names)
+ return;
+
+ delete mPlayers;
+ mPlayers = player_names;
+
+ // set up widgets
+ for (unsigned int r = 0; r < player_names->size(); ++r)
+ {
+ std::string name = (*player_names)[r];
+ gcn::Widget *widget = new Label(name);
+ mWidgets.push_back(widget);
+
+ gcn::DropDown *choicebox = new DropDown(mListModel);
+ choicebox->setSelected(player_relations.getRelation(name));
+ mWidgets.push_back(choicebox);
+ }
+
+ signalAfterUpdate();
+ }
+
+ virtual void updateModelInRow(int row)
+ {
+ gcn::DropDown *choicebox = static_cast<gcn::DropDown *>(
+ getElementAt(row, RELATION_CHOICE_COLUMN));
+ player_relations.setRelation(getPlayerAt(row),
+ static_cast<PlayerRelation::Relation>(
+ choicebox->getSelected()));
+ }
+
+
+ virtual gcn::Widget *getElementAt(int row, int column) const
+ {
+ return mWidgets[WIDGET_AT(row, column)];
+ }
+
+ virtual void freeWidgets()
+ {
+ delete mPlayers;
+ mPlayers = 0;
+
+ delete_all(mWidgets);
+ mWidgets.clear();
+ }
+
+ std::string getPlayerAt(int index) const
+ {
+ return (*mPlayers)[index];
+ }
+
+protected:
+ std::vector<std::string> *mPlayers;
+ std::vector<gcn::Widget *> mWidgets;
+ PlayerRelationListModel *mListModel;
+};
+
+/**
+ * Class for choosing one of the various `what to do when ignoring a player' options
+ */
+class IgnoreChoicesListModel : public gcn::ListModel
+{
+public:
+ virtual ~IgnoreChoicesListModel() { }
+
+ virtual int getNumberOfElements()
+ {
+ return static_cast<int>(player_relations.getPlayerIgnoreStrategies()
+ ->size());
+ }
+
+ virtual std::string getElementAt(int i)
+ {
+ if (i >= getNumberOfElements() || i < 0)
+ return _("???");
+
+ return (*player_relations.getPlayerIgnoreStrategies())
+ [i]->mDescription;
+ }
+};
+
+#define ACTION_DELETE "delete"
+#define ACTION_OLD "old"
+#define ACTION_TABLE "table"
+#define ACTION_STRATEGY "strategy"
+#define ACTION_WHISPER_TAB "whisper tab"
+
+Setup_Relations::Setup_Relations():
+ mPlayerTableTitleModel(new StaticTableModel(1, COLUMNS_NR)),
+ mPlayerTableModel(new PlayerTableModel),
+ mPlayerTable(new GuiTable(mPlayerTableModel)),
+ mPlayerTitleTable(new GuiTable(mPlayerTableTitleModel)),
+ mPlayerScrollArea(new ScrollArea(mPlayerTable)),
+ mDefaultTrading(new CheckBox(_("Allow trading"),
+ player_relations.getDefault() & PlayerRelation::TRADE)),
+ mDefaultWhisper(new CheckBox(_("Allow whispers"),
+ player_relations.getDefault() & PlayerRelation::WHISPER)),
+ mDeleteButton(new Button(_("Delete"), ACTION_DELETE, this)),
+ mOldButton(new Button(_("Old"), ACTION_OLD, this))
+{
+ setName(_("Relations"));
+
+ mPlayerTable->setOpaque(false);
+
+ mPlayerTableTitleModel->fixColumnWidth(NAME_COLUMN, NAME_COLUMN_WIDTH);
+ mPlayerTableTitleModel->fixColumnWidth(RELATION_CHOICE_COLUMN,
+ RELATION_CHOICE_COLUMN_WIDTH);
+ mPlayerTitleTable->setBackgroundColor(gcn::Color(0xbf, 0xbf, 0xbf));
+
+ mIgnoreActionChoicesModel = new IgnoreChoicesListModel;
+ mIgnoreActionChoicesBox = new DropDown(mIgnoreActionChoicesModel);
+
+ for (int i = 0; i < COLUMNS_NR; i++)
+ {
+ mPlayerTableTitleModel->set(0, i,
+ new Label(gettext(table_titles[i])));
+ }
+
+ mPlayerTitleTable->setLinewiseSelection(true);
+
+ mPlayerScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
+ mPlayerTable->setActionEventId(ACTION_TABLE);
+ mPlayerTable->setLinewiseSelection(true);
+ mPlayerTable->addActionListener(this);
+
+ gcn::Label *ignore_action_label = new Label(_("When ignoring:"));
+
+ mIgnoreActionChoicesBox->setActionEventId(ACTION_STRATEGY);
+ mIgnoreActionChoicesBox->addActionListener(this);
+
+ int ignore_strategy_index = 0; // safe default
+
+ if (player_relations.getPlayerIgnoreStrategy())
+ {
+ ignore_strategy_index = player_relations.getPlayerIgnoreStrategyIndex(
+ player_relations.getPlayerIgnoreStrategy()->mShortName);
+ if (ignore_strategy_index < 0)
+ ignore_strategy_index = 0;
+ }
+ mIgnoreActionChoicesBox->setSelected(ignore_strategy_index);
+ mIgnoreActionChoicesBox->adjustHeight();
+
+ reset();
+
+ // Do the layout
+ LayoutHelper h(this);
+ ContainerPlacer place = h.getPlacer(0, 0);
+
+ place(0, 0, mPlayerTitleTable, 6);
+ place(0, 1, mPlayerScrollArea, 6, 4).setPadding(2);
+ place(0, 5, mDeleteButton);
+ place(1, 5, mOldButton, 1);
+ place(3, 5, ignore_action_label, 1);
+ place(4, 5, mIgnoreActionChoicesBox, 2).setPadding(2);
+ place(3, 6, mDefaultTrading, 3);
+ place(3, 7, mDefaultWhisper, 3);
+
+ player_relations.addListener(this);
+
+ setDimension(gcn::Rectangle(0, 0, 500, 350));
+}
+
+Setup_Relations::~Setup_Relations()
+{
+ player_relations.removeListener(this);
+ delete mIgnoreActionChoicesModel;
+ mIgnoreActionChoicesModel = 0;
+}
+
+
+void Setup_Relations::reset()
+{
+ // We now have to search through the list of ignore choices to find the
+ // current selection. We could use an index into the table of config
+ // options in player_relations instead of strategies to sidestep this.
+ int selection = 0;
+ for (unsigned int i = 0;
+ i < player_relations.getPlayerIgnoreStrategies()->size();
+ ++i)
+ if ((*player_relations.getPlayerIgnoreStrategies())[i] ==
+ player_relations.getPlayerIgnoreStrategy())
+ {
+
+ selection = i;
+ break;
+ }
+
+ mIgnoreActionChoicesBox->setSelected(selection);
+}
+
+void Setup_Relations::apply()
+{
+ player_relations.store();
+
+ unsigned int old_default_relations = player_relations.getDefault() &
+ ~(PlayerRelation::TRADE |
+ PlayerRelation::WHISPER);
+ player_relations.setDefault(old_default_relations
+ | (mDefaultTrading->isSelected() ?
+ PlayerRelation::TRADE : 0)
+ | (mDefaultWhisper->isSelected() ?
+ PlayerRelation::WHISPER : 0));
+
+ if (actorSpriteManager)
+ actorSpriteManager->updatePlayerNames();
+
+ if (player_node)
+ player_node->setCheckNameSetting(true);
+}
+
+void Setup_Relations::cancel()
+{
+}
+
+void Setup_Relations::action(const gcn::ActionEvent &event)
+{
+ if (event.getId() == ACTION_TABLE)
+ {
+ // temporarily eliminate ourselves: we are fully aware of this change,
+ // so there is no need for asynchronous updates. (In fact, thouse
+ // might destroy the widet that triggered them, which would be rather
+ // embarrassing.)
+ player_relations.removeListener(this);
+
+ int row = mPlayerTable->getSelectedRow();
+ if (row >= 0)
+ mPlayerTableModel->updateModelInRow(row);
+
+ player_relations.addListener(this);
+
+ }
+ else if (event.getId() == ACTION_DELETE)
+ {
+ int player_index = mPlayerTable->getSelectedRow();
+
+ if (player_index < 0)
+ return;
+
+ std::string name = mPlayerTableModel->getPlayerAt(player_index);
+
+ player_relations.removePlayer(name);
+ }
+ else if (event.getId() == ACTION_OLD)
+ {
+ player_relations.load(true);
+ updateAll();
+ }
+ else if (event.getId() == ACTION_STRATEGY)
+ {
+ PlayerIgnoreStrategy *s =
+ (*player_relations.getPlayerIgnoreStrategies())[
+ mIgnoreActionChoicesBox->getSelected()];
+
+ player_relations.setPlayerIgnoreStrategy(s);
+ }
+}
+
+void Setup_Relations::updatedPlayer(const std::string &name A_UNUSED)
+{
+ mPlayerTableModel->playerRelationsUpdated();
+ mDefaultTrading->setSelected(
+ player_relations.getDefault() & PlayerRelation::TRADE);
+ mDefaultWhisper->setSelected(
+ player_relations.getDefault() & PlayerRelation::WHISPER);
+ if (player_node)
+ player_node->updateName();
+}
+
+void Setup_Relations::updateAll()
+{
+ PlayerTableModel *model = new PlayerTableModel();
+ mPlayerTable->setModel(model);
+ delete mPlayerTableModel;
+ mPlayerTableModel = model;
+ int ignore_strategy_index = 0; // safe default
+
+ if (player_relations.getPlayerIgnoreStrategy())
+ {
+ ignore_strategy_index = player_relations.getPlayerIgnoreStrategyIndex(
+ player_relations.getPlayerIgnoreStrategy()->mShortName);
+ if (ignore_strategy_index < 0)
+ ignore_strategy_index = 0;
+ }
+ mIgnoreActionChoicesBox->setSelected(ignore_strategy_index);
+ mIgnoreActionChoicesBox->adjustHeight();
+ reset();
+}
+void Setup_Relations::externalUpdated()
+{
+ mDefaultTrading->setSelected(
+ player_relations.getDefault() & PlayerRelation::TRADE);
+ mDefaultWhisper->setSelected(
+ player_relations.getDefault() & PlayerRelation::WHISPER);
+}
diff --git a/src/gui/setup_relations.h b/src/gui/setup_relations.h
new file mode 100644
index 000000000..a6627a06d
--- /dev/null
+++ b/src/gui/setup_relations.h
@@ -0,0 +1,81 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2008-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GUI_SETUP_RELATIONS_H
+#define GUI_SETUP_RELATIONS_H
+
+#include "guichanfwd.h"
+#include "playerrelations.h"
+
+#include "gui/widgets/setuptab.h"
+
+#include <guichan/actionlistener.hpp>
+
+#ifdef __GNUC__
+#define A_UNUSED __attribute__ ((unused))
+#else
+#define A_UNUSED
+#endif
+
+class EditDialog;
+class GuiTable;
+class PlayerTableModel;
+class StaticTableModel;
+
+class Setup_Relations : public SetupTab,
+ public PlayerRelationsListener
+{
+public:
+ Setup_Relations();
+ virtual ~Setup_Relations();
+
+ void apply();
+ void cancel();
+
+ void reset();
+
+ void action(const gcn::ActionEvent &event);
+
+ virtual void updatedPlayer(const std::string &name);
+
+ virtual void updateAll();
+
+ virtual void externalUpdated();
+
+private:
+ StaticTableModel *mPlayerTableTitleModel;
+ PlayerTableModel *mPlayerTableModel;
+ GuiTable *mPlayerTable;
+ GuiTable *mPlayerTitleTable;
+ gcn::ScrollArea *mPlayerScrollArea;
+
+ gcn::CheckBox *mDefaultTrading;
+ gcn::CheckBox *mDefaultWhisper;
+
+ gcn::Button *mDeleteButton;
+ gcn::Button *mOldButton;
+
+ gcn::ListModel *mIgnoreActionChoicesModel;
+ gcn::DropDown *mIgnoreActionChoicesBox;
+};
+
+#endif
diff --git a/src/gui/setup_theme.cpp b/src/gui/setup_theme.cpp
index 515e15611..05f8c7315 100644
--- a/src/gui/setup_theme.cpp
+++ b/src/gui/setup_theme.cpp
@@ -1,9 +1,10 @@
/*
- * The Mana World
+ * The ManaPlus Client
* Copyright (C) 2009 The Mana World Development Team
* Copyright (C) 2010 Andrei Karas
+ * Copyright (C) 2011 ManaPlus developers
*
- * This file is part of The Mana World.
+ * This file is part of The ManaPlus Client.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -36,7 +37,7 @@
#include "configuration.h"
#include "localplayer.h"
-#include "log.h"
+#include "logger.h"
#include "utils/gettext.h"
@@ -50,6 +51,7 @@ const char* ACTION_BOLD_FONT = "bold font";
const char* ACTION_PARTICLE_FONT = "particle font";
const char* ACTION_HELP_FONT = "help font";
const char* ACTION_SECURE_FONT = "secure font";
+const char* ACTION_JAPAN_FONT = "japan font";
class NamesModel : public gcn::ListModel
{
@@ -135,6 +137,7 @@ Setup_Theme::Setup_Theme():
mParticleFont(config.getStringValue("particleFont")),
mHelpFont(config.getStringValue("helpFont")),
mSecureFont(config.getStringValue("secureFont")),
+ mJapanFont(config.getStringValue("japanFont")),
mFontSize(config.getIntValue("fontSize"))
{
setName(_("Theme"));
@@ -145,6 +148,7 @@ Setup_Theme::Setup_Theme():
mParticleFontLabel = new Label(_("Particle font"));
mHelpFontLabel = new Label(_("Help font"));
mSecureFontLabel = new Label(_("Secure font"));
+ mJapanFontLabel = new Label(_("Japanese font"));
mThemesModel = new ThemesModel();
mFontsModel = new FontsModel();
@@ -172,6 +176,10 @@ Setup_Theme::Setup_Theme():
mSecureFontDropDown->setActionEventId(ACTION_SECURE_FONT);
mSecureFontDropDown->addActionListener(this);
+ mJapanFontDropDown = new DropDown(mFontsModel);
+ mJapanFontDropDown->setActionEventId(ACTION_JAPAN_FONT);
+ mJapanFontDropDown->addActionListener(this);
+
fontSizeLabel = new Label(_("Font size"));
mFontSizeListModel = new FontSizeChoiceListModel;
mFontSizeDropDown = new DropDown(mFontSizeListModel);
@@ -194,25 +202,30 @@ Setup_Theme::Setup_Theme():
config.getStringValue("helpFont")));
mSecureFontDropDown->setSelectedString(getFileName(
config.getStringValue("secureFont")));
+ mJapanFontDropDown->setSelectedString(getFileName(
+ config.getStringValue("japanFont")));
// Do the layout
LayoutHelper h(this);
ContainerPlacer place = h.getPlacer(0, 0);
- place(0, 0, mThemeLabel, 10);
- place(0, 1, mThemeDropDown, 6);
- place(0, 2, fontSizeLabel, 10);
- place(0, 3, mFontSizeDropDown, 6);
- place(0, 4, mFontLabel, 10);
- place(0, 5, mFontDropDown, 6);
- place(0, 6, mBoldFontLabel, 10);
- place(0, 7, mBoldFontDropDown, 6);
- place(0, 8, mParticleFontLabel, 10);
- place(0, 9, mParticleFontDropDown, 6);
- place(0, 10, mHelpFontLabel, 10);
- place(0, 11, mHelpFontDropDown, 6);
- place(0, 12, mSecureFontLabel, 10);
- place(0, 13, mSecureFontDropDown, 6);
+ place(0, 0, mThemeLabel, 5);
+ place(0, 1, fontSizeLabel, 5);
+ place(0, 2, mFontLabel, 5);
+ place(0, 3, mBoldFontLabel, 5);
+ place(0, 4, mParticleFontLabel, 5);
+ place(0, 5, mHelpFontLabel, 5);
+ place(0, 6, mSecureFontLabel, 5);
+ place(0, 7, mJapanFontLabel, 5);
+
+ place(6, 0, mThemeDropDown, 10);
+ place(6, 1, mFontSizeDropDown, 10);
+ place(6, 2, mFontDropDown, 10);
+ place(6, 3, mBoldFontDropDown, 10);
+ place(6, 4, mParticleFontDropDown, 10);
+ place(6, 5, mHelpFontDropDown, 10);
+ place(6, 6, mSecureFontDropDown, 10);
+ place(6, 7, mJapanFontDropDown, 10);
place.getCell().matchColWidth(0, 0);
place = h.getPlacer(0, 1);
@@ -261,6 +274,10 @@ void Setup_Theme::action(const gcn::ActionEvent &event)
{
mSecureFont = mSecureFontDropDown->getSelectedString();
}
+ else if (event.getId() == ACTION_JAPAN_FONT)
+ {
+ mJapanFont = mJapanFontDropDown->getSelectedString();
+ }
}
void Setup_Theme::cancel()
@@ -271,6 +288,7 @@ void Setup_Theme::cancel()
mParticleFont = getFileName(config.getStringValue("particleFont"));
mHelpFont = getFileName(config.getStringValue("helpFont"));
mSecureFont = getFileName(config.getStringValue("secureFont"));
+ mJapanFont = getFileName(config.getStringValue("japanFont"));
}
void Setup_Theme::apply()
@@ -289,6 +307,7 @@ void Setup_Theme::apply()
|| config.getValue("particleFont", "dejavusans.ttf") != mParticleFont
|| config.getValue("helpFont", "dejavusansmono.ttf") != mHelpFont
|| config.getValue("secureFont", "dejavusansmono.ttf") != mSecureFont
+ || config.getValue("japanFont", "mplus-1p-regular.ttf") != mJapanFont
|| config.getIntValue("fontSize")
!= static_cast<int>(mFontSizeDropDown->getSelected()) + 10)
{
@@ -297,6 +316,7 @@ void Setup_Theme::apply()
config.setValue("particleFont", "fonts/" + getFileName(mParticleFont));
config.setValue("helpFont", "fonts/" + getFileName(mHelpFont));
config.setValue("secureFont", "fonts/" + getFileName(mSecureFont));
+ config.setValue("japanFont", "fonts/" + getFileName(mJapanFont));
config.setValue("fontSize", mFontSizeDropDown->getSelected() + 10);
gui->updateFonts();
}
diff --git a/src/gui/setup_theme.h b/src/gui/setup_theme.h
index 0d141c0a5..c803cc296 100644
--- a/src/gui/setup_theme.h
+++ b/src/gui/setup_theme.h
@@ -1,9 +1,10 @@
/*
- * The Mana World
+ * The ManaPlus Client
* Copyright (C) 2009 The Mana World Development Team
* Copyright (C) 2009-2010 Andrei Karas
+ * Copyright (C) 2011 ManaPlus developers
*
- * This file is part of The Mana World.
+ * This file is part of The ManaPlus Client.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -73,6 +74,10 @@ class Setup_Theme : public SetupTab
DropDown *mSecureFontDropDown;
std::string mSecureFont;
+ gcn::Label *mJapanFontLabel;
+ DropDown *mJapanFontDropDown;
+ std::string mJapanFont;
+
FontSizeChoiceListModel *mFontSizeListModel;
gcn::Label *fontSizeLabel;
int mFontSize;
diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp
index 3e5c56f64..03b485097 100644
--- a/src/gui/setup_video.cpp
+++ b/src/gui/setup_video.cpp
@@ -26,7 +26,7 @@
#include "game.h"
#include "graphics.h"
#include "localplayer.h"
-#include "log.h"
+#include "logger.h"
#include "main.h"
#include "particle.h"
@@ -274,7 +274,6 @@ const char *Setup_Video::particleDetailToString(int detail)
Setup_Video::Setup_Video():
mFullScreenEnabled(config.getBoolValue("screen")),
mOpenGLEnabled(config.getIntValue("opengl")),
- mHwAccelEnabled(config.getBoolValue("hwaccel")),
mCustomCursorEnabled(config.getBoolValue("customcursor")),
mParticleEffectsEnabled(config.getBoolValue("particleeffects")),
mPickupChatEnabled(config.getBoolValue("showpickupchat")),
@@ -282,16 +281,11 @@ Setup_Video::Setup_Video():
mOpacity(config.getFloatValue("guialpha")),
mFps(config.getIntValue("fpslimit")),
mAltFps(config.getIntValue("altfpslimit")),
- mAlphaCache(config.getBoolValue("alphaCache")),
- mEnableMapReduce(config.getBoolValue("enableMapReduce")),
- mAdjustPerfomance(config.getBoolValue("adjustPerfomance")),
- mBeingOpacity(config.getBoolValue("beingopacity")),
mSpeechMode(static_cast<Being::Speech>(
config.getIntValue("speech"))),
mModeListModel(new ModeListModel),
mModeList(new ListBox(mModeListModel)),
mFsCheckBox(new CheckBox(_("Full screen"), mFullScreenEnabled)),
- mHwAccelCheckBox(new CheckBox(_("Hw acceleration"), mHwAccelEnabled)),
mCustomCursorCheckBox(new CheckBox(_("Custom cursor"),
mCustomCursorEnabled)),
mParticleEffectsCheckBox(new CheckBox(_("Particle effects"),
@@ -302,13 +296,6 @@ Setup_Video::Setup_Video():
// TRANSLATORS: Refers to "Show own name"
mPickupParticleCheckBox(new CheckBox(_("as particle"),
mPickupParticleEnabled)),
- mAlphaCacheCheckBox(new CheckBox(_("Enable opacity cache"), mAlphaCache)),
- mEnableMapReduceCheckBox(new CheckBox(_("Enable map reduce"),
- mEnableMapReduce)),
- mAdjustPerfomanceCheckBox(new CheckBox(_("Auto adjust perfomance"),
- mAdjustPerfomance)),
- mBeingOpacityCheckBox(new CheckBox(_("Show beings transparency"),
- mBeingOpacity)),
mSpeechSlider(new Slider(0, 3)),
mSpeechLabel(new Label("")),
mAlphaSlider(new Slider(0.1, 1.0)),
@@ -348,8 +335,6 @@ Setup_Video::Setup_Video():
mAlphaSlider->setValue(mOpacity);
mAlphaSlider->setWidth(90);
- mAlphaCacheCheckBox->setEnabled(mOpenGLDropDown->getSelected() == 0);
- mEnableMapReduceCheckBox->setEnabled(mOpenGLDropDown->getSelected() == 0);
mFpsLabel->setCaption(mFps > 0 ? toString(mFps) : _("None"));
mFpsLabel->setWidth(60);
@@ -381,9 +366,6 @@ Setup_Video::Setup_Video():
mOverlayDetailField->setActionEventId("overlaydetailfield");
mParticleDetailSlider->setActionEventId("particledetailslider");
mParticleDetailField->setActionEventId("particledetailfield");
- mAlphaCacheCheckBox->setActionEventId("alphaCache");
- mEnableMapReduceCheckBox->setActionEventId("enableMapReduce");
- mAdjustPerfomanceCheckBox->setActionEventId("adjustPerfomance");
mOpenGLDropDown->setActionEventId("opengl");
mModeList->addActionListener(this);
@@ -402,10 +384,6 @@ Setup_Video::Setup_Video():
mParticleDetailField->addKeyListener(this);
mOpenGLDropDown->addActionListener(this);
- mAlphaCacheCheckBox->addKeyListener(this);
- mEnableMapReduceCheckBox->addKeyListener(this);
- mAdjustPerfomanceCheckBox->addKeyListener(this);
-
mSpeechLabel->setCaption(speechModeToString(mSpeechMode));
mSpeechSlider->setValue(mSpeechMode);
@@ -422,45 +400,40 @@ Setup_Video::Setup_Video():
place(0, 0, scrollArea, 1, 5).setPadding(2);
place(0, 5, mOpenGLDropDown, 1);
- place(0, 6, mHwAccelCheckBox, 6);
- place(0, 7, mAlphaCacheCheckBox, 6);
- place(0, 8, mEnableMapReduceCheckBox, 6);
+// place(0, 6, mHwAccelCheckBox, 6);
place(1, 0, mFsCheckBox, 2);
place(1, 1, mCustomCursorCheckBox, 3);
- place(1, 2, mBeingOpacityCheckBox);
- place(1, 3, mParticleEffectsCheckBox, 2);
-
- place(1, 4, mPickupNotifyLabel, 4);
+ place(1, 2, mParticleEffectsCheckBox, 2);
- place(1, 5, mPickupChatCheckBox, 1);
- place(2, 5, mPickupParticleCheckBox, 2);
+ place(1, 3, mPickupNotifyLabel, 4);
- place(0, 9, mAdjustPerfomanceCheckBox, 6);
+ place(1, 4, mPickupChatCheckBox, 1);
+ place(2, 4, mPickupParticleCheckBox, 2);
- place(0, 10, mAlphaSlider);
- place(1, 10, alphaLabel, 3);
+ place(0, 6, mAlphaSlider);
+ place(1, 6, alphaLabel, 3);
- place(0, 11, mFpsSlider);
- place(1, 11, mFpsCheckBox).setPadding(3);
- place(2, 11, mFpsLabel).setPadding(1);
+ place(0, 7, mFpsSlider);
+ place(1, 7, mFpsCheckBox).setPadding(3);
+ place(2, 7, mFpsLabel).setPadding(1);
- place(0, 12, mAltFpsSlider);
- place(1, 12, mAltFpsLabel).setPadding(3);
+ place(0, 8, mAltFpsSlider);
+ place(1, 8, mAltFpsLabel).setPadding(3);
- place(0, 13, mSpeechSlider);
- place(1, 13, speechLabel);
- place(2, 13, mSpeechLabel, 3).setPadding(2);
+ place(0, 9, mSpeechSlider);
+ place(1, 9, speechLabel);
+ place(2, 9, mSpeechLabel, 3).setPadding(2);
- place(0, 14, mOverlayDetailSlider);
- place(1, 14, overlayDetailLabel);
- place(2, 14, mOverlayDetailField, 3).setPadding(2);
+ place(0, 10, mOverlayDetailSlider);
+ place(1, 10, overlayDetailLabel);
+ place(2, 10, mOverlayDetailField, 3).setPadding(2);
- place(0, 15, mParticleDetailSlider);
- place(1, 15, particleDetailLabel);
- place(2, 15, mParticleDetailField, 3).setPadding(2);
+ place(0, 11, mParticleDetailSlider);
+ place(1, 11, particleDetailLabel);
+ place(2, 11, mParticleDetailField, 3).setPadding(2);
int width = 600;
@@ -551,33 +524,20 @@ void Setup_Video::apply()
mAltFpsSlider->setEnabled(mAltFps > 0);
- config.setValue("hwaccel", mHwAccelCheckBox->isSelected());
-
// FPS change
config.setValue("fpslimit", mFps);
config.setValue("altfpslimit", mAltFps);
- config.setValue("alphaCache", mAlphaCacheCheckBox->isSelected());
- config.setValue("enableMapReduce", mEnableMapReduceCheckBox->isSelected());
- config.setValue("adjustPerfomance",
- mAdjustPerfomanceCheckBox->isSelected());
- config.setValue("beingopacity", mBeingOpacityCheckBox->isSelected());
-
// We sync old and new values at apply time
mFullScreenEnabled = config.getBoolValue("screen");
mCustomCursorEnabled = config.getBoolValue("customcursor");
mParticleEffectsEnabled = config.getBoolValue("particleeffects");
- mAlphaCache = config.getBoolValue("alphaCache");
- mEnableMapReduce = config.getBoolValue("enableMapReduce");
- mAdjustPerfomance = config.getBoolValue("adjustPerfomance");
- mBeingOpacity = config.getBoolValue("beingopacity");
mSpeechMode = static_cast<Being::Speech>(
config.getIntValue("speech"));
mOpacity = config.getFloatValue("guialpha");
mOverlayDetail = config.getIntValue("OverlayDetail");
mOpenGLEnabled = config.getIntValue("opengl");
- mHwAccelEnabled = config.getBoolValue("hwaccel");
mPickupChatEnabled = config.getBoolValue("showpickupchat");
mPickupParticleEnabled = config.getBoolValue("showpickupparticle");
}
@@ -587,7 +547,6 @@ void Setup_Video::cancel()
mFpsCheckBox->setSelected(mFps > 0);
mFsCheckBox->setSelected(mFullScreenEnabled);
mOpenGLDropDown->setSelected(mOpenGLEnabled);
- mHwAccelCheckBox->setSelected(mHwAccelEnabled);
mCustomCursorCheckBox->setSelected(mCustomCursorEnabled);
mParticleEffectsCheckBox->setSelected(mParticleEffectsEnabled);
mFpsSlider->setValue(mFps);
@@ -595,10 +554,6 @@ void Setup_Video::cancel()
mAltFpsSlider->setValue(mAltFps);
mAltFpsSlider->setEnabled(mAltFps > 0);
mSpeechSlider->setValue(mSpeechMode);
- mAlphaCacheCheckBox->setSelected(mAlphaCache);
- mEnableMapReduceCheckBox->setSelected(mEnableMapReduce);
- mAdjustPerfomanceCheckBox->setSelected(mAdjustPerfomance);
- mBeingOpacityCheckBox->setSelected(mBeingOpacity);
mAlphaSlider->setValue(mOpacity);
mOverlayDetailSlider->setValue(mOverlayDetail);
mParticleDetailSlider->setValue(mParticleDetail);
@@ -618,17 +573,11 @@ void Setup_Video::cancel()
config.setValue("customcursor", mCustomCursorEnabled);
config.setValue("particleeffects", mParticleEffectsEnabled);
config.setValue("speech", static_cast<int>(mSpeechMode));
- config.setValue("alphaCache", mAlphaCache);
- config.setValue("enableMapReduce", mEnableMapReduce);
- config.setValue("adjustPerfomance", mAdjustPerfomance);
- config.setValue("beingopacity", mBeingOpacity);
config.setValue("guialpha", mOpacity);
Image::setEnableAlpha(mOpacity != 1.0f);
config.setValue("opengl", mOpenGLEnabled);
- config.setValue("hwaccel", mHwAccelEnabled);
config.setValue("showpickupchat", mPickupChatEnabled);
config.setValue("showpickupparticle", mPickupParticleEnabled);
- mAlphaCacheCheckBox->setEnabled(mOpenGLDropDown->getSelected() == 0);
}
void Setup_Video::action(const gcn::ActionEvent &event)
@@ -761,12 +710,6 @@ void Setup_Video::action(const gcn::ActionEvent &event)
mAltFpsSlider->setValue(mAltFps);
mAltFpsSlider->setEnabled(mAltFps > 0);
}
- else if (id == "opengl")
- {
- bool isSoftware = (mOpenGLDropDown->getSelected() == 0);
- mAlphaCacheCheckBox->setEnabled(isSoftware);
- mEnableMapReduceCheckBox->setEnabled(isSoftware);
- }
}
void Setup_Video::externalUpdated()
diff --git a/src/gui/setup_video.h b/src/gui/setup_video.h
index 9533877fb..509deb2fd 100644
--- a/src/gui/setup_video.h
+++ b/src/gui/setup_video.h
@@ -55,7 +55,6 @@ class Setup_Video : public SetupTab, public gcn::KeyListener
private:
bool mFullScreenEnabled;
int mOpenGLEnabled;
- bool mHwAccelEnabled;
bool mCustomCursorEnabled;
bool mParticleEffectsEnabled;
bool mPickupChatEnabled;
@@ -63,10 +62,6 @@ class Setup_Video : public SetupTab, public gcn::KeyListener
float mOpacity;
int mFps;
int mAltFps;
- bool mAlphaCache;
- bool mEnableMapReduce;
- bool mAdjustPerfomance;
- bool mBeingOpacity;
Being::Speech mSpeechMode;
ModeListModel *mModeListModel;
@@ -83,7 +78,6 @@ class Setup_Video : public SetupTab, public gcn::KeyListener
gcn::ListBox *mModeList;
gcn::CheckBox *mFsCheckBox;
gcn::DropDown *mOpenGLDropDown;
- gcn::CheckBox *mHwAccelCheckBox;
gcn::CheckBox *mCustomCursorCheckBox;
gcn::CheckBox *mParticleEffectsCheckBox;
@@ -91,10 +85,6 @@ class Setup_Video : public SetupTab, public gcn::KeyListener
gcn::CheckBox *mPickupChatCheckBox;
gcn::CheckBox *mPickupParticleCheckBox;
- gcn::CheckBox *mAlphaCacheCheckBox;
- gcn::CheckBox *mEnableMapReduceCheckBox;
- gcn::CheckBox *mAdjustPerfomanceCheckBox;
- gcn::CheckBox *mBeingOpacityCheckBox;
gcn::Slider *mSpeechSlider;
gcn::Label *mSpeechLabel;
gcn::Slider *mAlphaSlider;
diff --git a/src/gui/shopwindow.cpp b/src/gui/shopwindow.cpp
index 68ea57314..4311a04d2 100644
--- a/src/gui/shopwindow.cpp
+++ b/src/gui/shopwindow.cpp
@@ -803,3 +803,12 @@ int ShopWindow::sumAmount(Item *shopItem)
}
return sum;
}
+
+bool ShopWindow::isShopEmpty()
+{
+ if (!mBuyShopItems || !mSellShopItems)
+ return true;
+ if (mBuyShopItems->empty() && mSellShopItems->empty())
+ return true;
+ return false;
+}
diff --git a/src/gui/shopwindow.h b/src/gui/shopwindow.h
index e07803225..e3fd9a5ca 100644
--- a/src/gui/shopwindow.h
+++ b/src/gui/shopwindow.h
@@ -133,6 +133,8 @@ class ShopWindow : public Window, public gcn::ActionListener,
bool checkFloodCounter(int &counterTime);
+ bool isShopEmpty();
+
private:
void startTrade();
diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp
index 5b47a5494..ff57195a9 100644
--- a/src/gui/skilldialog.cpp
+++ b/src/gui/skilldialog.cpp
@@ -22,7 +22,7 @@
#include "gui/skilldialog.h"
-#include "log.h"
+#include "logger.h"
#include "playerinfo.h"
#include "configuration.h"
@@ -152,7 +152,9 @@ public:
SkillListBox(SkillModel *model):
ListBox(model),
mModel(model),
- mPopup(new TextPopup())
+ mPopup(new TextPopup()),
+ mHighlightColor(Theme::getThemeColor(Theme::HIGHLIGHT)),
+ mTextColor(Theme::getThemeColor(Theme::TEXT))
{
}
@@ -187,8 +189,8 @@ public:
Graphics *graphics = static_cast<Graphics*>(gcnGraphics);
- graphics->setColor(Theme::getThemeColor(Theme::HIGHLIGHT,
- static_cast<int>(mAlpha * 255.0f)));
+ mHighlightColor.a = static_cast<int>(mAlpha * 255.0f);
+ graphics->setColor(mHighlightColor);
graphics->setFont(getFont());
// Draw filled rectangle around the selected list element
@@ -199,7 +201,7 @@ public:
}
// Draw the list elements
- graphics->setColor(Theme::getThemeColor(Theme::TEXT));
+ graphics->setColor(mTextColor);
for (int i = 0, y = 1;
i < model->getNumberOfElements();
++i, y += getRowHeight())
@@ -239,6 +241,8 @@ public:
private:
SkillModel *mModel;
TextPopup *mPopup;
+ gcn::Color mHighlightColor;
+ gcn::Color mTextColor;
};
class SkillTab : public Tab
diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp
index adcfe4d70..e3aa69b30 100644
--- a/src/gui/socialwindow.cpp
+++ b/src/gui/socialwindow.cpp
@@ -25,7 +25,7 @@
#include "guild.h"
#include "keyboardconfig.h"
#include "localplayer.h"
-#include "log.h"
+#include "logger.h"
#include "map.h"
#include "party.h"
diff --git a/src/gui/specialswindow.cpp b/src/gui/specialswindow.cpp
index 1c41752f3..a5d95c7ff 100644
--- a/src/gui/specialswindow.cpp
+++ b/src/gui/specialswindow.cpp
@@ -21,7 +21,7 @@
#include "gui/specialswindow.h"
-#include "log.h"
+#include "logger.h"
#include "gui/setup.h"
#include "gui/theme.h"
diff --git a/src/gui/spellpopup.cpp b/src/gui/spellpopup.cpp
index e867ec4e8..a918e037d 100644
--- a/src/gui/spellpopup.cpp
+++ b/src/gui/spellpopup.cpp
@@ -1,10 +1,11 @@
/*
- * The Mana World
+ * The ManaPlus Client
* Copyright (C) 2008 The Legend of Mazzeroth Development Team
* Copyright (C) 2009 The Mana World Development Team
* Copyright (C) 2009-2010 Andrei Karas
+ * Copyright (C) 2011 ManaPlus developers
*
- * This file is part of The Mana World.
+ * This file is part of The ManaPlus Client.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -26,6 +27,8 @@
#include "gui/gui.h"
#include "gui/palette.h"
+#include "gui/widgets/label.h"
+
#include "textcommand.h"
#include "graphics.h"
@@ -35,7 +38,6 @@
#include "utils/stringutils.h"
#include <guichan/font.hpp>
-#include <guichan/widgets/label.hpp>
#include "debug.h"
@@ -43,7 +45,7 @@ SpellPopup::SpellPopup():
Popup("SpellPopup")
{
// Item Name
- mItemName = new gcn::Label;
+ mItemName = new Label;
mItemName->setFont(boldFont);
mItemName->setPosition(getPadding(), getPadding());
diff --git a/src/gui/spellpopup.h b/src/gui/spellpopup.h
index 1b14e0e4c..69c47bf45 100644
--- a/src/gui/spellpopup.h
+++ b/src/gui/spellpopup.h
@@ -1,10 +1,11 @@
/*
- * The Mana World
+ * The ManaPlus Client
* Copyright (C) 2008 The Legend of Mazzeroth Development Team
* Copyright (C) 2009 The Mana World Development Team
* Copyright (C) 2009-2010 Andrei Karas
+ * Copyright (C) 2011 ManaPlus developers
*
- * This file is part of The Mana World.
+ * This file is part of The ManaPlus Client.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/gui/statuspopup.cpp b/src/gui/statuspopup.cpp
index c4216013a..bb7a295ab 100644
--- a/src/gui/statuspopup.cpp
+++ b/src/gui/statuspopup.cpp
@@ -1,10 +1,11 @@
/*
- * The Mana World
+ * The ManaPlus Client
* Copyright (C) 2008 The Legend of Mazzeroth Development Team
* Copyright (C) 2009 The Mana World Development Team
* Copyright (C) 2009-2010 Andrei Karas
+ * Copyright (C) 2011 ManaPlus developers
*
- * This file is part of The Mana World.
+ * This file is part of The ManaPlus Client.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -27,6 +28,7 @@
#include "gui/palette.h"
#include "gui/viewport.h"
+#include "gui/widgets/label.h"
#include "gui/widgets/layout.h"
#include "gui/widgets/textbox.h"
@@ -49,51 +51,51 @@ StatusPopup::StatusPopup():
const int fontHeight = getFont()->getHeight();
- mMoveType = new gcn::Label;
+ mMoveType = new Label;
mMoveType->setPosition(getPadding(), getPadding());
- mCrazyMoveType = new gcn::Label;
+ mCrazyMoveType = new Label;
mCrazyMoveType->setPosition(getPadding(), fontHeight + getPadding());
- mMoveToTargetType = new gcn::Label;
+ mMoveToTargetType = new Label;
mMoveToTargetType->setPosition(getPadding(),
2 * fontHeight + getPadding());
- mFollowMode = new gcn::Label;
+ mFollowMode = new Label;
mFollowMode->setPosition(getPadding(), 3 * fontHeight + getPadding());
- mAttackWeaponType = new gcn::Label;
+ mAttackWeaponType = new Label;
mAttackWeaponType->setPosition(getPadding(),
4 + 4 * fontHeight + getPadding());
- mAttackType = new gcn::Label;
+ mAttackType = new Label;
mAttackType->setPosition(getPadding(), 4 + 5 * fontHeight + getPadding());
- mMagicAttackType = new gcn::Label;
+ mMagicAttackType = new Label;
mMagicAttackType->setPosition(getPadding(),
4 + 6 * fontHeight + getPadding());
- mDropCounter = new gcn::Label;
+ mDropCounter = new Label;
mDropCounter->setPosition(getPadding(), 8 + 7 * fontHeight + getPadding());
- mPickUpType = new gcn::Label;
+ mPickUpType = new Label;
mPickUpType->setPosition(getPadding(), 8 + 8 * fontHeight + getPadding());
- mMapType = new gcn::Label;
+ mMapType = new Label;
mMapType->setPosition(getPadding(), 12 + 9 * fontHeight + getPadding());
- mImitationMode = new gcn::Label;
+ mImitationMode = new Label;
mImitationMode->setPosition(getPadding(),
16 + 10 * fontHeight + getPadding());
- mAwayMode = new gcn::Label;
+ mAwayMode = new Label;
mAwayMode->setPosition(getPadding(), 16 + 11 * fontHeight + getPadding());
- mCameraMode = new gcn::Label;
+ mCameraMode = new Label;
mCameraMode->setPosition(getPadding(),
16 + 12 * fontHeight + getPadding());
- mDisableGameModifiers = new gcn::Label;
+ mDisableGameModifiers = new Label;
mDisableGameModifiers->setPosition(getPadding(),
20 + 13 * fontHeight + getPadding());
diff --git a/src/gui/statuspopup.h b/src/gui/statuspopup.h
index d633fb1f6..802b077a6 100644
--- a/src/gui/statuspopup.h
+++ b/src/gui/statuspopup.h
@@ -1,10 +1,11 @@
/*
- * The Mana World
+ * The ManaPlus Client
* Copyright (C) 2008 The Legend of Mazzeroth Development Team
* Copyright (C) 2009 The Mana World Development Team
* Copyright (C) 2009-2010 Andrei Karas
+ * Copyright (C) 2011 ManaPlus developers
*
- * This file is part of The Mana World.
+ * This file is part of The ManaPlus Client.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp
index b96720341..7ab2afa2d 100644
--- a/src/gui/statuswindow.cpp
+++ b/src/gui/statuswindow.cpp
@@ -22,6 +22,7 @@
#include "gui/statuswindow.h"
+#include "chatwindow.h"
#include "configuration.h"
#include "event.h"
#include "equipment.h"
@@ -71,6 +72,14 @@ class AttrDisplay : public Container
virtual Type getType()
{ return UNKNOWN; }
+ std::string getValue()
+ {
+ if (!mValue)
+ return "-";
+ else
+ return mValue->getCaption();
+ }
+
protected:
AttrDisplay(int id, const std::string &name);
@@ -228,6 +237,10 @@ StatusWindow::StatusWindow():
mCharacterPointsLabel = new Label("C");
place(0, 6, mCharacterPointsLabel, 5);
+ mCopyButton = new Button(_("Copy to chat"), "copy", this);
+
+ place(0, 5, mCopyButton);
+
if (Net::getPlayerHandler()->canCorrectAttributes())
{
mCorrectionPointsLabel = new Label("C");
@@ -343,7 +356,7 @@ void StatusWindow::event(Mana::Channels channel A_UNUSED,
if (!lvl)
{
- // possible server broken and dont send job level,
+ // possible server broken and don't send job level,
// then we fixing it :)
if (exp.second < 20000)
{
@@ -359,7 +372,7 @@ void StatusWindow::event(Mana::Channels channel A_UNUSED,
}
if (exp.first < oldExp && exp.second >= 20000)
- { // possible job level up. but server broken and dont send
+ { // possible job level up. but server broken and don't send
// new job exp limit, we fixing it
lvl ++;
blocked = true;
@@ -876,7 +889,6 @@ void StatusWindow::updateStatusBar(ProgressBar *bar, bool percent A_UNUSED)
col.r = 100;
col.g = 100;
col.b = 100;
-// bar->setColor(new gcn::Color(100, 100, 100));
bar->setColor(col);
}
else
@@ -885,11 +897,31 @@ void StatusWindow::updateStatusBar(ProgressBar *bar, bool percent A_UNUSED)
col.r = 255;
col.g = 255;
col.b = 0;
-// bar->setColor(new gcn::Color(255, 255, 0));
bar->setColor(col);
}
}
+void StatusWindow::action(const gcn::ActionEvent &event)
+{
+ if (!chatWindow)
+ return;
+
+ if (event.getId() == "copy")
+ {
+ Attrs::iterator it = mAttrs.begin();
+ Attrs::iterator it_end = mAttrs.end();
+ std::string str;
+ while (it != it_end)
+ {
+ ChangeDisplay *attr = dynamic_cast<ChangeDisplay*>((*it).second);
+ if (attr)
+ str += attr->getValue() + " ";
+ ++ it;
+ }
+ chatWindow->addInputText(str);
+ }
+}
+
AttrDisplay::AttrDisplay(int id, const std::string &name):
mId(id),
mName(name)
diff --git a/src/gui/statuswindow.h b/src/gui/statuswindow.h
index 74eb2c401..44d052004 100644
--- a/src/gui/statuswindow.h
+++ b/src/gui/statuswindow.h
@@ -48,7 +48,9 @@ class VertContainer;
*
* \ingroup Interface
*/
-class StatusWindow : public Window, public Mana::Listener
+class StatusWindow : public Window,
+ public gcn::ActionListener,
+ public Mana::Listener
{
public:
/**
@@ -77,6 +79,8 @@ class StatusWindow : public Window, public Mana::Listener
void updateProgressBar(ProgressBar *bar, int id,
bool percent = true);
+ void action(const gcn::ActionEvent &event);
+
private:
static std::string translateLetter(char* letters);
@@ -97,6 +101,7 @@ class StatusWindow : public Window, public Mana::Listener
gcn::Label *mCharacterPointsLabel;
gcn::Label *mCorrectionPointsLabel;
+ gcn::Button *mCopyButton;
typedef std::map<int, AttrDisplay*> Attrs;
Attrs mAttrs;
diff --git a/src/gui/textcommandeditor.cpp b/src/gui/textcommandeditor.cpp
index b3a1440e1..8cf9fa398 100644
--- a/src/gui/textcommandeditor.cpp
+++ b/src/gui/textcommandeditor.cpp
@@ -1,9 +1,10 @@
/*
- * The Mana World
+ * The ManaPlus Client
* Copyright (C) 2009 The Mana World Development Team
* Copyright (C) 2009-2010 Andrei Karas
+ * Copyright (C) 2011 ManaPlus developers
*
- * This file is part of The Mana World.
+ * This file is part of The ManaPlus Client.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -37,7 +38,7 @@
#include "gui/widgets/layout.h"
#include "gui/widgets/layouthelper.h"
#include "gui/widgets/radiobutton.h"
-#include "gui/widgets/table.h"
+#include "gui/widgets/guitable.h"
#include "gui/widgets/textfield.h"
#include "configuration.h"
diff --git a/src/gui/textcommandeditor.h b/src/gui/textcommandeditor.h
index cb88b8160..236c42320 100644
--- a/src/gui/textcommandeditor.h
+++ b/src/gui/textcommandeditor.h
@@ -1,9 +1,10 @@
/*
- * The Mana World
+ * The ManaPlus Client
* Copyright (C) 2009 The Mana World Development Team
* Copyright (C) 2009-2010 Andrei Karas
+ * Copyright (C) 2011 ManaPlus developers
*
- * This file is part of The Mana World.
+ * This file is part of The ManaPlus Client.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/gui/textpopup.cpp b/src/gui/textpopup.cpp
index 4114706a6..1ff601154 100644
--- a/src/gui/textpopup.cpp
+++ b/src/gui/textpopup.cpp
@@ -1,11 +1,11 @@
/*
- * The Mana World
+ * The ManaPlus Client
* Copyright (C) 2008 The Legend of Mazzeroth Development Team
* Copyright (C) 2008-2009 The Mana World Development Team
* Copyright (C) 2009-2010 The Mana Developers
* Copyright (C) 2011 The ManaPlus Developers
*
- * This file is part of The Mana World.
+ * This file is part of The ManaPlus Client.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -26,6 +26,9 @@
#include "gui/gui.h"
#include "gui/palette.h"
+#include "gui/theme.h"
+
+#include "gui/widgets/label.h"
#include "graphics.h"
#include "units.h"
@@ -34,7 +37,6 @@
#include "utils/stringutils.h"
#include <guichan/font.hpp>
-#include <guichan/widgets/label.hpp>
#include "debug.h"
@@ -43,13 +45,13 @@ TextPopup::TextPopup():
{
const int fontHeight = getFont()->getHeight();
- mText1 = new gcn::Label;
+ mText1 = new Label;
mText1->setPosition(getPadding(), getPadding());
- mText2 = new gcn::Label;
+ mText2 = new Label;
mText2->setPosition(getPadding(), fontHeight + 2 * getPadding());
- mText3 = new gcn::Label;
+ mText3 = new Label;
mText3->setPosition(getPadding(), (2 * fontHeight) + 2 * getPadding());
add(mText1);
diff --git a/src/gui/textpopup.h b/src/gui/textpopup.h
index 898b53555..9ac041389 100644
--- a/src/gui/textpopup.h
+++ b/src/gui/textpopup.h
@@ -1,11 +1,11 @@
/*
- * The Mana World
+ * The ManaPlus Client
* Copyright (C) 2008 The Legend of Mazzeroth Development Team
* Copyright (C) 2008-2009 The Mana World Development Team
* Copyright (C) 2009-2010 The Mana Developers
* Copyright (C) 2011 The ManaPlus Developers
*
- * This file is part of The Mana World.
+ * This file is part of The ManaPlus Client.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp
index 92613a3b3..15554044d 100644
--- a/src/gui/theme.cpp
+++ b/src/gui/theme.cpp
@@ -26,7 +26,7 @@
#include "client.h"
#include "configuration.h"
-#include "log.h"
+#include "logger.h"
#include "resources/dye.h"
#include "resources/image.h"
@@ -599,6 +599,7 @@ static int readColorType(const std::string &type)
"TEXT",
"SHADOW",
"OUTLINE",
+ "BORDER",
"PROGRESS_BAR",
"BUTTON",
"BUTTON_DISABLED",
@@ -608,11 +609,15 @@ static int readColorType(const std::string &type)
"GUILD_CHAT_TAB",
"GUILD_SOCIAL_TAB",
"BACKGROUND",
+ "BACKGROUND_GRAY",
+ "SCROLLBAR_GRAY",
+ "DROPDOWN_SHADOW",
"HIGHLIGHT",
"TAB_FLASH",
"TAB_PLAYER_FLASH",
"SHOP_WARNING",
"ITEM_EQUIPPED",
+ "ITEM_NOT_EQUIPPED",
"CHAT",
"GM",
"PLAYER",
diff --git a/src/gui/theme.h b/src/gui/theme.h
index 120214232..4e6a64a6f 100644
--- a/src/gui/theme.h
+++ b/src/gui/theme.h
@@ -143,6 +143,7 @@ class Theme : public Palette, public ConfigListener
TEXT = 0,
SHADOW,
OUTLINE,
+ BORDER,
PROGRESS_BAR,
BUTTON,
BUTTON_DISABLED,
@@ -152,11 +153,15 @@ class Theme : public Palette, public ConfigListener
GUILD_CHAT_TAB,
GUILD_SOCIAL_TAB,
BACKGROUND,
+ BACKGROUND_GRAY,
+ SCROLLBAR_GRAY,
+ DROPDOWN_SHADOW,
HIGHLIGHT,
TAB_FLASH,
TAB_PLAYER_FLASH,
SHOP_WARNING,
ITEM_EQUIPPED,
+ ITEM_NOT_EQUIPPED,
CHAT,
GM,
PLAYER,
diff --git a/src/gui/tradewindow.cpp b/src/gui/tradewindow.cpp
index c607636d9..d00fb61f4 100644
--- a/src/gui/tradewindow.cpp
+++ b/src/gui/tradewindow.cpp
@@ -246,8 +246,11 @@ void TradeWindow::receivedOk(bool own)
}
}
-void TradeWindow::tradeItem(Item *item, int quantity)
+void TradeWindow::tradeItem(Item *item, int quantity, bool check)
{
+ if (check && !checkItem(item))
+ return;
+
Net::getTradeHandler()->addItem(item, quantity);
}
@@ -325,15 +328,9 @@ void TradeWindow::action(const gcn::ActionEvent &event)
if (mMyInventory->getFreeSlot() == -1)
return;
- if (mMyInventory->contains(item))
- {
- if (localChatTab)
- {
- localChatTab->chatLog(_("Failed adding item. You can not "
- "overlap one kind of item on the window."), BY_SERVER);
- }
+
+ if (!checkItem(item))
return;
- }
// Choose amount of items to trade
ItemAmountWindow::showWindow(ItemAmountWindow::TradeAdd, this, item);
@@ -442,3 +439,21 @@ void TradeWindow::initTrade(std::string nick)
if (!player_relations.isGoodName(nick))
setCaptionFont(gui->getSecureFont());
}
+
+bool TradeWindow::checkItem(Item *item)
+{
+ Item *tradeItem = mMyInventory->findItem(
+ item->getId(), item->getColor());
+
+ if (tradeItem && (tradeItem->getQuantity() > 1
+ || item->getQuantity() > 1))
+ {
+ if (localChatTab)
+ {
+ localChatTab->chatLog(_("Failed adding item. You can not "
+ "overlap one kind of item on the window."), BY_SERVER);
+ }
+ return false;
+ }
+ return true;
+}
diff --git a/src/gui/tradewindow.h b/src/gui/tradewindow.h
index 3c5ed56b0..16b3d9d6f 100644
--- a/src/gui/tradewindow.h
+++ b/src/gui/tradewindow.h
@@ -95,7 +95,7 @@ class TradeWindow : public Window, gcn::ActionListener, gcn::SelectionListener
/**
* Send trade packet.
*/
- void tradeItem(Item *item, int quantity);
+ void tradeItem(Item *item, int quantity, bool check = false);
/**
* Updates the labels and makes sure only one item is selected in
@@ -131,6 +131,8 @@ class TradeWindow : public Window, gcn::ActionListener, gcn::SelectionListener
std::string getAutoTradeNick()
{ return mAutoAddToNick; }
+ bool checkItem(Item *item);
+
private:
enum Status
{
diff --git a/src/gui/unregisterdialog.cpp b/src/gui/unregisterdialog.cpp
index 8f845e746..568e0613e 100644
--- a/src/gui/unregisterdialog.cpp
+++ b/src/gui/unregisterdialog.cpp
@@ -23,7 +23,7 @@
#include "gui/unregisterdialog.h"
#include "client.h"
-#include "log.h"
+#include "logger.h"
#include "gui/okdialog.h"
#include "gui/register.h"
diff --git a/src/gui/updatewindow.cpp b/src/gui/updaterwindow.cpp
index eb5471e2a..7534b12a9 100644
--- a/src/gui/updatewindow.cpp
+++ b/src/gui/updaterwindow.cpp
@@ -20,11 +20,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "gui/updatewindow.h"
+#include "gui/updaterwindow.h"
#include "client.h"
#include "configuration.h"
-#include "log.h"
+#include "logger.h"
#include "main.h"
#include "gui/sdlinput.h"
diff --git a/src/gui/updatewindow.h b/src/gui/updaterwindow.h
index a1dc556d5..a1dc556d5 100644
--- a/src/gui/updatewindow.h
+++ b/src/gui/updaterwindow.h
diff --git a/src/gui/userpalette.cpp b/src/gui/userpalette.cpp
index 40dddc4f1..eac9559ef 100644
--- a/src/gui/userpalette.cpp
+++ b/src/gui/userpalette.cpp
@@ -25,7 +25,7 @@
#include "configuration.h"
#include "client.h"
-#include "log.h"
+#include "logger.h"
#include "gui/gui.h"
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index ba8414699..a5b541a8e 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -36,7 +36,7 @@
#include "gui/beingpopup.h"
#include "gui/chatwindow.h"
#include "gui/gui.h"
-#include "gui/ministatus.h"
+#include "gui/ministatuswindow.h"
#include "gui/popupmenu.h"
#include "gui/statuspopup.h"
#include "gui/textpopup.h"
@@ -145,8 +145,10 @@ void Viewport::draw(gcn::Graphics *gcnGraphics)
if (mScrollLaziness < 1)
mScrollLaziness = 1; // Avoids division by zero
+ int cnt = 0;
+
// Apply lazy scrolling
- while (lastTick < tick_time)
+ while (lastTick < tick_time && cnt < 32)
{
if (player_x > static_cast<int>(mPixelViewX) + mScrollRadius)
{
@@ -172,19 +174,26 @@ void Viewport::draw(gcn::Graphics *gcnGraphics)
- static_cast<int>(mPixelViewY) + mScrollRadius) /
static_cast<float>(mScrollLaziness);
}
- lastTick++;
+ lastTick ++;
+ cnt ++;
}
// Auto center when player is off screen
- if (player_x - static_cast<int>(mPixelViewX) > graphics->mWidth / 2
- || static_cast<int>(mPixelViewX) - player_x > graphics->mWidth / 2
- || static_cast<int>(mPixelViewY) - player_y
- > graphics->getHeight() / 2
- || player_y - static_cast<int>(mPixelViewY)
- > graphics->getHeight() / 2)
+ if (cnt > 30 || player_x - static_cast<int>(mPixelViewX)
+ > graphics->mWidth / 2 || static_cast<int>(mPixelViewX)
+ - player_x > graphics->mWidth / 2 || static_cast<int>(mPixelViewY)
+ - player_y > graphics->getHeight() / 2 || player_y
+ - static_cast<int>(mPixelViewY) > graphics->getHeight() / 2)
{
mPixelViewX = static_cast<float>(player_x);
mPixelViewY = static_cast<float>(player_y);
+ if (player_x <= 0 || player_y <= 0)
+ {
+ if (debugChatTab)
+ debugChatTab->chatLog("incorrect player position!");
+ logger->log("incorrect player position: %d, %d",
+ player_x, player_y);
+ }
};
// Don't move camera so that the end of the map is on screen
@@ -684,7 +693,8 @@ void Viewport::mouseMoved(gcn::MouseEvent &event A_UNUSED)
const int y = getMouseY() + static_cast<int>(mPixelViewY);
mHoverBeing = actorSpriteManager->findBeingByPixel(x, y, true);
- if (mHoverBeing && mHoverBeing->getType() == Being::PLAYER)
+ if (mHoverBeing && (mHoverBeing->getType() == Being::PLAYER
+ || mHoverBeing->getType() == Being::NPC))
{
mTextPopup->setVisible(false);
if (mShowBeingPopup)
diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp
index 9c1a71478..99da53c66 100644
--- a/src/gui/whoisonline.cpp
+++ b/src/gui/whoisonline.cpp
@@ -1,9 +1,10 @@
/*
- * The Mana World
+ * The ManaPlus Client
* Copyright (C) 2009 The Mana World Development Team
* Copyright (C) 2009-2010 Andrei Karas
+ * Copyright (C) 2011 ManaPlus developers
*
- * This file is part of The Mana World.
+ * This file is part of The ManaPlus Client.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/gui/whoisonline.h b/src/gui/whoisonline.h
index 644121d08..72063b183 100644
--- a/src/gui/whoisonline.h
+++ b/src/gui/whoisonline.h
@@ -1,9 +1,10 @@
/*
- * The Mana World
+ * The ManaPlus Client
* Copyright (C) 2009 The Mana World Development Team
* Copyright (C) 2009-2010 Andrei Karas
+ * Copyright (C) 2011 ManaPlus developers
*
- * This file is part of The Mana World.
+ * This file is part of The ManaPlus Client.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp
index 748e038e2..d4764cba5 100644
--- a/src/gui/widgets/avatarlistbox.cpp
+++ b/src/gui/widgets/avatarlistbox.cpp
@@ -66,6 +66,9 @@ AvatarListBox::AvatarListBox(AvatarListModel *model):
config.addListener("showgender", this);
config.addListener("showlevel", this);
+
+ mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT);
+ setForegroundColor(Theme::getThemeColor(Theme::TEXT));
}
AvatarListBox::~AvatarListBox()
@@ -102,8 +105,8 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics)
Graphics *graphics = static_cast<Graphics*>(gcnGraphics);
- graphics->setColor(Theme::getThemeColor(Theme::HIGHLIGHT,
- static_cast<int>(mAlpha * 255.0f)));
+ mHighlightColor.a = static_cast<int>(mAlpha * 255.0f);
+ graphics->setColor(mHighlightColor);
graphics->setFont(getFont());
const int fontHeight = getFont()->getHeight();
@@ -113,7 +116,7 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics)
const std::string name = player_node->getName();
// Draw the list elements
- graphics->setColor(Theme::getThemeColor(Theme::TEXT));
+ graphics->setColor(getForegroundColor());
for (int i = 0, y = 0;
i < model->getNumberOfElements();
++i, y += fontHeight)
@@ -206,7 +209,7 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics)
if (a->getLevel() > 1)
{
- graphics->setColor(Theme::getThemeColor(Theme::TEXT));
+ graphics->setColor(getForegroundColor());
int minHp = 40 + ((a->getLevel() - 1) * 5);
if (minHp < 0)
minHp = 40;
@@ -242,28 +245,48 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics)
}
}
- if (mShowGender)
+ if (graphics->getSecure())
{
- switch (a->getGender())
+ if (mShowGender)
{
- case GENDER_FEMALE:
- text += strprintf(" \u2640 %s",
- a->getAdditionString().c_str());
- break;
- case GENDER_MALE:
- text += strprintf(" \u2642 %s",
- a->getAdditionString().c_str());
- break;
- default:
- break;
+ switch (a->getGender())
+ {
+ case GENDER_FEMALE:
+ text += strprintf(" \u2640 ");
+ break;
+ case GENDER_MALE:
+ text += strprintf(" \u2642 ");
+ break;
+ default:
+ break;
+ }
}
}
else
{
- text += a->getAdditionString();
+ if (mShowGender)
+ {
+ switch (a->getGender())
+ {
+ case GENDER_FEMALE:
+ text += strprintf(" \u2640 %s",
+ a->getAdditionString().c_str());
+ break;
+ case GENDER_MALE:
+ text += strprintf(" \u2642 %s",
+ a->getAdditionString().c_str());
+ break;
+ default:
+ break;
+ }
+ }
+ else
+ {
+ text += a->getAdditionString();
+ }
}
- graphics->setColor(Theme::getThemeColor(Theme::TEXT));
+ graphics->setColor(getForegroundColor());
// Draw Name
if (a->getType() == MapItem::SEPARATOR)
@@ -366,8 +389,10 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event)
{
if (ava->getType() == AVATAR_PLAYER && chatWindow)
{
- chatWindow->addWhisperTab(model->getAvatarAt(selected)
- ->getName(), true);
+ ChatTab *tab = chatWindow->addWhisperTab(
+ model->getAvatarAt(selected)->getName(), true);
+ if (chatWindow && tab)
+ chatWindow->saveState();
}
}
}
diff --git a/src/gui/widgets/avatarlistbox.h b/src/gui/widgets/avatarlistbox.h
index 2fe1dfe3d..afb4abdf5 100644
--- a/src/gui/widgets/avatarlistbox.h
+++ b/src/gui/widgets/avatarlistbox.h
@@ -62,6 +62,7 @@ public:
private:
bool mShowGender;
bool mShowLevel;
+ gcn::Color mHighlightColor;
static int instances;
static Image *onlineIcon;
diff --git a/src/gui/widgets/battletab.cpp b/src/gui/widgets/battletab.cpp
index e72c78ee0..c5500e801 100644
--- a/src/gui/widgets/battletab.cpp
+++ b/src/gui/widgets/battletab.cpp
@@ -22,10 +22,10 @@
#include "gui/widgets/battletab.h"
-#include "chatlog.h"
+#include "chatlogger.h"
#include "commandhandler.h"
#include "localplayer.h"
-#include "log.h"
+#include "logger.h"
#include "main.h"
#include "gui/theme.h"
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index 140a72770..bb83c1159 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -25,7 +25,7 @@
#include "client.h"
#include "graphics.h"
-#include "log.h"
+#include "logger.h"
#include "utils/stringutils.h"
@@ -64,6 +64,10 @@ BrowserBox::BrowserBox(unsigned int mode, bool opaque):
{
setFocusable(true);
addMouseListener(this);
+
+ mBackgroundColor = Theme::getThemeColor(Theme::BACKGROUND);
+ mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT);
+ mHyperLinkColor = Theme::getThemeColor(Theme::HYPERLINK);
}
BrowserBox::~BrowserBox()
@@ -310,7 +314,7 @@ void BrowserBox::draw(gcn::Graphics *graphics)
if (mOpaque)
{
- graphics->setColor(Theme::getThemeColor(Theme::BACKGROUND));
+ graphics->setColor(mBackgroundColor);
graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight()));
}
@@ -319,7 +323,7 @@ void BrowserBox::draw(gcn::Graphics *graphics)
{
if ((mHighMode & BACKGROUND))
{
- graphics->setColor(Theme::getThemeColor(Theme::HIGHLIGHT));
+ graphics->setColor(mHighlightColor);
graphics->fillRectangle(gcn::Rectangle(
mLinks[mSelectedLink].x1,
mLinks[mSelectedLink].y1,
@@ -330,7 +334,7 @@ void BrowserBox::draw(gcn::Graphics *graphics)
if ((mHighMode & UNDERLINE))
{
- graphics->setColor(Theme::getThemeColor(Theme::HYPERLINK));
+ graphics->setColor(mHyperLinkColor);
graphics->drawLine(
mLinks[mSelectedLink].x1,
mLinks[mSelectedLink].y2,
diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h
index 6fdb40042..9969bfd3b 100644
--- a/src/gui/widgets/browserbox.h
+++ b/src/gui/widgets/browserbox.h
@@ -225,6 +225,10 @@ class BrowserBox : public gcn::Widget,
bool mAlwaysUpdate;
bool mProcessVersion;
bool mEnableImages;
+
+ gcn::Color mBackgroundColor;
+ gcn::Color mHighlightColor;
+ gcn::Color mHyperLinkColor;
};
#endif
diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp
index 0570630c3..7c46ae9df 100644
--- a/src/gui/widgets/button.cpp
+++ b/src/gui/widgets/button.cpp
@@ -26,7 +26,7 @@
#include "configuration.h"
#include "graphics.h"
#include "graphicsvertexes.h"
-#include "log.h"
+#include "logger.h"
#include "gui/palette.h"
#include "gui/theme.h"
@@ -135,6 +135,9 @@ void Button::init()
}
updateAlpha();
}
+ mEnabledColor = Theme::getThemeColor(Theme::BUTTON);
+ mDisabledColor = Theme::getThemeColor(Theme::BUTTON_DISABLED);
+
mInstances++;
}
@@ -202,7 +205,7 @@ void Button::draw(gcn::Graphics *graphics)
}
else
{
- // because we dont know where parent windows was moved,
+ // because we don't know where parent windows was moved,
// need recalc vertexes
gcn::ClipRectangle &rect = static_cast<Graphics*>(
graphics)->getTopClip();
@@ -238,9 +241,9 @@ void Button::draw(gcn::Graphics *graphics)
// drawImageRect(0, 0, getWidth(), getHeight(), button[mode]);
if (mode == BUTTON_DISABLED)
- graphics->setColor(Theme::getThemeColor(Theme::BUTTON_DISABLED));
+ graphics->setColor(mDisabledColor);
else
- graphics->setColor(Theme::getThemeColor(Theme::BUTTON));
+ graphics->setColor(mEnabledColor);
int textX;
int textY = getHeight() / 2 - getFont()->getHeight() / 2;
diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h
index 8c43b6ddd..1b62179b3 100644
--- a/src/gui/widgets/button.h
+++ b/src/gui/widgets/button.h
@@ -101,6 +101,8 @@ class Button : public gcn::Button, public gcn::WidgetListener
int mMode;
int mXOffset;
int mYOffset;
+ gcn::Color mEnabledColor;
+ gcn::Color mDisabledColor;
};
#endif
diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp
index 42a39a20f..81c0d277f 100644
--- a/src/gui/widgets/chattab.cpp
+++ b/src/gui/widgets/chattab.cpp
@@ -23,11 +23,11 @@
#include "gui/widgets/chattab.h"
#include "actorspritemanager.h"
-#include "chatlog.h"
+#include "chatlogger.h"
#include "commandhandler.h"
#include "configuration.h"
#include "localplayer.h"
-#include "log.h"
+#include "logger.h"
#include "sound.h"
#include "gui/widgets/browserbox.h"
@@ -249,12 +249,13 @@ void ChatTab::chatLog(std::string line, Own own,
// We look if the Vertical Scroll Bar is set at the max before
// adding a row, otherwise the max will always be a row higher
// at comparison.
- if (mScrollArea->getVerticalScrollAmount() >=
+ if (mScrollArea->getVerticalScrollAmount() + 2 >=
mScrollArea->getVerticalMaxScroll())
{
addRow(line);
mScrollArea->setVerticalScrollAmount(
mScrollArea->getVerticalMaxScroll());
+
}
else
{
@@ -282,9 +283,7 @@ void ChatTab::chatLog(std::string line, Own own,
{
if (player_node)
{
- std::string::size_type pos
- = tmp.text.find(player_node->getName());
- if (pos != std::string::npos)
+ if (chatWindow && chatWindow->findHighlight(tmp.text))
setFlash(2);
else
setFlash(1);
diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp
index 61e5d9118..65d26e196 100644
--- a/src/gui/widgets/checkbox.cpp
+++ b/src/gui/widgets/checkbox.cpp
@@ -86,6 +86,8 @@ CheckBox::CheckBox(const std::string &caption, bool selected,
if (listener)
addActionListener(listener);
+
+ setForegroundColor(Theme::getThemeColor(Theme::TEXT));
}
CheckBox::~CheckBox()
@@ -114,7 +116,7 @@ void CheckBox::draw(gcn::Graphics* graphics)
drawBox(graphics);
graphics->setFont(getFont());
- graphics->setColor(Theme::getThemeColor(Theme::TEXT));
+ graphics->setColor(getForegroundColor());
const int h = getHeight() + getHeight() / 2;
diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp
index 3ade3b37f..46240f76d 100644
--- a/src/gui/widgets/desktop.cpp
+++ b/src/gui/widgets/desktop.cpp
@@ -22,7 +22,7 @@
#include "configuration.h"
#include "graphics.h"
-#include "log.h"
+#include "logger.h"
#include "main.h"
#include "gui/palette.h"
@@ -53,8 +53,12 @@ Desktop::Desktop() :
mVersionLabel = new Label(strprintf("%s (Mana %s)", appName.c_str(),
FULL_VERSION));
- mVersionLabel->setBackgroundColor(gcn::Color(255, 255, 255, 128));
+ mVersionLabel->setBackgroundColor(
+ Theme::getThemeColor(Theme::BACKGROUND, 128));
add(mVersionLabel, 25, 2);
+
+ mBackgroundColor = Theme::getThemeColor(Theme::BACKGROUND, 128);
+ mBackgroundGrayColor = Theme::getThemeColor(Theme::BACKGROUND_GRAY);
}
Desktop::~Desktop()
@@ -84,8 +88,7 @@ void Desktop::draw(gcn::Graphics *graphics)
if (!mWallpaper || (getWidth() > mWallpaper->getWidth() ||
getHeight() > mWallpaper->getHeight()))
{
- // TODO: Color from palette
- g->setColor(gcn::Color(64, 64, 64));
+ g->setColor(mBackgroundGrayColor);
g->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight()));
}
@@ -106,7 +109,7 @@ void Desktop::draw(gcn::Graphics *graphics)
}
// Draw a thin border under the application version...
- g->setColor(gcn::Color(255, 255, 255, 128));
+ g->setColor(mBackgroundColor);
g->fillRectangle(gcn::Rectangle(mVersionLabel->getDimension()));
Container::draw(graphics);
diff --git a/src/gui/widgets/desktop.h b/src/gui/widgets/desktop.h
index 962cc3c01..6364ecfe9 100644
--- a/src/gui/widgets/desktop.h
+++ b/src/gui/widgets/desktop.h
@@ -68,6 +68,8 @@ class Desktop : public Container, gcn::WidgetListener
Image *mWallpaper;
gcn::Label *mVersionLabel;
+ gcn::Color mBackgroundColor;
+ gcn::Color mBackgroundGrayColor;
};
#endif // DESKTOP_H
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index 681d7736e..f01d3fb55 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -101,6 +101,10 @@ DropDown::DropDown(gcn::ListModel *listModel):
}
instances++;
+
+ mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT);
+ mShadowColor = Theme::getThemeColor(Theme::DROPDOWN_SHADOW);
+ setForegroundColor(Theme::getThemeColor(Theme::TEXT));
}
DropDown::~DropDown()
@@ -163,25 +167,20 @@ void DropDown::draw(gcn::Graphics* graphics)
updateAlpha();
const int alpha = static_cast<int>(mAlpha * 255.0f);
- gcn::Color faceColor = getBaseColor();
- faceColor.a = alpha;
- const gcn::Color *highlightColor = &Theme::getThemeColor(Theme::HIGHLIGHT,
- alpha);
- gcn::Color shadowColor = faceColor - 0x303030;
- shadowColor.a = alpha;
+ mHighlightColor.a = alpha;
+ mShadowColor.a = alpha;
if (mListBox->getListModel() && mListBox->getSelected() >= 0)
{
graphics->setFont(getFont());
- graphics->setColor(Theme::getThemeColor(Theme::TEXT));
+ graphics->setColor(getForegroundColor());
graphics->drawText(mListBox->getListModel()->getElementAt(
mListBox->getSelected()), 1, 0);
}
if (isFocused())
{
- if (highlightColor)
- graphics->setColor(*highlightColor);
+ graphics->setColor(mHighlightColor);
graphics->drawRectangle(gcn::Rectangle(0, 0, getWidth() - h, h));
}
@@ -193,10 +192,9 @@ void DropDown::draw(gcn::Graphics* graphics)
// Draw two lines separating the ListBox with selected
// element view.
- if (highlightColor)
- graphics->setColor(*highlightColor);
+ graphics->setColor(mHighlightColor);
graphics->drawLine(0, h, getWidth(), h);
- graphics->setColor(shadowColor);
+ graphics->setColor(mShadowColor);
graphics->drawLine(0, h + 1, getWidth(), h + 1);
}
}
diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h
index d85c3166c..6a22ba497 100644
--- a/src/gui/widgets/dropdown.h
+++ b/src/gui/widgets/dropdown.h
@@ -87,6 +87,9 @@ class DropDown : public gcn::DropDown
*/
void drawButton(gcn::Graphics *graphics);
+ gcn::Color mShadowColor;
+ gcn::Color mHighlightColor;
+
// Add own Images.
static int instances;
static Image *buttons[2][2];
diff --git a/src/gui/widgets/dropshortcutcontainer.cpp b/src/gui/widgets/dropshortcutcontainer.cpp
index 257f4837c..b628cf2d4 100644
--- a/src/gui/widgets/dropshortcutcontainer.cpp
+++ b/src/gui/widgets/dropshortcutcontainer.cpp
@@ -1,9 +1,10 @@
/*
- * The Mana World
+ * The ManaPlus Client
* Copyright (C) 2009 The Mana World Development Team
* Copyright (C) 2009-2010 Andrei Karas
+ * Copyright (C) 2011 ManaPlus developers
*
- * This file is part of The Mana World.
+ * This file is part of The ManaPlus Client.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -72,6 +73,8 @@ DropShortcutContainer::DropShortcutContainer():
mBoxHeight = 1;
mBoxWidth = 1;
}
+ mEquipedColor = Theme::getThemeColor(Theme::ITEM_EQUIPPED);
+ mUnEquipedColor = Theme::getThemeColor(Theme::ITEM_NOT_EQUIPPED);
}
DropShortcutContainer::~DropShortcutContainer()
@@ -109,12 +112,6 @@ void DropShortcutContainer::draw(gcn::Graphics *graphics)
if (mBackgroundImg)
g->drawImage(mBackgroundImg, itemX, itemY);
-/* // Draw item keyboard shortcut.
- const char *key = SDL_GetKeyName(
- (SDLKey) keyboard.getKeyValue(keyboard.KEY_SHORTCUT_1 + i));
- graphics->setColor(guiPalette->getColor(Palette::TEXT));
- g->drawText(key, itemX + 2, itemY + 2, gcn::Graphics::LEFT);
-*/
if (dropShortcut->getItem(i) < 0)
continue;
@@ -141,11 +138,11 @@ void DropShortcutContainer::draw(gcn::Graphics *graphics)
image->setAlpha(1.0f);
g->drawImage(image, itemX, itemY);
if (item->isEquipped())
- g->setColor(Theme::getThemeColor(Theme::ITEM_EQUIPPED));
+ g->setColor(mEquipedColor);
else
- g->setColor(Theme::getThemeColor(Theme::TEXT));
+ g->setColor(mUnEquipedColor);
g->drawText(caption, itemX + mBoxWidth / 2,
- itemY + mBoxHeight - 14, gcn::Graphics::CENTER);
+ itemY + mBoxHeight - 14, gcn::Graphics::CENTER);
}
}
}
diff --git a/src/gui/widgets/dropshortcutcontainer.h b/src/gui/widgets/dropshortcutcontainer.h
index 77de914ea..b2d63a7dd 100644
--- a/src/gui/widgets/dropshortcutcontainer.h
+++ b/src/gui/widgets/dropshortcutcontainer.h
@@ -1,9 +1,10 @@
/*
- * The Mana World
+ * The ManaPlus Client
* Copyright (C) 2009 The Mana World Development Team
* Copyright (C) 2009-2010 Andrei Karas
+ * Copyright (C) 2011 ManaPlus developers
*
- * This file is part of The Mana World.
+ * This file is part of The ManaPlus Client.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -83,6 +84,8 @@ class DropShortcutContainer : public ShortcutContainer
Item *mItemMoved;
ItemPopup *mItemPopup;
+ gcn::Color mEquipedColor;
+ gcn::Color mUnEquipedColor;
};
#endif
diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp
index bb5af4b1c..5aced193f 100644
--- a/src/gui/widgets/emoteshortcutcontainer.cpp
+++ b/src/gui/widgets/emoteshortcutcontainer.cpp
@@ -29,7 +29,7 @@
#include "itemshortcut.h"
#include "keyboardconfig.h"
#include "localplayer.h"
-#include "log.h"
+#include "logger.h"
#include "gui/palette.h"
#include "gui/textpopup.h"
@@ -80,6 +80,7 @@ EmoteShortcutContainer::EmoteShortcutContainer():
mBoxHeight = 1;
mBoxWidth = 1;
}
+ setForegroundColor(Theme::getThemeColor(Theme::TEXT));
}
EmoteShortcutContainer::~EmoteShortcutContainer()
@@ -118,20 +119,9 @@ void EmoteShortcutContainer::draw(gcn::Graphics *graphics)
std::string key = keyboard.getKeyValueString(
keyboard.KEY_EMOTE_1 + i);
- graphics->setColor(Theme::getThemeColor(Theme::TEXT));
+ graphics->setColor(getForegroundColor());
g->drawText(key, emoteX + 2, emoteY + 2, gcn::Graphics::LEFT);
-/*
- if (emoteShortcut->getEmote(i)
- && static_cast<unsigned>(emoteShortcut->getEmote(i)) - 1
- < mEmoteImg.size()
- && mEmoteImg[emoteShortcut->getEmote(i) - 1])
- {
- mEmoteImg[emoteShortcut->getEmote(i) - 1]->draw(g, emoteX + 2,
- emoteY + 10);
- }
-*/
-
if (i < mEmoteImg.size() && mEmoteImg[i] && mEmoteImg[i]->sprite)
mEmoteImg[i]->sprite->draw(g, emoteX + 2, emoteY + 10);
}
diff --git a/src/gui/widgets/table.cpp b/src/gui/widgets/guitable.cpp
index 04ae41ad7..e02eda88c 100644
--- a/src/gui/widgets/table.cpp
+++ b/src/gui/widgets/guitable.cpp
@@ -20,7 +20,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "gui/widgets/table.h"
+#include "gui/widgets/guitable.h"
#include "client.h"
#include "configuration.h"
@@ -88,17 +88,17 @@ void GuiTableActionListener::action(const gcn::ActionEvent
}
-GuiTable::GuiTable(TableModel *initial_model, gcn::Color background,
- bool opacity) :
+GuiTable::GuiTable(TableModel *initial_model, bool opacity) :
mLinewiseMode(false),
mWrappingEnabled(false),
mOpaque(opacity),
- mBackgroundColor(background),
mModel(NULL),
mSelectedRow(0),
mSelectedColumn(0),
mTopWidget(NULL)
{
+ mBackgroundColor = Theme::getThemeColor(Theme::BACKGROUND);
+ mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT);
setModel(initial_model);
setFocusable(true);
@@ -292,8 +292,8 @@ void GuiTable::draw(gcn::Graphics* graphics)
if (mOpaque)
{
- graphics->setColor(Theme::getThemeColor(Theme::BACKGROUND,
- static_cast<int>(mAlpha * 255.0f)));
+ mBackgroundColor.a = static_cast<int>(mAlpha * 255.0f);
+ graphics->setColor(mBackgroundColor);
graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight()));
}
@@ -304,7 +304,7 @@ void GuiTable::draw(gcn::Graphics* graphics)
first_row = 0;
unsigned rows_nr = 1 + (getHeight() / getRowHeight()); // May overestimate
- // by one.
+ // by one.
unsigned max_rows_nr;
if (mModel->getRows() < first_row)
@@ -343,8 +343,8 @@ void GuiTable::draw(gcn::Graphics* graphics)
widget->setDimension(bounds);
- graphics->setColor(Theme::getThemeColor(Theme::HIGHLIGHT,
- static_cast<int>(mAlpha * 255.0f)));
+ mHighlightColor.a = static_cast<int>(mAlpha * 255.0f);
+ graphics->setColor(mHighlightColor);
if (mSelectedRow > 0)
{
diff --git a/src/gui/widgets/table.h b/src/gui/widgets/guitable.h
index c4fab6a0d..d248c4820 100644
--- a/src/gui/widgets/table.h
+++ b/src/gui/widgets/guitable.h
@@ -58,7 +58,6 @@ class GuiTable : public gcn::Widget,
public:
GuiTable(TableModel * initial_model = NULL,
- gcn::Color background = 0xffffff,
bool opacity = true);
virtual ~GuiTable();
@@ -190,6 +189,8 @@ private:
/** Vector for compactness; used as a list in practice. */
std::vector<GuiTableActionListener *> mActionListeners;
+
+ gcn::Color mHighlightColor;
};
diff --git a/src/gui/widgets/horizontcontainer.h b/src/gui/widgets/horizontcontainer.h
index 4a959190e..80014c171 100644
--- a/src/gui/widgets/horizontcontainer.h
+++ b/src/gui/widgets/horizontcontainer.h
@@ -41,8 +41,11 @@ class HorizontContainer : public Container, public gcn::WidgetListener
{
public:
HorizontContainer(int height, int spacing);
+
virtual void add(gcn::Widget *widget);
+
virtual void clear();
+
void widgetResized(const gcn::Event &event);
protected:
diff --git a/src/gui/widgets/inventoryfilter.cpp b/src/gui/widgets/inventoryfilter.cpp
index a220fdb98..795f0d31e 100644
--- a/src/gui/widgets/inventoryfilter.cpp
+++ b/src/gui/widgets/inventoryfilter.cpp
@@ -1,8 +1,8 @@
/*
- * The Mana Client
+ * The ManaPlus Client
* Copyright (C) 2011 The ManaPlus Developers
*
- * This file is part of The Mana Client.
+ * This file is part of The ManaPlus Client.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -23,7 +23,7 @@
#include "gui/widgets/horizontcontainer.h"
#include "gui/widgets/radiobutton.h"
-#include "log.h"
+#include "logger.h"
#include "debug.h"
diff --git a/src/gui/widgets/inventoryfilter.h b/src/gui/widgets/inventoryfilter.h
index da7b7af1e..be69489a8 100644
--- a/src/gui/widgets/inventoryfilter.h
+++ b/src/gui/widgets/inventoryfilter.h
@@ -1,9 +1,9 @@
/*
- * The Mana Client
+ * The ManaPlus Client
* Copyright (C) 2009-2010 The Mana Developers
* Copyright (C) 2011 The ManaPlus Developers
*
- * This file is part of The Mana Client.
+ * This file is part of The ManaPlus Client.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index 7818432f8..91b674018 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -27,7 +27,7 @@
#include "item.h"
#include "itemshortcut.h"
#include "dropshortcut.h"
-#include "log.h"
+#include "logger.h"
#include "gui/chatwindow.h"
#include "gui/itempopup.h"
@@ -118,6 +118,9 @@ ItemContainer::ItemContainer(Inventory *inventory, bool forceQuantity):
if (!mSelImg)
logger->log1("Error: Unable to load selection.png");
+ mEquipedColor = Theme::getThemeColor(Theme::ITEM_EQUIPPED);
+ mUnEquipedColor = Theme::getThemeColor(Theme::ITEM_NOT_EQUIPPED);
+
addKeyListener(this);
addMouseListener(this);
addWidgetListener(this);
@@ -204,15 +207,16 @@ void ItemContainer::draw(gcn::Graphics *graphics)
caption = "Eq.";
if (item->isEquipped())
- g->setColor(Theme::getThemeColor(Theme::ITEM_EQUIPPED));
+ g->setColor(mEquipedColor);
else
- g->setColor(gcn::Color(0, 0, 0));
+ g->setColor(mUnEquipedColor);
g->drawText(caption, itemX + BOX_WIDTH / 2,
itemY + BOX_HEIGHT - 14, gcn::Graphics::CENTER);
}
}
+/*
// Draw an orange box around the selected item
if (isFocused() && mHighlightedIndex != -1 && mGridColumns)
{
@@ -221,6 +225,7 @@ void ItemContainer::draw(gcn::Graphics *graphics)
g->setColor(gcn::Color(255, 128, 0));
g->drawRectangle(gcn::Rectangle(itemX, itemY, BOX_WIDTH, BOX_HEIGHT));
}
+*/
}
void ItemContainer::selectNone()
diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h
index 5fd897a29..df7de63ee 100644
--- a/src/gui/widgets/itemcontainer.h
+++ b/src/gui/widgets/itemcontainer.h
@@ -202,6 +202,8 @@ class ItemContainer : public gcn::Widget,
typedef SelectionListenerList::iterator SelectionListenerIterator;
SelectionListenerList mSelectionListeners;
+ gcn::Color mEquipedColor;
+ gcn::Color mUnEquipedColor;
};
#endif
diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp
index 328d5ae4d..79685fe45 100644
--- a/src/gui/widgets/itemshortcutcontainer.cpp
+++ b/src/gui/widgets/itemshortcutcontainer.cpp
@@ -77,6 +77,9 @@ ItemShortcutContainer::ItemShortcutContainer(unsigned number):
mBoxHeight = 1;
mBoxWidth = 1;
}
+ setForegroundColor(Theme::getThemeColor(Theme::TEXT));
+ mEquipedColor = Theme::getThemeColor(Theme::ITEM_EQUIPPED);
+ mUnEquipedColor = Theme::getThemeColor(Theme::ITEM_NOT_EQUIPPED);
}
ItemShortcutContainer::~ItemShortcutContainer()
@@ -119,7 +122,7 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics)
// Draw item keyboard shortcut.
std::string key = keyboard.getKeyValueString(
keyboard.KEY_SHORTCUT_1 + i);
- graphics->setColor(Theme::getThemeColor(Theme::TEXT));
+ graphics->setColor(getForegroundColor());
g->drawText(key, itemX + 2, itemY + 2, gcn::Graphics::LEFT);
@@ -154,14 +157,9 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics)
image->setAlpha(1.0f);
g->drawImage(image, itemX, itemY);
if (item->isEquipped())
- {
- g->setColor(Theme::getThemeColor(
- Theme::ITEM_EQUIPPED));
- }
+ g->setColor(mEquipedColor);
else
- {
- graphics->setColor(Theme::getThemeColor(Theme::TEXT));
- }
+ g->setColor(mUnEquipedColor);
g->drawText(caption, itemX + mBoxWidth / 2,
itemY + mBoxHeight - 14, gcn::Graphics::CENTER);
}
diff --git a/src/gui/widgets/itemshortcutcontainer.h b/src/gui/widgets/itemshortcutcontainer.h
index 7eac431ec..e6b32c6f8 100644
--- a/src/gui/widgets/itemshortcutcontainer.h
+++ b/src/gui/widgets/itemshortcutcontainer.h
@@ -88,7 +88,8 @@ class ItemShortcutContainer : public ShortcutContainer
ItemPopup *mItemPopup;
SpellPopup *mSpellPopup;
+ gcn::Color mEquipedColor;
+ gcn::Color mUnEquipedColor;
};
-//extern SpellManager *spellManager;
#endif
diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp
index 16b813dd5..67e8bd12b 100644
--- a/src/gui/widgets/label.cpp
+++ b/src/gui/widgets/label.cpp
@@ -26,6 +26,7 @@
Label::Label()
{
+ setForegroundColor(Theme::getThemeColor(Theme::TEXT));
}
Label::Label(const std::string &caption) :
diff --git a/src/gui/widgets/layout.cpp b/src/gui/widgets/layout.cpp
index 274c17d61..382d169dc 100644
--- a/src/gui/widgets/layout.cpp
+++ b/src/gui/widgets/layout.cpp
@@ -22,7 +22,7 @@
#include "gui/widgets/layout.h"
-#include "log.h"
+#include "logger.h"
#include <cassert>
diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp
index de8707406..53299ca46 100644
--- a/src/gui/widgets/listbox.cpp
+++ b/src/gui/widgets/listbox.cpp
@@ -41,6 +41,8 @@ float ListBox::mAlpha = 1.0;
ListBox::ListBox(gcn::ListModel *listModel):
gcn::ListBox(listModel)
{
+ mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT);
+ setForegroundColor(Theme::getThemeColor(Theme::TEXT));
}
ListBox::~ListBox()
@@ -63,8 +65,8 @@ void ListBox::draw(gcn::Graphics *graphics)
updateAlpha();
- graphics->setColor(Theme::getThemeColor(Theme::HIGHLIGHT,
- static_cast<int>(mAlpha * 255.0f)));
+ mHighlightColor.a = static_cast<int>(mAlpha * 255.0f);
+ graphics->setColor(mHighlightColor);
graphics->setFont(getFont());
const int height = getRowHeight();
@@ -77,7 +79,7 @@ void ListBox::draw(gcn::Graphics *graphics)
}
// Draw the list elements
- graphics->setColor(Theme::getThemeColor(Theme::TEXT));
+ graphics->setColor(getForegroundColor());
for (int i = 0, y = 0; i < mListModel->getNumberOfElements();
++i, y += height)
{
diff --git a/src/gui/widgets/listbox.h b/src/gui/widgets/listbox.h
index 5f8c20059..418b83f58 100644
--- a/src/gui/widgets/listbox.h
+++ b/src/gui/widgets/listbox.h
@@ -73,6 +73,7 @@ class ListBox : public gcn::ListBox
void mouseDragged(gcn::MouseEvent &event);
protected:
+ gcn::Color mHighlightColor;
static float mAlpha;
};
diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp
index ea51c146a..38088770b 100644
--- a/src/gui/widgets/popup.cpp
+++ b/src/gui/widgets/popup.cpp
@@ -26,7 +26,7 @@
#include "configuration.h"
#include "graphics.h"
#include "graphicsvertexes.h"
-#include "log.h"
+#include "logger.h"
#include "gui/theme.h"
#include "gui/viewport.h"
diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp
index a82ec3e8d..e641be323 100644
--- a/src/gui/widgets/radiobutton.cpp
+++ b/src/gui/widgets/radiobutton.cpp
@@ -46,6 +46,7 @@ RadioButton::RadioButton(const std::string &caption, const std::string &group,
gcn::RadioButton(caption, group, marked),
mHasMouse(false)
{
+ setForegroundColor(Theme::getThemeColor(Theme::TEXT));
if (instances == 0)
{
radioNormal = Theme::getImageFromTheme("radioout.png");
diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp
index df39854da..2796d3ab2 100644
--- a/src/gui/widgets/scrollarea.cpp
+++ b/src/gui/widgets/scrollarea.cpp
@@ -26,7 +26,7 @@
#include "configuration.h"
#include "graphics.h"
#include "graphicsvertexes.h"
-#include "log.h"
+#include "logger.h"
#include "gui/theme.h"
@@ -73,7 +73,6 @@ ScrollArea::ScrollArea(gcn::Widget *widget):
mDrawWidth(0),
mDrawHeight(0)
{
-// addWidgetListener(this);
init();
}
@@ -219,6 +218,9 @@ void ScrollArea::init()
}
instances++;
+
+ mGray = Theme::getThemeColor(Theme::SCROLLBAR_GRAY, 32);
+ mBackground = Theme::getThemeColor(Theme::BACKGROUND);
}
void ScrollArea::logic()
@@ -336,7 +338,7 @@ void ScrollArea::drawFrame(gcn::Graphics *graphics)
}
else
{
- // because we dont know where parent windows was moved,
+ // because we don't know where parent windows was moved,
// need recalc vertexes
gcn::ClipRectangle &rect = static_cast<Graphics*>(
graphics)->getTopClip();
@@ -439,17 +441,17 @@ void ScrollArea::drawRightButton(gcn::Graphics *graphics)
void ScrollArea::drawVBar(gcn::Graphics *graphics)
{
const gcn::Rectangle dim = getVerticalBarDimension();
- graphics->setColor(gcn::Color(0, 0, 0, 32));
+ graphics->setColor(mGray);
graphics->fillRectangle(dim);
- graphics->setColor(gcn::Color(255, 255, 255));
+ graphics->setColor(mBackground);
}
void ScrollArea::drawHBar(gcn::Graphics *graphics)
{
const gcn::Rectangle dim = getHorizontalBarDimension();
- graphics->setColor(gcn::Color(0, 0, 0, 32));
+ graphics->setColor(mGray);
graphics->fillRectangle(dim);
- graphics->setColor(gcn::Color(255, 255, 255));
+ graphics->setColor(mBackground);
}
void ScrollArea::drawVMarker(gcn::Graphics *graphics)
diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h
index 440fcec15..095010f3c 100644
--- a/src/gui/widgets/scrollarea.h
+++ b/src/gui/widgets/scrollarea.h
@@ -156,6 +156,9 @@ class ScrollArea : public gcn::ScrollArea, public gcn::WidgetListener
int mYOffset;
int mDrawWidth;
int mDrawHeight;
+
+ gcn::Color mGray;
+ gcn::Color mBackground;
};
#endif
diff --git a/src/gui/setupitem.cpp b/src/gui/widgets/setupitem.cpp
index 182501e72..698e133dd 100644
--- a/src/gui/setupitem.cpp
+++ b/src/gui/widgets/setupitem.cpp
@@ -18,16 +18,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "gui/setupitem.h"
+#include "gui/widgets/setupitem.h"
#include "configuration.h"
#include "main.h"
-#include "log.h"
+#include "logger.h"
#include "gui/editdialog.h"
#include "gui/widgets/button.h"
#include "gui/widgets/checkbox.h"
+#include "gui/widgets/dropdown.h"
#include "gui/widgets/horizontcontainer.h"
#include "gui/widgets/inttextfield.h"
#include "gui/widgets/label.h"
@@ -330,7 +331,6 @@ void SetupItemTextField::apply(std::string eventName)
save();
}
-
SetupItemIntTextField::SetupItemIntTextField(std::string text,
std::string description,
std::string keyName,
@@ -454,6 +454,8 @@ void SetupItemIntTextField::apply(std::string eventName)
save();
}
+
+
SetupItemLabel::SetupItemLabel(std::string text, std::string description,
SetupTabScroll *parent, bool separator) :
SetupItem(text, description, "", parent, "", "", true),
@@ -505,3 +507,85 @@ void SetupItemLabel::action(const gcn::ActionEvent &event A_UNUSED)
void SetupItemLabel::apply(std::string eventName A_UNUSED)
{
}
+
+
+SetupItemDropDown::SetupItemDropDown(std::string text,
+ std::string description,
+ std::string keyName,
+ SetupTabScroll *parent,
+ std::string eventName,
+ gcn::ListModel *model,
+ bool mainConfig) :
+ SetupItem(text, description, keyName, parent, eventName, mainConfig),
+ mHorizont(0),
+ mLabel(0),
+ mModel(model),
+ mDropDown(0)
+{
+ mValueType = VSTR;
+ createControls();
+}
+
+SetupItemDropDown::SetupItemDropDown(std::string text,
+ std::string description,
+ std::string keyName,
+ SetupTabScroll *parent,
+ std::string eventName,
+ gcn::ListModel *model,
+ std::string def,
+ bool mainConfig) :
+ SetupItem(text, description, keyName, parent, eventName, def, mainConfig),
+ mHorizont(0),
+ mLabel(0),
+ mModel(model),
+ mDropDown(0)
+{
+ mValueType = VSTR;
+ createControls();
+}
+
+SetupItemDropDown::~SetupItemDropDown()
+{
+ mHorizont = 0;
+ mWidget = 0;
+ mModel = 0;
+ mDropDown = 0;
+ mLabel = 0;
+}
+
+void SetupItemDropDown::createControls()
+{
+ load();
+ mHorizont = new HorizontContainer(32, 2);
+
+ mLabel = new Label(mText);
+ mDropDown = new DropDown(mModel);
+ mDropDown->setActionEventId(mEventName);
+ mDropDown->addActionListener(mParent);
+
+ mWidget = mDropDown;
+// mTextField->setWidth(50);
+ mHorizont->add(mLabel);
+ mHorizont->add(mDropDown);
+
+ mParent->getContainer()->add(mHorizont, true, 4);
+ mParent->addControl(this);
+ mParent->addActionListener(this);
+ mWidget->addActionListener(this);
+}
+
+void SetupItemDropDown::fromWidget()
+{
+ if (!mDropDown)
+ return;
+
+ mValue = mDropDown->getSelectedString();
+}
+
+void SetupItemDropDown::toWidget()
+{
+ if (!mDropDown)
+ return;
+
+ mDropDown->setSelectedString(mValue);
+}
diff --git a/src/gui/setupitem.h b/src/gui/widgets/setupitem.h
index 3396edea3..15d2d41ea 100644
--- a/src/gui/setupitem.h
+++ b/src/gui/widgets/setupitem.h
@@ -42,6 +42,7 @@
class CheckBox;
class Configuration;
class ContainerPlacer;
+class DropDown;
class EditDialog;
class HorizontContainer;
class IntTextField;
@@ -241,4 +242,32 @@ class SetupItemLabel : public SetupItem
bool mIsSeparator;
};
+class SetupItemDropDown : public SetupItem
+{
+ public:
+ SetupItemDropDown(std::string text, std::string description,
+ std::string keyName, SetupTabScroll *parent,
+ std::string eventName, gcn::ListModel *model,
+ bool mainConfig = true);
+
+ SetupItemDropDown(std::string text, std::string description,
+ std::string keyName, SetupTabScroll *parent,
+ std::string eventName, gcn::ListModel *model,
+ std::string def, bool mainConfig = true);
+
+ ~SetupItemDropDown();
+
+ void createControls();
+
+ void fromWidget();
+
+ void toWidget();
+
+ protected:
+ HorizontContainer *mHorizont;
+ Label *mLabel;
+ gcn::ListModel *mModel;
+ DropDown *mDropDown;
+};
+
#endif
diff --git a/src/gui/widgets/setuptabscroll.cpp b/src/gui/widgets/setuptabscroll.cpp
index 805c0c8c7..30bb66469 100644
--- a/src/gui/widgets/setuptabscroll.cpp
+++ b/src/gui/widgets/setuptabscroll.cpp
@@ -20,10 +20,9 @@
#include "gui/widgets/setuptabscroll.h"
-#include "gui/setupitem.h"
-
#include "gui/widgets/layouthelper.h"
#include "gui/widgets/scrollarea.h"
+#include "gui/widgets/setupitem.h"
#include "gui/widgets/vertcontainer.h"
#include "debug.h"
diff --git a/src/gui/widgets/shopitems.cpp b/src/gui/widgets/shopitems.cpp
index c5bcd88c4..e15445b77 100644
--- a/src/gui/widgets/shopitems.cpp
+++ b/src/gui/widgets/shopitems.cpp
@@ -43,6 +43,11 @@ int ShopItems::getNumberOfElements()
return static_cast<int>(mShopItems.size());
}
+bool ShopItems::empty()
+{
+ return mShopItems.empty();
+}
+
std::string ShopItems::getElementAt(int i)
{
if (i < 0 || static_cast<unsigned>(i) >= mShopItems.size()
diff --git a/src/gui/widgets/shopitems.h b/src/gui/widgets/shopitems.h
index abfcffb71..29d24cb64 100644
--- a/src/gui/widgets/shopitems.h
+++ b/src/gui/widgets/shopitems.h
@@ -76,6 +76,8 @@ class ShopItems : public gcn::ListModel
*/
int getNumberOfElements();
+ bool empty();
+
/**
* Returns the name of item number i in the shop.
*
diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp
index 2fe28181b..793491808 100644
--- a/src/gui/widgets/shoplistbox.cpp
+++ b/src/gui/widgets/shoplistbox.cpp
@@ -50,9 +50,7 @@ ShopListBox::ShopListBox(gcn::ListModel *listModel):
mShopItems(0)
{
mRowHeight = getFont()->getHeight();
- mPriceCheck = true;
-
- mItemPopup = new ItemPopup;
+ init();
}
ShopListBox::ShopListBox(gcn::ListModel *listModel, ShopItems *shopListModel):
@@ -61,9 +59,17 @@ ShopListBox::ShopListBox(gcn::ListModel *listModel, ShopItems *shopListModel):
mShopItems(shopListModel)
{
mRowHeight = std::max(getFont()->getHeight(), ITEM_ICON_SIZE);
- mPriceCheck = true;
+ init();
+}
+void ShopListBox::init()
+{
+ mPriceCheck = true;
mItemPopup = new ItemPopup;
+ mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT);
+ mBackgroundColor = Theme::getThemeColor(Theme::BACKGROUND);
+ mWarningColor = Theme::getThemeColor(Theme::SHOP_WARNING);
+ setForegroundColor(Theme::getThemeColor(Theme::TEXT));
}
void ShopListBox::setPlayersMoney(int money)
@@ -80,8 +86,7 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics)
mAlpha = Client::getGuiAlpha();
int alpha = static_cast<int>(mAlpha * 255.0f);
- const gcn::Color* highlightColor =
- &Theme::getThemeColor(Theme::HIGHLIGHT, alpha);
+ mHighlightColor.a = alpha;
Graphics *graphics = static_cast<Graphics*>(gcnGraphics);
@@ -93,29 +98,30 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics)
++i, y += mRowHeight)
{
gcn::Color temp;
- const gcn::Color* backgroundColor =
- &Theme::getThemeColor(Theme::BACKGROUND, alpha);
+ gcn::Color* backgroundColor = &mBackgroundColor;
+ mBackgroundColor.a = alpha;
if (mShopItems && mShopItems->at(i) &&
mPlayerMoney < mShopItems->at(i)->getPrice() && mPriceCheck)
{
if (i != mSelected)
{
- backgroundColor = &Theme::getThemeColor(Theme::SHOP_WARNING,
- alpha);
+ backgroundColor = &mWarningColor;
+ backgroundColor->a = alpha;
}
else
{
- temp = Theme::getThemeColor(Theme::SHOP_WARNING, alpha);
- temp.r = (temp.r + highlightColor->r) / 2;
- temp.g = (temp.g + highlightColor->g) / 2;
- temp.b = (temp.g + highlightColor->b) / 2;
+ temp = mWarningColor;
+ temp.r = (temp.r + mHighlightColor.r) / 2;
+ temp.g = (temp.g + mHighlightColor.g) / 2;
+ temp.b = (temp.g + mHighlightColor.b) / 2;
+ temp.a = alpha;
backgroundColor = &temp;
}
}
else if (i == mSelected)
{
- backgroundColor = highlightColor;
+ backgroundColor = &mHighlightColor;
}
graphics->setColor(*backgroundColor);
@@ -130,9 +136,9 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics)
graphics->drawImage(icon, 1, y);
}
}
- graphics->setColor(Theme::getThemeColor(Theme::TEXT));
+ graphics->setColor(getForegroundColor());
graphics->drawText(mListModel->getElementAt(i), ITEM_ICON_SIZE + 5,
- y + (ITEM_ICON_SIZE - getFont()->getHeight()) / 2);
+ y + (ITEM_ICON_SIZE - getFont()->getHeight()) / 2);
}
}
diff --git a/src/gui/widgets/shoplistbox.h b/src/gui/widgets/shoplistbox.h
index 917f46729..38e238f20 100644
--- a/src/gui/widgets/shoplistbox.h
+++ b/src/gui/widgets/shoplistbox.h
@@ -85,6 +85,8 @@ class ShopListBox : public ListBox
void mouseExited(gcn::MouseEvent& mouseEvent A_UNUSED);
private:
+ void init();
+
int mPlayerMoney;
/**
@@ -100,6 +102,10 @@ class ShopListBox : public ListBox
static float mAlpha;
bool mPriceCheck;
+
+ gcn::Color mHighlightColor;
+ gcn::Color mBackgroundColor;
+ gcn::Color mWarningColor;
};
#endif // SHOPLISTBOX_H
diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp
index 0f4814429..8abe727b5 100644
--- a/src/gui/widgets/spellshortcutcontainer.cpp
+++ b/src/gui/widgets/spellshortcutcontainer.cpp
@@ -1,9 +1,10 @@
/*
- * The Mana World
+ * The ManaPlus Client
* Copyright (C) 2009 The Mana World Development Team
* Copyright (C) 2009-2010 Andrei Karas
+ * Copyright (C) 2011 ManaPlus developers
*
- * This file is part of The Mana World.
+ * This file is part of The ManaPlus Client.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -39,7 +40,7 @@
#include "keyboardconfig.h"
#include "localplayer.h"
#include "spellmanager.h"
-#include "log.h"
+#include "logger.h"
#include "resources/image.h"
#include "textcommand.h"
@@ -80,6 +81,7 @@ SpellShortcutContainer::SpellShortcutContainer(unsigned number):
mBoxHeight = 1;
mBoxWidth = 1;
}
+ setForegroundColor(Theme::getThemeColor(Theme::TEXT));
}
SpellShortcutContainer::~SpellShortcutContainer()
@@ -105,11 +107,10 @@ void SpellShortcutContainer::draw(gcn::Graphics *graphics)
Graphics *g = static_cast<Graphics*>(graphics);
- graphics->setColor(gcn::Color(0, 0, 0, 255));
graphics->setFont(getFont());
int selectedId = spellShortcut->getSelectedItem();
- g->setColor(Theme::getThemeColor(Theme::TEXT));
+ g->setColor(getForegroundColor());
for (unsigned i = 0; i < mMaxItems; i++)
{
diff --git a/src/gui/widgets/spellshortcutcontainer.h b/src/gui/widgets/spellshortcutcontainer.h
index 28016cbad..2155e2a8b 100644
--- a/src/gui/widgets/spellshortcutcontainer.h
+++ b/src/gui/widgets/spellshortcutcontainer.h
@@ -1,9 +1,10 @@
/*
- * The Mana World
+ * The ManaPlus Client
* Copyright (C) 2009 The Mana World Development Team
* Copyright (C) 2009-2010 Andrei Karas
+ * Copyright (C) 2011 ManaPlus developers
*
- * This file is part of The Mana World.
+ * This file is part of The ManaPlus Client.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp
index 1b548a6a3..530f1ac82 100644
--- a/src/gui/widgets/tab.cpp
+++ b/src/gui/widgets/tab.cpp
@@ -26,7 +26,7 @@
#include "configuration.h"
#include "graphics.h"
#include "graphicsvertexes.h"
-#include "log.h"
+#include "logger.h"
#include "gui/palette.h"
#include "gui/theme.h"
@@ -77,6 +77,8 @@ Tab::Tab() : gcn::Tab(),
mMode(0)
{
init();
+ mFlashColor = Theme::getThemeColor(Theme::TAB_FLASH);
+ mPlayerFlashColor = Theme::getThemeColor(Theme::TAB_PLAYER_FLASH);
}
Tab::~Tab()
@@ -177,12 +179,10 @@ void Tab::draw(gcn::Graphics *graphics)
switch (mFlash)
{
case 1:
- mLabel->setForegroundColor(Theme::getThemeColor(
- Theme::TAB_FLASH));
+ mLabel->setForegroundColor(mFlashColor);
break;
case 2:
- mLabel->setForegroundColor(Theme::getThemeColor(
- Theme::TAB_PLAYER_FLASH));
+ mLabel->setForegroundColor(mPlayerFlashColor);
break;
default:
break;
diff --git a/src/gui/widgets/tab.h b/src/gui/widgets/tab.h
index 5847bd505..ba51e6c74 100644
--- a/src/gui/widgets/tab.h
+++ b/src/gui/widgets/tab.h
@@ -91,6 +91,8 @@ class Tab : public gcn::Tab, public gcn::WidgetListener
GraphicsVertexes *mVertexes;
bool mRedraw;
int mMode;
+ gcn::Color mFlashColor;
+ gcn::Color mPlayerFlashColor;
};
#endif
diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp
index d3539a115..940dad12a 100644
--- a/src/gui/widgets/tabbedarea.cpp
+++ b/src/gui/widgets/tabbedarea.cpp
@@ -25,7 +25,7 @@
#include "gui/widgets/scrollarea.h"
#include "gui/widgets/tab.h"
-#include "log.h"
+#include "logger.h"
#include <guichan/widgets/container.hpp>
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index d3108a77f..2729e5407 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -25,7 +25,7 @@
#include "client.h"
#include "configuration.h"
#include "graphics.h"
-#include "log.h"
+#include "logger.h"
#include "gui/palette.h"
#include "gui/sdlinput.h"
@@ -59,6 +59,8 @@ TextField::TextField(const std::string &text, bool loseFocusOnTab,
mLoseFocusOnTab = loseFocusOnTab;
+ setForegroundColor(Theme::getThemeColor(Theme::TEXT));
+
if (instances == 0)
{
// Load the skin
@@ -136,7 +138,7 @@ void TextField::draw(gcn::Graphics *graphics)
mXScroll);
}
- graphics->setColor(Theme::getThemeColor(Theme::TEXT));
+ graphics->setColor(getForegroundColor());
graphics->setFont(getFont());
graphics->drawText(mText, 1 - mXScroll, 1);
}
diff --git a/src/gui/widgets/tradetab.cpp b/src/gui/widgets/tradetab.cpp
index 99a145d86..deec2aea6 100644
--- a/src/gui/widgets/tradetab.cpp
+++ b/src/gui/widgets/tradetab.cpp
@@ -22,10 +22,10 @@
#include "gui/widgets/tradetab.h"
-#include "chatlog.h"
+#include "chatlogger.h"
#include "commandhandler.h"
#include "localplayer.h"
-#include "log.h"
+#include "logger.h"
#include "gui/theme.h"
diff --git a/src/gui/widgets/vertcontainer.cpp b/src/gui/widgets/vertcontainer.cpp
index d65274f20..ea6b4d520 100644
--- a/src/gui/widgets/vertcontainer.cpp
+++ b/src/gui/widgets/vertcontainer.cpp
@@ -49,7 +49,7 @@ void VertContainer::add(gcn::Widget *widget, bool resizable, int spacing)
widget->setPosition(mLeftSpacing, mNextY);
if (resizable)
{
- widget->setSize(getWidth() - mLeftSpacing, mVerticalItemSize);
+ widget->setSize(getWidth() - mLeftSpacing, mVerticalItemSize * 5);
mResizableWidgets.push_back(widget);
}
else if (widget->getHeight() > mVerticalItemSize)
diff --git a/src/gui/widgets/whispertab.cpp b/src/gui/widgets/whispertab.cpp
index bee30b969..c99c4e0c5 100644
--- a/src/gui/widgets/whispertab.cpp
+++ b/src/gui/widgets/whispertab.cpp
@@ -22,10 +22,10 @@
#include "gui/widgets/whispertab.h"
-#include "chatlog.h"
+#include "chatlogger.h"
#include "commandhandler.h"
#include "localplayer.h"
-#include "log.h"
+#include "logger.h"
#include "gui/theme.h"
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index 14448ea86..cdb9d3d55 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -25,7 +25,7 @@
#include "client.h"
#include "configuration.h"
#include "graphicsvertexes.h"
-#include "log.h"
+#include "logger.h"
#include "gui/gui.h"
#include "gui/palette.h"
@@ -95,6 +95,7 @@ Window::Window(const std::string &caption, bool modal, Window *parent,
addWidgetListener(this);
mCaptionFont = getFont();
+ setForegroundColor(Theme::getThemeColor(Theme::TEXT));
}
Window::~Window()
@@ -146,15 +147,10 @@ void Window::draw(gcn::Graphics *graphics)
g->drawImageRect2(mVertexes, mSkin->getBorder());
-/*
- g->drawImageRect(0, 0, getWidth(),
- getHeight(), mSkin->getBorder());
-*/
-
// Draw title
if (mShowTitle)
{
- g->setColor(Theme::getThemeColor(Theme::TEXT));
+ g->setColor(getForegroundColor());
g->setFont(mCaptionFont);
g->drawText(getCaption(), 7, 5, gcn::Graphics::LEFT);
}