summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/beingpopup.cpp4
-rw-r--r--src/gui/botcheckerwindow.cpp3
-rw-r--r--src/gui/buydialog.cpp30
-rw-r--r--src/gui/buyselldialog.cpp8
-rw-r--r--src/gui/changeemaildialog.cpp20
-rw-r--r--src/gui/changeemaildialog.h2
-rw-r--r--src/gui/changepassworddialog.cpp22
-rw-r--r--src/gui/changepassworddialog.h2
-rw-r--r--src/gui/charcreatedialog.cpp2
-rw-r--r--src/gui/charselectdialog.cpp50
-rw-r--r--src/gui/charselectdialog.h2
-rw-r--r--src/gui/chatwindow.cpp35
-rw-r--r--src/gui/chatwindow.h6
-rw-r--r--src/gui/confirmdialog.cpp2
-rw-r--r--src/gui/debugwindow.cpp2
-rw-r--r--src/gui/didyouknowwindow.cpp2
-rw-r--r--src/gui/editdialog.cpp2
-rw-r--r--src/gui/emotepopup.cpp3
-rw-r--r--src/gui/equipmentwindow.cpp2
-rw-r--r--src/gui/gui.cpp2
-rw-r--r--src/gui/helpwindow.cpp2
-rw-r--r--src/gui/inventorywindow.cpp120
-rw-r--r--src/gui/inventorywindow.h15
-rw-r--r--src/gui/itemamountwindow.cpp42
-rw-r--r--src/gui/itempopup.cpp2
-rw-r--r--src/gui/killstats.cpp8
-rw-r--r--src/gui/killstats.h4
-rw-r--r--src/gui/logindialog.cpp14
-rw-r--r--src/gui/logindialog.h2
-rw-r--r--src/gui/minimap.cpp71
-rw-r--r--src/gui/minimap.h4
-rw-r--r--src/gui/ministatuswindow.cpp16
-rw-r--r--src/gui/ministatuswindow.h4
-rw-r--r--src/gui/npcdialog.cpp22
-rw-r--r--src/gui/npcpostdialog.cpp6
-rw-r--r--src/gui/okdialog.cpp2
-rw-r--r--src/gui/outfitwindow.cpp2
-rw-r--r--src/gui/palette.cpp4
-rw-r--r--src/gui/palette.h13
-rw-r--r--src/gui/popupmenu.cpp610
-rw-r--r--src/gui/quitdialog.cpp25
-rw-r--r--src/gui/quitdialog.h2
-rw-r--r--src/gui/register.cpp54
-rw-r--r--src/gui/sdlfont.cpp4
-rw-r--r--src/gui/selldialog.cpp30
-rw-r--r--src/gui/serverdialog.cpp14
-rw-r--r--src/gui/setup.cpp37
-rw-r--r--src/gui/setup.h2
-rw-r--r--src/gui/setup_other.cpp9
-rw-r--r--src/gui/setup_perfomance.cpp6
-rw-r--r--src/gui/setup_video.cpp67
-rw-r--r--src/gui/shopwindow.cpp48
-rw-r--r--src/gui/shortcutwindow.cpp8
-rw-r--r--src/gui/shortcutwindow.h3
-rw-r--r--src/gui/skilldialog.cpp14
-rw-r--r--src/gui/socialwindow.cpp22
-rw-r--r--src/gui/specialswindow.cpp7
-rw-r--r--src/gui/spellpopup.cpp10
-rw-r--r--src/gui/statuspopup.cpp13
-rw-r--r--src/gui/statuswindow.cpp18
-rw-r--r--src/gui/statuswindow.h2
-rw-r--r--src/gui/textcommandeditor.cpp62
-rw-r--r--src/gui/textdialog.cpp2
-rw-r--r--src/gui/textpopup.cpp8
-rw-r--r--src/gui/theme.cpp251
-rw-r--r--src/gui/theme.h10
-rw-r--r--src/gui/tradewindow.cpp22
-rw-r--r--src/gui/unregisterdialog.cpp18
-rw-r--r--src/gui/updaterwindow.cpp16
-rw-r--r--src/gui/userpalette.cpp2
-rw-r--r--src/gui/viewport.cpp108
-rw-r--r--src/gui/viewport.h1
-rw-r--r--src/gui/whoisonline.cpp6
-rw-r--r--src/gui/widgets/avatarlistbox.cpp5
-rw-r--r--src/gui/widgets/browserbox.cpp19
-rw-r--r--src/gui/widgets/browserbox.h5
-rw-r--r--src/gui/widgets/chattab.cpp4
-rw-r--r--src/gui/widgets/dropdown.cpp9
-rw-r--r--src/gui/widgets/dropdown.h4
-rw-r--r--src/gui/widgets/flowcontainer.cpp2
-rw-r--r--src/gui/widgets/itemcontainer.cpp82
-rw-r--r--src/gui/widgets/itemcontainer.h4
-rw-r--r--src/gui/widgets/layout.cpp10
-rw-r--r--src/gui/widgets/mouseevent.h10
-rw-r--r--src/gui/widgets/popup.cpp32
-rw-r--r--src/gui/widgets/popup.h3
-rw-r--r--src/gui/widgets/progressbar.cpp4
-rw-r--r--src/gui/widgets/progressbar.h4
-rw-r--r--src/gui/widgets/radiobutton.cpp10
-rw-r--r--src/gui/widgets/setuptabscroll.cpp18
-rw-r--r--src/gui/widgets/tabbedarea.cpp13
-rw-r--r--src/gui/widgets/tabbedarea.h2
-rw-r--r--src/gui/widgets/textfield.cpp23
-rw-r--r--src/gui/widgets/textfield.h5
-rw-r--r--src/gui/widgets/vertcontainer.cpp5
-rw-r--r--src/gui/widgets/window.cpp116
-rw-r--r--src/gui/widgets/window.h2
-rw-r--r--src/gui/windowmenu.cpp14
-rw-r--r--src/gui/windowmenu.h2
-rw-r--r--src/gui/worldselectdialog.cpp2
100 files changed, 1386 insertions, 1088 deletions
diff --git a/src/gui/beingpopup.cpp b/src/gui/beingpopup.cpp
index 8d7b26c1b..98df1ca9a 100644
--- a/src/gui/beingpopup.cpp
+++ b/src/gui/beingpopup.cpp
@@ -39,8 +39,8 @@
#include "debug.h"
-BeingPopup::BeingPopup():
- Popup("BeingPopup")
+BeingPopup::BeingPopup() :
+ Popup("BeingPopup", "beingpopup.xml")
{
// Being Name
mBeingName = new Label("A");
diff --git a/src/gui/botcheckerwindow.cpp b/src/gui/botcheckerwindow.cpp
index 7c0339ead..34293e59d 100644
--- a/src/gui/botcheckerwindow.cpp
+++ b/src/gui/botcheckerwindow.cpp
@@ -263,12 +263,13 @@ protected:
BotCheckerWindow::BotCheckerWindow():
- Window(_("Bot Checker")),
+ Window(_("Bot Checker"), false, 0, "botchecker.xml"),
mEnabled(false)
{
int w = 500;
int h = 250;
+ setSaveVisible(true);
mLastUpdateTime = 0;
mNeedUpdate = false;
diff --git a/src/gui/buydialog.cpp b/src/gui/buydialog.cpp
index 8c1ad62ce..8628afc6e 100644
--- a/src/gui/buydialog.cpp
+++ b/src/gui/buydialog.cpp
@@ -53,14 +53,14 @@
BuyDialog::DialogList BuyDialog::instances;
BuyDialog::BuyDialog(int npcId):
- Window(_("Buy")),
+ Window(_("Buy"), false, 0, "buy.xml"),
mNpcId(npcId), mMoney(0), mAmountItems(0), mMaxItems(0), mNick("")
{
init();
}
BuyDialog::BuyDialog(std::string nick):
- Window(_("Buy")),
+ Window(_("Buy"), false, 0, "buy.xml"),
mNpcId(-1), mMoney(0), mAmountItems(0), mMaxItems(0), mNick(nick)
{
init();
@@ -111,18 +111,18 @@ void BuyDialog::init()
mSlider->addActionListener(this);
mShopItemList->addSelectionListener(this);
- ContainerPlacer place;
- place = getPlacer(0, 0);
+ ContainerPlacer placer;
+ placer = getPlacer(0, 0);
- place(0, 0, mScrollArea, 8, 5).setPadding(3);
- place(0, 5, mDecreaseButton);
- place(1, 5, mSlider, 3);
- place(4, 5, mIncreaseButton);
- place(5, 5, mQuantityLabel, 2);
- place(7, 5, mAddMaxButton);
- place(0, 6, mMoneyLabel, 8);
- place(6, 7, mBuyButton);
- place(7, 7, mQuitButton);
+ placer(0, 0, mScrollArea, 8, 5).setPadding(3);
+ placer(0, 5, mDecreaseButton);
+ placer(1, 5, mSlider, 3);
+ placer(4, 5, mIncreaseButton);
+ placer(5, 5, mQuantityLabel, 2);
+ placer(7, 5, mAddMaxButton);
+ placer(0, 6, mMoneyLabel, 8);
+ placer(6, 7, mBuyButton);
+ placer(7, 7, mQuitButton);
Layout &layout = getLayout();
layout.setRowHeight(0, Layout::AUTO_SET);
@@ -317,8 +317,8 @@ void BuyDialog::setVisible(bool visible)
void BuyDialog::closeAll()
{
- DialogList::iterator it = instances.begin();
- DialogList::iterator it_end = instances.end();
+ DialogList::const_iterator it = instances.begin();
+ DialogList::const_iterator it_end = instances.end();
for (; it != it_end; ++it)
{
diff --git a/src/gui/buyselldialog.cpp b/src/gui/buyselldialog.cpp
index 14dcb0bc1..e1063192a 100644
--- a/src/gui/buyselldialog.cpp
+++ b/src/gui/buyselldialog.cpp
@@ -37,7 +37,7 @@
BuySellDialog::DialogList BuySellDialog::instances;
BuySellDialog::BuySellDialog(int npcId):
- Window(_("Shop")),
+ Window(_("Shop"), false, 0, "buysell.xml"),
mNpcId(npcId),
mNick(""),
mBuyButton(0)
@@ -46,7 +46,7 @@ BuySellDialog::BuySellDialog(int npcId):
}
BuySellDialog::BuySellDialog(std::string nick):
- Window(_("Shop")),
+ Window(_("Shop"), false, 0, "buysell.xml"),
mNpcId(-1),
mNick(nick),
mBuyButton(0)
@@ -129,8 +129,8 @@ void BuySellDialog::action(const gcn::ActionEvent &event)
void BuySellDialog::closeAll()
{
- DialogList::iterator it = instances.begin();
- DialogList::iterator it_end = instances.end();
+ DialogList::const_iterator it = instances.begin();
+ DialogList::const_iterator it_end = instances.end();
for (; it != it_end; ++it)
{
diff --git a/src/gui/changeemaildialog.cpp b/src/gui/changeemaildialog.cpp
index c24624bc2..384ebf07f 100644
--- a/src/gui/changeemaildialog.cpp
+++ b/src/gui/changeemaildialog.cpp
@@ -44,10 +44,10 @@
#include "debug.h"
-ChangeEmailDialog::ChangeEmailDialog(LoginData *loginData):
- Window(_("Change Email Address"), true),
+ChangeEmailDialog::ChangeEmailDialog(LoginData *data):
+ Window(_("Change Email Address"), true, 0, "changeemail.xml"),
mWrongDataNoticeListener(new WrongDataNoticeListener),
- mLoginData(loginData)
+ mLoginData(data)
{
gcn::Label *accountLabel = new Label(strprintf(_("Account: %s"),
mLoginData->username.c_str()));
@@ -120,7 +120,7 @@ void ChangeEmailDialog::action(const gcn::ActionEvent &event)
logger->log("ChangeEmailDialog::Email change, Username is %s",
username.c_str());
- std::stringstream errorMessage;
+ std::stringstream errorMsg;
int error = 0;
unsigned int min = Net::getLoginHandler()->getMinPasswordLength();
@@ -129,21 +129,21 @@ void ChangeEmailDialog::action(const gcn::ActionEvent &event)
if (newFirstEmail.length() < min)
{
// First email address too short
- errorMessage << strprintf(_("The new email address needs to be at "
- "least %d characters long."), min);
+ errorMsg << strprintf(_("The new email address needs to be at "
+ "least %d characters long."), min);
error = 1;
}
else if (newFirstEmail.length() > max - 1 )
{
// First email address too long
- errorMessage << strprintf(_("The new email address needs to be "
- "less than %d characters long."), max);
+ errorMsg << strprintf(_("The new email address needs to be "
+ "less than %d characters long."), max);
error = 1;
}
else if (newFirstEmail != newSecondEmail)
{
// Second Pass mismatch
- errorMessage << _("The email address entries mismatch.");
+ errorMsg << _("The email address entries mismatch.");
error = 2;
}
@@ -154,7 +154,7 @@ void ChangeEmailDialog::action(const gcn::ActionEvent &event)
else if (error == 2)
mWrongDataNoticeListener->setTarget(this->mSecondEmailField);
- OkDialog *dlg = new OkDialog(_("Error"), errorMessage.str());
+ OkDialog *dlg = new OkDialog(_("Error"), errorMsg.str());
if (dlg)
dlg->addActionListener(mWrongDataNoticeListener);
}
diff --git a/src/gui/changeemaildialog.h b/src/gui/changeemaildialog.h
index e130a9074..fccb5cb1c 100644
--- a/src/gui/changeemaildialog.h
+++ b/src/gui/changeemaildialog.h
@@ -46,7 +46,7 @@ class ChangeEmailDialog : public Window, public gcn::ActionListener
*
* @see Window::Window
*/
- ChangeEmailDialog(LoginData *loginData);
+ ChangeEmailDialog(LoginData *data);
/**
* Destructor.
diff --git a/src/gui/changepassworddialog.cpp b/src/gui/changepassworddialog.cpp
index 30012ae52..7a67279b6 100644
--- a/src/gui/changepassworddialog.cpp
+++ b/src/gui/changepassworddialog.cpp
@@ -46,10 +46,10 @@
#include "debug.h"
-ChangePasswordDialog::ChangePasswordDialog(LoginData *loginData):
- Window(_("Change Password"), true),
+ChangePasswordDialog::ChangePasswordDialog(LoginData *data):
+ Window(_("Change Password"), true, 0, "changepassword.xml"),
mWrongDataNoticeListener(new WrongDataNoticeListener),
- mLoginData(loginData)
+ mLoginData(data)
{
gcn::Label *accountLabel = new Label(
strprintf(_("Account: %s"), mLoginData->username.c_str()));
@@ -101,7 +101,7 @@ void ChangePasswordDialog::action(const gcn::ActionEvent &event)
logger->log("ChangePasswordDialog::Password change, Username is %s",
username.c_str());
- std::stringstream errorMessage;
+ std::stringstream errorMsg;
int error = 0;
unsigned int min = Net::getLoginHandler()->getMinPasswordLength();
@@ -111,27 +111,27 @@ void ChangePasswordDialog::action(const gcn::ActionEvent &event)
if (oldPassword.empty())
{
// No old password
- errorMessage << _("Enter the old password first.");
+ errorMsg << _("Enter the old password first.");
error = 1;
}
else if (newFirstPass.length() < min)
{
// First password too short
- errorMessage << strprintf(_("The new password needs to be at least"
- " %d characters long."), min);
+ errorMsg << strprintf(_("The new password needs to be at least"
+ " %d characters long."), min);
error = 2;
}
else if (newFirstPass.length() > max - 1 )
{
// First password too long
- errorMessage << strprintf(_("The new password needs to be less "
- "than %d characters long."), max);
+ errorMsg << strprintf(_("The new password needs to be less "
+ "than %d characters long."), max);
error = 2;
}
else if (newFirstPass != newSecondPass)
{
// Second Pass mismatch
- errorMessage << _("The new password entries mismatch.");
+ errorMsg << _("The new password entries mismatch.");
error = 3;
}
@@ -144,7 +144,7 @@ void ChangePasswordDialog::action(const gcn::ActionEvent &event)
else if (error == 3)
mWrongDataNoticeListener->setTarget(this->mSecondPassField);
- OkDialog *dlg = new OkDialog(_("Error"), errorMessage.str());
+ OkDialog *dlg = new OkDialog(_("Error"), errorMsg.str());
dlg->addActionListener(mWrongDataNoticeListener);
}
else
diff --git a/src/gui/changepassworddialog.h b/src/gui/changepassworddialog.h
index 3b0626922..fca8b4946 100644
--- a/src/gui/changepassworddialog.h
+++ b/src/gui/changepassworddialog.h
@@ -46,7 +46,7 @@ class ChangePasswordDialog : public Window, public gcn::ActionListener
*
* @see Window::Window
*/
- ChangePasswordDialog(LoginData *loginData);
+ ChangePasswordDialog(LoginData *data);
/**
* Destructor
diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp
index d1773e7f3..efe7e804f 100644
--- a/src/gui/charcreatedialog.cpp
+++ b/src/gui/charcreatedialog.cpp
@@ -55,7 +55,7 @@
#include "debug.h"
CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot):
- Window(_("Create Character"), true, parent),
+ Window(_("Create Character"), true, parent, "charcreate.xml"),
mCharSelectDialog(parent),
mRace(0),
mSlot(slot)
diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp
index 1942ebaeb..00cae41e6 100644
--- a/src/gui/charselectdialog.cpp
+++ b/src/gui/charselectdialog.cpp
@@ -121,54 +121,54 @@ class CharacterDisplay : public Container
Button *mDelete;
};
-CharSelectDialog::CharSelectDialog(LoginData *loginData):
- Window(_("Account and Character Management")),
+CharSelectDialog::CharSelectDialog(LoginData *data):
+ Window(_("Account and Character Management"), false, 0, "char.xml"),
mLocked(false),
mUnregisterButton(0),
mChangeEmailButton(0),
mCharacterEntries(0),
- mLoginData(loginData),
+ mLoginData(data),
mCharHandler(Net::getCharHandler()),
mDeleteDialog(0),
mDeleteIndex(-1)
{
setCloseButton(false);
- mAccountNameLabel = new Label(loginData->username);
+ mAccountNameLabel = new Label(mLoginData->username);
mSwitchLoginButton = new Button(_("Switch Login"), "switch", this);
mChangePasswordButton = new Button(_("Change Password"), "change_password",
this);
int optionalActions = Net::getLoginHandler()->supportedOptionalActions();
- ContainerPlacer place;
- place = getPlacer(0, 0);
+ ContainerPlacer placer;
+ placer = getPlacer(0, 0);
- place(0, 0, mAccountNameLabel, 2);
- place(0, 1, mSwitchLoginButton);
+ placer(0, 0, mAccountNameLabel, 2);
+ placer(0, 1, mSwitchLoginButton);
if (optionalActions & Net::LoginHandler::Unregister)
{
mUnregisterButton = new Button(_("Unregister"),
"unregister", this);
- place(3, 1, mUnregisterButton);
+ placer(3, 1, mUnregisterButton);
}
- place(0, 2, mChangePasswordButton);
+ placer(0, 2, mChangePasswordButton);
if (optionalActions & Net::LoginHandler::ChangeEmail)
{
mChangeEmailButton = new Button(_("Change Email"),
"change_email", this);
- place(3, 2, mChangeEmailButton);
+ placer(3, 2, mChangeEmailButton);
}
- place = getPlacer(0, 1);
+ placer = getPlacer(0, 1);
for (int i = 0; i < static_cast<int>(mLoginData->characterSlots); i++)
{
mCharacterEntries.push_back(new CharacterDisplay(this));
- place(i % SLOTS_PER_ROW, static_cast<int>(i) / SLOTS_PER_ROW,
+ placer(i % SLOTS_PER_ROW, static_cast<int>(i) / SLOTS_PER_ROW,
mCharacterEntries[i]);
}
@@ -309,10 +309,12 @@ void CharSelectDialog::attemptCharacterSelect(int index)
void CharSelectDialog::setCharacters(const Net::Characters &characters)
{
// Reset previous characters
- std::vector<CharacterDisplay*>::iterator iter, iter_end;
+ std::vector<CharacterDisplay*>::const_iterator iter, iter_end;
for (iter = mCharacterEntries.begin(), iter_end = mCharacterEntries.end();
iter != iter_end; ++iter)
+ {
(*iter)->setCharacter(0);
+ }
Net::Characters::const_iterator i, i_end = characters.end();
for (i = characters.begin(); i != i_end; ++i)
@@ -371,7 +373,7 @@ void CharSelectDialog::setLocked(bool locked)
}
bool CharSelectDialog::selectByName(const std::string &name,
- SelectAction action)
+ SelectAction selAction)
{
if (mLocked)
return false;
@@ -385,7 +387,7 @@ bool CharSelectDialog::selectByName(const std::string &name,
{
if (mCharacterEntries[i])
mCharacterEntries[i]->requestFocus();
- if (action == Choose)
+ if (selAction == Choose)
attemptCharacterSelect(i);
return true;
}
@@ -408,14 +410,14 @@ CharacterDisplay::CharacterDisplay(CharSelectDialog *charSelectDialog):
mDelete = new Button(_("Delete"), "delete", charSelectDialog);
LayoutHelper h(this);
- ContainerPlacer place = h.getPlacer(0, 0);
-
- place(0, 0, mPlayerBox, 3, 5);
- place(0, 5, mName, 3);
- place(0, 6, mLevel, 3);
- place(0, 7, mMoney, 3);
- place(0, 8, mButton, 3);
- place(0, 9, mDelete, 3);
+ ContainerPlacer placer = h.getPlacer(0, 0);
+
+ placer(0, 0, mPlayerBox, 3, 5);
+ placer(0, 5, mName, 3);
+ placer(0, 6, mLevel, 3);
+ placer(0, 7, mMoney, 3);
+ placer(0, 8, mButton, 3);
+ placer(0, 9, mDelete, 3);
update();
diff --git a/src/gui/charselectdialog.h b/src/gui/charselectdialog.h
index bcbbb7679..0dfe90733 100644
--- a/src/gui/charselectdialog.h
+++ b/src/gui/charselectdialog.h
@@ -60,7 +60,7 @@ class CharSelectDialog : public Window, public gcn::ActionListener,
/**
* Constructor.
*/
- CharSelectDialog(LoginData *loginData);
+ CharSelectDialog(LoginData *data);
~CharSelectDialog();
diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp
index 784fb812a..82d6c2ff5 100644
--- a/src/gui/chatwindow.cpp
+++ b/src/gui/chatwindow.cpp
@@ -149,7 +149,7 @@ public:
ChatWindow::ChatWindow():
- Window(_("Chat")),
+ Window(_("Chat"), false, 0, "chat.xml"),
mTmpVisible(false),
mChatHistoryIndex(0)
{
@@ -666,8 +666,8 @@ void ChatWindow::mouseDragged(gcn::MouseEvent &event)
{
int newX = std::max(0, getX() + event.getX() - mDragOffsetX);
int newY = std::max(0, getY() + event.getY() - mDragOffsetY);
- newX = std::min(graphics->mWidth - getWidth(), newX);
- newY = std::min(graphics->mHeight - getHeight(), newY);
+ newX = std::min(mainGraphics->mWidth - getWidth(), newX);
+ newY = std::min(mainGraphics->mHeight - getHeight(), newY);
setPosition(newX, newY);
}
}
@@ -754,7 +754,7 @@ void ChatWindow::keyPressed(gcn::KeyEvent &event)
mChatHistoryIndex --;
}
- std::list<std::string>::iterator it;
+ std::list<std::string>::const_iterator it;
unsigned int f = 0;
for (it = tab->getRows().begin();
it != tab->getRows().end(); ++it, f++)
@@ -788,7 +788,7 @@ void ChatWindow::keyPressed(gcn::KeyEvent &event)
mChatHistoryIndex = 0;
}
- std::list<std::string>::iterator it;
+ std::list<std::string>::const_iterator it;
unsigned int f = 0;
for (it = tab->getRows().begin();
it != tab->getRows().end(); ++it, f++)
@@ -822,7 +822,7 @@ void ChatWindow::keyPressed(gcn::KeyEvent &event)
addInputText(Temp, false);
}
-void ChatWindow::event(Mana::Channels channel, const Mana::Event &event)
+void ChatWindow::processEvent(Mana::Channels channel, const Mana::Event &event)
{
if (channel == Mana::CHANNEL_NOTICES)
{
@@ -907,9 +907,9 @@ void ChatWindow::addItemText(const std::string &item)
addInputText(text.str());
}
-void ChatWindow::setVisible(bool isVisible)
+void ChatWindow::setVisible(bool visible)
{
- Window::setVisible(isVisible);
+ Window::setVisible(visible);
/*
* For whatever reason, if setVisible is called, the mTmpVisible effect
@@ -918,8 +918,8 @@ void ChatWindow::setVisible(bool isVisible)
mTmpVisible = false;
}
-void ChatWindow::whisper(const std::string &nick,
- const std::string &mes, Own own)
+void ChatWindow::addWhisper(const std::string &nick,
+ const std::string &mes, Own own)
{
if (mes.empty() || !player_node)
return;
@@ -1074,7 +1074,7 @@ std::string ChatWindow::addColors(std::string &msg)
return msg;
}
- std::string newMsg = "";
+ std::string newMsg("");
int cMap[] = {1, 4, 5, 2, 3, 6, 7, 9, 0, 8};
// rainbow
@@ -1179,7 +1179,7 @@ void ChatWindow::autoComplete()
std::string ChatWindow::autoComplete(std::vector<std::string> &names,
std::string partName) const
{
- std::vector<std::string>::iterator i = names.begin();
+ std::vector<std::string>::const_iterator i = names.begin();
toLower(partName);
std::string newName("");
@@ -1195,8 +1195,7 @@ std::string ChatWindow::autoComplete(std::vector<std::string> &names,
{
if (newName != "")
{
- toLower(newName);
- newName = findSameSubstring(name, newName);
+ newName = findSameSubstringI(*i, newName);
}
else
{
@@ -1215,7 +1214,7 @@ std::string ChatWindow::autoComplete(std::string partName, History *words)
if (!words)
return "";
- Commands::iterator i = words->begin();
+ Commands::const_iterator i = words->begin();
std::vector<std::string> nameList;
while (i != words->end())
@@ -1243,7 +1242,7 @@ void ChatWindow::moveTabRight(ChatTab *tab)
std::string ChatWindow::autoCompleteHistory(std::string partName)
{
- History::iterator i = mHistory.begin();
+ History::const_iterator i = mHistory.begin();
std::vector<std::string> nameList;
while (i != mHistory.end())
@@ -1344,7 +1343,7 @@ void ChatWindow::initTradeFilter()
void ChatWindow::updateOnline(std::set<std::string> &onlinePlayers)
{
- TabMap::iterator iter;
+ TabMap::const_iterator iter;
const Party *party = 0;
const Guild *guild = 0;
if (player_node)
@@ -1429,7 +1428,7 @@ void ChatWindow::loadState()
void ChatWindow::saveState()
{
int num = 0;
- TabMap::iterator iter;
+ TabMap::const_iterator iter;
for (iter = mWhispers.begin(); iter != mWhispers.end() && num < 50; ++iter)
{
if (!iter->second)
diff --git a/src/gui/chatwindow.h b/src/gui/chatwindow.h
index 6e1d548a3..1ad468a3b 100644
--- a/src/gui/chatwindow.h
+++ b/src/gui/chatwindow.h
@@ -196,7 +196,7 @@ class ChatWindow : public Window,
*/
void mousePressed(gcn::MouseEvent &event);
- void event(Mana::Channels channel, const Mana::Event &event);
+ void processEvent(Mana::Channels channel, const Mana::Event &event);
/**
* Scrolls the chat window
@@ -222,8 +222,8 @@ class ChatWindow : public Window,
void doPresent();
- void whisper(const std::string &nick, const std::string &mes,
- Own own = BY_OTHER);
+ void addWhisper(const std::string &nick, const std::string &mes,
+ Own own = BY_OTHER);
ChatTab *addWhisperTab(const std::string &nick, bool switchTo = false);
diff --git a/src/gui/confirmdialog.cpp b/src/gui/confirmdialog.cpp
index 661168dd9..f7f81bd2f 100644
--- a/src/gui/confirmdialog.cpp
+++ b/src/gui/confirmdialog.cpp
@@ -37,7 +37,7 @@
ConfirmDialog::ConfirmDialog(const std::string &title, const std::string &msg,
bool ignore, bool modal, Window *parent):
- Window(title, modal, parent)
+ Window(title, modal, parent, "confirm.xml")
{
mTextBox = new TextBox;
mTextBox->setEditable(false);
diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp
index dc540a782..83e9791ef 100644
--- a/src/gui/debugwindow.cpp
+++ b/src/gui/debugwindow.cpp
@@ -51,7 +51,7 @@
#include "debug.h"
DebugWindow::DebugWindow():
- Window(_("Debug"))
+ Window(_("Debug"), false, 0, "debug.xml")
{
setWindowName("Debug");
if (setupWindow)
diff --git a/src/gui/didyouknowwindow.cpp b/src/gui/didyouknowwindow.cpp
index d62417fc4..df15e6ebd 100644
--- a/src/gui/didyouknowwindow.cpp
+++ b/src/gui/didyouknowwindow.cpp
@@ -44,7 +44,7 @@ static const int minTip = 1;
static const int maxTip = 14;
DidYouKnowWindow::DidYouKnowWindow():
- Window(_("Did You Know?"))
+ Window(_("Did You Know?"), false, 0, "didyouknow.xml")
{
setMinWidth(300);
setMinHeight(250);
diff --git a/src/gui/editdialog.cpp b/src/gui/editdialog.cpp
index da1d98e81..84f4f6ddf 100644
--- a/src/gui/editdialog.cpp
+++ b/src/gui/editdialog.cpp
@@ -37,7 +37,7 @@
EditDialog::EditDialog(const std::string &title, const std::string &msg,
std::string eventOk, int width,
Window *parent, bool modal):
- Window(title, modal, parent)
+ Window(title, modal, parent, "edit.xml")
{
mTextField = new TextField;
mTextField->setText(msg);
diff --git a/src/gui/emotepopup.cpp b/src/gui/emotepopup.cpp
index 348a97952..6d2bf7be2 100644
--- a/src/gui/emotepopup.cpp
+++ b/src/gui/emotepopup.cpp
@@ -48,7 +48,8 @@ const int EmotePopup::gridHeight = 36; // emote icon height + 4
static const int MAX_COLUMNS = 6;
-EmotePopup::EmotePopup():
+EmotePopup::EmotePopup() :
+ Popup("EmotePopup", "emotepopup.xml"),
mSelectedEmoteIndex(-1),
mHoveredEmoteIndex(-1),
mRowCount(1),
diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp
index 0375d096f..f423cddf0 100644
--- a/src/gui/equipmentwindow.cpp
+++ b/src/gui/equipmentwindow.cpp
@@ -58,7 +58,7 @@ static const int BOX_HEIGHT = 36;
EquipmentWindow::EquipmentWindow(Equipment *equipment, Being *being,
bool foring):
- Window(_("Equipment")),
+ Window(_("Equipment"), false, 0, "equipment.xml"),
mEquipment(equipment),
mSelected(-1),
mForing(foring)
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 7d38b1025..658d65769 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -394,7 +394,7 @@ void Gui::distributeMouseEvent(gcn::Widget* source, int type, int button,
= widget->_getMouseListeners();
// Send the event to all mouse listeners of the widget.
- for (std::list<gcn::MouseListener*>::iterator
+ for (std::list<gcn::MouseListener*>::const_iterator
it = mouseListeners.begin();
it != mouseListeners.end(); ++ it)
{
diff --git a/src/gui/helpwindow.cpp b/src/gui/helpwindow.cpp
index b772ea36a..019baf503 100644
--- a/src/gui/helpwindow.cpp
+++ b/src/gui/helpwindow.cpp
@@ -40,7 +40,7 @@
#include "debug.h"
HelpWindow::HelpWindow():
- Window(_("Help"))
+ Window(_("Help"), false, 0, "help.xml")
{
setMinWidth(300);
setMinHeight(250);
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index d0454c4e1..cd02a6732 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -22,6 +22,7 @@
#include "gui/inventorywindow.h"
+#include "configuration.h"
#include "inventory.h"
#include "item.h"
#include "units.h"
@@ -38,6 +39,7 @@
#include "gui/widgets/button.h"
#include "gui/widgets/container.h"
+#include "gui/widgets/dropdown.h"
#include "gui/widgets/inventoryfilter.h"
#include "gui/widgets/itemcontainer.h"
#include "gui/widgets/label.h"
@@ -45,6 +47,7 @@
#include "gui/widgets/progressbar.h"
#include "gui/widgets/radiobutton.h"
#include "gui/widgets/scrollarea.h"
+#include "gui/widgets/textfield.h"
#include "net/inventoryhandler.h"
#include "net/net.h"
@@ -62,10 +65,38 @@
#include "debug.h"
+const char *SORT_NAME[6] =
+{
+ N_("default"),
+ N_("by name"),
+ N_("by id"),
+ N_("by weight"),
+ N_("by amount"),
+ N_("by type")
+};
+
+class SortListModel : public gcn::ListModel
+{
+public:
+ virtual ~SortListModel()
+ { }
+
+ virtual int getNumberOfElements()
+ { return 6; }
+
+ virtual std::string getElementAt(int i)
+ {
+ if (i >= getNumberOfElements() || i < 0)
+ return _("???");
+
+ return gettext(SORT_NAME[i]);
+ }
+};
+
InventoryWindow::WindowList InventoryWindow::instances;
InventoryWindow::InventoryWindow(Inventory *inventory):
- Window(),
+ Window("Inventory", false, 0, "inventory.xml"),
mInventory(inventory),
mDropButton(0),
mSplit(false)
@@ -105,25 +136,23 @@ InventoryWindow::InventoryWindow(Inventory *inventory):
mSlotsLabel = new Label(_("Slots:"));
mSlotsBar = new ProgressBar(0.0f, 100, 20, Theme::PROG_INVY_SLOTS);
- mFilter = new InventoryFilter("filter_" + getWindowName(), 20, 5);
+ int size = config.getIntValue("fontSize");
+ mFilter = new InventoryFilter("filter_" + getWindowName(), size, 0);
mFilter->addActionListener(this);
mFilter->setActionEventId("tag_");
- mSorter = new InventoryFilter("sorter_" + getWindowName(), 20, 0);
- mSorter->addActionListener(this);
- mSorter->setActionEventId("sort_");
+ mSortModel = new SortListModel();
+ mSortDropDown = new DropDown(mSortModel, this, "sort");
+ mSortDropDown->setSelected(0);
mFilterLabel = new Label(_("Filter:"));
mSorterLabel = new Label(_("Sort:"));
+ mNameFilter = new TextField("", true, this, "namefilter", true);
std::vector<std::string> tags = ItemDB::getTags();
for (unsigned f = 0; f < tags.size(); f ++)
mFilter->addButton(tags[f]);
- mSorter->addButton(_("na"), "na");
- mSorter->addButton(_("az"), "az");
- mSorter->addButton(_("id"), "id");
-
if (isMainInventory())
{
std::string equip = _("Equip");
@@ -154,10 +183,11 @@ InventoryWindow::InventoryWindow(Inventory *inventory):
place(4, 0, mSlotsLabel, 1).setPadding(3);
place(5, 0, mSlotsBar, 2);
place(7, 0, mSorterLabel, 1);
- place(8, 0, mSorter, 3);
+ place(8, 0, mSortDropDown, 3);
place(0, 1, mFilterLabel, 1).setPadding(3);
- place(1, 1, mFilter, 10).setPadding(3);
+ place(1, 1, mFilter, 7).setPadding(3);
+ place(8, 1, mNameFilter, 3);
place(0, 2, invenScroll, 11).setPadding(3);
place(0, 3, mUseButton);
@@ -176,12 +206,13 @@ InventoryWindow::InventoryWindow(Inventory *inventory):
mCloseButton = new Button(_("Close"), "close", this);
place(0, 0, mSlotsLabel).setPadding(3);
- place(1, 0, mSlotsBar, 3);
- place(4, 0, mSorterLabel, 1);
- place(5, 0, mSorter, 2);
+ place(1, 0, mSlotsBar, 4);
+ place(5, 0, mSorterLabel, 1);
+ place(6, 0, mSortDropDown, 1);
place(0, 1, mFilterLabel, 1).setPadding(3);
- place(1, 1, mFilter, 6).setPadding(3);
+ place(1, 1, mFilter, 5).setPadding(3);
+ place(6, 1, mNameFilter, 1);
place(0, 2, invenScroll, 7, 4);
place(0, 6, mStoreButton);
@@ -219,6 +250,8 @@ InventoryWindow::~InventoryWindow()
mInventory->removeInventoyListener(this);
if (!instances.empty())
instances.front()->updateDropButton();
+ delete mSortModel;
+ mSortModel = 0;
}
void InventoryWindow::action(const gcn::ActionEvent &event)
@@ -258,22 +291,21 @@ void InventoryWindow::action(const gcn::ActionEvent &event)
ItemAmountWindow::showWindow(ItemAmountWindow::StoreAdd, this, item);
}
+ else if (event.getId() == "sort")
+ {
+ mItems->setSortType(mSortDropDown->getSelected());
+ return;
+ }
+ else if (event.getId() == "namefilter")
+ {
+ mItems->setName(mNameFilter->getText());
+ mItems->updateMatrix();
+ }
else if (!event.getId().find("tag_") && mItems)
{
std::string tagName = event.getId().substr(4);
mItems->setFilter(ItemDB::getTagId(tagName));
- }
- else if (!event.getId().find("sort_") && mItems)
- {
- int sortType = 0;
- std::string str = event.getId().substr(5).c_str();
- if (str == "na")
- sortType = 0;
- else if (str == "az")
- sortType = 1;
- else if (str == "id")
- sortType = 2;
- mItems->setSortType(sortType);
+ return;
}
Item *item = mItems->getSelectedItem();
@@ -330,17 +362,12 @@ void InventoryWindow::action(const gcn::ActionEvent &event)
else if (event.getId() == "split")
{
ItemAmountWindow::showWindow(ItemAmountWindow::ItemSplit, this, item,
- (item->getQuantity() - 1));
+ (item->getQuantity() - 1));
}
else if (event.getId() == "retrieve")
{
- Item *item = mItems->getSelectedItem();
-
- if (!item)
- return;
-
- ItemAmountWindow::showWindow(ItemAmountWindow::StoreRemove, this,
- item);
+ ItemAmountWindow::showWindow(ItemAmountWindow::StoreRemove,
+ this, item);
}
}
@@ -532,7 +559,6 @@ void InventoryWindow::updateButtons(Item *item)
else
mSplitButton->setEnabled(false);
}
-
}
void InventoryWindow::setSplitAllowed(bool allowed)
@@ -553,8 +579,8 @@ void InventoryWindow::close()
}
}
-void InventoryWindow::event(Mana::Channels channel A_UNUSED,
- const Mana::Event &event)
+void InventoryWindow::processEvent(Mana::Channels channel A_UNUSED,
+ const Mana::Event &event)
{
if (event.getName() == Mana::EVENT_UPDATEATTRIBUTE)
{
@@ -622,3 +648,21 @@ void InventoryWindow::updateDropButton()
mDropButton->setCaption(_("Drop"));
}
}
+
+bool InventoryWindow::isInputFocused() const
+{
+ return mNameFilter && mNameFilter->isFocused();
+}
+
+bool InventoryWindow::isAnyInputFocused()
+{
+ WindowList::const_iterator it = instances.begin();
+ WindowList::const_iterator it_end = instances.end();
+
+ for (; it != it_end; ++it)
+ {
+ if ((*it) && (*it)->isInputFocused())
+ return true;
+ }
+ return false;
+}
diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h
index 503423ad3..c32fd8905 100644
--- a/src/gui/inventorywindow.h
+++ b/src/gui/inventorywindow.h
@@ -41,11 +41,14 @@
#define A_UNUSED
#endif
+class DropDown;
class Item;
class ItemContainer;
class InventoryFilter;
class ProgressBar;
-class TextBox;
+class SortListModel;
+//class TextBox;
+class TextField;
/**
* Inventory dialog.
@@ -124,10 +127,14 @@ class InventoryWindow : public Window,
void updateDropButton();
- void event(Mana::Channels channel, const Mana::Event &event);
+ void processEvent(Mana::Channels channel, const Mana::Event &event);
void updateButtons(Item *item = 0);
+ bool isInputFocused() const;
+
+ static bool isAnyInputFocused();
+
private:
/**
* Updates the weight bar.
@@ -151,7 +158,9 @@ class InventoryWindow : public Window,
ProgressBar *mWeightBar, *mSlotsBar;
InventoryFilter *mFilter;
- InventoryFilter *mSorter;
+ DropDown *mSortDropDown;
+ SortListModel *mSortModel;
+ TextField *mNameFilter;
bool mSplit;
};
diff --git a/src/gui/itemamountwindow.cpp b/src/gui/itemamountwindow.cpp
index 059f3d785..7c5b19415 100644
--- a/src/gui/itemamountwindow.cpp
+++ b/src/gui/itemamountwindow.cpp
@@ -53,11 +53,11 @@ class ItemsModal : public gcn::ListModel
public:
ItemsModal()
{
- std::map<int, ItemInfo*> info = ItemDB::getItemInfos();
+ std::map<int, ItemInfo*> items = ItemDB::getItemInfos();
std::list<std::string> tempStrings;
for (std::map<int, ItemInfo*>::const_iterator
- i = info.begin(), i_end = info.end();
+ i = items.begin(), i_end = items.end();
i != i_end; ++i)
{
if (i->first < 0)
@@ -137,7 +137,7 @@ void ItemAmountWindow::finish(Item *item, int amount, int price, Usage usage)
ItemAmountWindow::ItemAmountWindow(Usage usage, Window *parent, Item *item,
int maxRange):
- Window("", true, parent),
+ Window("", true, parent, "amount.xml"),
mItemPriceTextField(0),
mGPLabel(0),
mItem(item),
@@ -213,21 +213,21 @@ ItemAmountWindow::ItemAmountWindow(Usage usage, Window *parent, Item *item,
minusAmountButton->setWidth(plusAmountButton->getWidth());
// Set positions
- ContainerPlacer place;
- place = getPlacer(0, 0);
+ ContainerPlacer placer;
+ placer = getPlacer(0, 0);
int n = 0;
if (mUsage == ShopBuyAdd)
{
- place(0, n, mItemDropDown, 8);
+ placer(0, n, mItemDropDown, 8);
n++;
}
- place(1, n, minusAmountButton);
- place(2, n, mItemAmountTextField, 3);
- place(5, n, plusAmountButton);
- place(6, n, addAllButton);
+ placer(1, n, minusAmountButton);
+ placer(2, n, mItemAmountTextField, 3);
+ placer(5, n, plusAmountButton);
+ placer(6, n, addAllButton);
- place(0, n, mItemIcon, 1, 3);
- place(1, n + 1, mItemAmountSlide, 7);
+ placer(0, n, mItemIcon, 1, 3);
+ placer(1, n + 1, mItemAmountSlide, 7);
if (mUsage == ShopBuyAdd || mUsage == ShopSellAdd)
{
@@ -236,19 +236,19 @@ ItemAmountWindow::ItemAmountWindow(Usage usage, Window *parent, Item *item,
minusPriceButton->adjustSize();
minusPriceButton->setWidth(plusPriceButton->getWidth());
- place(1, n + 2, minusPriceButton);
- place(2, n + 2, mItemPriceTextField, 3);
- place(5, n + 2, plusPriceButton);
- place(6, n + 2, mGPLabel);
+ placer(1, n + 2, minusPriceButton);
+ placer(2, n + 2, mItemPriceTextField, 3);
+ placer(5, n + 2, plusPriceButton);
+ placer(6, n + 2, mGPLabel);
- place(1, n + 3, mItemPriceSlide, 7);
- place(4, n + 5, cancelButton);
- place(5, n + 5, okButton);
+ placer(1, n + 3, mItemPriceSlide, 7);
+ placer(4, n + 5, cancelButton);
+ placer(5, n + 5, okButton);
}
else
{
- place(4, n + 2, cancelButton);
- place(5, n + 2, okButton);
+ placer(4, n + 2, cancelButton);
+ placer(5, n + 2, okButton);
}
reflowLayout(225, 0);
diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp
index 4d401a627..b05d7fe28 100644
--- a/src/gui/itempopup.cpp
+++ b/src/gui/itempopup.cpp
@@ -49,7 +49,7 @@
#include "debug.h"
ItemPopup::ItemPopup():
- Popup("ItemPopup"),
+ Popup("ItemPopup", "itempopup.xml"),
mIcon(0),
mLastName(""),
mLastColor(1)
diff --git a/src/gui/killstats.cpp b/src/gui/killstats.cpp
index b9ce7c2a7..4bcab0a09 100644
--- a/src/gui/killstats.cpp
+++ b/src/gui/killstats.cpp
@@ -43,7 +43,8 @@
#include "debug.h"
KillStats::KillStats():
- Window(_("Kill stats")), mKillCounter(0), mExpCounter(0),
+ Window(_("Kill stats"), false, 0, "killstats.xml"),
+ mKillCounter(0), mExpCounter(0),
mKillTCounter(0), mExpTCounter(0), mKillTimer(0),
m1minExpTime(0), m1minExpNum(0), m1minSpeed(0),
m5minExpTime(0), m5minExpNum(0), m5minSpeed(0),
@@ -55,6 +56,7 @@ KillStats::KillStats():
setWindowName("Kill stats");
setCloseButton(true);
setResizable(true);
+ setSaveVisible(true);
setStickyButtonLock(true);
setDefaultSize(250, 250, 350, 300);
@@ -436,8 +438,8 @@ void KillStats::validateJacko()
}
}
-void KillStats::event(Mana::Channels channel A_UNUSED,
- const Mana::Event &event)
+void KillStats::processEvent(Mana::Channels channel A_UNUSED,
+ const Mana::Event &event)
{
if (event.getName() == Mana::EVENT_UPDATEATTRIBUTE)
{
diff --git a/src/gui/killstats.h b/src/gui/killstats.h
index ff2a8f010..8562e67a4 100644
--- a/src/gui/killstats.h
+++ b/src/gui/killstats.h
@@ -78,8 +78,8 @@ class KillStats : public Window, gcn::ActionListener, public Mana::Listener
void addLog(std::string str);
- void event(Mana::Channels channel A_UNUSED,
- const Mana::Event &event);
+ void processEvent(Mana::Channels channel A_UNUSED,
+ const Mana::Event &event);
private:
void validateJacko();
diff --git a/src/gui/logindialog.cpp b/src/gui/logindialog.cpp
index ab5dc7401..136a01b37 100644
--- a/src/gui/logindialog.cpp
+++ b/src/gui/logindialog.cpp
@@ -50,8 +50,8 @@ static const int LOGIN_DIALOG_WIDTH = 300;
static const int LOGIN_DIALOG_HEIGHT = 140;
static const int FIELD_WIDTH = LOGIN_DIALOG_WIDTH - 70;
-std::string LoginDialog::savedPassword = "";
-std::string LoginDialog::savedPasswordKey = "";
+std::string LoginDialog::savedPassword("");
+std::string LoginDialog::savedPasswordKey("");
const char *UPDATE_TYPE_TEXT[3] =
@@ -81,10 +81,10 @@ public:
}
};
-LoginDialog::LoginDialog(LoginData *loginData, std::string serverName,
+LoginDialog::LoginDialog(LoginData *data, std::string serverName,
std::string *updateHost):
- Window(_("Login")),
- mLoginData(loginData),
+ Window(_("Login"), false, 0, "login.xml"),
+ mLoginData(data),
mUpdateHost(updateHost),
mServerName(serverName)
{
@@ -94,7 +94,7 @@ LoginDialog::LoginDialog(LoginData *loginData, std::string serverName,
gcn::Label *userLabel = new Label(_("Name:"));
gcn::Label *passLabel = new Label(_("Password:"));
mCustomUpdateHost = new CheckBox(_("Custom update host"),
- loginData->updateType & LoginData::Upd_Custom, this, "customhost");
+ mLoginData->updateType & LoginData::Upd_Custom, this, "customhost");
mUpdateHostText = new TextField(serverConfig.getValue(
"customUpdateHost", ""));
@@ -112,7 +112,7 @@ LoginDialog::LoginDialog(LoginData *loginData, std::string serverName,
mUpdateTypeModel = new UpdateTypeModel();
mUpdateTypeDropDown = new DropDown(mUpdateTypeModel);
mUpdateTypeDropDown->setActionEventId("updatetype");
- mUpdateTypeDropDown->setSelected((loginData->updateType
+ mUpdateTypeDropDown->setSelected((mLoginData->updateType
| LoginData::Upd_Custom) ^ LoginData::Upd_Custom);
if (!mCustomUpdateHost->isSelected())
diff --git a/src/gui/logindialog.h b/src/gui/logindialog.h
index e464c6f24..0696bc680 100644
--- a/src/gui/logindialog.h
+++ b/src/gui/logindialog.h
@@ -49,7 +49,7 @@ class LoginDialog : public Window, public gcn::ActionListener,
*
* @see Window::Window
*/
- LoginDialog(LoginData *loginData, std::string serverName,
+ LoginDialog(LoginData *data, std::string serverName,
std::string *updateHost);
~LoginDialog();
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp
index c3a4417f6..e42f12336 100644
--- a/src/gui/minimap.cpp
+++ b/src/gui/minimap.cpp
@@ -47,11 +47,13 @@
bool Minimap::mShow = true;
Minimap::Minimap():
- Window(_("Map")),
+ Window(_("Map"), false, 0, "map.xml"),
mMapImage(0),
mWidthProportion(0.5),
mHeightProportion(0.5),
- mCustomMapImage(false)
+ mCustomMapImage(false),
+ mMapOriginX(0),
+ mMapOriginY(0)
{
setWindowName("Minimap");
mShow = config.getValueBool(getWindowName() + "Show", true);
@@ -87,7 +89,7 @@ Minimap::~Minimap()
void Minimap::setMap(Map *map)
{
- std::string caption = "";
+ std::string caption("");
std::string minimapName;
if (map)
@@ -215,8 +217,11 @@ void Minimap::draw(gcn::Graphics *graphics)
graphics->pushClipArea(a);
- int mapOriginX = 0;
- int mapOriginY = 0;
+ if (!actorSpriteManager)
+ return;
+
+ mMapOriginX = 0;
+ mMapOriginY = 0;
if (mMapImage)
{
@@ -224,33 +229,30 @@ void Minimap::draw(gcn::Graphics *graphics)
mMapImage->mBounds.h > a.height)
{
const Vector &p = player_node->getPosition();
- mapOriginX = ((a.width) / 2) - static_cast<int>((p.x
+ mMapOriginX = ((a.width) / 2) - static_cast<int>((p.x
+ viewport->getCameraRelativeX()) * static_cast<int>(
mWidthProportion)) / 32;
- mapOriginY = ((a.height) / 2) - static_cast<int>((p.y
+ mMapOriginY = ((a.height) / 2) - static_cast<int>((p.y
+ viewport->getCameraRelativeX()) * static_cast<int>(
mHeightProportion)) / 32;
const int minOriginX = a.width - mMapImage->mBounds.w;
const int minOriginY = a.height - mMapImage->mBounds.h;
- if (mapOriginX < minOriginX)
- mapOriginX = minOriginX;
- if (mapOriginY < minOriginY)
- mapOriginY = minOriginY;
- if (mapOriginX > 0)
- mapOriginX = 0;
- if (mapOriginY > 0)
- mapOriginY = 0;
+ if (mMapOriginX < minOriginX)
+ mMapOriginX = minOriginX;
+ if (mMapOriginY < minOriginY)
+ mMapOriginY = minOriginY;
+ if (mMapOriginX > 0)
+ mMapOriginX = 0;
+ if (mMapOriginY > 0)
+ mMapOriginY = 0;
}
- graph->drawImage(mMapImage, mapOriginX, mapOriginY);
+ graph->drawImage(mMapImage, mMapOriginX, mMapOriginY);
}
- if (!actorSpriteManager)
- return;
-
const ActorSprites &actors = actorSpriteManager->getAll();
for (ActorSpritesConstIterator it = actors.begin(), it_end = actors.end();
@@ -313,9 +315,9 @@ void Minimap::draw(gcn::Graphics *graphics)
graphics->fillRectangle(gcn::Rectangle(
static_cast<int>(pos.x * mWidthProportion) / 32
- + mapOriginX - offsetWidth,
+ + mMapOriginX - offsetWidth,
static_cast<int>(pos.y * mHeightProportion) / 32
- + mapOriginY - offsetHeight,
+ + mMapOriginY - offsetHeight,
dotSize, dotSize));
}
@@ -351,9 +353,9 @@ void Minimap::draw(gcn::Graphics *graphics)
graphics->fillRectangle(gcn::Rectangle(
static_cast<int>(member->getX()
- * mWidthProportion) + mapOriginX - offsetWidth,
+ * mWidthProportion) + mMapOriginX - offsetWidth,
static_cast<int>(member->getY()
- * mHeightProportion) + mapOriginY - offsetHeight,
+ * mHeightProportion) + mMapOriginY - offsetHeight,
2, 2));
}
++ it;
@@ -367,10 +369,10 @@ void Minimap::draw(gcn::Graphics *graphics)
int x = static_cast<int>((pos.x - (graph->getWidth() / 2)
+ viewport->getCameraRelativeX())
- * mWidthProportion) / 32 + mapOriginX;
+ * mWidthProportion) / 32 + mMapOriginX;
int y = static_cast<int>((pos.y - (graph->getHeight() / 2)
+ viewport->getCameraRelativeY())
- * mHeightProportion) / 32 + mapOriginY;
+ * mHeightProportion) / 32 + mMapOriginY;
const int w = static_cast<int>(static_cast<float>(
graph->getWidth()) * mWidthProportion / 32);
@@ -396,3 +398,22 @@ void Minimap::draw(gcn::Graphics *graphics)
graphics->drawRectangle(gcn::Rectangle(x, y, w, h));
graphics->popClipArea();
}
+
+void Minimap::mouseReleased(gcn::MouseEvent &event)
+{
+ gcn::Window::mouseReleased(event);
+
+ if (!player_node)
+ return;
+
+ if (event.getButton() == gcn::MouseEvent::LEFT)
+ {
+ const gcn::Rectangle a = getChildrenArea();
+ const int x = event.getX() - a.x;
+ const int y = event.getY() - a.y;
+
+ player_node->navigateTo((x - mMapOriginX + mWidthProportion)
+ / mWidthProportion, (y - mMapOriginY + mHeightProportion)
+ / mHeightProportion);
+ }
+}
diff --git a/src/gui/minimap.h b/src/gui/minimap.h
index 33e0f14ee..86996f51c 100644
--- a/src/gui/minimap.h
+++ b/src/gui/minimap.h
@@ -58,12 +58,16 @@ class Minimap : public Window
*/
void draw(gcn::Graphics *graphics);
+ void mouseReleased(gcn::MouseEvent &event);
+
private:
Image *mMapImage;
float mWidthProportion;
float mHeightProportion;
static bool mShow;
bool mCustomMapImage;
+ int mMapOriginX;
+ int mMapOriginY;
};
extern Minimap *minimap;
diff --git a/src/gui/ministatuswindow.cpp b/src/gui/ministatuswindow.cpp
index 08e3d0053..3e66f42cb 100644
--- a/src/gui/ministatuswindow.cpp
+++ b/src/gui/ministatuswindow.cpp
@@ -52,7 +52,7 @@
extern volatile int tick_time;
MiniStatusWindow::MiniStatusWindow():
- Popup("MiniStatus")
+ Popup("MiniStatus", "ministatus.xml")
{
listen(Mana::CHANNEL_ATTRIBUTES);
@@ -134,7 +134,7 @@ MiniStatusWindow::~MiniStatusWindow()
if (inv)
inv->removeInventoyListener(this);
- std::vector <ProgressBar*>::iterator it, it_end;
+ std::vector <ProgressBar*>::const_iterator it, it_end;
for (it = mBars.begin(), it_end = mBars.end(); it != it_end; ++it)
{
ProgressBar *bar = *it;
@@ -160,7 +160,7 @@ ProgressBar *MiniStatusWindow::createBar(float progress, int width, int height,
void MiniStatusWindow::updateBars()
{
int x = 0;
- std::vector <ProgressBar*>::iterator it, it_end;
+ std::vector <ProgressBar*>::const_iterator it, it_end;
ProgressBar* lastBar = 0;
for (it = mBars.begin(), it_end = mBars.end(); it != it_end; ++it)
safeRemove(*it);
@@ -218,8 +218,8 @@ void MiniStatusWindow::drawIcons(Graphics *graphics)
}
}
-void MiniStatusWindow::event(Mana::Channels channel A_UNUSED,
- const Mana::Event &event)
+void MiniStatusWindow::processEvent(Mana::Channels channel A_UNUSED,
+ const Mana::Event &event)
{
if (event.getName() == Mana::EVENT_UPDATEATTRIBUTE)
{
@@ -400,12 +400,12 @@ void MiniStatusWindow::mouseExited(gcn::MouseEvent &event)
mStatusPopup->hide();
}
-void MiniStatusWindow::showBar(std::string name, bool isVisible)
+void MiniStatusWindow::showBar(std::string name, bool visible)
{
ProgressBar *bar = mBarNames[name];
if (!bar)
return;
- bar->setVisible(isVisible);
+ bar->setVisible(visible);
updateBars();
saveBars();
}
@@ -439,7 +439,7 @@ void MiniStatusWindow::loadBars()
void MiniStatusWindow::saveBars()
{
- std::vector <ProgressBar*>::iterator it, it_end;
+ std::vector <ProgressBar*>::const_iterator it, it_end;
int i = 0;
for (it = mBars.begin(), it_end = mBars.end();
it != it_end; ++it)
diff --git a/src/gui/ministatuswindow.h b/src/gui/ministatuswindow.h
index 19517326b..5e1b442dc 100644
--- a/src/gui/ministatuswindow.h
+++ b/src/gui/ministatuswindow.h
@@ -66,7 +66,7 @@ class MiniStatusWindow : public Popup,
void drawIcons(Graphics *graphics);
- void event(Mana::Channels channel, const Mana::Event &event);
+ void processEvent(Mana::Channels channel, const Mana::Event &event);
void updateStatus();
@@ -80,7 +80,7 @@ class MiniStatusWindow : public Popup,
void mouseExited(gcn::MouseEvent &event);
- void showBar(std::string name, bool isVisible);
+ void showBar(std::string name, bool visible);
void updateBars();
diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp
index 0db618d69..3e1ee46d8 100644
--- a/src/gui/npcdialog.cpp
+++ b/src/gui/npcdialog.cpp
@@ -56,7 +56,7 @@
NpcDialog::DialogList NpcDialog::instances;
NpcDialog::NpcDialog(int npcId)
- : Window(_("NPC")),
+ : Window(_("NPC"), false, 0, "npc.xml"),
mNpcId(npcId),
mLogInteraction(config.getBoolValue("logNpcInGui")),
mDefaultInt(0),
@@ -228,8 +228,8 @@ void NpcDialog::action(const gcn::ActionEvent &event)
}
else if (mActionState == NPC_ACTION_INPUT)
{
- std::string printText = ""; // Text that will get printed
- // in the textbox
+ std::string printText(""); // Text that will get printed
+ // in the textbox
if (mInputState == NPC_INPUT_LIST)
{
@@ -362,12 +362,12 @@ bool NpcDialog::isInputFocused() const
bool NpcDialog::isAnyInputFocused()
{
- DialogList::iterator it = instances.begin();
- DialogList::iterator it_end = instances.end();
+ DialogList::const_iterator it = instances.begin();
+ DialogList::const_iterator it_end = instances.end();
for (; it != it_end; ++it)
{
- if ((*it)->isInputFocused())
+ if ((*it) && (*it)->isInputFocused())
return true;
}
@@ -430,12 +430,12 @@ NpcDialog *NpcDialog::getActive()
if (instances.size() == 1)
return instances.front();
- DialogList::iterator it = instances.begin();
- DialogList::iterator it_end = instances.end();
+ DialogList::const_iterator it = instances.begin();
+ DialogList::const_iterator it_end = instances.end();
for (; it != it_end; ++it)
{
- if ((*it)->isFocused())
+ if ((*it) && (*it)->isFocused())
return (*it);
}
@@ -444,8 +444,8 @@ NpcDialog *NpcDialog::getActive()
void NpcDialog::closeAll()
{
- DialogList::iterator it = instances.begin();
- DialogList::iterator it_end = instances.end();
+ DialogList::const_iterator it = instances.begin();
+ DialogList::const_iterator it_end = instances.end();
for (; it != it_end; ++it)
{
diff --git a/src/gui/npcpostdialog.cpp b/src/gui/npcpostdialog.cpp
index 0ba4e44b6..67fc57ba9 100644
--- a/src/gui/npcpostdialog.cpp
+++ b/src/gui/npcpostdialog.cpp
@@ -39,7 +39,7 @@
NpcPostDialog::DialogList NpcPostDialog::instances;
NpcPostDialog::NpcPostDialog(int npcId):
- Window(_("NPC")),
+ Window(_("NPC"), false, 0, "npcpost.xml"),
mNpcId(npcId)
{
setContentSize(400, 180);
@@ -123,8 +123,8 @@ void NpcPostDialog::setVisible(bool visible)
void NpcPostDialog::closeAll()
{
- DialogList::iterator it = instances.begin();
- DialogList::iterator it_end = instances.end();
+ DialogList::const_iterator it = instances.begin();
+ DialogList::const_iterator it_end = instances.end();
for (; it != it_end; ++it)
(*it)->close();
diff --git a/src/gui/okdialog.cpp b/src/gui/okdialog.cpp
index 122d7176f..5a6ee4846 100644
--- a/src/gui/okdialog.cpp
+++ b/src/gui/okdialog.cpp
@@ -35,7 +35,7 @@
OkDialog::OkDialog(const std::string &title, const std::string &msg,
bool modal, bool showCenter, Window *parent):
- Window(title, modal, parent)
+ Window(title, modal, parent, "ok.xml")
{
mTextBox = new TextBox;
mTextBox->setEditable(false);
diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp
index 9601e3ca5..8e0791af1 100644
--- a/src/gui/outfitwindow.cpp
+++ b/src/gui/outfitwindow.cpp
@@ -57,7 +57,7 @@
float OutfitWindow::mAlpha = 1.0;
OutfitWindow::OutfitWindow():
- Window(_("Outfits")),
+ Window(_("Outfits"), false, 0, "outfits.xml"),
mBoxWidth(33),
mBoxHeight(33),
mGridWidth(4),
diff --git a/src/gui/palette.cpp b/src/gui/palette.cpp
index f5c074f6c..f3046264f 100644
--- a/src/gui/palette.cpp
+++ b/src/gui/palette.cpp
@@ -80,8 +80,8 @@ const gcn::Color& Palette::getColor(char c, bool &valid)
void Palette::advanceGradients()
{
- Palettes::iterator it = mInstances.begin();
- Palettes::iterator it_end = mInstances.end();
+ Palettes::const_iterator it = mInstances.begin();
+ Palettes::const_iterator it_end = mInstances.end();
for (; it != it_end; ++it)
(*it)->advanceGradient();
diff --git a/src/gui/palette.h b/src/gui/palette.h
index 1cebe236f..645260280 100644
--- a/src/gui/palette.h
+++ b/src/gui/palette.h
@@ -182,13 +182,14 @@ class Palette
int delay;
int committedDelay;
- void set(int type, gcn::Color& color, GradientType grad, int delay)
+ void set(int type0, gcn::Color& color0, GradientType grad0,
+ int delay0)
{
- ColorElem::type = type;
- ColorElem::color = color;
- ColorElem::testColor = color;
- ColorElem::grad = grad;
- ColorElem::delay = delay;
+ ColorElem::type = type0;
+ ColorElem::color = color0;
+ ColorElem::testColor = color0;
+ ColorElem::grad = grad0;
+ ColorElem::delay = delay0;
ColorElem::gradientIndex = rand();
}
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index 0eac0a4f9..16e3d9ec7 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -83,7 +83,7 @@
std::string tradePartnerName("");
PopupMenu::PopupMenu():
- Popup("PopupMenu"),
+ Popup("PopupMenu", "popupmenu.xml"),
mBeingId(0),
mFloorItem(0),
mItem(0),
@@ -129,60 +129,45 @@ void PopupMenu::showPopup(int x, int y, Being *being)
{
case ActorSprite::PLAYER:
{
- mBrowserBox->addRow(strprintf("@@trade|%s@@", _("Trade")));
- mBrowserBox->addRow(strprintf("@@attack|%s@@", _("Attack")));
- mBrowserBox->addRow(strprintf("@@whisper|%s@@", _("Whisper")));
+ mBrowserBox->addRow("trade", _("Trade"));
+ mBrowserBox->addRow("attack", _("Attack"));
+ mBrowserBox->addRow("whisper", _("Whisper"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@heal|%s@@", _("Heal")));
+ mBrowserBox->addRow("heal", _("Heal"));
mBrowserBox->addRow("##3---");
switch (player_relations.getRelation(name))
{
case PlayerRelation::NEUTRAL:
- mBrowserBox->addRow(strprintf(
- "@@friend|%s@@", _("Be friend")));
- mBrowserBox->addRow(strprintf(
- "@@disregard|%s@@", _("Disregard")));
- mBrowserBox->addRow(strprintf(
- "@@ignore|%s@@", _("Ignore")));
- mBrowserBox->addRow(strprintf(
- "@@erase|%s@@", _("Erase")));
+ mBrowserBox->addRow("friend", _("Be friend"));
+ mBrowserBox->addRow("disregard", _("Disregard"));
+ mBrowserBox->addRow("ignore", _("Ignore"));
+ mBrowserBox->addRow("erase", _("Erase"));
break;
case PlayerRelation::FRIEND:
- mBrowserBox->addRow(strprintf(
- "@@disregard|%s@@", _("Disregard")));
- mBrowserBox->addRow(strprintf(
- "@@ignore|%s@@", _("Ignore")));
- mBrowserBox->addRow(strprintf(
- "@@erase|%s@@", _("Erase")));
+ mBrowserBox->addRow("disregard", _("Disregard"));
+ mBrowserBox->addRow("ignore", _("Ignore"));
+ mBrowserBox->addRow("erase", _("Erase"));
break;
case PlayerRelation::DISREGARDED:
- mBrowserBox->addRow(strprintf(
- "@@unignore|%s@@", _("Unignore")));
- mBrowserBox->addRow(strprintf(
- "@@ignore|%s@@", _("Completely ignore")));
- mBrowserBox->addRow(strprintf(
- "@@erase|%s@@", _("Erase")));
+ mBrowserBox->addRow("unignore", _("Unignore"));
+ mBrowserBox->addRow("ignore", _("Completely ignore"));
+ mBrowserBox->addRow("erase", _("Erase"));
break;
case PlayerRelation::IGNORED:
- mBrowserBox->addRow(strprintf(
- "@@unignore|%s@@", _("Unignore")));
- mBrowserBox->addRow(strprintf(
- "@@erase|%s@@", _("Erase")));
+ mBrowserBox->addRow("unignore", _("Unignore"));
+ mBrowserBox->addRow("erase", _("Erase"));
break;
case PlayerRelation::ERASED:
- mBrowserBox->addRow(strprintf(
- "@@unignore|%s@@", _("Unignore")));
- mBrowserBox->addRow(strprintf(
- "@@disregard|%s@@", _("Disregard")));
- mBrowserBox->addRow(strprintf(
- "@@ignore|%s@@", _("Completely ignore")));
+ mBrowserBox->addRow("unignore", _("Unignore"));
+ mBrowserBox->addRow("disregard", _("Disregard"));
+ mBrowserBox->addRow("ignore", _("Completely ignore"));
break;
default:
@@ -190,9 +175,8 @@ void PopupMenu::showPopup(int x, int y, Being *being)
}
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@follow|%s@@", _("Follow")));
- mBrowserBox->addRow(strprintf(
- "@@imitation|%s@@", _("Imitation")));
+ mBrowserBox->addRow("follow", _("Follow"));
+ mBrowserBox->addRow("imitation", _("Imitation"));
if (player_node->isInParty())
{
@@ -201,13 +185,12 @@ void PopupMenu::showPopup(int x, int y, Being *being)
if (player_node->getParty()->getName()
!= being->getPartyName())
{
- mBrowserBox->addRow(strprintf(
- "@@party|%s@@", _("Invite to party")));
+ mBrowserBox->addRow("party", _("Invite to party"));
}
else
{
- mBrowserBox->addRow(strprintf(
- "@@kick party|%s@@", _("Kick from party")));
+ mBrowserBox->addRow("kick party",
+ _("Kick from party"));
}
mBrowserBox->addRow("##3---");
}
@@ -221,8 +204,8 @@ void PopupMenu::showPopup(int x, int y, Being *being)
{
if (guild1->getId() == guild2->getId())
{
- mBrowserBox->addRow(strprintf(
- "@@guild-kick|%s@@", _("Kick from guild")));
+ mBrowserBox->addRow("guild-kick",
+ _("Kick from guild"));
if (guild2->getServerGuild())
{
mBrowserBox->addRow(strprintf(
@@ -233,8 +216,8 @@ void PopupMenu::showPopup(int x, int y, Being *being)
}
else if (guild2->getMember(mNick))
{
- mBrowserBox->addRow(strprintf(
- "@@guild-kick|%s@@", _("Kick from guild")));
+ mBrowserBox->addRow("guild-kick",
+ _("Kick from guild"));
if (guild2->getServerGuild())
{
mBrowserBox->addRow(strprintf(
@@ -247,8 +230,7 @@ void PopupMenu::showPopup(int x, int y, Being *being)
if (guild2->getServerGuild()
|| (guildManager && guildManager->havePower()))
{
- mBrowserBox->addRow(strprintf(
- "@@guild|%s@@", _("Invite to guild")));
+ mBrowserBox->addRow("guild", _("Invite to guild"));
}
}
}
@@ -256,16 +238,13 @@ void PopupMenu::showPopup(int x, int y, Being *being)
if (player_node->isGM())
{
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf(
- "@@admin-kick|%s@@", _("Kick player")));
+ mBrowserBox->addRow("admin-kick", _("Kick player"));
}
- mBrowserBox->addRow(strprintf("@@nuke|%s@@", _("Nuke")));
- mBrowserBox->addRow(strprintf("@@move|%s@@", _("Move")));
- mBrowserBox->addRow(strprintf("@@items|%s@@",
- _("Show Items")));
- mBrowserBox->addRow(strprintf("@@undress|%s@@", _("Undress")));
- mBrowserBox->addRow(strprintf(
- "@@addcomment|%s@@", _("Add comment")));
+ mBrowserBox->addRow("nuke", _("Nuke"));
+ mBrowserBox->addRow("move", _("Move"));
+ mBrowserBox->addRow("items", _("Show Items"));
+ mBrowserBox->addRow("undress", _("Undress"));
+ mBrowserBox->addRow("addcomment", _("Add comment"));
if (player_relations.getDefault() & PlayerRelation::TRADE)
{
@@ -274,18 +253,14 @@ void PopupMenu::showPopup(int x, int y, Being *being)
{
if (being->isShopEnabled())
{
- mBrowserBox->addRow(strprintf(
- "@@buy|%s@@", _("Buy")));
- mBrowserBox->addRow(strprintf(
- "@@sell|%s@@", _("Sell")));
+ mBrowserBox->addRow("buy", _("Buy"));
+ mBrowserBox->addRow("sell", _("Sell"));
}
}
else
{
- mBrowserBox->addRow(strprintf(
- "@@buy|%s@@", _("Buy (?)")));
- mBrowserBox->addRow(strprintf(
- "@@sell|%s@@", _("Sell (?)")));
+ mBrowserBox->addRow("buy", _("Buy (?)"));
+ mBrowserBox->addRow("sell", _("Sell (?)"));
}
}
}
@@ -294,26 +269,23 @@ void PopupMenu::showPopup(int x, int y, Being *being)
case ActorSprite::NPC:
// NPCs can be talked to (single option, candidate for removal
// unless more options would be added)
- mBrowserBox->addRow(strprintf("@@talk|%s@@", _("Talk")));
-
- mBrowserBox->addRow(strprintf("@@buy|%s@@", _("Buy")));
- mBrowserBox->addRow(strprintf("@@sell|%s@@", _("Sell")));
+ mBrowserBox->addRow("talk", _("Talk"));
+ mBrowserBox->addRow("buy", _("Buy"));
+ mBrowserBox->addRow("sell", _("Sell"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@move|%s@@", _("Move")));
- mBrowserBox->addRow(strprintf("@@addcomment|%s@@",
- _("Add comment")));
+ mBrowserBox->addRow("move", _("Move"));
+ mBrowserBox->addRow("addcomment", _("Add comment"));
break;
case ActorSprite::MONSTER:
{
// Monsters can be attacked
- mBrowserBox->addRow(strprintf("@@attack|%s@@", _("Attack")));
+ mBrowserBox->addRow("attack", _("Attack"));
if (player_node->isGM())
{
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf(
- "@@admin-kick|%s@@", _("Kick")));
+ mBrowserBox->addRow("admin-kick", _("Kick"));
}
if (config.getBoolValue("enableAttackFilter"))
@@ -323,19 +295,17 @@ void PopupMenu::showPopup(int x, int y, Being *being)
|| actorSpriteManager->isInIgnoreAttackList(name)
|| actorSpriteManager->isInPriorityAttackList(name))
{
- mBrowserBox->addRow(strprintf("@@remove attack|%s@@",
- _("Remove from attack list")));
+ mBrowserBox->addRow("remove attack",
+ _("Remove from attack list"));
}
else
{
- mBrowserBox->addRow(strprintf(
- "@@add attack priority|%s@@",
- _("Add to priority attack list")));
- mBrowserBox->addRow(strprintf(
- "@@add attack|%s@@", _("Add to attack list")));
- mBrowserBox->addRow(strprintf(
- "@@add attack ignore|%s@@",
- _("Add to ignore list")));
+ mBrowserBox->addRow("add attack priority",
+ _("Add to priority attack list"));
+ mBrowserBox->addRow("add attack",
+ _("Add to attack list"));
+ mBrowserBox->addRow("add attack ignore",
+ _("Add to ignore list"));
}
}
}
@@ -348,10 +318,10 @@ void PopupMenu::showPopup(int x, int y, Being *being)
/* Other beings aren't interesting... */
return;
}
- mBrowserBox->addRow(strprintf("@@name|%s@@", _("Add name to chat")));
+ mBrowserBox->addRow("name", _("Add name to chat"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -360,7 +330,7 @@ void PopupMenu::showPopup(int x, int y, std::vector<Being*> &beings)
{
mBrowserBox->clearRows();
mBrowserBox->addRow("Players");
- std::vector<Being*>::iterator it, it_end;
+ std::vector<Being*>::const_iterator it, it_end;
for (it = beings.begin(), it_end = beings.end(); it != it_end; ++it)
{
Being *being = *it;
@@ -372,7 +342,7 @@ void PopupMenu::showPopup(int x, int y, std::vector<Being*> &beings)
}
}
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -390,42 +360,39 @@ void PopupMenu::showPlayerPopup(int x, int y, std::string nick)
mBrowserBox->addRow(name);
- mBrowserBox->addRow(strprintf("@@whisper|%s@@", _("Whisper")));
+ mBrowserBox->addRow("whisper", _("Whisper"));
mBrowserBox->addRow("##3---");
switch (player_relations.getRelation(name))
{
case PlayerRelation::NEUTRAL:
- mBrowserBox->addRow(strprintf("@@friend|%s@@", _("Be friend")));
- mBrowserBox->addRow(strprintf(
- "@@disregard|%s@@", _("Disregard")));
- mBrowserBox->addRow(strprintf("@@ignore|%s@@", _("Ignore")));
- mBrowserBox->addRow(strprintf("@@erase|%s@@", _("Erase")));
+ mBrowserBox->addRow("friend", _("Be friend"));
+ mBrowserBox->addRow("disregard", _("Disregard"));
+ mBrowserBox->addRow("ignore", _("Ignore"));
+ mBrowserBox->addRow("erase", _("Erase"));
break;
case PlayerRelation::FRIEND:
- mBrowserBox->addRow(strprintf("@@disregard|%s@@", _("Disregard")));
- mBrowserBox->addRow(strprintf("@@ignore|%s@@", _("Ignore")));
- mBrowserBox->addRow(strprintf("@@erase|%s@@", _("Erase")));
+ mBrowserBox->addRow("disregard", _("Disregard"));
+ mBrowserBox->addRow("ignore", _("Ignore"));
+ mBrowserBox->addRow("erase", _("Erase"));
break;
case PlayerRelation::DISREGARDED:
- mBrowserBox->addRow(strprintf("@@unignore|%s@@", _("Unignore")));
- mBrowserBox->addRow(strprintf(
- "@@ignore|%s@@", _("Completely ignore")));
- mBrowserBox->addRow(strprintf("@@erase|%s@@", _("Erase")));
+ mBrowserBox->addRow("unignore", _("Unignore"));
+ mBrowserBox->addRow("ignore", _("Completely ignore"));
+ mBrowserBox->addRow("erase", _("Erase"));
break;
case PlayerRelation::IGNORED:
- mBrowserBox->addRow(strprintf("@@unignore|%s@@", _("Unignore")));
- mBrowserBox->addRow(strprintf("@@erase|%s@@", _("Erase")));
+ mBrowserBox->addRow("unignore", _("Unignore"));
+ mBrowserBox->addRow("erase", _("Erase"));
break;
case PlayerRelation::ERASED:
- mBrowserBox->addRow(strprintf("@@unignore|%s@@", _("Unignore")));
- mBrowserBox->addRow(strprintf("@@disregard|%s@@", _("Disregard")));
- mBrowserBox->addRow(strprintf(
- "@@ignore|%s@@", _("Completely ignore")));
+ mBrowserBox->addRow("unignore", _("Unignore"));
+ mBrowserBox->addRow("disregard", _("Disregard"));
+ mBrowserBox->addRow("ignore", _("Completely ignore"));
break;
default:
@@ -433,18 +400,24 @@ void PopupMenu::showPlayerPopup(int x, int y, std::string nick)
}
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@follow|%s@@", _("Follow")));
- mBrowserBox->addRow(strprintf("@@imitation|%s@@", _("Imitation")));
- mBrowserBox->addRow(strprintf("@@addcomment|%s@@", _("Add comment")));
+ mBrowserBox->addRow("follow", _("Follow"));
+ mBrowserBox->addRow("imitation", _("Imitation"));
+ mBrowserBox->addRow("addcomment", _("Add comment"));
- if (player_node->isInParty() && player_node->getParty())
+ if (player_node->isInParty())
{
- PartyMember *member = player_node->getParty()->getMember(mNick);
- if (member)
+ Party *party = player_node->getParty();
+ if (party)
{
- mBrowserBox->addRow(strprintf(
- "@@kick party|%s@@", _("Kick from party")));
- mBrowserBox->addRow("##3---");
+ PartyMember *member = party->getMember(mNick);
+ if (member)
+ {
+ mBrowserBox->addRow("kick party", _("Kick from party"));
+ mBrowserBox->addRow("##3---");
+ PartyMember *o = party->getMember(player_node->getName());
+ if (o && member->getMap() == o->getMap())
+ mBrowserBox->addRow("move", _("Move"));
+ }
}
}
@@ -456,8 +429,7 @@ void PopupMenu::showPlayerPopup(int x, int y, std::string nick)
if (guild2->getServerGuild() || (guildManager
&& guildManager->havePower()))
{
- mBrowserBox->addRow(strprintf(
- "@@guild-kick|%s@@", _("Kick from guild")));
+ mBrowserBox->addRow("guild-kick", _("Kick from guild"));
}
if (guild2->getServerGuild())
{
@@ -470,8 +442,7 @@ void PopupMenu::showPlayerPopup(int x, int y, std::string nick)
if (guild2->getServerGuild() || (guildManager
&& guildManager->havePower()))
{
- mBrowserBox->addRow(strprintf(
- "@@guild|%s@@", _("Invite to guild")));
+ mBrowserBox->addRow("guild", _("Invite to guild"));
}
}
}
@@ -479,17 +450,16 @@ void PopupMenu::showPlayerPopup(int x, int y, std::string nick)
mBrowserBox->addRow("##3---");
if (player_relations.getDefault() & PlayerRelation::TRADE)
{
- mBrowserBox->addRow(strprintf("@@buy|%s@@", _("Buy (?)")));
- mBrowserBox->addRow(strprintf("@@sell|%s@@", _("Sell (?)")));
+ mBrowserBox->addRow("buy", _("Buy (?)"));
+ mBrowserBox->addRow("sell", _("Sell (?)"));
}
- mBrowserBox->addRow(strprintf("@@name|%s@@", _("Add name to chat")));
+ mBrowserBox->addRow("name", _("Add name to chat"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
-
}
void PopupMenu::showPopup(int x, int y, FloorItem *floorItem)
@@ -509,11 +479,11 @@ void PopupMenu::showPopup(int x, int y, FloorItem *floorItem)
name = info.getName();
mBrowserBox->addRow(name);
- mBrowserBox->addRow(strprintf("@@pickup|%s@@", _("Pick up")));
- mBrowserBox->addRow(strprintf("@@chat|%s@@", _("Add to chat")));
+ mBrowserBox->addRow("pickup", _("Pick up"));
+ mBrowserBox->addRow("chat", _("Add to chat"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -528,16 +498,16 @@ void PopupMenu::showPopup(int x, int y, MapItem *mapItem)
mBrowserBox->clearRows();
mBrowserBox->addRow(_("Map Item"));
- mBrowserBox->addRow(strprintf("@@rename map|%s@@", _("Rename")));
- mBrowserBox->addRow(strprintf("@@remove map|%s@@", _("Remove")));
+ mBrowserBox->addRow("rename map", _("Rename"));
+ mBrowserBox->addRow("remove map", _("Remove"));
if (player_node && player_node->isGM())
{
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@warp map|%s@@", _("Warp")));
+ mBrowserBox->addRow("warp map", _("Warp"));
}
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -547,11 +517,10 @@ void PopupMenu::showOutfitsPopup(int x, int y)
mBrowserBox->clearRows();
mBrowserBox->addRow(_("Outfits"));
- mBrowserBox->addRow(strprintf(
- "@@load old outfits|%s@@", _("Load old outfits")));
+ mBrowserBox->addRow("load old outfits", _("Load old outfits"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -565,12 +534,11 @@ void PopupMenu::showSpellPopup(int x, int y, TextCommand *cmd)
mSpell = cmd;
mBrowserBox->addRow(_("Spells"));
- mBrowserBox->addRow(strprintf(
- "@@load old spells|%s@@", _("Load old spells")));
- mBrowserBox->addRow(strprintf("@@edit spell|%s@@", _("Edit spell")));
+ mBrowserBox->addRow("load old spells", _("Load old spells"));
+ mBrowserBox->addRow("edit spell", _("Edit spell"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -585,46 +553,28 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab)
mBrowserBox->clearRows();
if (tab->getType() == ChatTab::TAB_WHISPER)
- mBrowserBox->addRow(strprintf("@@chat close|%s@@", _("Close")));
+ mBrowserBox->addRow("chat close", _("Close"));
- mBrowserBox->addRow(strprintf("@@chat clear|%s@@", _("Clear")));
+ mBrowserBox->addRow("chat clear", _("Clear"));
mBrowserBox->addRow("##3---");
if (tab->getAllowHighlight())
- {
- mBrowserBox->addRow(strprintf("@@disable highlight|%s@@",
- _("Disable highlight")));
- }
+ mBrowserBox->addRow("disable highlight", _("Disable highlight"));
else
- {
- mBrowserBox->addRow(strprintf("@@enable highlight|%s@@",
- _("Enable highlight")));
- }
+ mBrowserBox->addRow("enable highlight", _("Enable highlight"));
if (tab->getRemoveNames())
- {
- mBrowserBox->addRow(strprintf("@@dont remove name|%s@@",
- _("Don't remove name")));
- }
+ mBrowserBox->addRow("dont remove name", _("Don't remove name"));
else
- {
- mBrowserBox->addRow(strprintf("@@remove name|%s@@",
- _("Remove name")));
- }
+ mBrowserBox->addRow("remove name", _("Remove name"));
if (tab->getNoAway())
- {
- mBrowserBox->addRow(strprintf("@@enable away|%s@@",
- _("Enable away")));
- }
+ mBrowserBox->addRow("enable away", _("Enable away"));
else
- {
- mBrowserBox->addRow(strprintf("@@disable away|%s@@",
- _("Disable away")));
- }
+ mBrowserBox->addRow("disable away", _("Disable away"));
mBrowserBox->addRow("##3---");
if (tab->getType() == ChatTab::TAB_PARTY)
{
- mBrowserBox->addRow(strprintf("@@leave party|%s@@", _("Leave")));
+ mBrowserBox->addRow("leave party", _("Leave"));
mBrowserBox->addRow("##3---");
}
@@ -642,55 +592,44 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab)
mNick = being->getName();
mType = being->getType();
- mBrowserBox->addRow(strprintf("@@trade|%s@@", _("Trade")));
- mBrowserBox->addRow(strprintf("@@attack|%s@@", _("Attack")));
+ mBrowserBox->addRow("trade", _("Trade"));
+ mBrowserBox->addRow("attack", _("Attack"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@heal|%s@@", _("Heal")));
+ mBrowserBox->addRow("heal", _("Heal"));
mBrowserBox->addRow("##3---");
switch (player_relations.getRelation(name))
{
case PlayerRelation::NEUTRAL:
- mBrowserBox->addRow(strprintf(
- "@@friend|%s@@", _("Be friend")));
- mBrowserBox->addRow(strprintf(
- "@@disregard|%s@@", _("Disregard")));
- mBrowserBox->addRow(strprintf(
- "@@ignore|%s@@", _("Ignore")));
- mBrowserBox->addRow(strprintf("@@erase|%s@@", _("Erase")));
+ mBrowserBox->addRow("friend", _("Be friend"));
+ mBrowserBox->addRow("disregard", _("Disregard"));
+ mBrowserBox->addRow("ignore", _("Ignore"));
+ mBrowserBox->addRow("erase", _("Erase"));
break;
case PlayerRelation::FRIEND:
- mBrowserBox->addRow(strprintf(
- "@@disregard|%s@@", _("Disregard")));
- mBrowserBox->addRow(strprintf(
- "@@ignore|%s@@", _("Ignore")));
- mBrowserBox->addRow(strprintf("@@erase|%s@@", _("Erase")));
+ mBrowserBox->addRow("disregard", _("Disregard"));
+ mBrowserBox->addRow("ignore", _("Ignore"));
+ mBrowserBox->addRow("erase", _("Erase"));
break;
case PlayerRelation::DISREGARDED:
- mBrowserBox->addRow(strprintf(
- "@@unignore|%s@@", _("Unignore")));
- mBrowserBox->addRow(strprintf(
- "@@ignore|%s@@", _("Completely ignore")));
- mBrowserBox->addRow(strprintf("@@erase|%s@@", _("Erase")));
+ mBrowserBox->addRow("unignore", _("Unignore"));
+ mBrowserBox->addRow("ignore", _("Completely ignore"));
+ mBrowserBox->addRow("erase", _("Erase"));
break;
case PlayerRelation::IGNORED:
- mBrowserBox->addRow(strprintf(
- "@@unignore|%s@@", _("Unignore")));
- mBrowserBox->addRow(strprintf("@@erase|%s@@", _("Erase")));
+ mBrowserBox->addRow("unignore", _("Unignore"));
+ mBrowserBox->addRow("erase", _("Erase"));
break;
case PlayerRelation::ERASED:
- mBrowserBox->addRow(strprintf(
- "@@unignore|%s@@", _("Unignore")));
- mBrowserBox->addRow(strprintf(
- "@@disregard|%s@@", _("Disregard")));
- mBrowserBox->addRow(strprintf(
- "@@ignore|%s@@", _("Completely ignore")));
+ mBrowserBox->addRow("unignore", _("Unignore"));
+ mBrowserBox->addRow("disregard", _("Disregard"));
+ mBrowserBox->addRow("ignore", _("Completely ignore"));
break;
default:
@@ -698,13 +637,12 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab)
}
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@follow|%s@@", _("Follow")));
- mBrowserBox->addRow(strprintf("@@imitation|%s@@", _("Imitation")));
- mBrowserBox->addRow(strprintf("@@move|%s@@", _("Move")));
- mBrowserBox->addRow(strprintf("@@items|%s@@", _("Show Items")));
- mBrowserBox->addRow(strprintf("@@undress|%s@@", _("Undress")));
- mBrowserBox->addRow(strprintf(
- "@@addcomment|%s@@", _("Add comment")));
+ mBrowserBox->addRow("follow", _("Follow"));
+ mBrowserBox->addRow("imitation", _("Imitation"));
+ mBrowserBox->addRow("move", _("Move"));
+ mBrowserBox->addRow("items", _("Show Items"));
+ mBrowserBox->addRow("undress", _("Undress"));
+ mBrowserBox->addRow("addcomment", _("Add comment"));
if (player_relations.getDefault() & PlayerRelation::TRADE)
{
@@ -713,17 +651,14 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab)
{
if (being->isShopEnabled())
{
- mBrowserBox->addRow(strprintf(
- "@@buy|%s@@", _("Buy")));
- mBrowserBox->addRow(strprintf(
- "@@sell|%s@@", _("Sell")));
+ mBrowserBox->addRow("buy", _("Buy"));
+ mBrowserBox->addRow("sell", _("Sell"));
}
}
else
{
- mBrowserBox->addRow(strprintf("@@buy|%s@@", _("Buy (?)")));
- mBrowserBox->addRow(strprintf(
- "@@sell|%s@@", _("Sell (?)")));
+ mBrowserBox->addRow("buy", _("Buy (?)"));
+ mBrowserBox->addRow("sell", _("Sell (?)"));
}
}
@@ -735,13 +670,12 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab)
{
if (!player_node->getParty()->isMember(wTab->getNick()))
{
- mBrowserBox->addRow(
- strprintf("@@party|%s@@", _("Invite to party")));
+ mBrowserBox->addRow("party", _("Invite to party"));
}
else
{
- mBrowserBox->addRow(strprintf(
- "@@kick party|%s@@", _("Kick from party")));
+ mBrowserBox->addRow("kick party",
+ _("Kick from party"));
}
mBrowserBox->addRow("##3---");
}
@@ -772,8 +706,7 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab)
if (guild2->getServerGuild() || (guildManager
&& guildManager->havePower()))
{
- mBrowserBox->addRow(strprintf(
- "@@guild|%s@@", _("Invite to guild")));
+ mBrowserBox->addRow("guild", _("Invite to guild"));
}
}
}
@@ -782,12 +715,34 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab)
{
mNick = name;
mType = Being::PLAYER;
- mBrowserBox->addRow(strprintf(
- "@@addcomment|%s@@", _("Add comment")));
+
+ mBrowserBox->addRow("follow", _("Follow"));
+ mBrowserBox->addRow("imitation", _("Imitation"));
+
+ if (player_node->isInParty())
+ {
+ Party *party = player_node->getParty();
+ if (party)
+ {
+ PartyMember *m = party->getMember(mNick);
+ if (m)
+ mBrowserBox->addRow("move", _("Move"));
+ }
+ }
+ mBrowserBox->addRow("items", _("Show Items"));
+ mBrowserBox->addRow("undress", _("Undress"));
+ mBrowserBox->addRow("addcomment", _("Add comment"));
+
+ if (player_relations.getDefault() & PlayerRelation::TRADE)
+ {
+ mBrowserBox->addRow("##3---");
+ mBrowserBox->addRow("buy", _("Buy (?)"));
+ mBrowserBox->addRow("sell", _("Sell (?)"));
+ }
mBrowserBox->addRow("##3---");
}
}
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -804,14 +759,14 @@ void PopupMenu::showChangePos(int x, int y)
if (guild)
{
PositionsMap map = guild->getPositions();
- PositionsMap::iterator itr = map.begin();
- PositionsMap::iterator itr_end = map.end();
+ PositionsMap::const_iterator itr = map.begin();
+ PositionsMap::const_iterator itr_end = map.end();
for (; itr != itr_end; ++itr)
{
mBrowserBox->addRow(strprintf("@@guild-pos-%d|%s@@",
itr->first, itr->second.c_str()));
}
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -879,7 +834,7 @@ void PopupMenu::handleLink(const std::string &link,
}
else if (link == "heal" && being && being->getType() != Being::MONSTER)
{
- actorSpriteManager->heal(player_node, being);
+ actorSpriteManager->heal(being);
}
else if (link == "unignore" && being &&
being->getType() == ActorSprite::PLAYER)
@@ -1054,10 +1009,26 @@ void PopupMenu::handleLink(const std::string &link,
chatWindow->addInputText("/w \"" + mNick + "\" ");
}
}
- else if (link == "move" && being)
+ else if (link == "move" && !mNick.empty())
{
if (player_node)
- player_node->navigateTo(being->getTileX(), being->getTileY());
+ {
+ if (being)
+ {
+ player_node->navigateTo(being->getTileX(), being->getTileY());
+ }
+ else if (player_node->isInParty())
+ {
+ Party *party = player_node->getParty();
+ if (party)
+ {
+ PartyMember *m = party->getMember(mNick);
+ PartyMember *o = party->getMember(player_node->getName());
+ if (m && o && m->getMap() == o->getMap())
+ player_node->navigateTo(m->getX(), m->getY());
+ }
+ }
+ }
}
else if (link == "split" && mItem)
{
@@ -1591,12 +1562,15 @@ void PopupMenu::handleLink(const std::string &link,
}
else if (!link.compare(0, 7, "player_"))
{
- mBeingId = atoi(link.substr(7).c_str());
- Being *being = actorSpriteManager->findBeing(mBeingId);
- if (being)
+ if (actorSpriteManager)
{
- showPopup(getX(), getY(), being);
- return;
+ mBeingId = atoi(link.substr(7).c_str());
+ being = actorSpriteManager->findBeing(mBeingId);
+ if (being)
+ {
+ showPopup(getX(), getY(), being);
+ return;
+ }
}
}
else if (!link.compare(0, 12, "hide button_"))
@@ -1653,36 +1627,25 @@ void PopupMenu::showPopup(Window *parent, int x, int y, Item *item,
{
if (tradeWindow && tradeWindow->isVisible())
{
- mBrowserBox->addRow(strprintf("@@addtrade|%s@@",
- _("Add to trade")));
+ mBrowserBox->addRow("addtrade", _("Add to trade"));
if (cnt > 1)
{
if (cnt > 10)
- {
- mBrowserBox->addRow(strprintf("@@addtrade 10|%s@@",
- _("Add to trade 10")));
- }
- mBrowserBox->addRow(strprintf("@@addtrade half|%s@@",
- _("Add to trade half")));
- mBrowserBox->addRow(strprintf("@@addtrade all|%s@@",
- _("Add to trade all")));
+ mBrowserBox->addRow("addtrade 10", _("Add to trade 10"));
+ mBrowserBox->addRow("addtrade half", _("Add to trade half"));
+ mBrowserBox->addRow("addtrade all", _("Add to trade all"));
}
mBrowserBox->addRow("##3---");
}
if (InventoryWindow::isStorageActive())
{
- mBrowserBox->addRow(strprintf("@@store|%s@@", _("Store")));
+ mBrowserBox->addRow("store", _("Store"));
if (cnt > 1)
{
if (cnt > 10)
- {
- mBrowserBox->addRow(strprintf("@@store 10|%s@@",
- _("Store 10")));
- }
- mBrowserBox->addRow(strprintf("@@store half|%s@@",
- _("Store half")));
- mBrowserBox->addRow(strprintf("@@store all|%s@@",
- _("Store all")));
+ mBrowserBox->addRow("store 10", _("Store 10"));
+ mBrowserBox->addRow("store half", _("Store half"));
+ mBrowserBox->addRow("store all", _("Store all"));
}
mBrowserBox->addRow("##3---");
}
@@ -1690,48 +1653,45 @@ void PopupMenu::showPopup(Window *parent, int x, int y, Item *item,
if (item->isEquipment())
{
if (item->isEquipped())
- mBrowserBox->addRow(strprintf("@@use|%s@@", _("Unequip")));
+ mBrowserBox->addRow("use", _("Unequip"));
else
- mBrowserBox->addRow(strprintf("@@use|%s@@", _("Equip")));
+ mBrowserBox->addRow("use", _("Equip"));
}
else
- mBrowserBox->addRow(strprintf("@@use|%s@@", _("Use")));
+ {
+ mBrowserBox->addRow("use", _("Use"));
+ }
if (cnt > 1)
{
- mBrowserBox->addRow(strprintf("@@drop|%s@@", _("Drop...")));
- mBrowserBox->addRow(strprintf("@@drop all|%s@@", _("Drop all")));
+ mBrowserBox->addRow("drop", _("Drop..."));
+ mBrowserBox->addRow("drop all", _("Drop all"));
}
else
{
- mBrowserBox->addRow(strprintf("@@drop|%s@@", _("Drop")));
+ mBrowserBox->addRow("drop", _("Drop"));
}
if (Net::getInventoryHandler()->canSplit(item))
- mBrowserBox->addRow(strprintf("@@split|%s@@", _("Split")));
+ mBrowserBox->addRow("split", _("Split"));
}
// Assume in storage for now
// TODO: make this whole system more flexible, if needed
else
{
- mBrowserBox->addRow(strprintf("@@retrieve|%s@@", _("Retrieve")));
+ mBrowserBox->addRow("retrieve", _("Retrieve"));
if (cnt > 1)
{
if (cnt > 10)
- {
- mBrowserBox->addRow(strprintf("@@retrieve 10|%s@@",
- _("Retrieve 10")));
- }
- mBrowserBox->addRow(strprintf("@@retrieve half|%s@@",
- _("Retrieve half")));
- mBrowserBox->addRow(strprintf("@@retrieve all|%s@@",
- _("Retrieve all")));
+ mBrowserBox->addRow("retrieve 10", _("Retrieve 10"));
+ mBrowserBox->addRow("retrieve half", _("Retrieve half"));
+ mBrowserBox->addRow("retrieve all", _("Retrieve all"));
}
}
- mBrowserBox->addRow(strprintf("@@chat|%s@@", _("Add to chat")));
+ mBrowserBox->addRow("chat", _("Add to chat"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -1754,12 +1714,12 @@ void PopupMenu::showItemPopup(int x, int y, int itemId, unsigned char color)
mItemColor = color;
mBrowserBox->clearRows();
- mBrowserBox->addRow(strprintf("@@use|%s@@", _("Use")));
+ mBrowserBox->addRow("use", _("Use"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@load old item shortcuts|%s@@",
- _("Load old item shortcuts")));
+ mBrowserBox->addRow("load old item shortcuts",
+ _("Load old item shortcuts"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -1785,37 +1745,37 @@ void PopupMenu::showItemPopup(int x, int y, Item *item)
if (item->isEquipment())
{
if (item->isEquipped())
- mBrowserBox->addRow(strprintf("@@use|%s@@", _("Unequip")));
+ mBrowserBox->addRow("use", _("Unequip"));
else
- mBrowserBox->addRow(strprintf("@@use|%s@@", _("Equip")));
+ mBrowserBox->addRow("use", _("Equip"));
}
else
{
- mBrowserBox->addRow(strprintf("@@use|%s@@", _("Use")));
+ mBrowserBox->addRow("use", _("Use"));
}
if (item->getQuantity() > 1)
{
- mBrowserBox->addRow(strprintf("@@drop|%s@@", _("Drop...")));
- mBrowserBox->addRow(strprintf("@@drop all|%s@@", _("Drop all")));
+ mBrowserBox->addRow("drop", _("Drop..."));
+ mBrowserBox->addRow("drop all", _("Drop all"));
}
else
{
- mBrowserBox->addRow(strprintf("@@drop|%s@@", _("Drop")));
+ mBrowserBox->addRow("drop", _("Drop"));
}
if (Net::getInventoryHandler()->canSplit(item))
- mBrowserBox->addRow(strprintf("@@split|%s@@", _("Split")));
+ mBrowserBox->addRow("split", _("Split"));
if (InventoryWindow::isStorageActive())
- mBrowserBox->addRow(strprintf("@@store|%s@@", _("Store")));
- mBrowserBox->addRow(strprintf("@@chat|%s@@", _("Add to chat")));
+ mBrowserBox->addRow("store", _("Store"));
+ mBrowserBox->addRow("chat", _("Add to chat"));
mBrowserBox->addRow("##3---");
}
- mBrowserBox->addRow(strprintf("@@load old item shortcuts|%s@@",
- _("Load old item shortcuts")));
+ mBrowserBox->addRow("load old item shortcuts",
+ _("Load old item shortcuts"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -1830,35 +1790,37 @@ void PopupMenu::showDropPopup(int x, int y, Item *item)
if (item->isEquipment())
{
if (item->isEquipped())
- mBrowserBox->addRow(strprintf("@@use|%s@@", _("Unequip")));
+ mBrowserBox->addRow("use", _("Unequip"));
else
- mBrowserBox->addRow(strprintf("@@use|%s@@", _("Equip")));
+ mBrowserBox->addRow("use", _("Equip"));
}
else
- mBrowserBox->addRow(strprintf("@@use|%s@@", _("Use")));
+ {
+ mBrowserBox->addRow("use", _("Use"));
+ }
if (item->getQuantity() > 1)
{
- mBrowserBox->addRow(strprintf("@@drop|%s@@", _("Drop...")));
- mBrowserBox->addRow(strprintf("@@drop all|%s@@", _("Drop all")));
+ mBrowserBox->addRow("drop", _("Drop..."));
+ mBrowserBox->addRow("drop all", _("Drop all"));
}
else
{
- mBrowserBox->addRow(strprintf("@@drop|%s@@", _("Drop")));
+ mBrowserBox->addRow("drop", _("Drop"));
}
if (Net::getInventoryHandler()->canSplit(item))
- mBrowserBox->addRow(strprintf("@@split|%s@@", _("Split")));
+ mBrowserBox->addRow("split", _("Split"));
if (InventoryWindow::isStorageActive())
- mBrowserBox->addRow(strprintf("@@store|%s@@", _("Store")));
- mBrowserBox->addRow(strprintf("@@chat|%s@@", _("Add to chat")));
+ mBrowserBox->addRow("store", _("Store"));
+ mBrowserBox->addRow("chat", _("Add to chat"));
mBrowserBox->addRow("##3---");
}
- mBrowserBox->addRow(strprintf("@@load old drop shortcuts|%s@@",
- _("Load old drop shortcuts")));
+ mBrowserBox->addRow("load old drop shortcuts",
+ _("Load old drop shortcuts"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -1872,7 +1834,7 @@ void PopupMenu::showPopup(int x, int y, Button *button)
mBrowserBox->clearRows();
std::vector <gcn::Button*> names = windowMenu->getButtons();
- std::vector <gcn::Button*>::iterator it, it_end;
+ std::vector <gcn::Button*>::const_iterator it, it_end;
for (it = names.begin(), it_end = names.end(); it != it_end; ++ it)
{
Button *btn = dynamic_cast<Button*>(*it);
@@ -1893,7 +1855,7 @@ void PopupMenu::showPopup(int x, int y, Button *button)
}
}
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -1907,7 +1869,7 @@ void PopupMenu::showPopup(int x, int y, ProgressBar *b)
mBrowserBox->clearRows();
std::vector <ProgressBar*> bars = miniStatusWindow->getBars();
- std::vector <ProgressBar*>::iterator it, it_end;
+ std::vector <ProgressBar*>::const_iterator it, it_end;
for (it = bars.begin(), it_end = bars.end(); it != it_end; ++it)
{
ProgressBar *bar = *it;
@@ -1929,11 +1891,10 @@ void PopupMenu::showPopup(int x, int y, ProgressBar *b)
}
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@reset yellow|%s@@",
- _("Reset yellow bar")));
+ mBrowserBox->addRow("reset yellow", _("Reset yellow bar"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@bar to chat|%s@@", _("Copy to chat")));
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("bar to chat", _("Copy to chat"));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -1941,7 +1902,7 @@ void PopupMenu::showPopup(int x, int y, ProgressBar *b)
void PopupMenu::showAttackMonsterPopup(int x, int y, std::string name,
int type)
{
- if (!player_node)
+ if (!player_node || !actorSpriteManager)
return;
mNick = name;
@@ -1960,17 +1921,10 @@ void PopupMenu::showAttackMonsterPopup(int x, int y, std::string name,
int idx = actorSpriteManager->getAttackMobIndex(name);
int size = actorSpriteManager->getAttackMobsSize();
if (idx > 0)
- {
- mBrowserBox->addRow(strprintf(
- "@@attack moveup|%s@@", _("Move up")));
- }
+ mBrowserBox->addRow("attack moveup", _("Move up"));
if (idx + 1 < size)
- {
- mBrowserBox->addRow(strprintf(
- "@@attack movedown|%s@@", _("Move down")));
- }
- mBrowserBox->addRow(strprintf(
- "@@attack remove|%s@@", _("Remove")));
+ mBrowserBox->addRow("attack movedown", _("Move down"));
+ mBrowserBox->addRow("attack remove", _("Remove"));
break;
}
case MapItem::PRIORITY:
@@ -1978,29 +1932,21 @@ void PopupMenu::showAttackMonsterPopup(int x, int y, std::string name,
int idx = actorSpriteManager->getPriorityAttackMobIndex(name);
int size = actorSpriteManager->getPriorityAttackMobsSize();
if (idx > 0)
- {
- mBrowserBox->addRow(strprintf(
- "@@priority moveup|%s@@", _("Move up")));
- }
+ mBrowserBox->addRow("priority moveup", _("Move up"));
if (idx + 1 < size)
- {
- mBrowserBox->addRow(strprintf(
- "@@priority movedown|%s@@", _("Move down")));
- }
- mBrowserBox->addRow(strprintf(
- "@@attack remove|%s@@", _("Remove")));
+ mBrowserBox->addRow("priority movedown", _("Move down"));
+ mBrowserBox->addRow("attack remove", _("Remove"));
break;
}
case MapItem::IGNORE_:
- mBrowserBox->addRow(strprintf(
- "@@attack remove|%s@@", _("Remove")));
+ mBrowserBox->addRow("attack remove", _("Remove"));
break;
default:
break;
}
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -2017,10 +1963,10 @@ void PopupMenu::showUndressPopup(int x, int y, Being *being, Item *item)
mBrowserBox->clearRows();
- mBrowserBox->addRow(strprintf("@@undress item|%s@@", _("Undress")));
+ mBrowserBox->addRow("undress item", _("Undress"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
@@ -2029,10 +1975,10 @@ void PopupMenu::showUndressPopup(int x, int y, Being *being, Item *item)
void PopupMenu::showPopup(int x, int y)
{
setContentSize(mBrowserBox->getWidth() + 8, mBrowserBox->getHeight() + 8);
- if (graphics->mWidth < (x + getWidth() + 5))
- x = graphics->mWidth - getWidth();
- if (graphics->mHeight < (y + getHeight() + 5))
- y = graphics->mHeight - getHeight();
+ if (mainGraphics->mWidth < (x + getWidth() + 5))
+ x = mainGraphics->mWidth - getWidth();
+ if (mainGraphics->mHeight < (y + getHeight() + 5))
+ y = mainGraphics->mHeight - getHeight();
setPosition(x, y);
setVisible(true);
requestMoveToTop();
diff --git a/src/gui/quitdialog.cpp b/src/gui/quitdialog.cpp
index 04f43fb88..05691c2d2 100644
--- a/src/gui/quitdialog.cpp
+++ b/src/gui/quitdialog.cpp
@@ -44,7 +44,8 @@
#include "debug.h"
QuitDialog::QuitDialog(QuitDialog** pointerToMe):
- Window(_("Quit"), true, NULL), mMyPointer(pointerToMe)
+ Window(_("Quit"), true, 0, "quit.xml"),
+ mMyPointer(pointerToMe)
{
mForceQuit = new RadioButton(_("Quit"), "quitdialog");
mLogoutQuit = new RadioButton(_("Quit"), "quitdialog");
@@ -55,7 +56,7 @@ QuitDialog::QuitDialog(QuitDialog** pointerToMe):
addKeyListener(this);
- ContainerPlacer place = getPlacer(0, 0);
+ ContainerPlacer placer = getPlacer(0, 0);
const State state = Client::getState();
@@ -67,25 +68,25 @@ QuitDialog::QuitDialog(QuitDialog** pointerToMe):
state == STATE_UPDATE ||
state == STATE_LOAD_DATA)
{
- placeOption(place, mForceQuit);
+ placeOption(placer, mForceQuit);
}
else
{
// Only added if we are connected to an accountserver or gameserver
- placeOption(place, mLogoutQuit);
- placeOption(place, mSwitchAccountServer);
+ placeOption(placer, mLogoutQuit);
+ placeOption(placer, mSwitchAccountServer);
// Only added if we are connected to a gameserver
if (state == STATE_GAME)
- placeOption(place, mSwitchCharacter);
+ placeOption(placer, mSwitchCharacter);
}
mOptions[0]->setSelected(true);
- place = getPlacer(0, 1);
+ placer = getPlacer(0, 1);
- place(1, 0, mOkButton, 1);
- place(2, 0, mCancelButton, 1);
+ placer(1, 0, mOkButton, 1);
+ placer(2, 0, mCancelButton, 1);
reflowLayout(200, 0);
setLocationRelativeTo(getParent());
@@ -109,9 +110,9 @@ QuitDialog::~QuitDialog()
mSwitchCharacter = 0;
}
-void QuitDialog::placeOption(ContainerPlacer &place, gcn::RadioButton *option)
+void QuitDialog::placeOption(ContainerPlacer &placer, gcn::RadioButton *option)
{
- place(0, static_cast<int>(mOptions.size()), option, 3);
+ placer(0, static_cast<int>(mOptions.size()), option, 3);
mOptions.push_back(option);
}
@@ -178,7 +179,7 @@ void QuitDialog::keyPressed(gcn::KeyEvent &keyEvent)
if (dir != 0)
{
- std::vector<gcn::RadioButton*>::iterator it = mOptions.begin();
+ std::vector<gcn::RadioButton*>::const_iterator it = mOptions.begin();
for (; it < mOptions.end(); ++it)
{
diff --git a/src/gui/quitdialog.h b/src/gui/quitdialog.h
index 380a85528..5456be26b 100644
--- a/src/gui/quitdialog.h
+++ b/src/gui/quitdialog.h
@@ -61,7 +61,7 @@ class QuitDialog : public Window, public gcn::ActionListener,
void keyPressed(gcn::KeyEvent &keyEvent);
private:
- void placeOption(ContainerPlacer &place, gcn::RadioButton *option);
+ void placeOption(ContainerPlacer &placer, gcn::RadioButton *option);
std::vector<gcn::RadioButton*> mOptions;
gcn::RadioButton *mLogoutQuit;
diff --git a/src/gui/register.cpp b/src/gui/register.cpp
index 913c958f2..062275b80 100644
--- a/src/gui/register.cpp
+++ b/src/gui/register.cpp
@@ -62,34 +62,34 @@ void WrongDataNoticeListener::action(const gcn::ActionEvent &event)
mTarget->requestFocus();
}
-RegisterDialog::RegisterDialog(LoginData *loginData):
- Window(_("Register")),
+RegisterDialog::RegisterDialog(LoginData *data):
+ Window(_("Register"), false, 0, "register.xml"),
mEmailField(0),
mMaleButton(0),
mFemaleButton(0),
mWrongDataNoticeListener(new WrongDataNoticeListener),
- mLoginData(loginData)
+ mLoginData(data)
{
int optionalActions = Net::getLoginHandler()->supportedOptionalActions();
gcn::Label *userLabel = new Label(_("Name:"));
gcn::Label *passwordLabel = new Label(_("Password:"));
gcn::Label *confirmLabel = new Label(_("Confirm:"));
- mUserField = new TextField(loginData->username);
- mPasswordField = new PasswordField(loginData->password);
+ mUserField = new TextField(mLoginData->username);
+ mPasswordField = new PasswordField(mLoginData->password);
mConfirmField = new PasswordField;
mRegisterButton = new Button(_("Register"), "register", this);
mCancelButton = new Button(_("Cancel"), "cancel", this);
- ContainerPlacer place;
- place = getPlacer(0, 0);
- place(0, 0, userLabel);
- place(0, 1, passwordLabel);
- place(0, 2, confirmLabel);
+ ContainerPlacer placer;
+ placer = getPlacer(0, 0);
+ placer(0, 0, userLabel);
+ placer(0, 1, passwordLabel);
+ placer(0, 2, confirmLabel);
- place(1, 0, mUserField, 3).setPadding(2);
- place(1, 1, mPasswordField, 3).setPadding(2);
- place(1, 2, mConfirmField, 3).setPadding(2);
+ placer(1, 0, mUserField, 3).setPadding(2);
+ placer(1, 1, mPasswordField, 3).setPadding(2);
+ placer(1, 2, mConfirmField, 3).setPadding(2);
int row = 3;
@@ -97,8 +97,8 @@ RegisterDialog::RegisterDialog(LoginData *loginData):
{
mMaleButton = new RadioButton(_("Male"), "sex", true);
mFemaleButton = new RadioButton(_("Female"), "sex", false);
- place(1, row, mMaleButton);
- place(2, row, mFemaleButton);
+ placer(1, row, mMaleButton);
+ placer(2, row, mFemaleButton);
row++;
}
@@ -107,15 +107,15 @@ RegisterDialog::RegisterDialog(LoginData *loginData):
{
gcn::Label *emailLabel = new Label(_("Email:"));
mEmailField = new TextField;
- place(0, row, emailLabel);
- place(1, row, mEmailField, 3).setPadding(2);
+ placer(0, row, emailLabel);
+ placer(1, row, mEmailField, 3).setPadding(2);
row++;
}
- place = getPlacer(0, 2);
- place(1, 0, mRegisterButton);
- place(2, 0, mCancelButton);
+ placer = getPlacer(0, 2);
+ placer(1, 0, mRegisterButton);
+ placer(2, 0, mCancelButton);
reflowLayout(250, 0);
mUserField->addKeyListener(this);
@@ -161,7 +161,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event)
const std::string user = mUserField->getText();
logger->log("RegisterDialog::register Username is %s", user.c_str());
- std::string errorMessage;
+ std::string errorMsg;
int error = 0;
unsigned int minUser = Net::getLoginHandler()->getMinUserNameLength();
@@ -172,7 +172,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event)
if (user.length() < minUser)
{
// Name too short
- errorMessage = strprintf
+ errorMsg = strprintf
(_("The username needs to be at least %d characters long."),
minUser);
error = 1;
@@ -180,7 +180,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event)
else if (user.length() > maxUser - 1 )
{
// Name too long
- errorMessage = strprintf
+ errorMsg = strprintf
(_("The username needs to be less than %d characters long."),
maxUser);
error = 1;
@@ -188,7 +188,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event)
else if (mPasswordField->getText().length() < minPass)
{
// Pass too short
- errorMessage = strprintf
+ errorMsg = strprintf
(_("The password needs to be at least %d characters long."),
minPass);
error = 2;
@@ -196,7 +196,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event)
else if (mPasswordField->getText().length() > maxPass - 1 )
{
// Pass too long
- errorMessage = strprintf
+ errorMsg = strprintf
(_("The password needs to be less than %d characters long."),
maxPass);
error = 2;
@@ -204,7 +204,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event)
else if (mPasswordField->getText() != mConfirmField->getText())
{
// Password does not match with the confirmation one
- errorMessage = _("Passwords do not match.");
+ errorMsg = _("Passwords do not match.");
error = 2;
}
@@ -225,7 +225,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event)
mWrongDataNoticeListener->setTarget(this->mPasswordField);
}
- OkDialog *dlg = new OkDialog(_("Error"), errorMessage);
+ OkDialog *dlg = new OkDialog(_("Error"), errorMsg);
dlg->addActionListener(mWrongDataNoticeListener);
}
else
diff --git a/src/gui/sdlfont.cpp b/src/gui/sdlfont.cpp
index 8dd7f929d..b196ae4e4 100644
--- a/src/gui/sdlfont.cpp
+++ b/src/gui/sdlfont.cpp
@@ -48,8 +48,8 @@ char *strBuf;
class SDLTextChunk
{
public:
- SDLTextChunk(const std::string &text, const gcn::Color &color) :
- img(0), text(text), color(color)
+ SDLTextChunk(const std::string &text0, const gcn::Color &color0) :
+ img(0), text(text0), color(color0)
{
}
diff --git a/src/gui/selldialog.cpp b/src/gui/selldialog.cpp
index d9030e3fb..bbd0a71c1 100644
--- a/src/gui/selldialog.cpp
+++ b/src/gui/selldialog.cpp
@@ -50,14 +50,14 @@
SellDialog::DialogList SellDialog::instances;
SellDialog::SellDialog(int npcId):
- Window(_("Sell")),
+ Window(_("Sell"), false, 0, "sell.xml"),
mNpcId(npcId), mMaxItems(0), mAmountItems(0), mNick("")
{
init();
}
SellDialog::SellDialog(std::string nick):
- Window(_("Sell")),
+ Window(_("Sell"), false, 0, "sell.xml"),
mNpcId(-1), mMaxItems(0), mAmountItems(0), mNick(nick)
{
init();
@@ -107,18 +107,18 @@ void SellDialog::init()
mSlider->setActionEventId("slider");
mSlider->addActionListener(this);
- ContainerPlacer place;
- place = getPlacer(0, 0);
+ ContainerPlacer placer;
+ placer = getPlacer(0, 0);
- place(0, 0, mScrollArea, 8, 5).setPadding(3);
- place(0, 5, mDecreaseButton);
- place(1, 5, mSlider, 3);
- place(4, 5, mIncreaseButton);
- place(5, 5, mQuantityLabel, 2);
- place(7, 5, mAddMaxButton);
- place(0, 6, mMoneyLabel, 8);
- place(6, 7, mSellButton);
- place(7, 7, mQuitButton);
+ placer(0, 0, mScrollArea, 8, 5).setPadding(3);
+ placer(0, 5, mDecreaseButton);
+ placer(1, 5, mSlider, 3);
+ placer(4, 5, mIncreaseButton);
+ placer(5, 5, mQuantityLabel, 2);
+ placer(7, 5, mAddMaxButton);
+ placer(0, 6, mMoneyLabel, 8);
+ placer(6, 7, mSellButton);
+ placer(7, 7, mQuitButton);
Layout &layout = getLayout();
layout.setRowHeight(0, Layout::AUTO_SET);
@@ -346,8 +346,8 @@ void SellDialog::setVisible(bool visible)
void SellDialog::closeAll()
{
- DialogList::iterator it = instances.begin();
- DialogList::iterator it_end = instances.end();
+ DialogList::const_iterator it = instances.begin();
+ DialogList::const_iterator it_end = instances.end();
for (; it != it_end; ++it)
(*it)->close();
diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp
index 763c190d6..5a00d4a76 100644
--- a/src/gui/serverdialog.cpp
+++ b/src/gui/serverdialog.cpp
@@ -234,7 +234,7 @@ private:
ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir):
- Window(_("Choose Your Server")),
+ Window(_("Choose Your Server"), false, 0, "server.xml"),
mDir(dir),
// mDownloadStatus(DOWNLOADING_PREPARING),
mDownloadStatus(DOWNLOADING_UNKNOWN),
@@ -367,7 +367,7 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir):
loadServers(false);
- if (mServers.size() == 0)
+ if (mServers.empty())
downloadServerList();
}
@@ -548,7 +548,7 @@ void ServerDialog::mouseClicked(gcn::MouseEvent &mouseEvent)
void ServerDialog::logic()
{
{
- MutexLocker lock(&mMutex);
+ MutexLocker tempLock(&mMutex);
if (mDownloadStatus == DOWNLOADING_COMPLETE)
{
mDownloadStatus = DOWNLOADING_OVER;
@@ -636,11 +636,11 @@ void ServerDialog::loadServers(bool addNew)
return;
}
- int version = XML::getProperty(rootNode, "version", 0);
- if (version != 1)
+ int ver = XML::getProperty(rootNode, "version", 0);
+ if (ver != 1)
{
logger->log("Error: unsupported online server list version: %d",
- version);
+ ver);
return;
}
@@ -703,7 +703,7 @@ void ServerDialog::loadServers(bool addNew)
server.version.first = gui->getFont()->getWidth(version);
server.version.second = version;
- MutexLocker lock(&mMutex);
+ MutexLocker tempLock(&mMutex);
// Add the server to the local list if it's not already present
bool found = false;
for (unsigned int i = 0; i < mServers.size(); i++)
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp
index 76e3936c2..ae7a3109c 100644
--- a/src/gui/setup.cpp
+++ b/src/gui/setup.cpp
@@ -51,7 +51,7 @@
extern Window *statusWindow;
Setup::Setup():
- Window(_("Setup"))
+ Window(_("Setup"), false, 0, "setup.xml")
{
setCloseButton(true);
setResizable(true);
@@ -103,7 +103,8 @@ Setup::Setup():
mTabs.push_back(new Setup_Theme);
mTabs.push_back(new Setup_Other);
- for (std::list<SetupTab*>::iterator i = mTabs.begin(), i_end = mTabs.end();
+ for (std::list<SetupTab*>::const_iterator i = mTabs.begin(),
+ i_end = mTabs.end();
i != i_end; ++i)
{
SetupTab *tab = *i;
@@ -162,10 +163,11 @@ void Setup::action(const gcn::ActionEvent &event)
if (!statusWindow)
return;
- for (std::list<Window*>::iterator it = mWindowsToReset.begin();
+ for (std::list<Window*>::const_iterator it = mWindowsToReset.begin();
it != mWindowsToReset.end(); ++it)
{
- (*it)->resetToDefaultSize();
+ if (*it)
+ (*it)->resetToDefaultSize();
}
}
}
@@ -177,10 +179,11 @@ void Setup::setInGame(bool inGame)
void Setup::externalUpdate()
{
- for (std::list<SetupTab*>::iterator it = mTabs.begin();
+ for (std::list<SetupTab*>::const_iterator it = mTabs.begin();
it != mTabs.end(); ++it)
{
- (*it)->externalUpdated();
+ if (*it)
+ (*it)->externalUpdated();
}
}
@@ -195,4 +198,26 @@ void Setup::doCancel()
for_each(mTabs.begin(), mTabs.end(), std::mem_fun(&SetupTab::cancel));
}
+void Setup::activateTab(const std::string &name)
+{
+ std::string tmp = gettext(name.c_str());
+ mPanel->setSelectedTab(tmp);
+/*
+ for (std::list<SetupTab*>::const_iterator it = mTabs.begin();
+ it != mTabs.end(); ++it)
+ {
+ if (*it)
+ {
+ SetupTab *tab = *it;
+ logger->log("check tab: " + tab->getName());
+ if (tab->getName() == tmp)
+ {
+ mPanel->setSelectedTab(name);
+ return;
+ }
+ }
+ }
+*/
+}
+
Setup *setupWindow;
diff --git a/src/gui/setup.h b/src/gui/setup.h
index cdaf7db99..b499da4ee 100644
--- a/src/gui/setup.h
+++ b/src/gui/setup.h
@@ -73,6 +73,8 @@ class Setup : public Window, public gcn::ActionListener
void doCancel();
+ void activateTab(const std::string &name);
+
private:
std::list<SetupTab*> mTabs;
std::list<Window*> mWindowsToReset;
diff --git a/src/gui/setup_other.cpp b/src/gui/setup_other.cpp
index 1cad4c594..23fb5c086 100644
--- a/src/gui/setup_other.cpp
+++ b/src/gui/setup_other.cpp
@@ -84,6 +84,15 @@ Setup_Other::Setup_Other()
new SetupItemCheckBox(_("Draw hotkeys on map"), "", "drawHotKeys",
this, "drawHotKeysEvent");
+ new SetupItemCheckBox(_("Enable lazy scrolling"), "",
+ "enableLazyScrolling", this, "enableLazyScrollingEvent");
+
+ new SetupItemIntTextField(_("Scroll laziness"), "", "ScrollLaziness",
+ this, "ScrollLazinessEvent", 1, 160);
+
+ new SetupItemIntTextField(_("Scroll radius"), "", "ScrollRadius",
+ this, "ScrollRadiusEvent", 0, 32);
+
new SetupItemLabel(_("Moving"), "", this);
diff --git a/src/gui/setup_perfomance.cpp b/src/gui/setup_perfomance.cpp
index dfb119b91..dd634d1f3 100644
--- a/src/gui/setup_perfomance.cpp
+++ b/src/gui/setup_perfomance.cpp
@@ -58,9 +58,6 @@ Setup_Perfomance::Setup_Perfomance()
new SetupItemCheckBox(_("Auto adjust perfomance"), "",
"adjustPerfomance", this, "adjustPerfomanceEvent");
- new SetupItemCheckBox(_("Show beings transparency"), "",
- "beingopacity", this, "beingopacityEvent");
-
new SetupItemCheckBox(_("Hw acceleration"), "",
"hwaccel", this, "hwaccelEvent");
@@ -77,6 +74,9 @@ Setup_Perfomance::Setup_Perfomance()
"be very slow)"), "Can slow down drawing", "enableAlphaFix",
this, "enableAlphaFixEvent");
+ new SetupItemCheckBox(_("Show beings transparency"), "",
+ "beingopacity", this, "beingopacityEvent");
+
new SetupItemCheckBox(_("Enable reorder sprites."), "",
"enableReorderSprites", this, "enableReorderSpritesEvent");
diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp
index 03b485097..d3c1163dc 100644
--- a/src/gui/setup_video.cpp
+++ b/src/gui/setup_video.cpp
@@ -59,7 +59,7 @@
#include "debug.h"
-extern Graphics *graphics;
+extern Graphics *mainGraphics;
/**
* The list model for mode list.
@@ -157,8 +157,8 @@ ModeListModel::ModeListModel()
addCustomMode("1280x1024");
addCustomMode("1400x900");
addCustomMode("1500x990");
- addCustomMode(toString(graphics->mWidth) + "x"
- + toString(graphics->mHeight));
+ addCustomMode(toString(mainGraphics->mWidth) + "x"
+ + toString(mainGraphics->mHeight));
std::sort(mVideoModes.begin(), mVideoModes.end(), modeSorter);
mVideoModes.push_back("custom");
@@ -166,8 +166,8 @@ ModeListModel::ModeListModel()
void ModeListModel::addCustomMode(std::string mode)
{
- std::vector<std::string>::iterator it = mVideoModes.begin();
- std::vector<std::string>::iterator it_end = mVideoModes.end();
+ std::vector<std::string>::const_iterator it = mVideoModes.begin();
+ std::vector<std::string>::const_iterator it_end = mVideoModes.end();
while (it != it_end)
{
if (*it == mode)
@@ -179,7 +179,7 @@ void ModeListModel::addCustomMode(std::string mode)
int ModeListModel::getIndexOf(const std::string &widthXHeightMode)
{
- std::string currentMode = "";
+ std::string currentMode("");
for (int i = 0; i < getNumberOfElements(); i++)
{
currentMode = getElementAt(i);
@@ -348,8 +348,8 @@ Setup_Video::Setup_Video():
mFpsCheckBox->setSelected(mFps > 0);
// Pre-select the current video mode.
- std::string videoMode = toString(graphics->mWidth) + "x"
- + toString(graphics->mHeight);
+ std::string videoMode = toString(mainGraphics->mWidth) + "x"
+ + toString(mainGraphics->mHeight);
mModeList->setSelected(mModeListModel->getIndexOf(videoMode));
mModeList->setActionEventId("videomode");
@@ -473,25 +473,25 @@ void Setup_Video::apply()
if (!config.getIntValue("opengl"))
{
#endif
- if (!graphics->setFullscreen(fullscreen))
+ if (!mainGraphics->setFullscreen(fullscreen))
{
fullscreen = !fullscreen;
- if (!graphics->setFullscreen(fullscreen))
+ if (!mainGraphics->setFullscreen(fullscreen))
{
- std::stringstream errorMessage;
+ std::stringstream errorMsg;
if (fullscreen)
{
- errorMessage << _("Failed to switch to windowed mode "
- "and restoration of old mode also "
- "failed!") << std::endl;
+ errorMsg << _("Failed to switch to windowed mode "
+ "and restoration of old mode also "
+ "failed!") << std::endl;
}
else
{
- errorMessage << _("Failed to switch to fullscreen mode"
- " and restoration of old mode also "
- "failed!") << std::endl;
+ errorMsg << _("Failed to switch to fullscreen mode"
+ " and restoration of old mode also "
+ "failed!") << std::endl;
}
- logger->error(errorMessage.str());
+ logger->error(errorMsg.str());
}
}
#if defined(WIN32) || defined(__APPLE__)
@@ -564,11 +564,11 @@ void Setup_Video::cancel()
config.setValue("screen", mFullScreenEnabled);
// Set back to the current video mode.
- std::string videoMode = toString(graphics->mWidth) + "x"
- + toString(graphics->mHeight);
+ std::string videoMode = toString(mainGraphics->mWidth) + "x"
+ + toString(mainGraphics->mHeight);
mModeList->setSelected(mModeListModel->getIndexOf(videoMode));
- config.setValue("screenwidth", graphics->mWidth);
- config.setValue("screenheight", graphics->mHeight);
+ config.setValue("screenwidth", mainGraphics->mWidth);
+ config.setValue("screenheight", mainGraphics->mHeight);
config.setValue("customcursor", mCustomCursorEnabled);
config.setValue("particleeffects", mParticleEffectsEnabled);
@@ -612,9 +612,9 @@ void Setup_Video::action(const gcn::ActionEvent &event)
return;
// TODO: Find out why the drawing area doesn't resize without a restart.
- if (width != graphics->mWidth || height != graphics->mHeight)
+ if (width != mainGraphics->mWidth || height != mainGraphics->mHeight)
{
- if (width < graphics->mWidth || height < graphics->mHeight)
+ if (width < mainGraphics->mWidth || height < mainGraphics->mHeight)
new OkDialog(_("Screen Resolution Changed"),
_("Restart your client for the change to take effect.")
+ std::string("\n") +
@@ -625,8 +625,8 @@ void Setup_Video::action(const gcn::ActionEvent &event)
}
config.setValue("oldscreen", config.getBoolValue("screen"));
- config.setValue("oldscreenwidth", graphics->mWidth);
- config.setValue("oldscreenheight", graphics->mHeight);
+ config.setValue("oldscreenwidth", mainGraphics->mWidth);
+ config.setValue("oldscreenheight", mainGraphics->mHeight);
config.setValue("screenwidth", width);
config.setValue("screenheight", height);
}
@@ -687,12 +687,12 @@ void Setup_Video::action(const gcn::ActionEvent &event)
}
else if (id == "fpslimitcheckbox" || id == "fpslimitslider")
{
- int fps = static_cast<int>(mFpsSlider->getValue());
+ int tempFps = static_cast<int>(mFpsSlider->getValue());
if (id == "fpslimitcheckbox" && !mFpsSlider->isEnabled())
- fps = 60;
+ tempFps = 60;
else
- fps = fps > 0 ? fps : 60;
- mFps = mFpsCheckBox->isSelected() ? fps : 0;
+ tempFps = tempFps > 0 ? tempFps : 60;
+ mFps = mFpsCheckBox->isSelected() ? tempFps : 0;
const std::string text = mFps > 0 ? toString(mFps) : _("None");
mFpsLabel->setCaption(text);
@@ -701,9 +701,10 @@ void Setup_Video::action(const gcn::ActionEvent &event)
}
else if (id == "altfpslimitslider")
{
- int fps = static_cast<int>(mAltFpsSlider->getValue());
- fps = fps > 0 ? fps : static_cast<int>(mAltFpsSlider->getScaleStart());
- mAltFps = fps;
+ int tempFps = static_cast<int>(mAltFpsSlider->getValue());
+ tempFps = tempFps > 0 ? tempFps : static_cast<int>(
+ mAltFpsSlider->getScaleStart());
+ mAltFps = tempFps;
const std::string text = mAltFps > 0 ? toString(mAltFps) : _("None");
mAltFpsLabel->setCaption(_("Alt FPS limit: ") + text);
diff --git a/src/gui/shopwindow.cpp b/src/gui/shopwindow.cpp
index 9aaf88bf3..2215ce699 100644
--- a/src/gui/shopwindow.cpp
+++ b/src/gui/shopwindow.cpp
@@ -72,7 +72,7 @@ extern std::string tradePartnerName;
ShopWindow::DialogList ShopWindow::instances;
ShopWindow::ShopWindow():
- Window(_("Personal Shop")),
+ Window(_("Personal Shop"), false, 0, "shop.xml"),
mSelectedItem(-1),
mAnnonceTime(0),
mLastRequestTimeList(0),
@@ -127,28 +127,28 @@ ShopWindow::ShopWindow():
mAnnounceLinks = new CheckBox(_("Show links in announce"), false,
this, "link announce");
- ContainerPlacer place;
- place = getPlacer(0, 0);
-
- place(0, 0, mBuyLabel, 8).setPadding(3);
- place(8, 0, mSellLabel, 8).setPadding(3);
- place(0, 1, mBuyScrollArea, 8, 5).setPadding(3);
- place(8, 1, mSellScrollArea, 8, 5).setPadding(3);
- place(0, 6, mBuyAddButton);
- place(1, 6, mBuyDeleteButton);
- place(3, 6, mBuyAnnounceButton);
- place(8, 6, mSellAddButton);
- place(9, 6, mSellDeleteButton);
- place(11, 6, mSellAnnounceButton);
- place(0, 7, mAnnounceLinks, 8);
- place(15, 7, mCloseButton);
+ ContainerPlacer placer;
+ placer = getPlacer(0, 0);
+
+ placer(0, 0, mBuyLabel, 8).setPadding(3);
+ placer(8, 0, mSellLabel, 8).setPadding(3);
+ placer(0, 1, mBuyScrollArea, 8, 5).setPadding(3);
+ placer(8, 1, mSellScrollArea, 8, 5).setPadding(3);
+ placer(0, 6, mBuyAddButton);
+ placer(1, 6, mBuyDeleteButton);
+ placer(3, 6, mBuyAnnounceButton);
+ placer(8, 6, mSellAddButton);
+ placer(9, 6, mSellDeleteButton);
+ placer(11, 6, mSellAnnounceButton);
+ placer(0, 7, mAnnounceLinks, 8);
+ placer(15, 7, mCloseButton);
if (auctionManager && auctionManager->getEnableAuctionBot())
{
mBuyAuctionButton = new Button(_("Auction"), "auction buy", this);
mSellAuctionButton = new Button(_("Auction"), "auction sell", this);
- place(4, 6, mBuyAuctionButton);
- place(12, 6, mSellAuctionButton);
+ placer(4, 6, mBuyAuctionButton);
+ placer(12, 6, mSellAuctionButton);
}
else
{
@@ -395,7 +395,7 @@ void ShopWindow::saveList()
}
std::vector<ShopItem*> items = mBuyShopItems->items();
- std::vector<ShopItem*>::iterator it;
+ std::vector<ShopItem*>::const_iterator it;
for (it = items.begin(); it != items.end(); ++it)
{
ShopItem *item = *(it);
@@ -428,7 +428,7 @@ void ShopWindow::saveList()
}
}
- std::map<int, ShopItem*>::iterator mapIt;
+ std::map<int, ShopItem*>::const_iterator mapIt;
for (mapIt = mapItems.begin(); mapIt != mapItems.end(); ++mapIt)
{
ShopItem *buyItem = (*mapIt).second;
@@ -468,7 +468,7 @@ void ShopWindow::announce(ShopItems *list, int mode)
mSellAnnounceButton->setEnabled(false);
std::vector<ShopItem*> items = list->items();
- std::vector<ShopItem*>::iterator it;
+ std::vector<ShopItem*>::const_iterator it;
for (it = items.begin(); it != items.end(); ++it)
{
@@ -534,7 +534,7 @@ void ShopWindow::giveList(const std::string &nick, int mode)
return;
std::vector<ShopItem*> items = list->items();
- std::vector<ShopItem*>::iterator it;
+ std::vector<ShopItem*>::const_iterator it;
for (it = items.begin(); it != items.end(); ++it)
{
@@ -596,7 +596,7 @@ void ShopWindow::sendMessage(const std::string &nick,
if (config.getBoolValue("hideShopMessages"))
Net::getChatHandler()->privateMessage(nick, data);
else if (chatWindow)
- chatWindow->whisper(nick, data, BY_PLAYER);
+ chatWindow->addWhisper(nick, data, BY_PLAYER);
//here was true
}
@@ -780,7 +780,7 @@ bool ShopWindow::findShopItem(ShopItem *shopItem, int mode)
return false;
std::vector<ShopItem*> items;
- std::vector<ShopItem*>::iterator it;
+ std::vector<ShopItem*>::const_iterator it;
if (mode == SELL)
{
if (!mSellShopItems)
diff --git a/src/gui/shortcutwindow.cpp b/src/gui/shortcutwindow.cpp
index 0492afce0..df21488a5 100644
--- a/src/gui/shortcutwindow.cpp
+++ b/src/gui/shortcutwindow.cpp
@@ -52,7 +52,9 @@ class ShortcutTab : public Tab
ShortcutWindow::ShortcutWindow(const std::string &title,
ShortcutContainer *content,
- int width, int height)
+ std::string skinFile,
+ int width, int height) :
+ Window("Window", false, 0, skinFile)
{
setWindowName(title);
// no title presented, title bar is padding so window can be moved.
@@ -96,7 +98,9 @@ ShortcutWindow::ShortcutWindow(const std::string &title,
loadWindowState();
}
-ShortcutWindow::ShortcutWindow(const std::string &title, int width, int height)
+ShortcutWindow::ShortcutWindow(const std::string &title, std::string skinFile,
+ int width, int height) :
+ Window("Window", false, 0, skinFile)
{
setWindowName(title);
// no title presented, title bar is padding so window can be moved.
diff --git a/src/gui/shortcutwindow.h b/src/gui/shortcutwindow.h
index 4301b72d1..1c91835e8 100644
--- a/src/gui/shortcutwindow.h
+++ b/src/gui/shortcutwindow.h
@@ -41,9 +41,10 @@ class ShortcutWindow : public Window
* Constructor.
*/
ShortcutWindow(const std::string &title, ShortcutContainer *content,
+ std::string skinFile = "",
int width = 0, int height = 0);
- ShortcutWindow(const std::string &title,
+ ShortcutWindow(const std::string &title, std::string skinFile = "",
int width = 0, int height = 0);
/**
diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp
index bf87e804d..28dbca939 100644
--- a/src/gui/skilldialog.cpp
+++ b/src/gui/skilldialog.cpp
@@ -273,7 +273,7 @@ private:
};
SkillDialog::SkillDialog():
- Window(_("Skills"))
+ Window(_("Skills"), false, 0, "skills.xml")
{
setWindowName("Skills");
setCloseButton(true);
@@ -321,7 +321,7 @@ void SkillDialog::action(const gcn::ActionEvent &event)
std::string SkillDialog::update(int id)
{
- SkillMap::iterator i = mSkills.find(id);
+ SkillMap::const_iterator i = mSkills.find(id);
if (i != mSkills.end())
{
@@ -342,7 +342,9 @@ void SkillDialog::update()
PlayerInfo::getAttribute(SKILL_POINTS)));
mPointsLabel->adjustSize();
- for (SkillMap::iterator it = mSkills.begin(); it != mSkills.end(); ++it)
+ for (SkillMap::const_iterator it = mSkills.begin();
+ it != mSkills.end();
+ ++ it)
{
if ((*it).second && (*it).second->modifiable)
(*it).second->update();
@@ -467,7 +469,7 @@ void SkillDialog::loadSkills(const std::string &file)
bool SkillDialog::setModifiable(int id, bool modifiable)
{
- SkillMap::iterator it = mSkills.find(id);
+ SkillMap::const_iterator it = mSkills.find(id);
if (it != mSkills.end())
{
@@ -508,7 +510,9 @@ void SkillModel::updateVisibilities()
{
mVisibleSkills.clear();
- for (SkillList::iterator it = mSkills.begin(); it != mSkills.end(); ++it)
+ for (SkillList::const_iterator it = mSkills.begin();
+ it != mSkills.end();
+ ++ it)
{
if ((*it)->visible)
mVisibleSkills.push_back((*it));
diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp
index 749f26f85..a8d15f36c 100644
--- a/src/gui/socialwindow.cpp
+++ b/src/gui/socialwindow.cpp
@@ -232,7 +232,7 @@ public:
mScroll = 0;
}
- void action(const gcn::ActionEvent &event)
+ void action(const gcn::ActionEvent &event A_UNUSED)
{
/*
if (event.getId() == "do invite")
@@ -528,7 +528,7 @@ public:
return 0;
Avatar *ava = 0;
- std::vector<Avatar*>::iterator i = avatars->begin();
+ std::vector<Avatar*>::const_iterator i = avatars->begin();
while (i != avatars->end())
{
ava = (*i);
@@ -562,7 +562,7 @@ public:
if (!ava)
break;
- std::vector<std::string>::iterator i = names.begin();
+ std::vector<std::string>::const_iterator i = names.begin();
while (i != names.end())
{
if (ava->getName() == (*i) && (*i) != "")
@@ -584,7 +584,7 @@ public:
}
}
- std::vector<std::string>::iterator i = names.begin();
+ std::vector<std::string>::const_iterator i = names.begin();
while (i != names.end())
{
@@ -659,7 +659,7 @@ public:
std::vector<Avatar*> *avatars = mBeings->getMembers();
std::vector<MapItem*> portals = map->getPortals();
- std::vector<MapItem*>::iterator i = portals.begin();
+ std::vector<MapItem*>::const_iterator i = portals.begin();
SpecialLayer *specialLayer = map->getSpecialLayer();
std::vector<Avatar*>::iterator ia = avatars->begin();
@@ -752,7 +752,7 @@ public:
return;
Avatar *ava = 0;
- std::vector<Avatar*>::iterator i = avatars->begin();
+ std::vector<Avatar*>::const_iterator i = avatars->begin();
while (i != avatars->end())
{
ava = (*i);
@@ -786,7 +786,7 @@ public:
return 01;
Avatar *ava = 0;
- std::vector<Avatar*>::iterator i = avatars->begin();
+ std::vector<Avatar*>::const_iterator i = avatars->begin();
unsigned num = 0;
while (i != avatars->end())
{
@@ -962,7 +962,7 @@ public:
{
name = *i;
}
- Avatar *ava = new Avatar(name);
+ ava = new Avatar(name);
ava->setOnline(true);
ava->setLevel(level);
ava->setType(MapItem::PRIORITY);
@@ -997,7 +997,7 @@ public:
{
name = *i;
}
- Avatar *ava = new Avatar(name);
+ ava = new Avatar(name);
ava->setOnline(true);
ava->setLevel(level);
ava->setType(MapItem::ATTACK);
@@ -1032,7 +1032,7 @@ public:
{
name = *i;
}
- Avatar *ava = new Avatar(name);
+ ava = new Avatar(name);
ava->setOnline(false);
ava->setLevel(level);
ava->setType(MapItem::IGNORE_);
@@ -1114,7 +1114,7 @@ private:
};
SocialWindow::SocialWindow() :
- Window(_("Social")),
+ Window(_("Social"), false, 0, "social.xml"),
mGuildInvited(0),
mGuildAcceptDialog(0),
mPartyAcceptDialog(0),
diff --git a/src/gui/specialswindow.cpp b/src/gui/specialswindow.cpp
index 702c31718..c464b83b5 100644
--- a/src/gui/specialswindow.cpp
+++ b/src/gui/specialswindow.cpp
@@ -76,7 +76,7 @@ class SpecialEntry : public Container
};
SpecialsWindow::SpecialsWindow():
- Window(_("Specials"))
+ Window(_("Specials"), false, 0, "specials.xml")
{
setWindowName("Specials");
setCloseButton(true);
@@ -134,10 +134,11 @@ void SpecialsWindow::draw(gcn::Graphics *graphics)
unsigned int found = 0; // number of entries in specialData
// which match mEntries
- for (std::map<int, Special>::iterator i = specialData.begin();
+ for (std::map<int, Special>::const_iterator i = specialData.begin();
i != specialData.end(); ++i)
{
- std::map<int, SpecialEntry *>::iterator e = mEntries.find(i->first);
+ std::map<int, SpecialEntry *>::const_iterator
+ e = mEntries.find(i->first);
if (e == mEntries.end())
{
// found a new special - abort update and rebuild from scratch
diff --git a/src/gui/spellpopup.cpp b/src/gui/spellpopup.cpp
index a918e037d..c7d25e257 100644
--- a/src/gui/spellpopup.cpp
+++ b/src/gui/spellpopup.cpp
@@ -42,7 +42,7 @@
#include "debug.h"
SpellPopup::SpellPopup():
- Popup("SpellPopup")
+ Popup("SpellPopup", "spellpopup.xml")
{
// Item Name
mItemName = new Label;
@@ -80,14 +80,14 @@ void SpellPopup::view(int x, int y)
int posX = std::max(0, x - getWidth() / 2);
int posY = y + distance;
- if (posX + getWidth() > graphics->mWidth)
+ if (posX + getWidth() > mainGraphics->mWidth)
{
- if (graphics->mWidth > getWidth())
- posX = graphics->mWidth - getWidth();
+ if (mainGraphics->mWidth > getWidth())
+ posX = mainGraphics->mWidth - getWidth();
else
posX = 0;
}
- if (posY + getHeight() > graphics->mHeight)
+ if (posY + getHeight() > mainGraphics->mHeight)
{
if (y > getHeight() + distance)
posY = y - getHeight() - distance;
diff --git a/src/gui/statuspopup.cpp b/src/gui/statuspopup.cpp
index bb7a295ab..fee6450df 100644
--- a/src/gui/statuspopup.cpp
+++ b/src/gui/statuspopup.cpp
@@ -46,7 +46,7 @@
#include "debug.h"
StatusPopup::StatusPopup():
- Popup("StatusPopup")
+ Popup("StatusPopup", "statuspopup.xml")
{
const int fontHeight = getFont()->getHeight();
@@ -157,9 +157,8 @@ void StatusPopup::update()
minWidth += 16 + 2 * getPadding();
setWidth(minWidth);
- const int fontHeight = getFont()->getHeight();
-
- setHeight(24 + 8 + 14 * fontHeight + getPadding());
+ setHeight(mDisableGameModifiers->getY()
+ + mDisableGameModifiers->getHeight() + 2 * getPadding());
}
void StatusPopup::view(int x, int y)
@@ -169,9 +168,9 @@ void StatusPopup::view(int x, int y)
int posX = std::max(0, x - getWidth() / 2);
int posY = y + distance;
- if (posX + getWidth() > graphics->mWidth)
- posX = graphics->mWidth - getWidth();
- if (posY + getHeight() > graphics->mHeight)
+ if (posX + getWidth() > mainGraphics->mWidth)
+ posX = mainGraphics->mWidth - getWidth();
+ if (posY + getHeight() > mainGraphics->mHeight)
posY = y - getHeight() - distance;
update();
diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp
index d1fde2dd1..0cad8732a 100644
--- a/src/gui/statuswindow.cpp
+++ b/src/gui/statuswindow.cpp
@@ -123,7 +123,7 @@ class ChangeDisplay : public AttrDisplay, gcn::ActionListener
};
StatusWindow::StatusWindow():
- Window(player_node ? player_node->getName() : "?")
+ Window(player_node ? player_node->getName() : "?", false, 0, "status.xml")
{
listen(Mana::CHANNEL_ATTRIBUTES);
@@ -276,8 +276,8 @@ StatusWindow::StatusWindow():
mLvlLabel->adjustSize();
}
-void StatusWindow::event(Mana::Channels channel A_UNUSED,
- const Mana::Event &event)
+void StatusWindow::processEvent(Mana::Channels channel A_UNUSED,
+ const Mana::Event &event)
{
static bool blocked = false;
if (blocked)
@@ -311,7 +311,7 @@ void StatusWindow::event(Mana::Channels channel A_UNUSED,
mCharacterPointsLabel->adjustSize();
// Update all attributes
- for (Attrs::iterator it = mAttrs.begin();
+ for (Attrs::const_iterator it = mAttrs.begin();
it != mAttrs.end(); ++it)
{
if (it->second)
@@ -324,7 +324,7 @@ void StatusWindow::event(Mana::Channels channel A_UNUSED,
_("Correction points: %d"), event.getInt("newValue")));
mCorrectionPointsLabel->adjustSize();
// Update all attributes
- for (Attrs::iterator it = mAttrs.begin();
+ for (Attrs::const_iterator it = mAttrs.begin();
it != mAttrs.end(); ++it)
{
if (it->second)
@@ -392,7 +392,7 @@ void StatusWindow::event(Mana::Channels channel A_UNUSED,
else
{
updateMPBar(mMpBar, true);
- Attrs::iterator it = mAttrs.find(id);
+ Attrs::const_iterator it = mAttrs.find(id);
if (it != mAttrs.end() && it->second)
{
if (it->second)
@@ -404,7 +404,7 @@ void StatusWindow::event(Mana::Channels channel A_UNUSED,
void StatusWindow::setPointsNeeded(int id, int needed)
{
- Attrs::iterator it = mAttrs.find(id);
+ Attrs::const_iterator it = mAttrs.find(id);
if (it != mAttrs.end())
{
@@ -909,8 +909,8 @@ void StatusWindow::action(const gcn::ActionEvent &event)
if (event.getId() == "copy")
{
- Attrs::iterator it = mAttrs.begin();
- Attrs::iterator it_end = mAttrs.end();
+ Attrs::const_iterator it = mAttrs.begin();
+ Attrs::const_iterator it_end = mAttrs.end();
std::string str;
while (it != it_end)
{
diff --git a/src/gui/statuswindow.h b/src/gui/statuswindow.h
index 44d052004..fa957d059 100644
--- a/src/gui/statuswindow.h
+++ b/src/gui/statuswindow.h
@@ -58,7 +58,7 @@ class StatusWindow : public Window,
*/
StatusWindow();
- void event(Mana::Channels channel, const Mana::Event &event);
+ void processEvent(Mana::Channels channel, const Mana::Event &event);
void setPointsNeeded(int id, int needed);
diff --git a/src/gui/textcommandeditor.cpp b/src/gui/textcommandeditor.cpp
index 9d759c4a2..282f23ee1 100644
--- a/src/gui/textcommandeditor.cpp
+++ b/src/gui/textcommandeditor.cpp
@@ -61,11 +61,11 @@ class IconsModal : public gcn::ListModel
public:
IconsModal()
{
- std::map<int, ItemInfo*> info = ItemDB::getItemInfos();
+ std::map<int, ItemInfo*> items = ItemDB::getItemInfos();
std::list<std::string> tempStrings;
for (std::map<int, ItemInfo*>::const_iterator
- i = info.begin(), i_end = info.end();
+ i = items.begin(), i_end = items.end();
i != i_end; ++i)
{
if (i->first < 0)
@@ -165,7 +165,7 @@ public:
TextCommandEditor::TextCommandEditor(TextCommand *command):
- Window(_("Command Editor"))
+ Window(_("Command Editor"), false, 0, "commandeditor.xml")
{
int w = 350;
int h = 350;
@@ -254,34 +254,34 @@ TextCommandEditor::TextCommandEditor(TextCommand *command):
mSchoolDropDown->setSelected(command->getSchool() - MAGIC_START_ID);
mSchoolLvlField->setValue(command->getSchoolLvl());
- ContainerPlacer place;
- place = getPlacer(0, 0);
-
- place(0, 0, mIsMagic, 1);
- place(2, 0, mIsOther, 1);
- place(0, 1, mSymbolLabel, 2).setPadding(3);
- place(2, 1, mSymbolTextField, 3).setPadding(3);
- place(0, 2, mCommandLabel, 2).setPadding(3);
- place(2, 2, mCommandTextField, 4).setPadding(3);
- place(0, 3, mTypeLabel, 2).setPadding(3);
- place(2, 3, mTypeDropDown, 3).setPadding(3);
-
- place(0, 4, mIconLabel, 2).setPadding(3);
- place(2, 4, mIconDropDown, 3).setPadding(3);
-
- place(0, 5, mManaLabel, 2).setPadding(3);
- place(2, 5, mManaField, 3).setPadding(3);
- place(0, 6, mMagicLvlLabel, 2).setPadding(3);
- place(2, 6, mMagicLvlField, 3).setPadding(3);
-
- place(0, 7, mSchoolLabel, 2).setPadding(3);
- place(2, 7, mSchoolDropDown, 3).setPadding(3);
- place(0, 8, mSchoolLvlLabel, 2).setPadding(3);
- place(2, 8, mSchoolLvlField, 3).setPadding(3);
-
- place(0, 9, mSaveButton, 2).setPadding(3);
- place(2, 9, mCancelButton, 2).setPadding(3);
- place(4, 9, mDeleteButton, 2).setPadding(3);
+ ContainerPlacer placer;
+ placer = getPlacer(0, 0);
+
+ placer(0, 0, mIsMagic, 1);
+ placer(2, 0, mIsOther, 1);
+ placer(0, 1, mSymbolLabel, 2).setPadding(3);
+ placer(2, 1, mSymbolTextField, 3).setPadding(3);
+ placer(0, 2, mCommandLabel, 2).setPadding(3);
+ placer(2, 2, mCommandTextField, 4).setPadding(3);
+ placer(0, 3, mTypeLabel, 2).setPadding(3);
+ placer(2, 3, mTypeDropDown, 3).setPadding(3);
+
+ placer(0, 4, mIconLabel, 2).setPadding(3);
+ placer(2, 4, mIconDropDown, 3).setPadding(3);
+
+ placer(0, 5, mManaLabel, 2).setPadding(3);
+ placer(2, 5, mManaField, 3).setPadding(3);
+ placer(0, 6, mMagicLvlLabel, 2).setPadding(3);
+ placer(2, 6, mMagicLvlField, 3).setPadding(3);
+
+ placer(0, 7, mSchoolLabel, 2).setPadding(3);
+ placer(2, 7, mSchoolDropDown, 3).setPadding(3);
+ placer(0, 8, mSchoolLvlLabel, 2).setPadding(3);
+ placer(2, 8, mSchoolLvlField, 3).setPadding(3);
+
+ placer(0, 9, mSaveButton, 2).setPadding(3);
+ placer(2, 9, mCancelButton, 2).setPadding(3);
+ placer(4, 9, mDeleteButton, 2).setPadding(3);
setWidth(w);
setHeight(h);
diff --git a/src/gui/textdialog.cpp b/src/gui/textdialog.cpp
index a80e25260..c1539684c 100644
--- a/src/gui/textdialog.cpp
+++ b/src/gui/textdialog.cpp
@@ -39,7 +39,7 @@ int TextDialog::instances = 0;
TextDialog::TextDialog(const std::string &title, const std::string &msg,
Window *parent, bool isPassword):
- Window(title, true, parent),
+ Window(title, true, parent, "textdialog.xml"),
mTextField(0),
mPasswordField(0)
{
diff --git a/src/gui/textpopup.cpp b/src/gui/textpopup.cpp
index 1ff601154..15b2618da 100644
--- a/src/gui/textpopup.cpp
+++ b/src/gui/textpopup.cpp
@@ -41,7 +41,7 @@
#include "debug.h"
TextPopup::TextPopup():
- Popup("TextPopup")
+ Popup("TextPopup", "textpopup.xml")
{
const int fontHeight = getFont()->getHeight();
@@ -96,9 +96,9 @@ void TextPopup::show(int x, int y, const std::string &str1,
int posX = std::max(0, x - getWidth() / 2);
int posY = y + distance;
- if (posX + getWidth() > graphics->mWidth)
- posX = graphics->mWidth - getWidth();
- if (posY + getHeight() > graphics->mHeight)
+ if (posX + getWidth() > mainGraphics->mWidth)
+ posX = mainGraphics->mWidth - getWidth();
+ if (posY + getHeight() > mainGraphics->mHeight)
posY = y - getHeight() - distance;
setPosition(posX, posY);
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp
index 0607564f9..0a1a930a9 100644
--- a/src/gui/theme.cpp
+++ b/src/gui/theme.cpp
@@ -65,14 +65,15 @@ static void initDefaultThemePath()
Skin::Skin(ImageRect skin, Image *close, Image *stickyUp, Image *stickyDown,
const std::string &filePath,
- const std::string &name):
+ const std::string &name, int padding):
instances(0),
mFilePath(filePath),
mName(name),
mBorder(skin),
mCloseImage(close),
mStickyImageUp(stickyUp),
- mStickyImageDown(stickyDown)
+ mStickyImageDown(stickyDown),
+ mPadding(padding)
{}
Skin::~Skin()
@@ -216,6 +217,9 @@ Skin *Theme::load(const std::string &filename, const std::string &defaultPath)
Skin *skin = readSkin(filename);
if (!skin)
+ skin = readSkin("window.xml");
+
+ if (!skin)
{
// Try falling back on the defaultPath if this makes sense
if (filename != defaultPath)
@@ -240,6 +244,31 @@ Skin *Theme::load(const std::string &filename, const std::string &defaultPath)
return skin;
}
+void Theme::unload(Skin *skin)
+{
+ if (!skin)
+ return;
+ skin->instances --;
+/*
+ // unload theme if no instances
+ if (!skin->instances)
+ {
+ SkinIterator it = mSkins.begin();
+ SkinIterator it_end = mSkins.end();
+ while (it != it_end)
+ {
+ if (it->second == skin)
+ {
+ mSkins.erase(it);
+ break;
+ }
+ ++ it;
+ }
+ delete skin;
+ }
+*/
+}
+
void Theme::setMinimumOpacity(float minimumOpacity)
{
if (minimumOpacity > 1.0f)
@@ -293,6 +322,7 @@ Skin *Theme::readSkin(const std::string &filename)
Image *dBorders = Theme::getImageFromTheme(skinSetImage);
ImageRect border;
memset(&border, 0, sizeof(ImageRect));
+ int padding = 3;
// iterate <widget>'s
for_each_xml_child_node(widgetNode, rootNode)
@@ -304,140 +334,143 @@ Skin *Theme::readSkin(const std::string &filename)
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")
+ if (xmlStrEqual(partNode->name, BAD_CAST "part"))
{
- if (dBorders)
+ 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);
+ if (dBorders)
+ {
+ border.grid[0] = dBorders->getSubImage(
+ xPos, yPos, width, height);
+ }
+ else
+ {
+ border.grid[0] = 0;
+ }
}
- else
- {
- border.grid[0] = 0;
- }
- }
- else if (partType == "top-edge")
- {
- if (dBorders)
- {
- border.grid[1] = dBorders->getSubImage(
- xPos, yPos, width, height);
- }
- else
+ else if (partType == "top-edge")
{
- border.grid[1] = 0;
+ if (dBorders)
+ {
+ border.grid[1] = dBorders->getSubImage(
+ xPos, yPos, width, height);
+ }
+ else
+ {
+ border.grid[1] = 0;
+ }
}
- }
- else if (partType == "top-right-corner")
- {
- if (dBorders)
+ else if (partType == "top-right-corner")
{
- border.grid[2] = dBorders->getSubImage(
- xPos, yPos, width, height);
+ if (dBorders)
+ {
+ border.grid[2] = dBorders->getSubImage(
+ xPos, yPos, width, height);
+ }
+ else
+ {
+ border.grid[2] = 0;
+ }
}
- else
- {
- border.grid[2] = 0;
- }
- }
- // MIDDLE ROW
- else if (partType == "left-edge")
- {
- if (dBorders)
- {
- border.grid[3] = dBorders->getSubImage(
- xPos, yPos, width, height);
- }
- else
- {
- border.grid[3] = 0;
- }
- }
- else if (partType == "bg-quad")
- {
- if (dBorders)
+ // MIDDLE ROW
+ else if (partType == "left-edge")
{
- border.grid[4] = dBorders->getSubImage(
- xPos, yPos, width, height);
+ if (dBorders)
+ {
+ border.grid[3] = dBorders->getSubImage(
+ xPos, yPos, width, height);
+ }
+ else
+ {
+ border.grid[3] = 0;
+ }
}
- else
+ else if (partType == "bg-quad")
{
- border.grid[4] = 0;
+ if (dBorders)
+ {
+ border.grid[4] = dBorders->getSubImage(
+ xPos, yPos, width, height);
+ }
+ else
+ {
+ border.grid[4] = 0;
+ }
}
- }
- else if (partType == "right-edge")
- {
- if (dBorders)
- {
- border.grid[5] = dBorders->getSubImage(
- xPos, yPos, width, height);
- }
- else
+ else if (partType == "right-edge")
{
- border.grid[5] = 0;
+ if (dBorders)
+ {
+ border.grid[5] = dBorders->getSubImage(
+ xPos, yPos, width, height);
+ }
+ else
+ {
+ border.grid[5] = 0;
+ }
}
- }
- // BOTTOM ROW
- else if (partType == "bottom-left-corner")
- {
- if (dBorders)
- {
- border.grid[6] = dBorders->getSubImage(
- xPos, yPos, width, height);
- }
- else
- {
- border.grid[6] = 0;
- }
- }
- else if (partType == "bottom-edge")
- {
- if (dBorders)
+ // BOTTOM ROW
+ else if (partType == "bottom-left-corner")
{
- border.grid[7] = dBorders->getSubImage(
- xPos, yPos, width, height);
+ if (dBorders)
+ {
+ border.grid[6] = dBorders->getSubImage(
+ xPos, yPos, width, height);
+ }
+ else
+ {
+ border.grid[6] = 0;
+ }
}
- else
+ else if (partType == "bottom-edge")
{
- border.grid[7] = 0;
+ if (dBorders)
+ {
+ border.grid[7] = dBorders->getSubImage(
+ xPos, yPos, width, height);
+ }
+ else
+ {
+ border.grid[7] = 0;
+ }
}
- }
- else if (partType == "bottom-right-corner")
- {
- if (dBorders)
+ else if (partType == "bottom-right-corner")
{
- border.grid[8] = dBorders->getSubImage(
- xPos, yPos, width, height);
+ if (dBorders)
+ {
+ border.grid[8] = dBorders->getSubImage(
+ xPos, yPos, width, height);
+ }
+ else
+ {
+ border.grid[8] = 0;
+ }
}
+
else
{
- border.grid[8] = 0;
+ logger->log("Theme::readSkin(): Unknown part type "
+ "'%s'", partType.c_str());
}
}
-
- else
+ else if (xmlStrEqual(partNode->name, BAD_CAST "option"))
{
- logger->log("Theme::readSkin(): Unknown part type '%s'",
- partType.c_str());
+ const std::string name = XML::getProperty(
+ partNode, "name", "");
+ if (name == "padding")
+ padding = XML::getProperty(partNode, "value", 3);
}
}
}
@@ -467,7 +500,7 @@ Skin *Theme::readSkin(const std::string &filename)
}
Skin *skin = new Skin(border, closeImage, stickyImageUp, stickyImageDown,
- filename);
+ filename, "", padding);
skin->updateAlpha(mMinimumOpacity);
return skin;
}
diff --git a/src/gui/theme.h b/src/gui/theme.h
index fbc6f13da..92b2c8878 100644
--- a/src/gui/theme.h
+++ b/src/gui/theme.h
@@ -43,8 +43,8 @@ class Skin
{
public:
Skin(ImageRect skin, Image *close, Image *stickyUp, Image *stickyDown,
- const std::string &filePath,
- const std::string &name = "");
+ const std::string &filePath, const std::string &name = "",
+ int padding = 3);
~Skin();
@@ -95,6 +95,9 @@ class Skin
*/
void updateAlpha(float minimumOpacityAllowed = 0.0f);
+ int getPadding()
+ { return mPadding; }
+
int instances;
private:
@@ -104,6 +107,7 @@ class Skin
Image *mCloseImage; /**< Close Button Image */
Image *mStickyImageUp; /**< Sticky Button Image */
Image *mStickyImageDown; /**< Sticky Button Image */
+ int mPadding;
};
class Theme : public Palette, public ConfigListener
@@ -238,6 +242,8 @@ class Theme : public Palette, public ConfigListener
Skin *load(const std::string &filename,
const std::string &defaultPath = getThemePath());
+ void unload(Skin *skin);
+
/**
* Updates the alpha values of all of the skins.
*/
diff --git a/src/gui/tradewindow.cpp b/src/gui/tradewindow.cpp
index 3c19ee9c2..bd7e9bb1e 100644
--- a/src/gui/tradewindow.cpp
+++ b/src/gui/tradewindow.cpp
@@ -63,7 +63,7 @@
#define CAPTION_ACCEPTED _("Agreed. Waiting...")
TradeWindow::TradeWindow():
- Window(_("Trade: You")),
+ Window(_("Trade: You"), false, 0, "trade.xml"),
mMyInventory(new Inventory(Inventory::TRADE)),
mPartnerInventory(new Inventory(Inventory::TRADE)),
mStatus(PROPOSING),
@@ -118,14 +118,14 @@ TradeWindow::TradeWindow():
place(1, 0, mMoneyLabel);
place(0, 1, myScroll).setPadding(3);
place(1, 1, partnerScroll).setPadding(3);
- ContainerPlacer place;
- place = getPlacer(0, 0);
- place(0, 0, mMoneyLabel2);
- place(1, 0, mMoneyField, 2);
- place(3, 0, mMoneyChangeButton).setHAlign(LayoutCell::LEFT);
- place = getPlacer(0, 2);
- place(0, 0, mAddButton);
- place(1, 0, mOkButton);
+ ContainerPlacer placer;
+ placer = getPlacer(0, 0);
+ placer(0, 0, mMoneyLabel2);
+ placer(1, 0, mMoneyField, 2);
+ placer(3, 0, mMoneyChangeButton).setHAlign(LayoutCell::LEFT);
+ placer = getPlacer(0, 2);
+ placer(0, 0, mAddButton);
+ placer(1, 0, mOkButton);
Layout &layout = getLayout();
layout.extend(0, 2, 2, 1);
layout.setRowHeight(1, Layout::AUTO_SET);
@@ -443,10 +443,10 @@ void TradeWindow::initTrade(std::string nick)
bool TradeWindow::checkItem(Item *item)
{
- Item *tradeItem = mMyInventory->findItem(
+ Item *tItem = mMyInventory->findItem(
item->getId(), item->getColor());
- if (tradeItem && (tradeItem->getQuantity() > 1
+ if (tItem && (tItem->getQuantity() > 1
|| item->getQuantity() > 1))
{
if (localChatTab)
diff --git a/src/gui/unregisterdialog.cpp b/src/gui/unregisterdialog.cpp
index 568e0613e..cc5caca60 100644
--- a/src/gui/unregisterdialog.cpp
+++ b/src/gui/unregisterdialog.cpp
@@ -46,10 +46,10 @@
#include "debug.h"
-UnRegisterDialog::UnRegisterDialog(LoginData *loginData):
- Window(_("Unregister"), true),
+UnRegisterDialog::UnRegisterDialog(LoginData *data):
+ Window(_("Unregister"), true, 0, "unregister.xml"),
mWrongDataNoticeListener(new WrongDataNoticeListener),
- mLoginData(loginData)
+ mLoginData(data)
{
gcn::Label *userLabel = new Label(strprintf(_("Name: %s"), mLoginData->
username.c_str()));
@@ -108,7 +108,7 @@ void UnRegisterDialog::action(const gcn::ActionEvent &event)
logger->log("UnregisterDialog::unregistered, Username is %s",
username.c_str());
- std::stringstream errorMessage;
+ std::stringstream errorMsg;
bool error = false;
unsigned int min = Net::getLoginHandler()->getMinPasswordLength();
@@ -118,15 +118,15 @@ void UnRegisterDialog::action(const gcn::ActionEvent &event)
if (password.length() < min)
{
// Pass too short
- errorMessage << strprintf(_("The password needs to be at least %d "
- "characters long."), min);
+ errorMsg << strprintf(_("The password needs to be at least %d "
+ "characters long."), min);
error = true;
}
else if (password.length() > max - 1)
{
// Pass too long
- errorMessage << strprintf(_("The password needs to be less than "
- "%d characters long."), max);
+ errorMsg << strprintf(_("The password needs to be less than "
+ "%d characters long."), max);
error = true;
}
@@ -134,7 +134,7 @@ void UnRegisterDialog::action(const gcn::ActionEvent &event)
{
mWrongDataNoticeListener->setTarget(this->mPasswordField);
- OkDialog *dlg = new OkDialog(_("Error"), errorMessage.str());
+ OkDialog *dlg = new OkDialog(_("Error"), errorMsg.str());
dlg->addActionListener(mWrongDataNoticeListener);
}
else
diff --git a/src/gui/updaterwindow.cpp b/src/gui/updaterwindow.cpp
index 4ba1c9179..2efe82199 100644
--- a/src/gui/updaterwindow.cpp
+++ b/src/gui/updaterwindow.cpp
@@ -135,7 +135,7 @@ UpdaterWindow::UpdaterWindow(const std::string &updateHost,
const std::string &updatesDir,
bool applyUpdates,
int updateType):
- Window(_("Updating...")),
+ Window(_("Updating..."), false, 0, "update.xml"),
mDownloadStatus(UPDATE_NEWS),
mUpdateHost(updateHost),
mUpdatesDir(updatesDir),
@@ -165,14 +165,14 @@ UpdaterWindow::UpdaterWindow(const std::string &updateHost,
mBrowserBox->setOpaque(false);
mPlayButton->setEnabled(false);
- ContainerPlacer place;
- place = getPlacer(0, 0);
+ ContainerPlacer placer;
+ placer = getPlacer(0, 0);
- place(0, 0, mScrollArea, 5, 3).setPadding(3);
- place(0, 3, mLabel, 5);
- place(0, 4, mProgressBar, 5);
- place(3, 5, mCancelButton);
- place(4, 5, mPlayButton);
+ placer(0, 0, mScrollArea, 5, 3).setPadding(3);
+ placer(0, 3, mLabel, 5);
+ placer(0, 4, mProgressBar, 5);
+ placer(3, 5, mCancelButton);
+ placer(4, 5, mPlayButton);
reflowLayout(450, 400);
diff --git a/src/gui/userpalette.cpp b/src/gui/userpalette.cpp
index eac9559ef..62fd03c70 100644
--- a/src/gui/userpalette.cpp
+++ b/src/gui/userpalette.cpp
@@ -172,7 +172,7 @@ UserPalette::UserPalette():
UserPalette::~UserPalette()
{
- for (Colors::iterator col = mColors.begin(),
+ for (Colors::const_iterator col = mColors.begin(),
colEnd = mColors.end(); col != colEnd; ++col)
{
const std::string &configName = ColorTypeNames[col->type];
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index b6e09c011..461dd581d 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -80,11 +80,13 @@ Viewport::Viewport():
mScrollCenterOffsetY = config.getIntValue("ScrollCenterOffsetY");
mShowBeingPopup = config.getBoolValue("showBeingPopup");
mSelfMouseHeal = config.getBoolValue("selfMouseHeal");
+ mEnableLazyScrolling = config.getBoolValue("enableLazyScrolling");
config.addListener("ScrollLaziness", this);
config.addListener("ScrollRadius", this);
config.addListener("showBeingPopup", this);
config.addListener("selfMouseHeal", this);
+ config.addListener("enableLazyScrolling", this);
mPopupMenu = new PopupMenu;
mBeingPopup = new BeingPopup;
@@ -99,6 +101,7 @@ Viewport::~Viewport()
config.removeListener("ScrollRadius", this);
config.removeListener("showBeingPopup", this);
config.removeListener("selfMouseHeal", this);
+ config.removeListener("enableLazyScrolling", this);
delete mPopupMenu;
mPopupMenu = 0;
@@ -150,59 +153,67 @@ void Viewport::draw(gcn::Graphics *gcnGraphics)
int cnt = 0;
- // Apply lazy scrolling
- while (lastTick < tick_time && cnt < 32)
+ if (mEnableLazyScrolling)
{
- if (player_x > static_cast<int>(mPixelViewX) + mScrollRadius)
+ // Apply lazy scrolling
+ while (lastTick < tick_time && cnt < 32)
{
- mPixelViewX += static_cast<float>(player_x
- - static_cast<int>(mPixelViewX) - mScrollRadius) /
+ if (player_x > static_cast<int>(mPixelViewX) + mScrollRadius)
+ {
+ mPixelViewX += static_cast<float>(player_x
+ - static_cast<int>(mPixelViewX) - mScrollRadius) /
+ static_cast<float>(mScrollLaziness);
+ }
+ if (player_x < static_cast<int>(mPixelViewX) - mScrollRadius)
+ {
+ mPixelViewX += static_cast<float>(player_x
+ - static_cast<int>(mPixelViewX) + mScrollRadius) /
+ static_cast<float>(mScrollLaziness);
+ }
+ if (player_y > static_cast<int>(mPixelViewY) + mScrollRadius)
+ {
+ mPixelViewY += static_cast<float>(player_y
+ - static_cast<int>(mPixelViewY) - mScrollRadius) /
static_cast<float>(mScrollLaziness);
- }
- if (player_x < static_cast<int>(mPixelViewX) - mScrollRadius)
- {
- mPixelViewX += static_cast<float>(player_x
- - static_cast<int>(mPixelViewX) + mScrollRadius) /
+ }
+ if (player_y < static_cast<int>(mPixelViewY) - mScrollRadius)
+ {
+ mPixelViewY += static_cast<float>(player_y
+ - static_cast<int>(mPixelViewY) + mScrollRadius) /
static_cast<float>(mScrollLaziness);
+ }
+ lastTick ++;
+ cnt ++;
}
- if (player_y > static_cast<int>(mPixelViewY) + mScrollRadius)
- {
- mPixelViewY += static_cast<float>(player_y
- - static_cast<int>(mPixelViewY) - mScrollRadius) /
- static_cast<float>(mScrollLaziness);
- }
- if (player_y < static_cast<int>(mPixelViewY) - mScrollRadius)
- {
- mPixelViewY += static_cast<float>(player_y
- - static_cast<int>(mPixelViewY) + mScrollRadius) /
- static_cast<float>(mScrollLaziness);
- }
- lastTick ++;
- cnt ++;
- }
- // Auto center when player is off screen
- if (cnt > 30 || player_x - static_cast<int>(mPixelViewX)
- > graphics->mWidth / 2 || static_cast<int>(mPixelViewX)
- - player_x > graphics->mWidth / 2 || static_cast<int>(mPixelViewY)
- - player_y > graphics->getHeight() / 2 || player_y
- - static_cast<int>(mPixelViewY) > graphics->getHeight() / 2)
- {
- if (player_x <= 0 || player_y <= 0)
+ // Auto center when player is off screen
+ if (cnt > 30 || player_x - static_cast<int>(mPixelViewX)
+ > graphics->mWidth / 2 || static_cast<int>(mPixelViewX)
+ - player_x > graphics->mWidth / 2 || static_cast<int>(mPixelViewY)
+ - player_y > graphics->getHeight() / 2 || player_y
+ - static_cast<int>(mPixelViewY) > graphics->getHeight() / 2)
{
- if (debugChatTab)
- debugChatTab->chatLog("incorrect player position!");
- logger->log("incorrect player position: %d, %d, %d, %d",
- player_x, player_y, (int)mPixelViewX, (int)mPixelViewY);
- if (player_node)
+ if (player_x <= 0 || player_y <= 0)
{
- logger->log("tile position: %d, %d",
- player_node->getTileX(), player_node->getTileY());
+ if (debugChatTab)
+ debugChatTab->chatLog("incorrect player position!");
+ logger->log("incorrect player position: %d, %d, %d, %d",
+ player_x, player_y, (int)mPixelViewX, (int)mPixelViewY);
+ if (player_node)
+ {
+ logger->log("tile position: %d, %d",
+ player_node->getTileX(), player_node->getTileY());
+ }
}
+ mPixelViewX = static_cast<float>(player_x);
+ mPixelViewY = static_cast<float>(player_y);
}
+ }
+ else
+ {
mPixelViewX = static_cast<float>(player_x);
mPixelViewY = static_cast<float>(player_y);
- };
+ }
// Don't move camera so that the end of the map is on screen
const int viewXmax =
@@ -478,7 +489,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
if (actorSpriteManager)
{
if (player_node != mHoverBeing || mSelfMouseHeal)
- actorSpriteManager->heal(player_node, mHoverBeing);
+ actorSpriteManager->heal(mHoverBeing);
}
}
else if (player_node->withinAttackRange(mHoverBeing) ||
@@ -693,9 +704,16 @@ void Viewport::closePopupMenu()
void Viewport::optionChanged(const std::string &name A_UNUSED)
{
- mScrollLaziness = config.getIntValue("ScrollLaziness");
- mScrollRadius = config.getIntValue("ScrollRadius");
- mShowBeingPopup = config.getBoolValue("showBeingPopup");
+ if (name == "ScrollLaziness")
+ mScrollLaziness = config.getIntValue("ScrollLaziness");
+ else if (name == "ScrollRadius")
+ mScrollRadius = config.getIntValue("ScrollRadius");
+ else if (name == "showBeingPopup")
+ mShowBeingPopup = config.getBoolValue("showBeingPopup");
+ else if (name == "selfMouseHeal")
+ mSelfMouseHeal = config.getBoolValue("selfMouseHeal");
+ else if (name == "enableLazyScrolling")
+ mEnableLazyScrolling = config.getBoolValue("enableLazyScrolling");
}
void Viewport::mouseMoved(gcn::MouseEvent &event A_UNUSED)
diff --git a/src/gui/viewport.h b/src/gui/viewport.h
index 50c81aff4..8823928a3 100644
--- a/src/gui/viewport.h
+++ b/src/gui/viewport.h
@@ -286,6 +286,7 @@ class Viewport : public WindowContainer, public gcn::MouseListener,
int mScrollLaziness;
bool mShowBeingPopup;
bool mSelfMouseHeal;
+ bool mEnableLazyScrolling;
int mScrollCenterOffsetX;
int mScrollCenterOffsetY;
int mMouseX; /**< Current mouse position in pixels. */
diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp
index 1e9f686e4..e1f69c2d7 100644
--- a/src/gui/whoisonline.cpp
+++ b/src/gui/whoisonline.cpp
@@ -78,7 +78,7 @@ bool stringCompare(const std::string &left, const std::string &right )
}
WhoIsOnline::WhoIsOnline():
- Window(_("Who Is Online - Updating")),
+ Window(_("Who Is Online - Updating"), false, 0, "whoisonline.xml"),
mThread(NULL),
mDownloadStatus(UPDATE_LIST),
mDownloadComplete(true),
@@ -95,9 +95,11 @@ WhoIsOnline::WhoIsOnline():
const int w = 200;
setDefaultSize(w, h, ImageRect::CENTER);
// setContentSize(w, h);
+ setVisible(false);
setCloseButton(true);
setResizable(true);
setStickyButtonLock(true);
+ setSaveVisible(true);
mUpdateButton = new Button(_("Update"), "update", this);
mUpdateButton->setEnabled(false);
@@ -563,4 +565,4 @@ void WhoIsOnline::optionChanged(const std::string &name)
{
if (name == "updateOnlineList")
mUpdateOnlineList = config.getBoolValue("updateOnlineList");
-} \ No newline at end of file
+}
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp
index d4764cba5..18dc48417 100644
--- a/src/gui/widgets/avatarlistbox.cpp
+++ b/src/gui/widgets/avatarlistbox.cpp
@@ -330,7 +330,7 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event)
Being* being = actorSpriteManager->findBeingByName(ava->getName(),
Being::PLAYER);
if (being)
- actorSpriteManager->heal(player_node, being);
+ actorSpriteManager->heal(being);
}
else
{
@@ -373,7 +373,7 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event)
default:
{
Map *map = viewport->getMap();
- Avatar *ava = model->getAvatarAt(selected);
+ ava = model->getAvatarAt(selected);
if (map && ava)
{
MapItem *mapItem = map->findPortalXY(
@@ -384,7 +384,6 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event)
}
}
}
-
else if (event.getButton() == gcn::MouseEvent::MIDDLE)
{
if (ava->getType() == AVATAR_PLAYER && chatWindow)
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index 65a25363d..1419e213c 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -210,23 +210,23 @@ void BrowserBox::addRow(const std::string &row, bool atTop)
for (TextRowIterator i = mTextRows.begin(); i != mTextRows.end(); ++i)
{
- std::string row = *i;
- for (unsigned int j = 0; j < row.size(); j++)
+ std::string tempRow = *i;
+ for (unsigned int j = 0; j < tempRow.size(); j++)
{
- std::string character = row.substr(j, 1);
+ std::string character = tempRow.substr(j, 1);
x += font->getWidth(character);
nextChar = j + 1;
// Wraping between words (at blank spaces)
- if ((nextChar < row.size()) && (row.at(nextChar) == ' '))
+ if (nextChar < tempRow.size() && tempRow.at(nextChar) == ' ')
{
int nextSpacePos = static_cast<int>(
- row.find(" ", (nextChar + 1)));
+ tempRow.find(" ", (nextChar + 1)));
if (nextSpacePos <= 0)
- nextSpacePos = static_cast<int>(row.size()) - 1;
+ nextSpacePos = static_cast<int>(tempRow.size()) - 1;
unsigned nextWordWidth = font->getWidth(
- row.substr(nextChar,
+ tempRow.substr(nextChar,
(nextSpacePos - nextChar)));
if ((x + nextWordWidth + 10) > (unsigned)getWidth())
@@ -256,6 +256,11 @@ void BrowserBox::addRow(const std::string &row, bool atTop)
updateHeight();
}
+void BrowserBox::addRow(const std::string &cmd, char *text)
+{
+ addRow(strprintf("@@%s|%s@@", cmd.c_str(), text));
+}
+
void BrowserBox::addImage(const std::string &path)
{
if (!mEnableImages)
diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h
index cd69ce56f..e86f0288e 100644
--- a/src/gui/widgets/browserbox.h
+++ b/src/gui/widgets/browserbox.h
@@ -112,6 +112,11 @@ class BrowserBox : public gcn::Widget,
*/
void addRow(const std::string &row, bool atTop = false);
+ /**
+ * Adds a menu line to the browser.
+ */
+ void addRow(const std::string &cmd, char *text);
+
void addImage(const std::string &path);
/**
diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp
index 81c0d277f..485e96e74 100644
--- a/src/gui/widgets/chattab.cpp
+++ b/src/gui/widgets/chattab.cpp
@@ -337,7 +337,7 @@ void ChatTab::chatInput(const std::string &message)
start = msg.find('[', start + 1);
}
- std::string temp = "";
+ std::string temp("");
if (start + 1 < msg.length() && end < msg.length()
&& end > start + 1)
{
@@ -439,7 +439,7 @@ void ChatTab::loadFromLogFile(std::string name)
{
std::list<std::string> list;
chatLogger->loadLast(name, list, 5);
- std::list<std::string>::iterator i = list.begin();
+ std::list<std::string>::const_iterator i = list.begin();
while (i != list.end())
{
std::string line = "##9" + *i;
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index f01d3fb55..687d7dc6d 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -46,7 +46,8 @@ Image *DropDown::buttons[2][2];
ImageRect DropDown::skin;
float DropDown::mAlpha = 1.0;
-DropDown::DropDown(gcn::ListModel *listModel):
+DropDown::DropDown(gcn::ListModel *listModel, gcn::ActionListener* listener,
+ std::string eventId):
gcn::DropDown::DropDown(listModel,
new ScrollArea,
new ListBox(listModel))
@@ -105,6 +106,12 @@ DropDown::DropDown(gcn::ListModel *listModel):
mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT);
mShadowColor = Theme::getThemeColor(Theme::DROPDOWN_SHADOW);
setForegroundColor(Theme::getThemeColor(Theme::TEXT));
+
+ if (!eventId.empty())
+ setActionEventId(eventId);
+
+ if (listener)
+ addActionListener(listener);
}
DropDown::~DropDown()
diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h
index 6a22ba497..4cbd23314 100644
--- a/src/gui/widgets/dropdown.h
+++ b/src/gui/widgets/dropdown.h
@@ -46,7 +46,9 @@ class DropDown : public gcn::DropDown
* @param listBox the listBox to use.
* @see ListModel, ScrollArea, ListBox.
*/
- DropDown(gcn::ListModel *listModel = 0);
+ DropDown(gcn::ListModel *listModel = 0,
+ gcn::ActionListener* listener = NULL,
+ std::string eventId = "");
~DropDown();
diff --git a/src/gui/widgets/flowcontainer.cpp b/src/gui/widgets/flowcontainer.cpp
index 33e3790a0..0a64a7142 100644
--- a/src/gui/widgets/flowcontainer.cpp
+++ b/src/gui/widgets/flowcontainer.cpp
@@ -67,7 +67,7 @@ void FlowContainer::widgetResized(const gcn::Event &event A_UNUSED)
int i = 0;
height = 0;
- for (WidgetList::iterator it = mWidgets.begin();
+ for (WidgetList::const_iterator it = mWidgets.begin();
it != mWidgets.end(); ++it)
{
int x = i % mGridWidth * mBoxWidth;
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index 91b674018..2cc80ee8b 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -96,6 +96,63 @@ class SortItemIdFunctor
}
} itemIdSorter;
+class SortItemWeightFunctor
+{
+ public:
+ bool operator() (ItemIdPair* pair1, ItemIdPair* pair2)
+ {
+ if (!pair1 || !pair2)
+ return false;
+
+ const int w1 = pair1->mItem->getInfo().getWeight();
+ const int w2 = pair2->mItem->getInfo().getWeight();
+ if (w1 == w2)
+ {
+ return (pair1->mItem->getInfo().getName()
+ < pair2->mItem->getInfo().getName());
+ }
+ return w1 < w2;
+ }
+} itemWeightSorter;
+
+class SortItemAmountFunctor
+{
+ public:
+ bool operator() (ItemIdPair* pair1, ItemIdPair* pair2)
+ {
+ if (!pair1 || !pair2)
+ return false;
+
+ const int c1 = pair1->mItem->getQuantity();
+ const int c2 = pair2->mItem->getQuantity();
+ if (c1 == c2)
+ {
+ return (pair1->mItem->getInfo().getName()
+ < pair2->mItem->getInfo().getName());
+ }
+ return c1 < c2;
+ }
+} itemAmountSorter;
+
+class SortItemTypeFunctor
+{
+ public:
+ bool operator() (ItemIdPair* pair1, ItemIdPair* pair2)
+ {
+ if (!pair1 || !pair2)
+ return false;
+
+ const int t1 = pair1->mItem->getInfo().getType();
+ const int t2 = pair2->mItem->getInfo().getType();
+ if (t1 == t2)
+ {
+ return (pair1->mItem->getInfo().getName()
+ < pair2->mItem->getInfo().getName());
+ }
+ return t1 < t2;
+ }
+} itemTypeSorter;
+
ItemContainer::ItemContainer(Inventory *inventory, bool forceQuantity):
mInventory(inventory),
mGridColumns(1),
@@ -456,6 +513,9 @@ void ItemContainer::updateMatrix()
int i = 0;
int j = 0;
+ std::string temp = mName;
+ toLower(temp);
+
for (unsigned idx = 0; idx < mInventory->getSize(); idx ++)
{
Item *item = mInventory->getItem(idx);
@@ -463,7 +523,15 @@ void ItemContainer::updateMatrix()
if (!item || item->getId() == 0 || !item->isHaveTag(mTag))
continue;
- sortedItems.push_back(new ItemIdPair(idx, item));
+ if (mName.empty())
+ {
+ sortedItems.push_back(new ItemIdPair(idx, item));
+ continue;
+ }
+ std::string name = item->getInfo().getName();
+ toLower(name);
+ if (name.find(temp) != std::string::npos)
+ sortedItems.push_back(new ItemIdPair(idx, item));
}
switch (mSortType)
@@ -477,9 +545,18 @@ void ItemContainer::updateMatrix()
case 2:
sort(sortedItems.begin(), sortedItems.end(), itemIdSorter);
break;
+ case 3:
+ sort(sortedItems.begin(), sortedItems.end(), itemWeightSorter);
+ break;
+ case 4:
+ sort(sortedItems.begin(), sortedItems.end(), itemAmountSorter);
+ break;
+ case 5:
+ sort(sortedItems.begin(), sortedItems.end(), itemTypeSorter);
+ break;
}
- std::vector<ItemIdPair*>::iterator iter;
+ std::vector<ItemIdPair*>::const_iterator iter;
for (iter = sortedItems.begin(); iter != sortedItems.end(); ++iter)
{
if (j >= mGridRows)
@@ -608,6 +685,5 @@ void ItemContainer::setFilter (int tag)
void ItemContainer::setSortType (int sortType)
{
mSortType = sortType;
- logger->log("setSortType: %d", sortType);
updateMatrix();
}
diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h
index df7de63ee..845bfb3a9 100644
--- a/src/gui/widgets/itemcontainer.h
+++ b/src/gui/widgets/itemcontainer.h
@@ -125,6 +125,9 @@ class ItemContainer : public gcn::Widget,
void setSortType (int sortType);
+ void setName(std::string str)
+ { mName = str; }
+
void updateMatrix();
private:
@@ -194,6 +197,7 @@ class ItemContainer : public gcn::Widget,
int mDragPosX, mDragPosY;
int mTag;
int mSortType;
+ std::string mName;
ItemPopup *mItemPopup;
int *mShowMatrix;
diff --git a/src/gui/widgets/layout.cpp b/src/gui/widgets/layout.cpp
index a14b416ce..52b92d0bc 100644
--- a/src/gui/widgets/layout.cpp
+++ b/src/gui/widgets/layout.cpp
@@ -86,12 +86,12 @@ void LayoutCell::computeSizes()
if (mType != ARRAY)
return;
- std::vector< std::vector< LayoutCell * > >::iterator
+ std::vector <std::vector <LayoutCell *> >::const_iterator
i = mArray->mCells.begin();
while (i != mArray->mCells.end())
{
- std::vector< LayoutCell * >::iterator j = i->begin();
+ std::vector <LayoutCell *>::const_iterator j = i->begin();
while (j != i->end())
{
LayoutCell *cell = *j;
@@ -113,7 +113,8 @@ LayoutArray::LayoutArray(): mSpacing(4)
LayoutArray::~LayoutArray()
{
- std::vector< std::vector< LayoutCell * > >::iterator i = mCells.begin();
+ std::vector <std::vector <LayoutCell *> >::iterator
+ i = mCells.begin();
while (i != mCells.end())
{
std::vector< LayoutCell * >::iterator j = i->begin();
@@ -154,7 +155,8 @@ void LayoutArray::resizeGrid(int w, int h)
if (extW)
mSizes[0].resize(w, Layout::AUTO_DEF);
- std::vector< std::vector< LayoutCell * > >::iterator i = mCells.begin();
+ std::vector <std::vector <LayoutCell *> >::iterator
+ i = mCells.begin();
while (i != mCells.end())
{
i->resize(w, 0);
diff --git a/src/gui/widgets/mouseevent.h b/src/gui/widgets/mouseevent.h
index 5e9a46cfd..9484be0a5 100644
--- a/src/gui/widgets/mouseevent.h
+++ b/src/gui/widgets/mouseevent.h
@@ -28,12 +28,12 @@
class MouseEvent : public gcn::MouseEvent
{
public:
- MouseEvent(gcn::Widget* source, bool isShiftPressed,
- bool isControlPressed, bool isAltPressed,
- bool isMetaPressed, unsigned int type, unsigned int button,
+ MouseEvent(gcn::Widget* source, bool shiftPressed,
+ bool controlPressed, bool altPressed,
+ bool metaPressed, unsigned int type, unsigned int button,
int x, int y, int clickCount) :
- gcn::MouseEvent(source, isShiftPressed, isControlPressed,
- isAltPressed, isMetaPressed, type, button, x, y,
+ gcn::MouseEvent(source, shiftPressed, controlPressed,
+ altPressed, metaPressed, type, button, x, y,
clickCount)
{
}
diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp
index 38088770b..ac282b088 100644
--- a/src/gui/widgets/popup.cpp
+++ b/src/gui/widgets/popup.cpp
@@ -40,12 +40,12 @@
#include "debug.h"
-Popup::Popup(const std::string &name, const std::string &skin):
+Popup::Popup(const std::string &name, std::string skin):
mPopupName(name),
mMinWidth(100),
mMinHeight(40),
- mMaxWidth(graphics->mWidth),
- mMaxHeight(graphics->mHeight),
+ mMaxWidth(mainGraphics->mWidth),
+ mMaxHeight(mainGraphics->mHeight),
mVertexes(new GraphicsVertexes()),
mRedraw(true)
{
@@ -58,8 +58,20 @@ Popup::Popup(const std::string &name, const std::string &skin):
setPadding(3);
+ if (skin == "")
+ skin = "popup.xml";
+
// Loads the skin
- mSkin = Theme::instance()->load(skin);
+ if (Theme::instance())
+ {
+ mSkin = Theme::instance()->load(skin);
+ if (mSkin)
+ setPadding(mSkin->getPadding());
+ }
+ else
+ {
+ mSkin = 0;
+ }
// Add this window to the window container
windowContainer->add(this);
@@ -76,7 +88,11 @@ Popup::~Popup()
mVertexes = 0;
if (mSkin)
- mSkin->instances--;
+ {
+ if (Theme::instance())
+ Theme::instance()->unload(mSkin);
+ mSkin = 0;
+ }
}
void Popup::setWindowContainer(WindowContainer *wc)
@@ -190,9 +206,9 @@ void Popup::position(int x, int y)
int posX = std::max(0, x - getWidth() / 2);
int posY = y + distance;
- if (posX + getWidth() > graphics->mWidth)
- posX = graphics->mWidth - getWidth();
- if (posY + getHeight() > graphics->mHeight)
+ if (posX + getWidth() > mainGraphics->mWidth)
+ posX = mainGraphics->mWidth - getWidth();
+ if (posY + getHeight() > mainGraphics->mHeight)
posY = y - getHeight() - distance;
setPosition(posX, posY);
diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h
index 0ac50f69e..9d4343ba3 100644
--- a/src/gui/widgets/popup.h
+++ b/src/gui/widgets/popup.h
@@ -66,8 +66,7 @@ class Popup : public Container, public gcn::MouseListener,
* debugging purposes.
* @param skin The location where the Popup's skin XML can be found.
*/
- Popup(const std::string &name = "",
- const std::string &skin = "window.xml");
+ Popup(const std::string &name = "", std::string skin = "");
/**
* Destructor. Deletes all the added widgets.
diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp
index c1d6a9531..7324fc9ad 100644
--- a/src/gui/widgets/progressbar.cpp
+++ b/src/gui/widgets/progressbar.cpp
@@ -70,7 +70,9 @@ ProgressBar::ProgressBar(float progress,
if (mInstances == 0)
{
- Image *dBorders = Theme::getImageFromTheme("vscroll_grey.png");
+ Image *dBorders = Theme::getImageFromTheme("progress.png");
+ if (!dBorders)
+ dBorders = Theme::getImageFromTheme("vscroll_grey.png");
if (dBorders)
{
mBorder.grid[0] = dBorders->getSubImage(0, 0, 4, 4);
diff --git a/src/gui/widgets/progressbar.h b/src/gui/widgets/progressbar.h
index 52a26ddac..36ed96bd2 100644
--- a/src/gui/widgets/progressbar.h
+++ b/src/gui/widgets/progressbar.h
@@ -94,8 +94,8 @@ class ProgressBar : public gcn::Widget, public gcn::WidgetListener
/**
* Sets the text shown on the progress bar.
*/
- void setText(const std::string &text)
- { mText = text; }
+ void setText(const std::string &str)
+ { mText = str; }
/**
* Returns the text shown on the progress bar.
diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp
index e641be323..feedeae7b 100644
--- a/src/gui/widgets/radiobutton.cpp
+++ b/src/gui/widgets/radiobutton.cpp
@@ -136,23 +136,16 @@ void RadioButton::drawBox(gcn::Graphics* graphics)
}
if (box)
- static_cast<Graphics*>(graphics)->drawImage(box, 2, 2);
+ static_cast<Graphics*>(graphics)->drawImage(box, 3, 3);
}
void RadioButton::draw(gcn::Graphics* graphics)
{
- graphics->pushClipArea(gcn::Rectangle(1, 1, getWidth() - 1,
- getHeight() - 1));
-
drawBox(graphics);
- graphics->popClipArea();
-
graphics->setFont(getFont());
graphics->setColor(getForegroundColor());
-// int h = getHeight() + getHeight() / 2;
-// graphics->drawText(getCaption(), h - 2, 0);
graphics->drawText(getCaption(), 16, 0);
}
@@ -165,4 +158,3 @@ void RadioButton::mouseExited(gcn::MouseEvent& event A_UNUSED)
{
mHasMouse = false;
}
-
diff --git a/src/gui/widgets/setuptabscroll.cpp b/src/gui/widgets/setuptabscroll.cpp
index 30bb66469..e9917b090 100644
--- a/src/gui/widgets/setuptabscroll.cpp
+++ b/src/gui/widgets/setuptabscroll.cpp
@@ -90,25 +90,31 @@ void SetupTabScroll::addControl(SetupItem *widget, std::string event)
void SetupTabScroll::apply()
{
- std::map<std::string, SetupItem*>::iterator iter;
+ std::map<std::string, SetupItem*>::const_iterator iter;
for (iter = mItems.begin(); iter != mItems.end(); ++ iter)
- (*iter).second->apply((*iter).first);
+ {
+ if ((*iter).second)
+ (*iter).second->apply((*iter).first);
+ }
}
void SetupTabScroll::cancel()
{
- std::map<std::string, SetupItem*>::iterator iter;
+ std::map<std::string, SetupItem*>::const_iterator iter;
for (iter = mItems.begin(); iter != mItems.end(); ++ iter)
- (*iter).second->cancel((*iter).first);
+ {
+ if ((*iter).second)
+ (*iter).second->cancel((*iter).first);
+ }
}
void SetupTabScroll::externalUpdated()
{
- std::map<std::string, SetupItem*>::iterator iter;
+ std::map<std::string, SetupItem*>::const_iterator iter;
for (iter = mItems.begin(); iter != mItems.end(); ++ iter)
{
SetupItem *widget = (*iter).second;
- if (!widget->isMainConfig())
+ if (widget && !widget->isMainConfig())
(*iter).second->externalUpdated((*iter).first);
}
}
diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp
index 940dad12a..47b02c925 100644
--- a/src/gui/widgets/tabbedarea.cpp
+++ b/src/gui/widgets/tabbedarea.cpp
@@ -241,6 +241,19 @@ void TabbedArea::setSelectedTab(gcn::Tab *tab)
widgetResized(NULL);
}
+void TabbedArea::setSelectedTab(const std::string &name)
+{
+ for (TabContainer::const_iterator itr = mTabs.begin(),
+ itr_end = mTabs.end(); itr != itr_end; ++itr)
+ {
+ if ((*itr).first && (*itr).first->getCaption() == name)
+ {
+ setSelectedTab((*itr).first);
+ return;
+ }
+ }
+}
+
void TabbedArea::widgetResized(const gcn::Event &event A_UNUSED)
{
int width = getWidth() - 2 * getFrameSize()
diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h
index a91b4c199..3ad113b4c 100644
--- a/src/gui/widgets/tabbedarea.h
+++ b/src/gui/widgets/tabbedarea.h
@@ -122,6 +122,8 @@ class TabbedArea : public gcn::TabbedArea, public gcn::WidgetListener
void setSelectedTab(gcn::Tab *tab);
+ void setSelectedTab(const std::string &name);
+
void widgetResized(const gcn::Event &event);
/*
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index 2729e5407..5d4fbc0b4 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -48,12 +48,14 @@ float TextField::mAlpha = 1.0;
ImageRect TextField::skin;
TextField::TextField(const std::string &text, bool loseFocusOnTab,
- gcn::ActionListener* listener, std::string eventId):
+ gcn::ActionListener* listener, std::string eventId,
+ bool sendAlwaysEvents):
gcn::TextField(text),
mNumeric(false),
mMinimum(0),
mMaximum(0),
- mLastEventPaste(false)
+ mLastEventPaste(false),
+ mSendAlwaysEvents(sendAlwaysEvents)
{
setFrameSize(2);
@@ -276,7 +278,9 @@ void TextField::keyPressed(gcn::KeyEvent &keyEvent)
case Key::ENTER:
distributeActionEvent();
- break;
+ keyEvent.consume();
+ fixScroll();
+ return;
case Key::HOME:
mCaretPosition = 0;
@@ -309,6 +313,10 @@ void TextField::keyPressed(gcn::KeyEvent &keyEvent)
}
break;
+ case 3:
+ handleCopy();
+ break;
+
case 22: // Control code 22, SYNCHRONOUS IDLE, sent on Ctrl+v
// hack to prevent paste key sticking
if (mLastEventPaste && mLastEventPaste > cur_time)
@@ -333,6 +341,9 @@ void TextField::keyPressed(gcn::KeyEvent &keyEvent)
break;
}
+ if (mSendAlwaysEvents)
+ distributeActionEvent();
+
keyEvent.consume();
fixScroll();
}
@@ -348,3 +359,9 @@ void TextField::handlePaste()
setCaretPosition(static_cast<unsigned>(caretPos));
}
}
+
+void TextField::handleCopy()
+{
+ std::string text = getText();
+ sendBuffer(text);
+}
diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h
index 79197bb7a..7e19099e8 100644
--- a/src/gui/widgets/textfield.h
+++ b/src/gui/widgets/textfield.h
@@ -41,7 +41,7 @@ class TextField : public gcn::TextField
*/
TextField(const std::string &text = "", bool loseFocusOnTab = true,
gcn::ActionListener* listener = NULL,
- std::string eventId = "");
+ std::string eventId = "", bool sendAlwaysEvents = false);
~TextField();
@@ -99,6 +99,8 @@ class TextField : public gcn::TextField
private:
void handlePaste();
+ void handleCopy();
+
static int instances;
static float mAlpha;
static ImageRect skin;
@@ -107,6 +109,7 @@ class TextField : public gcn::TextField
int mMaximum;
bool mLoseFocusOnTab;
int mLastEventPaste;
+ bool mSendAlwaysEvents;
};
#endif
diff --git a/src/gui/widgets/vertcontainer.cpp b/src/gui/widgets/vertcontainer.cpp
index ea6b4d520..5e79b7c19 100644
--- a/src/gui/widgets/vertcontainer.cpp
+++ b/src/gui/widgets/vertcontainer.cpp
@@ -73,8 +73,9 @@ void VertContainer::clear()
void VertContainer::widgetResized(const gcn::Event &event A_UNUSED)
{
- for (std::vector<gcn::Widget*>::iterator it = mResizableWidgets.begin();
- it != mResizableWidgets.end(); ++ it)
+ for (std::vector<gcn::Widget*>::const_iterator
+ it = mResizableWidgets.begin();
+ it != mResizableWidgets.end(); ++ it)
{
(*it)->setWidth(getWidth());
}
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index 4435496a7..c52bf744e 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -47,7 +47,7 @@ int Window::instances = 0;
int Window::mouseResize = 0;
Window::Window(const std::string &caption, bool modal, Window *parent,
- const std::string &skin):
+ std::string skin):
gcn::Window(caption),
mGrip(0),
mParent(parent),
@@ -63,8 +63,8 @@ Window::Window(const std::string &caption, bool modal, Window *parent,
mStickyButtonLock(false),
mMinWinWidth(100),
mMinWinHeight(40),
- mMaxWinWidth(graphics->mWidth),
- mMaxWinHeight(graphics->mHeight),
+ mMaxWinWidth(mainGraphics->mWidth),
+ mMaxWinHeight(mainGraphics->mHeight),
mVertexes(new GraphicsVertexes()),
mRedraw(true)
{
@@ -79,8 +79,20 @@ Window::Window(const std::string &caption, bool modal, Window *parent,
setPadding(3);
setTitleBarHeight(20);
+ if (skin == "")
+ skin = "window.xml";
+
// Loads the skin
- mSkin = Theme::instance()->load(skin);
+ if (Theme::instance())
+ {
+ mSkin = Theme::instance()->load(skin);
+ if (mSkin)
+ setPadding(mSkin->getPadding());
+ }
+ else
+ {
+ mSkin = 0;
+ }
// Add this window to the window container
windowContainer->add(this);
@@ -113,8 +125,6 @@ Window::~Window()
mWidgets.clear();
-// need mWidgets.clean ?
-
removeWidgetListener(this);
delete mVertexes;
mVertexes = 0;
@@ -122,7 +132,11 @@ Window::~Window()
instances--;
if (mSkin)
- mSkin->instances--;
+ {
+ if (Theme::instance())
+ Theme::instance()->unload(mSkin);
+ mSkin = 0;
+ }
}
void Window::setWindowContainer(WindowContainer *wc)
@@ -244,39 +258,39 @@ void Window::setLocationRelativeTo(ImageRect::ImagePosition position,
}
else if (position == ImageRect::UPPER_CENTER)
{
- offsetX += (graphics->mWidth - getWidth()) / 2;
+ offsetX += (mainGraphics->mWidth - getWidth()) / 2;
}
else if (position == ImageRect::UPPER_RIGHT)
{
- offsetX += graphics->mWidth - getWidth();
+ offsetX += mainGraphics->mWidth - getWidth();
}
else if (position == ImageRect::LEFT)
{
- offsetY += (graphics->mHeight - getHeight()) / 2;
+ offsetY += (mainGraphics->mHeight - getHeight()) / 2;
}
else if (position == ImageRect::CENTER)
{
- offsetX += (graphics->mWidth - getWidth()) / 2;
- offsetY += (graphics->mHeight - getHeight()) / 2;
+ offsetX += (mainGraphics->mWidth - getWidth()) / 2;
+ offsetY += (mainGraphics->mHeight - getHeight()) / 2;
}
else if (position == ImageRect::RIGHT)
{
- offsetX += graphics->mWidth - getWidth();
- offsetY += (graphics->mHeight - getHeight()) / 2;
+ offsetX += mainGraphics->mWidth - getWidth();
+ offsetY += (mainGraphics->mHeight - getHeight()) / 2;
}
else if (position == ImageRect::LOWER_LEFT)
{
- offsetY += graphics->mHeight - getHeight();
+ offsetY += mainGraphics->mHeight - getHeight();
}
else if (position == ImageRect::LOWER_CENTER)
{
- offsetX += (graphics->mWidth - getWidth()) / 2;
- offsetY += graphics->mHeight - getHeight();
+ offsetX += (mainGraphics->mWidth - getWidth()) / 2;
+ offsetY += mainGraphics->mHeight - getHeight();
}
else if (position == ImageRect::LOWER_RIGHT)
{
- offsetX += graphics->mWidth - getWidth();
- offsetY += graphics->mHeight - getHeight();
+ offsetX += mainGraphics->mWidth - getWidth();
+ offsetY += mainGraphics->mHeight - getHeight();
}
setPosition(offsetX, offsetY);
@@ -373,7 +387,7 @@ void Window::widgetHidden(const gcn::Event &event A_UNUSED)
if (!mFocusHandler)
return;
- for (it = mWidgets.begin(); it != mWidgets.end(); it++)
+ for (it = mWidgets.begin(); it != mWidgets.end(); ++ it)
{
if (mFocusHandler->isFocused(*it))
mFocusHandler->focusNone();
@@ -443,7 +457,7 @@ void Window::mousePressed(gcn::MouseEvent &event)
const int y = event.getY();
// Handle close button
- if (mCloseButton)
+ if (mCloseButton && mSkin)
{
Image *img = mSkin->getCloseImage();
if (img)
@@ -464,7 +478,7 @@ void Window::mousePressed(gcn::MouseEvent &event)
}
// Handle sticky button
- if (mStickyButton)
+ if (mStickyButton && mSkin)
{
Image *button = mSkin->getStickyImage(mSticky);
if (button)
@@ -579,8 +593,8 @@ void Window::mouseDragged(gcn::MouseEvent &event)
{
int newX = std::max(0, getX());
int newY = std::max(0, getY());
- newX = std::min(graphics->mWidth - getWidth(), newX);
- newY = std::min(graphics->mHeight - getHeight(), newY);
+ newX = std::min(mainGraphics->mWidth - getWidth(), newX);
+ newY = std::min(mainGraphics->mHeight - getHeight(), newY);
setPosition(newX, newY);
}
@@ -621,14 +635,10 @@ void Window::mouseDragged(gcn::MouseEvent &event)
newDim.height += newDim.y;
newDim.y = 0;
}
- if (newDim.x + newDim.width > graphics->mWidth)
- {
- newDim.width = graphics->mWidth - newDim.x;
- }
- if (newDim.y + newDim.height > graphics->mHeight)
- {
- newDim.height = graphics->mHeight - newDim.y;
- }
+ if (newDim.x + newDim.width > mainGraphics->mWidth)
+ newDim.width = mainGraphics->mWidth - newDim.x;
+ if (newDim.y + newDim.height > mainGraphics->mHeight)
+ newDim.height = mainGraphics->mHeight - newDim.y;
// Update mouse offset when dragging bottom or right border
if (mouseResize & BOTTOM)
@@ -790,39 +800,39 @@ void Window::setDefaultSize(int defaultWidth, int defaultHeight,
}
else if (position == ImageRect::UPPER_CENTER)
{
- x = (graphics->mWidth - defaultWidth) / 2;
+ x = (mainGraphics->mWidth - defaultWidth) / 2;
}
else if (position == ImageRect::UPPER_RIGHT)
{
- x = graphics->mWidth - defaultWidth;
+ x = mainGraphics->mWidth - defaultWidth;
}
else if (position == ImageRect::LEFT)
{
- y = (graphics->mHeight - defaultHeight) / 2;
+ y = (mainGraphics->mHeight - defaultHeight) / 2;
}
else if (position == ImageRect::CENTER)
{
- x = (graphics->mWidth - defaultWidth) / 2;
- y = (graphics->mHeight - defaultHeight) / 2;
+ x = (mainGraphics->mWidth - defaultWidth) / 2;
+ y = (mainGraphics->mHeight - defaultHeight) / 2;
}
else if (position == ImageRect::RIGHT)
{
- x = graphics->mWidth - defaultWidth;
- y = (graphics->mHeight - defaultHeight) / 2;
+ x = mainGraphics->mWidth - defaultWidth;
+ y = (mainGraphics->mHeight - defaultHeight) / 2;
}
else if (position == ImageRect::LOWER_LEFT)
{
- y = graphics->mHeight - defaultHeight;
+ y = mainGraphics->mHeight - defaultHeight;
}
else if (position == ImageRect::LOWER_CENTER)
{
- x = (graphics->mWidth - defaultWidth) / 2;
- y = graphics->mHeight - defaultHeight;
+ x = (mainGraphics->mWidth - defaultWidth) / 2;
+ y = mainGraphics->mHeight - defaultHeight;
}
else if (position == ImageRect::LOWER_RIGHT)
{
- x = graphics->mWidth - defaultWidth;
- y = graphics->mHeight - defaultHeight;
+ x = mainGraphics->mWidth - defaultWidth;
+ y = mainGraphics->mHeight - defaultHeight;
}
mDefaultX = x - offsetX;
@@ -994,11 +1004,11 @@ void Window::checkIfIsOffScreen(bool partially, bool entirely)
// Look if the window is partially off-screen limits...
if (partially)
{
- if (winDimension.x + winDimension.width > graphics->mWidth)
- winDimension.x = graphics->mWidth - winDimension.width;
+ if (winDimension.x + winDimension.width > mainGraphics->mWidth)
+ winDimension.x = mainGraphics->mWidth - winDimension.width;
- if (winDimension.y + winDimension.height > graphics->mHeight)
- winDimension.y = graphics->mHeight - winDimension.height;
+ if (winDimension.y + winDimension.height > mainGraphics->mHeight)
+ winDimension.y = mainGraphics->mHeight - winDimension.height;
setDimension(winDimension);
return;
@@ -1006,11 +1016,11 @@ void Window::checkIfIsOffScreen(bool partially, bool entirely)
if (entirely)
{
- if (winDimension.x > graphics->mWidth)
- winDimension.x = graphics->mWidth - winDimension.width;
+ if (winDimension.x > mainGraphics->mWidth)
+ winDimension.x = mainGraphics->mWidth - winDimension.width;
- if (winDimension.y > graphics->mHeight)
- winDimension.y = graphics->mHeight - winDimension.height;
+ if (winDimension.y > mainGraphics->mHeight)
+ winDimension.y = mainGraphics->mHeight - winDimension.height;
}
setDimension(winDimension);
}
@@ -1021,4 +1031,4 @@ gcn::Rectangle Window::getWindowArea()
getPadding(),
getWidth() - getPadding() * 2,
getHeight() - getPadding() * 2);
-} \ No newline at end of file
+}
diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h
index b9f65dceb..510a68323 100644
--- a/src/gui/widgets/window.h
+++ b/src/gui/widgets/window.h
@@ -65,7 +65,7 @@ class Window : public gcn::Window, gcn::WidgetListener
* @param skin The location where the window's skin XML can be found.
*/
Window(const std::string &caption = "Window", bool modal = false,
- Window *parent = NULL, const std::string &skin = "window.xml");
+ Window *parent = NULL, std::string skin = "");
/**
* Destructor. Deletes all the added widgets.
diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp
index 0d81ba3a9..487035350 100644
--- a/src/gui/windowmenu.cpp
+++ b/src/gui/windowmenu.cpp
@@ -99,9 +99,9 @@ WindowMenu::WindowMenu():
KeyboardConfig::KEY_WINDOW_DIDYOUKNOW);
addButton(N_("SET"), _("Setup"), x, h, KeyboardConfig::KEY_WINDOW_SETUP);
- if (graphics)
+ if (mainGraphics)
{
- setDimension(gcn::Rectangle(graphics->mWidth - x - 3,
+ setDimension(gcn::Rectangle(mainGraphics->mWidth - x - 3,
3, x - 3, h));
}
@@ -315,13 +315,13 @@ void WindowMenu::mouseExited(gcn::MouseEvent& mouseEvent A_UNUSED)
mTextPopup->hide();
}
-void WindowMenu::showButton(std::string name, bool isVisible)
+void WindowMenu::showButton(std::string name, bool visible)
{
Button *btn = dynamic_cast<Button*>(mButtonNames[name]);
if (!btn)
return;
- btn->setVisible(isVisible);
+ btn->setVisible(visible);
updateButtons();
saveButtons();
}
@@ -329,7 +329,7 @@ void WindowMenu::showButton(std::string name, bool isVisible)
void WindowMenu::updateButtons()
{
int x = 0, h = 0;
- std::vector <gcn::Button*>::iterator it, it_end;
+ std::vector <gcn::Button*>::const_iterator it, it_end;
for (it = mButtons.begin(), it_end = mButtons.end(); it != it_end; ++it)
safeRemove(*it);
for (it = mButtons.begin(), it_end = mButtons.end(); it != it_end; ++it)
@@ -345,9 +345,9 @@ void WindowMenu::updateButtons()
h = btn->getHeight();
}
}
- if (graphics)
+ if (mainGraphics)
{
- setDimension(gcn::Rectangle(graphics->mWidth - x - 3,
+ setDimension(gcn::Rectangle(mainGraphics->mWidth - x - 3,
3, x - 3, h));
}
}
diff --git a/src/gui/windowmenu.h b/src/gui/windowmenu.h
index 6572fe470..739a302ba 100644
--- a/src/gui/windowmenu.h
+++ b/src/gui/windowmenu.h
@@ -72,7 +72,7 @@ class WindowMenu : public Container,
std::vector <gcn::Button*> &getButtons()
{ return mButtons; }
- void showButton(std::string name, bool isVisible);
+ void showButton(std::string name, bool visible);
void loadButtons();
diff --git a/src/gui/worldselectdialog.cpp b/src/gui/worldselectdialog.cpp
index 7e2afbaa3..b4f697ba3 100644
--- a/src/gui/worldselectdialog.cpp
+++ b/src/gui/worldselectdialog.cpp
@@ -74,7 +74,7 @@ class WorldListModel : public gcn::ListModel
};
WorldSelectDialog::WorldSelectDialog(Worlds worlds):
- Window(_("Select World"))
+ Window(_("Select World"), false, 0, "world.xml")
{
mWorldListModel = new WorldListModel(worlds);
mWorldList = new ListBox(mWorldListModel);