summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-09-06 20:57:24 +0300
committerAndrei Karas <akaras@inbox.ru>2012-09-06 22:58:35 +0300
commit4ad3cd45f7a8c3f6d1817705c06223d1a2798a2f (patch)
treea776928bb1339cdd29eb2e54d50eb3fa6e3448d7 /src
parent22ed653d8b630c813333d5c73a4ca02dede2a5a5 (diff)
downloadplus-4ad3cd45f7a8c3f6d1817705c06223d1a2798a2f.tar.gz
plus-4ad3cd45f7a8c3f6d1817705c06223d1a2798a2f.tar.bz2
plus-4ad3cd45f7a8c3f6d1817705c06223d1a2798a2f.tar.xz
plus-4ad3cd45f7a8c3f6d1817705c06223d1a2798a2f.zip
Improve constructors in some classes.
Diffstat (limited to 'src')
-rw-r--r--src/actorsprite.cpp2
-rw-r--r--src/gui/chatwindow.cpp21
-rw-r--r--src/gui/chatwindow.h12
-rw-r--r--src/gui/confirmdialog.cpp5
-rw-r--r--src/gui/connectiondialog.cpp1
-rw-r--r--src/gui/debugwindow.cpp68
-rw-r--r--src/gui/debugwindow.h7
-rw-r--r--src/gui/didyouknowwindow.cpp9
-rw-r--r--src/gui/editdialog.cpp6
-rw-r--r--src/gui/editserverdialog.cpp22
-rw-r--r--src/gui/editserverdialog.h2
-rw-r--r--src/gui/equipmentwindow.cpp11
-rw-r--r--src/gui/equipmentwindow.h2
-rw-r--r--src/gui/gui.cpp5
-rw-r--r--src/gui/helpwindow.cpp7
-rw-r--r--src/gui/inventorywindow.cpp33
-rw-r--r--src/gui/inventorywindow.h25
-rw-r--r--src/gui/itemamountwindow.cpp15
-rw-r--r--src/gui/killstats.cpp78
-rw-r--r--src/gui/logindialog.cpp36
-rw-r--r--src/gui/logindialog.h5
-rw-r--r--src/gui/ministatuswindow.cpp42
-rw-r--r--src/gui/ministatuswindow.h8
23 files changed, 229 insertions, 193 deletions
diff --git a/src/actorsprite.cpp b/src/actorsprite.cpp
index 94c4ef966..957661f8c 100644
--- a/src/actorsprite.cpp
+++ b/src/actorsprite.cpp
@@ -49,8 +49,8 @@ SimpleAnimation *ActorSprite::targetCursor[2][NUM_TC];
bool ActorSprite::loaded = false;
ActorSprite::ActorSprite(const int id) :
- Actor(),
CompoundSprite(),
+ Actor(),
mId(id),
mStunMode(0),
mStatusParticleEffects(&mStunParticleEffects, false),
diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp
index 3f87e6d2c..3d1cd86db 100644
--- a/src/gui/chatwindow.cpp
+++ b/src/gui/chatwindow.cpp
@@ -78,6 +78,7 @@ class ChatInput : public TextField, public gcn::FocusListener
public:
ChatInput(ChatWindow *const window, TabbedArea *const tabs):
TextField("", false),
+ FocusListener(),
mWindow(window),
mChatTabs(tabs)
{
@@ -154,7 +155,16 @@ static const char *ACTION_COLOR_PICKER = "color picker";
ChatWindow::ChatWindow():
Window(_("Chat"), false, nullptr, "chat.xml"),
+ ActionListener(),
+ KeyListener(),
+ mItemLinkHandler(new ItemLinkHandler),
+ mChatTabs(new TabbedArea),
+ mChatInput(new ChatInput(this, mChatTabs)),
mTmpVisible(false),
+ mReturnToggles(config.getBoolValue("ReturnToggles")),
+ mColorListModel(new ColorListModel),
+ mColorPicker(new DropDown(mColorListModel)),
+ mChatColor(config.getIntValue("chatColor")),
mChatHistoryIndex(0),
mGMLoaded(false),
mHaveMouse(false),
@@ -181,20 +191,12 @@ ChatWindow::ChatWindow():
setMinWidth(150);
setMinHeight(90);
- mItemLinkHandler = new ItemLinkHandler;
-
- mChatTabs = new TabbedArea;
mChatTabs->enableScrollButtons(true);
mChatTabs->setFollowDownScroll(true);
- mChatInput = new ChatInput(this, mChatTabs);
mChatInput->setActionEventId("chatinput");
mChatInput->addActionListener(this);
- mChatColor = config.getIntValue("chatColor");
- mColorListModel = new ColorListModel;
- mColorPicker = new DropDown(mColorListModel);
-
mColorPicker->setActionEventId(ACTION_COLOR_PICKER);
mColorPicker->addActionListener(this);
mColorPicker->setSelected(mChatColor);
@@ -212,10 +214,7 @@ ChatWindow::ChatWindow():
mChatInput->addKeyListener(this);
mCurHist = mHistory.end();
- mReturnToggles = config.getBoolValue("ReturnToggles");
-
mRainbowColor = 0;
-
mColorPicker->setVisible(config.getBoolValue("showChatColorsList"));
fillCommands();
diff --git a/src/gui/chatwindow.h b/src/gui/chatwindow.h
index 66d35ead5..4f65ed44d 100644
--- a/src/gui/chatwindow.h
+++ b/src/gui/chatwindow.h
@@ -285,6 +285,8 @@ class ChatWindow : public Window,
void unHideWindow();
+ void widgetResized(const gcn::Event &event);
+
protected:
friend class ChatTab;
friend class WhisperTab;
@@ -315,11 +317,12 @@ class ChatWindow : public Window,
/** Used for showing item popup on clicking links **/
ItemLinkHandler *mItemLinkHandler;
+ /** Tabbed area for holding each channel. */
+ TabbedArea *mChatTabs;
+
/** Input box for typing chat messages. */
ChatInput *mChatInput;
- void widgetResized(const gcn::Event &event);
-
void initTradeFilter();
int mRainbowColor;
@@ -329,9 +332,6 @@ class ChatWindow : public Window,
bool mTmpVisible;
- /** Tabbed area for holding each channel. */
- TabbedArea *mChatTabs;
-
typedef std::map<const std::string, ChatTab*> TabMap;
/** Manage whisper tabs */
TabMap mWhispers;
@@ -350,8 +350,8 @@ class ChatWindow : public Window,
StringVect mTradeFilter;
- gcn::DropDown *mColorPicker;
ColorListModel *mColorListModel;
+ gcn::DropDown *mColorPicker;
int mChatColor;
unsigned int mChatHistoryIndex;
std::list<std::string> mAwayLog;
diff --git a/src/gui/confirmdialog.cpp b/src/gui/confirmdialog.cpp
index b0407572a..b3ced2cde 100644
--- a/src/gui/confirmdialog.cpp
+++ b/src/gui/confirmdialog.cpp
@@ -38,9 +38,10 @@
ConfirmDialog::ConfirmDialog(const std::string &title, const std::string &msg,
const bool ignore, const bool modal,
Window *const parent):
- Window(title, modal, parent, "confirm.xml")
+ Window(title, modal, parent, "confirm.xml"),
+ ActionListener(),
+ mTextBox(new TextBox)
{
- mTextBox = new TextBox;
mTextBox->setEditable(false);
mTextBox->setOpaque(false);
mTextBox->setTextWrapped(msg, 260);
diff --git a/src/gui/connectiondialog.cpp b/src/gui/connectiondialog.cpp
index 872f8ad76..9e4163839 100644
--- a/src/gui/connectiondialog.cpp
+++ b/src/gui/connectiondialog.cpp
@@ -36,6 +36,7 @@
ConnectionDialog::ConnectionDialog(const std::string &text,
const State cancelState):
Window(""),
+ ActionListener(),
mCancelState(cancelState)
{
setTitleBarHeight(0);
diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp
index 7bcec47ec..673edc914 100644
--- a/src/gui/debugwindow.cpp
+++ b/src/gui/debugwindow.cpp
@@ -47,7 +47,11 @@
#include "debug.h"
DebugWindow::DebugWindow():
- Window(_("Debug"), false, nullptr, "debug.xml")
+ Window(_("Debug"), false, nullptr, "debug.xml"),
+ mTabs(new TabbedArea),
+ mMapWidget(new MapDebugTab),
+ mTargetWidget(new TargetDebugTab),
+ mNetWidget(new NetDebugTab)
{
setWindowName("Debug");
if (setupWindow)
@@ -60,11 +64,6 @@ DebugWindow::DebugWindow():
setDefaultSize(400, 300, ImageRect::CENTER);
- mTabs = new TabbedArea;
- mMapWidget = new MapDebugTab;
- mTargetWidget = new TargetDebugTab;
- mNetWidget = new NetDebugTab;
-
mTabs->addTab(std::string(_("Map")), mMapWidget);
mTabs->addTab(std::string(_("Target")), mTargetWidget);
mTabs->addTab(std::string(_("Net")), mNetWidget);
@@ -135,24 +134,25 @@ void DebugWindow::widgetResized(const gcn::Event &event)
}
MapDebugTab::MapDebugTab() :
- mTexturesLabel(nullptr)
+ DebugTab(),
+ mMusicFileLabel(new Label(strprintf(_("Music:")))),
+ mMapLabel(new Label(strprintf(_("Map:")))),
+ mMinimapLabel(new Label(strprintf(_("Minimap:")))),
+ mTileMouseLabel(new Label(strprintf("%s (%d, %d)", _("Cursor:"), 0, 0))),
+ mXYLabel(new Label(strprintf("%s (?,?)", _("Player Position:")))),
+ mTexturesLabel(nullptr),
+ mUpdateTime(0),
+ mFPSLabel(new Label(strprintf(_("%d FPS"), 0))),
+ mLPSLabel(new Label(strprintf(_("%d LPS"), 0)))
{
LayoutHelper h(this);
ContainerPlacer place = h.getPlacer(0, 0);
- mMusicFileLabel = new Label(strprintf(_("Music:")));
- mMapLabel = new Label(strprintf(_("Map:")));
- mMinimapLabel = new Label(strprintf(_("Minimap:")));
- mTileMouseLabel = new Label(strprintf("%s (%d, %d)", _("Cursor:"), 0, 0));
- mXYLabel = new Label(strprintf("%s (?,?)", _("Player Position:")));
-
mParticleCountLabel = new Label(strprintf("%s %d",
_("Particle count:"), 88888));
mMapActorCountLabel = new Label(strprintf("%s %d",
_("Map actors count:"), 88888));
- mUpdateTime = 0;
-
#ifdef USE_OPENGL
switch (imageHelper->useOpenGL())
{
@@ -171,9 +171,6 @@ MapDebugTab::MapDebugTab() :
mFPSText = _("%d FPS (Software)");
#endif
- mFPSLabel = new Label(strprintf(_("%d FPS"), 0));
- mLPSLabel = new Label(strprintf(_("%d LPS"), 0));
-
place(0, 0, mFPSLabel, 2);
place(0, 1, mLPSLabel, 2);
place(0, 2, mMusicFileLabel, 2);
@@ -261,22 +258,22 @@ void MapDebugTab::logic()
mLPSLabel->setCaption(strprintf(_("%d LPS"), lps));
}
-TargetDebugTab::TargetDebugTab()
+TargetDebugTab::TargetDebugTab() :
+ DebugTab(),
+ mTargetLabel(new Label(strprintf("%s ?", _("Target:")))),
+ mTargetIdLabel(new Label(strprintf("%s ? ", _("Target Id:")))),
+ mTargetLevelLabel(new Label(strprintf("%s ?", _("Target level:")))),
+ mTargetRaceLabel(new Label(strprintf("%s ?", _("Target race:")))),
+ mTargetPartyLabel(new Label(strprintf("%s ?", _("Target party:")))),
+ mTargetGuildLabel(new Label(strprintf("%s ?", _("Target guild:")))),
+ mAttackDelayLabel(new Label(strprintf("%s ?", _("Attack delay:")))),
+ mMinHitLabel(new Label(strprintf("%s ?", _("Minimal hit:")))),
+ mMaxHitLabel(new Label(strprintf("%s ?", _("Maximum hit:")))),
+ mCriticalHitLabel(new Label(strprintf("%s ?", _("Critical hit:"))))
{
LayoutHelper h(this);
ContainerPlacer place = h.getPlacer(0, 0);
- mTargetLabel = new Label(strprintf("%s ?", _("Target:")));
- mTargetIdLabel = new Label(strprintf("%s ? ", _("Target Id:")));
- mTargetLevelLabel = new Label(strprintf("%s ?", _("Target level:")));
- mTargetRaceLabel = new Label(strprintf("%s ?", _("Target race:")));
- mTargetPartyLabel = new Label(strprintf("%s ?", _("Target party:")));
- mTargetGuildLabel = new Label(strprintf("%s ?", _("Target guild:")));
- mAttackDelayLabel = new Label(strprintf("%s ?", _("Attack delay:")));
- mMinHitLabel = new Label(strprintf("%s ?", _("Minimal hit:")));
- mMaxHitLabel = new Label(strprintf("%s ?", _("Maximum hit:")));
- mCriticalHitLabel = new Label(strprintf("%s ?", _("Critical hit:")));
-
place(0, 0, mTargetLabel, 2);
place(0, 1, mTargetIdLabel, 2);
place(0, 2, mTargetLevelLabel, 2);
@@ -365,15 +362,15 @@ void TargetDebugTab::logic()
mAttackDelayLabel->adjustSize();
}
-NetDebugTab::NetDebugTab()
+NetDebugTab::NetDebugTab() :
+ DebugTab(),
+ mPingLabel(new Label(" ")),
+ mInPackets1Label(new Label(" ")),
+ mOutPackets1Label(new Label(" "))
{
LayoutHelper h(this);
ContainerPlacer place = h.getPlacer(0, 0);
- mPingLabel = new Label(" ");
- mInPackets1Label = new Label(" ");
- mOutPackets1Label = new Label(" ");
-
place(0, 0, mPingLabel, 2);
place(0, 1, mInPackets1Label, 2);
place(0, 2, mOutPackets1Label, 2);
@@ -383,7 +380,6 @@ NetDebugTab::NetDebugTab()
setDimension(gcn::Rectangle(0, 0, 600, 300));
}
-
void NetDebugTab::logic()
{
if (player_node && player_node->getPingTime() != 0)
diff --git a/src/gui/debugwindow.h b/src/gui/debugwindow.h
index c6143dfa1..1a35e890b 100644
--- a/src/gui/debugwindow.h
+++ b/src/gui/debugwindow.h
@@ -37,7 +37,8 @@ class DebugTab : public Container
friend class DebugWindow;
public:
- DebugTab()
+ DebugTab() :
+ Container()
{ }
void logic() = 0;
@@ -58,7 +59,9 @@ class MapDebugTab : public DebugTab
void logic();
private:
- Label *mMusicFileLabel, *mMapLabel, *mMinimapLabel;
+ Label *mMusicFileLabel;
+ Label *mMapLabel;
+ Label *mMinimapLabel;
Label *mTileMouseLabel;
Label *mParticleCountLabel;
Label *mMapActorCountLabel;
diff --git a/src/gui/didyouknowwindow.cpp b/src/gui/didyouknowwindow.cpp
index c9e372823..24965848e 100644
--- a/src/gui/didyouknowwindow.cpp
+++ b/src/gui/didyouknowwindow.cpp
@@ -48,7 +48,11 @@ static const int minTip = 1;
static const int maxTip = 16;
DidYouKnowWindow::DidYouKnowWindow():
- Window(_("Did You Know?"), false, nullptr, "didyouknow.xml")
+ Window(_("Did You Know?"), false, nullptr, "didyouknow.xml"),
+ ActionListener(),
+ mBrowserBox(new BrowserBox),
+ mScrollArea(new ScrollArea(mBrowserBox,
+ true, "didyouknow_background.xml"))
{
setMinWidth(300);
setMinHeight(250);
@@ -61,10 +65,7 @@ DidYouKnowWindow::DidYouKnowWindow():
setDefaultSize(500, 400, ImageRect::CENTER);
- mBrowserBox = new BrowserBox;
mBrowserBox->setOpaque(false);
- mScrollArea = new ScrollArea(mBrowserBox,
- true, "didyouknow_background.xml");
Button *const okButton = new Button(_("Close"), "close", this);
mButtonPrev = new Button(_("< Previous"), "prev", this);
mButtonNext = new Button(_("Next >"), "next", this);
diff --git a/src/gui/editdialog.cpp b/src/gui/editdialog.cpp
index f4a71b47e..cb96adca3 100644
--- a/src/gui/editdialog.cpp
+++ b/src/gui/editdialog.cpp
@@ -35,11 +35,11 @@
EditDialog::EditDialog(const std::string &title, const std::string &msg,
std::string eventOk, const int width,
Window *const parent, const bool modal):
- Window(title, modal, parent, "edit.xml")
+ Window(title, modal, parent, "edit.xml"),
+ ActionListener(),
+ mTextField(new TextField)
{
- mTextField = new TextField;
mTextField->setText(msg);
-
mEventOk = eventOk;
gcn::Button *const okButton = new Button(_("OK"), mEventOk, this);
diff --git a/src/gui/editserverdialog.cpp b/src/gui/editserverdialog.cpp
index 15f4b8ac8..c4d36da74 100644
--- a/src/gui/editserverdialog.cpp
+++ b/src/gui/editserverdialog.cpp
@@ -64,6 +64,17 @@ EditServerDialog::EditServerDialog(ServerDialog *const parent,
ServerInfo server,
const int index) :
Window(_("Edit Server"), true, parent),
+ ActionListener(),
+ KeyListener(),
+ mServerAddressField(new TextField(std::string())),
+ mPortField(new TextField(std::string())),
+ mNameField(new TextField(std::string())),
+ mDescriptionField(new TextField(std::string())),
+ mConnectButton(new Button(_("Connect"), "connect", this)),
+ mOkButton(new Button(_("OK"), "addServer", this)),
+ mCancelButton(new Button(_("Cancel"), "cancel", this)),
+ mTypeListModel(new TypeListModel()),
+ mTypeField(new DropDown(mTypeListModel)),
mServerDialog(parent),
mServer(server),
mIndex(index)
@@ -75,22 +86,11 @@ EditServerDialog::EditServerDialog(ServerDialog *const parent,
Label *const portLabel = new Label(_("Port:"));
Label *const typeLabel = new Label(_("Server type:"));
Label *const descriptionLabel = new Label(_("Description:"));
- mServerAddressField = new TextField(std::string());
- mPortField = new TextField(std::string());
mPortField->setNumeric(true);
mPortField->setRange(1, 65535);
- mTypeListModel = new TypeListModel();
- mTypeField = new DropDown(mTypeListModel);
mTypeField->setSelected(0); // TmwAthena by default for now.
- mNameField = new TextField(std::string());
- mDescriptionField = new TextField(std::string());
-
- mConnectButton = new Button(_("Connect"), "connect", this);
- mOkButton = new Button(_("OK"), "addServer", this);
- mCancelButton = new Button(_("Cancel"), "cancel", this);
-
mServerAddressField->addActionListener(this);
mPortField->addActionListener(this);
diff --git a/src/gui/editserverdialog.h b/src/gui/editserverdialog.h
index 438529865..d66a7b3b7 100644
--- a/src/gui/editserverdialog.h
+++ b/src/gui/editserverdialog.h
@@ -104,8 +104,8 @@ class EditServerDialog : public Window,
Button *mOkButton;
Button *mCancelButton;
- DropDown *mTypeField;
TypeListModel *mTypeListModel;
+ DropDown *mTypeField;
ServerDialog *mServerDialog;
ServerInfo mServer;
diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp
index e6cb2b9a8..1265d2119 100644
--- a/src/gui/equipmentwindow.cpp
+++ b/src/gui/equipmentwindow.cpp
@@ -57,18 +57,20 @@ EquipmentWindow::EquipmentWindow(Equipment *const equipment,
Being *const being,
const bool foring):
Window(_("Equipment"), false, nullptr, "equipment.xml"),
+ ActionListener(),
mEquipment(equipment),
+ mItemPopup(new ItemPopup),
+ mPlayerBox(new PlayerBox("equipment_playerbox.xml")),
+ mUnequip(new Button(_("Unequip"), "unequip", this)),
mSelected(-1),
mForing(foring),
- mImageSet(nullptr)
+ mImageSet(nullptr),
+ mBeing(being)
{
- mBeing = being;
- mItemPopup = new ItemPopup;
if (setupWindow)
setupWindow->registerWindowForReset(this);
// Control that shows the Player
- mPlayerBox = new PlayerBox("equipment_playerbox.xml");
mPlayerBox->setDimension(gcn::Rectangle(50, 80, 74, 168));
mPlayerBox->setPlayer(being);
@@ -91,7 +93,6 @@ EquipmentWindow::EquipmentWindow(Equipment *const equipment,
loadWindowState();
- mUnequip = new Button(_("Unequip"), "unequip", this);
const gcn::Rectangle &area = getChildrenArea();
const int buttonPadding = getOption("buttonPadding", 5);
mUnequip->setPosition(area.width - mUnequip->getWidth() - buttonPadding,
diff --git a/src/gui/equipmentwindow.h b/src/gui/equipmentwindow.h
index 3d865165d..c30d04504 100644
--- a/src/gui/equipmentwindow.h
+++ b/src/gui/equipmentwindow.h
@@ -97,11 +97,11 @@ class EquipmentWindow : public Window, public gcn::ActionListener
void resetBeing(const Being *const being);
- private:
void mouseExited(gcn::MouseEvent &event);
void mouseMoved(gcn::MouseEvent &event);
+ private:
Item *getItem(const int x, const int y) const;
void setSelected(const int index);
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index ae2c38d15..237c867bf 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -74,7 +74,9 @@ class GuiConfigListener : public ConfigListener
Gui *mGui;
};
-Gui::Gui(Graphics *const graphics):
+Gui::Gui(Graphics *const graphics) :
+ gcn::Gui(),
+ mConfigListener(new GuiConfigListener(this)),
mCustomCursor(false),
mMouseCursors(nullptr),
mMouseCursorAlpha(1.0f),
@@ -218,7 +220,6 @@ Gui::Gui(Graphics *const graphics):
// Initialize mouse cursor and listen for changes to the option
setUseCustomCursor(config.getBoolValue("customcursor"));
- mConfigListener = new GuiConfigListener(this);
config.addListener("customcursor", mConfigListener);
}
diff --git a/src/gui/helpwindow.cpp b/src/gui/helpwindow.cpp
index 1099aec3d..61bd54c8c 100644
--- a/src/gui/helpwindow.cpp
+++ b/src/gui/helpwindow.cpp
@@ -45,7 +45,10 @@
#include "debug.h"
HelpWindow::HelpWindow():
- Window(_("Help"), false, nullptr, "help.xml")
+ Window(_("Help"), false, nullptr, "help.xml"),
+ ActionListener(),
+ mBrowserBox(new BrowserBox),
+ mScrollArea(new ScrollArea(mBrowserBox, true, "help_background.xml"))
{
setMinWidth(300);
setMinHeight(250);
@@ -58,9 +61,7 @@ HelpWindow::HelpWindow():
setDefaultSize(500, 400, ImageRect::CENTER);
- mBrowserBox = new BrowserBox;
mBrowserBox->setOpaque(false);
- mScrollArea = new ScrollArea(mBrowserBox, true, "help_background.xml");
Button *const okButton = new Button(_("Close"), "close", this);
mBrowserBox->setLinkHandler(this);
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index 67faedbad..0f1a0ed9e 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -91,8 +91,33 @@ InventoryWindow::WindowList InventoryWindow::instances;
InventoryWindow::InventoryWindow(Inventory *const inventory):
Window("Inventory", false, nullptr, "inventory.xml"),
+ ActionListener(),
+ KeyListener(),
+ SelectionListener(),
+ InventoryListener(),
mInventory(inventory),
+ mUseButton(nullptr),
mDropButton(nullptr),
+ mSplitButton(nullptr),
+ mOutfitButton(nullptr),
+ mShopButton(nullptr),
+ mEquipmentButton(nullptr),
+ mStoreButton(nullptr),
+ mRetrieveButton(nullptr),
+ mCloseButton(nullptr),
+ mWeightLabel(nullptr),
+ mSlotsLabel(new Label(_("Slots:"))),
+ mFilterLabel(new Label(_("Filter:"))),
+ mWeightBar(nullptr),
+ mSlotsBar(new ProgressBar(0.0f, 100, 20, Theme::PROG_INVY_SLOTS)),
+ mFilter(nullptr),
+ mSortModel(new SortListModel()),
+ mSortDropDown(new DropDown(mSortModel, this, "sort")),
+ mNameFilter(new TextField("", true, this, "namefilter", true)),
+ mSortDropDownCell(nullptr),
+ mNameFilterCell(nullptr),
+ mFilterCell(nullptr),
+ mSlotsBarCell(nullptr),
mSplit(false),
mCompactMode(false)
{
@@ -129,21 +154,13 @@ InventoryWindow::InventoryWindow(Inventory *const inventory):
mItems, getOptionBool("showbackground"), "inventory_background.xml");
invenScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
- mSlotsLabel = new Label(_("Slots:"));
- mSlotsBar = new ProgressBar(0.0f, 100, 20, Theme::PROG_INVY_SLOTS);
-
const int size = config.getIntValue("fontSize");
mFilter = new TabStrip("filter_" + getWindowName(), size + 8);
mFilter->addActionListener(this);
mFilter->setActionEventId("tag_");
- mSortModel = new SortListModel();
- mSortDropDown = new DropDown(mSortModel, this, "sort");
mSortDropDown->setSelected(0);
- mFilterLabel = new Label(_("Filter:"));
- mNameFilter = new TextField("", true, this, "namefilter", true);
-
StringVect tags = ItemDB::getTags();
for (unsigned f = 0; f < tags.size(); f ++)
mFilter->addButton(tags[f]);
diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h
index fd86db6ea..04ca2067d 100644
--- a/src/gui/inventorywindow.h
+++ b/src/gui/inventorywindow.h
@@ -162,16 +162,25 @@ class InventoryWindow : public Window,
std::string mWeight, mSlots;
- gcn::Button *mUseButton, *mDropButton, *mSplitButton,
- *mOutfitButton, *mShopButton, *mEquipmentButton,
- *mStoreButton, *mRetrieveButton, *mCloseButton;
-
- gcn::Label *mWeightLabel, *mSlotsLabel, *mFilterLabel;
-
- ProgressBar *mWeightBar, *mSlotsBar;
+ gcn::Button *mUseButton;
+ gcn::Button *mDropButton;
+ gcn::Button *mSplitButton;
+ gcn::Button *mOutfitButton;
+ gcn::Button *mShopButton;
+ gcn::Button *mEquipmentButton;
+ gcn::Button *mStoreButton;
+ gcn::Button *mRetrieveButton;
+ gcn::Button *mCloseButton;
+
+ gcn::Label *mWeightLabel;
+ gcn::Label *mSlotsLabel;
+ gcn::Label *mFilterLabel;
+
+ ProgressBar *mWeightBar;
+ ProgressBar *mSlotsBar;
TabStrip *mFilter;
- DropDown *mSortDropDown;
SortListModel *mSortModel;
+ DropDown *mSortDropDown;
TextField *mNameFilter;
LayoutCell *mSortDropDownCell;
LayoutCell *mNameFilterCell;
diff --git a/src/gui/itemamountwindow.cpp b/src/gui/itemamountwindow.cpp
index d950a1dd4..98fe9582a 100644
--- a/src/gui/itemamountwindow.cpp
+++ b/src/gui/itemamountwindow.cpp
@@ -136,13 +136,21 @@ void ItemAmountWindow::finish(Item *const item, const int amount,
ItemAmountWindow::ItemAmountWindow(const Usage usage, Window *const parent,
Item *const item, const int maxRange) :
Window("", true, parent, "amount.xml"),
+ ActionListener(),
+ KeyListener(),
+ mItemAmountTextField(new IntTextField(1)),
mItemPriceTextField(nullptr),
mGPLabel(nullptr),
mItem(item),
+ mItemIcon(new Icon(item->getImage())),
mMax(maxRange),
mUsage(usage),
+ mItemPopup(new ItemPopup),
+ mItemAmountSlide(new Slider(1.0, mMax)),
mItemPriceSlide(nullptr),
+ mItemDropDown(nullptr),
mItemsModal(nullptr),
+ mEnabledKeyboard(keyboard.isEnabled()),
mPrice(0)
{
if (!mItem)
@@ -156,17 +164,14 @@ ItemAmountWindow::ItemAmountWindow(const Usage usage, Window *const parent,
mMax = mItem->getQuantity();
// Save keyboard state
- mEnabledKeyboard = keyboard.isEnabled();
keyboard.setEnabled(false);
// Integer field
- mItemAmountTextField = new IntTextField(1);
mItemAmountTextField->setRange(1, mMax);
mItemAmountTextField->setWidth(35);
mItemAmountTextField->addKeyListener(this);
// Slider
- mItemAmountSlide = new Slider(1.0, mMax);
mItemAmountSlide->setHeight(10);
mItemAmountSlide->setActionEventId("slide");
mItemAmountSlide->addActionListener(this);
@@ -196,9 +201,6 @@ ItemAmountWindow::ItemAmountWindow(const Usage usage, Window *const parent,
mItemDropDown->addActionListener(this);
}
- //Item icon
- Image *const image = item->getImage();
- mItemIcon = new Icon(image);
// Buttons
Button *const minusAmountButton = new Button(_("-"), "dec", this);
@@ -284,7 +286,6 @@ ItemAmountWindow::ItemAmountWindow(const Usage usage, Window *const parent,
setLocationRelativeTo(getParentWindow());
setVisible(true);
- mItemPopup = new ItemPopup;
mItemIcon->addMouseListener(this);
}
diff --git a/src/gui/killstats.cpp b/src/gui/killstats.cpp
index f5c73fe88..3ce85db33 100644
--- a/src/gui/killstats.cpp
+++ b/src/gui/killstats.cpp
@@ -41,13 +41,50 @@
KillStats::KillStats():
Window(_("Kill stats"), false, nullptr, "killstats.xml"),
- mKillCounter(0), mExpCounter(0),
- mKillTCounter(0), mExpTCounter(0), mKillTimer(0),
- m1minExpTime(0), m1minExpNum(0), m1minSpeed(0),
- m5minExpTime(0), m5minExpNum(0), m5minSpeed(0),
- m15minExpTime(0), m15minExpNum(0), m15minSpeed(0),
- mJackoSpawnTime(0), mValidateJackoTime(0), mJackoId(0),
- mIsJackoAlive(false), mIsJackoMustSpawn(true),
+ ActionListener(),
+ mKillCounter(0),
+ mExpCounter(0),
+ mKillTCounter(0),
+ mExpTCounter(0),
+ mKillTimer(0),
+ mResetButton(new Button(_("Reset stats"), "reset", this)),
+ mTimerButton(new Button(_("Reset timer"), "timer", this)),
+ mLine4(new Label(strprintf(_("Kills: %s, total exp: %s"), "?", "?"))),
+ mLine5(new Label(strprintf(_("Avg Exp: %s"), "?"))),
+ mLine6(new Label(strprintf(_("No. of avg mob to next level: %s"), "?"))),
+ mLine7(new Label(strprintf(_("Kills/Min: %s, Exp/Min: %s"), "?", "?"))),
+ mExpSpeed1Label(new Label(strprintf(ngettext("Exp speed per %d min: %s",
+ "Exp speed per %d min: %s", 1), 1, "?"))),
+ mExpTime1Label(new Label(strprintf(ngettext(
+ "Time for next level per %d min: %s",
+ "Time for next level per %d min: %s", 1), 1, "?"))),
+ mExpSpeed5Label(new Label(strprintf(ngettext("Exp speed per %d min: %s",
+ "Exp speed per %d min: %s", 5), 5, "?"))),
+ mExpTime5Label(new Label(strprintf(ngettext(
+ "Time for next level per %d min: %s",
+ "Time for next level per %d min: %s", 5), 5, "?"))),
+ mExpSpeed15Label(new Label(strprintf(ngettext("Exp speed per %d min: %s",
+ "Exp speed per %d min: %s", 15), 15, "?"))),
+ mExpTime15Label(new Label(strprintf(ngettext(
+ "Time for next level per %d min: %s",
+ "Time for next level per %d min: %s", 15), 15, "?"))),
+ mLastKillExpLabel(new Label(strprintf("%s ?", _("Last kill exp:")))),
+ mTimeBeforeJackoLabel(new Label(strprintf(
+ "%s ?", _("Time before jacko spawn:")))),
+ m1minExpTime(0),
+ m1minExpNum(0),
+ m1minSpeed(0),
+ m5minExpTime(0),
+ m5minExpNum(0),
+ m5minSpeed(0),
+ m15minExpTime(0),
+ m15minExpNum(0),
+ m15minSpeed(0),
+ mJackoSpawnTime(0),
+ mValidateJackoTime(0),
+ mJackoId(0),
+ mIsJackoAlive(false),
+ mIsJackoMustSpawn(true),
mIsJackoSpawnTimeUnknown(true)
{
setWindowName("Kill stats");
@@ -61,8 +98,6 @@ KillStats::KillStats():
const int xp(PlayerInfo::getAttribute(PlayerInfo::EXP));
int xpNextLevel(PlayerInfo::getAttribute(PlayerInfo::EXP_NEEDED));
- mResetButton = new Button(_("Reset stats"), "reset", this);
- mTimerButton = new Button(_("Reset timer"), "timer", this);
if (!xpNextLevel)
xpNextLevel = 1;
@@ -76,31 +111,6 @@ KillStats::KillStats():
mLine3 = new Label(strprintf(_("1%% = %d exp, avg mob for 1%%: %s"),
xpNextLevel / 100, "?"));
- mLine4 = new Label(strprintf(_("Kills: %s, total exp: %s"), "?", "?"));
- mLine5 = new Label(strprintf(_("Avg Exp: %s"), "?"));
- mLine6 = new Label(strprintf(_("No. of avg mob to next level: %s"), "?"));
- mLine7 = new Label(strprintf(_("Kills/Min: %s, Exp/Min: %s"), "?", "?"));
-
- mExpSpeed1Label = new Label(strprintf(ngettext("Exp speed per %d min: %s",
- "Exp speed per %d min: %s", 1), 1, "?"));
- mExpTime1Label = new Label(strprintf(ngettext(
- "Time for next level per %d min: %s",
- "Time for next level per %d min: %s", 1), 1, "?"));
- mExpSpeed5Label = new Label(strprintf(ngettext("Exp speed per %d min: %s",
- "Exp speed per %d min: %s", 5), 5, "?"));
- mExpTime5Label = new Label(strprintf(ngettext(
- "Time for next level per %d min: %s",
- "Time for next level per %d min: %s", 5), 5, "?"));
- mExpSpeed15Label = new Label(strprintf(ngettext("Exp speed per %d min: %s",
- "Exp speed per %d min: %s", 15), 15, "?"));
- mExpTime15Label = new Label(strprintf(ngettext(
- "Time for next level per %d min: %s",
- "Time for next level per %d min: %s", 15), 15, "?"));
-
- mLastKillExpLabel = new Label(strprintf("%s ?", _("Last kill exp:")));
- mTimeBeforeJackoLabel = new Label(strprintf(
- "%s ?", _("Time before jacko spawn:")));
-
place(0, 0, mLine1, 6).setPadding(0);
place(0, 1, mLine2, 6).setPadding(0);
place(0, 2, mLine3, 6).setPadding(0);
diff --git a/src/gui/logindialog.cpp b/src/gui/logindialog.cpp
index e105911e8..4f0325a1d 100644
--- a/src/gui/logindialog.cpp
+++ b/src/gui/logindialog.cpp
@@ -110,7 +110,25 @@ class UpdateListModel : public gcn::ListModel
LoginDialog::LoginDialog(LoginData *const data, std::string serverName,
std::string *const updateHost):
Window(_("Login"), false, nullptr, "login.xml"),
+ ActionListener(),
+ KeyListener(),
mLoginData(data),
+ mUserField(new TextField(mLoginData->username)),
+ mPassField(new PasswordField(mLoginData->password)),
+ mKeepCheck(new CheckBox(_("Remember username"), mLoginData->remember)),
+ mUpdateTypeLabel(new Label(_("Update:"))),
+ mUpdateHostLabel(nullptr),
+ mUpdateTypeModel(new UpdateTypeModel()),
+ mUpdateTypeDropDown(new DropDown(mUpdateTypeModel)),
+ mServerButton(new Button(_("Change Server"), "server", this)),
+ mLoginButton(new Button(_("Login"), "login", this)),
+ mRegisterButton(new Button(_("Register"), "register", this)),
+ mCustomUpdateHost(new CheckBox(_("Custom update host"),
+ mLoginData->updateType & LoginData::Upd_Custom, this, "customhost")),
+ mUpdateHostText(new TextField(serverConfig.getValue(
+ "customUpdateHost", ""))),
+ mUpdateListModel(nullptr),
+ mUpdateHostDropDown(nullptr),
mUpdateHost(updateHost),
mServerName(serverName)
{
@@ -136,25 +154,11 @@ LoginDialog::LoginDialog(LoginData *const data, std::string serverName,
mUpdateListModel = nullptr;
mUpdateHostDropDown = nullptr;
}
-
- mCustomUpdateHost = new CheckBox(_("Custom update host"),
- mLoginData->updateType & LoginData::Upd_Custom, this, "customhost");
-
- mUpdateHostText = new TextField(serverConfig.getValue(
- "customUpdateHost", ""));
-
mUpdateHostText->adjustSize();
- mUserField = new TextField(mLoginData->username);
- mPassField = new PasswordField(mLoginData->password);
-
if (mPassField->getText().empty() && LoginDialog::savedPassword != "")
mPassField->setText(LoginDialog::savedPassword);
- mKeepCheck = new CheckBox(_("Remember username"), mLoginData->remember);
- mUpdateTypeLabel = new Label(_("Update:"));
- mUpdateTypeModel = new UpdateTypeModel();
- mUpdateTypeDropDown = new DropDown(mUpdateTypeModel);
mUpdateTypeDropDown->setActionEventId("updatetype");
mUpdateTypeDropDown->setSelected((mLoginData->updateType
| LoginData::Upd_Custom) ^ LoginData::Upd_Custom);
@@ -162,10 +166,6 @@ LoginDialog::LoginDialog(LoginData *const data, std::string serverName,
if (!mCustomUpdateHost->isSelected())
mUpdateHostText->setVisible(false);
- mRegisterButton = new Button(_("Register"), "register", this);
- mServerButton = new Button(_("Change Server"), "server", this);
- mLoginButton = new Button(_("Login"), "login", this);
-
mUserField->setActionEventId("login");
mPassField->setActionEventId("login");
diff --git a/src/gui/logindialog.h b/src/gui/logindialog.h
index d85e88b8a..e2c882ee4 100644
--- a/src/gui/logindialog.h
+++ b/src/gui/logindialog.h
@@ -84,11 +84,14 @@ class LoginDialog : public Window, public gcn::ActionListener,
*/
bool canSubmit() const;
+ LoginData *mLoginData;
+
gcn::TextField *mUserField;
gcn::TextField *mPassField;
gcn::CheckBox *mKeepCheck;
gcn::Label *mUpdateTypeLabel;
gcn::Label *mUpdateHostLabel;
+ UpdateTypeModel *mUpdateTypeModel;
DropDown *mUpdateTypeDropDown;
gcn::Button *mServerButton;
gcn::Button *mLoginButton;
@@ -98,9 +101,7 @@ class LoginDialog : public Window, public gcn::ActionListener,
UpdateListModel *mUpdateListModel;
DropDown *mUpdateHostDropDown;
- LoginData *mLoginData;
std::string *mUpdateHost;
- UpdateTypeModel *mUpdateTypeModel;
std::string mServerName;
};
diff --git a/src/gui/ministatuswindow.cpp b/src/gui/ministatuswindow.cpp
index 2c4fdda9c..9f9f63a86 100644
--- a/src/gui/ministatuswindow.cpp
+++ b/src/gui/ministatuswindow.cpp
@@ -50,12 +50,27 @@
extern volatile int tick_time;
-MiniStatusWindow::MiniStatusWindow():
- Popup("MiniStatus", "ministatus.xml")
+MiniStatusWindow::MiniStatusWindow() :
+ Popup("MiniStatus", "ministatus.xml"),
+ InventoryListener(),
+ mHpBar(createBar(0, 100, 20, Theme::PROG_HP, "hp bar", _("health bar"))),
+ mXpBar(createBar(0, 100, 20, Theme::PROG_EXP,
+ "xp bar", _("experience bar"))),
+ mWeightBar(createBar(0, 140, 20, Theme::PROG_WEIGHT,
+ "weight bar", _("weight bar"))),
+ mInvSlotsBar(createBar(0, 45, 20, Theme::PROG_INVY_SLOTS,
+ "inventory slots bar", _("inventory slots bar"))),
+ mMoneyBar(createBar(0, 130, 20, Theme::PROG_INVY_SLOTS,
+ "money bar", _("money bar"))),
+ mArrowsBar(createBar(0, 50, 20, Theme::PROG_INVY_SLOTS,
+ "arrows bar", _("arrows bar"))),
+ mStatusBar(createBar(100, 165, 20, Theme::PROG_EXP,
+ "status bar", _("status bar"))),
+ mTextPopup(new TextPopup),
+ mStatusPopup(new StatusPopup)
{
listen(CHANNEL_ATTRIBUTES);
- mHpBar = createBar(0, 100, 20, Theme::PROG_HP, "hp bar", _("health bar"));
StatusWindow::updateHPBar(mHpBar);
if (Net::getGameHandler()->canUseMagicBar())
@@ -72,8 +87,6 @@ MiniStatusWindow::MiniStatusWindow():
const int job = Net::getPlayerHandler()->getJobLocation()
&& serverConfig.getValueBool("showJob", false);
- mXpBar = createBar(0, 100, 20, Theme::PROG_EXP,
- "xp bar", _("experience bar"));
StatusWindow::updateXPBar(mXpBar);
if (job)
@@ -87,29 +100,10 @@ MiniStatusWindow::MiniStatusWindow():
mJobBar = nullptr;
}
- mWeightBar = createBar(0, 140, 20, Theme::PROG_WEIGHT,
- "weight bar", _("weight bar"));
-
- mInvSlotsBar = createBar(0, 45, 20, Theme::PROG_INVY_SLOTS,
- "inventory slots bar", _("inventory slots bar"));
-
- mMoneyBar = createBar(0, 130, 20, Theme::PROG_INVY_SLOTS,
- "money bar", _("money bar"));
-
- mArrowsBar = createBar(0, 50, 20, Theme::PROG_INVY_SLOTS,
- "arrows bar", _("arrows bar"));
-
- mStatusBar = createBar(100, 165, 20, Theme::PROG_EXP,
- "status bar", _("status bar"));
-
loadBars();
updateBars();
setVisible(config.getValueBool(getPopupName() + "Visible", true));
-
- mStatusPopup = new StatusPopup();
- mTextPopup = new TextPopup();
-
addMouseListener(this);
Inventory *const inv = PlayerInfo::getInventory();
if (inv)
diff --git a/src/gui/ministatuswindow.h b/src/gui/ministatuswindow.h
index d67cf8b03..cba3c3c4c 100644
--- a/src/gui/ministatuswindow.h
+++ b/src/gui/ministatuswindow.h
@@ -95,6 +95,10 @@ class MiniStatusWindow : public Popup,
void saveBars();
+ std::vector <ProgressBar*> mBars;
+ std::map <std::string, ProgressBar*> mBarNames;
+ std::vector<AnimatedSprite *> mIcons;
+
/*
* Mini Status Bars
*/
@@ -109,10 +113,6 @@ class MiniStatusWindow : public Popup,
ProgressBar *mStatusBar;
TextPopup *mTextPopup;
StatusPopup *mStatusPopup;
- std::vector <ProgressBar*> mBars;
- std::map <std::string, ProgressBar*> mBarNames;
-
- std::vector<AnimatedSprite *> mIcons;
};
extern MiniStatusWindow *miniStatusWindow;