summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/beingpopup.cpp12
-rw-r--r--src/gui/beingpopup.h4
-rw-r--r--src/gui/buy.cpp13
-rw-r--r--src/gui/buy.h5
-rw-r--r--src/gui/buysell.cpp7
-rw-r--r--src/gui/buysell.h5
-rw-r--r--src/gui/changeemaildialog.h2
-rw-r--r--src/gui/changepassworddialog.h2
-rw-r--r--src/gui/charcreatedialog.cpp9
-rw-r--r--src/gui/charcreatedialog.h8
-rw-r--r--src/gui/charselectdialog.cpp24
-rw-r--r--src/gui/charselectdialog.h4
-rw-r--r--src/gui/chat.cpp65
-rw-r--r--src/gui/chat.h25
-rw-r--r--src/gui/emotepopup.cpp9
-rw-r--r--src/gui/emotepopup.h4
-rw-r--r--src/gui/equipmentwindow.cpp4
-rw-r--r--src/gui/equipmentwindow.h1
-rw-r--r--src/gui/gui.cpp25
-rw-r--r--src/gui/help.cpp4
-rw-r--r--src/gui/inventorywindow.cpp100
-rw-r--r--src/gui/inventorywindow.h23
-rw-r--r--src/gui/itemamount.cpp26
-rw-r--r--src/gui/itempopup.cpp29
-rw-r--r--src/gui/minimap.cpp71
-rw-r--r--src/gui/ministatus.cpp148
-rw-r--r--src/gui/ministatus.h21
-rw-r--r--src/gui/npcdialog.cpp192
-rw-r--r--src/gui/npcdialog.h24
-rw-r--r--src/gui/npcpostdialog.cpp13
-rw-r--r--src/gui/npcpostdialog.h5
-rw-r--r--src/gui/outfitwindow.cpp23
-rw-r--r--src/gui/popupmenu.cpp75
-rw-r--r--src/gui/quitdialog.h2
-rw-r--r--src/gui/recorder.cpp12
-rw-r--r--src/gui/register.h2
-rw-r--r--src/gui/sell.cpp12
-rw-r--r--src/gui/sell.h5
-rw-r--r--src/gui/serverdialog.cpp72
-rw-r--r--src/gui/serverdialog.h5
-rw-r--r--src/gui/setup.h2
-rw-r--r--src/gui/setup_audio.cpp14
-rw-r--r--src/gui/setup_colors.cpp5
-rw-r--r--src/gui/setup_joystick.cpp2
-rw-r--r--src/gui/setup_players.cpp39
-rw-r--r--src/gui/setup_players.h3
-rw-r--r--src/gui/setup_video.cpp73
-rw-r--r--src/gui/skilldialog.cpp20
-rw-r--r--src/gui/skilldialog.h6
-rw-r--r--src/gui/socialwindow.cpp73
-rw-r--r--src/gui/specialswindow.cpp179
-rw-r--r--src/gui/specialswindow.h20
-rw-r--r--src/gui/speechbubble.cpp6
-rw-r--r--src/gui/speechbubble.h4
-rw-r--r--src/gui/statuswindow.cpp294
-rw-r--r--src/gui/statuswindow.h15
-rw-r--r--src/gui/textdialog.cpp4
-rw-r--r--src/gui/textpopup.cpp6
-rw-r--r--src/gui/theme.cpp578
-rw-r--r--src/gui/theme.h252
-rw-r--r--src/gui/trade.cpp31
-rw-r--r--src/gui/trade.h2
-rw-r--r--src/gui/unregisterdialog.h2
-rw-r--r--src/gui/updatewindow.cpp2
-rw-r--r--src/gui/userpalette.cpp247
-rw-r--r--src/gui/userpalette.h210
-rw-r--r--src/gui/viewport.cpp124
-rw-r--r--src/gui/viewport.h17
-rw-r--r--src/gui/widgets/avatarlistbox.cpp2
-rw-r--r--src/gui/widgets/browserbox.cpp4
-rw-r--r--src/gui/widgets/button.cpp6
-rw-r--r--src/gui/widgets/chattab.cpp20
-rw-r--r--src/gui/widgets/chattab.h18
-rw-r--r--src/gui/widgets/checkbox.cpp6
-rw-r--r--src/gui/widgets/dropdown.cpp6
-rw-r--r--src/gui/widgets/emoteshortcutcontainer.cpp14
-rw-r--r--src/gui/widgets/emoteshortcutcontainer.h5
-rw-r--r--src/gui/widgets/itemcontainer.cpp27
-rw-r--r--src/gui/widgets/itemlinkhandler.cpp2
-rw-r--r--src/gui/widgets/itemshortcutcontainer.cpp18
-rw-r--r--src/gui/widgets/label.cpp5
-rw-r--r--src/gui/widgets/listbox.cpp7
-rw-r--r--src/gui/widgets/playerbox.cpp25
-rw-r--r--src/gui/widgets/playerbox.h9
-rw-r--r--src/gui/widgets/popup.cpp2
-rw-r--r--src/gui/widgets/progressbar.cpp6
-rw-r--r--src/gui/widgets/progressindicator.cpp3
-rw-r--r--src/gui/widgets/radiobutton.cpp7
-rw-r--r--src/gui/widgets/resizegrip.cpp7
-rw-r--r--src/gui/widgets/scrollarea.cpp13
-rw-r--r--src/gui/widgets/shoplistbox.cpp6
-rw-r--r--src/gui/widgets/slider.cpp7
-rw-r--r--src/gui/widgets/tab.cpp6
-rw-r--r--src/gui/widgets/table.cpp7
-rw-r--r--src/gui/widgets/textbox.cpp2
-rw-r--r--src/gui/widgets/textfield.cpp9
-rw-r--r--src/gui/widgets/textpreview.cpp4
-rw-r--r--src/gui/widgets/whispertab.cpp11
-rw-r--r--src/gui/widgets/whispertab.h2
-rw-r--r--src/gui/widgets/window.cpp6
-rw-r--r--src/gui/windowmenu.cpp2
-rw-r--r--src/gui/worldselectdialog.cpp10
-rw-r--r--src/gui/worldselectdialog.h2
103 files changed, 1326 insertions, 2282 deletions
diff --git a/src/gui/beingpopup.cpp b/src/gui/beingpopup.cpp
index 2150f7e5..ae0b43fd 100644
--- a/src/gui/beingpopup.cpp
+++ b/src/gui/beingpopup.cpp
@@ -20,8 +20,8 @@
#include "gui/beingpopup.h"
+#include "being.h"
#include "graphics.h"
-#include "player.h"
#include "units.h"
#include "gui/gui.h"
@@ -57,24 +57,24 @@ BeingPopup::~BeingPopup()
{
}
-void BeingPopup::show(int x, int y, Player *p)
+void BeingPopup::show(int x, int y, Being *b)
{
- if (!p)
+ if (!b)
{
setVisible(false);
return;
}
- mBeingName->setCaption(p->getName());
+ mBeingName->setCaption(b->getName());
mBeingName->adjustSize();
int minWidth = mBeingName->getWidth();
const int height = getFont()->getHeight();
- if (!(p->getPartyName().empty()))
+ if (!(b->getPartyName().empty()))
{
mBeingParty->setCaption(strprintf(_("Party: %s"),
- p->getPartyName().c_str()));
+ b->getPartyName().c_str()));
mBeingParty->adjustSize();
if (minWidth < mBeingParty->getWidth())
diff --git a/src/gui/beingpopup.h b/src/gui/beingpopup.h
index f397e374..514a6e7e 100644
--- a/src/gui/beingpopup.h
+++ b/src/gui/beingpopup.h
@@ -23,8 +23,8 @@
#include "gui/widgets/popup.h"
+class Being;
class Label;
-class Player;
/**
* A popup that displays information about a being.
@@ -45,7 +45,7 @@ class BeingPopup : public Popup
/**
* Sets the info to be displayed given a particular player.
*/
- void show(int x, int y, Player *p);
+ void show(int x, int y, Being *b);
// TODO: Add a version for monsters, NPCs, etc?
diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp
index 031c53dd..cc135e07 100644
--- a/src/gui/buy.cpp
+++ b/src/gui/buy.cpp
@@ -21,6 +21,10 @@
#include "gui/buy.h"
+#include "playerinfo.h"
+#include "shopitem.h"
+#include "units.h"
+
#include "gui/setup.h"
#include "gui/widgets/button.h"
@@ -31,10 +35,6 @@
#include "gui/widgets/shoplistbox.h"
#include "gui/widgets/slider.h"
-#include "npc.h"
-#include "shopitem.h"
-#include "units.h"
-
#include "net/net.h"
#include "net/npchandler.h"
@@ -112,6 +112,8 @@ BuyDialog::BuyDialog(int npcId):
instances.push_back(this);
setVisible(true);
+
+ PlayerInfo::setBuySellState(BUYSELL_BUYING);
}
BuyDialog::~BuyDialog()
@@ -119,6 +121,9 @@ BuyDialog::~BuyDialog()
delete mShopItems;
instances.remove(this);
+
+ if (PlayerInfo::getBuySellState() == BUYSELL_BUYING)
+ PlayerInfo::setBuySellState(BUYSELL_NONE);
}
void BuyDialog::setMoney(int amount)
diff --git a/src/gui/buy.h b/src/gui/buy.h
index 4b273bcc..c3cb3229 100644
--- a/src/gui/buy.h
+++ b/src/gui/buy.h
@@ -100,11 +100,6 @@ class BuyDialog : public Window, public gcn::ActionListener,
void setVisible(bool visible);
/**
- * Returns true if any instances exist.
- */
- static bool isActive() { return instances.size() > 0; }
-
- /**
* Closes all instances.
*/
static void closeAll();
diff --git a/src/gui/buysell.cpp b/src/gui/buysell.cpp
index c6b4ef41..4419ffcc 100644
--- a/src/gui/buysell.cpp
+++ b/src/gui/buysell.cpp
@@ -21,7 +21,7 @@
#include "buysell.h"
-#include "npc.h"
+#include "playerinfo.h"
#include "gui/setup.h"
@@ -67,11 +67,16 @@ BuySellDialog::BuySellDialog(int npcId):
instances.push_back(this);
setVisible(true);
+
+ PlayerInfo::setBuySellState(BUYSELL_CHOOSING);
}
BuySellDialog::~BuySellDialog()
{
instances.remove(this);
+
+ if (PlayerInfo::getBuySellState() == BUYSELL_CHOOSING)
+ PlayerInfo::setBuySellState(BUYSELL_NONE);
}
void BuySellDialog::setVisible(bool visible)
diff --git a/src/gui/buysell.h b/src/gui/buysell.h
index cf7ec91e..3408821a 100644
--- a/src/gui/buysell.h
+++ b/src/gui/buysell.h
@@ -52,11 +52,6 @@ class BuySellDialog : public Window, public gcn::ActionListener
void action(const gcn::ActionEvent &event);
/**
- * Returns true if any instances exist.
- */
- static bool isActive() { return instances.size() > 0; }
-
- /**
* Closes all instances.
*/
static void closeAll();
diff --git a/src/gui/changeemaildialog.h b/src/gui/changeemaildialog.h
index 7e5f04fa..84838d15 100644
--- a/src/gui/changeemaildialog.h
+++ b/src/gui/changeemaildialog.h
@@ -22,8 +22,6 @@
#ifndef GUI_CHANGEEMAIL_H
#define GUI_CHANGEEMAIL_H
-#include "guichanfwd.h"
-
#include "gui/widgets/window.h"
#include <guichan/actionlistener.hpp>
diff --git a/src/gui/changepassworddialog.h b/src/gui/changepassworddialog.h
index 361debe4..d356a5df 100644
--- a/src/gui/changepassworddialog.h
+++ b/src/gui/changepassworddialog.h
@@ -22,8 +22,6 @@
#ifndef CHANGEPASSWORDDIALOG_H
#define CHANGEPASSWORDDIALOG_H
-#include "guichanfwd.h"
-
#include "gui/widgets/window.h"
#include <guichan/actionlistener.hpp>
diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp
index e4a5fd01..2db25a35 100644
--- a/src/gui/charcreatedialog.cpp
+++ b/src/gui/charcreatedialog.cpp
@@ -54,7 +54,7 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot):
mCharSelectDialog(parent),
mSlot(slot)
{
- mPlayer = new Player(0, 0, NULL);
+ mPlayer = new Being(0, ActorSprite::PLAYER, 0, NULL);
mPlayer->setGender(GENDER_MALE);
int numberOfHairColors = ColorDB::size();
@@ -65,10 +65,10 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot):
mNameField = new TextField("");
mNameLabel = new Label(_("Name:"));
- // TRANSLATORS: This is a narrow symbol used to denote 'next'.
+ // TRANSLATORS: This is an arrow symbol used to denote 'next'.
// You may change this symbol if your language uses another.
mNextHairColorButton = new Button(_(">"), "nextcolor", this);
- // TRANSLATORS: This is a narrow symbol used to denote 'previous'.
+ // TRANSLATORS: This is an arrow symbol used to denote 'previous'.
// You may change this symbol if your language uses another.
mPrevHairColorButton = new Button(_("<"), "prevcolor", this);
mHairColorLabel = new Label(_("Hair color:"));
@@ -277,7 +277,8 @@ int CharCreateDialog::getDistributedPoints() const
}
void CharCreateDialog::setAttributes(const std::vector<std::string> &labels,
- int available, int min, int max)
+ unsigned int available, unsigned int min,
+ unsigned int max)
{
mMaxPoints = available;
diff --git a/src/gui/charcreatedialog.h b/src/gui/charcreatedialog.h
index 902e650e..d6b6d390 100644
--- a/src/gui/charcreatedialog.h
+++ b/src/gui/charcreatedialog.h
@@ -22,7 +22,7 @@
#ifndef CHAR_CREATE_DIALOG_H
#define CHAR_CREATE_DIALOG_H
-#include "player.h"
+#include "being.h"
#include "guichanfwd.h"
#include "gui/charselectdialog.h"
@@ -63,8 +63,8 @@ class CharCreateDialog : public Window, public gcn::ActionListener
void unlock();
void setAttributes(const std::vector<std::string> &labels,
- int available,
- int min, int max);
+ unsigned int available,
+ unsigned int min, unsigned int max);
void setFixedGender(bool fixed, Gender gender = GENDER_FEMALE);
@@ -110,7 +110,7 @@ class CharCreateDialog : public Window, public gcn::ActionListener
gcn::Button *mCreateButton;
gcn::Button *mCancelButton;
- Player *mPlayer;
+ Being *mPlayer;
PlayerBox *mPlayerBox;
int mHairStyle;
diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp
index f8c28c6a..d8794afd 100644
--- a/src/gui/charselectdialog.cpp
+++ b/src/gui/charselectdialog.cpp
@@ -154,7 +154,8 @@ CharSelectDialog::CharSelectDialog(LoginData *loginData):
place = getPlacer(0, 1);
- for (int i = 0; i < MAX_CHARACTER_COUNT; i++) {
+ for (int i = 0; i < MAX_CHARACTER_COUNT; i++)
+ {
mCharacterEntries[i] = new CharacterDisplay(this);
place(i, 0, mCharacterEntries[i]);
}
@@ -191,7 +192,8 @@ void CharSelectDialog::action(const gcn::ActionEvent &event)
{
attemptCharacterSelect(selected);
}
- else if (eventId == "new" && !mCharacterEntries[selected]->getCharacter())
+ else if (eventId == "new"
+ && !mCharacterEntries[selected]->getCharacter())
{
// Start new character dialog
CharCreateDialog *charCreateDialog =
@@ -268,7 +270,8 @@ void CharSelectDialog::setCharacters(const Net::Characters &characters)
for (i = characters.begin(); i != i_end; ++i)
{
Net::Character *character = *i;
- if (character->slot >= MAX_CHARACTER_COUNT) {
+ if (character->slot >= MAX_CHARACTER_COUNT)
+ {
logger->log("Warning: slot out of range: %d", character->slot);
continue;
}
@@ -309,9 +312,12 @@ bool CharSelectDialog::selectByName(const std::string &name,
if (mLocked)
return false;
- for (int i = 0; i < MAX_CHARACTER_COUNT; ++i) {
- if (Net::Character *character = mCharacterEntries[i]->getCharacter()) {
- if (character->dummy->getName() == name) {
+ for (int i = 0; i < MAX_CHARACTER_COUNT; ++i)
+ {
+ if (Net::Character *character = mCharacterEntries[i]->getCharacter())
+ {
+ if (character->dummy->getName() == name)
+ {
mCharacterEntries[i]->requestFocus();
if (action == Choose)
attemptCharacterSelect(i);
@@ -380,8 +386,10 @@ void CharacterDisplay::update()
mButton->setCaption(_("Choose"));
mButton->setActionEventId("use");
mName->setCaption(strprintf("%s", character->getName().c_str()));
- mLevel->setCaption(strprintf("Level %d", character->getLevel()));
- mMoney->setCaption(Units::formatCurrency(character->getMoney()));
+ mLevel->setCaption(strprintf("Level %d",
+ mCharacter->data.mAttributes[LEVEL]));
+ mMoney->setCaption(Units::formatCurrency(
+ mCharacter->data.mAttributes[MONEY]));
mDelete->setVisible(true);
}
diff --git a/src/gui/charselectdialog.h b/src/gui/charselectdialog.h
index b6e71715..2c0444bf 100644
--- a/src/gui/charselectdialog.h
+++ b/src/gui/charselectdialog.h
@@ -22,10 +22,6 @@
#ifndef CHAR_SELECT_H
#define CHAR_SELECT_H
-#include "guichanfwd.h"
-#include "main.h"
-#include "player.h"
-
#include "gui/widgets/window.h"
#include "net/charhandler.h"
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index 6d900e98..7acb7de8 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -21,10 +21,11 @@
#include "chat.h"
-#include "beingmanager.h"
+#include "actorspritemanager.h"
#include "configuration.h"
#include "localplayer.h"
#include "party.h"
+#include "playerrelations.h"
#include "gui/recorder.h"
#include "gui/setup.h"
@@ -89,6 +90,9 @@ ChatWindow::ChatWindow():
mAutoComplete(new ChatAutoComplete),
mTmpVisible(false)
{
+ listen(CHANNEL_CHAT);
+ listen(CHANNEL_NOTICES);
+
setWindowName("Chat");
setupWindow->registerWindowForReset(this);
@@ -119,7 +123,7 @@ ChatWindow::ChatWindow():
mChatInput->setHistory(mHistory);
mChatInput->setAutoComplete(mAutoComplete);
- mReturnToggles = config.getValue("ReturnToggles", "0") == "1";
+ mReturnToggles = config.getBoolValue("ReturnToggles");
mRecorder = new Recorder(this);
}
@@ -286,20 +290,20 @@ void ChatWindow::chatInput(const std::string &msg)
void ChatWindow::doPresent()
{
- const Beings &beings = beingManager->getAll();
+ const ActorSprites &actors = actorSpriteManager->getAll();
std::string response = "";
int playercount = 0;
- for (Beings::const_iterator bi = beings.begin(), be = beings.end();
- bi != be; ++bi)
+ for (ActorSpritesConstIterator it = actors.begin(), it_end = actors.end();
+ it != it_end; it++)
{
- if ((*bi)->getType() == Being::PLAYER)
+ if ((*it)->getType() == ActorSprite::PLAYER)
{
if (!response.empty())
{
response += ", ";
}
- response += (*bi)->getName();
+ response += static_cast<Being*>(*it)->getName();
++playercount;
}
}
@@ -371,6 +375,40 @@ void ChatWindow::mouseDragged(gcn::MouseEvent &event)
}
}
+void ChatWindow::event(Channels channel, const Mana::Event &event)
+{
+ if (channel == CHANNEL_NOTICES)
+ {
+ if (event.getName() == EVENT_SERVERNOTICE)
+ localChatTab->chatLog(event.getString("message"), BY_SERVER);
+ }
+ else if (channel == CHANNEL_CHAT)
+ {
+ if (event.getName() == EVENT_WHISPER)
+ {
+ whisper(event.getString("nick"), event.getString("message"));
+ }
+ else if (event.getName() == EVENT_WHISPERERROR)
+ {
+ whisper(event.getString("nick"),
+ event.getString("error"), BY_SERVER);
+ }
+ else if (event.getName() == EVENT_PLAYER)
+ {
+ localChatTab->chatLog(event.getString("message"), BY_PLAYER);
+ }
+ else if (event.getName() == EVENT_ANNOUNCEMENT)
+ {
+ localChatTab->chatLog(event.getString("message"), BY_GM);
+ }
+ else if (event.getName() == EVENT_BEING)
+ {
+ if (event.getInt("permissions") & PlayerRelation::SPEECH_LOG)
+ localChatTab->chatLog(event.getString("message"), BY_OTHER);
+ }
+ }
+}
+
void ChatWindow::addInputText(const std::string &text)
{
const int caretPos = mChatInput->getCaretPosition();
@@ -409,7 +447,7 @@ void ChatWindow::setRecordingFile(const std::string &msg)
}
void ChatWindow::whisper(const std::string &nick,
- const std::string &mes, bool own)
+ const std::string &mes, Own own)
{
if (mes.empty())
return;
@@ -428,24 +466,27 @@ void ChatWindow::whisper(const std::string &nick,
if (i != mWhispers.end())
tab = i->second;
- else if (config.getValue("whispertab", true))
+ else if (config.getBoolValue("whispertab"))
tab = addWhisperTab(nick);
if (tab)
{
- if (own)
+ if (own == BY_PLAYER)
{
tab->chatInput(mes);
}
+ else if (own == BY_SERVER)
+ {
+ tab->chatLog(mes);
+ }
else
{
tab->chatLog(nick, mes);
- player_node->afkRespond(tab, nick);
}
}
else
{
- if (own)
+ if (own == BY_PLAYER)
{
Net::getChatHandler()->privateMessage(nick, mes);
diff --git a/src/gui/chat.h b/src/gui/chat.h
index 1c673556..f546502c 100644
--- a/src/gui/chat.h
+++ b/src/gui/chat.h
@@ -22,6 +22,8 @@
#ifndef CHAT_H
#define CHAT_H
+#include "listener.h"
+
#include "gui/widgets/window.h"
#include "gui/widgets/textfield.h"
@@ -36,8 +38,8 @@
#include <vector>
class BrowserBox;
-class Channel;
class ChatTab;
+class Channel;
class ChatInput;
class Recorder;
class ScrollArea;
@@ -48,12 +50,24 @@ class WhisperTab;
#define DEFAULT_CHAT_WINDOW_SCROLL 7 // 1 means `1/8th of the window size'.
+enum Own
+{
+ BY_GM,
+ BY_PLAYER,
+ BY_OTHER,
+ BY_SERVER,
+ BY_CHANNEL,
+ ACT_WHISPER, // getting whispered at
+ ACT_IS, // equivalent to "/me" on IRC
+ BY_LOGGER
+};
+
/** One item in the chat log */
struct CHATLOG
{
std::string nick;
std::string text;
- int own;
+ Own own;
};
/**
@@ -62,7 +76,8 @@ struct CHATLOG
* \ingroup Interface
*/
class ChatWindow : public Window,
- public gcn::ActionListener
+ public gcn::ActionListener,
+ public Mana::Listener
{
public:
/**
@@ -143,6 +158,8 @@ class ChatWindow : public Window,
void mousePressed(gcn::MouseEvent &event);
void mouseDragged(gcn::MouseEvent &event);
+ void event(Channels channel, const Mana::Event &event);
+
/**
* Scrolls the chat window
*
@@ -165,7 +182,7 @@ class ChatWindow : public Window,
void doPresent();
void whisper(const std::string &nick, const std::string &mes,
- bool own = false);
+ Own own = BY_OTHER);
ChatTab *addWhisperTab(const std::string &nick, bool switchTo = false);
diff --git a/src/gui/emotepopup.cpp b/src/gui/emotepopup.cpp
index 7c05e263..bd40a932 100644
--- a/src/gui/emotepopup.cpp
+++ b/src/gui/emotepopup.cpp
@@ -22,18 +22,17 @@
#include "gui/emotepopup.h"
-#include "animatedsprite.h"
+#include "imagesprite.h"
#include "configuration.h"
#include "emoteshortcut.h"
#include "graphics.h"
#include "localplayer.h"
#include "log.h"
-#include "gui/theme.h"
-
#include "resources/emotedb.h"
#include "resources/image.h"
#include "resources/iteminfo.h"
+#include "resources/theme.h"
#include "utils/dtor.h"
@@ -54,14 +53,14 @@ EmotePopup::EmotePopup():
// Setup emote sprites
for (int i = 0; i <= EmoteDB::getLast(); ++i)
{
- mEmotes.push_back(EmoteDB::getAnimation(i));
+ mEmotes.push_back(EmoteDB::get(i)->sprite);
}
mSelectionImage = Theme::getImageFromTheme("selection.png");
if (!mSelectionImage)
logger->error("Unable to load selection.png");
- mSelectionImage->setAlpha(config.getValue("guialpha", 0.8));
+ mSelectionImage->setAlpha(config.getFloatValue("guialpha"));
addMouseListener(this);
recalculateSize();
diff --git a/src/gui/emotepopup.h b/src/gui/emotepopup.h
index 62a3f24a..d2cabc44 100644
--- a/src/gui/emotepopup.h
+++ b/src/gui/emotepopup.h
@@ -30,7 +30,7 @@
#include <list>
#include <vector>
-class AnimatedSprite;
+class ImageSprite;
class Image;
namespace gcn {
@@ -105,7 +105,7 @@ class EmotePopup : public Popup
*/
void distributeValueChangedEvent();
- std::vector<const AnimatedSprite*> mEmotes;
+ std::vector<const ImageSprite*> mEmotes;
Image *mSelectionImage;
int mSelectedEmoteIndex;
int mHoveredEmoteIndex;
diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp
index 43e330f4..aeeaf223 100644
--- a/src/gui/equipmentwindow.cpp
+++ b/src/gui/equipmentwindow.cpp
@@ -29,7 +29,6 @@
#include "gui/equipmentwindow.h"
#include "gui/itempopup.h"
-#include "gui/theme.h"
#include "gui/setup.h"
#include "gui/viewport.h"
@@ -41,6 +40,7 @@
#include "resources/image.h"
#include "resources/iteminfo.h"
#include "resources/resourcemanager.h"
+#include "resources/theme.h"
#include "utils/gettext.h"
#include "utils/stringutils.h"
@@ -158,7 +158,7 @@ void EquipmentWindow::action(const gcn::ActionEvent &event)
if (event.getId() == "unequip" && mSelected > -1)
{
Item *item = mEquipment->getEquipment(mSelected);
- Net::getInventoryHandler()->unequipItem(item);
+ item->doEvent(EVENT_DOUNEQUIP);
setSelected(-1);
}
}
diff --git a/src/gui/equipmentwindow.h b/src/gui/equipmentwindow.h
index 5688bf30..dcb3523d 100644
--- a/src/gui/equipmentwindow.h
+++ b/src/gui/equipmentwindow.h
@@ -23,7 +23,6 @@
#define EQUIPMENTWINDOW_H
#include "equipment.h"
-#include "guichanfwd.h"
#include "gui/widgets/window.h"
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 75f67435..c0d1babf 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -24,14 +24,13 @@
#include "gui/focushandler.h"
#include "gui/palette.h"
#include "gui/sdlinput.h"
-#include "gui/theme.h"
#include "gui/truetypefont.h"
#include "gui/widgets/window.h"
#include "gui/widgets/windowcontainer.h"
-#include "configlistener.h"
#include "configuration.h"
+#include "listener.h"
#include "graphics.h"
#include "log.h"
@@ -39,6 +38,7 @@
#include "resources/imageset.h"
#include "resources/imageloader.h"
#include "resources/resourcemanager.h"
+#include "resources/theme.h"
#include <guichan/exception.hpp>
#include <guichan/image.hpp>
@@ -50,19 +50,23 @@ SDLInput *guiInput = 0;
// Bolded font
gcn::Font *boldFont = 0;
-class GuiConfigListener : public ConfigListener
+class GuiConfigListener : public Mana::Listener
{
public:
GuiConfigListener(Gui *g):
mGui(g)
{}
- void optionChanged(const std::string &name)
+ void event(Channels channel, const Mana::Event &event)
{
- if (name == "customcursor")
+ if (channel == CHANNEL_CONFIG)
{
- bool bCustomCursor = config.getValue("customcursor", 1) == 1;
- mGui->setUseCustomCursor(bCustomCursor);
+ if (event.getName() == EVENT_CONFIGOPTIONCHANGED &&
+ event.getString("option") == "customcursor")
+ {
+ bool bCustomCursor = config.getBoolValue("customcursor");
+ mGui->setUseCustomCursor(bCustomCursor);
+ }
}
}
private:
@@ -104,7 +108,7 @@ Gui::Gui(Graphics *graphics):
ResourceManager *resman = ResourceManager::getInstance();
// Set global font
- const int fontSize = (int) config.getValue("fontSize", 11);
+ const int fontSize = config.getValue("fontSize", 11);
std::string fontFile = branding.getValue("font", "fonts/dejavusans.ttf");
std::string path = resman->getPath(fontFile);
@@ -135,14 +139,13 @@ Gui::Gui(Graphics *graphics):
gcn::Widget::setGlobalFont(mGuiFont);
// Initialize mouse cursor and listen for changes to the option
- setUseCustomCursor(config.getValue("customcursor", 1) == 1);
+ setUseCustomCursor(config.getBoolValue("customcursor"));
mConfigListener = new GuiConfigListener(this);
- config.addListener("customcursor", mConfigListener);
+ mConfigListener->listen(CHANNEL_CONFIG);
}
Gui::~Gui()
{
- config.removeListener("customcursor", mConfigListener);
delete mConfigListener;
if (mMouseCursors)
diff --git a/src/gui/help.cpp b/src/gui/help.cpp
index f3c6a0af..aca036c1 100644
--- a/src/gui/help.cpp
+++ b/src/gui/help.cpp
@@ -94,9 +94,9 @@ void HelpWindow::loadHelp(const std::string &helpFile)
void HelpWindow::loadFile(const std::string &file)
{
ResourceManager *resman = ResourceManager::getInstance();
- std::string helpPath = branding.getValue("helpPath", "");
+ std::string helpPath = branding.getStringValue("helpPath");
if (helpPath.empty())
- helpPath = paths.getValue("help", "help/");
+ helpPath = paths.getStringValue("help");
std::vector<std::string> lines =
resman->loadTextFile(helpPath + file + ".txt");
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index 16ac5409..31743c57 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -23,14 +23,13 @@
#include "inventory.h"
#include "item.h"
-#include "localplayer.h"
#include "units.h"
#include "keyboardconfig.h"
+#include "playerinfo.h"
#include "gui/itemamount.h"
#include "gui/setup.h"
#include "gui/sdlinput.h"
-#include "gui/theme.h"
#include "gui/viewport.h"
#include "gui/widgets/button.h"
@@ -44,6 +43,7 @@
#include "net/net.h"
#include "resources/iteminfo.h"
+#include "resources/theme.h"
#include "utils/gettext.h"
#include "utils/stringutils.h"
@@ -60,6 +60,8 @@ InventoryWindow::InventoryWindow(Inventory *inventory):
mInventory(inventory),
mSplit(false)
{
+ listen(CHANNEL_ATTRIBUTES);
+
setWindowName(isMainInventory() ? "Inventory" : "Storage");
setupWindow->registerWindowForReset(this);
setResizable(true);
@@ -95,7 +97,8 @@ InventoryWindow::InventoryWindow(Inventory *inventory):
longestUseString = unequip;
}
- mUseButton = new Button(longestUseString, "use", this);
+ mEquipButton = new Button(_("Equip"), "equip", this);
+ mUseButton = new Button(_("Activate"), "activate", this);
mDropButton = new Button(_("Drop..."), "drop", this);
mSplitButton = new Button(_("Split"), "split", this);
mOutfitButton = new Button(_("Outfits"), "outfit", this);
@@ -109,8 +112,9 @@ InventoryWindow::InventoryWindow(Inventory *inventory):
place(5, 0, mSlotsBar, 2);
place(0, 1, invenScroll, 7).setPadding(3);
place(0, 2, mUseButton);
- place(1, 2, mDropButton);
- place(2, 2, mSplitButton);
+ place(1, 2, mEquipButton);
+ place(2, 2, mDropButton);
+ place(3, 2, mSplitButton);
place(6, 2, mOutfitButton);
updateWeight();
@@ -138,13 +142,19 @@ InventoryWindow::InventoryWindow(Inventory *inventory):
slotsChanged(mInventory);
if (!isMainInventory())
+ {
setVisible(true);
+ PlayerInfo::setStorageCount(PlayerInfo::getStorageCount() + 1);
+ }
}
InventoryWindow::~InventoryWindow()
{
instances.remove(this);
mInventory->removeInventoyListener(this);
+
+ if (!isMainInventory())
+ PlayerInfo::setStorageCount(PlayerInfo::getStorageCount() - 1);
}
void InventoryWindow::action(const gcn::ActionEvent &event)
@@ -175,17 +185,21 @@ void InventoryWindow::action(const gcn::ActionEvent &event)
if (!item)
return;
- if (event.getId() == "use")
+ if (event.getId() == "activate")
+ item->doEvent(EVENT_DOUSE);
+ else if (event.getId() == "equip")
{
- if (item->isEquipment())
+ if (item->isEquippable())
{
if (item->isEquipped())
- Net::getInventoryHandler()->unequipItem(item);
+ item->doEvent(EVENT_DOUNEQUIP);
else
- Net::getInventoryHandler()->equipItem(item);
+ item->doEvent(EVENT_DOEQUIP);
}
else
- Net::getInventoryHandler()->useItem(item);
+ {
+ item->doEvent(EVENT_DOUSE);
+ }
}
else if (event.getId() == "drop")
{
@@ -234,20 +248,30 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event)
if (event.getButton() == gcn::MouseEvent::LEFT)
{
- if (isStorageActive() && keyboard.isKeyActive(keyboard.KEY_EMOTE))
+ if (instances.size() > 1 && keyboard.isKeyActive(keyboard.KEY_EMOTE))
{
Item *item = mItems->getSelectedItem();
if(!item)
return;
if (mInventory->isMainInventory())
- Net::getInventoryHandler()->moveItem(Inventory::INVENTORY,
- item->getInvIndex(), item->getQuantity(),
- Inventory::STORAGE);
+ {
+ Mana::Event event(EVENT_DOMOVE);
+ event.setItem("item", item);
+ event.setInt("amount", item->getQuantity());
+ event.setInt("source", Inventory::INVENTORY);
+ event.setInt("destination", Inventory::STORAGE);
+ event.trigger(CHANNEL_ITEM);
+ }
else
- Net::getInventoryHandler()->moveItem(Inventory::STORAGE,
- item->getInvIndex(), item->getQuantity(),
- Inventory::INVENTORY);
+ {
+ Mana::Event event(EVENT_DOMOVE);
+ event.setItem("item", item);
+ event.setInt("amount", item->getQuantity());
+ event.setInt("source", Inventory::STORAGE);
+ event.setInt("destination", Inventory::INVENTORY);
+ event.trigger(CHANNEL_ITEM);
+ }
}
}
}
@@ -298,26 +322,27 @@ void InventoryWindow::updateButtons()
if (!item || item->getQuantity() == 0)
{
mUseButton->setEnabled(false);
+ mEquipButton->setEnabled(false);
mDropButton->setEnabled(false);
mSplitButton->setEnabled(false);
return;
}
- mUseButton->setEnabled(true);
mDropButton->setEnabled(true);
- if (item->isEquipment())
+ if (item->getInfo().getEquippable())
{
if (item->isEquipped())
- mUseButton->setCaption(_("Unequip"));
+ mEquipButton->setCaption(_("Unequip"));
else
- mUseButton->setCaption(_("Equip"));
+ mEquipButton->setCaption(_("Equip"));
+ mEquipButton->setEnabled(true);
}
else
- {
- mUseButton->setCaption(_("Use"));
- }
+ mEquipButton->setEnabled(false);
+
+ mUseButton->setEnabled(item->getInfo().getActivatable());
if (item->getQuantity() > 1)
mDropButton->setCaption(_("Drop..."));
@@ -343,15 +368,36 @@ void InventoryWindow::close()
}
else
{
- Net::getInventoryHandler()->closeStorage(Inventory::STORAGE);
+ Mana::Event event(EVENT_DOCLOSEINVENTORY);
+ event.setInt("type", mInventory->getType());
+ event.trigger(CHANNEL_ITEM);
scheduleDelete();
}
}
+void InventoryWindow::event(Channels channel, const Mana::Event &event)
+{
+ if (event.getName() == EVENT_UPDATEATTRIBUTE)
+ {
+ int id = event.getInt("id");
+ if (id == TOTAL_WEIGHT ||
+ id == MAX_WEIGHT)
+ {
+ updateWeight();
+ }
+ }
+}
+
void InventoryWindow::updateWeight()
{
- int total = player_node->getTotalWeight();
- int max = player_node->getMaxWeight();
+ if (!isMainInventory())
+ return;
+
+ int total = PlayerInfo::getAttribute(TOTAL_WEIGHT);
+ int max = PlayerInfo::getAttribute(MAX_WEIGHT);
+
+ if (max <= 0)
+ return;
// Adjust progress bar
mWeightBar->setProgress((float) total / max);
diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h
index 0dce0611..0ddd13f7 100644
--- a/src/gui/inventorywindow.h
+++ b/src/gui/inventorywindow.h
@@ -23,11 +23,11 @@
#define INVENTORYWINDOW_H
#include "inventory.h"
+#include "listener.h"
#include "gui/widgets/window.h"
#include "net/inventoryhandler.h"
-#include "net/net.h"
#include <guichan/actionlistener.hpp>
#include <guichan/keylistener.hpp>
@@ -47,7 +47,8 @@ class InventoryWindow : public Window,
public gcn::ActionListener,
public gcn::KeyListener,
public gcn::SelectionListener,
- public InventoryListener
+ public InventoryListener,
+ public Mana::Listener
{
public:
/**
@@ -106,21 +107,19 @@ class InventoryWindow : public Window,
*/
void updateButtons();
- /**
- * Updates the weight bar.
- */
- void updateWeight();
-
void slotsChanged(Inventory* inventory);
bool isMainInventory() { return mInventory->isMainInventory(); }
+ void event(Channels channel, const Mana::Event &event);
+
+ private:
/**
- * Returns true if any instances exist.
+ * Updates the weight bar.
*/
- static bool isStorageActive() { return instances.size() > 1; }
+ void updateWeight();
+
- private:
typedef std::list<InventoryWindow*> WindowList;
static WindowList instances;
@@ -129,8 +128,8 @@ class InventoryWindow : public Window,
std::string mWeight, mSlots;
- gcn::Button *mUseButton, *mDropButton, *mSplitButton, *mOutfitButton,
- *mStoreButton, *mRetrieveButton;
+ gcn::Button *mUseButton, *mEquipButton, *mDropButton, *mSplitButton,
+ *mOutfitButton, *mStoreButton, *mRetrieveButton;
gcn::Label *mWeightLabel, *mSlotsLabel;
diff --git a/src/gui/itemamount.cpp b/src/gui/itemamount.cpp
index a98a67ab..85325c66 100644
--- a/src/gui/itemamount.cpp
+++ b/src/gui/itemamount.cpp
@@ -47,20 +47,30 @@ void ItemAmountWindow::finish(Item *item, int amount, Usage usage)
tradeWindow->tradeItem(item, amount);
break;
case ItemDrop:
- Net::getInventoryHandler()->dropItem(item, amount);
+ item->doEvent(EVENT_DODROP, amount);
break;
case ItemSplit:
- Net::getInventoryHandler()->splitItem(item, amount);
+ item->doEvent(EVENT_DOSPLIT, amount);
break;
case StoreAdd:
- Net::getInventoryHandler()->moveItem(Inventory::INVENTORY,
- item->getInvIndex(), amount,
- Inventory::STORAGE);
+ {
+ Mana::Event event(EVENT_DOMOVE);
+ event.setItem("item", item);
+ event.setInt("amount", amount);
+ event.setInt("source", Inventory::INVENTORY);
+ event.setInt("destination", Inventory::STORAGE);
+ event.trigger(CHANNEL_ITEM);
+ }
break;
case StoreRemove:
- Net::getInventoryHandler()->moveItem(Inventory::STORAGE,
- item->getInvIndex(), amount,
- Inventory::INVENTORY);
+ {
+ Mana::Event event(EVENT_DOMOVE);
+ event.setItem("item", item);
+ event.setInt("amount", amount);
+ event.setInt("source", Inventory::STORAGE);
+ event.setInt("destination", Inventory::INVENTORY);
+ event.trigger(CHANNEL_ITEM);
+ }
break;
default:
break;
diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp
index b71ca529..9b2df34d 100644
--- a/src/gui/itempopup.cpp
+++ b/src/gui/itempopup.cpp
@@ -26,9 +26,9 @@
#include "units.h"
#include "gui/gui.h"
-#include "gui/theme.h"
#include "gui/widgets/icon.h"
+#include "gui/widgets/label.h"
#include "gui/widgets/textbox.h"
#include "utils/gettext.h"
@@ -36,6 +36,7 @@
#include "resources/image.h"
#include "resources/resourcemanager.h"
+#include "resources/theme.h"
#include <guichan/font.hpp>
@@ -46,7 +47,7 @@ ItemPopup::ItemPopup():
mIcon(0)
{
// Item Name
- mItemName = new gcn::Label;
+ mItemName = new Label;
mItemName->setFont(boldFont);
mItemName->setPosition(getPadding(), getPadding());
@@ -98,8 +99,9 @@ void ItemPopup::setItem(const ItemInfo &item, bool showImage)
{
ResourceManager *resman = ResourceManager::getInstance();
Image *image = resman->getImage(
- paths.getValue("itemIcons", "graphics/items/")
- + item.getImageName());
+ paths.getStringValue("itemIcons")
+ + item.getDisplay().image);
+
mIcon->setImage(image);
if (image)
{
@@ -114,18 +116,27 @@ void ItemPopup::setItem(const ItemInfo &item, bool showImage)
mIcon->setImage(0);
}
- mItemType = item.getType();
+ //mItemType = item.getType();
mItemName->setCaption(item.getName());
mItemName->adjustSize();
- mItemName->setForegroundColor(getColor(mItemType));
+ mItemName->setForegroundColor(Theme::UNKNOWN_ITEM); // TODO
mItemName->setPosition(getPadding() + space, getPadding());
- mItemDesc->setTextWrapped(item.getDescription(), 196);
- mItemEffect->setTextWrapped(item.getEffect(), 196);
+#define ITEMPOPUP_WRAP_WIDTH 196
+
+ mItemDesc->setTextWrapped(item.getDescription(), ITEMPOPUP_WRAP_WIDTH);
+ {
+ const std::vector<std::string> &effect = item.getEffect();
+ std::string temp = "";
+ for (std::vector<std::string>::const_iterator it = effect.begin(),
+ it_end = effect.end(); it != it_end; ++it)
+ temp += temp.empty() ? *it : "\n" + *it;
+ mItemEffect->setTextWrapped(temp, ITEMPOPUP_WRAP_WIDTH);
+ }
mItemWeight->setTextWrapped(strprintf(_("Weight: %s"),
Units::formatWeight(item.getWeight()).c_str()),
- 196);
+ ITEMPOPUP_WRAP_WIDTH);
int minWidth = mItemName->getWidth() + space;
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp
index 8713d3f9..993814ea 100644
--- a/src/gui/minimap.cpp
+++ b/src/gui/minimap.cpp
@@ -21,20 +21,19 @@
#include "gui/minimap.h"
+#include "actorspritemanager.h"
#include "being.h"
-#include "beingmanager.h"
#include "configuration.h"
#include "graphics.h"
#include "localplayer.h"
#include "log.h"
#include "map.h"
-#include "player.h"
#include "gui/setup.h"
-#include "gui/userpalette.h"
#include "resources/image.h"
#include "resources/resourcemanager.h"
+#include "resources/userpalette.h"
#include "utils/gettext.h"
@@ -186,52 +185,46 @@ void Minimap::draw(gcn::Graphics *graphics)
drawImage(mMapImage, mapOriginX, mapOriginY);
}
- const Beings &beings = beingManager->getAll();
+ const ActorSprites &actors = actorSpriteManager->getAll();
- for (Beings::const_iterator bi = beings.begin(), bi_end = beings.end();
- bi != bi_end; ++bi)
+ for (ActorSpritesConstIterator it = actors.begin(), it_end = actors.end();
+ it != it_end; it++)
{
- const Being *being = (*bi);
+ if ((*it)->getType() == ActorSprite::FLOOR_ITEM)
+ continue;
+
+ const Being *being = static_cast<Being*>(*it);
int dotSize = 2;
- switch (being->getType())
+ int type = UserPalette::PC;
+
+ if (being == player_node)
+ {
+ type = UserPalette::SELF;
+ dotSize = 3;
+ }
+ else if (being->isGM())
+ type = UserPalette::GM;
+ else if (being->isInParty())
+ type = UserPalette::PARTY;
+ else
{
- case Being::PLAYER:
- {
- const Player *player = static_cast<const Player*>(being);
-
- int type = UserPalette::PC;
-
- if (being == player_node)
- {
- type = UserPalette::SELF;
- dotSize = 3;
- }
- else if (player->isGM())
- {
- type = UserPalette::GM;
- }
- else if (player->isInParty())
- {
- type = UserPalette::PARTY;
- }
-
- graphics->setColor(userPalette->getColor(type));
+ switch (being->getType())
+ {
+ case ActorSprite::MONSTER:
+ graphics->setColor(userPalette->getColor(UserPalette::MONSTER));
break;
- }
-
- case Being::MONSTER:
- graphics->setColor(userPalette->getColor(UserPalette::MONSTER));
- break;
- case Being::NPC:
- graphics->setColor(userPalette->getColor(UserPalette::NPC));
- break;
+ case ActorSprite::NPC:
+ graphics->setColor(userPalette->getColor(UserPalette::NPC));
+ break;
- default:
- continue;
+ default:
+ continue;
+ }
}
+ graphics->setColor(userPalette->getColor(type));
const int offsetHeight = (int) ((dotSize - 1) * mHeightProportion);
const int offsetWidth = (int) ((dotSize - 1) * mWidthProportion);
diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp
index 90581f61..fae40d03 100644
--- a/src/gui/ministatus.cpp
+++ b/src/gui/ministatus.cpp
@@ -24,17 +24,20 @@
#include "animatedsprite.h"
#include "configuration.h"
#include "graphics.h"
-#include "localplayer.h"
+#include "playerinfo.h"
+#include "statuseffect.h"
#include "gui/gui.h"
#include "gui/statuswindow.h"
#include "gui/textpopup.h"
-#include "gui/theme.h"
#include "gui/widgets/progressbar.h"
#include "net/net.h"
#include "net/playerhandler.h"
+#include "net/gamehandler.h"
+
+#include "resources/theme.h"
#include "utils/gettext.h"
#include "utils/stringutils.h"
@@ -44,22 +47,36 @@ extern volatile int tick_time;
MiniStatusWindow::MiniStatusWindow():
Popup("MiniStatus")
{
- int max = player_node->getMaxHp();
- mHpBar = new ProgressBar(max ? (float) player_node->getHp() / max : 0,
- 100, 20, Theme::PROG_HP);
- max = player_node->getMaxMP();
- mMpBar = new ProgressBar(max ? (float) player_node->getMP() / max : 0,
- 100, 20, Net::getPlayerHandler()->canUseMagic() ?
- Theme::PROG_MP : Theme::PROG_NO_MP);
- max = player_node->getExpNeeded();
- mXpBar = new ProgressBar(max ? (float) player_node->getExp() / max : 0,
- 100, 20, Theme::PROG_EXP);
+ listen(CHANNEL_ATTRIBUTES);
+
+ mHpBar = new ProgressBar(0, 100, 20, Theme::PROG_HP);
+ StatusWindow::updateHPBar(mHpBar);
+
+ if (Net::getGameHandler()->canUseMagicBar())
+ {
+ mMpBar = new ProgressBar(0, 100, 20,
+ Net::getPlayerHandler()->canUseMagic()
+ ? Theme::PROG_MP : Theme::PROG_NO_MP);
+
+ StatusWindow::updateMPBar(mMpBar);
+ }
+ else
+ mMpBar = 0;
+
+ mXpBar = new ProgressBar(0, 100, 20, Theme::PROG_EXP);
+ StatusWindow::updateXPBar(mXpBar);
+
+ // Add the progressbars to the window
+
mHpBar->setPosition(0, 3);
- mMpBar->setPosition(mHpBar->getWidth() + 3, 3);
- mXpBar->setPosition(mMpBar->getX() + mMpBar->getWidth() + 3, 3);
+ if (mMpBar)
+ mMpBar->setPosition(mHpBar->getWidth() + 3, 3);
+ mXpBar->setPosition(mMpBar ? mMpBar->getX() + mMpBar->getWidth() + 3 :
+ mHpBar->getX() + mHpBar->getWidth() + 3, 3);
add(mHpBar);
- add(mMpBar);
+ if (mMpBar)
+ add(mMpBar);
add(mXpBar);
setContentSize(mXpBar->getX() + mXpBar->getWidth(),
@@ -70,8 +87,6 @@ MiniStatusWindow::MiniStatusWindow():
mTextPopup = new TextPopup();
addMouseListener(this);
-
- update(StatusWindow::HP);
}
void MiniStatusWindow::setIcon(int index, AnimatedSprite *sprite)
@@ -104,19 +119,82 @@ void MiniStatusWindow::drawIcons(Graphics *graphics)
}
}
-void MiniStatusWindow::update(int id)
+void MiniStatusWindow::event(Channels channel, const Mana::Event &event)
{
- if (id == StatusWindow::HP)
- {
- StatusWindow::updateHPBar(mHpBar);
- }
- else if (id == StatusWindow::MP)
+ if (channel == CHANNEL_ATTRIBUTES)
{
- StatusWindow::updateMPBar(mMpBar);
+ if (event.getName() == EVENT_UPDATEATTRIBUTE)
+ {
+ int id = event.getInt("id");
+ if (id == HP || id == MAX_HP)
+ {
+ StatusWindow::updateHPBar(mHpBar);
+ }
+ else if (id == MP || id == MAX_MP)
+ {
+ StatusWindow::updateMPBar(mMpBar);
+ }
+ else if (id == EXP || id == EXP_NEEDED)
+ {
+ StatusWindow::updateXPBar(mXpBar);
+ }
+ }
}
- else if (id == StatusWindow::EXP)
+ else if (channel == CHANNEL_ACTORSPRITE)
{
- StatusWindow::updateXPBar(mXpBar);
+ if (event.getName() == EVENT_UPDATESTATUSEFFECT)
+ {
+ int index = event.getInt("index");
+ bool newStatus = event.getBool("newStatus");
+
+ StatusEffect *effect = StatusEffect::getStatusEffect(index,
+ newStatus);
+
+ if (effect)
+ {
+ effect->deliverMessage();
+ effect->playSFX();
+
+ AnimatedSprite *sprite = effect->getIcon();
+
+ typedef std::vector<int> IntMap;
+
+ if (!sprite)
+ {
+ // delete sprite, if necessary
+ for (unsigned int i = 0; i < mStatusEffectIcons.size();)
+ if (mStatusEffectIcons[i] == index)
+ {
+ mStatusEffectIcons.erase(mStatusEffectIcons.begin()
+ + i);
+ miniStatusWindow->eraseIcon(i);
+ }
+ else
+ i++;
+ }
+ else
+ {
+ // replace sprite or append
+ bool found = false;
+
+ for (unsigned int i = 0; i < mStatusEffectIcons.size();
+ i++)
+ if (mStatusEffectIcons[i] == index)
+ {
+ miniStatusWindow->setIcon(i, sprite);
+ found = true;
+ break;
+ }
+
+ if (!found)
+ { // add new
+ int offset = mStatusEffectIcons.size();
+ miniStatusWindow->setIcon(offset, sprite);
+ mStatusEffectIcons.push_back(index);
+ }
+ }
+ }
+ }
}
}
@@ -152,23 +230,23 @@ void MiniStatusWindow::mouseMoved(gcn::MouseEvent &event)
if (event.getSource() == mXpBar)
{
mTextPopup->show(x + getX(), y + getY(),
- strprintf("%u/%u", player_node->getExp(),
- player_node->getExpNeeded()),
+ strprintf("%u/%u", PlayerInfo::getAttribute(EXP),
+ PlayerInfo::getAttribute(EXP_NEEDED)),
strprintf("%s: %u", _("Need"),
- player_node->getExpNeeded()
- - player_node->getExp()));
+ PlayerInfo::getAttribute(EXP_NEEDED)
+ - PlayerInfo::getAttribute(EXP)));
}
else if (event.getSource() == mHpBar)
{
mTextPopup->show(x + getX(), y + getY(),
- strprintf("%u/%u", player_node->getHp(),
- player_node->getMaxHp()));
+ strprintf("%u/%u", PlayerInfo::getAttribute(HP),
+ PlayerInfo::getAttribute(MAX_HP)));
}
else if (event.getSource() == mMpBar)
{
mTextPopup->show(x + getX(), y + getY(),
- strprintf("%u/%u", player_node->getMP(),
- player_node->getMaxMP()));
+ strprintf("%u/%u", PlayerInfo::getAttribute(MP),
+ PlayerInfo::getAttribute(MAX_MP)));
}
else
{
@@ -182,5 +260,3 @@ void MiniStatusWindow::mouseExited(gcn::MouseEvent &event)
mTextPopup->setVisible(false);
}
-
-
diff --git a/src/gui/ministatus.h b/src/gui/ministatus.h
index bb8d4094..9dfcaeae 100644
--- a/src/gui/ministatus.h
+++ b/src/gui/ministatus.h
@@ -22,6 +22,8 @@
#ifndef MINISTATUS_H
#define MINISTATUS_H
+#include "listener.h"
+
#include "gui/widgets/popup.h"
#include <vector>
@@ -36,21 +38,14 @@ class TextPopup;
*
* \ingroup Interface
*/
-class MiniStatusWindow : public Popup
+class MiniStatusWindow : public Popup, public Mana::Listener
{
public:
MiniStatusWindow();
- /**
- * Sets one of the icons.
- */
- void setIcon(int index, AnimatedSprite *sprite);
-
- void eraseIcon(int index);
-
void drawIcons(Graphics *graphics);
- void update(int id); // Same types as status window
+ void event(Channels channel, const Mana::Event &event);
void logic(); // Updates icons
@@ -63,6 +58,13 @@ class MiniStatusWindow : public Popup
private:
bool isInBar(ProgressBar *bar, int x, int y) const;
+ /**
+ * Sets one of the icons.
+ */
+ void setIcon(int index, AnimatedSprite *sprite);
+
+ void eraseIcon(int index);
+
/*
* Mini Status Bars
*/
@@ -71,6 +73,7 @@ class MiniStatusWindow : public Popup
ProgressBar *mXpBar;
TextPopup *mTextPopup;
+ std::vector<int> mStatusEffectIcons;
std::vector<AnimatedSprite *> mIcons;
};
diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp
index c4128588..590001b0 100644
--- a/src/gui/npcdialog.cpp
+++ b/src/gui/npcdialog.cpp
@@ -22,8 +22,11 @@
#include "gui/npcdialog.h"
#include "configuration.h"
-#include "npc.h"
+#include "event.h"
+#include "listener.h"
+#include "playerinfo.h"
+#include "gui/npcpostdialog.h"
#include "gui/setup.h"
#include "gui/widgets/button.h"
@@ -47,12 +50,29 @@
#define CAPTION_CLOSE _("Close")
#define CAPTION_SUBMIT _("Submit")
+typedef std::map<int, NpcDialog*> NpcDialogs;
+
+class NpcEventListener : public Mana::Listener
+{
+public:
+ void event(Channels channel, const Mana::Event &event);
+
+ NpcDialog *getDialog(int id, bool make = true);
+
+ void removeDialog(int id);
+
+private:
+ NpcDialogs mNpcDialogs;
+};
+
+static NpcEventListener *npcListener = NULL;
+
NpcDialog::DialogList NpcDialog::instances;
NpcDialog::NpcDialog(int npcId)
: Window(_("NPC")),
mNpcId(npcId),
- mLogInteraction(config.getValue("logNpcInGui", true)),
+ mLogInteraction(config.getBoolValue("logNpcInGui")),
mDefaultInt(0),
mInputState(NPC_INPUT_NONE),
mActionState(NPC_ACTION_WAIT)
@@ -123,7 +143,9 @@ NpcDialog::NpcDialog(int npcId)
setVisible(true);
requestFocus();
- config.addListener("logNpcInGui", this);
+ listen(CHANNEL_CONFIG);
+ PlayerInfo::setNPCInteractionCount(PlayerInfo::getNPCInteractionCount()
+ + 1);
}
NpcDialog::~NpcDialog()
@@ -139,7 +161,10 @@ NpcDialog::~NpcDialog()
instances.remove(this);
- config.removeListener("logNpcInGui", this);
+ PlayerInfo::setNPCInteractionCount(PlayerInfo::getNPCInteractionCount()
+ - 1);
+
+ npcListener->removeDialog(mNpcId);
}
void NpcDialog::setText(const std::string &text)
@@ -192,26 +217,25 @@ void NpcDialog::action(const gcn::ActionEvent &event)
if (mInputState == NPC_INPUT_LIST)
{
- int choice = 0;
int selectedIndex = mItemList->getSelected();
if (selectedIndex >= (int) mItems.size() || selectedIndex < 0)
- {
return;
- }
- choice = selectedIndex + 1;
+
printText = mItems[selectedIndex];
- Net::getNpcHandler()->listInput(mNpcId, choice);
+ Net::getNpcHandler()->menuSelect(mNpcId, selectedIndex + 1);
}
else if (mInputState == NPC_INPUT_STRING)
{
printText = mTextField->getText();
+
Net::getNpcHandler()->stringInput(mNpcId, printText);
}
else if (mInputState == NPC_INPUT_INTEGER)
{
printText = strprintf("%d", mIntField->getValue());
+
Net::getNpcHandler()->integerInput(mNpcId, mIntField->getValue());
}
// addText will auto remove the input layout
@@ -256,6 +280,7 @@ void NpcDialog::nextDialog()
void NpcDialog::closeDialog()
{
Net::getNpcHandler()->closeDialog(mNpcId);
+ close();
}
int NpcDialog::getNumberOfElements()
@@ -281,15 +306,6 @@ void NpcDialog::addChoice(const std::string &choice)
mItems.push_back(choice);
}
-void NpcDialog::parseListItems(const std::string &itemString)
-{
- std::istringstream iss(itemString);
-
- std::string tmp;
- while (getline(iss, tmp, ':'))
- mItems.push_back(tmp);
-}
-
void NpcDialog::textRequest(const std::string &defaultText)
{
mActionState = NPC_ACTION_INPUT;
@@ -371,11 +387,15 @@ void NpcDialog::setVisible(bool visible)
}
}
-void NpcDialog::optionChanged(const std::string &name)
+void NpcDialog::event(Channels channel, const Mana::Event &event)
{
- if (name == "logNpcInGui")
+ if (channel != CHANNEL_CONFIG)
+ return;
+
+ if (event.getName() == EVENT_CONFIGOPTIONCHANGED &&
+ event.getString("option") == "logNpcInGui")
{
- mLogInteraction = config.getValue("logNpcInGui", true);
+ mLogInteraction = config.getBoolValue("logNpcInGui");
}
}
@@ -409,6 +429,16 @@ void NpcDialog::closeAll()
}
}
+void NpcDialog::setup()
+{
+ if (npcListener)
+ return;
+
+ npcListener = new NpcEventListener();
+
+ npcListener->listen(CHANNEL_NPC);
+}
+
void NpcDialog::buildLayout()
{
clearLayout();
@@ -475,3 +505,123 @@ void NpcDialog::buildLayout()
mScrollArea->setVerticalScrollAmount(mScrollArea->getVerticalMaxScroll());
}
+
+void NpcEventListener::event(Channels channel,
+ const Mana::Event &event)
+{
+ if (channel != CHANNEL_NPC)
+ return;
+
+ if (event.getName() == EVENT_MESSAGE)
+ {
+ NpcDialog *dialog = getDialog(event.getInt("id"));
+
+ dialog->addText(event.getString("text"));
+ }
+ else if (event.getName() == EVENT_MENU)
+ {
+ NpcDialog *dialog = getDialog(event.getInt("id"));
+
+ dialog->choiceRequest();
+
+ int count = event.getInt("choiceCount");
+ for (int i = 1; i <= count; i++)
+ dialog->addChoice(event.getString("choice" + toString(i)));
+ }
+ else if (event.getName() == EVENT_INTEGERINPUT)
+ {
+ NpcDialog *dialog = getDialog(event.getInt("id"));
+
+ int defaultValue = event.getInt("default", 0);
+ int min = event.getInt("min", 0);
+ int max = event.getInt("max", 2147483647);
+
+ dialog->integerRequest(defaultValue, min, max);
+ }
+ else if (event.getName() == EVENT_STRINGINPUT)
+ {
+ NpcDialog *dialog = getDialog(event.getInt("id"));
+
+ try
+ {
+ dialog->textRequest(event.getString("default"));
+ }
+ catch (Mana::BadEvent)
+ {
+ dialog->textRequest("");
+ }
+ }
+ else if (event.getName() == EVENT_NEXT)
+ {
+ int id = event.getInt("id");
+ NpcDialog *dialog = getDialog(id, false);
+
+ if (!dialog)
+ {
+ int mNpcId = id;
+ Net::getNpcHandler()->nextDialog(mNpcId);
+ return;
+ }
+
+ dialog->showNextButton();
+ }
+ else if (event.getName() == EVENT_CLOSE)
+ {
+ int id = event.getInt("id");
+ NpcDialog *dialog = getDialog(id, false);
+
+ if (!dialog)
+ {
+ int mNpcId = id;
+ Net::getNpcHandler()->closeDialog(mNpcId);
+ return;
+ }
+
+ dialog->showCloseButton();
+ }
+ else if (event.getName() == EVENT_CLOSEALL)
+ {
+ NpcDialog::closeAll();
+ }
+ else if (event.getName() == EVENT_END)
+ {
+ int id = event.getInt("id");
+ NpcDialog *dialog = getDialog(id, false);
+
+ if (dialog)
+ dialog->close();
+ }
+ else if (event.getName() == EVENT_POST)
+ {
+ new NpcPostDialog(event.getInt("id"));
+ }
+}
+
+NpcDialog *NpcEventListener::getDialog(int id, bool make)
+{
+ NpcDialogs::iterator diag = mNpcDialogs.find(id);
+ NpcDialog *dialog = 0;
+
+ if (diag == mNpcDialogs.end())
+ {
+ // Empty dialogs don't help
+ if (make)
+ {
+ dialog = new NpcDialog(id);
+ mNpcDialogs[id] = dialog;
+ }
+ }
+ else
+ {
+ dialog = diag->second;
+ }
+
+ return dialog;
+}
+
+void NpcEventListener::removeDialog(int id)
+{
+ NpcDialogs::iterator it = mNpcDialogs.find(id);
+ if (it != mNpcDialogs.end())
+ mNpcDialogs.erase(it);
+}
diff --git a/src/gui/npcdialog.h b/src/gui/npcdialog.h
index 337da6f2..d0131d0e 100644
--- a/src/gui/npcdialog.h
+++ b/src/gui/npcdialog.h
@@ -22,8 +22,7 @@
#ifndef NPCDIALOG_H
#define NPCDIALOG_H
-#include "configlistener.h"
-#include "npc.h"
+#include "listener.h"
#include "gui/widgets/window.h"
@@ -46,7 +45,7 @@ class Button;
* \ingroup Interface
*/
class NpcDialog : public Window, public gcn::ActionListener,
- public gcn::ListModel, public ConfigListener
+ public gcn::ListModel, public Mana::Listener
{
public:
/**
@@ -120,13 +119,6 @@ class NpcDialog : public Window, public gcn::ActionListener,
void addChoice(const std::string &);
/**
- * Fills the options list for an NPC dialog.
- *
- * @param itemString A string with the options separated with colons.
- */
- void parseListItems(const std::string &itemString);
-
- /**
* Requests a text string from the user.
*/
void textRequest(const std::string &defaultText = "");
@@ -140,8 +132,7 @@ class NpcDialog : public Window, public gcn::ActionListener,
/**
* Requests a interger from the user.
*/
- void integerRequest(int defaultValue = 0, int min = 0,
- int max = 2147483647);
+ void integerRequest(int defaultValue, int min, int max);
void move(int amount);
@@ -154,12 +145,7 @@ class NpcDialog : public Window, public gcn::ActionListener,
void setVisible(bool visible);
- void optionChanged(const std::string &name);
-
- /**
- * Returns true if any instances exist.
- */
- static bool isActive() { return instances.size() > 0; }
+ void event(Channels channel, const Mana::Event &event);
/**
* Returns the first active instance. Useful for pushing user
@@ -172,6 +158,8 @@ class NpcDialog : public Window, public gcn::ActionListener,
*/
static void closeAll();
+ static void setup();
+
private:
typedef std::list<NpcDialog*> DialogList;
static DialogList instances;
diff --git a/src/gui/npcpostdialog.cpp b/src/gui/npcpostdialog.cpp
index 19d0cf61..c53203be 100644
--- a/src/gui/npcpostdialog.cpp
+++ b/src/gui/npcpostdialog.cpp
@@ -21,10 +21,10 @@
#include "gui/npcpostdialog.h"
-#include "npc.h"
+#include "event.h"
+#include "playerinfo.h"
#include "gui/widgets/button.h"
-#include "gui/widgets/chattab.h"
#include "gui/widgets/label.h"
#include "gui/widgets/textbox.h"
#include "gui/widgets/textfield.h"
@@ -80,11 +80,14 @@ NpcPostDialog::NpcPostDialog(int npcId):
instances.push_back(this);
setVisible(true);
+
+ PlayerInfo::setNPCPostCount(PlayerInfo::getNPCPostCount() + 1);
}
NpcPostDialog::~NpcPostDialog()
{
instances.remove(this);
+ PlayerInfo::setNPCPostCount(PlayerInfo::getNPCPostCount() - 1);
}
void NpcPostDialog::action(const gcn::ActionEvent &event)
@@ -93,12 +96,12 @@ void NpcPostDialog::action(const gcn::ActionEvent &event)
{
if (mSender->getText().empty() || mText->getText().empty())
{
- localChatTab->chatLog(_("Failed to send as sender or letter "
- "invalid."));
+ SERVER_NOTICE(_("Failed to send as sender or letter invalid."))
}
else
{
- Net::getNpcHandler()->sendLetter(mNpcId, mSender->getText(),
+ Net::getNpcHandler()->sendLetter(mNpcId,
+ mSender->getText(),
mText->getText());
}
setVisible(false);
diff --git a/src/gui/npcpostdialog.h b/src/gui/npcpostdialog.h
index ad0053a3..248e4515 100644
--- a/src/gui/npcpostdialog.h
+++ b/src/gui/npcpostdialog.h
@@ -47,11 +47,6 @@ public:
void setVisible(bool visible);
/**
- * Returns true if any instances exist.
- */
- static bool isActive() { return instances.size() > 0; }
-
- /**
* Closes all instances.
*/
static void closeAll();
diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp
index 89bf47da..8da8914a 100644
--- a/src/gui/outfitwindow.cpp
+++ b/src/gui/outfitwindow.cpp
@@ -22,18 +22,17 @@
#include "outfitwindow.h"
#include "configuration.h"
-#include "localplayer.h"
+#include "equipment.h"
#include "graphics.h"
#include "inventory.h"
-#include "equipment.h"
#include "item.h"
#include "log.h"
+#include "playerinfo.h"
#include "gui/chat.h"
#include "gui/widgets/button.h"
#include "gui/widgets/checkbox.h"
-#include "gui/widgets/chattab.h"
#include "gui/widgets/label.h"
#include "gui/widgets/layout.h"
@@ -41,6 +40,7 @@
#include "net/net.h"
#include "resources/image.h"
+#include "resources/iteminfo.h"
#include "utils/gettext.h"
#include "utils/stringutils.h"
@@ -168,11 +168,11 @@ void OutfitWindow::wearOutfit(int outfit)
Item *item;
for (int i = 0; i < OUTFIT_ITEM_COUNT; i++)
{
- item = player_node->getInventory()->findItem(mItems[outfit][i]);
+ item = PlayerInfo::getInventory()->findItem(mItems[outfit][i]);
if (item && !item->isEquipped() && item->getQuantity())
{
- if (item->isEquipment())
- Net::getInventoryHandler()->equipItem(item);
+ if (item->isEquippable())
+ item->doEvent(EVENT_DOEQUIP);
}
}
}
@@ -206,7 +206,7 @@ void OutfitWindow::draw(gcn::Graphics *graphics)
}
Item *item =
- player_node->getInventory()->findItem(mItems[mCurrentOutfit][i]);
+ PlayerInfo::getInventory()->findItem(mItems[mCurrentOutfit][i]);
if (item)
{
// Draw item icon.
@@ -245,7 +245,7 @@ void OutfitWindow::mouseDragged(gcn::MouseEvent &event)
const int itemId = mItems[mCurrentOutfit][index];
if (itemId < 0)
return;
- Item *item = player_node->getInventory()->findItem(itemId);
+ Item *item = PlayerInfo::getInventory()->findItem(itemId);
if (item)
{
mItemMoved = item;
@@ -319,7 +319,7 @@ int OutfitWindow::getIndexFromGrid(int pointX, int pointY) const
void OutfitWindow::unequipNotInOutfit(int outfit)
{
- Inventory *inventory = player_node->getInventory();
+ Inventory *inventory = PlayerInfo::getInventory();
if (!inventory)
return;
@@ -338,7 +338,10 @@ void OutfitWindow::unequipNotInOutfit(int outfit)
}
if (!found)
{
- Net::getInventoryHandler()->unequipItem(inventory->getItem(i));
+ Item *item = inventory->getItem(i);
+
+ if (item)
+ item->doEvent(EVENT_DOUNEQUIP);
}
}
}
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index 409a0eda..8ff638c2 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -21,14 +21,14 @@
#include "gui/popupmenu.h"
+#include "actorspritemanager.h"
#include "being.h"
-#include "beingmanager.h"
#include "flooritem.h"
#include "graphics.h"
#include "item.h"
#include "localplayer.h"
#include "log.h"
-#include "npc.h"
+#include "playerinfo.h"
#include "playerrelations.h"
#include "gui/chat.h"
@@ -76,7 +76,7 @@ void PopupMenu::showPopup(int x, int y, Being *being)
switch (being->getType())
{
- case Being::PLAYER:
+ case ActorSprite::PLAYER:
{
// Players can be traded with.
mBrowserBox->addRow(strprintf("@@trade|%s@@",
@@ -143,7 +143,7 @@ void PopupMenu::showPopup(int x, int y, Being *being)
}
break;
- case Being::NPC:
+ case ActorSprite::NPC:
// NPCs can be talked to (single option, candidate for removal
// unless more options would be added)
mBrowserBox->addRow(strprintf("@@talk|%s@@",
@@ -151,7 +151,7 @@ void PopupMenu::showPopup(int x, int y, Being *being)
name.c_str()).c_str()));
break;
- case Being::MONSTER:
+ case ActorSprite::MONSTER:
{
// Monsters can be attacked
mBrowserBox->addRow(strprintf("@@attack|%s@@",
@@ -180,11 +180,11 @@ void PopupMenu::showPopup(int x, int y, Being *being)
void PopupMenu::showPopup(int x, int y, FloorItem *floorItem)
{
mFloorItem = floorItem;
- mItem = floorItem->getItem();
+ ItemInfo info = floorItem->getInfo();
mBrowserBox->clearRows();
// Floor item can be picked up (single option, candidate for removal)
- std::string name = ItemDB::get(mFloorItem->getItemId()).getName();
+ std::string name = info.getName();
mBrowserBox->addRow(strprintf("@@pickup|%s@@", strprintf(_("Pick up %s"),
name.c_str()).c_str()));
mBrowserBox->addRow(strprintf("@@chat|%s@@", _("Add to chat")));
@@ -198,16 +198,17 @@ void PopupMenu::showPopup(int x, int y, FloorItem *floorItem)
void PopupMenu::handleLink(const std::string &link)
{
- Being *being = beingManager->findBeing(mBeingId);
+ Being *being = actorSpriteManager->findBeing(mBeingId);
// Talk To action
- if (link == "talk" && being && being->getType() == Being::NPC)
+ if (link == "talk" && being && being->canTalk())
{
- static_cast<NPC*>(being)->talk();
+ being->talkTo();
}
// Trade action
- else if (link == "trade" && being && being->getType() == Being::PLAYER)
+ else if (link == "trade" && being &&
+ being->getType() == ActorSprite::PLAYER)
{
Net::getTradeHandler()->request(being);
tradePartnerName = being->getName();
@@ -221,27 +222,32 @@ void PopupMenu::handleLink(const std::string &link)
{
chatWindow->addInputText("/w \"" + being->getName() + "\" ");
}
- else if (link == "unignore" && being && being->getType() == Being::PLAYER)
+ else if (link == "unignore" && being &&
+ being->getType() == ActorSprite::PLAYER)
{
player_relations.setRelation(being->getName(), PlayerRelation::NEUTRAL);
}
- else if (link == "ignore" && being && being->getType() == Being::PLAYER)
+ else if (link == "ignore" && being &&
+ being->getType() == ActorSprite::PLAYER)
{
player_relations.setRelation(being->getName(), PlayerRelation::IGNORED);
}
- else if (link == "disregard" && being && being->getType() == Being::PLAYER)
+ else if (link == "disregard" && being &&
+ being->getType() == ActorSprite::PLAYER)
{
player_relations.setRelation(being->getName(), PlayerRelation::DISREGARDED);
}
- else if (link == "friend" && being && being->getType() == Being::PLAYER)
+ else if (link == "friend" && being &&
+ being->getType() == ActorSprite::PLAYER)
{
player_relations.setRelation(being->getName(), PlayerRelation::FRIEND);
}
// Guild action
- else if (link == "guild" && being && being->getType() == Being::PLAYER)
+ else if (link == "guild" && being &&
+ being->getType() == ActorSprite::PLAYER)
{
player_node->inviteToGuild(being);
}
@@ -257,25 +263,27 @@ void PopupMenu::handleLink(const std::string &link)
{
}
- else if (link == "use")
+ else if (link == "activate")
{
assert(mItem);
- if (mItem->isEquipment())
+ if (mItem->isEquippable())
{
if (mItem->isEquipped())
- Net::getInventoryHandler()->unequipItem(mItem);
+ mItem->doEvent(EVENT_DOUNEQUIP);
else
- Net::getInventoryHandler()->equipItem(mItem);
+ mItem->doEvent(EVENT_DOEQUIP);
}
else
{
- Net::getInventoryHandler()->useItem(mItem);
+ mItem->doEvent(EVENT_DOUSE);
}
}
-
else if (link == "chat")
{
- chatWindow->addItemText(mItem->getInfo().getName());
+ if (mItem)
+ chatWindow->addItemText(mItem->getInfo().getName());
+ else if (mFloorItem)
+ chatWindow->addItemText(mFloorItem->getInfo().getName());
}
else if (link == "split")
@@ -302,9 +310,10 @@ void PopupMenu::handleLink(const std::string &link)
mItem);
}
- else if (link == "party" && being && being->getType() == Being::PLAYER)
+ else if (link == "party" && being &&
+ being->getType() == ActorSprite::PLAYER)
{
- Net::getPartyHandler()->invite(static_cast<Player*>(being));
+ Net::getPartyHandler()->invite(being);
}
else if (link == "name" && being)
@@ -315,8 +324,8 @@ void PopupMenu::handleLink(const std::string &link)
else if (link == "admin-kick" &&
being &&
- (being->getType() == Being::PLAYER ||
- being->getType() == Being::MONSTER))
+ (being->getType() == ActorSprite::PLAYER ||
+ being->getType() == ActorSprite::MONSTER))
{
Net::getAdminHandler()->kick(being->getId());
}
@@ -344,15 +353,15 @@ void PopupMenu::showPopup(Window *parent, int x, int y, Item *item,
if (isInventory)
{
- if (item->isEquipment())
+ if (item->getInfo().getEquippable())
{
if (item->isEquipped())
- mBrowserBox->addRow(strprintf("@@use|%s@@", _("Unequip")));
+ mBrowserBox->addRow(strprintf("@@equip|%s@@", _("Unequip")));
else
- mBrowserBox->addRow(strprintf("@@use|%s@@", _("Equip")));
+ mBrowserBox->addRow(strprintf("@@equip|%s@@", _("Equip")));
}
- else
- mBrowserBox->addRow(strprintf("@@use|%s@@", _("Use")));
+ if (item->getInfo().getActivatable())
+ mBrowserBox->addRow(strprintf("@@activate|%s@@", _("Activate")));
if (item->getQuantity() > 1)
mBrowserBox->addRow(strprintf("@@drop|%s@@", _("Drop...")));
@@ -364,7 +373,7 @@ void PopupMenu::showPopup(Window *parent, int x, int y, Item *item,
mBrowserBox->addRow(strprintf("@@split|%s@@", _("Split")));
}
- if (InventoryWindow::isStorageActive())
+ if (PlayerInfo::getStorageCount() > 0)
{
mBrowserBox->addRow(strprintf("@@store|%s@@", _("Store")));
}
diff --git a/src/gui/quitdialog.h b/src/gui/quitdialog.h
index 8fa1052c..d0dc2c69 100644
--- a/src/gui/quitdialog.h
+++ b/src/gui/quitdialog.h
@@ -22,8 +22,6 @@
#ifndef QUITDIALOG_H
#define QUITDIALOG_H
-#include "guichanfwd.h"
-
#include "gui/widgets/window.h"
#include <guichan/actionlistener.hpp>
diff --git a/src/gui/recorder.cpp b/src/gui/recorder.cpp
index 257afd7f..2345369e 100644
--- a/src/gui/recorder.cpp
+++ b/src/gui/recorder.cpp
@@ -21,11 +21,11 @@
#include "gui/recorder.h"
#include "client.h"
+#include "event.h"
#include "gui/chat.h"
#include "gui/widgets/button.h"
-#include "gui/widgets/chattab.h"
#include "gui/widgets/layout.h"
#include "gui/widgets/windowcontainer.h"
@@ -84,16 +84,16 @@ void Recorder::setRecordingFile(const std::string &msg)
* Message should go after mStream is closed so that it isn't
* recorded.
*/
- localChatTab->chatLog(_("Finishing recording."), BY_SERVER);
+ SERVER_NOTICE(_("Finishing recording."))
}
else
{
- localChatTab->chatLog(_("Not currently recording."), BY_SERVER);
+ SERVER_NOTICE(_("Not currently recording."))
}
}
else if (mStream.is_open())
{
- localChatTab->chatLog(_("Already recording."), BY_SERVER);
+ SERVER_NOTICE(_("Already recording."))
}
else
{
@@ -101,7 +101,7 @@ void Recorder::setRecordingFile(const std::string &msg)
* Message should go before mStream is opened so that it isn't
* recorded.
*/
- localChatTab->chatLog(_("Starting to record..."), BY_SERVER);
+ SERVER_NOTICE(_("Starting to record..."))
const std::string file = Client::getLocalDataDirectory() + "/" + msgCopy;
mStream.open(file.c_str(), std::ios_base::trunc);
@@ -109,7 +109,7 @@ void Recorder::setRecordingFile(const std::string &msg)
if (mStream.is_open())
setVisible(true);
else
- localChatTab->chatLog(_("Failed to start recording."), BY_SERVER);
+ SERVER_NOTICE(_("Failed to start recording."))
}
}
diff --git a/src/gui/register.h b/src/gui/register.h
index 645b0be8..3c65695b 100644
--- a/src/gui/register.h
+++ b/src/gui/register.h
@@ -22,8 +22,6 @@
#ifndef REGISTER_H
#define REGISTER_H
-#include "player.h"
-
#include "gui/widgets/window.h"
#include <guichan/actionlistener.hpp>
diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp
index 13e0ba99..f33111d7 100644
--- a/src/gui/sell.cpp
+++ b/src/gui/sell.cpp
@@ -21,7 +21,7 @@
#include "gui/sell.h"
-#include "npc.h"
+#include "playerinfo.h"
#include "shopitem.h"
#include "units.h"
@@ -111,6 +111,8 @@ SellDialog::SellDialog(int npcId):
instances.push_back(this);
setVisible(true);
+
+ PlayerInfo::setBuySellState(BUYSELL_SELLING);
}
SellDialog::~SellDialog()
@@ -118,6 +120,9 @@ SellDialog::~SellDialog()
delete mShopItems;
instances.remove(this);
+
+ if (PlayerInfo::getBuySellState() == BUYSELL_SELLING)
+ PlayerInfo::setBuySellState(BUYSELL_NONE);
}
void SellDialog::reset()
@@ -197,6 +202,11 @@ void SellDialog::action(const gcn::ActionEvent &event)
// the inventory index of the next Duplicate otherwise.
itemIndex = item->getCurrentInvIndex();
sellCount = item->sellCurrentDuplicate(mAmountItems);
+
+ // For Manaserv, the Item id is to be given as index.
+ if ((Net::getNetworkType() == ServerInfo::MANASERV))
+ itemIndex = item->getId();
+
Net::getNpcHandler()->sellItem(mNpcId, itemIndex, sellCount);
mAmountItems -= sellCount;
}
diff --git a/src/gui/sell.h b/src/gui/sell.h
index 32a4dc55..c286dcc2 100644
--- a/src/gui/sell.h
+++ b/src/gui/sell.h
@@ -86,11 +86,6 @@ class SellDialog : public Window, gcn::ActionListener, gcn::SelectionListener
void setVisible(bool visible);
/**
- * Returns true if any instances exist.
- */
- static bool isActive() { return instances.size() > 0; }
-
- /**
* Closes all instances.
*/
static void closeAll();
diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp
index abe898b0..ca8da9b4 100644
--- a/src/gui/serverdialog.cpp
+++ b/src/gui/serverdialog.cpp
@@ -21,6 +21,7 @@
#include "gui/serverdialog.h"
+#include "chatlog.h"
#include "client.h"
#include "configuration.h"
#include "gui.h"
@@ -29,7 +30,6 @@
#include "gui/okdialog.h"
#include "gui/sdlinput.h"
-#include "gui/theme.h"
#include "gui/widgets/button.h"
#include "gui/widgets/dropdown.h"
@@ -41,10 +41,11 @@
#include "net/net.h"
+#include "resources/theme.h"
+
#include "utils/gettext.h"
#include "utils/stringutils.h"
#include "utils/xml.h"
-#include "widgets/dropdown.h"
#include <guichan/font.hpp>
@@ -198,18 +199,13 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir):
mDownloadStatus(DOWNLOADING_PREPARING),
mDownloadProgress(-1.0f),
mServers(ServerInfos()),
-#ifndef MANASERV_SUPPORT
- mManaservServers(ServerInfos()),
-#endif
mServerInfo(serverInfo)
{
setWindowName("ServerDialog");
Label *serverLabel = new Label(_("Server:"));
Label *portLabel = new Label(_("Port:"));
-#ifdef MANASERV_SUPPORT
Label *typeLabel = new Label(_("Server type:"));
-#endif
mServerNameField = new TextField(mServerInfo->hostname);
mPortField = new TextField(toString(mServerInfo->port));
@@ -247,7 +243,6 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir):
place(1, 0, mServerNameField, 4).setPadding(3);
place(0, 1, portLabel);
place(1, 1, mPortField, 4).setPadding(3);
-#ifdef MANASERV_SUPPORT
place(0, 2, typeLabel);
place(1, 2, mTypeField, 4).setPadding(3);
place(0, 3, usedScroll, 5, 5).setPadding(3);
@@ -256,14 +251,6 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir):
place(1, 9, mDeleteButton);
place(3, 9, mQuitButton);
place(4, 9, mConnectButton);
-#else
- place(0, 2, usedScroll, 5, 5).setPadding(3);
- place(0, 7, mDescription, 5);
- place(0, 8, mManualEntryButton);
- place(1, 8, mDeleteButton);
- place(3, 8, mQuitButton);
- place(4, 8, mConnectButton);
-#endif
// Make sure the list has enough height
getLayout().setRowHeight(3, 80);
@@ -360,6 +347,8 @@ void ServerDialog::action(const gcn::ActionEvent &event)
// Save the selected server
mServerInfo->save = true;
+ chatLogger->setServerName(mServerInfo->hostname);
+
saveCustomServers(*mServerInfo);
Client::setState(STATE_CONNECT_SERVER);
@@ -427,6 +416,16 @@ void ServerDialog::valueChanged(const gcn::SelectionEvent &)
mDeleteButton->setEnabled(myServer.save);
}
+void ServerDialog::mouseClicked(gcn::MouseEvent &mouseEvent)
+{
+ if (mouseEvent.getSource() == mServersList &&
+ isDoubleClick(mServersList->getSelected()))
+ {
+ action(gcn::ActionEvent(mConnectButton,
+ mConnectButton->getActionEventId()));
+ }
+}
+
void ServerDialog::logic()
{
{
@@ -468,12 +467,7 @@ void ServerDialog::setFieldsReadOnly(bool readOnly)
mServersList->setSelected(-1);
mServerNameField->setText(std::string());
-#ifdef MANASERV_SUPPORT
mPortField->setText(std::string());
-#else
- mPortField->setText(std::string("6901"));
-#endif
-
mServerNameField->requestFocus();
}
@@ -489,10 +483,10 @@ void ServerDialog::setFieldsReadOnly(bool readOnly)
void ServerDialog::downloadServerList()
{
// Try to load the configuration value for the onlineServerList
- std::string listFile = branding.getValue("onlineServerList", std::string());
+ std::string listFile = branding.getStringValue("onlineServerList");
if (listFile.empty())
- listFile = config.getValue("onlineServerList", std::string());
+ listFile = config.getStringValue("onlineServerList");
// Fall back to manasource.org when neither branding nor config set it
if (listFile.empty())
@@ -594,11 +588,7 @@ void ServerDialog::loadServers()
}
}
-#ifdef MANASERV_SUPPORT
if (!found)
-#else
- if (!found && server.type != ServerInfo::MANASERV)
-#endif
mServers.push_back(server);
}
}
@@ -625,14 +615,7 @@ void ServerDialog::loadCustomServers()
server.save = true;
-#ifdef MANASERV_SUPPORT
mServers.push_back(server);
-#else
- if (server.type == ServerInfo::MANASERV)
- mManaservServers.push_back(server);
- else
- mServers.push_back(server);
-#endif
}
}
@@ -675,27 +658,6 @@ void ServerDialog::saveCustomServers(const ServerInfo &currentServer)
++savedServerCount;
}
-#ifndef MANASERV_SUPPORT
- for (unsigned i = 0;
- i < mManaservServers.size() && savedServerCount < MAX_SERVERLIST; ++i)
- {
- const ServerInfo &server = mManaservServers.at(i);
-
- // Only save servers that were loaded from settings
- if (!(server.save && server.isValid()))
- continue;
-
- const std::string index = toString(savedServerCount);
- const std::string nameKey = "MostUsedServerName" + index;
- const std::string typeKey = "MostUsedServerType" + index;
- const std::string portKey = "MostUsedServerPort" + index;
-
- config.setValue(nameKey, toString(server.hostname));
- config.setValue(typeKey, serverTypeToString(server.type));
- config.setValue(portKey, toString(server.port));
- ++savedServerCount;
- }
-#endif
// Insert an invalid entry at the end to make the loading stop there
if (savedServerCount < MAX_SERVERLIST)
config.setValue("MostUsedServerName" + toString(savedServerCount), "");
diff --git a/src/gui/serverdialog.h b/src/gui/serverdialog.h
index aae8b2e0..f1d9c9b8 100644
--- a/src/gui/serverdialog.h
+++ b/src/gui/serverdialog.h
@@ -135,6 +135,8 @@ class ServerDialog : public Window,
*/
void valueChanged(const gcn::SelectionEvent &event);
+ void mouseClicked(gcn::MouseEvent &mouseEvent);
+
void logic();
protected:
@@ -191,9 +193,6 @@ class ServerDialog : public Window,
float mDownloadProgress;
ServerInfos mServers;
-#ifndef MANASERV_SUPPORT
- ServerInfos mManaservServers;
-#endif
ServerInfo *mServerInfo;
};
diff --git a/src/gui/setup.h b/src/gui/setup.h
index 43e83a68..4be94bb8 100644
--- a/src/gui/setup.h
+++ b/src/gui/setup.h
@@ -22,8 +22,6 @@
#ifndef SETUP_H
#define SETUP_H
-#include "guichanfwd.h"
-
#include "gui/widgets/window.h"
#include <guichan/actionlistener.hpp>
diff --git a/src/gui/setup_audio.cpp b/src/gui/setup_audio.cpp
index 2c6b89e8..8e9f5e98 100644
--- a/src/gui/setup_audio.cpp
+++ b/src/gui/setup_audio.cpp
@@ -35,10 +35,10 @@
#include "utils/gettext.h"
Setup_Audio::Setup_Audio():
- mMusicVolume((int)config.getValue("musicVolume", 60)),
- mSfxVolume((int)config.getValue("sfxVolume", 100)),
- mSoundEnabled(config.getValue("sound", 0)),
- mDownloadEnabled(config.getValue("download-music", false)),
+ mMusicVolume(config.getIntValue("musicVolume")),
+ mSfxVolume(config.getIntValue("sfxVolume")),
+ mSoundEnabled(config.getBoolValue("sound")),
+ mDownloadEnabled(config.getBoolValue("download-music")),
mSoundCheckBox(new CheckBox(_("Sound"), mSoundEnabled)),
mDownloadMusicCheckBox(new CheckBox(_("Download music"), mDownloadEnabled)),
mSfxSlider(new Slider(0, sound.getMaxVolume())),
@@ -82,14 +82,14 @@ void Setup_Audio::apply()
{
mSoundEnabled = mSoundCheckBox->isSelected();
mDownloadEnabled = mDownloadMusicCheckBox->isSelected();
- mSfxVolume = (int) config.getValue("sfxVolume", 100);
- mMusicVolume = (int) config.getValue("musicVolume", 60);
+ mSfxVolume = config.getIntValue("sfxVolume");
+ mMusicVolume = config.getIntValue("musicVolume");
config.setValue("sound", mSoundEnabled);
// Display a message if user has selected to download music,
// And if downloadmusic is not already enabled
- if (mDownloadEnabled && !config.getValue("download-music", false))
+ if (mDownloadEnabled && !config.getBoolValue("download-music"))
{
new OkDialog(_("Notice"),_("You may have to restart your client if you want to download new music"));
}
diff --git a/src/gui/setup_colors.cpp b/src/gui/setup_colors.cpp
index 12dba82a..6b3b3fec 100644
--- a/src/gui/setup_colors.cpp
+++ b/src/gui/setup_colors.cpp
@@ -23,8 +23,6 @@
#include "configuration.h"
#include "gui/gui.h"
-#include "gui/theme.h"
-#include "gui/userpalette.h"
#include "gui/widgets/browserbox.h"
#include "gui/widgets/itemlinkhandler.h"
@@ -36,6 +34,9 @@
#include "gui/widgets/textfield.h"
#include "gui/widgets/textpreview.h"
+#include "resources/theme.h"
+#include "resources/userpalette.h"
+
#include "utils/gettext.h"
#include "utils/stringutils.h"
diff --git a/src/gui/setup_joystick.cpp b/src/gui/setup_joystick.cpp
index 965f5712..7ac5b5ed 100644
--- a/src/gui/setup_joystick.cpp
+++ b/src/gui/setup_joystick.cpp
@@ -40,7 +40,7 @@ Setup_Joystick::Setup_Joystick():
{
setName(_("Joystick"));
- mOriginalJoystickEnabled = !config.getValue("joystickEnabled", false);
+ mOriginalJoystickEnabled = !config.getBoolValue("joystickEnabled");
mJoystickEnabled->setSelected(mOriginalJoystickEnabled);
mJoystickEnabled->addActionListener(this);
diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp
index 93551689..e1948bb0 100644
--- a/src/gui/setup_players.cpp
+++ b/src/gui/setup_players.cpp
@@ -21,7 +21,7 @@
#include "gui/setup_players.h"
-#include "beingmanager.h"
+#include "actorspritemanager.h"
#include "configuration.h"
#include "log.h"
@@ -214,6 +214,7 @@ public:
#define ACTION_STRATEGY "strategy"
#define ACTION_WHISPER_TAB "whisper tab"
#define ACTION_SHOW_GENDER "show gender"
+#define ACTION_ENABLE_CHAT_LOG "enable log"
Setup_Players::Setup_Players():
mPlayerTableTitleModel(new StaticTableModel(1, COLUMNS_NR)),
@@ -226,10 +227,12 @@ Setup_Players::Setup_Players():
mDefaultWhisper(new CheckBox(_("Allow whispers"),
player_relations.getDefault() & PlayerRelation::WHISPER)),
mDeleteButton(new Button(_("Delete"), ACTION_DELETE, this)),
- mWhisperTab(config.getValue("whispertab", false)),
+ mWhisperTab(config.getBoolValue("whispertab")),
mWhisperTabCheckBox(new CheckBox(_("Put all whispers in tabs"), mWhisperTab)),
- mShowGender(config.getValue("showgender", false)),
- mShowGenderCheckBox(new CheckBox(_("Show gender"), mShowGender))
+ mShowGender(config.getBoolValue("showgender")),
+ mShowGenderCheckBox(new CheckBox(_("Show gender"), mShowGender)),
+ mEnableChatLog(config.getBoolValue("enableChatLog")),
+ mEnableChatLogCheckBox(new CheckBox(_("Enable Chat log"), mEnableChatLog))
{
setName(_("Players"));
@@ -279,6 +282,9 @@ Setup_Players::Setup_Players():
mShowGenderCheckBox->setActionEventId(ACTION_SHOW_GENDER);
mShowGenderCheckBox->addActionListener(this);
+ mEnableChatLogCheckBox->setActionEventId(ACTION_ENABLE_CHAT_LOG);
+ mEnableChatLogCheckBox->addActionListener(this);
+
reset();
// Do the layout
@@ -289,11 +295,12 @@ Setup_Players::Setup_Players():
place(0, 1, mPlayerScrollArea, 4, 4).setPadding(2);
place(0, 5, mDeleteButton);
place(0, 6, mShowGenderCheckBox, 2).setPadding(2);
+ place(0, 7, mEnableChatLogCheckBox, 2).setPadding(2);
place(2, 5, ignore_action_label);
place(2, 6, mIgnoreActionChoicesBox, 2).setPadding(2);
- place(0, 7, mDefaultTrading);
- place(0, 8, mDefaultWhisper);
- place(0, 9, mWhisperTabCheckBox, 4).setPadding(4);
+ place(0, 8, mDefaultTrading);
+ place(0, 9, mDefaultWhisper);
+ place(0, 10, mWhisperTabCheckBox, 4).setPadding(4);
player_relations.addListener(this);
@@ -341,20 +348,24 @@ void Setup_Players::apply()
PlayerRelation::WHISPER : 0));
config.setValue("whispertab", mWhisperTab);
- bool showGender = config.getValue("showgender", false);
+ bool showGender = config.getBoolValue("showgender");
config.setValue("showgender", mShowGender);
- if (beingManager && mShowGender != showGender)
- beingManager->updatePlayerNames();
+ if (actorSpriteManager && mShowGender != showGender)
+ actorSpriteManager->updatePlayerNames();
+
+ config.setValue("enableChatLog", mEnableChatLog);
}
void Setup_Players::cancel()
{
- mWhisperTab = config.getValue("whispertab", false);
+ mWhisperTab = config.getBoolValue("whispertab");
mWhisperTabCheckBox->setSelected(mWhisperTab);
- mShowGender = config.getValue("showgender", false);
+ mShowGender = config.getBoolValue("showgender");
mShowGenderCheckBox->setSelected(mShowGender);
+ mEnableChatLog = config.getBoolValue("enableChatLog");
+ mEnableChatLogCheckBox->setSelected(mEnableChatLog);
}
void Setup_Players::action(const gcn::ActionEvent &event)
@@ -402,6 +413,10 @@ void Setup_Players::action(const gcn::ActionEvent &event)
{
mShowGender = mShowGenderCheckBox->isSelected();
}
+ else if (event.getId() == ACTION_ENABLE_CHAT_LOG)
+ {
+ mEnableChatLog = mEnableChatLogCheckBox->isSelected();
+ }
}
void Setup_Players::updatedPlayer(const std::string &name)
diff --git a/src/gui/setup_players.h b/src/gui/setup_players.h
index 5337b213..a62ffe1f 100644
--- a/src/gui/setup_players.h
+++ b/src/gui/setup_players.h
@@ -70,6 +70,9 @@ private:
bool mShowGender;
gcn::CheckBox *mShowGenderCheckBox;
+
+ bool mEnableChatLog;
+ gcn::CheckBox *mEnableChatLogCheckBox;
};
#endif
diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp
index 1a5e17b6..c8af218f 100644
--- a/src/gui/setup_video.cpp
+++ b/src/gui/setup_video.cpp
@@ -171,7 +171,7 @@ static const char *speechModeToString(Being::Speech mode)
const char *Setup_Video::overlayDetailToString(int detail)
{
if (detail == -1)
- detail = config.getValue("OverlayDetail", -1);
+ detail = config.getIntValue("OverlayDetail");
switch (detail)
{
@@ -185,7 +185,7 @@ const char *Setup_Video::overlayDetailToString(int detail)
const char *Setup_Video::particleDetailToString(int detail)
{
if (detail == -1)
- detail = 3 - config.getValue("particleEmitterSkip", -1);
+ detail = 3 - config.getIntValue("particleEmitterSkip");
switch (detail)
{
@@ -198,22 +198,20 @@ const char *Setup_Video::particleDetailToString(int detail)
}
Setup_Video::Setup_Video():
- mFullScreenEnabled(config.getValue("screen", false)),
- mOpenGLEnabled(config.getValue("opengl", false)),
- mCustomCursorEnabled(config.getValue("customcursor", true)),
- mShowMonsterDamageEnabled(config.getValue("showMonstersTakedDamage",
- false)),
- mVisibleNamesEnabled(config.getValue("visiblenames", true)),
- mParticleEffectsEnabled(config.getValue("particleeffects", true)),
- mNameEnabled(config.getValue("showownname", false)),
- mNPCLogEnabled(config.getValue("logNpcInGui", true)),
- mPickupChatEnabled(config.getValue("showpickupchat", true)),
- mPickupParticleEnabled(config.getValue("showpickupparticle", false)),
- mOpacity(config.getValue("guialpha", 0.8)),
- mFps((int) config.getValue("fpslimit", 60)),
- mSDLTransparencyDisabled(config.getValue("disableTransparency", true)),
- mSpeechMode(static_cast<Being::Speech>(
- config.getValue("speech", Being::TEXT_OVERHEAD))),
+ mFullScreenEnabled(config.getBoolValue("screen")),
+ mOpenGLEnabled(config.getBoolValue("opengl")),
+ mCustomCursorEnabled(config.getBoolValue("customcursor")),
+ mShowMonsterDamageEnabled(config.getBoolValue("showMonstersTakedDamage")),
+ mVisibleNamesEnabled(config.getBoolValue("visiblenames")),
+ mParticleEffectsEnabled(config.getBoolValue("particleeffects")),
+ mNameEnabled(config.getBoolValue("showownname")),
+ mNPCLogEnabled(config.getBoolValue("logNpcInGui")),
+ mPickupChatEnabled(config.getBoolValue("showpickupchat")),
+ mPickupParticleEnabled(config.getBoolValue("showpickupparticle")),
+ mOpacity(config.getFloatValue("guialpha")),
+ mFps(config.getIntValue("fpslimit")),
+ mSDLTransparencyDisabled(config.getBoolValue("disableTransparency")),
+ mSpeechMode(static_cast<Being::Speech>(config.getIntValue("speech"))),
mModeListModel(new ModeListModel),
mModeList(new ListBox(mModeListModel)),
mFsCheckBox(new CheckBox(_("Full screen"), mFullScreenEnabled)),
@@ -238,13 +236,13 @@ Setup_Video::Setup_Video():
mFpsCheckBox(new CheckBox(_("FPS limit:"))),
mFpsSlider(new Slider(10, 120)),
mFpsLabel(new Label),
- mOverlayDetail((int) config.getValue("OverlayDetail", 2)),
+ mOverlayDetail(config.getIntValue("OverlayDetail")),
mOverlayDetailSlider(new Slider(0, 2)),
mOverlayDetailField(new Label),
- mParticleDetail(3 - (int) config.getValue("particleEmitterSkip", 1)),
+ mParticleDetail(3 - config.getIntValue("particleEmitterSkip")),
mParticleDetailSlider(new Slider(0, 3)),
mParticleDetailField(new Label),
- mFontSize((int) config.getValue("fontSize", 11)),
+ mFontSize(config.getIntValue("fontSize")),
mDisableSDLTransparencyCheckBox(
new CheckBox(_("Disable transparency (Low CPU mode)"),
mSDLTransparencyDisabled))
@@ -403,7 +401,7 @@ void Setup_Video::apply()
{
// Full screen changes
bool fullscreen = mFsCheckBox->isSelected();
- if (fullscreen != (config.getValue("screen", false) == 1))
+ if (fullscreen != config.getBoolValue("screen"))
{
/* The OpenGL test is only necessary on Windows, since switching
* to/from full screen works fine on Linux. On Windows we'd have to
@@ -414,7 +412,7 @@ void Setup_Video::apply()
#if defined(WIN32) || defined(__APPLE__)
// checks for opengl usage
- if (!(config.getValue("opengl", false) == 1))
+ if (!config.getBoolValue("opengl"))
{
#endif
if (!graphics->setFullscreen(fullscreen))
@@ -497,21 +495,20 @@ void Setup_Video::apply()
config.setValue("fontSize", mFontSizeDropDown->getSelected() + 10);
// We sync old and new values at apply time
- mFullScreenEnabled = config.getValue("screen", false);
- mCustomCursorEnabled = config.getValue("customcursor", true);
- mShowMonsterDamageEnabled = config.getValue("showMonstersTakedDamage", false);
- mVisibleNamesEnabled = config.getValue("visiblenames", true);
- mParticleEffectsEnabled = config.getValue("particleeffects", true);
- mNameEnabled = config.getValue("showownname", false);
- mNPCLogEnabled = config.getValue("logNpcInGui", true);
- mSpeechMode = static_cast<Being::Speech>(
- config.getValue("speech", Being::TEXT_OVERHEAD));
- mOpacity = config.getValue("guialpha", 0.8);
- mOverlayDetail = (int) config.getValue("OverlayDetail", 2);
- mOpenGLEnabled = config.getValue("opengl", false);
- mPickupChatEnabled = config.getValue("showpickupchat", true);
- mPickupParticleEnabled = config.getValue("showpickupparticle", false);
- mSDLTransparencyDisabled = config.getValue("disableTransparency", true);
+ mFullScreenEnabled = config.getBoolValue("screen");
+ mCustomCursorEnabled = config.getBoolValue("customcursor");
+ mShowMonsterDamageEnabled = config.getBoolValue("showMonstersTakedDamage");
+ mVisibleNamesEnabled = config.getBoolValue("visiblenames");
+ mParticleEffectsEnabled = config.getBoolValue("particleeffects");
+ mNameEnabled = config.getBoolValue("showownname");
+ mNPCLogEnabled = config.getBoolValue("logNpcInGui");
+ mSpeechMode = static_cast<Being::Speech>(config.getIntValue("speech"));
+ mOpacity = config.getFloatValue("guialpha");
+ mOverlayDetail = config.getIntValue("OverlayDetail");
+ mOpenGLEnabled = config.getBoolValue("opengl");
+ mPickupChatEnabled = config.getBoolValue("showpickupchat");
+ mPickupParticleEnabled = config.getBoolValue("showpickupparticle");
+ mSDLTransparencyDisabled = config.getBoolValue("disableTransparency");
}
void Setup_Video::cancel()
diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp
index 207e3ded..be46132e 100644
--- a/src/gui/skilldialog.cpp
+++ b/src/gui/skilldialog.cpp
@@ -21,11 +21,11 @@
#include "gui/skilldialog.h"
-#include "localplayer.h"
#include "log.h"
+#include "playerinfo.h"
+#include "configuration.h"
#include "gui/setup.h"
-#include "gui/theme.h"
#include "gui/widgets/button.h"
#include "gui/widgets/container.h"
@@ -43,6 +43,7 @@
#include "resources/image.h"
#include "resources/resourcemanager.h"
+#include "resources/theme.h"
#include "utils/dtor.h"
#include "utils/gettext.h"
@@ -93,7 +94,8 @@ struct SkillInfo
if (!icon)
{
- icon = Theme::getImageFromTheme("unknown-item.png");
+ icon = Theme::getImageFromTheme(
+ paths.getStringValue("unknownItemFile"));
}
}
@@ -246,10 +248,6 @@ void SkillDialog::action(const gcn::ActionEvent &event)
{
setVisible(false);
}
- else
- {
- printf("Unknown event '%s'\n", event.getId().c_str());
- }
}
std::string SkillDialog::update(int id)
@@ -269,7 +267,7 @@ std::string SkillDialog::update(int id)
void SkillDialog::update()
{
mPointsLabel->setCaption(strprintf(_("Skill points available: %d"),
- player_node->getSkillPoints()));
+ PlayerInfo::getAttribute(SKILL_POINTS)));
mPointsLabel->adjustSize();
for (SkillMap::iterator it = mSkills.begin(); it != mSkills.end(); it++)
@@ -420,10 +418,10 @@ void SkillModel::updateVisibilities()
void SkillInfo::update()
{
- int baseLevel = player_node->getAttributeBase(id);
- int effLevel = player_node->getAttributeEffective(id);
+ int baseLevel = PlayerInfo::getStatBase(id);
+ int effLevel = PlayerInfo::getStatEffective(id);
- std::pair<int, int> exp = player_node->getExperience(id);
+ std::pair<int, int> exp = PlayerInfo::getStatExperience(id);
if (!modifiable && baseLevel == 0 && effLevel == 0 && exp.second == 0)
{
diff --git a/src/gui/skilldialog.h b/src/gui/skilldialog.h
index 95f8ef25..3b1b1832 100644
--- a/src/gui/skilldialog.h
+++ b/src/gui/skilldialog.h
@@ -19,10 +19,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef SKILL_H
-#define SKILL_H
-
-#include "guichanfwd.h"
+#ifndef SKILLDIALOG_H
+#define SKILLDIALOG_H
#include "gui/widgets/window.h"
diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp
index d52e073c..b4321b25 100644
--- a/src/gui/socialwindow.cpp
+++ b/src/gui/socialwindow.cpp
@@ -20,22 +20,19 @@
#include "gui/socialwindow.h"
-#include "beingmanager.h"
+#include "event.h"
#include "guild.h"
#include "localplayer.h"
#include "party.h"
-#include "player.h"
#include "gui/confirmdialog.h"
#include "gui/okdialog.h"
#include "gui/setup.h"
#include "gui/textdialog.h"
-#include "gui/theme.h"
#include "gui/widgets/avatarlistbox.h"
#include "gui/widgets/browserbox.h"
#include "gui/widgets/button.h"
-#include "gui/widgets/chattab.h"
#include "gui/widgets/container.h"
#include "gui/widgets/label.h"
#include "gui/widgets/layouthelper.h"
@@ -49,6 +46,8 @@
#include "net/guildhandler.h"
#include "net/partyhandler.h"
+#include "resources/theme.h"
+
#include "utils/dtor.h"
#include "utils/gettext.h"
#include "utils/stringutils.h"
@@ -124,13 +123,10 @@ public:
if (!name.empty())
{
- Net::getGuildHandler()->invite(mGuild->getId(), name);
- localChatTab->chatLog(strprintf(_("Invited user %s to guild %s."),
- name.c_str(),
- mGuild->getName().c_str()),
- BY_SERVER);
+ SERVER_NOTICE(strprintf(_("Invited user %s to guild %s."),
+ name.c_str(),
+ mGuild->getName().c_str()))
}
-
mInviteDialog = NULL;
}
else if (event.getId() == "~do invite")
@@ -140,8 +136,8 @@ public:
else if (event.getId() == "yes")
{
Net::getGuildHandler()->leave(mGuild->getId());
- localChatTab->chatLog(strprintf(_("Guild %s quit requested."),
- mGuild->getName().c_str()), BY_SERVER);
+ SERVER_NOTICE(strprintf(_("Guild %s quit requested."),
+ mGuild->getName().c_str()))
mConfirmDialog = NULL;
}
else if (event.getId() == "no")
@@ -208,8 +204,8 @@ public:
std::string name = mInviteDialog->getText();
if (!name.empty())
- Net::getPartyHandler()->invite(name);
-
+ SERVER_NOTICE(strprintf(_("Invited user %s to party."),
+ name.c_str()))
mInviteDialog = NULL;
}
else if (event.getId() == "~do invite")
@@ -219,8 +215,8 @@ public:
else if (event.getId() == "yes")
{
Net::getPartyHandler()->leave();
- localChatTab->chatLog(strprintf(_("Party %s quit requested."),
- mParty->getName().c_str()), BY_SERVER);
+ SERVER_NOTICE(strprintf(_("Party %s quit requested."),
+ mParty->getName().c_str()))
mConfirmDialog = NULL;
}
else if (event.getId() == "no")
@@ -444,14 +440,14 @@ void SocialWindow::action(const gcn::ActionEvent &event)
// check if they accepted the invite
if (eventId == "yes")
{
- localChatTab->chatLog(strprintf(_("Accepted party invite from %s."),
- mPartyInviter.c_str()));
+ SERVER_NOTICE(strprintf(_("Accepted party invite from %s."),
+ mPartyInviter.c_str()))
Net::getPartyHandler()->inviteResponse(mPartyInviter, true);
}
else if (eventId == "no")
{
- localChatTab->chatLog(strprintf(_("Rejected party invite from %s."),
- mPartyInviter.c_str()));
+ SERVER_NOTICE(strprintf(_("Rejected party invite from %s."),
+ mPartyInviter.c_str()))
Net::getPartyHandler()->inviteResponse(mPartyInviter, false);
}
@@ -463,14 +459,14 @@ void SocialWindow::action(const gcn::ActionEvent &event)
// check if they accepted the invite
if (eventId == "yes")
{
- localChatTab->chatLog(strprintf(_("Accepted guild invite from %s."),
- mPartyInviter.c_str()));
+ SERVER_NOTICE(strprintf(_("Accepted guild invite from %s."),
+ mPartyInviter.c_str()))
Net::getGuildHandler()->inviteResponse(mGuildInvited, true);
}
else if (eventId == "no")
{
- localChatTab->chatLog(strprintf(_("Rejected guild invite from %s."),
- mPartyInviter.c_str()));
+ SERVER_NOTICE(strprintf(_("Rejected guild invite from %s."),
+ mPartyInviter.c_str()))
Net::getGuildHandler()->inviteResponse(mGuildInvited, false);
}
@@ -498,14 +494,15 @@ void SocialWindow::action(const gcn::ActionEvent &event)
if (name.size() > 16)
{
- localChatTab->chatLog(_("Creating guild failed, please choose a "
- "shorter name."), BY_SERVER);
+ SERVER_NOTICE(_("Creating guild failed, please choose a "
+ "shorter name."));
+ return;
}
else if (!name.empty())
{
Net::getGuildHandler()->create(name);
- localChatTab->chatLog(strprintf(_("Creating guild called %s."),
- name.c_str()), BY_SERVER);
+ SERVER_NOTICE(strprintf(_("Creating guild called %s."),
+ name.c_str()));
}
mGuildCreateDialog = NULL;
@@ -520,14 +517,15 @@ void SocialWindow::action(const gcn::ActionEvent &event)
if (name.size() > 16)
{
- localChatTab->chatLog(_("Creating party failed, please choose a "
- "shorter name."), BY_SERVER);
+ SERVER_NOTICE(_("Creating party failed, please choose a "
+ "shorter name."));
+ return;
}
else if (!name.empty())
{
Net::getPartyHandler()->create(name);
- localChatTab->chatLog(strprintf(_("Creating party called %s."),
- name.c_str()), BY_SERVER);
+ SERVER_NOTICE(strprintf(_("Creating party called %s."),
+ name.c_str()));
}
mPartyCreateDialog = NULL;
@@ -553,14 +551,14 @@ void SocialWindow::showGuildInvite(const std::string &guildName,
// check there isnt already an invite showing
if (mGuildInvited != 0)
{
- localChatTab->chatLog(_("Received guild request, but one already "
- "exists."), BY_SERVER);
+ SERVER_NOTICE(_("Received guild request, but one already "
+ "exists."))
return;
}
std::string msg = strprintf(_("%s has invited you to join the guild %s."),
inviterName.c_str(), guildName.c_str());
- localChatTab->chatLog(msg, BY_SERVER);
+ SERVER_NOTICE(msg)
// show invite
mGuildAcceptDialog = new ConfirmDialog(_("Accept Guild Invite"), msg, this);
@@ -575,8 +573,7 @@ void SocialWindow::showPartyInvite(const std::string &partyName,
// check there isnt already an invite showing
if (mPartyInviter != "")
{
- localChatTab->chatLog(_("Received party request, but one already "
- "exists."), BY_SERVER);
+ SERVER_NOTICE(_("Received party request, but one already exists."))
return;
}
@@ -607,7 +604,7 @@ void SocialWindow::showPartyInvite(const std::string &partyName,
}
}
- localChatTab->chatLog(msg, BY_SERVER);
+ SERVER_NOTICE(msg)
// show invite
mPartyAcceptDialog = new ConfirmDialog(_("Accept Party Invite"), msg, this);
diff --git a/src/gui/specialswindow.cpp b/src/gui/specialswindow.cpp
index 44551825..b511e4a3 100644
--- a/src/gui/specialswindow.cpp
+++ b/src/gui/specialswindow.cpp
@@ -20,11 +20,9 @@
#include "gui/specialswindow.h"
-#include "localplayer.h"
#include "log.h"
#include "gui/setup.h"
-#include "gui/theme.h"
#include "gui/widgets/button.h"
#include "gui/widgets/container.h"
@@ -42,6 +40,9 @@
#include "net/net.h"
#include "net/specialhandler.h"
+#include "resources/specialdb.h"
+#include "resources/theme.h"
+
#include "utils/dtor.h"
#include "utils/gettext.h"
#include "utils/stringutils.h"
@@ -54,31 +55,24 @@
class SpecialEntry;
-struct SpecialInfo
-{
- unsigned short id;
- std::string name;
- std::string icon;
- SpecialEntry *display;
-};
class SpecialEntry : public Container
{
public:
SpecialEntry(SpecialInfo *info);
- void update();
+ void update(int current, int needed);
protected:
friend class SpecialsWindow;
SpecialInfo *mInfo;
private:
- Icon *mIcon;
- Label *mNameLabel;
- Label *mLevelLabel;
- Label *mTechLabel;
- Button *mUse;
+ Icon *mIcon; // icon to display
+ Label *mNameLabel; // name to display
+ Label *mLevelLabel; // level number label (only shown when applicable)
+ Button *mUse; // use button (only shown when applicable)
+ ProgressBar *mRechargeBar; // recharge bar (only shown when applicable)
};
SpecialsWindow::SpecialsWindow():
@@ -102,7 +96,6 @@ SpecialsWindow::SpecialsWindow():
SpecialsWindow::~SpecialsWindow()
{
// Clear gui
- loadSpecials("");
}
void SpecialsWindow::action(const gcn::ActionEvent &event)
@@ -127,91 +120,70 @@ void SpecialsWindow::action(const gcn::ActionEvent &event)
}
}
-std::string SpecialsWindow::update(int id)
-{
- // TODO
-
- return std::string();
-}
-
-void SpecialsWindow::loadSpecials(const std::string &file)
+void SpecialsWindow::draw(gcn::Graphics *graphics)
{
- // TODO: mTabs->clear();
- while (mTabs->getSelectedTabIndex() != -1)
+ // update the progress bars
+ std::map<int, Special> specialData = PlayerInfo::getSpecialStatus();
+ bool foundNew = false;
+ unsigned int found = 0; // number of entries in specialData which match mEntries
+
+ for (std::map<int, Special>::iterator i = specialData.begin();
+ i != specialData.end();
+ i++)
{
- mTabs->removeTabWithIndex(mTabs->getSelectedTabIndex());
- }
-
- for (SpecialMap::iterator it = mSpecials.begin(); it != mSpecials.end(); it++)
- {
- delete (*it).second->display;
+ std::map<int, SpecialEntry *>::iterator e = mEntries.find(i->first);
+ if (e == mEntries.end())
+ {
+ // found a new special - abort update and rebuild from scratch
+ foundNew = true;
+ break;
+ } else {
+ // update progress bar of special
+ e->second->update(i->second.currentMana, i->second.neededMana);
+ found++;
+ }
}
- delete_all(mSpecials);
- mSpecials.clear();
+ // a rebuild is needed when a) the number of specials changed or b) an existing entry isn't found anymore
+ if (foundNew || found != mEntries.size()) rebuild(specialData);
- if (file.length() == 0)
- return;
+ Window::draw(graphics);
+}
- XML::Document doc(file);
- xmlNodePtr root = doc.rootNode();
+void SpecialsWindow::rebuild(const std::map<int, Special> &specialData)
+{
+ make_dtor(mEntries);
+ mEntries.clear();
+ int vPos = 0; //vertical position of next placed element
- if (!root || !xmlStrEqual(root->name, BAD_CAST "specials"))
+ for (std::map<int, Special>::const_iterator i = specialData.begin();
+ i != specialData.end();
+ i++)
{
- logger->log("Error loading specials file: %s", file.c_str());
- return;
- }
-
- int setCount = 0;
- std::string setName;
- ScrollArea *scroll;
- FlowContainer *container;
+ logger->log("Updating special GUI for %d", i->first);
- for_each_xml_child_node(set, root)
- {
- if (xmlStrEqual(set->name, BAD_CAST "set"))
+ SpecialInfo* info = SpecialDB::get(i->first);
+ if (info)
{
- setCount++;
- setName = XML::getProperty(set, "name", strprintf(_("Specials Set %d"), setCount));
-
- container = new FlowContainer(SPECIALS_WIDTH, SPECIALS_HEIGHT);
- container->setOpaque(false);
- scroll = new ScrollArea(container);
- scroll->setOpaque(false);
- scroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
- scroll->setVerticalScrollPolicy(ScrollArea::SHOW_ALWAYS);
-
- mTabs->addTab(setName, scroll);
- for_each_xml_child_node(node, set)
- {
- if (xmlStrEqual(node->name, BAD_CAST "special"))
- {
- int id = atoi(XML::getProperty(node, "id", "-1").c_str());
- if (id == -1)
- continue;
- std::string name = XML::getProperty(node, "name", strprintf(_("Special %d"), id));
- std::string icon = XML::getProperty(node, "icon", "");
-
- SpecialInfo *special = new SpecialInfo;
- special->id = id;
- special->name = name;
- special->icon = icon;
- special->display = new SpecialEntry(special);
-
- container->add(special->display);
-
- mSpecials[id] = special;
- }
- }
+ info->rechargeCurrent = i->second.currentMana;
+ info->rechargeNeeded = i->second.neededMana;
+ SpecialEntry* entry = new SpecialEntry(info);
+ entry->setPosition(0, vPos);
+ vPos += entry->getHeight();
+ add(entry);
+ mEntries[i->first] = entry;
+ } else {
+ logger->log("Warning: No info available of special %d", i->first);
}
}
}
+
SpecialEntry::SpecialEntry(SpecialInfo *info) :
mInfo(info),
mIcon(NULL),
- mNameLabel(new Label(info->name)),
- mLevelLabel(new Label("999")),
- mUse(new Button("Use", "use", specialsWindow))
+ mLevelLabel(NULL),
+ mUse(NULL),
+ mRechargeBar(NULL)
{
setFrameSize(1);
setOpaque(false);
@@ -225,21 +197,42 @@ SpecialEntry::SpecialEntry(SpecialInfo *info) :
mIcon->setPosition(1, 0);
add(mIcon);
+
+ mNameLabel = new Label(info->name);
mNameLabel->setPosition(35, 0);
add(mNameLabel);
- mLevelLabel->setPosition(getWidth() - mLevelLabel->getWidth(), 0);
- add(mLevelLabel);
+ if (info->hasLevel)
+ {
+ mLevelLabel = new Label(toString(info->level));
+ mLevelLabel->setPosition(getWidth() - mLevelLabel->getWidth(), 0);
+ add(mLevelLabel);
+ }
+
- mNameLabel->setWidth(mLevelLabel->getX() - mNameLabel->getX() - 1);
+ if (info->isActive)
+ {
+ mUse = new Button("Use", "use", specialsWindow);
+ mUse->setPosition(getWidth() - mUse->getWidth(), 13);
+ add(mUse);
+ }
- mUse->setPosition(getWidth() - mUse->getWidth(), 13);
- add(mUse);
+ if (info->hasRechargeBar)
+ {
+ float progress = (float)info->rechargeCurrent / (float)info->rechargeNeeded;
+ mRechargeBar = new ProgressBar(progress, 100, 10, Theme::PROG_MP);
+ mRechargeBar->setSmoothProgress(false);
+ mRechargeBar->setPosition(0, 13);
+ add(mRechargeBar);
+ }
- update();
}
-void SpecialEntry::update()
+void SpecialEntry::update(int current, int needed)
{
- // TODO
+ if (mRechargeBar)
+ {
+ float progress = (float)current / (float)needed;
+ mRechargeBar->setProgress(progress);
+ }
}
diff --git a/src/gui/specialswindow.h b/src/gui/specialswindow.h
index 81384856..dedeeffc 100644
--- a/src/gui/specialswindow.h
+++ b/src/gui/specialswindow.h
@@ -23,7 +23,7 @@
#include <vector>
-#include "guichanfwd.h"
+#include "playerinfo.h"
#include "gui/widgets/window.h"
@@ -36,7 +36,7 @@ class ScrollArea;
class Tab;
class TabbedArea;
-struct SpecialInfo;
+struct SpecialEntry;
class SpecialsWindow : public Window, public gcn::ActionListener {
public:
@@ -49,20 +49,14 @@ class SpecialsWindow : public Window, public gcn::ActionListener {
*/
void action(const gcn::ActionEvent &actionEvent);
- /**
- * Update the given special's display
- */
- std::string update(int id);
-
- void loadSpecials(const std::string &file);
-
- bool hasSpecials() { return !mSpecials.empty(); }
+ void draw(gcn::Graphics *graphics);
private:
- std::vector<gcn::Button *> mSpellButtons;
- typedef std::map<int, SpecialInfo*> SpecialMap;
- SpecialMap mSpecials;
+ // (re)constructs the list of specials
+ void rebuild(const std::map<int, Special> &specialData);
+
TabbedArea *mTabs;
+ std::map<int, SpecialEntry *> mEntries;
};
extern SpecialsWindow *specialsWindow;
diff --git a/src/gui/speechbubble.cpp b/src/gui/speechbubble.cpp
index 08d00038..e0a9f8a0 100644
--- a/src/gui/speechbubble.cpp
+++ b/src/gui/speechbubble.cpp
@@ -25,10 +25,12 @@
#include "graphics.h"
#include "gui/gui.h"
-#include "gui/theme.h"
+#include "gui/widgets/label.h"
#include "gui/widgets/textbox.h"
+#include "resources/theme.h"
+
#include <guichan/font.hpp>
#include <guichan/widgets/label.hpp>
@@ -40,7 +42,7 @@ SpeechBubble::SpeechBubble():
setMinWidth(29);
setMinHeight(29);
- mCaption = new gcn::Label;
+ mCaption = new Label;
mCaption->setFont(boldFont);
mSpeechBox = new TextBox;
diff --git a/src/gui/speechbubble.h b/src/gui/speechbubble.h
index 8682ab7e..6017398a 100644
--- a/src/gui/speechbubble.h
+++ b/src/gui/speechbubble.h
@@ -23,10 +23,10 @@
#ifndef SPEECHBUBBLE_H
#define SPEECHBUBBLE_H
-#include "gui/theme.h"
-
#include "gui/widgets/popup.h"
+#include "resources/theme.h"
+
class TextBox;
class SpeechBubble : public Popup
diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp
index 91f832f5..a3420f06 100644
--- a/src/gui/statuswindow.cpp
+++ b/src/gui/statuswindow.cpp
@@ -22,11 +22,10 @@
#include "gui/statuswindow.h"
#include "localplayer.h"
+#include "playerinfo.h"
#include "units.h"
-#include "gui/ministatus.h"
#include "gui/setup.h"
-#include "gui/theme.h"
#include "gui/widgets/button.h"
#include "gui/widgets/label.h"
@@ -38,6 +37,9 @@
#include "net/net.h"
#include "net/playerhandler.h"
+#include "net/gamehandler.h"
+
+#include "resources/theme.h"
#include "utils/gettext.h"
#include "utils/mathutils.h"
@@ -94,6 +96,8 @@ class ChangeDisplay : public AttrDisplay, gcn::ActionListener
StatusWindow::StatusWindow():
Window(player_node->getName())
{
+ listen(CHANNEL_ATTRIBUTES);
+
setWindowName("Status");
setupWindow->registerWindowForReset(this);
setResizable(true);
@@ -109,21 +113,26 @@ StatusWindow::StatusWindow():
mLvlLabel = new Label(strprintf(_("Level: %d"), 0));
mMoneyLabel = new Label(strprintf(_("Money: %s"), ""));
- int max = player_node->getMaxHp();
+ int max = PlayerInfo::getAttribute(MAX_HP);
mHpLabel = new Label(_("HP:"));
- mHpBar = new ProgressBar(max ? (float) player_node->getHp() / max: 0,
- 80, 15, Theme::PROG_HP);
+ mHpBar = new ProgressBar(max ? (float) PlayerInfo::getAttribute(HP) / max :
+ 0, 80, 15, Theme::PROG_HP);
- max = player_node->getExpNeeded();
+ max = PlayerInfo::getAttribute(EXP_NEEDED);
mXpLabel = new Label(_("Exp:"));
- mXpBar = new ProgressBar(max ? (float) player_node->getExp() / max : 0,
- 80, 15, Theme::PROG_EXP);
+ mXpBar = new ProgressBar(max ? (float) PlayerInfo::getAttribute(EXP) / max :
+ 0, 80, 15, Theme::PROG_EXP);
- max = player_node->getMaxMP();
- mMpLabel = new Label(_("MP:"));
- mMpBar = new ProgressBar(max ? (float) player_node->getMaxMP() / max : 0,
- 80, 15, Net::getPlayerHandler()->canUseMagic() ?
+ bool magicBar = Net::getGameHandler()->canUseMagicBar();
+ if (magicBar)
+ {
+ max = PlayerInfo::getAttribute(MAX_MP);
+ mMpLabel = new Label(_("MP:"));
+ mMpBar = new ProgressBar(max ?
+ (float) PlayerInfo::getAttribute(MAX_MP) / max :
+ 0, 80, 15, Net::getPlayerHandler()->canUseMagic() ?
Theme::PROG_MP : Theme::PROG_NO_MP);
+ }
place(0, 0, mLvlLabel, 3);
// 5, 0 Job Level
@@ -132,9 +141,17 @@ StatusWindow::StatusWindow():
place(1, 1, mHpBar, 4);
place(5, 1, mXpLabel).setPadding(3);
place(6, 1, mXpBar, 5);
- place(0, 2, mMpLabel).setPadding(3);
- // 5, 2 and 6, 2 Job Progress Bar
- place(1, 2, mMpBar, 4);
+
+ int attributesFirstRow = 2;
+ if (magicBar)
+ {
+ place(0, 2, mMpLabel).setPadding(3);
+ // 5, 2 and 6, 2 Job Progress Bar
+ place(1, 2, mMpBar, 4);
+
+ // We move the attribute row to the next one
+ attributesFirstRow = 3;
+ }
if (Net::getPlayerHandler()->getJobLocation() > 0)
{
@@ -145,128 +162,131 @@ StatusWindow::StatusWindow():
place(5, 0, mJobLvlLabel, 3);
place(5, 2, mJobLabel).setPadding(3);
place(6, 2, mJobBar, 5);
+
+ // We move the attribute row to the next one
+ attributesFirstRow = 3;
}
// ----------------------
// Stats Part
// ----------------------
- mAttrCont = new VertContainer(32);
+ mAttrCont = new VertContainer(28);
mAttrScroll = new ScrollArea(mAttrCont);
mAttrScroll->setOpaque(false);
mAttrScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
mAttrScroll->setVerticalScrollPolicy(ScrollArea::SHOW_AUTO);
- place(0, 3, mAttrScroll, 5, 3);
+ place(0, attributesFirstRow, mAttrScroll, 5, 3);
- mDAttrCont = new VertContainer(32);
+ mDAttrCont = new VertContainer(28);
mDAttrScroll = new ScrollArea(mDAttrCont);
mDAttrScroll->setOpaque(false);
mDAttrScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
mDAttrScroll->setVerticalScrollPolicy(ScrollArea::SHOW_AUTO);
- place(6, 3, mDAttrScroll, 5, 3);
+ place(6, attributesFirstRow, mDAttrScroll, 5, 3);
- getLayout().setRowHeight(3, Layout::AUTO_SET);
+ getLayout().setRowHeight(attributesFirstRow, Layout::AUTO_SET);
- mCharacterPointsLabel = new Label("C");
- place(0, 6, mCharacterPointsLabel, 5);
+ mCharacterPointsLabel = new Label("Character points: 0");
+ place(0, attributesFirstRow + 3, mCharacterPointsLabel, 4);
if (Net::getPlayerHandler()->canCorrectAttributes())
{
- mCorrectionPointsLabel = new Label("C");
- place(0, 7, mCorrectionPointsLabel, 5);
+ mCorrectionPointsLabel = new Label("Correction points: 0");
+ place(4, attributesFirstRow + 3, mCorrectionPointsLabel, 4);
}
loadWindowState();
- update(HP);
- update(MP);
- update(EXP);
- update(MONEY);
- update(CHAR_POINTS); // This also updates all attributes (none atm)
- update(LEVEL);
- int job = Net::getPlayerHandler()->getJobLocation();
- if (job > 0)
- {
- update(job);
- }
-}
-
-std::string StatusWindow::update(int id)
-{
- if (miniStatusWindow)
- miniStatusWindow->update(id);
-
- if (id == HP)
- {
- updateHPBar(mHpBar, true);
-
- return _("HP");
- }
- else if (id == MP)
- {
+ // Update bars
+ updateHPBar(mHpBar, true);
+ if (magicBar)
updateMPBar(mMpBar, true);
+ updateXPBar(mXpBar, false);
- return _("MP");
- }
- else if (id == EXP)
- {
- updateXPBar(mXpBar, false);
- return _("Exp");
- }
- else if (id == MONEY)
- {
- int money = player_node->getMoney();
- mMoneyLabel->setCaption(strprintf(_("Money: %s"),
- Units::formatCurrency(money).c_str()));
- mMoneyLabel->adjustSize();
+ mMoneyLabel->setCaption(strprintf(_("Money: %s"),
+ Units::formatCurrency(PlayerInfo::getAttribute(MONEY)).c_str()));
+ mMoneyLabel->adjustSize();
+ mCharacterPointsLabel->setCaption(strprintf(_("Character points: %d"),
+ PlayerInfo::getAttribute(CHAR_POINTS)));
+ mCharacterPointsLabel->adjustSize();
- return _("Money");
- }
- else if (id == Net::getPlayerHandler()->getJobLocation())
- {
- mJobLvlLabel->setCaption(strprintf(_("Job: %d"),
- player_node->getAttributeBase(id)));
- mJobLvlLabel->adjustSize();
-
- updateProgressBar(mJobBar, id, false);
+ mLvlLabel->setCaption(strprintf(_("Level: %d"),
+ PlayerInfo::getAttribute(LEVEL)));
+ mLvlLabel->adjustSize();
+}
- return _("Job");
- }
- else if (id == CHAR_POINTS)
+void StatusWindow::event(Channels channel, const Mana::Event &event)
+{
+ if (event.getName() == EVENT_UPDATEATTRIBUTE)
{
- mCharacterPointsLabel->setCaption(strprintf(_("Character points: %d"),
- player_node->getCharacterPoints()));
- mCharacterPointsLabel->adjustSize();
-
- if (Net::getPlayerHandler()->canCorrectAttributes())
+ switch(event.getInt("id"))
{
- mCorrectionPointsLabel->setCaption(strprintf(_("Correction points: %d"),
- player_node->getCorrectionPoints()));
- mCorrectionPointsLabel->adjustSize();
+ case HP: case MAX_HP:
+ updateHPBar(mHpBar, true);
+ break;
+
+ case MP: case MAX_MP:
+ updateMPBar(mMpBar, true);
+ break;
+
+ case EXP: case EXP_NEEDED:
+ updateXPBar(mXpBar, false);
+ break;
+
+ case MONEY:
+ mMoneyLabel->setCaption(strprintf(_("Money: %s"),
+ Units::formatCurrency(
+ event.getInt("newValue")).c_str()));
+ mMoneyLabel->adjustSize();
+ break;
+
+ case CHAR_POINTS:
+ mCharacterPointsLabel->setCaption(strprintf(
+ _("Character points: %d"),
+ event.getInt("newValue")));
+ mCharacterPointsLabel->adjustSize();
+ updateAttrs();
+ break;
+
+ case CORR_POINTS:
+ mCorrectionPointsLabel->setCaption(strprintf(
+ _("Correction points: %d"),
+ event.getInt("newValue")));
+ mCorrectionPointsLabel->adjustSize();
+ updateAttrs();
+ break;
+
+ case LEVEL:
+ mLvlLabel->setCaption(strprintf(_("Level: %d"),
+ event.getInt("newValue")));
+ mLvlLabel->adjustSize();
+ break;
}
-
- updateAttrs();
}
- else if (id == LEVEL)
+ else if (event.getName() == EVENT_UPDATESTAT)
{
- mLvlLabel->setCaption(strprintf(_("Level: %d"),
- player_node->getLevel()));
- mLvlLabel->adjustSize();
+ int id = event.getInt("id");
- return _("Level");
- }
- else
- {
- Attrs::iterator it = mAttrs.find(id);
+ if (id == Net::getPlayerHandler()->getJobLocation())
+ {
+
+ mJobLvlLabel->setCaption(strprintf(_("Job: %d"),
+ PlayerInfo::getStatBase(id)));
+ mJobLvlLabel->adjustSize();
- if (it != mAttrs.end())
+ updateProgressBar(mJobBar, id, false);
+ }
+ else
{
- return it->second->update();
+ Attrs::iterator it = mAttrs.find(id);
+ if (it != mAttrs.end())
+ {
+ it->second->update();
+ }
}
}
-
- return "";
}
void StatusWindow::updateAttrs()
@@ -311,32 +331,39 @@ void StatusWindow::addAttribute(int id, const std::string &name,
void StatusWindow::updateHPBar(ProgressBar *bar, bool showMax)
{
+ if (!bar)
+ return;
if (showMax)
- bar->setText(toString(player_node->getHp()) +
- "/" + toString(player_node->getMaxHp()));
+ bar->setText(toString(PlayerInfo::getAttribute(HP)) +
+ "/" + toString(PlayerInfo::getAttribute(MAX_HP)));
else
- bar->setText(toString(player_node->getHp()));
+ bar->setText(toString(PlayerInfo::getAttribute(HP)));
float prog = 1.0;
- if (player_node->getMaxHp() > 0)
- prog = (float) player_node->getHp() / player_node->getMaxHp();
+ if (PlayerInfo::getAttribute(MAX_HP) > 0)
+ prog = (float) PlayerInfo::getAttribute(HP)
+ / PlayerInfo::getAttribute(MAX_HP);
bar->setProgress(prog);
}
void StatusWindow::updateMPBar(ProgressBar *bar, bool showMax)
{
+ if (!bar)
+ return;
+
if (showMax)
- bar->setText(toString(player_node->getMP()) +
- "/" + toString(player_node->getMaxMP()));
+ bar->setText(toString(PlayerInfo::getAttribute(MP)) +
+ "/" + toString(PlayerInfo::getAttribute(MAX_MP)));
else
- bar->setText(toString(player_node->getMP()));
+ bar->setText(toString(PlayerInfo::getAttribute(MP)));
float prog = 1.0f;
- if (player_node->getMaxMP() > 0)
- prog = (float) player_node->getMP() / player_node->getMaxMP();
+ if (PlayerInfo::getAttribute(MAX_MP) > 0)
+ prog = (float) PlayerInfo::getAttribute(MP)
+ / PlayerInfo::getAttribute(MAX_MP);
if (Net::getPlayerHandler()->canUseMagic())
bar->setProgressPalette(Theme::PROG_MP);
@@ -347,8 +374,11 @@ void StatusWindow::updateMPBar(ProgressBar *bar, bool showMax)
}
void StatusWindow::updateProgressBar(ProgressBar *bar, int value, int max,
- bool percent)
+ bool percent)
{
+ if (!bar)
+ return;
+
if (max == 0)
{
bar->setText(_("Max"));
@@ -369,13 +399,16 @@ void StatusWindow::updateProgressBar(ProgressBar *bar, int value, int max,
void StatusWindow::updateXPBar(ProgressBar *bar, bool percent)
{
- updateProgressBar(bar, player_node->getExp(),
- player_node->getExpNeeded(), percent);
+ if (!bar)
+ return;
+
+ updateProgressBar(bar, PlayerInfo::getAttribute(EXP),
+ PlayerInfo::getAttribute(EXP_NEEDED), percent);
}
void StatusWindow::updateProgressBar(ProgressBar *bar, int id, bool percent)
{
- std::pair<int, int> exp = player_node->getExperience(id);
+ std::pair<int, int> exp = PlayerInfo::getStatExperience(id);
updateProgressBar(bar, exp.first, exp.second, percent);
}
@@ -400,8 +433,8 @@ AttrDisplay::~AttrDisplay()
std::string AttrDisplay::update()
{
- int base = player_node->getAttributeBase(mId);
- int bonus = player_node->getAttributeEffective(mId) - base;
+ int base = PlayerInfo::getStatBase(mId);
+ int bonus = PlayerInfo::getStatMod(mId);
std::string value = toString(base);
if (bonus)
value += strprintf(" (%+d)", bonus);
@@ -465,9 +498,9 @@ std::string ChangeDisplay::update()
if (mDec)
{
- mDec->setEnabled(player_node->getCorrectionPoints());
+ mDec->setEnabled(PlayerInfo::getAttribute(CORR_POINTS));
}
- mInc->setEnabled(player_node->getCharacterPoints() >= mNeeded &&
+ mInc->setEnabled(PlayerInfo::getAttribute(CHAR_POINTS) >= mNeeded &&
mNeeded > 0);
return AttrDisplay::update();
@@ -485,24 +518,25 @@ void ChangeDisplay::action(const gcn::ActionEvent &event)
if (Net::getPlayerHandler()->canCorrectAttributes() &&
event.getSource() == mDec)
{
- int newcorpoints = player_node->getCorrectionPoints() - 1;
- player_node->setCorrectionPoints(newcorpoints);
- int newpoints = player_node->getCharacterPoints() + 1;
- player_node->setCharacterPoints(newpoints);
- int newbase = player_node->getAttributeBase(mId) - 1;
- player_node->setAttributeBase(mId, newbase);
- int newmod = player_node->getAttributeEffective(mId) - 1;
- player_node->setAttributeEffective(mId, newmod);
+ int newcorpoints = PlayerInfo::getAttribute(CORR_POINTS) - 1;
+ PlayerInfo::setAttribute(CORR_POINTS, newcorpoints);
+
+ int newpoints = PlayerInfo::getAttribute(CHAR_POINTS) + 1;
+ PlayerInfo::setAttribute(CHAR_POINTS, newpoints);
+
+ int newbase = PlayerInfo::getStatBase(mId) - 1;
+ PlayerInfo::setStatBase(mId, newbase);
+
Net::getPlayerHandler()->decreaseAttribute(mId);
}
else if (event.getSource() == mInc)
{
- int newpoints = player_node->getCharacterPoints() - 1;
- player_node->setCharacterPoints(newpoints);
- int newbase = player_node->getAttributeBase(mId) + 1;
- player_node->setAttributeBase(mId, newbase);
- int newmod = player_node->getAttributeEffective(mId) + 1;
- player_node->setAttributeEffective(mId, newmod);
+ int newpoints = PlayerInfo::getAttribute(CHAR_POINTS) - 1;
+ PlayerInfo::setAttribute(CHAR_POINTS, newpoints);
+
+ int newbase = PlayerInfo::getStatBase(mId) + 1;
+ PlayerInfo::setStatBase(mId, newbase);
+
Net::getPlayerHandler()->increaseAttribute(mId);
}
}
diff --git a/src/gui/statuswindow.h b/src/gui/statuswindow.h
index d99368b8..103111a7 100644
--- a/src/gui/statuswindow.h
+++ b/src/gui/statuswindow.h
@@ -22,7 +22,7 @@
#ifndef STATUS_H
#define STATUS_H
-#include "guichanfwd.h"
+#include "listener.h"
#include "gui/widgets/window.h"
@@ -40,24 +40,15 @@ class VertContainer;
*
* \ingroup Interface
*/
-class StatusWindow : public Window
+class StatusWindow : public Window, public Mana::Listener
{
public:
- enum { // Some update constants
- HP = -1,
- MP = -2,
- EXP = -3,
- MONEY = -4,
- CHAR_POINTS = -5,
- LEVEL = -6
- };
-
/**
* Constructor.
*/
StatusWindow();
- std::string update(int id);
+ void event(Channels channel, const Mana::Event &event);
void updateAttrs();
diff --git a/src/gui/textdialog.cpp b/src/gui/textdialog.cpp
index d9728357..f88a6afa 100644
--- a/src/gui/textdialog.cpp
+++ b/src/gui/textdialog.cpp
@@ -21,7 +21,7 @@
#include "gui/textdialog.h"
-#include "beingmanager.h"
+#include "actorspritemanager.h"
#include "gui/widgets/button.h"
#include "gui/widgets/label.h"
@@ -42,7 +42,7 @@ TextDialog::TextDialog(const std::string &title, const std::string &msg,
// In TextField the escape key will either cause autoComplete or lose focus
mTextField = new TextField("", ! autoCompleteEnabled);
if (autoCompleteEnabled)
- mTextField->setAutoComplete(beingManager->getPlayerNameLister());
+ mTextField->setAutoComplete(actorSpriteManager->getPlayerNameLister());
mTextField->addActionListener(this);
diff --git a/src/gui/textpopup.cpp b/src/gui/textpopup.cpp
index 6aeae319..d0a0c495 100644
--- a/src/gui/textpopup.cpp
+++ b/src/gui/textpopup.cpp
@@ -26,6 +26,8 @@
#include "gui/gui.h"
#include "gui/palette.h"
+#include "gui/widgets/label.h"
+
#include "graphics.h"
#include "units.h"
@@ -40,10 +42,10 @@ 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 + getPadding());
add(mText1);
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp
deleted file mode 100644
index 3d0bd5d3..00000000
--- a/src/gui/theme.cpp
+++ /dev/null
@@ -1,578 +0,0 @@
-/*
- * Gui Skinning
- * Copyright (C) 2008 The Legend of Mazzeroth Development Team
- * Copyright (C) 2009 Aethyra Development Team
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- *
- * This file is part of The Mana 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/theme.h"
-
-#include "client.h"
-#include "configuration.h"
-#include "log.h"
-
-#include "resources/dye.h"
-#include "resources/image.h"
-#include "resources/imageset.h"
-#include "resources/resourcemanager.h"
-
-#include "utils/dtor.h"
-#include "utils/stringutils.h"
-#include "utils/xml.h"
-
-#include <physfs.h>
-
-#include <algorithm>
-
-static std::string defaultThemePath;
-std::string Theme::mThemePath;
-Theme *Theme::mInstance = 0;
-
-// Set the theme path...
-static void initDefaultThemePath()
-{
- ResourceManager *resman = ResourceManager::getInstance();
- defaultThemePath = branding.getValue("guiThemePath", "");
-
- if (!defaultThemePath.empty() && resman->isDirectory(defaultThemePath))
- return;
- else
- defaultThemePath = "graphics/gui/";
-}
-
-Skin::Skin(ImageRect skin, Image *close, Image *stickyUp, Image *stickyDown,
- const std::string &filePath,
- const std::string &name):
- instances(0),
- mFilePath(filePath),
- mName(name),
- mBorder(skin),
- mCloseImage(close),
- mStickyImageUp(stickyUp),
- mStickyImageDown(stickyDown)
-{}
-
-Skin::~Skin()
-{
- // Clean up static resources
- for (int i = 0; i < 9; i++)
- delete mBorder.grid[i];
-
- mCloseImage->decRef();
- delete mStickyImageUp;
- delete mStickyImageDown;
-}
-
-void Skin::updateAlpha(float minimumOpacityAllowed)
-{
- const float alpha = std::max((double)minimumOpacityAllowed,
- config.getValue("guialpha", 0.8f));
-
- for_each(mBorder.grid, mBorder.grid + 9,
- std::bind2nd(std::mem_fun(&Image::setAlpha), alpha));
-
- mCloseImage->setAlpha(alpha);
- mStickyImageUp->setAlpha(alpha);
- mStickyImageDown->setAlpha(alpha);
-}
-
-int Skin::getMinWidth() const
-{
- return mBorder.grid[ImageRect::UPPER_LEFT]->getWidth() +
- mBorder.grid[ImageRect::UPPER_RIGHT]->getWidth();
-}
-
-int Skin::getMinHeight() const
-{
- return mBorder.grid[ImageRect::UPPER_LEFT]->getHeight() +
- mBorder.grid[ImageRect::LOWER_LEFT]->getHeight();
-}
-
-Theme::Theme():
- Palette(THEME_COLORS_END),
- mMinimumOpacity(-1.0f),
- mProgressColors(ProgressColors(THEME_PROG_END))
-{
- initDefaultThemePath();
-
- config.addListener("guialpha", this);
- loadColors();
-
- mColors[HIGHLIGHT].ch = 'H';
- mColors[CHAT].ch = 'C';
- mColors[GM].ch = 'G';
- mColors[PLAYER].ch = 'Y';
- mColors[WHISPER].ch = 'W';
- mColors[IS].ch = 'I';
- mColors[PARTY].ch = 'P';
- mColors[GUILD].ch = 'U';
- mColors[SERVER].ch = 'S';
- mColors[LOGGER].ch = 'L';
- mColors[HYPERLINK].ch = '<';
-}
-
-Theme::~Theme()
-{
- delete_all(mSkins);
- config.removeListener("guialpha", this);
- delete_all(mProgressColors);
-}
-
-Theme *Theme::instance()
-{
- if (!mInstance)
- mInstance = new Theme;
-
- return mInstance;
-}
-
-void Theme::deleteInstance()
-{
- delete mInstance;
- mInstance = 0;
-}
-
-gcn::Color Theme::getProgressColor(int type, float progress)
-{
- DyePalette *dye = mInstance->mProgressColors[type];
-
- int color[3] = {0, 0, 0};
- dye->getColor(progress, color);
-
- return gcn::Color(color[0], color[1], color[2]);
-}
-
-Skin *Theme::load(const std::string &filename, const std::string &defaultPath)
-{
- // Check if this skin was already loaded
- SkinIterator skinIterator = mSkins.find(filename);
- if (mSkins.end() != skinIterator)
- {
- skinIterator->second->instances++;
- return skinIterator->second;
- }
-
- Skin *skin = readSkin(filename);
-
- if (!skin)
- {
- // Try falling back on the defaultPath if this makes sense
- if (filename != defaultPath)
- {
- logger->log("Error loading skin '%s', falling back on default.",
- filename.c_str());
-
- skin = readSkin(defaultPath);
- }
-
- if (!skin)
- {
- logger->error(strprintf("Error: Loading default skin '%s' failed. "
- "Make sure the skin file is valid.",
- defaultPath.c_str()));
- }
- }
-
- // Add the skin to the loaded skins
- mSkins[filename] = skin;
-
- return skin;
-}
-
-void Theme::setMinimumOpacity(float minimumOpacity)
-{
- if (minimumOpacity > 1.0f) return;
-
- mMinimumOpacity = minimumOpacity;
- updateAlpha();
-}
-
-void Theme::updateAlpha()
-{
- for (SkinIterator iter = mSkins.begin(); iter != mSkins.end(); ++iter)
- iter->second->updateAlpha(mMinimumOpacity);
-}
-
-void Theme::optionChanged(const std::string &)
-{
- updateAlpha();
-}
-
-Skin *Theme::readSkin(const std::string &filename)
-{
- if (filename.empty())
- return 0;
-
- logger->log("Loading skin '%s'.", filename.c_str());
-
- XML::Document doc(resolveThemePath(filename));
- xmlNodePtr rootNode = doc.rootNode();
-
- if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "skinset"))
- return 0;
-
- const std::string skinSetImage = XML::getProperty(rootNode, "image", "");
-
- if (skinSetImage.empty())
- {
- logger->log("Theme::readSkin(): Skinset does not define an image!");
- return 0;
- }
-
- logger->log("Theme::load(): <skinset> defines '%s' as a skin image.",
- skinSetImage.c_str());
-
- Image *dBorders = Theme::getImageFromTheme(skinSetImage);
- ImageRect border;
- memset(&border, 0, sizeof(ImageRect));
-
- // iterate <widget>'s
- for_each_xml_child_node(widgetNode, rootNode)
- {
- if (!xmlStrEqual(widgetNode->name, BAD_CAST "widget"))
- continue;
-
- const std::string widgetType =
- XML::getProperty(widgetNode, "type", "unknown");
- if (widgetType == "Window")
- {
- // Iterate through <part>'s
- // LEEOR / TODO:
- // We need to make provisions to load in a CloseButton image. For
- // now it can just be hard-coded.
- for_each_xml_child_node(partNode, widgetNode)
- {
- if (!xmlStrEqual(partNode->name, BAD_CAST "part"))
- continue;
-
- const std::string partType =
- XML::getProperty(partNode, "type", "unknown");
- // TOP ROW
- const int xPos = XML::getProperty(partNode, "xpos", 0);
- const int yPos = XML::getProperty(partNode, "ypos", 0);
- const int width = XML::getProperty(partNode, "width", 1);
- const int height = XML::getProperty(partNode, "height", 1);
-
- if (partType == "top-left-corner")
- border.grid[0] = dBorders->getSubImage(xPos, yPos, width, height);
- else if (partType == "top-edge")
- border.grid[1] = dBorders->getSubImage(xPos, yPos, width, height);
- else if (partType == "top-right-corner")
- border.grid[2] = dBorders->getSubImage(xPos, yPos, width, height);
-
- // MIDDLE ROW
- else if (partType == "left-edge")
- border.grid[3] = dBorders->getSubImage(xPos, yPos, width, height);
- else if (partType == "bg-quad")
- border.grid[4] = dBorders->getSubImage(xPos, yPos, width, height);
- else if (partType == "right-edge")
- border.grid[5] = dBorders->getSubImage(xPos, yPos, width, height);
-
- // BOTTOM ROW
- else if (partType == "bottom-left-corner")
- border.grid[6] = dBorders->getSubImage(xPos, yPos, width, height);
- else if (partType == "bottom-edge")
- border.grid[7] = dBorders->getSubImage(xPos, yPos, width, height);
- else if (partType == "bottom-right-corner")
- border.grid[8] = dBorders->getSubImage(xPos, yPos, width, height);
-
- else
- logger->log("Theme::readSkin(): Unknown part type '%s'",
- partType.c_str());
- }
- }
- else
- {
- logger->log("Theme::readSkin(): Unknown widget type '%s'",
- widgetType.c_str());
- }
- }
-
- dBorders->decRef();
-
- logger->log("Finished loading skin.");
-
- // Hard-coded for now until we update the above code to look for window buttons
- Image *closeImage = Theme::getImageFromTheme("close_button.png");
- Image *sticky = Theme::getImageFromTheme("sticky_button.png");
- Image *stickyImageUp = sticky->getSubImage(0, 0, 15, 15);
- Image *stickyImageDown = sticky->getSubImage(15, 0, 15, 15);
- sticky->decRef();
-
- Skin *skin = new Skin(border, closeImage, stickyImageUp, stickyImageDown,
- filename);
- skin->updateAlpha(mMinimumOpacity);
- return skin;
-}
-
-bool Theme::tryThemePath(std::string themePath)
-{
- if (!themePath.empty())
- {
- themePath = defaultThemePath + themePath;
-
- if (PHYSFS_exists(themePath.c_str()))
- {
- mThemePath = themePath;
- return true;
- }
- }
-
- return false;
-}
-
-void Theme::prepareThemePath()
-{
- // Ensure the Theme object has been created
- instance();
-
- // Try theme from settings
- if (!tryThemePath(config.getValue("theme", "")))
- // Try theme from branding
- if (!tryThemePath(branding.getValue("theme", "")))
- // Use default
- mThemePath = defaultThemePath;
-
- instance()->loadColors(mThemePath);
-}
-
-std::string Theme::resolveThemePath(const std::string &path)
-{
- // Need to strip off any dye info for the existence tests
- int pos = path.find('|');
- std::string file;
- if (pos > 0)
- file = path.substr(0, pos);
- else
- file = path;
-
- // Might be a valid path already
- if (PHYSFS_exists(file.c_str()))
- return path;
-
- // Try the theme
- file = getThemePath() + "/" + file;
- if (PHYSFS_exists(file.c_str()))
- return getThemePath() + "/" + path;
-
- // Backup
- return std::string(defaultThemePath) + "/" + path;
-}
-
-Image *Theme::getImageFromTheme(const std::string &path)
-{
- ResourceManager *resman = ResourceManager::getInstance();
- return resman->getImage(resolveThemePath(path));
-}
-
-ImageSet *Theme::getImageSetFromTheme(const std::string &path,
- int w, int h)
-{
- ResourceManager *resman = ResourceManager::getInstance();
- return resman->getImageSet(resolveThemePath(path), w, h);
-}
-
-static int readColorType(const std::string &type)
-{
- static std::string colors[] = {
- "TEXT",
- "SHADOW",
- "OUTLINE",
- "PROGRESS_BAR",
- "BUTTON",
- "BUTTON_DISABLED",
- "TAB",
- "PARTY_CHAT_TAB",
- "PARTY_SOCIAL_TAB",
- "BACKGROUND",
- "HIGHLIGHT",
- "TAB_FLASH",
- "SHOP_WARNING",
- "ITEM_EQUIPPED",
- "CHAT",
- "GM",
- "PLAYER",
- "WHISPER",
- "IS",
- "PARTY",
- "GUILD",
- "SERVER",
- "LOGGER",
- "HYPERLINK",
- "UNKNOWN_ITEM",
- "GENERIC",
- "HEAD",
- "USABLE",
- "TORSO",
- "ONEHAND",
- "LEGS",
- "FEET",
- "TWOHAND",
- "SHIELD",
- "RING",
- "NECKLACE",
- "ARMS",
- "AMMO",
- "SERVER_VERSION_NOT_SUPPORTED"
- };
-
- if (type.empty())
- return -1;
-
- for (int i = 0; i < Theme::THEME_COLORS_END; i++)
- {
- if (compareStrI(type, colors[i]) == 0)
- {
- return i;
- }
- }
-
- return -1;
-}
-
-static gcn::Color readColor(const std::string &description)
-{
- int size = description.length();
- if (size < 7 || description[0] != '#')
- {
- error:
- logger->log("Error, invalid theme color palette: %s",
- description.c_str());
- return Palette::BLACK;
- }
-
- int v = 0;
- for (int i = 1; i < 7; ++i)
- {
- char c = description[i];
- int n;
-
- if ('0' <= c && c <= '9')
- n = c - '0';
- else if ('A' <= c && c <= 'F')
- n = c - 'A' + 10;
- else if ('a' <= c && c <= 'f')
- n = c - 'a' + 10;
- else
- goto error;
-
- v = (v << 4) | n;
- }
-
- return gcn::Color(v);
-}
-
-static Palette::GradientType readColorGradient(const std::string &grad)
-{
- static std::string grads[] = {
- "STATIC",
- "PULSE",
- "SPECTRUM",
- "RAINBOW"
- };
-
- if (grad.empty())
- return Palette::STATIC;
-
- for (int i = 0; i < 4; i++)
- {
- if (compareStrI(grad, grads[i]))
- return (Palette::GradientType) i;
- }
-
- return Palette::STATIC;
-}
-
-static int readProgressType(const std::string &type)
-{
- static std::string colors[] = {
- "DEFAULT",
- "HP",
- "MP",
- "NO_MP",
- "EXP",
- "INVY_SLOTS",
- "WEIGHT",
- "JOB"
- };
-
- if (type.empty())
- return -1;
-
- for (int i = 0; i < Theme::THEME_PROG_END; i++)
- {
- if (compareStrI(type, colors[i]) == 0)
- return i;
- }
-
- return -1;
-}
-
-void Theme::loadColors(std::string file)
-{
- if (file == defaultThemePath)
- return; // No need to reload
-
- if (file == "")
- file = defaultThemePath;
-
- file += "/colors.xml";
-
- XML::Document doc(file);
- xmlNodePtr root = doc.rootNode();
-
- if (!root || !xmlStrEqual(root->name, BAD_CAST "colors"))
- {
- logger->log("Error loading colors file: %s", file.c_str());
- return;
- }
-
- int type;
- std::string temp;
- gcn::Color color;
- GradientType grad;
-
- for_each_xml_child_node(node, root)
- {
- if (xmlStrEqual(node->name, BAD_CAST "color"))
- {
- type = readColorType(XML::getProperty(node, "id", ""));
- if (type < 0) // invalid or no type given
- continue;
-
- temp = XML::getProperty(node, "color", "");
- if (temp.empty()) // no color set, so move on
- continue;
-
- color = readColor(temp);
- grad = readColorGradient(XML::getProperty(node, "effect", ""));
-
- mColors[type].set(type, color, grad, 10);
- }
- else if (xmlStrEqual(node->name, BAD_CAST "progressbar"))
- {
- type = readProgressType(XML::getProperty(node, "id", ""));
- if (type < 0) // invalid or no type given
- continue;
-
- mProgressColors[type] = new DyePalette(XML::getProperty(node,
- "color", ""));
- }
- }
-}
diff --git a/src/gui/theme.h b/src/gui/theme.h
deleted file mode 100644
index 3a5aa41a..00000000
--- a/src/gui/theme.h
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * Gui Skinning
- * Copyright (C) 2008 The Legend of Mazzeroth Development Team
- * Copyright (C) 2009 Aethyra Development Team
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- *
- * This file is part of The Mana 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 SKIN_H
-#define SKIN_H
-
-#include "configlistener.h"
-#include "graphics.h"
-
-#include "gui/palette.h"
-
-#include <map>
-#include <string>
-
-class DyePalette;
-class Image;
-class ImageSet;
-class ProgressBar;
-
-class Skin
-{
- public:
- Skin(ImageRect skin, Image *close, Image *stickyUp, Image *stickyDown,
- const std::string &filePath,
- const std::string &name = "");
-
- ~Skin();
-
- /**
- * Returns the skin's name. Useful for giving a human friendly skin
- * name if a dialog for skin selection for a specific window type is
- * done.
- */
- const std::string &getName() const { return mName; }
-
- /**
- * Returns the skin's xml file path.
- */
- const std::string &getFilePath() const { return mFilePath; }
-
- /**
- * Returns the background skin.
- */
- const ImageRect &getBorder() const { return mBorder; }
-
- /**
- * Returns the image used by a close button for this skin.
- */
- Image *getCloseImage() const { return mCloseImage; }
-
- /**
- * Returns the image used by a sticky button for this skin.
- */
- Image *getStickyImage(bool state) const
- { return state ? mStickyImageDown : mStickyImageUp; }
-
- /**
- * Returns the minimum width which can be used with this skin.
- */
- int getMinWidth() const;
-
- /**
- * Returns the minimum height which can be used with this skin.
- */
- int getMinHeight() const;
-
- /**
- * Updates the alpha value of the skin
- */
- void updateAlpha(float minimumOpacityAllowed = 0.0f);
-
- int instances;
-
- private:
- std::string mFilePath; /**< File name path for the skin */
- std::string mName; /**< Name of the skin to use */
- ImageRect mBorder; /**< The window border and background */
- Image *mCloseImage; /**< Close Button Image */
- Image *mStickyImageUp; /**< Sticky Button Image */
- Image *mStickyImageDown; /**< Sticky Button Image */
-};
-
-class Theme : public Palette, public ConfigListener
-{
- public:
- static Theme *instance();
- static void deleteInstance();
-
- static void prepareThemePath();
- static std::string getThemePath() { return mThemePath; }
-
- /**
- * Returns the patch to the given gui resource relative to the theme
- * or, if it isn't in the theme, relative to 'graphics/gui'.
- */
- static std::string resolveThemePath(const std::string &path);
-
- static Image *getImageFromTheme(const std::string &path);
- static ImageSet *getImageSetFromTheme(const std::string &path,
- int w, int h);
-
- enum ThemePalette {
- TEXT,
- SHADOW,
- OUTLINE,
- PROGRESS_BAR,
- BUTTON,
- BUTTON_DISABLED,
- TAB,
- PARTY_CHAT_TAB,
- PARTY_SOCIAL_TAB,
- BACKGROUND,
- HIGHLIGHT,
- TAB_FLASH,
- SHOP_WARNING,
- ITEM_EQUIPPED,
- CHAT,
- GM,
- PLAYER,
- WHISPER,
- IS,
- PARTY,
- GUILD,
- SERVER,
- LOGGER,
- HYPERLINK,
- UNKNOWN_ITEM,
- GENERIC,
- HEAD,
- USABLE,
- TORSO,
- ONEHAND,
- LEGS,
- FEET,
- TWOHAND,
- SHIELD,
- RING,
- NECKLACE,
- ARMS,
- AMMO,
- SERVER_VERSION_NOT_SUPPORTED,
- THEME_COLORS_END
- };
-
- enum ProgressPalette {
- PROG_DEFAULT,
- PROG_HP,
- PROG_MP,
- PROG_NO_MP,
- PROG_EXP,
- PROG_INVY_SLOTS,
- PROG_WEIGHT,
- PROG_JOB,
- THEME_PROG_END
- };
-
- /**
- * Gets the color associated with the type. Sets the alpha channel
- * before returning.
- *
- * @param type the color type requested
- * @param alpha alpha channel to use
- *
- * @return the requested color
- */
- inline static const gcn::Color &getThemeColor(int type, int alpha = 255)
- {
- return mInstance->getColor(type, alpha);
- }
-
- const static gcn::Color &getThemeColor(char c, bool &valid)
- {
- return mInstance->getColor(c, valid);
- }
-
- static gcn::Color getProgressColor(int type, float progress);
-
- /**
- * Loads a skin.
- */
- Skin *load(const std::string &filename,
- const std::string &defaultPath = getThemePath());
-
- /**
- * Updates the alpha values of all of the skins.
- */
- void updateAlpha();
-
- /**
- * Get the minimum opacity allowed to skins.
- */
- float getMinimumOpacity()
- { return mMinimumOpacity; }
-
- /**
- * Set the minimum opacity allowed to skins.
- * Set a negative value to free the minimum allowed.
- */
- void setMinimumOpacity(float minimumOpacity);
-
- void optionChanged(const std::string &);
-
- private:
- Theme();
- ~Theme();
-
- Skin *readSkin(const std::string &filename);
-
- // Map containing all window skins
- typedef std::map<std::string, Skin*> Skins;
- typedef Skins::iterator SkinIterator;
-
- Skins mSkins;
-
- static std::string mThemePath;
- static Theme *mInstance;
-
- static bool tryThemePath(std::string themePath);
-
- void loadColors(std::string file = "");
-
- /**
- * Tells if the current skins opacity
- * should not get less than the given value
- */
- float mMinimumOpacity;
-
- typedef std::vector<DyePalette*> ProgressColors;
- ProgressColors mProgressColors;
-};
-
-#endif
diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp
index dcb38e8e..37662bef 100644
--- a/src/gui/trade.cpp
+++ b/src/gui/trade.cpp
@@ -21,9 +21,11 @@
#include "gui/trade.h"
+#include "event.h"
#include "inventory.h"
#include "item.h"
#include "localplayer.h"
+#include "playerinfo.h"
#include "units.h"
#include "gui/inventorywindow.h"
@@ -31,7 +33,6 @@
#include "gui/setup.h"
#include "gui/widgets/button.h"
-#include "gui/widgets/chattab.h"
#include "gui/widgets/itemcontainer.h"
#include "gui/widgets/label.h"
#include "gui/widgets/scrollarea.h"
@@ -59,7 +60,7 @@ TradeWindow::TradeWindow():
mMyInventory(new Inventory(Inventory::TRADE)),
mPartnerInventory(new Inventory(Inventory::TRADE)),
mStatus(PROPOSING)
-{
+{
setWindowName("Trade");
setResizable(true);
setCloseButton(true);
@@ -96,7 +97,7 @@ TradeWindow::TradeWindow():
mMoneyLabel = new Label(strprintf(_("You get %s"), ""));
gcn::Label *mMoneyLabel2 = new Label(_("You give:"));
-
+
mMoneyField = new TextField;
mMoneyField->setWidth(40);
mMoneyChangeButton = new Button(_("Change"), "money", this);
@@ -140,18 +141,6 @@ void TradeWindow::addItem(int id, bool own, int quantity)
(own ? mMyInventory : mPartnerInventory)->addItem(id, quantity);
}
-void TradeWindow::addItem(int id, bool own, int quantity, bool equipment)
-{
- if (own)
- {
- mMyInventory->addItem(id, quantity, equipment);
- }
- else
- {
- mPartnerInventory->addItem(id, quantity, equipment);
- }
-}
-
void TradeWindow::changeQuantity(int index, bool own, int quantity)
{
if (own)
@@ -270,9 +259,8 @@ void TradeWindow::action(const gcn::ActionEvent &event)
if (mMyInventory->contains(item))
{
- localChatTab->chatLog(_("Failed adding item. You can not "
- "overlap one kind of item on the window."),
- BY_SERVER);
+ SERVER_NOTICE(_("Failed adding item. You can not "
+ "overlap one kind of item on the window."))
return;
}
@@ -285,7 +273,7 @@ void TradeWindow::action(const gcn::ActionEvent &event)
{
setVisible(false);
reset();
- player_node->setTrading(false);
+ PlayerInfo::setTrading(false);
Net::getTradeHandler()->cancel();
}
@@ -310,11 +298,10 @@ void TradeWindow::action(const gcn::ActionEvent &event)
return;
int v = atoi(mMoneyField->getText().c_str());
- int curMoney = player_node->getMoney();
+ int curMoney = PlayerInfo::getAttribute(MONEY);
if (v > curMoney)
{
- localChatTab->chatLog(_("You don't have enough money."),
- BY_SERVER);
+ SERVER_NOTICE(_("You don't have enough money."))
v = curMoney;
}
Net::getTradeHandler()->setMoney(v);
diff --git a/src/gui/trade.h b/src/gui/trade.h
index ac602669..e22f8863 100644
--- a/src/gui/trade.h
+++ b/src/gui/trade.h
@@ -22,8 +22,6 @@
#ifndef TRADE_H
#define TRADE_H
-#include "guichanfwd.h"
-
#include "gui/widgets/window.h"
#include <guichan/actionlistener.hpp>
diff --git a/src/gui/unregisterdialog.h b/src/gui/unregisterdialog.h
index dd330afd..87999d5d 100644
--- a/src/gui/unregisterdialog.h
+++ b/src/gui/unregisterdialog.h
@@ -22,8 +22,6 @@
#ifndef UNREGISTERDIALOG_H
#define UNREGISTERDIALOG_H
-#include "guichanfwd.h"
-
#include "gui/widgets/window.h"
#include <guichan/actionlistener.hpp>
diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp
index 7448a102..23d23b5e 100644
--- a/src/gui/updatewindow.cpp
+++ b/src/gui/updatewindow.cpp
@@ -476,7 +476,7 @@ void UpdaterWindow::logic()
// This statement checks to see if the file type is music, and if download-music is true
// If it fails, this statement returns true, and results in not downloading the file
// Else it will ignore the break, and download the file.
- if ( !(thisFile.type == "music" && config.getValue("download-music", false)) )
+ if ( !(thisFile.type == "music" && config.getBoolValue("download-music")) )
{
mUpdateIndex++;
break;
diff --git a/src/gui/userpalette.cpp b/src/gui/userpalette.cpp
deleted file mode 100644
index 9e202fe9..00000000
--- a/src/gui/userpalette.cpp
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * Configurable text colors
- * Copyright (C) 2008 Douglas Boffey <dougaboffey@netscape.net>
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- *
- * This file is part of The Mana 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 "userpalette.h"
-
-#include "configuration.h"
-#include "client.h"
-
-#include "gui/gui.h"
-
-#include "utils/gettext.h"
-#include "utils/stringutils.h"
-
-#include <math.h>
-
-const std::string ColorTypeNames[] = {
- "ColorBeing",
- "ColorPlayer",
- "ColorSelf",
- "ColorGM",
- "ColorNPC",
- "ColorMonster",
- "ColorParty",
- "ColorGuild",
- "ColorParticle",
- "ColorExperience",
- "ColorPickup",
- "ColorHitPlayerMonster",
- "ColorHitMonsterPlayer",
- "ColorHitCritical",
- "ColorHitLocalPlayerMonster",
- "ColorHitLocalPlayerCritical",
- "ColorHitLocalPlayerMiss",
- "ColorMiss"
-};
-
-std::string UserPalette::getConfigName(const std::string &typeName)
-{
- std::string res = "Color" + typeName;
-
- int pos = 5;
- for (size_t i = 0; i < typeName.length(); i++)
- {
- if (i == 0 || typeName[i] == '_')
- {
- if (i > 0)
- i++;
-
- res[pos] = typeName[i];
- }
- else
- {
- res[pos] = tolower(typeName[i]);
- }
- pos++;
- }
- res.erase(pos, res.length() - pos);
-
- return res;
-}
-
-UserPalette::UserPalette():
- Palette(USER_COLOR_LAST)
-{
- mColors[BEING] = ColorElem();
- mColors[PC] = ColorElem();
- mColors[SELF] = ColorElem();
- mColors[GM] = ColorElem();
- mColors[NPC] = ColorElem();
- mColors[MONSTER] = ColorElem();
-
- addColor(BEING, 0xffffff, STATIC, _("Being"));
- addColor(PC, 0xffffff, STATIC, _("Other Players' Names"));
- addColor(SELF, 0xff8040, STATIC, _("Own Name"));
- addColor(GM, 0x00ff00, STATIC, _("GM Names"));
- addColor(NPC, 0xc8c8ff, STATIC, _("NPCs"));
- addColor(MONSTER, 0xff4040, STATIC, _("Monsters"));
- addColor(PARTY, 0xff00d8, STATIC, _("Party Members"));
- addColor(GUILD, 0xff00d8, STATIC, _("Guild Members"));
- addColor(PARTICLE, 0xffffff, STATIC, _("Particle Effects"));
- addColor(PICKUP_INFO, 0x28dc28, STATIC, _("Pickup Notification"));
- addColor(EXP_INFO, 0xffff00, STATIC, _("Exp Notification"));
- addColor(HIT_PLAYER_MONSTER, 0x0064ff, STATIC,
- _("Other Player Hits Monster"));
- addColor(HIT_MONSTER_PLAYER, 0xff3232, STATIC, _("Monster Hits Player"));
- addColor(HIT_CRITICAL, 0xff0000, RAINBOW, _("Critical Hit"));
- addColor(HIT_LOCAL_PLAYER_MONSTER, 0x00ff00, STATIC,
- _("Local Player Hits Monster"));
- addColor(HIT_LOCAL_PLAYER_CRITICAL, 0xff0000, RAINBOW,
- _("Local Player Critical Hit"));
- addColor(HIT_LOCAL_PLAYER_MISS, 0x00ffa6, STATIC,
- _("Local Player Miss"));
- addColor(MISS, 0xffff00, STATIC, _("Misses"));
- commit(true);
-}
-
-UserPalette::~UserPalette()
-{
- for (Colors::iterator col = mColors.begin(),
- colEnd = mColors.end(); col != colEnd; ++col)
- {
- const std::string &configName = ColorTypeNames[col->type];
- config.setValue(configName + "Gradient", col->committedGrad);
-
- if (col->grad != STATIC)
- config.setValue(configName + "Delay", col->delay);
-
- if (col->grad == STATIC || col->grad == PULSE)
- {
- char buffer[20];
- sprintf(buffer, "0x%06x", col->getRGB());
- config.setValue(configName, std::string(buffer));
- }
- }
-}
-
-void UserPalette::setColor(int type, int r, int g, int b)
-{
- mColors[type].color.r = r;
- mColors[type].color.g = g;
- mColors[type].color.b = b;
-}
-
-void UserPalette::setGradient(int type, GradientType grad)
-{
- ColorElem *elem = &mColors[type];
- if (elem->grad != STATIC && grad == STATIC)
- {
- for (size_t i = 0; i < mGradVector.size(); i++)
- {
- if (mGradVector[i] == elem)
- {
- mGradVector.erase(mGradVector.begin() + i);
- break;
- }
- }
- }
- else if (elem->grad == STATIC && grad != STATIC)
- {
- mGradVector.push_back(elem);
- }
-
- if (elem->grad != grad)
- {
- elem->grad = grad;
- }
-}
-
-std::string UserPalette::getElementAt(int i)
-{
- if (i < 0 || i >= getNumberOfElements())
- {
- return "";
- }
- return mColors[i].text;
-}
-
-void UserPalette::commit(bool commitNonStatic)
-{
- for (Colors::iterator i = mColors.begin(), iEnd = mColors.end();
- i != iEnd; ++i)
- {
- i->committedGrad = i->grad;
- i->committedDelay = i->delay;
- if (commitNonStatic || i->grad == STATIC)
- {
- i->committedColor = i->color;
- }
- else if (i->grad == PULSE)
- {
- i->committedColor = i->testColor;
- }
- }
-}
-
-void UserPalette::rollback()
-{
- for (Colors::iterator i = mColors.begin(), iEnd = mColors.end();
- i != iEnd; ++i)
- {
- if (i->grad != i->committedGrad)
- {
- setGradient(i->type, i->committedGrad);
- }
- setGradientDelay(i->type, i->committedDelay);
- setColor(i->type, i->committedColor.r,
- i->committedColor.g, i->committedColor.b);
- if (i->grad == PULSE)
- {
- i->testColor.r = i->committedColor.r;
- i->testColor.g = i->committedColor.g;
- i->testColor.b = i->committedColor.b;
- }
- }
-}
-
-int UserPalette::getColorTypeAt(int i)
-{
- if (i < 0 || i >= getNumberOfElements())
- {
- return BEING;
- }
-
- return mColors[i].type;
-}
-
-void UserPalette::addColor(int type, int rgb, Palette::GradientType grad,
- const std::string &text, int delay)
-{
- const std::string &configName = ColorTypeNames[type];
- char buffer[20];
- sprintf(buffer, "0x%06x", rgb);
- const std::string rgbString = config.getValue(configName,
- std::string(buffer));
- unsigned int rgbValue = 0;
- if (rgbString.length() == 8 && rgbString[0] == '0' && rgbString[1] == 'x')
- rgbValue = atox(rgbString);
- else
- rgbValue = atoi(rgbString.c_str());
- gcn::Color trueCol = rgbValue;
- grad = (GradientType) config.getValue(configName + "Gradient", grad);
- delay = (int) config.getValue(configName + "Delay", delay);
- mColors[type].set(type, trueCol, grad, delay);
- mColors[type].text = text;
-
- if (grad != STATIC)
- mGradVector.push_back(&mColors[type]);
-}
diff --git a/src/gui/userpalette.h b/src/gui/userpalette.h
deleted file mode 100644
index be02db10..00000000
--- a/src/gui/userpalette.h
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Configurable text colors
- * Copyright (C) 2008 Douglas Boffey <dougaboffey@netscape.net>
- * Copyright (C) 2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- *
- * This file is part of The Mana 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 USER_PALETTE_H
-#define USER_PALETTE_H
-
-#include "gui/palette.h"
-
-#include <guichan/listmodel.hpp>
-
-/**
- * Class controlling the game's color palette.
- */
-class UserPalette : public Palette, public gcn::ListModel
-{
- public:
- /** List of all colors that are configurable. */
- enum {
- BEING,
- PC,
- SELF,
- GM,
- NPC,
- MONSTER,
- PARTY,
- GUILD,
- PARTICLE,
- EXP_INFO,
- PICKUP_INFO,
- HIT_PLAYER_MONSTER,
- HIT_MONSTER_PLAYER,
- HIT_CRITICAL,
- HIT_LOCAL_PLAYER_MONSTER,
- HIT_LOCAL_PLAYER_CRITICAL,
- HIT_LOCAL_PLAYER_MISS,
- MISS,
- USER_COLOR_LAST
- };
-
- /**
- * Constructor
- */
- UserPalette();
-
- /**
- * Destructor
- */
- ~UserPalette();
-
- /**
- * Gets the committed color associated with the specified type.
- *
- * @param type the color type requested
- *
- * @return the requested committed color
- */
- inline const gcn::Color &getCommittedColor(int type)
- {
- return mColors[type].committedColor;
- }
-
- /**
- * Gets the test color associated with the specified type.
- *
- * @param type the color type requested
- *
- * @return the requested test color
- */
- inline const gcn::Color &getTestColor(int type)
- {
- return mColors[type].testColor;
- }
-
- /**
- * Sets the test color associated with the specified type.
- *
- * @param type the color type requested
- * @param color the color that should be tested
- */
- inline void setTestColor(int type, gcn::Color color)
- {
- mColors[type].testColor = color;
- }
-
- /**
- * Sets the color for the specified type.
- *
- * @param type color to be set
- * @param r red component
- * @param g green component
- * @param b blue component
- */
- void setColor(int type, int r, int g, int b);
-
- /**
- * Sets the gradient type for the specified color.
- *
- * @param grad gradient type to set
- */
- void setGradient(int type, Palette::GradientType grad);
-
- /**
- * Sets the gradient delay for the specified color.
- *
- * @param grad gradient type to set
- */
- void setGradientDelay(int type, int delay)
- { mColors[type].delay = delay; }
-
- /**
- * Returns the number of colors known.
- *
- * @return the number of colors known
- */
- inline int getNumberOfElements() { return mColors.size(); }
-
- /**
- * Returns the name of the ith color.
- *
- * @param i index of color interested in
- *
- * @return the name of the color
- */
- std::string getElementAt(int i);
-
- /**
- * Commit the colors
- */
- inline void commit()
- {
- commit(false);
- }
-
- /**
- * Rollback the colors
- */
- void rollback();
-
- /**
- * Gets the ColorType used by the color for the element at index i in
- * the current color model.
- *
- * @param i the index of the color
- *
- * @return the color type of the color with the given index
- */
- int getColorTypeAt(int i);
-
- private:
- /**
- * Define a color replacement.
- *
- * @param i the index of the color to replace
- * @param r red component
- * @param g green component
- * @param b blue component
- */
- void setColorAt(int i, int r, int g, int b);
-
- /**
- * Commit the colors. Commit the non-static color values, if
- * commitNonStatic is true. Only needed in the constructor.
- */
- void commit(bool commitNonStatic);
-
- /**
- * Prefixes the given string with "Color", lowercases all letters but
- * the first and all following a '_'. All '_'s will be removed.
- *
- * E.g.: HIT_PLAYER_MONSTER -> HitPlayerMonster
- *
- * @param typeName string to transform
- *
- * @return the transformed string
- */
- static std::string getConfigName(const std::string &typeName);
-
- /**
- * Initialise color
- *
- * @param c character that needs initialising
- * @param rgb default color if not found in config
- * @param text identifier of color
- */
- void addColor(int type, int rgb, GradientType grad,
- const std::string &text, int delay = GRADIENT_DELAY);
-};
-
-extern UserPalette *userPalette;
-
-#endif // USER_PALETTE_H
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index b18b9b0b..ac910d5f 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -21,16 +21,14 @@
#include "gui/viewport.h"
+#include "actorspritemanager.h"
#include "client.h"
-#include "beingmanager.h"
#include "configuration.h"
-#include "flooritemmanager.h"
#include "graphics.h"
#include "keyboardconfig.h"
#include "localplayer.h"
#include "map.h"
-#include "monster.h"
-#include "npc.h"
+#include "playerinfo.h"
#include "textmanager.h"
#include "gui/gui.h"
@@ -40,7 +38,6 @@
#include "net/net.h"
-#include "resources/monsterinfo.h"
#include "resources/resourcemanager.h"
#include "utils/stringutils.h"
@@ -62,18 +59,18 @@ Viewport::Viewport():
setOpaque(false);
addMouseListener(this);
- mScrollLaziness = (int) config.getValue("ScrollLaziness", 16);
- mScrollRadius = (int) config.getValue("ScrollRadius", 0);
- mScrollCenterOffsetX = (int) config.getValue("ScrollCenterOffsetX", 0);
- mScrollCenterOffsetY = (int) config.getValue("ScrollCenterOffsetY", 0);
-
- config.addListener("ScrollLaziness", this);
- config.addListener("ScrollRadius", this);
+ mScrollLaziness = config.getIntValue("ScrollLaziness");
+ mScrollRadius = config.getIntValue("ScrollRadius");
+ mScrollCenterOffsetX = config.getIntValue("ScrollCenterOffsetX");
+ mScrollCenterOffsetY = config.getIntValue("ScrollCenterOffsetY");
mPopupMenu = new PopupMenu;
mBeingPopup = new BeingPopup;
setFocusable(true);
+
+ listen(CHANNEL_CONFIG);
+ listen(CHANNEL_ACTORSPRITE);
}
Viewport::~Viewport()
@@ -207,12 +204,15 @@ void Viewport::draw(gcn::Graphics *gcnGraphics)
}
// Draw player names, speech, and emotion sprite as needed
- const Beings &beings = beingManager->getAll();
- for (Beings::const_iterator i = beings.begin(), i_end = beings.end();
- i != i_end; ++i)
+ const ActorSprites &actors = actorSpriteManager->getAll();
+ for (ActorSpritesConstIterator it = actors.begin(), it_end = actors.end();
+ it != it_end; it++)
{
- (*i)->drawSpeech((int) mPixelViewX, (int) mPixelViewY);
- (*i)->drawEmotion(graphics, (int) mPixelViewX, (int) mPixelViewY);
+ if ((*it)->getType() == ActorSprite::FLOOR_ITEM)
+ continue;
+
+ Being *b = static_cast<Being*>(*it);
+ b->drawSpeech((int) mPixelViewX, (int) mPixelViewY);
}
if (miniStatusWindow)
@@ -345,7 +345,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
return;
// Check if we are busy
- if (NPC::isTalking())
+ if (PlayerInfo::isTalking())
return;
mPlayerFollowMouse = false;
@@ -354,9 +354,8 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
const int pixelX = event.getX() + (int) mPixelViewX;
const int pixelY = event.getY() + (int) mPixelViewY;
- mHoverBeing = beingManager->findBeingByPixel(pixelX, pixelY);
- mHoverItem = floorItemManager->
- findByCoordinates(pixelX / mMap->getTileWidth(),
+ mHoverBeing = actorSpriteManager->findBeingByPixel(pixelX, pixelY);
+ mHoverItem = actorSpriteManager->findItem(pixelX / mMap->getTileWidth(),
pixelY / mMap->getTileHeight());
updateCursorType();
@@ -389,33 +388,20 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
// Interact with some being
if (mHoverBeing)
{
- switch (mHoverBeing->getType())
+ if (mHoverBeing->canTalk())
+ mHoverBeing->talkTo();
+ else
{
- // Talk to NPCs
- case Being::NPC:
- static_cast<NPC*>(mHoverBeing)->talk();
- break;
-
- // Attack or walk to monsters or players
- case Being::MONSTER:
- case Being::PLAYER:
- // Ignore it if its dead
- if (!mHoverBeing->isAlive())
- break;
-
+ // Ignore it if its dead
+ if (mHoverBeing->isAlive())
+ {
if (player_node->withinAttackRange(mHoverBeing) ||
keyboard.isKeyActive(keyboard.KEY_ATTACK))
- {
player_node->attack(mHoverBeing,
!keyboard.isKeyActive(keyboard.KEY_TARGET));
- }
else
- {
player_node->setGotoTarget(mHoverBeing);
- }
- break;
- default:
- break;
+ }
}
// Picks up a item if we clicked on one
}
@@ -440,8 +426,8 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
else if (event.getButton() == gcn::MouseEvent::MIDDLE)
{
// Find the being nearest to the clicked position
- Being *target = beingManager->findNearestLivingBeing(
- pixelX, pixelY, 20, Being::MONSTER);
+ Being *target = actorSpriteManager->findNearestLivingBeing(
+ pixelX, pixelY, 20, ActorSprite::MONSTER);
if (target)
player_node->setTarget(target);
@@ -467,9 +453,9 @@ void Viewport::mouseDragged(gcn::MouseEvent &event)
}
else
{
- if (mLocalWalkTime != player_node->getWalkTime())
+ if (mLocalWalkTime != player_node->getActionTime())
{
- mLocalWalkTime = player_node->getWalkTime();
+ mLocalWalkTime = player_node->getActionTime();
int destX = (event.getX() + mPixelViewX) / mMap->getTileWidth();
int destY = (event.getY() + mPixelViewY) / mMap->getTileHeight();
player_node->setDestination(destX, destY);
@@ -497,12 +483,6 @@ void Viewport::closePopupMenu()
mPopupMenu->handleLink("cancel");
}
-void Viewport::optionChanged(const std::string &name)
-{
- mScrollLaziness = (int) config.getValue("ScrollLaziness", 32);
- mScrollRadius = (int) config.getValue("ScrollRadius", 32);
-}
-
void Viewport::mouseMoved(gcn::MouseEvent &event)
{
// Check if we are on the map
@@ -512,15 +492,11 @@ void Viewport::mouseMoved(gcn::MouseEvent &event)
const int x = (event.getX() + (int) mPixelViewX);
const int y = (event.getY() + (int) mPixelViewY);
- mHoverBeing = beingManager->findBeingByPixel(x, y);
- if (mHoverBeing && mHoverBeing->getType() == Being::PLAYER)
- mBeingPopup->show(getMouseX(), getMouseY(),
- static_cast<Player*>(mHoverBeing));
- else
- mBeingPopup->setVisible(false);
+ mHoverBeing = actorSpriteManager->findBeingByPixel(x, y);
+ mBeingPopup->show(getMouseX(), getMouseY(), mHoverBeing);
- mHoverItem = floorItemManager->findByCoordinates(x / mMap->getTileWidth(),
- y / mMap->getTileHeight());
+ mHoverItem = actorSpriteManager->findItem(x / mMap->getTileWidth(),
+ y / mMap->getTileHeight());
updateCursorType();
}
@@ -532,12 +508,12 @@ void Viewport::updateCursorType()
switch (mHoverBeing->getType())
{
// NPCs
- case Being::NPC:
+ case ActorSprite::NPC:
gui->setCursorType(Gui::CURSOR_TALK);
break;
// Monsters
- case Being::MONSTER:
+ case ActorSprite::MONSTER:
gui->setCursorType(Gui::CURSOR_FIGHT);
break;
default:
@@ -559,7 +535,7 @@ void Viewport::updateCursorType()
void Viewport::toggleDebugPath()
{
mShowDebugPath++;
- if (mShowDebugPath > Map::MAP_SPECIAL)
+ if (mShowDebugPath > Map::MAP_SPECIAL3)
mShowDebugPath = Map::MAP_NORMAL;
if (mMap)
{
@@ -572,8 +548,26 @@ void Viewport::hideBeingPopup()
mBeingPopup->setVisible(false);
}
-void Viewport::clearHoverBeing(Being *being)
+void Viewport::event(Channels channel, const Mana::Event &event)
{
- if (mHoverBeing == being)
- mHoverBeing = 0;
+ if (channel == CHANNEL_ACTORSPRITE && event.getName() == EVENT_DESTROYED)
+ {
+ ActorSprite *actor = event.getActor("source");
+
+ if (mHoverBeing == actor)
+ mHoverBeing = 0;
+
+ if (mHoverItem == actor)
+ mHoverItem = 0;
+ }
+ else if (channel == CHANNEL_CONFIG &&
+ event.getName() == EVENT_CONFIGOPTIONCHANGED)
+ {
+ const std::string option = event.getString("option");
+ if (option == "ScrollLaziness" || option == "ScrollRadius")
+ {
+ mScrollLaziness = config.getIntValue("ScrollLaziness");
+ mScrollRadius = config.getIntValue("ScrollRadius");
+ }
+ }
}
diff --git a/src/gui/viewport.h b/src/gui/viewport.h
index 616b88be..93e36b5b 100644
--- a/src/gui/viewport.h
+++ b/src/gui/viewport.h
@@ -22,14 +22,14 @@
#ifndef VIEWPORT_H
#define VIEWPORT_H
-#include "beingmanager.h"
-#include "configlistener.h"
+#include "listener.h"
#include "position.h"
#include "gui/widgets/windowcontainer.h"
#include <guichan/mouselistener.hpp>
+class ActorSprite;
class Being;
class BeingPopup;
class FloorItem;
@@ -52,7 +52,7 @@ const int walkingMouseDelay = 500;
* coordinates.
*/
class Viewport : public WindowContainer, public gcn::MouseListener,
- public ConfigListener
+ public Mana::Listener
{
public:
/**
@@ -119,11 +119,6 @@ class Viewport : public WindowContainer, public gcn::MouseListener,
void closePopupMenu();
/**
- * A relevant config option changed.
- */
- void optionChanged(const std::string &name);
-
- /**
* Returns camera x offset in pixels.
*/
int getCameraX() const { return (int) mPixelViewX; }
@@ -158,11 +153,7 @@ class Viewport : public WindowContainer, public gcn::MouseListener,
*/
void hideBeingPopup();
- protected:
- friend class BeingManager;
-
- /// Clears the hovered being if it matches
- void clearHoverBeing(Being *being);
+ void event(Channels channel, const Mana::Event &event);
private:
/**
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp
index cc2c7d6a..60837ea1 100644
--- a/src/gui/widgets/avatarlistbox.cpp
+++ b/src/gui/widgets/avatarlistbox.cpp
@@ -24,10 +24,10 @@
#include "gui/gui.h"
#include "gui/palette.h"
-#include "gui/theme.h"
#include "resources/image.h"
#include "resources/resourcemanager.h"
+#include "resources/theme.h"
#include "utils/stringutils.h"
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index 81f54212..314429fa 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -24,10 +24,10 @@
#include "client.h"
-#include "gui/theme.h"
-
#include "gui/widgets/linkhandler.h"
+#include "resources/theme.h"
+
#include <guichan/graphics.hpp>
#include <guichan/font.hpp>
#include <guichan/cliprectangle.hpp>
diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp
index 26e0ad90..3d3a07c2 100644
--- a/src/gui/widgets/button.cpp
+++ b/src/gui/widgets/button.cpp
@@ -25,9 +25,9 @@
#include "graphics.h"
#include "gui/palette.h"
-#include "gui/theme.h"
#include "resources/image.h"
+#include "resources/theme.h"
#include "utils/dtor.h"
@@ -125,8 +125,8 @@ Button::~Button()
void Button::updateAlpha()
{
- float alpha = std::max(config.getValue("guialpha", 0.8f),
- (double) Theme::instance()->getMinimumOpacity());
+ float alpha = std::max(config.getFloatValue("guialpha"),
+ Theme::instance()->getMinimumOpacity());
if (mAlpha != alpha)
{
diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp
index bbb2b8bb..c86eb2ea 100644
--- a/src/gui/widgets/chattab.cpp
+++ b/src/gui/widgets/chattab.cpp
@@ -21,7 +21,8 @@
#include "gui/widgets/chattab.h"
-#include "beingmanager.h"
+#include "actorspritemanager.h"
+#include "chatlog.h"
#include "commandhandler.h"
#include "configuration.h"
#include "localplayer.h"
@@ -51,7 +52,7 @@ ChatTab::ChatTab(const std::string &name) : Tab()
mTextOutput = new BrowserBox(BrowserBox::AUTO_WRAP);
mTextOutput->setOpaque(false);
- mTextOutput->setMaxRow((int) config.getValue("ChatLogLength", 0));
+ mTextOutput->setMaxRow((int) config.getIntValue("ChatLogLength"));
mTextOutput->setLinkHandler(chatWindow->mItemLinkHandler);
mTextOutput->setAlwaysUpdate(false);
@@ -73,7 +74,7 @@ ChatTab::~ChatTab()
delete mScrollArea;
}
-void ChatTab::chatLog(std::string line, int own, bool ignoreRecord)
+void ChatTab::chatLog(std::string line, Own own, bool ignoreRecord)
{
// Trim whitespace
trim(line);
@@ -182,6 +183,9 @@ void ChatTab::chatLog(std::string line, int own, bool ignoreRecord)
line = lineColor + timeStr.str() + tmp.nick + tmp.text;
+ if (config.getBoolValue("enableChatLog"))
+ saveToLogFile(line);
+
// 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.
@@ -234,7 +238,7 @@ void ChatTab::chatInput(const std::string &message)
std::string temp = msg.substr(start + 1, end - start - 1);
- const ItemInfo itemInfo = ItemDB::get(temp);
+ const ItemInfo itemInfo = itemDb->get(temp);
if (itemInfo.getId() != 0)
{
msg.insert(end, "@@");
@@ -279,7 +283,13 @@ void ChatTab::handleCommand(const std::string &msg)
void ChatTab::getAutoCompleteList(std::vector<std::string> &names) const
{
- beingManager->getPlayerNPCNameLister()->getAutoCompleteList(names);
+ actorSpriteManager->getPlayerNPCNameLister()->getAutoCompleteList(names);
+}
+
+void ChatTab::saveToLogFile(std::string &msg)
+{
+ if (chatLogger)
+ chatLogger->log(msg);
}
void ChatTab::addRow(std::string &line)
diff --git a/src/gui/widgets/chattab.h b/src/gui/widgets/chattab.h
index c2dfa1c1..1e187f23 100644
--- a/src/gui/widgets/chattab.h
+++ b/src/gui/widgets/chattab.h
@@ -31,18 +31,6 @@ class BrowserBox;
class Recorder;
class ScrollArea;
-enum
-{
- BY_GM,
- BY_PLAYER,
- BY_OTHER,
- BY_SERVER,
- BY_CHANNEL,
- ACT_WHISPER, // getting whispered at
- ACT_IS, // equivalent to "/me" on IRC
- BY_LOGGER
-};
-
/**
* A tab for the chat window. This is special to ease chat handling.
*/
@@ -63,7 +51,8 @@ class ChatTab : public Tab, public AutoCompleteLister
* @param channelName which channel to send the message to.
* @param ignoreRecord should this not be recorded?
*/
- void chatLog(std::string line, int own = BY_SERVER, bool ignoreRecord = false);
+ void chatLog(std::string line, Own own = BY_SERVER,
+ bool ignoreRecord = false);
/**
* Adds the text to the message list
@@ -112,8 +101,11 @@ class ChatTab : public Tab, public AutoCompleteLister
const std::string &args)
{ return false; }
+
void getAutoCompleteList(std::vector<std::string> &names) const;
+ virtual void saveToLogFile(std::string &msg);
+
protected:
friend class ChatWindow;
friend class WhisperWindow;
diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp
index f9002166..6a44132d 100644
--- a/src/gui/widgets/checkbox.cpp
+++ b/src/gui/widgets/checkbox.cpp
@@ -25,9 +25,9 @@
#include "graphics.h"
#include "gui/palette.h"
-#include "gui/theme.h"
#include "resources/image.h"
+#include "resources/theme.h"
int CheckBox::instances = 0;
float CheckBox::mAlpha = 1.0;
@@ -92,8 +92,8 @@ void CheckBox::draw(gcn::Graphics* graphics)
void CheckBox::updateAlpha()
{
- float alpha = std::max(config.getValue("guialpha", 0.8f),
- (double) Theme::instance()->getMinimumOpacity());
+ float alpha = std::max(config.getFloatValue("guialpha"),
+ Theme::instance()->getMinimumOpacity());
if (mAlpha != alpha)
{
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index 6c3417e7..ced9c38b 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -26,12 +26,12 @@
#include "gui/palette.h"
#include "gui/sdlinput.h"
-#include "gui/theme.h"
#include "gui/widgets/listbox.h"
#include "gui/widgets/scrollarea.h"
#include "resources/image.h"
+#include "resources/theme.h"
#include "utils/dtor.h"
@@ -110,8 +110,8 @@ DropDown::~DropDown()
void DropDown::updateAlpha()
{
- float alpha = std::max(config.getValue("guialpha", 0.8f),
- (double) Theme::instance()->getMinimumOpacity());
+ float alpha = std::max(config.getFloatValue("guialpha"),
+ Theme::instance()->getMinimumOpacity());
if (mAlpha != alpha)
{
diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp
index 82fb9f8d..f7a6ca2b 100644
--- a/src/gui/widgets/emoteshortcutcontainer.cpp
+++ b/src/gui/widgets/emoteshortcutcontainer.cpp
@@ -20,11 +20,11 @@
#include "gui/widgets/emoteshortcutcontainer.h"
-#include "animatedsprite.h"
#include "configuration.h"
#include "emoteshortcut.h"
#include "graphics.h"
#include "inventory.h"
+#include "imagesprite.h"
#include "item.h"
#include "itemshortcut.h"
#include "keyboardconfig.h"
@@ -32,10 +32,10 @@
#include "log.h"
#include "gui/palette.h"
-#include "gui/theme.h"
#include "resources/emotedb.h"
#include "resources/image.h"
+#include "resources/theme.h"
#include "utils/dtor.h"
@@ -51,12 +51,12 @@ EmoteShortcutContainer::EmoteShortcutContainer():
mBackgroundImg = Theme::getImageFromTheme("item_shortcut_bgr.png");
- mBackgroundImg->setAlpha(config.getValue("guialpha", 0.8));
+ mBackgroundImg->setAlpha(config.getFloatValue("guialpha"));
// Setup emote sprites
for (int i = 0; i <= EmoteDB::getLast(); i++)
{
- mEmoteImg.push_back(EmoteDB::getAnimation(i));
+ mEmoteImg.push_back(EmoteDB::get(i)->sprite);
}
mMaxItems = EmoteDB::getLast() < MAX_ITEMS ? EmoteDB::getLast() : MAX_ITEMS;
@@ -72,9 +72,9 @@ EmoteShortcutContainer::~EmoteShortcutContainer()
void EmoteShortcutContainer::draw(gcn::Graphics *graphics)
{
- if (config.getValue("guialpha", 0.8) != mAlpha)
+ if (config.getFloatValue("guialpha") != mAlpha)
{
- mAlpha = config.getValue("guialpha", 0.8);
+ mAlpha = config.getFloatValue("guialpha");
mBackgroundImg->setAlpha(mAlpha);
}
@@ -106,7 +106,7 @@ void EmoteShortcutContainer::draw(gcn::Graphics *graphics)
if (mEmoteMoved)
{
// Draw the emote image being dragged by the cursor.
- const AnimatedSprite* sprite = mEmoteImg[mEmoteMoved - 1];
+ const ImageSprite* sprite = mEmoteImg[mEmoteMoved - 1];
if (sprite)
{
const int tPosX = mCursorPosX - (sprite->getWidth() / 2);
diff --git a/src/gui/widgets/emoteshortcutcontainer.h b/src/gui/widgets/emoteshortcutcontainer.h
index e90612b4..c3fb9d14 100644
--- a/src/gui/widgets/emoteshortcutcontainer.h
+++ b/src/gui/widgets/emoteshortcutcontainer.h
@@ -25,8 +25,7 @@
#include <vector>
-class AnimatedSprite;
-class Image;
+class ImageSprite;
/**
* An emote shortcut container. Used to quickly use emoticons.
@@ -67,7 +66,7 @@ class EmoteShortcutContainer : public ShortcutContainer
void mouseReleased(gcn::MouseEvent &event);
private:
- std::vector<const AnimatedSprite*> mEmoteImg;
+ std::vector<const ImageSprite*> mEmoteImg;
bool mEmoteClicked;
int mEmoteMoved;
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index fb5105b2..2e9b698d 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -32,7 +32,6 @@
#include "gui/outfitwindow.h"
#include "gui/palette.h"
#include "gui/sdlinput.h"
-#include "gui/theme.h"
#include "gui/viewport.h"
#include "net/net.h"
@@ -40,6 +39,7 @@
#include "resources/image.h"
#include "resources/iteminfo.h"
+#include "resources/theme.h"
#include "utils/stringutils.h"
@@ -263,7 +263,7 @@ void ItemContainer::mousePressed(gcn::MouseEvent &event)
mSelectionStatus = SEL_SELECTING;
itemShortcut->setItemSelected(item->getId());
- if (item->isEquipment())
+ if (item->getInfo().getEquippable())
outfitWindow->setItemSelected(item->getId());
}
else
@@ -305,7 +305,14 @@ void ItemContainer::mouseReleased(gcn::MouseEvent &event)
return;
if (index == mSelectedIndex || mSelectedIndex == -1)
return;
- Net::getInventoryHandler()->moveItem(mSelectedIndex, index);
+
+ Item *item = getSelectedItem();
+ {
+ Mana::Event event(EVENT_DOMOVE);
+ event.setItem("item", item);
+ event.setInt("newIndex", index);
+ event.trigger(CHANNEL_ITEM);
+ }
selectNone();
}
@@ -372,8 +379,11 @@ void ItemContainer::keyAction()
mSelectedIndex != -1 &&
mHighlightedIndex != -1)
{
- Net::getInventoryHandler()->moveItem(
- mSelectedIndex, mHighlightedIndex);
+ Item *item = getSelectedItem();
+ Mana::Event event(EVENT_DOMOVE);
+ event.setItem("item", item);
+ event.setInt("newIndex", mHighlightedIndex);
+ event.trigger(CHANNEL_ITEM);
setSelectedIndex(mHighlightedIndex);
}
// If the highlight is on an item then select it.
@@ -385,8 +395,11 @@ void ItemContainer::keyAction()
// If the highlight is on a blank space then move it.
else if (mSelectedIndex != -1)
{
- Net::getInventoryHandler()->moveItem(
- mSelectedIndex, mHighlightedIndex);
+ Item *item = getSelectedItem();
+ Mana::Event event(EVENT_DOMOVE);
+ event.setItem("item", item);
+ event.setInt("newIndex", mHighlightedIndex);
+ event.trigger(CHANNEL_ITEM);
selectNone();
}
}
diff --git a/src/gui/widgets/itemlinkhandler.cpp b/src/gui/widgets/itemlinkhandler.cpp
index b7341084..8477225f 100644
--- a/src/gui/widgets/itemlinkhandler.cpp
+++ b/src/gui/widgets/itemlinkhandler.cpp
@@ -49,7 +49,7 @@ void ItemLinkHandler::handleLink(const std::string &link)
if (id > 0)
{
- const ItemInfo &itemInfo = ItemDB::get(id);
+ const ItemInfo &itemInfo = itemDb->get(id);
mItemPopup->setItem(itemInfo, true);
if (mItemPopup->isVisible())
diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp
index 682d71e5..fb4f558f 100644
--- a/src/gui/widgets/itemshortcutcontainer.cpp
+++ b/src/gui/widgets/itemshortcutcontainer.cpp
@@ -27,16 +27,16 @@
#include "item.h"
#include "itemshortcut.h"
#include "keyboardconfig.h"
-#include "localplayer.h"
+#include "playerinfo.h"
#include "gui/inventorywindow.h"
#include "gui/itempopup.h"
#include "gui/palette.h"
-#include "gui/theme.h"
#include "gui/viewport.h"
#include "resources/image.h"
#include "resources/iteminfo.h"
+#include "resources/theme.h"
#include "utils/stringutils.h"
@@ -53,7 +53,7 @@ ItemShortcutContainer::ItemShortcutContainer():
mBackgroundImg = Theme::getImageFromTheme("item_shortcut_bgr.png");
mMaxItems = itemShortcut->getItemCount();
- mBackgroundImg->setAlpha(config.getValue("guialpha", 0.8));
+ mBackgroundImg->setAlpha(config.getFloatValue("guialpha"));
mBoxHeight = mBackgroundImg->getHeight();
mBoxWidth = mBackgroundImg->getWidth();
@@ -67,9 +67,9 @@ ItemShortcutContainer::~ItemShortcutContainer()
void ItemShortcutContainer::draw(gcn::Graphics *graphics)
{
- if (config.getValue("guialpha", 0.8) != mAlpha)
+ if (config.getFloatValue("guialpha") != mAlpha)
{
- mAlpha = config.getValue("guialpha", 0.8);
+ mAlpha = config.getFloatValue("guialpha");
mBackgroundImg->setAlpha(mAlpha);
}
@@ -94,7 +94,7 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics)
continue;
Item *item =
- player_node->getInventory()->findItem(itemShortcut->getItem(i));
+ PlayerInfo::getInventory()->findItem(itemShortcut->getItem(i));
if (item)
{
@@ -152,7 +152,7 @@ void ItemShortcutContainer::mouseDragged(gcn::MouseEvent &event)
if (itemId < 0)
return;
- Item *item = player_node->getInventory()->findItem(itemId);
+ Item *item = PlayerInfo::getInventory()->findItem(itemId);
if (item)
{
@@ -188,7 +188,7 @@ void ItemShortcutContainer::mousePressed(gcn::MouseEvent &event)
}
else if (event.getButton() == gcn::MouseEvent::RIGHT)
{
- Item *item = player_node->getInventory()->
+ Item *item = PlayerInfo::getInventory()->
findItem(itemShortcut->getItem(index));
if (!item)
@@ -241,7 +241,7 @@ void ItemShortcutContainer::mouseMoved(gcn::MouseEvent &event)
if (itemId < 0)
return;
- Item *item = player_node->getInventory()->findItem(itemId);
+ Item *item = PlayerInfo::getInventory()->findItem(itemId);
if (item)
{
diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp
index 4c607edf..939e9fc0 100644
--- a/src/gui/widgets/label.cpp
+++ b/src/gui/widgets/label.cpp
@@ -20,19 +20,20 @@
#include "gui/widgets/label.h"
-#include "gui/theme.h"
+#include "resources/theme.h"
Label::Label()
{
+ setForegroundColor(Theme::getThemeColor(Theme::TEXT));
}
Label::Label(const std::string &caption) :
gcn::Label(caption)
{
+ setForegroundColor(Theme::getThemeColor(Theme::TEXT));
}
void Label::draw(gcn::Graphics *graphics)
{
- setForegroundColor(Theme::getThemeColor(Theme::TEXT));
gcn::Label::draw(static_cast<gcn::Graphics*>(graphics));
}
diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp
index ef591023..d79d8d0c 100644
--- a/src/gui/widgets/listbox.cpp
+++ b/src/gui/widgets/listbox.cpp
@@ -25,7 +25,8 @@
#include "gui/palette.h"
#include "gui/sdlinput.h"
-#include "gui/theme.h"
+
+#include "resources/theme.h"
#include <guichan/font.hpp>
#include <guichan/graphics.hpp>
@@ -45,8 +46,8 @@ ListBox::~ListBox()
void ListBox::updateAlpha()
{
- float alpha = std::max(config.getValue("guialpha", 0.8),
- (double) Theme::instance()->getMinimumOpacity());
+ float alpha = std::max(config.getFloatValue("guialpha"),
+ Theme::instance()->getMinimumOpacity());
if (mAlpha != alpha)
mAlpha = alpha;
diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp
index 57cbec6f..559ac5a6 100644
--- a/src/gui/widgets/playerbox.cpp
+++ b/src/gui/widgets/playerbox.cpp
@@ -22,13 +22,12 @@
#include "gui/widgets/playerbox.h"
#include "animatedsprite.h"
+#include "being.h"
#include "configuration.h"
#include "graphics.h"
-#include "player.h"
-
-#include "gui/theme.h"
#include "resources/image.h"
+#include "resources/theme.h"
#include "utils/dtor.h"
@@ -36,8 +35,8 @@ int PlayerBox::instances = 0;
float PlayerBox::mAlpha = 1.0;
ImageRect PlayerBox::background;
-PlayerBox::PlayerBox(const Player *player):
- mPlayer(player)
+PlayerBox::PlayerBox(const Being *being):
+ mBeing(being)
{
setFrameSize(2);
@@ -57,7 +56,7 @@ PlayerBox::PlayerBox(const Player *player):
bggridx[x], bggridy[y],
bggridx[x + 1] - bggridx[x] + 1,
bggridy[y + 1] - bggridy[y] + 1);
- background.grid[a]->setAlpha(config.getValue("guialpha", 0.8));
+ background.grid[a]->setAlpha(config.getFloatValue("guialpha"));
a++;
}
}
@@ -72,7 +71,7 @@ PlayerBox::~PlayerBox()
{
instances--;
- mPlayer = 0;
+ mBeing = 0;
if (instances == 0)
{
@@ -82,20 +81,20 @@ PlayerBox::~PlayerBox()
void PlayerBox::draw(gcn::Graphics *graphics)
{
- if (mPlayer)
+ if (mBeing)
{
// Draw character
const int bs = getFrameSize();
- const int x = getWidth() / 2 + bs;
- const int y = getHeight() - bs;
- mPlayer->drawSpriteAt(static_cast<Graphics*>(graphics), x, y);
+ const int x = getWidth() / 2 + bs - 16;
+ const int y = getHeight() - bs - 32;
+ mBeing->drawSpriteAt(static_cast<Graphics*>(graphics), x, y);
}
- if (config.getValue("guialpha", 0.8) != mAlpha)
+ if (config.getFloatValue("guialpha") != mAlpha)
{
for (int a = 0; a < 9; a++)
{
- background.grid[a]->setAlpha(config.getValue("guialpha", 0.8));
+ background.grid[a]->setAlpha(config.getFloatValue("guialpha"));
}
}
}
diff --git a/src/gui/widgets/playerbox.h b/src/gui/widgets/playerbox.h
index 33b4a628..4ce6782d 100644
--- a/src/gui/widgets/playerbox.h
+++ b/src/gui/widgets/playerbox.h
@@ -24,8 +24,8 @@
#include <guichan/widgets/scrollarea.hpp>
+class Being;
class ImageRect;
-class Player;
/**
* A box showing a player character.
@@ -39,7 +39,7 @@ class PlayerBox : public gcn::ScrollArea
* Constructor. Takes the initial player character that this box should
* display, which defaults to <code>NULL</code>.
*/
- PlayerBox(const Player *player = 0);
+ PlayerBox(const Being *being = 0);
/**
* Destructor.
@@ -51,7 +51,8 @@ class PlayerBox : public gcn::ScrollArea
* player to <code>NULL</code> causes the box not to draw any
* character.
*/
- void setPlayer(const Player *player) { mPlayer = player; }
+ void setPlayer(const Being *being)
+ { mBeing = being; }
/**
* Draws the scroll area.
@@ -64,7 +65,7 @@ class PlayerBox : public gcn::ScrollArea
void drawFrame(gcn::Graphics *graphics);
private:
- const Player *mPlayer; /**< The character used for display */
+ const Being *mBeing; /**< The character used for display */
static float mAlpha;
static int instances;
diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp
index 4dc58f72..e242bcf4 100644
--- a/src/gui/widgets/popup.cpp
+++ b/src/gui/widgets/popup.cpp
@@ -26,12 +26,12 @@
#include "graphics.h"
#include "log.h"
-#include "gui/theme.h"
#include "gui/viewport.h"
#include "gui/widgets/windowcontainer.h"
#include "resources/image.h"
+#include "resources/theme.h"
#include <guichan/exception.hpp>
diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp
index 028658ab..15838952 100644
--- a/src/gui/widgets/progressbar.cpp
+++ b/src/gui/widgets/progressbar.cpp
@@ -27,9 +27,9 @@
#include "gui/gui.h"
#include "gui/palette.h"
-#include "gui/theme.h"
#include "resources/image.h"
+#include "resources/theme.h"
#include "utils/dtor.h"
@@ -123,8 +123,8 @@ void ProgressBar::logic()
void ProgressBar::updateAlpha()
{
- float alpha = std::max(config.getValue("guialpha", 0.8),
- (double) Theme::instance()->getMinimumOpacity());
+ float alpha = std::max(config.getFloatValue("guialpha"),
+ Theme::instance()->getMinimumOpacity());
if (mAlpha != alpha)
{
diff --git a/src/gui/widgets/progressindicator.cpp b/src/gui/widgets/progressindicator.cpp
index 6bda617f..91b40751 100644
--- a/src/gui/widgets/progressindicator.cpp
+++ b/src/gui/widgets/progressindicator.cpp
@@ -23,11 +23,10 @@
#include "graphics.h"
#include "simpleanimation.h"
-#include "gui/theme.h"
-
#include "resources/animation.h"
#include "resources/imageset.h"
#include "resources/resourcemanager.h"
+#include "resources/theme.h"
#include <guichan/widgets/label.hpp>
diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp
index 96797225..1296feb6 100644
--- a/src/gui/widgets/radiobutton.cpp
+++ b/src/gui/widgets/radiobutton.cpp
@@ -24,9 +24,8 @@
#include "configuration.h"
#include "graphics.h"
-#include "gui/theme.h"
-
#include "resources/image.h"
+#include "resources/theme.h"
int RadioButton::instances = 0;
float RadioButton::mAlpha = 1.0;
@@ -78,9 +77,9 @@ RadioButton::~RadioButton()
void RadioButton::drawBox(gcn::Graphics* graphics)
{
- if (config.getValue("guialpha", 0.8) != mAlpha)
+ if (config.getFloatValue("guialpha") != mAlpha)
{
- mAlpha = config.getValue("guialpha", 0.8);
+ mAlpha = config.getFloatValue("guialpha");
radioNormal->setAlpha(mAlpha);
radioChecked->setAlpha(mAlpha);
radioDisabled->setAlpha(mAlpha);
diff --git a/src/gui/widgets/resizegrip.cpp b/src/gui/widgets/resizegrip.cpp
index f0c3691c..7850643f 100644
--- a/src/gui/widgets/resizegrip.cpp
+++ b/src/gui/widgets/resizegrip.cpp
@@ -24,9 +24,8 @@
#include "configuration.h"
#include "graphics.h"
-#include "gui/theme.h"
-
#include "resources/image.h"
+#include "resources/theme.h"
#include <guichan/graphics.hpp>
@@ -59,9 +58,9 @@ ResizeGrip::~ResizeGrip()
void ResizeGrip::draw(gcn::Graphics *graphics)
{
- if (config.getValue("guialpha", 0.8) != mAlpha)
+ if (config.getFloatValue("guialpha") != mAlpha)
{
- mAlpha = config.getValue("guialpha", 0.8);
+ mAlpha = config.getFloatValue("guialpha");
gripImage->setAlpha(mAlpha);
}
diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp
index 0c7f4d7d..7d42883a 100644
--- a/src/gui/widgets/scrollarea.cpp
+++ b/src/gui/widgets/scrollarea.cpp
@@ -24,9 +24,8 @@
#include "configuration.h"
#include "graphics.h"
-#include "gui/theme.h"
-
#include "resources/image.h"
+#include "resources/theme.h"
#include "utils/dtor.h"
@@ -108,7 +107,7 @@ void ScrollArea::init()
bggridx[x], bggridy[y],
bggridx[x + 1] - bggridx[x] + 1,
bggridy[y + 1] - bggridy[y] + 1);
- background.grid[a]->setAlpha(config.getValue("guialpha", 0.8));
+ background.grid[a]->setAlpha(config.getFloatValue("guialpha"));
a++;
}
}
@@ -135,8 +134,8 @@ void ScrollArea::init()
vsgridx[x], vsgridy[y],
vsgridx[x + 1] - vsgridx[x],
vsgridy[y + 1] - vsgridy[y]);
- vMarker.grid[a]->setAlpha(config.getValue("guialpha", 0.8));
- vMarkerHi.grid[a]->setAlpha(config.getValue("guialpha", 0.8));
+ vMarker.grid[a]->setAlpha(config.getFloatValue("guialpha"));
+ vMarkerHi.grid[a]->setAlpha(config.getFloatValue("guialpha"));
a++;
}
}
@@ -213,8 +212,8 @@ void ScrollArea::logic()
void ScrollArea::updateAlpha()
{
- float alpha = std::max(config.getValue("guialpha", 0.8),
- (double) Theme::instance()->getMinimumOpacity());
+ float alpha = std::max(config.getFloatValue("guialpha"),
+ Theme::instance()->getMinimumOpacity());
if (alpha != mAlpha)
{
diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp
index a5033570..ae7d4d9b 100644
--- a/src/gui/widgets/shoplistbox.cpp
+++ b/src/gui/widgets/shoplistbox.cpp
@@ -26,12 +26,12 @@
#include "shopitem.h"
#include "gui/itempopup.h"
-#include "gui/theme.h"
#include "gui/viewport.h"
#include "gui/widgets/shopitems.h"
#include "resources/image.h"
+#include "resources/theme.h"
#include <guichan/font.hpp>
#include <guichan/listmodel.hpp>
@@ -76,8 +76,8 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics)
if (!mListModel)
return;
- if (config.getValue("guialpha", 0.8) != mAlpha)
- mAlpha = config.getValue("guialpha", 0.8);
+ if (config.getFloatValue("guialpha") != mAlpha)
+ mAlpha = config.getFloatValue("guialpha");
int alpha = (int)(mAlpha * 255.0f);
const gcn::Color* highlightColor =
diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp
index 6a9a5c7c..c044d55d 100644
--- a/src/gui/widgets/slider.cpp
+++ b/src/gui/widgets/slider.cpp
@@ -24,9 +24,8 @@
#include "configuration.h"
#include "graphics.h"
-#include "gui/theme.h"
-
#include "resources/image.h"
+#include "resources/theme.h"
Image *Slider::hStart, *Slider::hMid, *Slider::hEnd, *Slider::hGrip;
Image *Slider::vStart, *Slider::vMid, *Slider::vEnd, *Slider::vGrip;
@@ -126,8 +125,8 @@ void Slider::init()
void Slider::updateAlpha()
{
- float alpha = std::max(config.getValue("guialpha", 0.8),
- (double) Theme::instance()->getMinimumOpacity());
+ float alpha = std::max(config.getFloatValue("guialpha"),
+ Theme::instance()->getMinimumOpacity());
if (alpha != mAlpha)
{
diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp
index 2ab126dd..10a51afe 100644
--- a/src/gui/widgets/tab.cpp
+++ b/src/gui/widgets/tab.cpp
@@ -25,11 +25,11 @@
#include "graphics.h"
#include "gui/palette.h"
-#include "gui/theme.h"
#include "gui/widgets/tabbedarea.h"
#include "resources/image.h"
+#include "resources/theme.h"
#include "utils/dtor.h"
@@ -118,8 +118,8 @@ void Tab::init()
void Tab::updateAlpha()
{
- float alpha = std::max(config.getValue("guialpha", 0.8),
- (double) Theme::instance()->getMinimumOpacity());
+ float alpha = std::max(config.getFloatValue("guialpha"),
+ Theme::instance()->getMinimumOpacity());
// TODO We don't need to do this for every tab on every draw
// Maybe use a config listener to do it as the value changes.
diff --git a/src/gui/widgets/table.cpp b/src/gui/widgets/table.cpp
index f0887ed7..3d8680ce 100644
--- a/src/gui/widgets/table.cpp
+++ b/src/gui/widgets/table.cpp
@@ -24,7 +24,8 @@
#include "configuration.h"
#include "gui/sdlinput.h"
-#include "gui/theme.h"
+
+#include "resources/theme.h"
#include "utils/dtor.h"
@@ -270,8 +271,8 @@ void GuiTable::draw(gcn::Graphics* graphics)
if (!mModel)
return;
- if (config.getValue("guialpha", 0.8) != mAlpha)
- mAlpha = config.getValue("guialpha", 0.8);
+ if (config.getFloatValue("guialpha") != mAlpha)
+ mAlpha = config.getFloatValue("guialpha");
if (mOpaque)
{
diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp
index f248f35d..5b112e54 100644
--- a/src/gui/widgets/textbox.cpp
+++ b/src/gui/widgets/textbox.cpp
@@ -21,7 +21,7 @@
#include "gui/widgets/textbox.h"
-#include "gui/theme.h"
+#include "resources/theme.h"
#include <guichan/font.hpp>
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index 4989ae83..d06df376 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -21,15 +21,14 @@
#include "gui/widgets/textfield.h"
-#include "beingmanager.h"
#include "configuration.h"
#include "graphics.h"
#include "gui/palette.h"
#include "gui/sdlinput.h"
-#include "gui/theme.h"
#include "resources/image.h"
+#include "resources/theme.h"
#include "utils/copynpaste.h"
#include "utils/dtor.h"
@@ -69,7 +68,7 @@ TextField::TextField(const std::string &text, bool loseFocusOnTab):
gridx[x], gridy[y],
gridx[x + 1] - gridx[x] + 1,
gridy[y + 1] - gridy[y] + 1);
- skin.grid[a]->setAlpha(config.getValue("guialpha", 0.8));
+ skin.grid[a]->setAlpha(config.getFloatValue("guialpha"));
a++;
}
}
@@ -90,8 +89,8 @@ TextField::~TextField()
void TextField::updateAlpha()
{
- float alpha = std::max(config.getValue("guialpha", 0.8),
- (double) Theme::instance()->getMinimumOpacity());
+ float alpha = std::max(config.getFloatValue("guialpha"),
+ Theme::instance()->getMinimumOpacity());
if (alpha != mAlpha)
{
diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp
index 10426d7c..869ebd35 100644
--- a/src/gui/widgets/textpreview.cpp
+++ b/src/gui/widgets/textpreview.cpp
@@ -45,8 +45,8 @@ TextPreview::TextPreview(const std::string &text):
void TextPreview::draw(gcn::Graphics* graphics)
{
- if (config.getValue("guialpha", 0.8) != mAlpha)
- mAlpha = config.getValue("guialpha", 0.8);
+ if (config.getFloatValue("guialpha") != mAlpha)
+ mAlpha = config.getFloatValue("guialpha");
int alpha = (int) (mAlpha * 255.0f);
diff --git a/src/gui/widgets/whispertab.cpp b/src/gui/widgets/whispertab.cpp
index 7542e251..864f1f51 100644
--- a/src/gui/widgets/whispertab.cpp
+++ b/src/gui/widgets/whispertab.cpp
@@ -21,14 +21,15 @@
#include "whispertab.h"
+#include "chatlog.h"
#include "commandhandler.h"
#include "localplayer.h"
-#include "gui/theme.h"
-
#include "net/chathandler.h"
#include "net/net.h"
+#include "resources/theme.h"
+
#include "utils/gettext.h"
#include "utils/stringutils.h"
@@ -115,3 +116,9 @@ bool WhisperTab::handleCommand(const std::string &type,
return true;
}
+
+void WhisperTab::saveToLogFile(std::string &msg)
+{
+ if (chatLogger)
+ chatLogger->log(getNick(), msg);
+}
diff --git a/src/gui/widgets/whispertab.h b/src/gui/widgets/whispertab.h
index 447a8fe0..20a07449 100644
--- a/src/gui/widgets/whispertab.h
+++ b/src/gui/widgets/whispertab.h
@@ -39,6 +39,8 @@ class WhisperTab : public ChatTab
bool handleCommand(const std::string &type,
const std::string &args);
+ void saveToLogFile(std::string &msg);
+
protected:
friend class ChatWindow;
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index 118ee7c0..aa8e6df3 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -26,7 +26,6 @@
#include "gui/gui.h"
#include "gui/palette.h"
-#include "gui/theme.h"
#include "gui/viewport.h"
#include "gui/widgets/layout.h"
@@ -34,6 +33,7 @@
#include "gui/widgets/windowcontainer.h"
#include "resources/image.h"
+#include "resources/theme.h"
#include <guichan/exception.hpp>
#include <guichan/focushandler.hpp>
@@ -697,8 +697,8 @@ int Window::getResizeHandles(gcn::MouseEvent &event)
int Window::getGuiAlpha()
{
- float alpha = std::max(config.getValue("guialpha", 0.8),
- (double) Theme::instance()->getMinimumOpacity());
+ float alpha = std::max(config.getFloatValue("guialpha"),
+ Theme::instance()->getMinimumOpacity());
return (int) (alpha * 255.0f);
}
diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp
index 4b18de89..542ab4a0 100644
--- a/src/gui/windowmenu.cpp
+++ b/src/gui/windowmenu.cpp
@@ -58,7 +58,7 @@ WindowMenu::WindowMenu():
if (skillDialog->hasSkills())
addButton(N_("Skills"), x, h);
- if (specialsWindow->hasSpecials())
+ // if (specialsWindow->hasSpecials())
addButton(N_("Specials"), x, h);
addButton(N_("Social"), x, h);
diff --git a/src/gui/worldselectdialog.cpp b/src/gui/worldselectdialog.cpp
index 3219b83d..3207f394 100644
--- a/src/gui/worldselectdialog.cpp
+++ b/src/gui/worldselectdialog.cpp
@@ -137,3 +137,13 @@ void WorldSelectDialog::keyPressed(gcn::KeyEvent &keyEvent)
action(gcn::ActionEvent(NULL, mChooseWorld->getActionEventId()));
}
}
+
+void WorldSelectDialog::mouseClicked(gcn::MouseEvent &mouseEvent)
+{
+ if (mouseEvent.getSource() == mWorldList &&
+ isDoubleClick(mWorldList->getSelected()))
+ {
+ action(gcn::ActionEvent(mChooseWorld,
+ mChooseWorld->getActionEventId()));
+ }
+}
diff --git a/src/gui/worldselectdialog.h b/src/gui/worldselectdialog.h
index 2d4f0189..b51110b4 100644
--- a/src/gui/worldselectdialog.h
+++ b/src/gui/worldselectdialog.h
@@ -62,6 +62,8 @@ class WorldSelectDialog : public Window, public gcn::ActionListener,
void keyPressed(gcn::KeyEvent &keyEvent);
+ void mouseClicked(gcn::MouseEvent &mouseEvent);
+
private:
WorldListModel *mWorldListModel;
gcn::ListBox *mWorldList;