summaryrefslogtreecommitdiff
path: root/src/gui/windows
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-03-01 19:13:11 +0300
committerAndrei Karas <akaras@inbox.ru>2014-03-01 19:13:11 +0300
commita260aeab234704ace8ba672b1d1ce57e18425e07 (patch)
treee215c6eeeae7e6c2ca4f4453718cef6ca9a8af6a /src/gui/windows
parent382067b05c4fe97bcf0da0143405375ec295f7c6 (diff)
parent2c62286a7ecf246e8a445dd7d00f618efae2a96a (diff)
downloadplus-a260aeab234704ace8ba672b1d1ce57e18425e07.tar.gz
plus-a260aeab234704ace8ba672b1d1ce57e18425e07.tar.bz2
plus-a260aeab234704ace8ba672b1d1ce57e18425e07.tar.xz
plus-a260aeab234704ace8ba672b1d1ce57e18425e07.zip
Merge branch 'master' into stable
Diffstat (limited to 'src/gui/windows')
-rw-r--r--src/gui/windows/botcheckerwindow.cpp24
-rw-r--r--src/gui/windows/botcheckerwindow.h10
-rw-r--r--src/gui/windows/buydialog.cpp61
-rw-r--r--src/gui/windows/buydialog.h13
-rw-r--r--src/gui/windows/buyselldialog.cpp6
-rw-r--r--src/gui/windows/buyselldialog.h7
-rw-r--r--src/gui/windows/changeemaildialog.cpp4
-rw-r--r--src/gui/windows/changeemaildialog.h7
-rw-r--r--src/gui/windows/changepassworddialog.cpp4
-rw-r--r--src/gui/windows/changepassworddialog.h7
-rw-r--r--src/gui/windows/charcreatedialog.cpp39
-rw-r--r--src/gui/windows/charcreatedialog.h16
-rw-r--r--src/gui/windows/charselectdialog.cpp30
-rw-r--r--src/gui/windows/charselectdialog.h15
-rw-r--r--src/gui/windows/chatwindow.cpp97
-rw-r--r--src/gui/windows/chatwindow.h30
-rw-r--r--src/gui/windows/confirmdialog.cpp6
-rw-r--r--src/gui/windows/confirmdialog.h7
-rw-r--r--src/gui/windows/connectiondialog.cpp8
-rw-r--r--src/gui/windows/connectiondialog.h9
-rw-r--r--src/gui/windows/debugwindow.cpp17
-rw-r--r--src/gui/windows/debugwindow.h6
-rw-r--r--src/gui/windows/didyouknowwindow.cpp15
-rw-r--r--src/gui/windows/didyouknowwindow.h8
-rw-r--r--src/gui/windows/editdialog.cpp4
-rw-r--r--src/gui/windows/editdialog.h7
-rw-r--r--src/gui/windows/editserverdialog.cpp63
-rw-r--r--src/gui/windows/editserverdialog.h48
-rw-r--r--src/gui/windows/emotewindow.cpp15
-rw-r--r--src/gui/windows/emotewindow.h6
-rw-r--r--src/gui/windows/equipmentwindow.cpp68
-rw-r--r--src/gui/windows/equipmentwindow.h25
-rw-r--r--src/gui/windows/helpwindow.cpp16
-rw-r--r--src/gui/windows/helpwindow.h11
-rw-r--r--src/gui/windows/inventorywindow.cpp100
-rw-r--r--src/gui/windows/inventorywindow.h34
-rw-r--r--src/gui/windows/itemamountwindow.cpp67
-rw-r--r--src/gui/windows/itemamountwindow.h16
-rw-r--r--src/gui/windows/killstats.cpp4
-rw-r--r--src/gui/windows/killstats.h9
-rw-r--r--src/gui/windows/logindialog.cpp93
-rw-r--r--src/gui/windows/logindialog.h13
-rw-r--r--src/gui/windows/minimap.cpp34
-rw-r--r--src/gui/windows/minimap.h8
-rw-r--r--src/gui/windows/ministatuswindow.cpp18
-rw-r--r--src/gui/windows/ministatuswindow.h13
-rw-r--r--src/gui/windows/npcdialog.cpp20
-rw-r--r--src/gui/windows/npcdialog.h14
-rw-r--r--src/gui/windows/npcpostdialog.cpp8
-rw-r--r--src/gui/windows/npcpostdialog.h6
-rw-r--r--src/gui/windows/okdialog.cpp6
-rw-r--r--src/gui/windows/okdialog.h6
-rw-r--r--src/gui/windows/outfitwindow.cpp35
-rw-r--r--src/gui/windows/outfitwindow.h18
-rw-r--r--src/gui/windows/questswindow.cpp30
-rw-r--r--src/gui/windows/questswindow.h6
-rw-r--r--src/gui/windows/quitdialog.cpp18
-rw-r--r--src/gui/windows/quitdialog.h13
-rw-r--r--src/gui/windows/registerdialog.cpp22
-rw-r--r--src/gui/windows/registerdialog.h16
-rw-r--r--src/gui/windows/selldialog.cpp33
-rw-r--r--src/gui/windows/selldialog.h12
-rw-r--r--src/gui/windows/serverdialog.cpp118
-rw-r--r--src/gui/windows/serverdialog.h67
-rw-r--r--src/gui/windows/setupwindow.cpp15
-rw-r--r--src/gui/windows/setupwindow.h8
-rw-r--r--src/gui/windows/shopwindow.cpp15
-rw-r--r--src/gui/windows/shopwindow.h12
-rw-r--r--src/gui/windows/shortcutwindow.cpp17
-rw-r--r--src/gui/windows/shortcutwindow.h8
-rw-r--r--src/gui/windows/skilldialog.cpp50
-rw-r--r--src/gui/windows/skilldialog.h9
-rw-r--r--src/gui/windows/socialwindow.cpp130
-rw-r--r--src/gui/windows/socialwindow.h11
-rw-r--r--src/gui/windows/statuswindow.cpp16
-rw-r--r--src/gui/windows/statuswindow.h8
-rw-r--r--src/gui/windows/textcommandeditor.cpp135
-rw-r--r--src/gui/windows/textcommandeditor.h11
-rw-r--r--src/gui/windows/textdialog.cpp8
-rw-r--r--src/gui/windows/textdialog.h7
-rw-r--r--src/gui/windows/tradewindow.cpp23
-rw-r--r--src/gui/windows/tradewindow.h12
-rw-r--r--src/gui/windows/unregisterdialog.cpp4
-rw-r--r--src/gui/windows/unregisterdialog.h7
-rw-r--r--src/gui/windows/updaterwindow.cpp25
-rw-r--r--src/gui/windows/updaterwindow.h14
-rw-r--r--src/gui/windows/whoisonline.cpp20
-rw-r--r--src/gui/windows/whoisonline.h12
-rw-r--r--src/gui/windows/worldselectdialog.cpp60
-rw-r--r--src/gui/windows/worldselectdialog.h13
90 files changed, 808 insertions, 1408 deletions
diff --git a/src/gui/windows/botcheckerwindow.cpp b/src/gui/windows/botcheckerwindow.cpp
index b94093ebb..d1fc0e7bd 100644
--- a/src/gui/windows/botcheckerwindow.cpp
+++ b/src/gui/windows/botcheckerwindow.cpp
@@ -101,7 +101,7 @@ public:
freeWidgets();
mPlayers.clear();
if (actorManager && botCheckerWindow
- && botCheckerWindow->mEnabled)
+ && botCheckerWindow->mBotcheckerEnabled)
{
std::set<ActorSprite*> beings = actorManager->getAll();
FOR_EACH (ActorSprites::iterator, i, beings)
@@ -125,7 +125,7 @@ public:
continue;
const Being *const player = mPlayers.at(r);
- gcn::Widget *widget = new Label(this, player->getName());
+ Widget *widget = new Label(this, player->getName());
mWidgets.push_back(widget);
@@ -235,14 +235,14 @@ public:
{
}
- gcn::Widget *getElementAt(const int row, const int column) const
+ Widget *getElementAt(const int row, const int column) const
{
return mWidgets[WIDGET_AT(row, column)];
}
void freeWidgets()
{
- for (std::vector<gcn::Widget *>::const_iterator it = mWidgets.begin();
+ for (std::vector<Widget *>::const_iterator it = mWidgets.begin();
it != mWidgets.end(); ++it)
{
delete *it;
@@ -253,17 +253,17 @@ public:
protected:
std::vector<Being*> mPlayers;
- std::vector<gcn::Widget*> mWidgets;
+ std::vector<Widget*> mWidgets;
};
BotCheckerWindow::BotCheckerWindow():
// TRANSLATORS: bot checker window header
Window(_("Bot Checker"), false, nullptr, "botchecker.xml"),
- gcn::ActionListener(),
+ ActionListener(),
mTableModel(new UsersTableModel(this)),
mTable(new GuiTable(this, mTableModel)),
- playersScrollArea(new ScrollArea(mTable, true,
+ playersScrollArea(new ScrollArea(this, mTable, true,
"bochecker_background.xml")),
mPlayerTableTitleModel(new StaticTableModel(1, COLUMNS_NR)),
mPlayerTitleTable(new GuiTable(this, mPlayerTableTitleModel)),
@@ -271,7 +271,7 @@ BotCheckerWindow::BotCheckerWindow():
mIncButton(new Button(this, _("Reset"), "reset", this)),
mLastUpdateTime(0),
mNeedUpdate(false),
- mEnabled(false)
+ mBotcheckerEnabled(false)
{
const int w = 500;
const int h = 250;
@@ -346,7 +346,7 @@ BotCheckerWindow::BotCheckerWindow():
enableVisibleSound(true);
config.addListener("enableBotCheker", this);
- mEnabled = config.getBoolValue("enableBotCheker");
+ mBotcheckerEnabled = config.getBoolValue("enableBotCheker");
}
BotCheckerWindow::~BotCheckerWindow()
@@ -358,7 +358,7 @@ BotCheckerWindow::~BotCheckerWindow()
void BotCheckerWindow::slowLogic()
{
BLOCK_START("BotCheckerWindow::slowLogic")
- if (mEnabled && mTableModel)
+ if (mBotcheckerEnabled && mTableModel)
{
const unsigned int nowTime = cur_time;
if (nowTime - mLastUpdateTime > 5 && mNeedUpdate)
@@ -377,7 +377,7 @@ void BotCheckerWindow::slowLogic()
BLOCK_END("BotCheckerWindow::slowLogic")
}
-void BotCheckerWindow::action(const gcn::ActionEvent &event)
+void BotCheckerWindow::action(const ActionEvent &event)
{
if (event.getId() == "reset")
{
@@ -417,7 +417,7 @@ void BotCheckerWindow::reset()
void BotCheckerWindow::optionChanged(const std::string &name)
{
if (name == "enableBotCheker")
- mEnabled = config.getBoolValue("enableBotCheker");
+ mBotcheckerEnabled = config.getBoolValue("enableBotCheker");
}
#ifdef USE_PROFILER
diff --git a/src/gui/windows/botcheckerwindow.h b/src/gui/windows/botcheckerwindow.h
index d3615957d..0c86b13b0 100644
--- a/src/gui/windows/botcheckerwindow.h
+++ b/src/gui/windows/botcheckerwindow.h
@@ -23,11 +23,11 @@
#ifndef GUI_BOTCHECKERWINDOW_H
#define GUI_BOTCHECKERWINDOW_H
-#include "configlistener.h"
+#include "listeners/configlistener.h"
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
struct BOTCHK final
{
@@ -43,7 +43,7 @@ class UsersTableModel;
class StaticTableModel;
class BotCheckerWindow final : public Window,
- public gcn::ActionListener,
+ public ActionListener,
public ConfigListener
{
public:
@@ -61,7 +61,7 @@ class BotCheckerWindow final : public Window,
*/
~BotCheckerWindow();
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
void update();
@@ -86,7 +86,7 @@ class BotCheckerWindow final : public Window,
Button *mIncButton;
int mLastUpdateTime;
bool mNeedUpdate;
- bool mEnabled;
+ bool mBotcheckerEnabled;
};
extern BotCheckerWindow *botCheckerWindow;
diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp
index cfefa8159..c2514a15d 100644
--- a/src/gui/windows/buydialog.cpp
+++ b/src/gui/windows/buydialog.cpp
@@ -28,13 +28,15 @@
#include "gui/windows/tradewindow.h"
+#include "gui/models/shopitems.h"
+#include "gui/models/sortlistmodelbuy.h"
+
#include "gui/widgets/button.h"
#include "gui/widgets/dropdown.h"
#include "gui/widgets/inttextfield.h"
#include "gui/widgets/label.h"
#include "gui/widgets/layout.h"
#include "gui/widgets/scrollarea.h"
-#include "gui/widgets/shopitems.h"
#include "gui/widgets/shoplistbox.h"
#include "gui/widgets/slider.h"
@@ -51,41 +53,6 @@
#include "debug.h"
-static const char *const SORT_NAME_BUY[7] =
-{
- // TRANSLATORS: buy dialog sort type.
- N_("unsorted"),
- // TRANSLATORS: buy dialog sort type.
- N_("by price"),
- // TRANSLATORS: buy dialog sort type.
- N_("by name"),
- // TRANSLATORS: buy dialog sort type.
- N_("by id"),
- // TRANSLATORS: buy dialog sort type.
- N_("by weight"),
- // TRANSLATORS: buy dialog sort type.
- N_("by amount"),
- // TRANSLATORS: buy dialog sort type.
- N_("by type")
-};
-
-class SortListModelBuy final : public gcn::ListModel
-{
-public:
- ~SortListModelBuy()
- { }
-
- int getNumberOfElements()
- { return 7; }
-
- std::string getElementAt(int i)
- {
- if (i >= getNumberOfElements() || i < 0)
- return "???";
- return gettext(SORT_NAME_BUY[i]);
- }
-};
-
class SortItemPriceFunctor final
{
public:
@@ -193,8 +160,8 @@ BuyDialog::DialogList BuyDialog::instances;
BuyDialog::BuyDialog() :
// TRANSLATORS: buy dialog name
Window(_("Create items"), false, nullptr, "buy.xml"),
- gcn::ActionListener(),
- gcn::SelectionListener(),
+ ActionListener(),
+ SelectionListener(),
mNpcId(-2), mMoney(0), mAmountItems(0), mMaxItems(0), mNick(),
mSortModel(nullptr),
mSortDropDown(nullptr)
@@ -205,8 +172,8 @@ BuyDialog::BuyDialog() :
BuyDialog::BuyDialog(const int npcId) :
// TRANSLATORS: buy dialog name
Window(_("Buy"), false, nullptr, "buy.xml"),
- gcn::ActionListener(),
- gcn::SelectionListener(),
+ ActionListener(),
+ SelectionListener(),
mNpcId(npcId), mMoney(0), mAmountItems(0), mMaxItems(0), mNick(),
mSortModel(nullptr),
mSortDropDown(nullptr)
@@ -217,8 +184,8 @@ BuyDialog::BuyDialog(const int npcId) :
BuyDialog::BuyDialog(std::string nick) :
// TRANSLATORS: buy dialog name
Window(_("Buy"), false, nullptr, "buy.xml"),
- gcn::ActionListener(),
- gcn::SelectionListener(),
+ ActionListener(),
+ SelectionListener(),
mNpcId(-1), mMoney(0), mAmountItems(0), mMaxItems(0), mNick(nick),
mSortModel(new SortListModelBuy),
mSortDropDown(new DropDown(this, mSortModel, false, false, this, "sort"))
@@ -240,14 +207,14 @@ void BuyDialog::init()
mShopItemList = new ShopListBox(this, mShopItems, mShopItems);
mShopItemList->postInit();
- mScrollArea = new ScrollArea(mShopItemList,
+ mScrollArea = new ScrollArea(this, mShopItemList,
getOptionBool("showbackground"), "buy_background.xml");
mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
- mSlider = new Slider(1.0);
+ mSlider = new Slider(this, 1.0);
mQuantityLabel = new Label(this, strprintf(
"%d / %d", mAmountItems, mMaxItems));
- mQuantityLabel->setAlignment(gcn::Graphics::CENTER);
+ mQuantityLabel->setAlignment(Graphics::CENTER);
// TRANSLATORS: buy dialog label
mMoneyLabel = new Label(this, strprintf(
_("Price: %s / Total: %s"), "", ""));
@@ -388,7 +355,7 @@ void BuyDialog::sort()
}
}
-void BuyDialog::action(const gcn::ActionEvent &event)
+void BuyDialog::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "quit")
@@ -482,7 +449,7 @@ void BuyDialog::action(const gcn::ActionEvent &event)
}
}
-void BuyDialog::valueChanged(const gcn::SelectionEvent &event A_UNUSED)
+void BuyDialog::valueChanged(const SelectionEvent &event A_UNUSED)
{
// Reset amount of items and update labels
mAmountItems = 1;
diff --git a/src/gui/windows/buydialog.h b/src/gui/windows/buydialog.h
index e11317cde..aa163d5d0 100644
--- a/src/gui/windows/buydialog.h
+++ b/src/gui/windows/buydialog.h
@@ -25,8 +25,8 @@
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
-#include <guichan/selectionlistener.hpp>
+#include "listeners/actionlistener.h"
+#include "listeners/selectionlistener.h"
class Button;
class DropDown;
@@ -35,7 +35,6 @@ class ShopListBox;
class SortListModelBuy;
class IntTextField;
class Label;
-class ListBox;
class ScrollArea;
class Slider;
@@ -45,8 +44,8 @@ class Slider;
* \ingroup Interface
*/
class BuyDialog final : public Window,
- public gcn::ActionListener,
- public gcn::SelectionListener
+ public ActionListener,
+ public SelectionListener
{
public:
/**
@@ -98,7 +97,7 @@ class BuyDialog final : public Window,
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
/**
* Returns the number of items in the shop inventory.
@@ -108,7 +107,7 @@ class BuyDialog final : public Window,
/**
* Updates the labels according to the selected item.
*/
- void valueChanged(const gcn::SelectionEvent &event) override final;
+ void valueChanged(const SelectionEvent &event) override final;
/**
* Updates the state of buttons and labels.
diff --git a/src/gui/windows/buyselldialog.cpp b/src/gui/windows/buyselldialog.cpp
index 22f39f449..92f6503bb 100644
--- a/src/gui/windows/buyselldialog.cpp
+++ b/src/gui/windows/buyselldialog.cpp
@@ -37,7 +37,7 @@ BuySellDialog::DialogList BuySellDialog::dialogInstances;
BuySellDialog::BuySellDialog(const int npcId) :
// TRANSLATORS: shop window name
Window(_("Shop"), false, nullptr, "buysell.xml"),
- gcn::ActionListener(),
+ ActionListener(),
mNpcId(npcId),
mNick(""),
mBuyButton(nullptr)
@@ -48,7 +48,7 @@ BuySellDialog::BuySellDialog(const int npcId) :
BuySellDialog::BuySellDialog(const std::string &nick) :
// TRANSLATORS: shop window name
Window(_("Shop"), false, nullptr, "buysell.xml"),
- gcn::ActionListener(),
+ ActionListener(),
mNpcId(-1),
mNick(nick),
mBuyButton(nullptr)
@@ -119,7 +119,7 @@ void BuySellDialog::setVisible(bool visible)
}
}
-void BuySellDialog::action(const gcn::ActionEvent &event)
+void BuySellDialog::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "Buy")
diff --git a/src/gui/windows/buyselldialog.h b/src/gui/windows/buyselldialog.h
index 34a716ee1..a89ff0bea 100644
--- a/src/gui/windows/buyselldialog.h
+++ b/src/gui/windows/buyselldialog.h
@@ -25,7 +25,7 @@
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
class Button;
@@ -34,7 +34,8 @@ class Button;
*
* \ingroup Interface
*/
-class BuySellDialog final : public Window, public gcn::ActionListener
+class BuySellDialog final : public Window,
+ public ActionListener
{
public:
/**
@@ -58,7 +59,7 @@ class BuySellDialog final : public Window, public gcn::ActionListener
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
/**
* Returns true if any instances exist.
diff --git a/src/gui/windows/changeemaildialog.cpp b/src/gui/windows/changeemaildialog.cpp
index a9f3b3449..b8f9c1fd2 100644
--- a/src/gui/windows/changeemaildialog.cpp
+++ b/src/gui/windows/changeemaildialog.cpp
@@ -45,7 +45,7 @@
ChangeEmailDialog::ChangeEmailDialog(LoginData *const data):
// TRANSLATORS: change email dialog header
Window(_("Change Email Address"), true, nullptr, "changeemail.xml"),
- gcn::ActionListener(),
+ ActionListener(),
mFirstEmailField(new TextField(this)),
mSecondEmailField(new TextField(this)),
// TRANSLATORS: button in change email dialog
@@ -109,7 +109,7 @@ ChangeEmailDialog::~ChangeEmailDialog()
mWrongDataNoticeListener = nullptr;
}
-void ChangeEmailDialog::action(const gcn::ActionEvent &event)
+void ChangeEmailDialog::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "cancel")
diff --git a/src/gui/windows/changeemaildialog.h b/src/gui/windows/changeemaildialog.h
index 31ffa7b39..d2928025d 100644
--- a/src/gui/windows/changeemaildialog.h
+++ b/src/gui/windows/changeemaildialog.h
@@ -25,7 +25,7 @@
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
class Button;
class LoginData;
@@ -37,7 +37,8 @@ class WrongDataNoticeListener;
*
* \ingroup Interface
*/
-class ChangeEmailDialog final : public Window, public gcn::ActionListener
+class ChangeEmailDialog final : public Window,
+ public ActionListener
{
public:
/**
@@ -57,7 +58,7 @@ class ChangeEmailDialog final : public Window, public gcn::ActionListener
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
/**
* This is used to pass the pointer to where the new email should be
diff --git a/src/gui/windows/changepassworddialog.cpp b/src/gui/windows/changepassworddialog.cpp
index 4646947fa..05c7a9309 100644
--- a/src/gui/windows/changepassworddialog.cpp
+++ b/src/gui/windows/changepassworddialog.cpp
@@ -46,7 +46,7 @@
ChangePasswordDialog::ChangePasswordDialog(LoginData *const data):
// TRANSLATORS: change password window name
Window(_("Change Password"), true, nullptr, "changepassword.xml"),
- gcn::ActionListener(),
+ ActionListener(),
mOldPassField(new PasswordField(this)),
mFirstPassField(new PasswordField(this)),
mSecondPassField(new PasswordField(this)),
@@ -88,7 +88,7 @@ ChangePasswordDialog::~ChangePasswordDialog()
mWrongDataNoticeListener = nullptr;
}
-void ChangePasswordDialog::action(const gcn::ActionEvent &event)
+void ChangePasswordDialog::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "cancel")
diff --git a/src/gui/windows/changepassworddialog.h b/src/gui/windows/changepassworddialog.h
index ce45e6f47..adbaf109a 100644
--- a/src/gui/windows/changepassworddialog.h
+++ b/src/gui/windows/changepassworddialog.h
@@ -25,7 +25,7 @@
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
class Button;
class LoginData;
@@ -37,7 +37,8 @@ class WrongDataNoticeListener;
*
* \ingroup Interface
*/
-class ChangePasswordDialog final : public Window, public gcn::ActionListener
+class ChangePasswordDialog final : public Window,
+ public ActionListener
{
public:
/**
@@ -57,7 +58,7 @@ class ChangePasswordDialog final : public Window, public gcn::ActionListener
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
private:
TextField *mOldPassField;
diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp
index cbce28db7..a877f45e0 100644
--- a/src/gui/windows/charcreatedialog.cpp
+++ b/src/gui/windows/charcreatedialog.cpp
@@ -24,12 +24,14 @@
#include "main.h"
+#include "events/keyevent.h"
+
#include "input/keydata.h"
-#include "input/keyevent.h"
#include "gui/windows/okdialog.h"
#include "gui/widgets/button.h"
+#include "gui/windows/charselectdialog.h"
#include "gui/widgets/label.h"
#include "gui/widgets/playerbox.h"
#include "gui/widgets/radiobutton.h"
@@ -63,8 +65,8 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent,
const int slot) :
// TRANSLATORS: char create dialog name
Window(_("New Character"), true, parent, "charcreate.xml"),
- gcn::ActionListener(),
- gcn::KeyListener(),
+ ActionListener(),
+ KeyListener(),
mCharSelectDialog(parent),
mNameField(new TextField(this, "")),
// TRANSLATORS: char create dialog label
@@ -123,7 +125,7 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent,
mMaxLook(CharDB::getMaxLook()),
mPlayer(new Being(0, ActorSprite::PLAYER, static_cast<uint16_t>(mRace),
nullptr)),
- mPlayerBox(new PlayerBox(mPlayer, "charcreate_playerbox.xml",
+ mPlayerBox(new PlayerBox(this, mPlayer, "charcreate_playerbox.xml",
"charcreate_selectedplayerbox.xml")),
mHairStyle(0),
mHairColor(0),
@@ -206,13 +208,13 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent,
const int h = 350;
setContentSize(w, h);
- mPlayerBox->setDimension(gcn::Rectangle(360, 0, 110, 90));
+ mPlayerBox->setDimension(Rect(360, 0, 110, 90));
mActionButton->setPosition(385, 100);
mRotateButton->setPosition(415, 100);
mNameLabel->setPosition(5, 2);
mNameField->setDimension(
- gcn::Rectangle(60, 2, 300, mNameField->getHeight()));
+ Rect(60, 2, 300, mNameField->getHeight()));
const int leftX = 120;
const int rightX = 300;
@@ -318,16 +320,12 @@ CharCreateDialog::~CharCreateDialog()
Net::getCharServerHandler()->setCharCreateDialog(nullptr);
}
-void CharCreateDialog::action(const gcn::ActionEvent &event)
+void CharCreateDialog::action(const ActionEvent &event)
{
const std::string id = event.getId();
if (id == "create")
{
- if (
-#ifdef MANASERV_SUPPORT
- Net::getNetworkType() == ServerInfo::MANASERV ||
-#endif
- getName().length() >= 4)
+ if (getName().length() >= 4)
{
// Attempt to create the character
mCreateButton->setEnabled(false);
@@ -339,14 +337,7 @@ void CharCreateDialog::action(const gcn::ActionEvent &event)
mAttributeSlider[i]->getValue()));
}
-#ifdef MANASERV_SUPPORT
- int characterSlot = mSlot;
- // On Manaserv, the slots start at 1, so we offset them.
- if (Net::getNetworkType() == ServerInfo::MANASERV)
- ++characterSlot;
-#else
const int characterSlot = mSlot;
-#endif
Net::getCharServerHandler()->newCharacter(getName(), characterSlot,
mFemale->isSelected(), mHairStyle, mHairColor,
@@ -527,8 +518,8 @@ void CharCreateDialog::setAttributes(const StringVect &labels,
mAttributeLabel[i]->adjustSize();
add(mAttributeLabel[i]);
- mAttributeSlider[i] = new Slider(min, max);
- mAttributeSlider[i]->setDimension(gcn::Rectangle(140, y + i * 24,
+ mAttributeSlider[i] = new Slider(this, min, max);
+ mAttributeSlider[i]->setDimension(Rect(140, y + i * 24,
150, 12));
mAttributeSlider[i]->setActionEventId("statslider");
mAttributeSlider[i]->addActionListener(this);
@@ -664,14 +655,14 @@ void CharCreateDialog::updatePlayer()
}
}
-void CharCreateDialog::keyPressed(gcn::KeyEvent &keyEvent)
+void CharCreateDialog::keyPressed(KeyEvent &keyEvent)
{
- const int actionId = static_cast<KeyEvent*>(&keyEvent)->getActionId();
+ const int actionId = keyEvent.getActionId();
switch (actionId)
{
case Input::KEY_GUI_CANCEL:
keyEvent.consume();
- action(gcn::ActionEvent(mCancelButton,
+ action(ActionEvent(mCancelButton,
mCancelButton->getActionEventId()));
break;
diff --git a/src/gui/windows/charcreatedialog.h b/src/gui/windows/charcreatedialog.h
index 0d73bf805..12ddf7970 100644
--- a/src/gui/windows/charcreatedialog.h
+++ b/src/gui/windows/charcreatedialog.h
@@ -25,11 +25,13 @@
#include "being/being.h"
-#include "gui/windows/charselectdialog.h"
+#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
-#include <guichan/keylistener.hpp>
+#include "listeners/actionlistener.h"
+#include "listeners/keylistener.h"
+class Button;
+class CharSelectDialog;
class Label;
class PlayerBox;
class RadioButton;
@@ -42,8 +44,8 @@ class TextField;
* \ingroup Interface
*/
class CharCreateDialog final : public Window,
- public gcn::ActionListener,
- public gcn::KeyListener
+ public ActionListener,
+ public KeyListener
{
public:
/**
@@ -58,7 +60,7 @@ class CharCreateDialog final : public Window,
*/
~CharCreateDialog();
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
/**
* Unlocks the dialog, enabling the create character button again.
@@ -76,7 +78,7 @@ class CharCreateDialog final : public Window,
void updatePlayer();
- void keyPressed(gcn::KeyEvent &keyEvent) override final;
+ void keyPressed(KeyEvent &keyEvent) override final;
private:
int getDistributedPoints() const A_WARN_UNUSED;
diff --git a/src/gui/windows/charselectdialog.cpp b/src/gui/windows/charselectdialog.cpp
index 3f44617f8..4480f06af 100644
--- a/src/gui/windows/charselectdialog.cpp
+++ b/src/gui/windows/charselectdialog.cpp
@@ -26,8 +26,9 @@
#include "configuration.h"
#include "units.h"
+#include "events/keyevent.h"
+
#include "input/keydata.h"
-#include "input/keyevent.h"
#include "gui/windows/charcreatedialog.h"
#include "gui/windows/confirmdialog.h"
@@ -43,6 +44,7 @@
#include "net/logindata.h"
#include "net/loginhandler.h"
+#include "net/net.h"
#include "utils/gettext.h"
@@ -70,7 +72,7 @@ class CharDeleteConfirm final : public ConfirmDialog
A_DELETE_COPY(CharDeleteConfirm)
- void action(const gcn::ActionEvent &event)
+ void action(const ActionEvent &event)
{
if (event.getId() == "yes" && mMaster)
mMaster->askPasswordForDeletion(mIndex);
@@ -88,8 +90,8 @@ CharSelectDialog::CharSelectDialog(LoginData *const data):
Window(strprintf(_("Account %s (last login time %s)"),
data->username.c_str(), data->lastLogin.c_str()),
false, nullptr, "char.xml"),
- gcn::ActionListener(),
- gcn::KeyListener(),
+ ActionListener(),
+ KeyListener(),
mLoginData(data),
// TRANSLATORS: char select dialog. button.
mSwitchLoginButton(new Button(this, _("Switch Login"), "switch", this)),
@@ -205,10 +207,10 @@ void CharSelectDialog::postInit()
requestFocus();
}
-void CharSelectDialog::action(const gcn::ActionEvent &event)
+void CharSelectDialog::action(const ActionEvent &event)
{
// Check if a button of a character was pressed
- const gcn::Widget *const sourceParent = event.getSource()->getParent();
+ const Widget *const sourceParent = event.getSource()->getParent();
int selected = -1;
for (unsigned int i = 0, sz = static_cast<unsigned int>(
mCharacterEntries.size()); i < sz; ++i)
@@ -315,14 +317,14 @@ void CharSelectDialog::use(const int selected)
}
}
-void CharSelectDialog::keyPressed(gcn::KeyEvent &keyEvent)
+void CharSelectDialog::keyPressed(KeyEvent &keyEvent)
{
- const int actionId = static_cast<KeyEvent*>(&keyEvent)->getActionId();
+ const int actionId = keyEvent.getActionId();
switch (actionId)
{
case Input::KEY_GUI_CANCEL:
keyEvent.consume();
- action(gcn::ActionEvent(mSwitchLoginButton,
+ action(ActionEvent(mSwitchLoginButton,
mSwitchLoginButton->getActionEventId()));
break;
@@ -471,15 +473,7 @@ void CharSelectDialog::setCharacters(const Net::Characters &characters)
Net::Character *const character = *i;
- // Slots Number start at 1 for Manaserv, so we offset them by one.
-#ifdef MANASERV_SUPPORT
- int characterSlot = character->slot;
- if (Net::getNetworkType() == ServerInfo::MANASERV && characterSlot > 0)
- --characterSlot;
-#else
const int characterSlot = character->slot;
-#endif
-
if (characterSlot >= static_cast<int>(mCharacterEntries.size()))
{
logger->log("Warning: slot out of range: %d", character->slot);
@@ -563,7 +557,7 @@ void CharSelectDialog::close()
Window::close();
}
-void CharSelectDialog::widgetResized(const gcn::Event &event)
+void CharSelectDialog::widgetResized(const Event &event)
{
Window::widgetResized(event);
if (mCharacterView)
diff --git a/src/gui/windows/charselectdialog.h b/src/gui/windows/charselectdialog.h
index 3ac5d664f..38c307f30 100644
--- a/src/gui/windows/charselectdialog.h
+++ b/src/gui/windows/charselectdialog.h
@@ -29,13 +29,12 @@
#include "net/charserverhandler.h"
-#include <guichan/actionlistener.hpp>
-#include <guichan/keylistener.hpp>
+#include "listeners/actionlistener.h"
+#include "listeners/keylistener.h"
class Button;
class CharacterDisplay;
class CharacterViewBase;
-class Label;
class LoginData;
class TextDialog;
@@ -45,8 +44,8 @@ class TextDialog;
* \ingroup Interface
*/
class CharSelectDialog final : public Window,
- public gcn::ActionListener,
- public gcn::KeyListener
+ public ActionListener,
+ public KeyListener
{
public:
friend class CharDeleteConfirm;
@@ -61,9 +60,9 @@ class CharSelectDialog final : public Window,
~CharSelectDialog();
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
- void keyPressed(gcn::KeyEvent &keyEvent) override final;
+ void keyPressed(KeyEvent &keyEvent) override final;
enum SelectAction
{
@@ -86,7 +85,7 @@ class CharSelectDialog final : public Window,
void close() override final;
- void widgetResized(const gcn::Event &event) override final;
+ void widgetResized(const Event &event) override final;
void updateState();
diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp
index 26f665052..d769c4397 100644
--- a/src/gui/windows/chatwindow.cpp
+++ b/src/gui/windows/chatwindow.cpp
@@ -35,13 +35,16 @@
#include "being/playerinfo.h"
#include "being/playerrelations.h"
+#include "events/keyevent.h"
+
#include "input/inputmanager.h"
-#include "input/keyevent.h"
-#include "gui/sdlfont.h"
-#include "gui/sdlinput.h"
+#include "gui/focushandler.h"
+#include "gui/gui.h"
#include "gui/viewport.h"
+#include "gui/models/colorlistmodel.h"
+
#include "gui/windows/emotewindow.h"
#include "gui/windows/setupwindow.h"
#include "gui/widgets/tabbedarea.h"
@@ -68,8 +71,6 @@
#include "resources/resourcemanager.h"
-#include <guichan/focushandler.hpp>
-
#include <sstream>
#include <sys/stat.h>
@@ -97,7 +98,7 @@ class ChatInput final : public TextField
* Called if the chat input loses focus. It will set itself to
* invisible as result.
*/
- void focusLost(const gcn::Event &event)
+ void focusLost(const Event &event)
{
TextField::focusLost(event);
if (mFocusGaining || !config.getBoolValue("protectChatFocus"))
@@ -145,65 +146,13 @@ class ChatInput final : public TextField
bool mFocusGaining;
};
-const char *COLOR_NAME[14] =
-{
- // TRANSLATORS: chat color
- N_("default"),
- // TRANSLATORS: chat color
- N_("black"),
- // TRANSLATORS: chat color
- N_("red"),
- // TRANSLATORS: chat color
- N_("green"),
- // TRANSLATORS: chat color
- N_("blue"),
- // TRANSLATORS: chat color
- N_("gold"),
- // TRANSLATORS: chat color
- N_("yellow"),
- // TRANSLATORS: chat color
- N_("pink"),
- // TRANSLATORS: chat color
- N_("purple"),
- // TRANSLATORS: chat color
- N_("grey"),
- // TRANSLATORS: chat color
- N_("brown"),
- // TRANSLATORS: chat color
- N_("rainbow 1"),
- // TRANSLATORS: chat color
- N_("rainbow 2"),
- // TRANSLATORS: chat color
- N_("rainbow 3"),
-};
-
-
-class ColorListModel final : public gcn::ListModel
-{
-public:
- ~ColorListModel()
- { }
-
- int getNumberOfElements()
- {
- return 14;
- }
-
- std::string getElementAt(int i)
- {
- if (i >= getNumberOfElements() || i < 0)
- return "???";
- return gettext(COLOR_NAME[i]);
- }
-};
-
static const char *const ACTION_COLOR_PICKER = "color picker";
ChatWindow::ChatWindow():
// TRANSLATORS: chat window name
Window(_("Chat"), false, nullptr, "chat.xml"),
- gcn::ActionListener(),
- gcn::KeyListener(),
+ ActionListener(),
+ KeyListener(),
mItemLinkHandler(new ItemLinkHandler),
mChatTabs(new TabbedArea(this)),
mChatInput(new ChatInput(this)),
@@ -378,7 +327,7 @@ void ChatWindow::updateTabsMargin()
void ChatWindow::adjustTabSize()
{
- const gcn::Rectangle area = getChildrenArea();
+ const Rect area = getChildrenArea();
const int aw = area.width;
const int ah = area.height;
@@ -425,7 +374,7 @@ void ChatWindow::adjustTabSize()
const ChatTab *const tab = getFocused();
if (tab)
{
- gcn::Widget *const content = tab->mScrollArea;
+ Widget *const content = tab->mScrollArea;
if (content)
{
const int contentFrame2 = 2 * content->getFrameSize();
@@ -441,7 +390,7 @@ void ChatWindow::adjustTabSize()
mChatTabs->adjustSize();
}
-void ChatWindow::widgetResized(const gcn::Event &event)
+void ChatWindow::widgetResized(const Event &event)
{
Window::widgetResized(event);
@@ -514,7 +463,7 @@ void ChatWindow::defaultTab()
mChatTabs->setSelectedTabByIndex(static_cast<unsigned>(0));
}
-void ChatWindow::action(const gcn::ActionEvent &event)
+void ChatWindow::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "chatinput")
@@ -770,12 +719,12 @@ void ChatWindow::scroll(const int amount) const
tab->scroll(amount);
}
-void ChatWindow::mousePressed(gcn::MouseEvent &event)
+void ChatWindow::mousePressed(MouseEvent &event)
{
if (event.isConsumed())
return;
- if (event.getButton() == gcn::MouseEvent::RIGHT)
+ if (event.getButton() == MouseEvent::RIGHT)
{
if (viewport)
{
@@ -804,7 +753,7 @@ void ChatWindow::mousePressed(gcn::MouseEvent &event)
if (event.isConsumed())
return;
- if (event.getButton() == gcn::MouseEvent::LEFT)
+ if (event.getButton() == MouseEvent::LEFT)
{
const ChatTab *const tab = getFocused();
if (tab)
@@ -815,7 +764,7 @@ void ChatWindow::mousePressed(gcn::MouseEvent &event)
mDragOffsetY = event.getY();
}
-void ChatWindow::mouseDragged(gcn::MouseEvent &event)
+void ChatWindow::mouseDragged(MouseEvent &event)
{
Window::mouseDragged(event);
@@ -836,10 +785,10 @@ void ChatWindow::mouseDragged(gcn::MouseEvent &event)
temp = str; \
break
-void ChatWindow::keyPressed(gcn::KeyEvent &event)
+void ChatWindow::keyPressed(KeyEvent &event)
{
const int key = event.getKey().getValue();
- const int actionId = static_cast<KeyEvent*>(&event)->getActionId();
+ const int actionId = event.getActionId();
if (actionId == static_cast<int>(Input::KEY_GUI_DOWN))
{
if (mCurHist != mHistory.end())
@@ -1884,25 +1833,25 @@ void ChatWindow::optionChanged(const std::string &name)
parseGlobalsFilter();
}
-void ChatWindow::mouseMoved(gcn::MouseEvent &event)
+void ChatWindow::mouseMoved(MouseEvent &event)
{
mHaveMouse = true;
Window::mouseMoved(event);
}
-void ChatWindow::mouseEntered(gcn::MouseEvent& mouseEvent)
+void ChatWindow::mouseEntered(MouseEvent& mouseEvent)
{
mHaveMouse = true;
Window::mouseEntered(mouseEvent);
}
-void ChatWindow::mouseExited(gcn::MouseEvent& mouseEvent)
+void ChatWindow::mouseExited(MouseEvent& mouseEvent)
{
updateVisibility();
Window::mouseExited(mouseEvent);
}
-void ChatWindow::draw(gcn::Graphics* graphics)
+void ChatWindow::draw(Graphics* graphics)
{
BLOCK_START("ChatWindow::draw")
if (!mAutoHide || mHaveMouse)
diff --git a/src/gui/windows/chatwindow.h b/src/gui/windows/chatwindow.h
index 3093c52e9..2ec4e6bec 100644
--- a/src/gui/windows/chatwindow.h
+++ b/src/gui/windows/chatwindow.h
@@ -23,14 +23,14 @@
#ifndef GUI_WINDOWS_CHATWINDOW_H
#define GUI_WINDOWS_CHATWINDOW_H
-#include "depricatedlistener.h"
+#include "listeners/depricatedlistener.h"
-#include "configlistener.h"
+#include "listeners/configlistener.h"
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
-#include <guichan/keylistener.hpp>
+#include "listeners/actionlistener.h"
+#include "listeners/keylistener.h"
#include <list>
#include <map>
@@ -83,8 +83,8 @@ struct CHATLOG final
* \ingroup Interface
*/
class ChatWindow final : public Window,
- public gcn::ActionListener,
- public gcn::KeyListener,
+ public ActionListener,
+ public KeyListener,
public DepricatedListener,
public ConfigListener
{
@@ -139,7 +139,7 @@ class ChatWindow final : public Window,
/**
* Performs action.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
/**
* Request focus for typing chat message.
@@ -169,7 +169,7 @@ class ChatWindow final : public Window,
void localChatInput(const std::string &msg) const;
/** Called when key is pressed */
- void keyPressed(gcn::KeyEvent &event) override final;
+ void keyPressed(KeyEvent &event) override final;
/** Set the chat input as the given text. */
void setInputText(const std::string &text);
@@ -186,12 +186,12 @@ class ChatWindow final : public Window,
/**
* Handles mouse when dragged.
*/
- void mouseDragged(gcn::MouseEvent &event) override final;
+ void mouseDragged(MouseEvent &event) override final;
/**
* Handles mouse when pressed.
*/
- void mousePressed(gcn::MouseEvent &event) override final;
+ void mousePressed(MouseEvent &event) override final;
void processEvent(const Channels channel,
const DepricatedEvent &event) override final;
@@ -274,19 +274,19 @@ class ChatWindow final : public Window,
void optionChanged(const std::string &name) override final;
- void mouseEntered(gcn::MouseEvent& mouseEvent) override final;
+ void mouseEntered(MouseEvent& mouseEvent) override final;
- void mouseMoved(gcn::MouseEvent &event) override final;
+ void mouseMoved(MouseEvent &event) override final;
- void mouseExited(gcn::MouseEvent& mouseEvent A_UNUSED) override final;
+ void mouseExited(MouseEvent& mouseEvent A_UNUSED) override final;
- void draw(gcn::Graphics* graphics) override final;
+ void draw(Graphics* graphics) override final;
void updateVisibility();
void unHideWindow();
- void widgetResized(const gcn::Event &event) override final;
+ void widgetResized(const Event &event) override final;
void addGlobalMessage(const std::string &line);
diff --git a/src/gui/windows/confirmdialog.cpp b/src/gui/windows/confirmdialog.cpp
index e48427a5b..6eb21622d 100644
--- a/src/gui/windows/confirmdialog.cpp
+++ b/src/gui/windows/confirmdialog.cpp
@@ -29,7 +29,7 @@
#include "utils/gettext.h"
-#include <guichan/font.hpp>
+#include "gui/font.h"
#include "debug.h"
@@ -39,7 +39,7 @@ ConfirmDialog::ConfirmDialog(const std::string &restrict title,
const bool ignore,
const bool modal, Window *const parent):
Window(title, modal, parent, "confirm.xml"),
- gcn::ActionListener(),
+ ActionListener(),
mTextBox(new TextBox(this)),
mIgnore(ignore)
{
@@ -107,7 +107,7 @@ void ConfirmDialog::postInit()
yesButton->requestFocus();
}
-void ConfirmDialog::action(const gcn::ActionEvent &event)
+void ConfirmDialog::action(const ActionEvent &event)
{
setActionEventId(event.getId());
distributeActionEvent();
diff --git a/src/gui/windows/confirmdialog.h b/src/gui/windows/confirmdialog.h
index 0b092e234..0d9f25d38 100644
--- a/src/gui/windows/confirmdialog.h
+++ b/src/gui/windows/confirmdialog.h
@@ -29,7 +29,7 @@
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
class TextBox;
@@ -38,7 +38,8 @@ class TextBox;
*
* \ingroup GUI
*/
-class ConfirmDialog : public Window, public gcn::ActionListener
+class ConfirmDialog : public Window,
+ public ActionListener
{
public:
/**
@@ -57,7 +58,7 @@ class ConfirmDialog : public Window, public gcn::ActionListener
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override;
+ void action(const ActionEvent &event) override;
void postInit() override final;
diff --git a/src/gui/windows/connectiondialog.cpp b/src/gui/windows/connectiondialog.cpp
index 6d01dcaae..1a7c23187 100644
--- a/src/gui/windows/connectiondialog.cpp
+++ b/src/gui/windows/connectiondialog.cpp
@@ -34,14 +34,14 @@
ConnectionDialog::ConnectionDialog(const std::string &text,
const State cancelState):
Window("", false, nullptr, "connection.xml"),
- gcn::ActionListener(),
+ ActionListener(),
mCancelState(cancelState)
{
setTitleBarHeight(0);
setMovable(false);
setMinWidth(0);
- ProgressIndicator *const progressIndicator = new ProgressIndicator;
+ ProgressIndicator *const progressIndicator = new ProgressIndicator(this);
Label *const label = new Label(this, text);
Button *const cancelButton = new Button(
// TRANSLATORS: connection dialog button
@@ -60,13 +60,13 @@ void ConnectionDialog::postInit()
setVisible(true);
}
-void ConnectionDialog::action(const gcn::ActionEvent &)
+void ConnectionDialog::action(const ActionEvent &)
{
logger->log1("Cancel pressed");
client->setState(mCancelState);
}
-void ConnectionDialog::draw(gcn::Graphics *graphics)
+void ConnectionDialog::draw(Graphics *graphics)
{
BLOCK_START("ConnectionDialog::draw")
// Don't draw the window background, only draw the children
diff --git a/src/gui/windows/connectiondialog.h b/src/gui/windows/connectiondialog.h
index 2f861bc52..059d4bd6d 100644
--- a/src/gui/windows/connectiondialog.h
+++ b/src/gui/windows/connectiondialog.h
@@ -27,14 +27,15 @@
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
/**
* The connection dialog.
*
* \ingroup Interface
*/
-class ConnectionDialog final : public Window, private gcn::ActionListener
+class ConnectionDialog final : public Window,
+ private ActionListener
{
public:
/**
@@ -55,9 +56,9 @@ class ConnectionDialog final : public Window, private gcn::ActionListener
* Called when the user presses Cancel. Restores the global state to
* the previous one.
*/
- void action(const gcn::ActionEvent &) override;
+ void action(const ActionEvent &) override;
- void draw(gcn::Graphics *graphics) override;
+ void draw(Graphics *graphics) override;
private:
State mCancelState;
diff --git a/src/gui/windows/debugwindow.cpp b/src/gui/windows/debugwindow.cpp
index 30d202054..50dc5dbe5 100644
--- a/src/gui/windows/debugwindow.cpp
+++ b/src/gui/windows/debugwindow.cpp
@@ -75,7 +75,7 @@ DebugWindow::DebugWindow() :
// TRANSLATORS: debug window tab
mTabs->addTab(std::string(_("Net")), mNetWidget);
- mTabs->setDimension(gcn::Rectangle(0, 0, 600, 300));
+ mTabs->setDimension(Rect(0, 0, 600, 300));
const int w = mDimension.width;
const int h = mDimension.height;
@@ -129,7 +129,7 @@ void DebugWindow::slowLogic()
BLOCK_END("DebugWindow::slowLogic")
}
-void DebugWindow::draw(gcn::Graphics *g)
+void DebugWindow::draw(Graphics *g)
{
BLOCK_START("DebugWindow::draw")
Window::draw(g);
@@ -139,8 +139,7 @@ void DebugWindow::draw(gcn::Graphics *g)
const Being *const target = player_node->getTarget();
if (target)
{
- Graphics *const g2 = static_cast<Graphics*>(g);
- target->draw(g2, -target->getPixelX() + mapTileSize / 2
+ target->draw(g, -target->getPixelX() + mapTileSize / 2
+ mDimension.width / 2, -target->getPixelY() + mapTileSize
+ mDimension.height / 2);
}
@@ -148,11 +147,11 @@ void DebugWindow::draw(gcn::Graphics *g)
BLOCK_END("DebugWindow::draw")
}
-void DebugWindow::widgetResized(const gcn::Event &event)
+void DebugWindow::widgetResized(const Event &event)
{
Window::widgetResized(event);
- mTabs->setDimension(gcn::Rectangle(0, 0,
+ mTabs->setDimension(Rect(0, 0,
mDimension.width, mDimension.height));
}
@@ -268,7 +267,7 @@ MapDebugTab::MapDebugTab(const Widget2 *const widget) :
#endif
place.getCell().matchColWidth(0, 0);
place = h.getPlacer(0, 1);
- setDimension(gcn::Rectangle(0, 0, 600, 300));
+ setDimension(Rect(0, 0, 600, 300));
}
void MapDebugTab::logic()
@@ -413,7 +412,7 @@ TargetDebugTab::TargetDebugTab(const Widget2 *const widget) :
place.getCell().matchColWidth(0, 0);
place = h.getPlacer(0, 1);
- setDimension(gcn::Rectangle(0, 0, 600, 300));
+ setDimension(Rect(0, 0, 600, 300));
}
void TargetDebugTab::logic()
@@ -532,7 +531,7 @@ NetDebugTab::NetDebugTab(const Widget2 *const widget) :
place.getCell().matchColWidth(0, 0);
place = h.getPlacer(0, 1);
- setDimension(gcn::Rectangle(0, 0, 600, 300));
+ setDimension(Rect(0, 0, 600, 300));
}
void NetDebugTab::logic()
diff --git a/src/gui/windows/debugwindow.h b/src/gui/windows/debugwindow.h
index 13e73c29e..1a56f3164 100644
--- a/src/gui/windows/debugwindow.h
+++ b/src/gui/windows/debugwindow.h
@@ -41,7 +41,7 @@ class DebugTab : public Container
}
void resize(const int x, const int y)
- { setDimension(gcn::Rectangle(0, 0, x, y)); }
+ { setDimension(Rect(0, 0, x, y)); }
protected:
explicit DebugTab(const Widget2 *const widget) :
@@ -147,11 +147,11 @@ class DebugWindow final : public Window
*/
void slowLogic();
- void draw(gcn::Graphics *g) override final;
+ void draw(Graphics *g) override final;
void setPing(int pingTime);
- void widgetResized(const gcn::Event &event) override final;
+ void widgetResized(const Event &event) override final;
#ifdef USE_PROFILER
void logicChildren();
diff --git a/src/gui/windows/didyouknowwindow.cpp b/src/gui/windows/didyouknowwindow.cpp
index 93166e6fa..79ad4c208 100644
--- a/src/gui/windows/didyouknowwindow.cpp
+++ b/src/gui/windows/didyouknowwindow.cpp
@@ -24,7 +24,7 @@
#include "configuration.h"
-#include "gui/sdlfont.h"
+#include "gui/gui.h"
#include "gui/windows/setupwindow.h"
@@ -48,10 +48,10 @@ static const int maxTip = 18;
DidYouKnowWindow::DidYouKnowWindow() :
// TRANSLATORS: did you know window name
Window(_("Did You Know?"), false, nullptr, "didyouknow.xml"),
- gcn::ActionListener(),
+ ActionListener(),
mBrowserBox(new BrowserBox(this, BrowserBox::AUTO_SIZE, true,
"browserbox.xml")),
- mScrollArea(new ScrollArea(mBrowserBox,
+ mScrollArea(new ScrollArea(this, mBrowserBox,
true, "didyouknow_background.xml")),
// TRANSLATORS: did you know window button
mButtonPrev(new Button(this, _("< Previous"), "prev", this)),
@@ -78,7 +78,8 @@ DidYouKnowWindow::DidYouKnowWindow() :
Button *const okButton = new Button(this, _("Close"), "close", this);
mBrowserBox->setLinkHandler(this);
- mBrowserBox->setFont(gui->getHelpFont());
+ if (gui)
+ mBrowserBox->setFont(gui->getHelpFont());
mBrowserBox->setProcessVersion(true);
mBrowserBox->setEnableImages(true);
mBrowserBox->setEnableKeys(true);
@@ -99,10 +100,10 @@ DidYouKnowWindow::DidYouKnowWindow() :
void DidYouKnowWindow::postInit()
{
- widgetResized(gcn::Event(nullptr));
+ widgetResized(Event(nullptr));
}
-void DidYouKnowWindow::action(const gcn::ActionEvent &event)
+void DidYouKnowWindow::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "close")
@@ -129,7 +130,7 @@ void DidYouKnowWindow::action(const gcn::ActionEvent &event)
}
void DidYouKnowWindow::handleLink(const std::string &link,
- gcn::MouseEvent *event A_UNUSED)
+ MouseEvent *event A_UNUSED)
{
if (strStartWith(link, "http://") || strStartWith(link, "https://"))
openBrowser(link);
diff --git a/src/gui/windows/didyouknowwindow.h b/src/gui/windows/didyouknowwindow.h
index 942bcf41c..fd539e360 100644
--- a/src/gui/windows/didyouknowwindow.h
+++ b/src/gui/windows/didyouknowwindow.h
@@ -26,7 +26,7 @@
#include "gui/widgets/linkhandler.h"
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
class Button;
class BrowserBox;
@@ -38,7 +38,7 @@ class ScrollArea;
*/
class DidYouKnowWindow final : public Window,
public LinkHandler,
- public gcn::ActionListener
+ public ActionListener
{
public:
/**
@@ -53,13 +53,13 @@ class DidYouKnowWindow final : public Window,
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
/**
* Handles link action.
*/
void handleLink(const std::string &link,
- gcn::MouseEvent *event) override final;
+ MouseEvent *event) override final;
void loadData(int num = 0);
diff --git a/src/gui/windows/editdialog.cpp b/src/gui/windows/editdialog.cpp
index 5c002212f..55102acdb 100644
--- a/src/gui/windows/editdialog.cpp
+++ b/src/gui/windows/editdialog.cpp
@@ -33,7 +33,7 @@ EditDialog::EditDialog(const std::string &restrict title,
const std::string &restrict eventOk, const int width,
Window *const parent, const bool modal):
Window(title, modal, parent, "edit.xml"),
- gcn::ActionListener(),
+ ActionListener(),
mEventOk(eventOk),
mTextField(new TextField(this))
{
@@ -65,7 +65,7 @@ void EditDialog::postInit()
okButton->requestFocus();
}
-void EditDialog::action(const gcn::ActionEvent &event)
+void EditDialog::action(const ActionEvent &event)
{
// Proxy button events to our listeners
FOR_EACH (ActionListenerIterator, i, mActionListeners)
diff --git a/src/gui/windows/editdialog.h b/src/gui/windows/editdialog.h
index fa4a02bf7..b3bfe1f45 100644
--- a/src/gui/windows/editdialog.h
+++ b/src/gui/windows/editdialog.h
@@ -28,7 +28,7 @@
#include "gui/widgets/window.h"
#include "gui/widgets/textfield.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
#define ACTION_EDIT_OK "edit ok"
@@ -37,7 +37,8 @@
*
* \ingroup GUI
*/
-class EditDialog final : public Window, public gcn::ActionListener
+class EditDialog final : public Window,
+ public ActionListener
{
public:
/**
@@ -58,7 +59,7 @@ class EditDialog final : public Window, public gcn::ActionListener
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
std::string getMsg() const A_WARN_UNUSED
{ return mTextField->getText(); }
diff --git a/src/gui/windows/editserverdialog.cpp b/src/gui/windows/editserverdialog.cpp
index 900fe840b..316a7051b 100644
--- a/src/gui/windows/editserverdialog.cpp
+++ b/src/gui/windows/editserverdialog.cpp
@@ -21,8 +21,11 @@
#include "gui/windows/editserverdialog.h"
+#include "events/keyevent.h"
+
#include "input/keydata.h"
-#include "input/keyevent.h"
+
+#include "gui/models/typelistmodel.h"
#include "gui/windows/okdialog.h"
#include "gui/windows/serverdialog.h"
@@ -35,36 +38,13 @@
#include "utils/gettext.h"
-std::string TypeListModel::getElementAt(int elementIndex)
-{
- if (elementIndex == 0)
- return "TmwAthena";
- else if (elementIndex == 1)
- return "Evol";
-#ifdef EATHENA_SUPPORT
- else if (elementIndex == 2)
- return "eAthena";
-#ifdef MANASERV_SUPPORT
- else if (elementIndex == 3)
- return "ManaServ";
-#endif
-#else
-#ifdef MANASERV_SUPPORT
- else if (elementIndex == 2)
- return "ManaServ";
-#endif
-#endif
- else
- return "Unknown";
-}
-
EditServerDialog::EditServerDialog(ServerDialog *const parent,
ServerInfo server,
const int index) :
// TRANSLATORS: edit server dialog name
Window(_("Edit Server"), true, parent),
- gcn::ActionListener(),
- gcn::KeyListener(),
+ ActionListener(),
+ KeyListener(),
mServerAddressField(new TextField(this, std::string())),
mPortField(new TextField(this, std::string())),
mNameField(new TextField(this, std::string())),
@@ -159,17 +139,6 @@ EditServerDialog::EditServerDialog(ServerDialog *const parent,
case ServerInfo::EATHENA:
mTypeField->setSelected(2);
break;
- case ServerInfo::MANASERV:
-#ifdef MANASERV_SUPPORT
- mTypeField->setSelected(3);
- break;
-#endif
-#else
- case ServerInfo::MANASERV:
-#ifdef MANASERV_SUPPORT
- mTypeField->setSelected(2);
- break;
-#endif
#endif
default:
case ServerInfo::UNKNOWN:
@@ -198,7 +167,7 @@ void EditServerDialog::postInit()
mNameField->requestFocus();
}
-void EditServerDialog::action(const gcn::ActionEvent &event)
+void EditServerDialog::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
@@ -246,17 +215,6 @@ void EditServerDialog::action(const gcn::ActionEvent &event)
case 2:
mServer.type = ServerInfo::EATHENA;
break;
-#ifdef MANASERV_SUPPORT
- case 3:
- mServer.type = ServerInfo::MANASERV;
- break;
-#endif
-#else
-#ifdef MANASERV_SUPPORT
- case 2:
- mServer.type = ServerInfo::MANASERV;
- break;
-#endif
#endif
default:
mServer.type = ServerInfo::UNKNOWN;
@@ -284,13 +242,12 @@ void EditServerDialog::action(const gcn::ActionEvent &event)
}
}
-void EditServerDialog::keyPressed(gcn::KeyEvent &keyEvent)
+void EditServerDialog::keyPressed(KeyEvent &keyEvent)
{
if (keyEvent.isConsumed())
return;
- const int actionId = static_cast<KeyEvent*>(
- &keyEvent)->getActionId();
+ const int actionId = keyEvent.getActionId();
if (actionId == static_cast<int>(Input::KEY_GUI_CANCEL))
{
@@ -299,6 +256,6 @@ void EditServerDialog::keyPressed(gcn::KeyEvent &keyEvent)
else if (actionId == static_cast<int>(Input::KEY_GUI_SELECT)
|| actionId == static_cast<int>(Input::KEY_GUI_SELECT2))
{
- action(gcn::ActionEvent(nullptr, mOkButton->getActionEventId()));
+ action(ActionEvent(nullptr, mOkButton->getActionEventId()));
}
}
diff --git a/src/gui/windows/editserverdialog.h b/src/gui/windows/editserverdialog.h
index 525005429..b70d1031b 100644
--- a/src/gui/windows/editserverdialog.h
+++ b/src/gui/windows/editserverdialog.h
@@ -26,48 +26,14 @@ class Button;
class TextField;
class DropDown;
class ServerDialog;
+class TypeListModel;
#include "gui/widgets/window.h"
#include "net/serverinfo.h"
-#include <guichan/actionlistener.hpp>
-#include <guichan/keylistener.hpp>
-#include <guichan/listmodel.hpp>
-
-/**
- * Server Type List Model
- */
-class TypeListModel : public gcn::ListModel
-{
- public:
- TypeListModel()
- { }
-
- /**
- * Used to get number of line in the list
- */
- int getNumberOfElements() override final A_WARN_UNUSED
-#ifdef EATHENA_SUPPORT
-#ifdef MANASERV_SUPPORT
- { return 4; }
-#else
- { return 3; }
-#endif
-#else
-#ifdef MANASERV_SUPPORT
- { return 3; }
-#else
- { return 2; }
-#endif
-#endif
-
- /**
- * Used to get an element from the list
- */
- std::string getElementAt(int elementIndex)
- override final A_WARN_UNUSED;
-};
+#include "listeners/actionlistener.h"
+#include "listeners/keylistener.h"
/**
* The custom server addition dialog.
@@ -75,8 +41,8 @@ class TypeListModel : public gcn::ListModel
* \ingroup Interface
*/
class EditServerDialog final : public Window,
- public gcn::ActionListener,
- public gcn::KeyListener
+ public ActionListener,
+ public KeyListener
{
public:
EditServerDialog(ServerDialog *const parent, ServerInfo server,
@@ -91,9 +57,9 @@ class EditServerDialog final : public Window,
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
- void keyPressed(gcn::KeyEvent &keyEvent) override final;
+ void keyPressed(KeyEvent &keyEvent) override final;
private:
TextField *mServerAddressField;
diff --git a/src/gui/windows/emotewindow.cpp b/src/gui/windows/emotewindow.cpp
index 9dd5f648c..3a7141533 100644
--- a/src/gui/windows/emotewindow.cpp
+++ b/src/gui/windows/emotewindow.cpp
@@ -20,10 +20,11 @@
#include "gui/windows/emotewindow.h"
-#include "gui/widgets/colormodel.h"
+#include "gui/models/colormodel.h"
+#include "gui/models/namesmodel.h"
+
#include "gui/widgets/colorpage.h"
#include "gui/widgets/emotepage.h"
-#include "gui/widgets/namesmodel.h"
#include "gui/widgets/scrollarea.h"
#include "gui/widgets/tabbedarea.h"
@@ -51,10 +52,10 @@ EmoteWindow::EmoteWindow() :
mEmotePage(new EmotePage(this)),
mColorModel(ColorModel::createDefault(this)),
mColorPage(new ColorPage(this, mColorModel, "colorpage.xml")),
- mScrollColorPage(new ScrollArea(mColorPage, false, "emotepage.xml")),
+ mScrollColorPage(new ScrollArea(this, mColorPage, false, "emotepage.xml")),
mFontModel(new NamesModel),
mFontPage(new ListBox(this, mFontModel, "")),
- mScrollFontPage(new ScrollArea(mFontPage, false, "fontpage.xml")),
+ mScrollFontPage(new ScrollArea(this, mFontPage, false, "fontpage.xml")),
mImageSet(Theme::getImageSetFromThemeXml("emotetabs.xml", "", 17, 16))
{
mTabs->postInit();
@@ -207,14 +208,14 @@ void EmoteWindow::clearFont()
setVisible(false);
}
-void EmoteWindow::addListeners(gcn::ActionListener *const listener)
+void EmoteWindow::addListeners(ActionListener *const listener)
{
mEmotePage->addActionListener(listener);
mColorPage->addActionListener(listener);
mFontPage->addActionListener(listener);
}
-void EmoteWindow::widgetResized(const gcn::Event &event)
+void EmoteWindow::widgetResized(const Event &event)
{
Window::widgetResized(event);
const int pad2 = mPadding * 2;
@@ -229,7 +230,7 @@ void EmoteWindow::widgetResized(const gcn::Event &event)
mEmotePage->widgetResized(event);
}
-void EmoteWindow::widgetMoved(const gcn::Event &event)
+void EmoteWindow::widgetMoved(const Event &event)
{
Window::widgetMoved(event);
mEmotePage->widgetResized(event);
diff --git a/src/gui/windows/emotewindow.h b/src/gui/windows/emotewindow.h
index 0f15b7bc6..37a5c015f 100644
--- a/src/gui/windows/emotewindow.h
+++ b/src/gui/windows/emotewindow.h
@@ -59,11 +59,11 @@ class EmoteWindow final : public Window
void clearFont();
- void addListeners(gcn::ActionListener *const listener);
+ void addListeners(ActionListener *const listener);
- void widgetResized(const gcn::Event &event) override final;
+ void widgetResized(const Event &event) override final;
- void widgetMoved(const gcn::Event &event) override final;
+ void widgetMoved(const Event &event) override final;
private:
TabbedArea *mTabs;
diff --git a/src/gui/windows/equipmentwindow.cpp b/src/gui/windows/equipmentwindow.cpp
index 3b97e12d7..c793ba6ce 100644
--- a/src/gui/windows/equipmentwindow.cpp
+++ b/src/gui/windows/equipmentwindow.cpp
@@ -32,6 +32,7 @@
#include "being/localplayer.h"
#include "being/playerinfo.h"
+#include "gui/font.h"
#include "gui/viewport.h"
#include "gui/popups/itempopup.h"
@@ -46,8 +47,6 @@
#include "utils/dtor.h"
#include "utils/gettext.h"
-#include <guichan/font.hpp>
-
#include "debug.h"
static const int BOX_COUNT = 13;
@@ -57,10 +56,11 @@ EquipmentWindow::EquipmentWindow(Equipment *const equipment,
const bool foring):
// TRANSLATORS: equipment window name
Window(_("Equipment"), false, nullptr, "equipment.xml"),
- gcn::ActionListener(),
+ ActionListener(),
mEquipment(equipment),
mItemPopup(new ItemPopup),
- mPlayerBox(new PlayerBox("equipment_playerbox.xml",
+ mPlayerBox(new PlayerBox(this,
+ "equipment_playerbox.xml",
"equipment_selectedplayerbox.xml")),
// TRANSLATORS: equipment window button
mUnequip(new Button(this, _("Unequip"), "unequip", this)),
@@ -92,7 +92,7 @@ EquipmentWindow::EquipmentWindow(Equipment *const equipment,
mBoxSize = 36;
// Control that shows the Player
- mPlayerBox->setDimension(gcn::Rectangle(50, 80, 74, 168));
+ mPlayerBox->setDimension(Rect(50, 80, 74, 168));
mPlayerBox->setPlayer(being);
if (foring)
@@ -116,7 +116,7 @@ EquipmentWindow::EquipmentWindow(Equipment *const equipment,
void EquipmentWindow::postInit()
{
- const gcn::Rectangle &area = getChildrenArea();
+ const Rect &area = getChildrenArea();
mUnequip->setPosition(area.width - mUnequip->getWidth() - mButtonPadding,
area.height - mUnequip->getHeight() - mButtonPadding);
mUnequip->setEnabled(false);
@@ -156,15 +156,14 @@ EquipmentWindow::~EquipmentWindow()
mVertexes = nullptr;
}
-void EquipmentWindow::draw(gcn::Graphics *graphics)
+void EquipmentWindow::draw(Graphics *graphics)
{
BLOCK_START("EquipmentWindow::draw")
// Draw window graphics
Window::draw(graphics);
- Graphics *const g = static_cast<Graphics*>(graphics);
int i = 0;
- gcn::Font *const font = getFont();
+ Font *const font = getFont();
const int fontHeight = font->getHeight();
if (isBatchDrawRenders(openGLMode))
@@ -179,17 +178,19 @@ void EquipmentWindow::draw(gcn::Graphics *graphics)
continue;
if (i == mSelected)
{
- g->calcTileCollection(mVertexes,
- mSlotHighlightedBackground, box->x, box->y);
+ graphics->calcTileCollection(mVertexes,
+ mSlotHighlightedBackground,
+ box->x, box->y);
}
else
{
- g->calcTileCollection(mVertexes, mSlotBackground,
+ graphics->calcTileCollection(mVertexes,
+ mSlotBackground,
box->x, box->y);
}
}
}
- g->drawTileCollection(mVertexes);
+ graphics->drawTileCollection(mVertexes);
}
else
{
@@ -200,9 +201,14 @@ void EquipmentWindow::draw(gcn::Graphics *graphics)
if (!box)
continue;
if (i == mSelected)
- g->drawImage2(mSlotHighlightedBackground, box->x, box->y);
+ {
+ graphics->drawImage(mSlotHighlightedBackground,
+ box->x, box->y);
+ }
else
- g->drawImage2(mSlotBackground, box->x, box->y);
+ {
+ graphics->drawImage(mSlotBackground, box->x, box->y);
+ }
}
}
@@ -228,13 +234,14 @@ void EquipmentWindow::draw(gcn::Graphics *graphics)
{
image->setAlpha(1.0F); // Ensure the image is drawn
// with maximum opacity
- g->drawImage2(image, box->x + mItemPadding,
+ graphics->drawImage(image, box->x + mItemPadding,
box->y + mItemPadding);
if (i == EQUIP_PROJECTILE_SLOT)
{
- g->setColorAll(mLabelsColor, mLabelsColor2);
+ graphics->setColorAll(mLabelsColor, mLabelsColor2);
const std::string str = toString(item->getQuantity());
- font->drawString(g, str,
+ font->drawString(graphics,
+ str,
box->x + (mBoxSize - font->getWidth(str)) / 2,
box->y - fontHeight);
}
@@ -242,14 +249,15 @@ void EquipmentWindow::draw(gcn::Graphics *graphics)
}
else if (box->image)
{
- g->drawImage2(box->image, box->x + mItemPadding,
+ graphics->drawImage(box->image,
+ box->x + mItemPadding,
box->y + mItemPadding);
}
}
BLOCK_END("EquipmentWindow::draw")
}
-void EquipmentWindow::action(const gcn::ActionEvent &event)
+void EquipmentWindow::action(const ActionEvent &event)
{
if (!mEquipment)
return;
@@ -275,7 +283,7 @@ Item *EquipmentWindow::getItem(const int x, const int y) const
const EquipmentBox *const box = *it;
if (!box)
continue;
- const gcn::Rectangle tRect(box->x, box->y, mBoxSize, mBoxSize);
+ const Rect tRect(box->x, box->y, mBoxSize, mBoxSize);
if (tRect.isPointInRect(x, y))
return mEquipment->getEquipment(i);
@@ -283,7 +291,7 @@ Item *EquipmentWindow::getItem(const int x, const int y) const
return nullptr;
}
-void EquipmentWindow::mousePressed(gcn::MouseEvent& mouseEvent)
+void EquipmentWindow::mousePressed(MouseEvent& mouseEvent)
{
if (!mEquipment)
{
@@ -294,7 +302,7 @@ void EquipmentWindow::mousePressed(gcn::MouseEvent& mouseEvent)
const int x = mouseEvent.getX();
const int y = mouseEvent.getY();
- if (mouseEvent.getButton() == gcn::MouseEvent::LEFT)
+ if (mouseEvent.getButton() == MouseEvent::LEFT)
{
if (mForing)
{
@@ -313,7 +321,7 @@ void EquipmentWindow::mousePressed(gcn::MouseEvent& mouseEvent)
if (!box)
continue;
const Item *const item = mEquipment->getEquipment(i);
- const gcn::Rectangle tRect(box->x, box->y, mBoxSize, mBoxSize);
+ const Rect tRect(box->x, box->y, mBoxSize, mBoxSize);
if (tRect.isPointInRect(x, y))
{
@@ -329,7 +337,7 @@ void EquipmentWindow::mousePressed(gcn::MouseEvent& mouseEvent)
return;
}
}
- else if (mouseEvent.getButton() == gcn::MouseEvent::RIGHT)
+ else if (mouseEvent.getButton() == MouseEvent::RIGHT)
{
if (Item *const item = getItem(x, y))
{
@@ -354,7 +362,7 @@ void EquipmentWindow::mousePressed(gcn::MouseEvent& mouseEvent)
Window::mousePressed(mouseEvent);
}
-void EquipmentWindow::mouseReleased(gcn::MouseEvent &mouseEvent)
+void EquipmentWindow::mouseReleased(MouseEvent &mouseEvent)
{
Window::mouseReleased(mouseEvent);
const DragDropSource src = dragDrop.getSource();
@@ -394,7 +402,7 @@ void EquipmentWindow::mouseReleased(gcn::MouseEvent &mouseEvent)
const EquipmentBox *const box = *it;
if (!box)
continue;
- const gcn::Rectangle tRect(box->x, box->y, mBoxSize, mBoxSize);
+ const Rect tRect(box->x, box->y, mBoxSize, mBoxSize);
if (tRect.isPointInRect(x, y))
return;
@@ -409,7 +417,7 @@ void EquipmentWindow::mouseReleased(gcn::MouseEvent &mouseEvent)
}
// Show ItemTooltip
-void EquipmentWindow::mouseMoved(gcn::MouseEvent &event)
+void EquipmentWindow::mouseMoved(MouseEvent &event)
{
Window::mouseMoved(event);
@@ -433,7 +441,7 @@ void EquipmentWindow::mouseMoved(gcn::MouseEvent &event)
}
// Hide ItemTooltip
-void EquipmentWindow::mouseExited(gcn::MouseEvent &event A_UNUSED)
+void EquipmentWindow::mouseExited(MouseEvent &event A_UNUSED)
{
if (mItemPopup)
mItemPopup->setVisible(false);
@@ -506,7 +514,7 @@ void EquipmentWindow::fillBoxes()
void EquipmentWindow::loadPlayerBox(const XmlNodePtr playerBoxNode)
{
- mPlayerBox->setDimension(gcn::Rectangle(
+ mPlayerBox->setDimension(Rect(
XML::getProperty(playerBoxNode, "x", 50),
XML::getProperty(playerBoxNode, "y", 80),
XML::getProperty(playerBoxNode, "width", 74),
diff --git a/src/gui/windows/equipmentwindow.h b/src/gui/windows/equipmentwindow.h
index 7387fb249..0ab4ca462 100644
--- a/src/gui/windows/equipmentwindow.h
+++ b/src/gui/windows/equipmentwindow.h
@@ -30,7 +30,7 @@
#include "utils/xml.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
#include <vector>
@@ -60,7 +60,8 @@ struct EquipmentBox final
*
* \ingroup Interface
*/
-class EquipmentWindow final : public Window, public gcn::ActionListener
+class EquipmentWindow final : public Window,
+ public ActionListener
{
public:
/**
@@ -81,11 +82,11 @@ class EquipmentWindow final : public Window, public gcn::ActionListener
/**
* Draws the equipment window.
*/
- void draw(gcn::Graphics *graphics) override final;
+ void draw(Graphics *graphics) override final;
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
- void mousePressed(gcn::MouseEvent& mouseEvent) override final;
+ void mousePressed(MouseEvent& mouseEvent) override final;
const Item* getEquipment(const int i) const A_WARN_UNUSED
{ return mEquipment ? mEquipment->getEquipment(i) : nullptr; }
@@ -96,11 +97,11 @@ class EquipmentWindow final : public Window, public gcn::ActionListener
void resetBeing(const Being *const being);
- void mouseExited(gcn::MouseEvent &event) override final;
+ void mouseExited(MouseEvent &event) override final;
- void mouseMoved(gcn::MouseEvent &event) override final;
+ void mouseMoved(MouseEvent &event) override final;
- void mouseReleased(gcn::MouseEvent &event) override final;
+ void mouseReleased(MouseEvent &event) override final;
void recalcSize();
@@ -135,10 +136,10 @@ class EquipmentWindow final : public Window, public gcn::ActionListener
ImageSet *mImageSet;
Being *mBeing;
std::vector<EquipmentBox*> mBoxes;
- gcn::Color mHighlightColor;
- gcn::Color mBorderColor;
- gcn::Color mLabelsColor;
- gcn::Color mLabelsColor2;
+ Color mHighlightColor;
+ Color mBorderColor;
+ Color mLabelsColor;
+ Color mLabelsColor2;
Image *mSlotBackground;
Image *mSlotHighlightedBackground;
ImageCollection *mVertexes;
diff --git a/src/gui/windows/helpwindow.cpp b/src/gui/windows/helpwindow.cpp
index eb2300e0e..fa9963217 100644
--- a/src/gui/windows/helpwindow.cpp
+++ b/src/gui/windows/helpwindow.cpp
@@ -24,7 +24,7 @@
#include "configuration.h"
-#include "gui/sdlfont.h"
+#include "gui/gui.h"
#include "gui/windows/didyouknowwindow.h"
#include "gui/windows/setupwindow.h"
@@ -48,12 +48,13 @@
HelpWindow::HelpWindow() :
// TRANSLATORS: help window name
Window(_("Help"), false, nullptr, "help.xml"),
- gcn::ActionListener(),
+ ActionListener(),
// TRANSLATORS: help window. button.
mDYKButton(new Button(this, _("Did you know..."), "DYK", this)),
mBrowserBox(new BrowserBox(this, BrowserBox::AUTO_SIZE, true,
"browserbox.xml")),
- mScrollArea(new ScrollArea(mBrowserBox, true, "help_background.xml")),
+ mScrollArea(new ScrollArea(this, mBrowserBox,
+ true, "help_background.xml")),
mTagFileMap()
{
setMinWidth(300);
@@ -72,7 +73,8 @@ HelpWindow::HelpWindow() :
mBrowserBox->setOpaque(false);
mBrowserBox->setLinkHandler(this);
- mBrowserBox->setFont(gui->getHelpFont());
+ if (gui)
+ mBrowserBox->setFont(gui->getHelpFont());
mBrowserBox->setProcessVersion(true);
mBrowserBox->setEnableImages(true);
mBrowserBox->setEnableKeys(true);
@@ -87,10 +89,10 @@ HelpWindow::HelpWindow() :
loadWindowState();
loadTags();
enableVisibleSound(true);
- widgetResized(gcn::Event(nullptr));
+ widgetResized(Event(nullptr));
}
-void HelpWindow::action(const gcn::ActionEvent &event)
+void HelpWindow::action(const ActionEvent &event)
{
if (event.getId() == "DYK")
{
@@ -104,7 +106,7 @@ void HelpWindow::action(const gcn::ActionEvent &event)
}
void HelpWindow::handleLink(const std::string &link,
- gcn::MouseEvent *event A_UNUSED)
+ MouseEvent *event A_UNUSED)
{
if (!strStartWith(link, "http://") && !strStartWith(link, "https://"))
{
diff --git a/src/gui/windows/helpwindow.h b/src/gui/windows/helpwindow.h
index 72c0d4aba..4290c99f9 100644
--- a/src/gui/windows/helpwindow.h
+++ b/src/gui/windows/helpwindow.h
@@ -26,7 +26,7 @@
#include "gui/widgets/linkhandler.h"
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
#include "localconsts.h"
@@ -44,8 +44,9 @@ typedef std::map<std::string, HelpNames> HelpTagsMap;
/**
* The help window.
*/
-class HelpWindow final : public Window, public LinkHandler,
- public gcn::ActionListener
+class HelpWindow final : public Window,
+ public LinkHandler,
+ public ActionListener
{
public:
/**
@@ -58,13 +59,13 @@ class HelpWindow final : public Window, public LinkHandler,
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
/**
* Handles link action.
*/
void handleLink(const std::string &link,
- gcn::MouseEvent *event A_UNUSED) override final;
+ MouseEvent *event A_UNUSED) override final;
/**
* Loads help in the dialog.
diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp
index 6fd2ab95b..ee8c85f06 100644
--- a/src/gui/windows/inventorywindow.cpp
+++ b/src/gui/windows/inventorywindow.cpp
@@ -28,11 +28,16 @@
#include "being/playerinfo.h"
+#include "events/keyevent.h"
+
#include "input/inputmanager.h"
-#include "input/keyevent.h"
+#include "gui/font.h"
+#include "gui/gui.h"
#include "gui/viewport.h"
+#include "gui/models/sortlistmodelinv.h"
+
#include "gui/popups/textpopup.h"
#include "gui/windows/equipmentwindow.h"
@@ -42,7 +47,6 @@
#include "gui/windows/shopwindow.h"
#include "gui/windows/tradewindow.h"
-
#include "gui/widgets/button.h"
#include "gui/widgets/dropdown.h"
#include "gui/widgets/itemcontainer.h"
@@ -57,53 +61,17 @@
#include "utils/gettext.h"
-#include <guichan/font.hpp>
-
#include <string>
#include "debug.h"
-static const char *const SORT_NAME_INVENTORY[6] =
-{
- // TRANSLATORS: inventory sort mode
- N_("default"),
- // TRANSLATORS: inventory sort mode
- N_("by name"),
- // TRANSLATORS: inventory sort mode
- N_("by id"),
- // TRANSLATORS: inventory sort mode
- N_("by weight"),
- // TRANSLATORS: inventory sort mode
- N_("by amount"),
- // TRANSLATORS: inventory sort mode
- N_("by type")
-};
-
-class SortListModelInv final : public gcn::ListModel
-{
-public:
- ~SortListModelInv()
- { }
-
- int getNumberOfElements() override final
- { return 6; }
-
- std::string getElementAt(int i) override final
- {
- if (i >= getNumberOfElements() || i < 0)
- return "???";
-
- return gettext(SORT_NAME_INVENTORY[i]);
- }
-};
-
InventoryWindow::WindowList InventoryWindow::invInstances;
InventoryWindow::InventoryWindow(Inventory *const inventory):
Window("Inventory", false, nullptr, "inventory.xml"),
- gcn::ActionListener(),
- gcn::KeyListener(),
- gcn::SelectionListener(),
+ ActionListener(),
+ KeyListener(),
+ SelectionListener(),
InventoryListener(),
mInventory(inventory),
mItems(new ItemContainer(this, mInventory)),
@@ -183,8 +151,8 @@ InventoryWindow::InventoryWindow(Inventory *const inventory):
mItems->addSelectionListener(this);
- gcn::ScrollArea *const invenScroll = new ScrollArea(
- mItems, getOptionBool("showbackground"), "inventory_background.xml");
+ gcn::ScrollArea *const invenScroll = new ScrollArea(this, mItems,
+ getOptionBool("showbackground"), "inventory_background.xml");
invenScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
const int size = config.getIntValue("fontSize");
@@ -295,7 +263,7 @@ void InventoryWindow::postInit()
slotsChanged(mInventory);
mItems->setSortType(mSortDropDown->getSelected());
- widgetResized(gcn::Event(nullptr));
+ widgetResized(Event(nullptr));
if (!isMainInventory())
setVisible(true);
}
@@ -335,7 +303,7 @@ void InventoryWindow::storeSortOrder()
}
}
-void InventoryWindow::action(const gcn::ActionEvent &event)
+void InventoryWindow::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "outfit")
@@ -459,13 +427,13 @@ void InventoryWindow::unselectItem()
mItems->selectNone();
}
-void InventoryWindow::widgetHidden(const gcn::Event &event)
+void InventoryWindow::widgetHidden(const Event &event)
{
Window::widgetHidden(event);
mItems->hidePopup();
}
-void InventoryWindow::mouseClicked(gcn::MouseEvent &event)
+void InventoryWindow::mouseClicked(MouseEvent &event)
{
Window::mouseClicked(event);
@@ -481,7 +449,7 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event)
&& inputManager.isActionActive(static_cast<int>(
Input::KEY_STOP_ATTACK)));
- if (!mod && !mod2 && event.getButton() == gcn::MouseEvent::RIGHT)
+ if (!mod && !mod2 && event.getButton() == MouseEvent::RIGHT)
{
Item *const item = mItems->getSelectedItem();
@@ -501,8 +469,8 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event)
if (!mInventory)
return;
- if (event.getButton() == gcn::MouseEvent::LEFT
- || event.getButton() == gcn::MouseEvent::RIGHT)
+ if (event.getButton() == MouseEvent::LEFT
+ || event.getButton() == MouseEvent::RIGHT)
{
Item *const item = mItems->getSelectedItem();
@@ -513,7 +481,7 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event)
{
if (mInventory->isMainInventory())
{
- if (event.getButton() == gcn::MouseEvent::RIGHT)
+ if (event.getButton() == MouseEvent::RIGHT)
{
ItemAmountWindow::showWindow(ItemAmountWindow::StoreAdd,
inventoryWindow, item);
@@ -527,7 +495,7 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event)
}
else
{
- if (event.getButton() == gcn::MouseEvent::RIGHT)
+ if (event.getButton() == MouseEvent::RIGHT)
{
ItemAmountWindow::showWindow(ItemAmountWindow::StoreRemove,
inventoryWindow, item);
@@ -544,7 +512,7 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event)
{
if (PlayerInfo::isItemProtected(item->getId()))
return;
- if (event.getButton() == gcn::MouseEvent::RIGHT)
+ if (event.getButton() == MouseEvent::RIGHT)
{
ItemAmountWindow::showWindow(ItemAmountWindow::TradeAdd,
tradeWindow, item);
@@ -588,15 +556,15 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event)
}
}
-void InventoryWindow::mouseMoved(gcn::MouseEvent &event)
+void InventoryWindow::mouseMoved(MouseEvent &event)
{
Window::mouseMoved(event);
- const gcn::Widget *const src = event.getSource();
+ const Widget *const src = event.getSource();
if (src == mSlotsBar || src == mWeightBar)
{
const int x = event.getX();
const int y = event.getY();
- const gcn::Rectangle &rect = mDimension;
+ const Rect &rect = mDimension;
mTextPopup->show(rect.x + x, rect.y + y, strprintf(_("Money: %s"),
Units::formatCurrency(PlayerInfo::getAttribute(
PlayerInfo::MONEY)).c_str()));
@@ -607,30 +575,24 @@ void InventoryWindow::mouseMoved(gcn::MouseEvent &event)
}
}
-void InventoryWindow::mouseExited(gcn::MouseEvent &event A_UNUSED)
+void InventoryWindow::mouseExited(MouseEvent &event A_UNUSED)
{
mTextPopup->hide();
}
-void InventoryWindow::keyPressed(gcn::KeyEvent &event)
+void InventoryWindow::keyPressed(KeyEvent &event)
{
- if (static_cast<KeyEvent*>(&event)->getActionId()
- == static_cast<int>(Input::KEY_GUI_MOD))
- {
+ if (event.getActionId() == static_cast<int>(Input::KEY_GUI_MOD))
mSplit = true;
- }
}
-void InventoryWindow::keyReleased(gcn::KeyEvent &event)
+void InventoryWindow::keyReleased(KeyEvent &event)
{
- if (static_cast<KeyEvent*>(&event)->getActionId()
- == static_cast<int>(Input::KEY_GUI_MOD))
- {
+ if (event.getActionId() == static_cast<int>(Input::KEY_GUI_MOD))
mSplit = false;
- }
}
-void InventoryWindow::valueChanged(const gcn::SelectionEvent &event A_UNUSED)
+void InventoryWindow::valueChanged(const SelectionEvent &event A_UNUSED)
{
if (!mInventory || !mInventory->isMainInventory())
return;
@@ -812,7 +774,7 @@ bool InventoryWindow::isAnyInputFocused()
return false;
}
-void InventoryWindow::widgetResized(const gcn::Event &event)
+void InventoryWindow::widgetResized(const Event &event)
{
Window::widgetResized(event);
diff --git a/src/gui/windows/inventorywindow.h b/src/gui/windows/inventorywindow.h
index 4e32f6fa2..c81e83d77 100644
--- a/src/gui/windows/inventorywindow.h
+++ b/src/gui/windows/inventorywindow.h
@@ -24,19 +24,19 @@
#define GUI_WINDOWS_INVENTORYWINDOW_H
#include "inventory.h"
-#include "depricatedlistener.h"
+
+#include "listeners/depricatedlistener.h"
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
-#include <guichan/keylistener.hpp>
-#include <guichan/selectionlistener.hpp>
+#include "listeners/actionlistener.h"
+#include "listeners/keylistener.h"
+#include "listeners/selectionlistener.h"
class Button;
class DropDown;
class Item;
class ItemContainer;
-class Label;
class LayoutCell;
class ProgressBar;
class SortListModelInv;
@@ -50,9 +50,9 @@ class TextPopup;
* \ingroup Interface
*/
class InventoryWindow final : public Window,
- public gcn::ActionListener,
- public gcn::KeyListener,
- public gcn::SelectionListener,
+ public ActionListener,
+ public KeyListener,
+ public SelectionListener,
public InventoryListener,
public DepricatedListener
{
@@ -76,7 +76,7 @@ class InventoryWindow final : public Window,
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
/**
* Returns the selected item.
@@ -91,27 +91,27 @@ class InventoryWindow final : public Window,
/**
* Handles closing of the window
*/
- void widgetHidden(const gcn::Event &event) override final;
+ void widgetHidden(const Event &event) override final;
/**
* Handles the mouse clicks.
*/
- void mouseClicked(gcn::MouseEvent &event) override final;
+ void mouseClicked(MouseEvent &event) override final;
/**
* Handles the key presses.
*/
- void keyPressed(gcn::KeyEvent &event) override final;
+ void keyPressed(KeyEvent &event) override final;
/**
* Handles the key releases.
*/
- void keyReleased(gcn::KeyEvent &event) override final;
+ void keyReleased(KeyEvent &event) override final;
/**
* Updates labels to currently selected item.
*/
- void valueChanged(const gcn::SelectionEvent &event) override final;
+ void valueChanged(const SelectionEvent &event) override final;
/**
* Sets whether the split button should be shown.
@@ -144,11 +144,11 @@ class InventoryWindow final : public Window,
bool isInputFocused() const A_WARN_UNUSED;
- void widgetResized(const gcn::Event &event) override final;
+ void widgetResized(const Event &event) override final;
- void mouseMoved(gcn::MouseEvent &event) override final;
+ void mouseMoved(MouseEvent &event) override final;
- void mouseExited(gcn::MouseEvent &event) override final;
+ void mouseExited(MouseEvent &event) override final;
void setVisible(bool visible) override final;
diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp
index 975892888..fc0c5880b 100644
--- a/src/gui/windows/itemamountwindow.cpp
+++ b/src/gui/windows/itemamountwindow.cpp
@@ -33,6 +33,8 @@
#include "net/net.h"
#include "gui/viewport.h"
+#include "gui/models/itemsmodel.h"
+
#include "gui/popups/itempopup.h"
#include "gui/windows/shopwindow.h"
@@ -50,55 +52,6 @@
#include "debug.h"
-class ItemsModal final : public gcn::ListModel
-{
-public:
- ItemsModal() :
- mStrings()
- {
- const std::map<int, ItemInfo*> &items = ItemDB::getItemInfos();
- std::list<std::string> tempStrings;
-
- for (std::map<int, ItemInfo*>::const_iterator
- i = items.begin(), i_end = items.end();
- i != i_end; ++i)
- {
- if (i->first < 0)
- continue;
-
- const ItemInfo &info = *i->second;
- const std::string name = info.getName();
- if (name != "unnamed" && !info.getName().empty()
- && info.getName() != "unnamed")
- {
- tempStrings.push_back(name);
- }
- }
- tempStrings.sort();
- FOR_EACH (std::list<std::string>::const_iterator, i, tempStrings)
- mStrings.push_back(*i);
- }
-
- A_DELETE_COPY(ItemsModal)
-
- ~ItemsModal()
- { }
-
- int getNumberOfElements() override final
- {
- return static_cast<int>(mStrings.size());
- }
-
- std::string getElementAt(int i) override final
- {
- if (i < 0 || i >= getNumberOfElements())
- return "???";
- return mStrings.at(i);
- }
-private:
- StringVect mStrings;
-};
-
void ItemAmountWindow::finish(Item *const item, const int amount,
const int price, const Usage usage)
{
@@ -138,8 +91,8 @@ void ItemAmountWindow::finish(Item *const item, const int amount,
ItemAmountWindow::ItemAmountWindow(const Usage usage, Window *const parent,
Item *const item, const int maxRange) :
Window("", false, parent, "amount.xml"),
- gcn::ActionListener(),
- gcn::KeyListener(),
+ ActionListener(),
+ KeyListener(),
mItemAmountTextField(new IntTextField(this, 1)),
mItemPriceTextField(nullptr),
mGPLabel(nullptr),
@@ -148,7 +101,7 @@ ItemAmountWindow::ItemAmountWindow(const Usage usage, Window *const parent,
mMax(maxRange),
mUsage(usage),
mItemPopup(new ItemPopup),
- mItemAmountSlide(new Slider(1.0, mMax)),
+ mItemAmountSlide(new Slider(this, 1.0, mMax)),
mItemPriceSlide(nullptr),
mItemDropDown(nullptr),
mItemsModal(nullptr),
@@ -182,7 +135,7 @@ ItemAmountWindow::ItemAmountWindow(const Usage usage, Window *const parent,
mItemPriceTextField->setWidth(35);
mItemPriceTextField->addKeyListener(this);
- mItemPriceSlide = new Slider(1.0, 10000000);
+ mItemPriceSlide = new Slider(this, 1.0, 10000000);
mItemPriceSlide->setHeight(10);
mItemPriceSlide->setActionEventId("slidePrice");
mItemPriceSlide->addActionListener(this);
@@ -313,7 +266,7 @@ ItemAmountWindow::~ItemAmountWindow()
}
// Show ItemTooltip
-void ItemAmountWindow::mouseMoved(gcn::MouseEvent &event)
+void ItemAmountWindow::mouseMoved(MouseEvent &event)
{
Window::mouseMoved(event);
@@ -328,7 +281,7 @@ void ItemAmountWindow::mouseMoved(gcn::MouseEvent &event)
}
// Hide ItemTooltip
-void ItemAmountWindow::mouseExited(gcn::MouseEvent &event A_UNUSED)
+void ItemAmountWindow::mouseExited(MouseEvent &event A_UNUSED)
{
if (mItemPopup)
mItemPopup->setVisible(false);
@@ -339,7 +292,7 @@ void ItemAmountWindow::resetAmount()
mItemAmountTextField->setValue(1);
}
-void ItemAmountWindow::action(const gcn::ActionEvent &event)
+void ItemAmountWindow::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "cancel")
@@ -435,7 +388,7 @@ void ItemAmountWindow::close()
scheduleDelete();
}
-void ItemAmountWindow::keyReleased(gcn::KeyEvent &keyEvent A_UNUSED)
+void ItemAmountWindow::keyReleased(KeyEvent &keyEvent A_UNUSED)
{
mItemAmountSlide->setValue2(mItemAmountTextField->getValue());
}
diff --git a/src/gui/windows/itemamountwindow.h b/src/gui/windows/itemamountwindow.h
index 7625c4a71..cf721ee30 100644
--- a/src/gui/windows/itemamountwindow.h
+++ b/src/gui/windows/itemamountwindow.h
@@ -25,8 +25,8 @@
#include "gui/widgets/window.h"
-#include <guichan/keylistener.hpp>
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
+#include "listeners/keylistener.h"
class DropDown;
class Icon;
@@ -43,8 +43,8 @@ class Slider;
* \ingroup Interface
*/
class ItemAmountWindow final : public Window,
- public gcn::ActionListener,
- public gcn::KeyListener
+ public ActionListener,
+ public KeyListener
{
public:
enum Usage
@@ -65,7 +65,7 @@ class ItemAmountWindow final : public Window,
/**
* Called when receiving actions from widget.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
/**
* Sets default amount value.
@@ -73,16 +73,16 @@ class ItemAmountWindow final : public Window,
void resetAmount();
// MouseListener
- void mouseMoved(gcn::MouseEvent &event) override final;
+ void mouseMoved(MouseEvent &event) override final;
- void mouseExited(gcn::MouseEvent &event) override final;
+ void mouseExited(MouseEvent &event) override final;
/**
* Schedules the Item Amount window for deletion.
*/
void close();
- void keyReleased(gcn::KeyEvent &keyEvent) override final;
+ void keyReleased(KeyEvent &keyEvent) override final;
/**
* Creates the dialog, or bypass it if there aren't enough items.
diff --git a/src/gui/windows/killstats.cpp b/src/gui/windows/killstats.cpp
index 0adabc3ad..710875a3c 100644
--- a/src/gui/windows/killstats.cpp
+++ b/src/gui/windows/killstats.cpp
@@ -40,7 +40,7 @@
KillStats::KillStats() :
// TRANSLATORS: kill stats window name
Window(_("Kill stats"), false, nullptr, "killstats.xml"),
- gcn::ActionListener(),
+ ActionListener(),
mKillCounter(0),
mExpCounter(0),
mKillTCounter(0),
@@ -156,7 +156,7 @@ KillStats::~KillStats()
{
}
-void KillStats::action(const gcn::ActionEvent &event)
+void KillStats::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "reset")
diff --git a/src/gui/windows/killstats.h b/src/gui/windows/killstats.h
index 094147383..486ec9135 100644
--- a/src/gui/windows/killstats.h
+++ b/src/gui/windows/killstats.h
@@ -23,9 +23,8 @@
#ifndef GUI_WINDOWS_KILLSTATS_H
#define GUI_WINDOWS_KILLSTATS_H
-#include <guichan/actionlistener.hpp>
-
-#include "depricatedlistener.h"
+#include "listeners/actionlistener.h"
+#include "listeners/depricatedlistener.h"
#include "gui/widgets/window.h"
@@ -33,7 +32,7 @@ class Label;
class Button;
class KillStats final : public Window,
- private gcn::ActionListener,
+ private ActionListener,
public DepricatedListener
{
public:
@@ -52,7 +51,7 @@ class KillStats final : public Window,
/**
* Stuff.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
void gainXp(int Xp);
diff --git a/src/gui/windows/logindialog.cpp b/src/gui/windows/logindialog.cpp
index 8ec6144a0..71abf153a 100644
--- a/src/gui/windows/logindialog.cpp
+++ b/src/gui/windows/logindialog.cpp
@@ -25,8 +25,12 @@
#include "client.h"
#include "configuration.h"
+#include "events/keyevent.h"
+
#include "input/keydata.h"
-#include "input/keyevent.h"
+
+#include "gui/models/updatelistmodel.h"
+#include "gui/models/updatetypemodel.h"
#include "gui/windows/confirmdialog.h"
@@ -53,17 +57,17 @@ std::string LoginDialog::savedPasswordKey("");
namespace
{
- struct OpenUrlListener : public gcn::ActionListener
+ struct OpenUrlListener : public ActionListener
{
OpenUrlListener() :
- gcn::ActionListener(),
+ ActionListener(),
url()
{
}
A_DELETE_COPY(OpenUrlListener)
- void action(const gcn::ActionEvent &event) override final
+ void action(const ActionEvent &event) override final
{
if (event.getId() == "yes")
openBrowser(url);
@@ -73,78 +77,12 @@ namespace
} urlListener;
} // namespace
-const char *UPDATE_TYPE_TEXT[3] =
-{
- // TRANSLATORS: update type
- N_("Normal"),
- // TRANSLATORS: update type
- N_("Auto Close"),
- // TRANSLATORS: update type
- N_("Skip"),
-};
-
-class UpdateTypeModel final : public gcn::ListModel
-{
- public:
- UpdateTypeModel()
- { }
-
- A_DELETE_COPY(UpdateTypeModel)
-
- ~UpdateTypeModel()
- { }
-
- int getNumberOfElements() override final
- {
- return 3;
- }
-
- std::string getElementAt(int i) override final
- {
- if (i >= getNumberOfElements() || i < 0)
- return "???";
- return gettext(UPDATE_TYPE_TEXT[i]);
- }
-};
-
-class UpdateListModel final : public gcn::ListModel
-{
- public:
- explicit UpdateListModel(LoginData *const data) :
- gcn::ListModel(),
- mLoginData(data)
- {
- }
-
- A_DELETE_COPY(UpdateListModel)
-
- ~UpdateListModel()
- { }
-
- int getNumberOfElements() override final
- {
- if (!mLoginData)
- return 0;
- return static_cast<int>(mLoginData->updateHosts.size());
- }
-
- std::string getElementAt(int i) override final
- {
- if (!mLoginData || i >= getNumberOfElements() || i < 0)
- return "???";
- return mLoginData->updateHosts[i];
- }
-
- protected:
- LoginData *mLoginData;
-};
-
LoginDialog::LoginDialog(LoginData *const data, std::string serverName,
std::string *const updateHost):
// TRANSLATORS: login dialog name
Window(_("Login"), false, nullptr, "login.xml"),
- gcn::ActionListener(),
- gcn::KeyListener(),
+ ActionListener(),
+ KeyListener(),
mLoginData(data),
mUserField(new TextField(this, mLoginData->username)),
mPassField(new PasswordField(this, mLoginData->password)),
@@ -276,7 +214,7 @@ LoginDialog::~LoginDialog()
mUpdateListModel = nullptr;
}
-void LoginDialog::action(const gcn::ActionEvent &event)
+void LoginDialog::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "login" && canSubmit())
@@ -318,7 +256,7 @@ void LoginDialog::action(const gcn::ActionEvent &event)
}
}
-void LoginDialog::keyPressed(gcn::KeyEvent &keyEvent)
+void LoginDialog::keyPressed(KeyEvent &keyEvent)
{
if (keyEvent.isConsumed())
{
@@ -326,16 +264,15 @@ void LoginDialog::keyPressed(gcn::KeyEvent &keyEvent)
return;
}
- const int actionId = static_cast<KeyEvent*>(
- &keyEvent)->getActionId();
+ const int actionId = keyEvent.getActionId();
if (actionId == static_cast<int>(Input::KEY_GUI_CANCEL))
{
- action(gcn::ActionEvent(nullptr, mServerButton->getActionEventId()));
+ action(ActionEvent(nullptr, mServerButton->getActionEventId()));
}
else if (actionId == static_cast<int>(Input::KEY_GUI_SELECT)
|| actionId == static_cast<int>(Input::KEY_GUI_SELECT2))
{
- action(gcn::ActionEvent(nullptr, mLoginButton->getActionEventId()));
+ action(ActionEvent(nullptr, mLoginButton->getActionEventId()));
}
else
{
diff --git a/src/gui/windows/logindialog.h b/src/gui/windows/logindialog.h
index c9d2ad61f..7150b62c1 100644
--- a/src/gui/windows/logindialog.h
+++ b/src/gui/windows/logindialog.h
@@ -25,8 +25,8 @@
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
-#include <guichan/keylistener.hpp>
+#include "listeners/actionlistener.h"
+#include "listeners/keylistener.h"
#include <string>
@@ -44,8 +44,9 @@ class UpdateTypeModel;
*
* \ingroup Interface
*/
-class LoginDialog final : public Window, public gcn::ActionListener,
- public gcn::KeyListener
+class LoginDialog final : public Window,
+ public ActionListener,
+ public KeyListener
{
public:
/**
@@ -65,12 +66,12 @@ class LoginDialog final : public Window, public gcn::ActionListener,
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
/**
* Called when a key is pressed in one of the text fields.
*/
- void keyPressed(gcn::KeyEvent &keyEvent) override final;
+ void keyPressed(KeyEvent &keyEvent) override final;
void close() override final;
diff --git a/src/gui/windows/minimap.cpp b/src/gui/windows/minimap.cpp
index 02be64a13..ef1830763 100644
--- a/src/gui/windows/minimap.cpp
+++ b/src/gui/windows/minimap.cpp
@@ -213,7 +213,7 @@ void Minimap::setMap(const Map *const map)
setHeight(height);
}
- const gcn::Rectangle &rect = mDimension;
+ const Rect &rect = mDimension;
setDefaultSize(rect.x, rect.y, rect.width, rect.height);
resetToDefaultSize();
@@ -233,7 +233,7 @@ void Minimap::toggle()
mShow = isWindowVisible();
}
-void Minimap::draw(gcn::Graphics *graphics)
+void Minimap::draw(Graphics *graphics)
{
BLOCK_START("Minimap::draw")
Window::draw(graphics);
@@ -244,9 +244,7 @@ void Minimap::draw(gcn::Graphics *graphics)
return;
}
- Graphics *const graph = static_cast<Graphics*>(graphics);
-
- const gcn::Rectangle a = getChildrenArea();
+ const Rect a = getChildrenArea();
graphics->pushClipArea(a);
@@ -286,7 +284,7 @@ void Minimap::draw(gcn::Graphics *graphics)
mMapOriginY = 0;
}
- graph->drawImage2(mMapImage, mMapOriginX, mMapOriginY);
+ graphics->drawImage(mMapImage, mMapOriginX, mMapOriginY);
}
const ActorSprites &actors = actorManager->getAll();
@@ -348,7 +346,7 @@ void Minimap::draw(gcn::Graphics *graphics)
dotSize - 1) * mWidthProportion);
const Vector &pos = being->getPosition();
- graphics->fillRectangle(gcn::Rectangle(
+ graphics->fillRectangle(Rect(
static_cast<float>(pos.x * mWidthProportion) / 32
+ mMapOriginX - offsetWidth,
static_cast<float>(pos.y * mHeightProportion) / 32
@@ -386,7 +384,7 @@ void Minimap::draw(gcn::Graphics *graphics)
const int offsetWidth = static_cast<int>(
mWidthProportion);
- graphics->fillRectangle(gcn::Rectangle(
+ graphics->fillRectangle(Rect(
static_cast<int>(member->getX()
* mWidthProportion) + mMapOriginX - offsetWidth,
static_cast<int>(member->getY()
@@ -401,8 +399,8 @@ void Minimap::draw(gcn::Graphics *graphics)
const Vector &pos = player_node->getPosition();
- const int gw = graph->getWidth();
- const int gh = graph->getHeight();
+ const int gw = graphics->getWidth();
+ const int gh = graphics->getHeight();
int x = static_cast<float>((pos.x - (gw / 2)
+ viewport->getCameraRelativeX())
* mWidthProportion) / 32 + mMapOriginX;
@@ -431,19 +429,19 @@ void Minimap::draw(gcn::Graphics *graphics)
}
graphics->setColor(userPalette->getColor(UserPalette::PC));
- graphics->drawRectangle(gcn::Rectangle(x, y, w, h));
+ graphics->drawRectangle(Rect(x, y, w, h));
graphics->popClipArea();
BLOCK_END("Minimap::draw")
}
-void Minimap::mouseReleased(gcn::MouseEvent &event)
+void Minimap::mouseReleased(MouseEvent &event)
{
Window::mouseReleased(event);
if (!player_node || !viewport)
return;
- if (event.getButton() == gcn::MouseEvent::LEFT)
+ if (event.getButton() == MouseEvent::LEFT)
{
int x = event.getX();
int y = event.getY();
@@ -451,7 +449,7 @@ void Minimap::mouseReleased(gcn::MouseEvent &event)
player_node->navigateTo(x, y);
}
- else if (event.getButton() == gcn::MouseEvent::RIGHT)
+ else if (event.getButton() == MouseEvent::RIGHT)
{
int x = event.getX();
int y = event.getY();
@@ -460,16 +458,16 @@ void Minimap::mouseReleased(gcn::MouseEvent &event)
}
}
-void Minimap::mouseMoved(gcn::MouseEvent &event)
+void Minimap::mouseMoved(MouseEvent &event)
{
Window::mouseMoved(event);
const int x = event.getX();
const int y = event.getY();
- const gcn::Rectangle &rect = mDimension;
+ const Rect &rect = mDimension;
mTextPopup->show(x + rect.x, y + rect.y, mCaption);
}
-void Minimap::mouseExited(gcn::MouseEvent &event)
+void Minimap::mouseExited(MouseEvent &event)
{
Window::mouseExited(event);
mTextPopup->hide();
@@ -477,7 +475,7 @@ void Minimap::mouseExited(gcn::MouseEvent &event)
void Minimap::screenToMap(int &x, int &y)
{
- const gcn::Rectangle a = getChildrenArea();
+ const Rect a = getChildrenArea();
x = (x - a.x - mMapOriginX + mWidthProportion) / mWidthProportion;
y = (y - a.y - mMapOriginY + mHeightProportion) / mHeightProportion;
}
diff --git a/src/gui/windows/minimap.h b/src/gui/windows/minimap.h
index 90c08db0f..d99aea13d 100644
--- a/src/gui/windows/minimap.h
+++ b/src/gui/windows/minimap.h
@@ -60,13 +60,13 @@ class Minimap final : public Window, public ConfigListener
/**
* Draws the minimap.
*/
- void draw(gcn::Graphics *graphics) override final;
+ void draw(Graphics *graphics) override final;
- void mouseMoved(gcn::MouseEvent &event) override final;
+ void mouseMoved(MouseEvent &event) override final;
- void mouseReleased(gcn::MouseEvent &event) override final;
+ void mouseReleased(MouseEvent &event) override final;
- void mouseExited(gcn::MouseEvent &event) override final;
+ void mouseExited(MouseEvent &event) override final;
void screenToMap(int &x, int &y);
diff --git a/src/gui/windows/ministatuswindow.cpp b/src/gui/windows/ministatuswindow.cpp
index b5832c7b7..db4555b26 100644
--- a/src/gui/windows/ministatuswindow.cpp
+++ b/src/gui/windows/ministatuswindow.cpp
@@ -308,21 +308,21 @@ void MiniStatusWindow::logic()
BLOCK_END("MiniStatusWindow::logic")
}
-void MiniStatusWindow::draw(gcn::Graphics *graphics)
+void MiniStatusWindow::draw(Graphics *graphics)
{
BLOCK_START("MiniStatusWindow::draw")
drawChildren(graphics);
BLOCK_END("MiniStatusWindow::draw")
}
-void MiniStatusWindow::mouseMoved(gcn::MouseEvent &event)
+void MiniStatusWindow::mouseMoved(MouseEvent &event)
{
Popup::mouseMoved(event);
const int x = event.getX();
const int y = event.getY();
- const gcn::Rectangle &rect = mDimension;
+ const Rect &rect = mDimension;
if (event.getSource() == mStatusBar)
{
mStatusPopup->view(x + rect.x, y + rect.y);
@@ -433,12 +433,12 @@ void MiniStatusWindow::mouseMoved(gcn::MouseEvent &event)
}
}
-void MiniStatusWindow::mousePressed(gcn::MouseEvent &event)
+void MiniStatusWindow::mousePressed(MouseEvent &event)
{
if (!viewport)
return;
- if (event.getButton() == gcn::MouseEvent::RIGHT)
+ if (event.getButton() == MouseEvent::RIGHT)
{
const ProgressBar *const bar = dynamic_cast<ProgressBar*>(
event.getSource());
@@ -452,7 +452,7 @@ void MiniStatusWindow::mousePressed(gcn::MouseEvent &event)
}
}
-void MiniStatusWindow::mouseExited(gcn::MouseEvent &event)
+void MiniStatusWindow::mouseExited(MouseEvent &event)
{
Popup::mouseExited(event);
@@ -535,12 +535,12 @@ void MiniStatusWindow::updateArrows()
StatusWindow::updateArrowsBar(mArrowsBar);
}
-gcn::Rectangle MiniStatusWindow::getChildrenArea()
+Rect MiniStatusWindow::getChildrenArea()
{
const int padding = mPadding;
const int padding2 = padding * 2;
- const gcn::Rectangle &rect = mDimension;
- return gcn::Rectangle(padding, padding,
+ const Rect &rect = mDimension;
+ return Rect(padding, padding,
rect.width - padding2,
rect.height - padding2);
}
diff --git a/src/gui/windows/ministatuswindow.h b/src/gui/windows/ministatuswindow.h
index 2a5903eca..0344d6c3a 100644
--- a/src/gui/windows/ministatuswindow.h
+++ b/src/gui/windows/ministatuswindow.h
@@ -24,7 +24,8 @@
#define GUI_WINDOWS_MINISTATUSWINDOW_H
#include "inventory.h"
-#include "depricatedlistener.h"
+
+#include "listeners/depricatedlistener.h"
#include "gui/widgets/popup.h"
@@ -68,13 +69,13 @@ class MiniStatusWindow final : public Popup,
void logic() override final;
- void draw(gcn::Graphics *graphics) override final;
+ void draw(Graphics *graphics) override final;
- void mouseMoved(gcn::MouseEvent &mouseEvent) override final;
+ void mouseMoved(MouseEvent &mouseEvent) override final;
- void mousePressed(gcn::MouseEvent &event) override final;
+ void mousePressed(MouseEvent &event) override final;
- void mouseExited(gcn::MouseEvent &event) override final;
+ void mouseExited(MouseEvent &event) override final;
void showBar(const std::string &name, const bool visible);
@@ -87,7 +88,7 @@ class MiniStatusWindow final : public Popup,
std::vector <ProgressBar*> &getBars() A_WARN_UNUSED
{ return mBars; }
- gcn::Rectangle getChildrenArea() override final A_WARN_UNUSED;
+ Rect getChildrenArea() override final A_WARN_UNUSED;
#ifdef USE_PROFILER
void logicChildren();
diff --git a/src/gui/windows/npcdialog.cpp b/src/gui/windows/npcdialog.cpp
index b441b724c..a1b2109fb 100644
--- a/src/gui/windows/npcdialog.cpp
+++ b/src/gui/windows/npcdialog.cpp
@@ -32,8 +32,8 @@
#include "being/being.h"
+#include "gui/font.h"
#include "gui/gui.h"
-#include "gui/sdlfont.h"
#include "gui/viewport.h"
#include "gui/windows/inventorywindow.h"
@@ -59,8 +59,6 @@
#include "utils/copynpaste.h"
#include "utils/gettext.h"
-#include <guichan/font.hpp>
-
#include "debug.h"
// TRANSLATORS: npc dialog button
@@ -80,18 +78,18 @@ typedef std::vector<Image *>::iterator ImageVectorIter;
NpcDialog::NpcDialog(const int npcId) :
// TRANSLATORS: npc dialog name
Window(_("NPC"), false, nullptr, "npc.xml"),
- gcn::ActionListener(),
+ ActionListener(),
mNpcId(npcId),
mDefaultInt(0),
mDefaultString(),
mTextBox(new BrowserBox(this, BrowserBox::AUTO_WRAP, true,
"browserbox.xml")),
- mScrollArea(new ScrollArea(mTextBox,
+ mScrollArea(new ScrollArea(this, mTextBox,
getOptionBool("showtextbackground"), "npc_textbackground.xml")),
mText(),
mNewText(),
mItemList(new ExtendedListBox(this, this, "extendedlistbox.xml")),
- mListScrollArea(new ScrollArea(mItemList,
+ mListScrollArea(new ScrollArea(this, mItemList,
getOptionBool("showlistbackground"), "npc_listbackground.xml")),
mItems(),
mImages(),
@@ -113,7 +111,7 @@ NpcDialog::NpcDialog(const int npcId) :
mResetButton(new Button(this, _("Reset"), "reset", this)),
mInventory(new Inventory(Inventory::NPC, 1)),
mItemContainer(new ItemContainer(this, mInventory)),
- mItemScrollArea(new ScrollArea(mItemContainer,
+ mItemScrollArea(new ScrollArea(this, mItemContainer,
getOptionBool("showitemsbackground"), "npc_listbackground.xml")),
mInputState(NPC_INPUT_NONE),
mActionState(NPC_ACTION_WAIT),
@@ -170,7 +168,7 @@ NpcDialog::NpcDialog(const int npcId) :
mTextField->setVisible(true);
mIntField->setVisible(true);
- const gcn::Font *const fnt = mButton->getFont();
+ const Font *const fnt = mButton->getFont();
int width = std::max(fnt->getWidth(CAPTION_WAITING),
fnt->getWidth(CAPTION_NEXT));
width = std::max(width, fnt->getWidth(CAPTION_CLOSE));
@@ -295,7 +293,7 @@ void NpcDialog::showCloseButton()
buildLayout();
}
-void NpcDialog::action(const gcn::ActionEvent &event)
+void NpcDialog::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "ok")
@@ -965,10 +963,10 @@ void NpcDialog::clearDialogs()
mNpcDialogs.clear();
}
-void NpcDialog::mousePressed(gcn::MouseEvent &event)
+void NpcDialog::mousePressed(MouseEvent &event)
{
Window::mousePressed(event);
- if (event.getButton() == gcn::MouseEvent::RIGHT
+ if (event.getButton() == MouseEvent::RIGHT
&& event.getSource() == mTextBox)
{
if (viewport)
diff --git a/src/gui/windows/npcdialog.h b/src/gui/windows/npcdialog.h
index 5e679d7d1..5188c2fe2 100644
--- a/src/gui/windows/npcdialog.h
+++ b/src/gui/windows/npcdialog.h
@@ -23,14 +23,15 @@
#ifndef GUI_WINDOWS_NPCDIALOG_H
#define GUI_WINDOWS_NPCDIALOG_H
-#include "configlistener.h"
+#include "listeners/configlistener.h"
+
+#include "gui/models/extendedlistmodel.h"
-#include "gui/widgets/extendedlistmodel.h"
#include "gui/widgets/window.h"
#include "utils/stringvector.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
#include <list>
@@ -45,7 +46,6 @@ class ItemContainer;
class NpcDialog;
class PlayerBox;
class ScrollArea;
-class TextBox;
class TextField;
typedef std::map<int, NpcDialog*> NpcDialogs;
@@ -56,7 +56,7 @@ typedef std::map<int, NpcDialog*> NpcDialogs;
* \ingroup Interface
*/
class NpcDialog final : public Window,
- public gcn::ActionListener,
+ public ActionListener,
public ExtendedListModel,
public ConfigListener
{
@@ -77,7 +77,7 @@ class NpcDialog final : public Window,
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
/**
* Sets the text shows in the dialog.
@@ -210,7 +210,7 @@ class NpcDialog final : public Window,
void clearRows();
- void mousePressed(gcn::MouseEvent &event);
+ void mousePressed(MouseEvent &event);
int isCloseState() const
{ return mActionState == NPC_ACTION_CLOSE; }
diff --git a/src/gui/windows/npcpostdialog.cpp b/src/gui/windows/npcpostdialog.cpp
index 63ae6f53b..3c63775fe 100644
--- a/src/gui/windows/npcpostdialog.cpp
+++ b/src/gui/windows/npcpostdialog.cpp
@@ -42,7 +42,7 @@ NpcPostDialog::DialogList NpcPostDialog::instances;
NpcPostDialog::NpcPostDialog(const int npcId):
// TRANSLATORS: npc post dialog caption
Window(_("NPC"), false, nullptr, "npcpost.xml"),
- gcn::ActionListener(),
+ ActionListener(),
mNpcId(npcId),
mText(new TextBox(this)),
mSender(new TextField(this))
@@ -74,9 +74,9 @@ void NpcPostDialog::postInit()
mText->setEditable(true);
// create scroll box for letter text
- ScrollArea *const scrollArea = new ScrollArea(mText);
+ ScrollArea *const scrollArea = new ScrollArea(this, mText);
scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
- scrollArea->setDimension(gcn::Rectangle(
+ scrollArea->setDimension(Rect(
5, mSender->getHeight() + 5,
380, 140 - (mSender->getHeight() + sendButton->getHeight())));
@@ -98,7 +98,7 @@ NpcPostDialog::~NpcPostDialog()
instances.remove(this);
}
-void NpcPostDialog::action(const gcn::ActionEvent &event)
+void NpcPostDialog::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "send")
diff --git a/src/gui/windows/npcpostdialog.h b/src/gui/windows/npcpostdialog.h
index e111f150e..5396aad6e 100644
--- a/src/gui/windows/npcpostdialog.h
+++ b/src/gui/windows/npcpostdialog.h
@@ -25,13 +25,13 @@
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
class TextBox;
class TextField;
class NpcPostDialog final : public Window,
- public gcn::ActionListener
+ public ActionListener
{
public:
/**
@@ -48,7 +48,7 @@ class NpcPostDialog final : public Window,
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
void setVisible(bool visible) override final;
diff --git a/src/gui/windows/okdialog.cpp b/src/gui/windows/okdialog.cpp
index c16123abd..3d734b7ad 100644
--- a/src/gui/windows/okdialog.cpp
+++ b/src/gui/windows/okdialog.cpp
@@ -30,7 +30,7 @@
#include "utils/gettext.h"
-#include <guichan/font.hpp>
+#include "gui/font.h"
#include "debug.h"
@@ -40,7 +40,7 @@ OkDialog::OkDialog(const std::string &restrict title,
const bool showCenter, Window *const parent,
const int minWidth) :
Window(title, modal, parent, "ok.xml"),
- gcn::ActionListener(),
+ ActionListener(),
mTextBox(new TextBox(this))
{
mTextBox->setEditable(false);
@@ -84,7 +84,7 @@ OkDialog::OkDialog(const std::string &restrict title,
soundManager.playGuiSound(SOUND_ERROR);
}
-void OkDialog::action(const gcn::ActionEvent &event)
+void OkDialog::action(const ActionEvent &event)
{
setActionEventId(event.getId());
distributeActionEvent();
diff --git a/src/gui/windows/okdialog.h b/src/gui/windows/okdialog.h
index 7d2ff070b..b8236dfbc 100644
--- a/src/gui/windows/okdialog.h
+++ b/src/gui/windows/okdialog.h
@@ -27,7 +27,7 @@
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
class TextBox;
@@ -44,7 +44,7 @@ enum
* \ingroup GUI
*/
class OkDialog final : public Window,
- public gcn::ActionListener
+ public ActionListener
{
public:
/**
@@ -63,7 +63,7 @@ class OkDialog final : public Window,
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
private:
TextBox *mTextBox;
diff --git a/src/gui/windows/outfitwindow.cpp b/src/gui/windows/outfitwindow.cpp
index d686056ac..6fcea7d3a 100644
--- a/src/gui/windows/outfitwindow.cpp
+++ b/src/gui/windows/outfitwindow.cpp
@@ -51,7 +51,7 @@
OutfitWindow::OutfitWindow():
// TRANSLATORS: outfits window name
Window(_("Outfits"), false, nullptr, "outfits.xml"),
- gcn::ActionListener(),
+ ActionListener(),
// TRANSLATORS: outfits window button
mPreviousButton(new Button(this, _("<"), "previous", this)),
// TRANSLATORS: outfits window button
@@ -91,8 +91,8 @@ OutfitWindow::OutfitWindow():
setMinWidth(145);
setMinHeight(220);
- mCurrentLabel->setAlignment(gcn::Graphics::CENTER);
- mKeyLabel->setAlignment(gcn::Graphics::CENTER);
+ mCurrentLabel->setAlignment(Graphics::CENTER);
+ mKeyLabel->setAlignment(Graphics::CENTER);
mUnequipCheck->setActionEventId("unequip");
mUnequipCheck->addActionListener(this);
@@ -225,7 +225,7 @@ void OutfitWindow::save() const
serverConfig.setValue("OutfitAwayIndex", mAwayOutfit);
}
-void OutfitWindow::action(const gcn::ActionEvent &event)
+void OutfitWindow::action(const ActionEvent &event)
{
const std::string eventId = event.getId();
if (eventId == "next")
@@ -310,11 +310,10 @@ void OutfitWindow::copyOutfit(const int src, const int dst)
save();
}
-void OutfitWindow::draw(gcn::Graphics *graphics)
+void OutfitWindow::draw(Graphics *graphics)
{
BLOCK_START("OutfitWindow::draw")
Window::draw(graphics);
- Graphics *const g = static_cast<Graphics*>(graphics);
if (mCurrentOutfit < 0 || mCurrentOutfit
>= static_cast<signed int>(OUTFITS_COUNT))
@@ -326,12 +325,12 @@ void OutfitWindow::draw(gcn::Graphics *graphics)
{
const int itemX = mPadding + ((i % mGridWidth) * mBoxWidth);
const int itemY = mPadding + mTitleBarHeight
- + ((i / mGridWidth) * mBoxHeight);
+ + ((i / static_cast<unsigned int>(mGridWidth)) * mBoxHeight);
graphics->setColor(mBorderColor);
- graphics->drawRectangle(gcn::Rectangle(itemX, itemY, 32, 32));
+ graphics->drawRectangle(Rect(itemX, itemY, 32, 32));
graphics->setColor(mBackgroundColor);
- graphics->fillRectangle(gcn::Rectangle(itemX, itemY, 32, 32));
+ graphics->fillRectangle(Rect(itemX, itemY, 32, 32));
if (mItems[mCurrentOutfit][i] < 0)
continue;
@@ -348,7 +347,7 @@ void OutfitWindow::draw(gcn::Graphics *graphics)
const Image *const image = item->getImage();
if (image)
{
- g->drawImage2(image, itemX, itemY);
+ graphics->drawImage(image, itemX, itemY);
foundItem = true;
}
}
@@ -359,7 +358,7 @@ void OutfitWindow::draw(gcn::Graphics *graphics)
mItemColors[mCurrentOutfit][i]);
if (image)
{
- g->drawImage2(image, itemX, itemY);
+ graphics->drawImage(image, itemX, itemY);
image->decRef();
}
}
@@ -367,9 +366,9 @@ void OutfitWindow::draw(gcn::Graphics *graphics)
BLOCK_END("OutfitWindow::draw")
}
-void OutfitWindow::mouseDragged(gcn::MouseEvent &event)
+void OutfitWindow::mouseDragged(MouseEvent &event)
{
- if (event.getButton() == gcn::MouseEvent::LEFT)
+ if (event.getButton() == MouseEvent::LEFT)
{
if (dragDrop.isEmpty() && mItemClicked)
{
@@ -410,12 +409,12 @@ void OutfitWindow::mouseDragged(gcn::MouseEvent &event)
Window::mouseDragged(event);
}
-void OutfitWindow::mousePressed(gcn::MouseEvent &event)
+void OutfitWindow::mousePressed(MouseEvent &event)
{
const int index = getIndexFromGrid(event.getX(), event.getY());
if (index == -1)
{
- if (event.getButton() == gcn::MouseEvent::RIGHT && viewport)
+ if (event.getButton() == MouseEvent::RIGHT && viewport)
{
viewport->showOutfitsPopup();
event.consume();
@@ -447,9 +446,9 @@ void OutfitWindow::mousePressed(gcn::MouseEvent &event)
Window::mousePressed(event);
}
-void OutfitWindow::mouseReleased(gcn::MouseEvent &event)
+void OutfitWindow::mouseReleased(MouseEvent &event)
{
- if (event.getButton() == gcn::MouseEvent::LEFT)
+ if (event.getButton() == MouseEvent::LEFT)
{
if (mCurrentOutfit < 0 || mCurrentOutfit
>= static_cast<signed int>(OUTFITS_COUNT))
@@ -484,7 +483,7 @@ void OutfitWindow::mouseReleased(gcn::MouseEvent &event)
int OutfitWindow::getIndexFromGrid(const int pointX, const int pointY) const
{
- const gcn::Rectangle tRect = gcn::Rectangle(mPadding, mTitleBarHeight,
+ const Rect tRect = Rect(mPadding, mTitleBarHeight,
mGridWidth * mBoxWidth, mGridHeight * mBoxHeight);
if (!tRect.isPointInRect(pointX, pointY))
return -1;
diff --git a/src/gui/windows/outfitwindow.h b/src/gui/windows/outfitwindow.h
index eeedc2ec6..55948f834 100644
--- a/src/gui/windows/outfitwindow.h
+++ b/src/gui/windows/outfitwindow.h
@@ -25,7 +25,7 @@
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
const unsigned int OUTFITS_COUNT = 100;
const unsigned int OUTFIT_ITEM_COUNT = 16;
@@ -35,7 +35,7 @@ class CheckBox;
class Label;
class OutfitWindow final : public Window,
- private gcn::ActionListener
+ private ActionListener
{
public:
/**
@@ -50,15 +50,15 @@ class OutfitWindow final : public Window,
*/
~OutfitWindow();
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
- void draw(gcn::Graphics *graphics) override final;
+ void draw(Graphics *graphics) override final;
- void mousePressed(gcn::MouseEvent &event) override final;
+ void mousePressed(MouseEvent &event) override final;
- void mouseDragged(gcn::MouseEvent &event) override final;
+ void mouseDragged(MouseEvent &event) override final;
- void mouseReleased(gcn::MouseEvent &event) override final;
+ void mouseReleased(MouseEvent &event) override final;
void load(const bool oldConfig = false);
@@ -115,8 +115,8 @@ class OutfitWindow final : public Window,
int mItems[OUTFITS_COUNT + 1][OUTFIT_ITEM_COUNT];
int mAwayOutfit;
- gcn::Color mBorderColor;
- gcn::Color mBackgroundColor;
+ Color mBorderColor;
+ Color mBackgroundColor;
unsigned char mItemColors[OUTFITS_COUNT + 1][OUTFIT_ITEM_COUNT];
bool mItemClicked;
bool mItemsUnequip[OUTFITS_COUNT];
diff --git a/src/gui/windows/questswindow.cpp b/src/gui/windows/questswindow.cpp
index e5f599f0f..eee3e4259 100644
--- a/src/gui/windows/questswindow.cpp
+++ b/src/gui/windows/questswindow.cpp
@@ -26,13 +26,15 @@
#include "being/localplayer.h"
-#include "gui/sdlfont.h"
+#include "gui/font.h"
+#include "gui/gui.h"
+
+#include "gui/models/questsmodel.h"
#include "gui/widgets/browserbox.h"
#include "gui/widgets/button.h"
#include "gui/widgets/layout.h"
#include "gui/widgets/extendedlistbox.h"
-#include "gui/widgets/extendednamesmodel.h"
#include "gui/widgets/itemlinkhandler.h"
#include "gui/widgets/scrollarea.h"
@@ -87,20 +89,6 @@ struct QuestItem final
bool broken;
};
-class QuestsModel final : public ExtendedNamesModel
-{
- public:
- QuestsModel() :
- ExtendedNamesModel()
- {
- }
-
- A_DELETE_COPY(QuestsModel)
-
- ~QuestsModel()
- { }
-};
-
struct QuestEffect final
{
QuestEffect() :
@@ -122,15 +110,15 @@ struct QuestEffect final
QuestsWindow::QuestsWindow() :
// TRANSLATORS: quests window name
Window(_("Quests"), false, nullptr, "quests.xml"),
- gcn::ActionListener(),
+ ActionListener(),
mQuestsModel(new QuestsModel),
mQuestsListBox(new ExtendedListBox(this,
mQuestsModel, "extendedlistbox.xml")),
- mQuestScrollArea(new ScrollArea(mQuestsListBox,
+ mQuestScrollArea(new ScrollArea(this, mQuestsListBox,
getOptionBool("showlistbackground"), "quests_list_background.xml")),
mItemLinkHandler(new ItemLinkHandler),
mText(new BrowserBox(this, BrowserBox::AUTO_WRAP, true, "browserbox.xml")),
- mTextScrollArea(new ScrollArea(mText,
+ mTextScrollArea(new ScrollArea(this, mText,
getOptionBool("showtextbackground"), "quests_text_background.xml")),
// TRANSLATORS: quests window button
mCloseButton(new Button(this, _("Close"), "close", this)),
@@ -166,7 +154,7 @@ QuestsWindow::QuestsWindow() :
mText->setLinkHandler(mItemLinkHandler);
mTextScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
mQuestsListBox->setWidth(500);
- if (gui->getNpcFont()->getHeight() < 20)
+ if (gui && gui->getNpcFont()->getHeight() < 20)
mQuestsListBox->setRowHeight(20);
else
mQuestsListBox->setRowHeight(gui->getNpcFont()->getHeight());
@@ -318,7 +306,7 @@ void QuestsWindow::loadEffect(const int var, const XmlNodePtr node)
mAllEffects.push_back(effect);
}
-void QuestsWindow::action(const gcn::ActionEvent &event)
+void QuestsWindow::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "select")
diff --git a/src/gui/windows/questswindow.h b/src/gui/windows/questswindow.h
index 7ecc86c84..9000fcaa9 100644
--- a/src/gui/windows/questswindow.h
+++ b/src/gui/windows/questswindow.h
@@ -27,7 +27,7 @@
#include "utils/xml.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
#include <map>
#include <vector>
@@ -48,7 +48,7 @@ typedef std::map<int, const QuestEffect*> NpcQuestEffectMap;
typedef NpcQuestEffectMap::const_iterator NpcQuestEffectMapCIter;
class QuestsWindow final : public Window,
- public gcn::ActionListener
+ public ActionListener
{
public:
QuestsWindow();
@@ -57,7 +57,7 @@ class QuestsWindow final : public Window,
~QuestsWindow();
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
void updateQuest(const int var, const int val);
diff --git a/src/gui/windows/quitdialog.cpp b/src/gui/windows/quitdialog.cpp
index ff9f669b7..98aa70c70 100644
--- a/src/gui/windows/quitdialog.cpp
+++ b/src/gui/windows/quitdialog.cpp
@@ -28,8 +28,9 @@
#include "soundconsts.h"
#include "soundmanager.h"
+#include "events/keyevent.h"
+
#include "input/keydata.h"
-#include "input/keyevent.h"
#include "gui/viewport.h"
@@ -49,8 +50,8 @@
QuitDialog::QuitDialog(QuitDialog **const pointerToMe):
// TRANSLATORS: quit dialog name
Window(_("Quit"), true, nullptr, "quit.xml"),
- gcn::ActionListener(),
- gcn::KeyListener(),
+ ActionListener(),
+ KeyListener(),
mOptions(),
// TRANSLATORS: quit dialog button
mLogoutQuit(new RadioButton(this, _("Quit"), "quitdialog")),
@@ -147,7 +148,7 @@ void QuitDialog::placeOption(ContainerPlacer &placer,
mOptions.push_back(option);
}
-void QuitDialog::action(const gcn::ActionEvent &event)
+void QuitDialog::action(const ActionEvent &event)
{
soundManager.playGuiSound(SOUND_HIDE_WINDOW);
if (event.getId() == "ok")
@@ -202,20 +203,19 @@ void QuitDialog::action(const gcn::ActionEvent &event)
scheduleDelete();
}
-void QuitDialog::keyPressed(gcn::KeyEvent &keyEvent)
+void QuitDialog::keyPressed(KeyEvent &keyEvent)
{
- const int actionId = static_cast<KeyEvent*>(&keyEvent)->getActionId();
+ const int actionId = keyEvent.getActionId();
int dir = 0;
switch (actionId)
{
case Input::KEY_GUI_SELECT:
case Input::KEY_GUI_SELECT2:
- action(gcn::ActionEvent(nullptr, mOkButton->getActionEventId()));
+ action(ActionEvent(nullptr, mOkButton->getActionEventId()));
break;
case Input::KEY_GUI_CANCEL:
- action(gcn::ActionEvent(nullptr,
- mCancelButton->getActionEventId()));
+ action(ActionEvent(nullptr, mCancelButton->getActionEventId()));
break;
case Input::KEY_GUI_UP:
dir = -1;
diff --git a/src/gui/windows/quitdialog.h b/src/gui/windows/quitdialog.h
index ab395c7f4..8ce60d06c 100644
--- a/src/gui/windows/quitdialog.h
+++ b/src/gui/windows/quitdialog.h
@@ -25,8 +25,8 @@
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
-#include <guichan/keylistener.hpp>
+#include "listeners/actionlistener.h"
+#include "listeners/keylistener.h"
#include <vector>
@@ -38,8 +38,9 @@ class RadioButton;
*
* \ingroup Interface
*/
-class QuitDialog final : public Window, public gcn::ActionListener,
- public gcn::KeyListener
+class QuitDialog final : public Window,
+ public ActionListener,
+ public KeyListener
{
public:
/**
@@ -61,9 +62,9 @@ class QuitDialog final : public Window, public gcn::ActionListener,
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
- void keyPressed(gcn::KeyEvent &keyEvent) override final;
+ void keyPressed(KeyEvent &keyEvent) override final;
private:
void placeOption(ContainerPlacer &placer,
diff --git a/src/gui/windows/registerdialog.cpp b/src/gui/windows/registerdialog.cpp
index 1867b6b40..50344f223 100644
--- a/src/gui/windows/registerdialog.cpp
+++ b/src/gui/windows/registerdialog.cpp
@@ -24,8 +24,9 @@
#include "client.h"
+#include "events/keyevent.h"
+
#include "input/keydata.h"
-#include "input/keyevent.h"
#include "gui/windows/okdialog.h"
@@ -44,7 +45,7 @@
#include "debug.h"
WrongDataNoticeListener::WrongDataNoticeListener():
- gcn::ActionListener(),
+ ActionListener(),
mTarget(nullptr)
{
}
@@ -54,7 +55,7 @@ void WrongDataNoticeListener::setTarget(TextField *const textField)
mTarget = textField;
}
-void WrongDataNoticeListener::action(const gcn::ActionEvent &event)
+void WrongDataNoticeListener::action(const ActionEvent &event)
{
if (event.getId() == "ok" && mTarget)
mTarget->requestFocus();
@@ -63,8 +64,8 @@ void WrongDataNoticeListener::action(const gcn::ActionEvent &event)
RegisterDialog::RegisterDialog(LoginData *const data) :
// TRANSLATORS: register dialog name
Window(_("Register"), false, nullptr, "register.xml"),
- gcn::ActionListener(),
- gcn::KeyListener(),
+ ActionListener(),
+ KeyListener(),
mLoginData(data),
mUserField(new TextField(this, mLoginData->username)),
mPasswordField(new PasswordField(this, mLoginData->password)),
@@ -172,7 +173,7 @@ RegisterDialog::~RegisterDialog()
mWrongDataNoticeListener = nullptr;
}
-void RegisterDialog::action(const gcn::ActionEvent &event)
+void RegisterDialog::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "cancel")
@@ -281,23 +282,22 @@ void RegisterDialog::action(const gcn::ActionEvent &event)
}
}
-void RegisterDialog::keyPressed(gcn::KeyEvent &keyEvent)
+void RegisterDialog::keyPressed(KeyEvent &keyEvent)
{
if (keyEvent.isConsumed())
{
mRegisterButton->setEnabled(canSubmit());
return;
}
- const int actionId = static_cast<KeyEvent*>(
- &keyEvent)->getActionId();
+ const int actionId = keyEvent.getActionId();
if (actionId == static_cast<int>(Input::KEY_GUI_CANCEL))
{
- action(gcn::ActionEvent(nullptr, mCancelButton->getActionEventId()));
+ action(ActionEvent(nullptr, mCancelButton->getActionEventId()));
}
else if (actionId == static_cast<int>(Input::KEY_GUI_SELECT)
|| actionId == static_cast<int>(Input::KEY_GUI_SELECT2))
{
- action(gcn::ActionEvent(nullptr, mRegisterButton->getActionEventId()));
+ action(ActionEvent(nullptr, mRegisterButton->getActionEventId()));
}
else
{
diff --git a/src/gui/windows/registerdialog.h b/src/gui/windows/registerdialog.h
index 66c3e40b7..1d5b5e48b 100644
--- a/src/gui/windows/registerdialog.h
+++ b/src/gui/windows/registerdialog.h
@@ -25,8 +25,8 @@
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
-#include <guichan/keylistener.hpp>
+#include "listeners/actionlistener.h"
+#include "listeners/keylistener.h"
class Button;
class LoginData;
@@ -38,7 +38,7 @@ class TextField;
* to the field which contained wrong data when the Ok button was pressed on
* the error notice.
*/
-class WrongDataNoticeListener final : public gcn::ActionListener
+class WrongDataNoticeListener final : public ActionListener
{
public:
WrongDataNoticeListener();
@@ -47,7 +47,7 @@ class WrongDataNoticeListener final : public gcn::ActionListener
void setTarget(TextField *const textField);
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
private:
TextField *mTarget;
};
@@ -58,8 +58,8 @@ class WrongDataNoticeListener final : public gcn::ActionListener
* \ingroup Interface
*/
class RegisterDialog final : public Window,
- public gcn::ActionListener,
- public gcn::KeyListener
+ public ActionListener,
+ public KeyListener
{
public:
/**
@@ -82,12 +82,12 @@ class RegisterDialog final : public Window,
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override;
+ void action(const ActionEvent &event) override;
/**
* Called when a key is pressed in one of the text fields.
*/
- void keyPressed(gcn::KeyEvent &keyEvent) override;
+ void keyPressed(KeyEvent &keyEvent) override;
void close() override;
diff --git a/src/gui/windows/selldialog.cpp b/src/gui/windows/selldialog.cpp
index 15389a9c3..8bfcc6728 100644
--- a/src/gui/windows/selldialog.cpp
+++ b/src/gui/windows/selldialog.cpp
@@ -30,11 +30,12 @@
#include "gui/windows/confirmdialog.h"
#include "gui/windows/tradewindow.h"
+#include "gui/models/shopitems.h"
+
#include "gui/widgets/button.h"
#include "gui/widgets/label.h"
#include "gui/widgets/layout.h"
#include "gui/widgets/scrollarea.h"
-#include "gui/widgets/shopitems.h"
#include "gui/widgets/shoplistbox.h"
#include "gui/widgets/slider.h"
@@ -53,8 +54,8 @@ SellDialog::DialogList SellDialog::instances;
SellDialog::SellDialog(const int npcId) :
// TRANSLATORS: sell dialog name
Window(_("Sell"), false, nullptr, "sell.xml"),
- gcn::ActionListener(),
- gcn::SelectionListener(),
+ ActionListener(),
+ SelectionListener(),
mNpcId(npcId), mMaxItems(0), mAmountItems(0), mNick("")
{
init();
@@ -63,8 +64,8 @@ SellDialog::SellDialog(const int npcId) :
SellDialog::SellDialog(const std::string &nick):
// TRANSLATORS: sell dialog name
Window(_("Sell"), false, nullptr, "sell.xml"),
- gcn::ActionListener(),
- gcn::SelectionListener(),
+ ActionListener(),
+ SelectionListener(),
mNpcId(-1), mMaxItems(0), mAmountItems(0), mNick(nick)
{
init();
@@ -86,15 +87,15 @@ void SellDialog::init()
mShopItemList = new ShopListBox(this, mShopItems, mShopItems);
mShopItemList->postInit();
mShopItemList->setProtectItems(true);
- mScrollArea = new ScrollArea(mShopItemList,
+ mScrollArea = new ScrollArea(this, mShopItemList,
getOptionBool("showbackground"), "sell_background.xml");
mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
- mSlider = new Slider(1.0);
+ mSlider = new Slider(this, 1.0);
mQuantityLabel = new Label(this, strprintf(
"%d / %d", mAmountItems, mMaxItems));
- mQuantityLabel->setAlignment(gcn::Graphics::CENTER);
+ mQuantityLabel->setAlignment(Graphics::CENTER);
// TRANSLATORS: sell dialog label
mMoneyLabel = new Label(this, strprintf(_("Price: %s / Total: %s"),
"", ""));
@@ -185,7 +186,7 @@ void SellDialog::addItem(const int id, const unsigned char color,
}
-void SellDialog::action(const gcn::ActionEvent &event)
+void SellDialog::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
@@ -257,20 +258,10 @@ void SellDialog::action(const gcn::ActionEvent &event)
mMaxItems -= mAmountItems;
while (mAmountItems > 0)
{
-#ifdef MANASERV_SUPPORT
- // This order is important, item->getCurrentInvIndex() would
- // return the inventory index of the next Duplicate otherwise.
- int itemIndex = item->getCurrentInvIndex();
- const int sellCount = item->sellCurrentDuplicate(mAmountItems);
- // For Manaserv, the Item id is to be given as index.
- if ((Net::getNetworkType() == ServerInfo::MANASERV))
- itemIndex = item->getId();
-#else
// This order is important, item->getCurrentInvIndex() would
// return the inventory index of the next Duplicate otherwise.
const int itemIndex = item->getCurrentInvIndex();
const int sellCount = item->sellCurrentDuplicate(mAmountItems);
-#endif
Net::getNpcHandler()->sellItem(mNpcId, itemIndex, sellCount);
mAmountItems -= sellCount;
}
@@ -291,7 +282,7 @@ void SellDialog::action(const gcn::ActionEvent &event)
delete mShopItems->at(selectedItem);
mShopItems->erase(selectedItem);
- gcn::Rectangle scroll;
+ Rect scroll;
scroll.y = mShopItemList->getRowHeight() * (selectedItem + 1);
scroll.height = mShopItemList->getRowHeight();
mShopItemList->showPart(scroll);
@@ -309,7 +300,7 @@ void SellDialog::action(const gcn::ActionEvent &event)
}
}
-void SellDialog::valueChanged(const gcn::SelectionEvent &event A_UNUSED)
+void SellDialog::valueChanged(const SelectionEvent &event A_UNUSED)
{
// Reset amount of items and update labels
mAmountItems = 1;
diff --git a/src/gui/windows/selldialog.h b/src/gui/windows/selldialog.h
index 15db28f10..bd270919e 100644
--- a/src/gui/windows/selldialog.h
+++ b/src/gui/windows/selldialog.h
@@ -25,8 +25,8 @@
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
-#include <guichan/selectionlistener.hpp>
+#include "listeners/actionlistener.h"
+#include "listeners/selectionlistener.h"
class Button;
class Item;
@@ -42,8 +42,8 @@ class Slider;
* \ingroup Interface
*/
class SellDialog final : public Window,
- private gcn::ActionListener,
- private gcn::SelectionListener
+ private ActionListener,
+ private SelectionListener
{
public:
/**
@@ -80,14 +80,14 @@ class SellDialog final : public Window,
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
/**
* Updates labels according to selected item.
*
* @see SelectionListener::selectionChanged
*/
- void valueChanged(const gcn::SelectionEvent &event) override final;
+ void valueChanged(const SelectionEvent &event) override final;
/**
* Gives Player's Money amount
diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp
index 3006922c3..af29da656 100644
--- a/src/gui/windows/serverdialog.cpp
+++ b/src/gui/windows/serverdialog.cpp
@@ -27,11 +27,16 @@
#include "configuration.h"
#include "main.h"
+#include "events/keyevent.h"
+
#include "input/keydata.h"
-#include "input/keyevent.h"
-#include "gui/sdlfont.h"
+#include "gui/font.h"
+#include "gui/gui.h"
+
+#include "gui/models/serverslistmodel.h"
+#include "gui/widgets/checkbox.h"
#include "gui/windows/editserverdialog.h"
#include "gui/windows/logindialog.h"
@@ -44,8 +49,6 @@
#include "utils/gettext.h"
#include "utils/langs.h"
-#include <guichan/font.hpp>
-
#include <string>
#include "debug.h"
@@ -60,19 +63,10 @@ static std::string serverTypeToString(const ServerInfo::Type type)
return "TmwAthena";
case ServerInfo::EVOL:
return "Evol";
-#ifdef EATHENA_SUPPORT
case ServerInfo::EATHENA:
+#ifdef EATHENA_SUPPORT
return "eAthena";
#endif
-#ifdef MANASERV_SUPPORT
- case ServerInfo::MANASERV:
- return "ManaServ";
-#else
- case ServerInfo::MANASERV:
-#endif
-#ifndef EATHENA_SUPPORT
- case ServerInfo::EATHENA:
-#endif
default:
case ServerInfo::UNKNOWN:
return "";
@@ -87,60 +81,11 @@ static uint16_t defaultPortForServerType(const ServerInfo::Type type)
case ServerInfo::EATHENA:
#ifdef EATHENA_SUPPORT
return 6900;
-#else
- return 6901;
#endif
case ServerInfo::UNKNOWN:
case ServerInfo::TMWATHENA:
case ServerInfo::EVOL:
-#ifdef MANASERV_SUPPORT
- return 6901;
- case ServerInfo::MANASERV:
- return 9601;
-#else
- case ServerInfo::MANASERV:
return 6901;
-#endif
- }
-}
-
-ServersListModel::ServersListModel(ServerInfos *const servers,
- ServerDialog *const parent) :
- mServers(servers),
- mVersionStrings(servers->size(), VersionString(0, "")),
- mParent(parent)
-{
-}
-
-int ServersListModel::getNumberOfElements()
-{
- MutexLocker lock = mParent->lock();
- return static_cast<int>(mServers->size());
-}
-
-std::string ServersListModel::getElementAt(int elementIndex)
-{
- MutexLocker lock = mParent->lock();
- const ServerInfo &server = mServers->at(elementIndex);
- std::string myServer;
- myServer.append(server.hostname);
- return myServer;
-}
-
-void ServersListModel::setVersionString(const int index,
- const std::string &version)
-{
- if (index < 0 || index >= static_cast<int>(mVersionStrings.size()))
- return;
-
- if (version.empty())
- {
- mVersionStrings[index] = VersionString(0, "");
- }
- else
- {
- mVersionStrings[index] = VersionString(
- gui->getFont()->getWidth(version), version);
}
}
@@ -157,19 +102,18 @@ public:
mHighlightColor = getThemeColor(Theme::HIGHLIGHT);
}
- void draw(gcn::Graphics *graphics) override final
+ void draw(Graphics *graphics) override final
{
if (!mListModel)
return;
ServersListModel *const model = static_cast<ServersListModel *const>(
mListModel);
- Graphics *const g = static_cast<Graphics*>(graphics);
updateAlpha();
mHighlightColor.a = static_cast<int>(mAlpha * 255.0F);
- g->setColor(mHighlightColor);
+ graphics->setColor(mHighlightColor);
const int height = getRowHeight();
mNotSupportedColor.a = static_cast<int>(mAlpha * 255.0F);
@@ -177,13 +121,13 @@ public:
// Draw filled rectangle around the selected list element
if (mSelected >= 0)
{
- graphics->fillRectangle(gcn::Rectangle(mPadding,
+ graphics->fillRectangle(Rect(mPadding,
height * mSelected + mPadding, getWidth() - 2 * mPadding,
height));
}
- gcn::Font *const font1 = boldFont;
- gcn::Font *const font2 = getFont();
+ Font *const font1 = boldFont;
+ Font *const font2 = getFont();
const int fontHeight = font1->getHeight();
const int pad1 = fontHeight + mPadding;
const int pad2 = height / 4 + mPadding;
@@ -196,12 +140,12 @@ public:
if (mSelected == i)
{
- g->setColorAll(mForegroundSelectedColor,
+ graphics->setColorAll(mForegroundSelectedColor,
mForegroundSelectedColor2);
}
else
{
- g->setColorAll(mForegroundColor, mForegroundColor2);
+ graphics->setColorAll(mForegroundColor, mForegroundColor2);
}
int top;
@@ -224,7 +168,7 @@ public:
if (info.version.first > 0)
{
- g->setColorAll(mNotSupportedColor, mNotSupportedColor2);
+ graphics->setColorAll(mNotSupportedColor, mNotSupportedColor2);
font2->drawString(graphics, info.version.second,
width - info.version.first - mPadding, top);
}
@@ -236,8 +180,8 @@ public:
return 2 * getFont()->getHeight() + 5;
}
private:
- gcn::Color mNotSupportedColor;
- gcn::Color mNotSupportedColor2;
+ Color mNotSupportedColor;
+ Color mNotSupportedColor2;
};
@@ -245,9 +189,9 @@ ServerDialog::ServerDialog(ServerInfo *const serverInfo,
const std::string &dir) :
// TRANSLATORS: servers dialog name
Window(_("Choose Your Server"), false, nullptr, "server.xml"),
- gcn::ActionListener(),
- gcn::KeyListener(),
- gcn::SelectionListener(),
+ ActionListener(),
+ KeyListener(),
+ SelectionListener(),
mMutex(),
mDescription(new Label(this, std::string())),
// TRANSLATORS: servers dialog button
@@ -294,7 +238,7 @@ ServerDialog::ServerDialog(ServerInfo *const serverInfo,
mServersList->addMouseListener(this);
- ScrollArea *const usedScroll = new ScrollArea(mServersList,
+ ScrollArea *const usedScroll = new ScrollArea(this, mServersList,
getOptionBool("showbackground"), "server_background.xml");
usedScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
@@ -405,7 +349,7 @@ void ServerDialog::connectToSelectedServer()
client->setState(STATE_CONNECT_SERVER);
}
-void ServerDialog::action(const gcn::ActionEvent &event)
+void ServerDialog::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "connect")
@@ -445,9 +389,9 @@ void ServerDialog::action(const gcn::ActionEvent &event)
}
}
-void ServerDialog::keyPressed(gcn::KeyEvent &keyEvent)
+void ServerDialog::keyPressed(KeyEvent &keyEvent)
{
- switch (static_cast<KeyEvent*>(&keyEvent)->getActionId())
+ switch (keyEvent.getActionId())
{
case Input::KEY_GUI_CANCEL:
keyEvent.consume();
@@ -457,7 +401,7 @@ void ServerDialog::keyPressed(gcn::KeyEvent &keyEvent)
case Input::KEY_GUI_SELECT:
case Input::KEY_GUI_SELECT2:
keyEvent.consume();
- action(gcn::ActionEvent(nullptr,
+ action(ActionEvent(nullptr,
mConnectButton->getActionEventId()));
return;
@@ -495,7 +439,7 @@ void ServerDialog::keyPressed(gcn::KeyEvent &keyEvent)
mServersList->keyPressed(keyEvent);
}
-void ServerDialog::valueChanged(const gcn::SelectionEvent &)
+void ServerDialog::valueChanged(const SelectionEvent &)
{
const int index = mServersList->getSelected();
if (index == -1)
@@ -506,13 +450,13 @@ void ServerDialog::valueChanged(const gcn::SelectionEvent &)
mDeleteButton->setEnabled(true);
}
-void ServerDialog::mouseClicked(gcn::MouseEvent &mouseEvent)
+void ServerDialog::mouseClicked(MouseEvent &mouseEvent)
{
if (mouseEvent.getClickCount() == 2 &&
mouseEvent.getSource() == mServersList)
{
- action(gcn::ActionEvent(mConnectButton,
- mConnectButton->getActionEventId()));
+ action(ActionEvent(mConnectButton,
+ mConnectButton->getActionEventId()));
}
}
@@ -644,7 +588,7 @@ void ServerDialog::loadServers(const bool addNew)
version = strprintf(_("requires v%s"), version.c_str());
}
- const gcn::Font *const font = gui->getFont();
+ const Font *const font = gui->getFont();
for_each_xml_child_node(subNode, serverNode)
{
diff --git a/src/gui/windows/serverdialog.h b/src/gui/windows/serverdialog.h
index ad6f554c6..39c82279e 100644
--- a/src/gui/windows/serverdialog.h
+++ b/src/gui/windows/serverdialog.h
@@ -24,66 +24,23 @@
#define GUI_WINDOWS_SERVERDIALOG_H
#include "gui/widgets/window.h"
-#include "gui/widgets/checkbox.h"
#include "net/download.h"
#include "net/serverinfo.h"
#include "utils/mutex.h"
-#include <guichan/actionlistener.hpp>
-#include <guichan/keylistener.hpp>
-#include <guichan/listmodel.hpp>
-#include <guichan/selectionlistener.hpp>
+#include "listeners/actionlistener.h"
+#include "listeners/keylistener.h"
+#include "listeners/selectionlistener.h"
#include <string>
-#include <vector>
class Button;
+class CheckBox;
class Label;
class ListBox;
-class ServerDialog;
-
-/**
- * Server and Port List Model
- */
-class ServersListModel final : public gcn::ListModel
-{
- public:
- typedef std::pair<int, std::string> VersionString;
-
- ServersListModel(ServerInfos *const servers,
- ServerDialog *const parent);
-
- A_DELETE_COPY(ServersListModel)
-
- /**
- * Used to get number of line in the list
- */
- int getNumberOfElements() override final A_WARN_UNUSED;
-
- /**
- * Used to get an element from the list
- */
- std::string getElementAt(int elementIndex)
- override final A_WARN_UNUSED;
-
- /**
- * Used to get the corresponding Server struct
- */
- const ServerInfo &getServer(const int elementIndex) const A_WARN_UNUSED
- { return mServers->at(elementIndex); }
-
- void setVersionString(const int index, const std::string &version);
-
- private:
- typedef std::vector<VersionString> VersionStrings;
-
- ServerInfos *mServers;
- VersionStrings mVersionStrings;
- ServerDialog *mParent;
-};
-
+class ServersListModel;
/**
* The server choice dialog.
@@ -91,9 +48,9 @@ class ServersListModel final : public gcn::ListModel
* \ingroup Interface
*/
class ServerDialog final : public Window,
- public gcn::ActionListener,
- public gcn::KeyListener,
- public gcn::SelectionListener
+ public ActionListener,
+ public KeyListener,
+ public SelectionListener
{
public:
/**
@@ -115,16 +72,16 @@ class ServerDialog final : public Window,
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
- void keyPressed(gcn::KeyEvent &keyEvent) override final;
+ void keyPressed(KeyEvent &keyEvent) override final;
/**
* Called when the selected value changed in the servers list box.
*/
- void valueChanged(const gcn::SelectionEvent &event) override final;
+ void valueChanged(const SelectionEvent &event) override final;
- void mouseClicked(gcn::MouseEvent &mouseEvent) override final;
+ void mouseClicked(MouseEvent &mouseEvent) override final;
void logic() override final;
diff --git a/src/gui/windows/setupwindow.cpp b/src/gui/windows/setupwindow.cpp
index 0780865aa..2bcac85a5 100644
--- a/src/gui/windows/setupwindow.cpp
+++ b/src/gui/windows/setupwindow.cpp
@@ -44,6 +44,7 @@
#include "gui/widgets/tabs/setup_video.h"
#include "gui/widgets/tabs/setup_visual.h"
+#include "gui/widgets/button.h"
#include "gui/widgets/label.h"
#include "gui/widgets/tabbedarea.h"
@@ -58,7 +59,7 @@ SetupWindow *setupWindow = nullptr;
SetupWindow::SetupWindow() :
// TRANSLATORS: setup window name
Window(_("Setup"), false, nullptr, "setup.xml"),
- gcn::ActionListener(),
+ ActionListener(),
mTabs(),
mModsTab(nullptr),
mWindowsToReset(),
@@ -112,7 +113,7 @@ void SetupWindow::postInit()
mResetWindows = btn;
}
- mPanel->setDimension(gcn::Rectangle(5, 5, width - 10, height - 40));
+ mPanel->setDimension(Rect(5, 5, width - 10, height - 40));
mPanel->enableScrollButtons(true);
mTabs.push_back(new Setup_Video(this));
@@ -149,7 +150,7 @@ void SetupWindow::postInit()
center();
- widgetResized(gcn::Event(nullptr));
+ widgetResized(Event(nullptr));
setInGame(false);
enableVisibleSound(true);
}
@@ -160,7 +161,7 @@ SetupWindow::~SetupWindow()
mButtons.clear();
}
-void SetupWindow::action(const gcn::ActionEvent &event)
+void SetupWindow::action(const ActionEvent &event)
{
if (Game::instance())
Game::instance()->resetAdjustLevel();
@@ -260,16 +261,16 @@ void SetupWindow::setVisible(bool visible)
Window::setVisible(visible);
}
-void SetupWindow::widgetResized(const gcn::Event &event)
+void SetupWindow::widgetResized(const Event &event)
{
Window::widgetResized(event);
- const gcn::Rectangle area = getChildrenArea();
+ const Rect area = getChildrenArea();
int x = area.width;
const int height = area.height;
const int width = area.width;
const int buttonPadding = getOption("buttonPadding", 5);
- mPanel->setDimension(gcn::Rectangle(5, 5, width - 10, height - 40));
+ mPanel->setDimension(Rect(5, 5, width - 10, height - 40));
FOR_EACH (std::vector<Button*>::iterator, it, mButtons)
{
Button *const btn = *it;
diff --git a/src/gui/windows/setupwindow.h b/src/gui/windows/setupwindow.h
index f5406e8ac..38b3eb206 100644
--- a/src/gui/windows/setupwindow.h
+++ b/src/gui/windows/setupwindow.h
@@ -25,7 +25,7 @@
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
#include <list>
@@ -41,7 +41,7 @@ class TabbedArea;
* \ingroup GUI
*/
class SetupWindow final : public Window,
- public gcn::ActionListener
+ public ActionListener
{
public:
SetupWindow();
@@ -52,7 +52,7 @@ class SetupWindow final : public Window,
void postInit() override final;
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
void setInGame(const bool inGame);
@@ -71,7 +71,7 @@ class SetupWindow final : public Window,
void setVisible(bool visible) override final;
- void widgetResized(const gcn::Event &event) override final;
+ void widgetResized(const Event &event) override final;
private:
void unloadModTab();
diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp
index a940e4cdb..32e249d35 100644
--- a/src/gui/windows/shopwindow.cpp
+++ b/src/gui/windows/shopwindow.cpp
@@ -27,12 +27,13 @@
#include "gui/windows/selldialog.h"
#include "gui/windows/tradewindow.h"
+#include "gui/models/shopitems.h"
+
#include "gui/widgets/button.h"
#include "gui/widgets/checkbox.h"
#include "gui/widgets/label.h"
#include "gui/widgets/layout.h"
#include "gui/widgets/scrollarea.h"
-#include "gui/widgets/shopitems.h"
#include "gui/widgets/shoplistbox.h"
#include "gui/widgets/tabs/chattab.h"
@@ -71,17 +72,17 @@ ShopWindow::DialogList ShopWindow::instances;
ShopWindow::ShopWindow():
// TRANSLATORS: shop window name
Window(_("Personal Shop"), false, nullptr, "shop.xml"),
- gcn::ActionListener(),
- gcn::SelectionListener(),
+ ActionListener(),
+ SelectionListener(),
// TRANSLATORS: shop window button
mCloseButton(new Button(this, _("Close"), "close", this)),
mBuyShopItems(new ShopItems),
mSellShopItems(new ShopItems),
mBuyShopItemList(new ShopListBox(this, mBuyShopItems, mBuyShopItems)),
mSellShopItemList(new ShopListBox(this, mSellShopItems, mSellShopItems)),
- mBuyScrollArea(new ScrollArea(mBuyShopItemList,
+ mBuyScrollArea(new ScrollArea(this, mBuyShopItemList,
getOptionBool("showbuybackground"), "shop_buy_background.xml")),
- mSellScrollArea(new ScrollArea(mSellShopItemList,
+ mSellScrollArea(new ScrollArea(this, mSellShopItemList,
getOptionBool("showsellbackground"), "shop_sell_background.xml")),
// TRANSLATORS: shop window label
mBuyLabel(new Label(this, _("Buy items"))),
@@ -205,7 +206,7 @@ ShopWindow::~ShopWindow()
instances.remove(this);
}
-void ShopWindow::action(const gcn::ActionEvent &event)
+void ShopWindow::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "close")
@@ -307,7 +308,7 @@ void ShopWindow::startTrade()
mTradeNick.clear();
}
-void ShopWindow::valueChanged(const gcn::SelectionEvent &event A_UNUSED)
+void ShopWindow::valueChanged(const SelectionEvent &event A_UNUSED)
{
updateButtonsAndLabels();
}
diff --git a/src/gui/windows/shopwindow.h b/src/gui/windows/shopwindow.h
index 95eee1e05..76971364b 100644
--- a/src/gui/windows/shopwindow.h
+++ b/src/gui/windows/shopwindow.h
@@ -25,8 +25,8 @@
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
-#include <guichan/selectionlistener.hpp>
+#include "listeners/actionlistener.h"
+#include "listeners/selectionlistener.h"
class Button;
class CheckBox;
@@ -43,8 +43,8 @@ class ShopListBox;
* \ingroup Interface
*/
class ShopWindow final : public Window,
- public gcn::ActionListener,
- public gcn::SelectionListener
+ public ActionListener,
+ public SelectionListener
{
public:
enum ShopMode
@@ -72,12 +72,12 @@ class ShopWindow final : public Window,
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
/**
* Updates the labels according to the selected item.
*/
- void valueChanged(const gcn::SelectionEvent &event) override final;
+ void valueChanged(const SelectionEvent &event) override final;
/**
* Updates the state of buttons and labels.
diff --git a/src/gui/windows/shortcutwindow.cpp b/src/gui/windows/shortcutwindow.cpp
index 96ec8c93c..5b3c03e90 100644
--- a/src/gui/windows/shortcutwindow.cpp
+++ b/src/gui/windows/shortcutwindow.cpp
@@ -40,7 +40,8 @@ class ShortcutTab final : public Tab
{
public:
ShortcutTab(const Widget2 *const widget,
- std::string name, ShortcutContainer *const content) :
+ std::string name,
+ ShortcutContainer *const content) :
Tab(widget),
mContent(content)
{
@@ -58,7 +59,7 @@ ShortcutWindow::ShortcutWindow(const std::string &restrict title,
int width, int height) :
Window("Window", false, nullptr, skinFile),
mItems(content),
- mScrollArea(new ScrollArea(mItems, false)),
+ mScrollArea(new ScrollArea(this, mItems, false)),
mTabs(nullptr),
mPages()
{
@@ -160,7 +161,7 @@ ShortcutWindow::~ShortcutWindow()
void ShortcutWindow::addTab(const std::string &name,
ShortcutContainer *const content)
{
- ScrollArea *const scroll = new ScrollArea(content, false);
+ ScrollArea *const scroll = new ScrollArea(this, content, false);
scroll->setPosition(SCROLL_PADDING, SCROLL_PADDING);
scroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
content->setWidget2(this);
@@ -176,7 +177,7 @@ int ShortcutWindow::getTabIndex() const
return mTabs->getSelectedTabIndex();
}
-void ShortcutWindow::widgetHidden(const gcn::Event &event)
+void ShortcutWindow::widgetHidden(const Event &event)
{
if (mItems)
mItems->widgetHidden(event);
@@ -195,21 +196,21 @@ void ShortcutWindow::widgetHidden(const gcn::Event &event)
}
}
-void ShortcutWindow::mousePressed(gcn::MouseEvent &event)
+void ShortcutWindow::mousePressed(MouseEvent &event)
{
Window::mousePressed(event);
if (event.isConsumed())
return;
- if (event.getButton() == gcn::MouseEvent::LEFT)
+ if (event.getButton() == MouseEvent::LEFT)
{
mDragOffsetX = event.getX();
mDragOffsetY = event.getY();
}
}
-void ShortcutWindow::mouseDragged(gcn::MouseEvent &event)
+void ShortcutWindow::mouseDragged(MouseEvent &event)
{
Window::mouseDragged(event);
@@ -226,7 +227,7 @@ void ShortcutWindow::mouseDragged(gcn::MouseEvent &event)
}
}
-void ShortcutWindow::widgetMoved(const gcn::Event& event)
+void ShortcutWindow::widgetMoved(const Event& event)
{
Window::widgetMoved(event);
if (mItems)
diff --git a/src/gui/windows/shortcutwindow.h b/src/gui/windows/shortcutwindow.h
index f4c417c94..5e36e68d7 100644
--- a/src/gui/windows/shortcutwindow.h
+++ b/src/gui/windows/shortcutwindow.h
@@ -60,13 +60,13 @@ class ShortcutWindow final : public Window
int getTabIndex() const A_WARN_UNUSED;
- void widgetHidden(const gcn::Event &event) override final;
+ void widgetHidden(const Event &event) override final;
- void widgetMoved(const gcn::Event& event) override final;
+ void widgetMoved(const Event& event) override final;
- void mousePressed(gcn::MouseEvent &event) override final;
+ void mousePressed(MouseEvent &event) override final;
- void mouseDragged(gcn::MouseEvent &event) override final;
+ void mouseDragged(MouseEvent &event) override final;
void nextTab();
diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp
index 04baad26a..21cc009bc 100644
--- a/src/gui/windows/skilldialog.cpp
+++ b/src/gui/windows/skilldialog.cpp
@@ -29,10 +29,13 @@
#include "being/localplayer.h"
+#include "gui/font.h"
#include "gui/viewport.h"
#include "gui/popups/textpopup.h"
+#include "gui/models/skillmodel.h"
+
#include "gui/windows/setupwindow.h"
#include "gui/windows/shortcutwindow.h"
@@ -40,7 +43,6 @@
#include "gui/widgets/label.h"
#include "gui/widgets/listbox.h"
#include "gui/widgets/scrollarea.h"
-#include "gui/widgets/skillmodel.h"
#include "gui/widgets/tabs/tab.h"
#include "gui/widgets/tabbedarea.h"
@@ -53,14 +55,13 @@
#include "resources/beingcommon.h"
-#include <guichan/font.hpp>
-
#include "debug.h"
class SkillListBox final : public ListBox
{
public:
- SkillListBox(const Widget2 *const widget, SkillModel *const model) :
+ SkillListBox(const Widget2 *const widget,
+ SkillModel *const model) :
ListBox(widget, model, "skilllistbox.xml"),
mModel(model),
mPopup(new TextPopup),
@@ -100,15 +101,13 @@ class SkillListBox final : public ListBox
return static_cast<SkillModel*>(mListModel)->getSkillAt(selected);
}
- void draw(gcn::Graphics *gcnGraphics) override
+ void draw(Graphics *graphics) override
{
if (!mListModel)
return;
SkillModel *const model = static_cast<SkillModel*>(mListModel);
updateAlpha();
- Graphics *const graphics = static_cast<Graphics *const>(
- gcnGraphics);
mHighlightColor.a = static_cast<int>(mAlpha * 255.0F);
graphics->setColor(mHighlightColor);
@@ -116,14 +115,14 @@ class SkillListBox final : public ListBox
// Draw filled rectangle around the selected list element
if (mSelected >= 0)
{
- graphics->fillRectangle(gcn::Rectangle(mPadding, getRowHeight()
+ graphics->fillRectangle(Rect(mPadding, getRowHeight()
* mSelected + mPadding, getWidth() - 2 * mPadding,
getRowHeight()));
}
// Draw the list elements
graphics->setColorAll(mTextColor, mTextColor2);
- gcn::Font *const font = getFont();
+ Font *const font = getFont();
const int space = font->getHeight() + mSpacing;
const int width2 = getWidth() - mPadding;
for (int i = 0, y = 1;
@@ -136,7 +135,7 @@ class SkillListBox final : public ListBox
const SkillData *const data = e->data;
const int yPad = y + mPadding;
const std::string &description = data->description;
- graphics->drawImage2(data->icon, mPadding, yPad);
+ graphics->drawImage(data->icon, mPadding, yPad);
font->drawString(graphics, data->name, mTextPadding, yPad);
if (!description.empty())
{
@@ -159,7 +158,7 @@ class SkillListBox final : public ListBox
unsigned int getRowHeight() const override
{ return mRowHeight; }
- const SkillInfo *getSkillByEvent(const gcn::MouseEvent &event) const
+ const SkillInfo *getSkillByEvent(const MouseEvent &event) const
{
const int y = (event.getY() + mPadding) / getRowHeight();
if (!mModel || y >= mModel->getNumberOfElements())
@@ -170,7 +169,7 @@ class SkillListBox final : public ListBox
return skill;
}
- void mouseMoved(gcn::MouseEvent &event) override
+ void mouseMoved(MouseEvent &event) override
{
ListBox::mouseMoved(event);
if (!viewport || !dragDrop.isEmpty())
@@ -184,9 +183,9 @@ class SkillListBox final : public ListBox
skill->data->dispName, skill->data->description);
}
- void mouseDragged(gcn::MouseEvent &event)
+ void mouseDragged(MouseEvent &event)
{
- if (event.getButton() == gcn::MouseEvent::LEFT)
+ if (event.getButton() == MouseEvent::LEFT)
{
if (dragDrop.isEmpty())
{
@@ -208,10 +207,10 @@ class SkillListBox final : public ListBox
}
}
- void mousePressed(gcn::MouseEvent &event)
+ void mousePressed(MouseEvent &event)
{
ListBox::mousePressed(event);
- if (event.getButton() == gcn::MouseEvent::LEFT)
+ if (event.getButton() == MouseEvent::LEFT)
{
const SkillInfo *const skill = getSkillByEvent(event);
if (!skill)
@@ -220,12 +219,12 @@ class SkillListBox final : public ListBox
}
}
- void mouseReleased(gcn::MouseEvent &event)
+ void mouseReleased(MouseEvent &event)
{
ListBox::mouseReleased(event);
}
- void mouseExited(gcn::MouseEvent &event A_UNUSED) override
+ void mouseExited(MouseEvent &event A_UNUSED) override
{
mPopup->hide();
}
@@ -233,8 +232,8 @@ class SkillListBox final : public ListBox
private:
SkillModel *mModel;
TextPopup *mPopup;
- gcn::Color mTextColor;
- gcn::Color mTextColor2;
+ Color mTextColor;
+ Color mTextColor2;
int mTextPadding;
int mSpacing;
bool mSkillClicked;
@@ -244,7 +243,8 @@ class SkillTab final : public Tab
{
public:
SkillTab(const Widget2 *const widget,
- const std::string &name, SkillListBox *const listBox) :
+ const std::string &name,
+ SkillListBox *const listBox) :
Tab(widget),
mListBox(listBox)
{
@@ -281,7 +281,7 @@ class SkillTab final : public Tab
SkillDialog::SkillDialog() :
// TRANSLATORS: skills dialog name
Window(_("Skills"), false, nullptr, "skills.xml"),
- gcn::ActionListener(),
+ ActionListener(),
mSkills(),
mTabs(new TabbedArea(this)),
mDeleteTabs(),
@@ -323,7 +323,7 @@ SkillDialog::~SkillDialog()
clearSkills();
}
-void SkillDialog::action(const gcn::ActionEvent &event)
+void SkillDialog::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "inc")
@@ -544,7 +544,7 @@ void SkillDialog::loadXmlFile(const std::string &fileName)
SkillListBox *const listbox = new SkillListBox(this, model);
listbox->setActionEventId("sel");
listbox->addActionListener(this);
- ScrollArea *const scroll = new ScrollArea(listbox, false);
+ ScrollArea *const scroll = new ScrollArea(this, listbox, false);
scroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
scroll->setVerticalScrollPolicy(ScrollArea::SHOW_ALWAYS);
@@ -619,7 +619,7 @@ SkillInfo* SkillDialog::getSkillByItem(const int itemId) const
return nullptr;
}
-void SkillDialog::widgetResized(const gcn::Event &event)
+void SkillDialog::widgetResized(const Event &event)
{
Window::widgetResized(event);
diff --git a/src/gui/windows/skilldialog.h b/src/gui/windows/skilldialog.h
index 4a6182d38..3bf64df9b 100644
--- a/src/gui/windows/skilldialog.h
+++ b/src/gui/windows/skilldialog.h
@@ -25,7 +25,7 @@
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
const int SKILL_MIN_ID = 200000;
const unsigned int SKILL_VAR_MIN_ID = 1000000;
@@ -43,7 +43,8 @@ struct SkillInfo;
*
* \ingroup Interface
*/
-class SkillDialog final : public Window, public gcn::ActionListener
+class SkillDialog final : public Window,
+ public ActionListener
{
public:
SkillDialog();
@@ -57,7 +58,7 @@ class SkillDialog final : public Window, public gcn::ActionListener
/**
* Called when receiving actions from widget.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
/**
* Update the given skill's display
@@ -87,7 +88,7 @@ class SkillDialog final : public Window, public gcn::ActionListener
bool hasSkills() const A_WARN_UNUSED
{ return !mSkills.empty(); }
- void widgetResized(const gcn::Event &event) override final;
+ void widgetResized(const Event &event) override final;
void useItem(const int itemId) const;
diff --git a/src/gui/windows/socialwindow.cpp b/src/gui/windows/socialwindow.cpp
index 2385066be..f33534a85 100644
--- a/src/gui/windows/socialwindow.cpp
+++ b/src/gui/windows/socialwindow.cpp
@@ -33,6 +33,8 @@
#include "input/keyboardconfig.h"
+#include "gui/models/beingslistmodel.h"
+
#include "gui/windows/confirmdialog.h"
#include "gui/windows/okdialog.h"
#include "gui/windows/setupwindow.h"
@@ -41,6 +43,7 @@
#include "gui/windows/outfitwindow.h"
+#include "gui/widgets/avatarlistbox.h"
#include "gui/widgets/button.h"
#include "gui/widgets/browserbox.h"
#include "gui/widgets/label.h"
@@ -115,6 +118,11 @@ public:
virtual void selectIndex(const unsigned num A_UNUSED)
{ }
+ virtual void buildCounter(const int online A_UNUSED = 0,
+ const int total A_UNUSED = 0)
+ {
+ }
+
protected:
friend class SocialWindow;
@@ -157,11 +165,6 @@ protected:
socialWindow->setCounter(this, mCounterString);
}
- virtual void buildCounter(const int online A_UNUSED = 0,
- const int total A_UNUSED = 0)
- {
- }
-
TextDialog *mInviteDialog;
ConfirmDialog *mConfirmDialog;
ScrollArea *mScroll;
@@ -169,13 +172,14 @@ protected:
std::string mCounterString;
};
-class SocialGuildTab final : public SocialTab, public gcn::ActionListener
+class SocialGuildTab final : public SocialTab, public ActionListener
{
public:
SocialGuildTab(const Widget2 *const widget,
- Guild *const guild, const bool showBackground) :
+ Guild *const guild,
+ const bool showBackground) :
SocialTab(widget),
- gcn::ActionListener(),
+ ActionListener(),
mGuild(guild)
{
// TRANSLATORS: tab in social window
@@ -191,7 +195,7 @@ public:
mList = new AvatarListBox(this, guild);
mList->postInit();
- mScroll = new ScrollArea(mList, showBackground,
+ mScroll = new ScrollArea(this, mList, showBackground,
"social_background.xml");
mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_AUTO);
@@ -208,7 +212,7 @@ public:
mScroll = nullptr;
}
- void action(const gcn::ActionEvent &event) override final
+ void action(const ActionEvent &event) override final
{
const std::string &eventId = event.getId();
if (eventId == "do invite")
@@ -305,13 +309,14 @@ private:
Guild *mGuild;
};
-class SocialGuildTab2 final : public SocialTab, public gcn::ActionListener
+class SocialGuildTab2 final : public SocialTab, public ActionListener
{
public:
- SocialGuildTab2(const Widget2 *const widget, Guild *const guild,
+ SocialGuildTab2(const Widget2 *const widget,
+ Guild *const guild,
const bool showBackground) :
SocialTab(widget),
- gcn::ActionListener()
+ ActionListener()
{
// TRANSLATORS: tab in social window
setCaption(_("Guild"));
@@ -326,7 +331,7 @@ public:
mList = new AvatarListBox(this, guild);
mList->postInit();
- mScroll = new ScrollArea(mList, showBackground,
+ mScroll = new ScrollArea(this, mList, showBackground,
"social_background.xml");
mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_AUTO);
@@ -343,7 +348,7 @@ public:
mScroll = nullptr;
}
- void action(const gcn::ActionEvent &event A_UNUSED) override final
+ void action(const ActionEvent &event A_UNUSED) override final
{
}
@@ -372,13 +377,14 @@ public:
}
};
-class SocialPartyTab final : public SocialTab, public gcn::ActionListener
+class SocialPartyTab final : public SocialTab, public ActionListener
{
public:
SocialPartyTab(const Widget2 *const widget,
- Party *const party, const bool showBackground) :
+ Party *const party,
+ const bool showBackground) :
SocialTab(widget),
- gcn::ActionListener(),
+ ActionListener(),
mParty(party)
{
// TRANSLATORS: tab in social window
@@ -394,7 +400,7 @@ public:
mList = new AvatarListBox(this, party);
mList->postInit();
- mScroll = new ScrollArea(mList, showBackground,
+ mScroll = new ScrollArea(this, mList, showBackground,
"social_background.xml");
mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_AUTO);
@@ -411,7 +417,7 @@ public:
mScroll = nullptr;
}
- void action(const gcn::ActionEvent &event) override final
+ void action(const ActionEvent &event) override final
{
const std::string &eventId = event.getId();
if (eventId == "do invite")
@@ -499,52 +505,18 @@ private:
Party *mParty;
};
-class BeingsListModal final : public AvatarListModel
-{
-public:
- BeingsListModal() :
- AvatarListModel(),
- mMembers()
- {
- }
-
- A_DELETE_COPY(BeingsListModal)
-
- ~BeingsListModal()
- {
- delete_all(mMembers);
- mMembers.clear();
- }
-
- std::vector<Avatar*> *getMembers()
- {
- return &mMembers;
- }
-
- Avatar *getAvatarAt(int index) override final
- {
- return mMembers[index];
- }
-
- int getNumberOfElements() override final
- {
- return static_cast<int>(mMembers.size());
- }
-
- std::vector<Avatar*> mMembers;
-};
-
class SocialPlayersTab final : public SocialTab
{
public:
SocialPlayersTab(const Widget2 *const widget,
- std::string name, const bool showBackground) :
+ std::string name,
+ const bool showBackground) :
SocialTab(widget),
- mBeings(new BeingsListModal)
+ mBeings(new BeingsListModel)
{
mList = new AvatarListBox(this, mBeings);
mList->postInit();
- mScroll = new ScrollArea(mList, showBackground,
+ mScroll = new ScrollArea(this, mList, showBackground,
"social_background.xml");
mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_AUTO);
@@ -696,7 +668,7 @@ public:
}
private:
- BeingsListModal *mBeings;
+ BeingsListModel *mBeings;
};
@@ -706,11 +678,11 @@ public:
SocialNavigationTab(const Widget2 *const widget,
const bool showBackground) :
SocialTab(widget),
- mBeings(new BeingsListModal)
+ mBeings(new BeingsListModel)
{
mList = new AvatarListBox(this, mBeings);
mList->postInit();
- mScroll = new ScrollArea(mList, showBackground,
+ mScroll = new ScrollArea(this, mList, showBackground,
"social_background.xml");
mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_AUTO);
@@ -973,7 +945,7 @@ public:
}
private:
- BeingsListModal *mBeings;
+ BeingsListModel *mBeings;
};
@@ -1035,11 +1007,11 @@ public:
SocialAttackTab(const Widget2 *const widget,
const bool showBackground) :
SocialTab(widget),
- mBeings(new BeingsListModal)
+ mBeings(new BeingsListModel)
{
mList = new AvatarListBox(this, mBeings);
mList->postInit();
- mScroll = new ScrollArea(mList, showBackground,
+ mScroll = new ScrollArea(this, mList, showBackground,
"social_background.xml");
mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_AUTO);
@@ -1073,7 +1045,7 @@ public:
}
private:
- BeingsListModal *mBeings;
+ BeingsListModel *mBeings;
};
class SocialPickupTab final : public SocialTab
@@ -1082,11 +1054,11 @@ public:
SocialPickupTab(const Widget2 *const widget,
const bool showBackground) :
SocialTab(widget),
- mBeings(new BeingsListModal)
+ mBeings(new BeingsListModel)
{
mList = new AvatarListBox(this, mBeings);
mList->postInit();
- mScroll = new ScrollArea(mList, showBackground,
+ mScroll = new ScrollArea(this, mList, showBackground,
"social_background.xml");
mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_AUTO);
@@ -1118,7 +1090,7 @@ public:
}
private:
- BeingsListModal *mBeings;
+ BeingsListModel *mBeings;
};
@@ -1126,13 +1098,14 @@ class SocialFriendsTab final : public SocialTab
{
public:
SocialFriendsTab(const Widget2 *const widget,
- std::string name, const bool showBackground) :
+ std::string name,
+ const bool showBackground) :
SocialTab(widget),
- mBeings(new BeingsListModal)
+ mBeings(new BeingsListModel)
{
mList = new AvatarListBox(this, mBeings);
mList->postInit();
- mScroll = new ScrollArea(mList, showBackground,
+ mScroll = new ScrollArea(this, mList, showBackground,
"social_background.xml");
mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_AUTO);
@@ -1208,7 +1181,7 @@ public:
}
private:
- BeingsListModal *mBeings;
+ BeingsListModel *mBeings;
};
@@ -1242,7 +1215,7 @@ public:
A_DELETE_COPY(CreatePopup)
void handleLink(const std::string &link,
- gcn::MouseEvent *event A_UNUSED) override final
+ MouseEvent *event A_UNUSED) override final
{
if (link == "guild" && socialWindow)
{
@@ -1256,7 +1229,7 @@ public:
setVisible(false);
}
- void show(gcn::Widget *parent)
+ void show(Widget *parent)
{
if (!parent)
return;
@@ -1276,7 +1249,7 @@ private:
SocialWindow::SocialWindow() :
// TRANSLATORS: social window name
Window(_("Social"), false, nullptr, "social.xml"),
- gcn::ActionListener(),
+ ActionListener(),
PlayerRelationsListener(),
mGuildInvited(0),
mGuildAcceptDialog(nullptr),
@@ -1336,7 +1309,7 @@ void SocialWindow::postInit()
place(0, 1, mCountLabel);
place(0, 2, mTabs, 4, 4);
- widgetResized(gcn::Event(nullptr));
+ widgetResized(Event(nullptr));
loadWindowState();
@@ -1482,7 +1455,7 @@ bool SocialWindow::removeTab(Party *const party)
return true;
}
-void SocialWindow::action(const gcn::ActionEvent &event)
+void SocialWindow::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
@@ -1744,7 +1717,6 @@ void SocialWindow::slowLogic()
const unsigned int nowTime = cur_time;
if (mNeedUpdate && nowTime - mLastUpdateTime > 1)
{
- logger->log("soc update");
mPlayers->updateList();
mFriends->updateList();
mNeedUpdate = false;
@@ -1863,7 +1835,7 @@ void SocialWindow::updateParty()
}
}
-void SocialWindow::widgetResized(const gcn::Event &event)
+void SocialWindow::widgetResized(const Event &event)
{
Window::widgetResized(event);
if (mTabs)
diff --git a/src/gui/windows/socialwindow.h b/src/gui/windows/socialwindow.h
index e8dc44043..57fbd5be5 100644
--- a/src/gui/windows/socialwindow.h
+++ b/src/gui/windows/socialwindow.h
@@ -24,9 +24,8 @@
#include "gui/widgets/window.h"
-#include "being/playerrelationslistener.h"
-
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
+#include "listeners/playerrelationslistener.h"
#include <string>
#include <map>
@@ -48,7 +47,7 @@ class TextDialog;
* \ingroup Interface
*/
class SocialWindow final : public Window,
- private gcn::ActionListener,
+ private ActionListener,
public PlayerRelationsListener
{
public:
@@ -68,7 +67,7 @@ public:
bool removeTab(Party *const party);
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
void showGuildInvite(const std::string &restrict guildName,
const int guildId,
@@ -123,7 +122,7 @@ public:
void updatePickupFilter();
- void widgetResized(const gcn::Event &event) override final;
+ void widgetResized(const Event &event) override final;
void setCounter(const SocialTab *const tab, const std::string &str);
diff --git a/src/gui/windows/statuswindow.cpp b/src/gui/windows/statuswindow.cpp
index 80e86e66f..05172c9b3 100644
--- a/src/gui/windows/statuswindow.cpp
+++ b/src/gui/windows/statuswindow.cpp
@@ -113,7 +113,7 @@ class DerDisplay final : public AttrDisplay
{ return DERIVED; }
};
-class ChangeDisplay final : public AttrDisplay, gcn::ActionListener
+class ChangeDisplay final : public AttrDisplay, ActionListener
{
public:
ChangeDisplay(const Widget2 *const widget,
@@ -129,7 +129,7 @@ class ChangeDisplay final : public AttrDisplay, gcn::ActionListener
void setPointsNeeded(const int needed);
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
private:
int mNeeded;
@@ -142,7 +142,7 @@ class ChangeDisplay final : public AttrDisplay, gcn::ActionListener
StatusWindow::StatusWindow() :
Window(player_node ? player_node->getName() :
"?", false, nullptr, "status.xml"),
- gcn::ActionListener(),
+ ActionListener(),
// TRANSLATORS: status window label
mLvlLabel(new Label(this, strprintf(_("Level: %d"), 0))),
// TRANSLATORS: status window label
@@ -159,9 +159,9 @@ StatusWindow::StatusWindow() :
mJobLabel(nullptr),
mJobBar(nullptr),
mAttrCont(new VertContainer(this, 32)),
- mAttrScroll(new ScrollArea(mAttrCont, false)),
+ mAttrScroll(new ScrollArea(this, mAttrCont, false)),
mDAttrCont(new VertContainer(this, 32)),
- mDAttrScroll(new ScrollArea(mDAttrCont, false)),
+ mDAttrScroll(new ScrollArea(this, mDAttrCont, false)),
mCharacterPointsLabel(new Label(this, "C")),
mCorrectionPointsLabel(nullptr),
// TRANSLATORS: status window button
@@ -746,7 +746,7 @@ void StatusWindow::updateStatusBar(ProgressBar *const bar,
bar->setBackgroundColor(Theme::getThemeColor(Theme::STATUSBAR_OFF));
}
-void StatusWindow::action(const gcn::ActionEvent &event)
+void StatusWindow::action(const ActionEvent &event)
{
if (!chatWindow)
return;
@@ -820,7 +820,7 @@ ChangeDisplay::ChangeDisplay(const Widget2 *const widget,
const int id, const std::string &restrict name,
const std::string &restrict shortName) :
AttrDisplay(widget, id, name, shortName),
- gcn::ActionListener(),
+ ActionListener(),
mNeeded(1),
// TRANSLATORS: status window label
mPoints(new Label(this, _("Max"))),
@@ -873,7 +873,7 @@ void ChangeDisplay::setPointsNeeded(const int needed)
update();
}
-void ChangeDisplay::action(const gcn::ActionEvent &event)
+void ChangeDisplay::action(const ActionEvent &event)
{
if (Net::getPlayerHandler()->canCorrectAttributes() &&
event.getSource() == mDec)
diff --git a/src/gui/windows/statuswindow.h b/src/gui/windows/statuswindow.h
index 94f1aaa65..3b171a25e 100644
--- a/src/gui/windows/statuswindow.h
+++ b/src/gui/windows/statuswindow.h
@@ -23,11 +23,11 @@
#ifndef GUI_WINDOWS_STATUSWINDOW_H
#define GUI_WINDOWS_STATUSWINDOW_H
-#include "depricatedlistener.h"
+#include "listeners/depricatedlistener.h"
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
#include <map>
@@ -44,7 +44,7 @@ class VertContainer;
* \ingroup Interface
*/
class StatusWindow final : public Window,
- public gcn::ActionListener,
+ public ActionListener,
public DepricatedListener
{
public:
@@ -83,7 +83,7 @@ class StatusWindow final : public Window,
const int id,
const bool percent = true);
- void action(const gcn::ActionEvent &event) override;
+ void action(const ActionEvent &event) override;
void clearAttributes();
diff --git a/src/gui/windows/textcommandeditor.cpp b/src/gui/windows/textcommandeditor.cpp
index 4ae098a3c..dead469bc 100644
--- a/src/gui/windows/textcommandeditor.cpp
+++ b/src/gui/windows/textcommandeditor.cpp
@@ -27,6 +27,10 @@
#include "input/keyboardconfig.h"
+#include "gui/models/iconsmodel.h"
+#include "gui/models/magicschoolmodel.h"
+#include "gui/models/targettypemodel.h"
+
#include "gui/widgets/button.h"
#include "gui/widgets/dropdown.h"
#include "gui/widgets/inttextfield.h"
@@ -36,131 +40,12 @@
#include "utils/gettext.h"
-#include "resources/iteminfo.h"
-
-#include "resources/db/itemdb.h"
-
#include "debug.h"
-class IconsModal final : public gcn::ListModel
-{
-public:
- IconsModal() :
- mStrings()
- {
- const std::map<int, ItemInfo*> &items = ItemDB::getItemInfos();
- std::list<std::string> tempStrings;
-
- for (std::map<int, ItemInfo*>::const_iterator
- i = items.begin(), i_end = items.end();
- i != i_end; ++i)
- {
- if (i->first < 0)
- continue;
-
- const ItemInfo &info = (*i->second);
- const std::string name = info.getName();
- if (name != "unnamed" && !info.getName().empty()
- && info.getName() != "unnamed")
- {
- tempStrings.push_back(name);
- }
- }
- tempStrings.sort();
- mStrings.push_back("");
- FOR_EACH (std::list<std::string>::const_iterator, i, tempStrings)
- mStrings.push_back(*i);
- }
-
- A_DELETE_COPY(IconsModal)
-
- ~IconsModal()
- { }
-
- int getNumberOfElements() override final
- {
- return static_cast<int>(mStrings.size());
- }
-
- std::string getElementAt(int i) override final
- {
- if (i < 0 || i >= getNumberOfElements())
- return "???";
- return mStrings.at(i);
- }
-private:
- StringVect mStrings;
-};
-
-
-const char *TARGET_TYPE_TEXT[3] =
-{
- // TRANSLATORS: target type
- N_("No Target"),
- // TRANSLATORS: target type
- N_("Allow Target"),
- // TRANSLATORS: target type
- N_("Need Target"),
-};
-
-const char *MAGIC_SCHOOL_TEXT[6] =
-{
- // TRANSLATORS: magic school
- N_("General Magic"),
- // TRANSLATORS: magic school
- N_("Life Magic"),
- // TRANSLATORS: magic school
- N_("War Magic"),
- // TRANSLATORS: magic school
- N_("Transmute Magic"),
- // TRANSLATORS: magic school
- N_("Nature Magic"),
- // TRANSLATORS: magic school
- N_("Astral Magic")
-};
-
-class TargetTypeModel final : public gcn::ListModel
-{
-public:
- ~TargetTypeModel()
- { }
-
- int getNumberOfElements() override final
- {
- return 3;
- }
-
- std::string getElementAt(int i) override final
- {
- if (i >= getNumberOfElements() || i < 0)
- return "???";
- return TARGET_TYPE_TEXT[i];
- }
-};
-
-class MagicSchoolModel final : public gcn::ListModel
-{
-public:
- ~MagicSchoolModel()
- { }
-
- int getNumberOfElements() override final
- {
- return 6;
- }
-
- std::string getElementAt(int i) override final
- {
- if (i >= getNumberOfElements() || i < 0)
- return "???";
- return MAGIC_SCHOOL_TEXT[i];
- }
-};
-
TextCommandEditor::TextCommandEditor(TextCommand *const command) :
// TRANSLATORS: command editor name
Window(_("Command Editor"), false, nullptr, "commandeditor.xml"),
- gcn::ActionListener(),
+ ActionListener(),
mIsMagicCommand(command->getCommandType() == TEXT_COMMAND_MAGIC),
mCommand(command),
// TRANSLATORS: command editor button
@@ -180,10 +65,10 @@ TextCommandEditor::TextCommandEditor(TextCommand *const command) :
// TRANSLATORS: command editor label
mTypeLabel(new Label(this, _("Target Type:"))),
mTypeDropDown(new DropDown(this, mTargetTypeModel)),
- mIconsModal(new IconsModal),
+ mIconsModel(new IconsModel),
// TRANSLATORS: command editor label
mIconLabel(new Label(this, _("Icon:"))),
- mIconDropDown(new DropDown(this, mIconsModal)),
+ mIconDropDown(new DropDown(this, mIconsModel)),
// TRANSLATORS: command editor label
mManaLabel(new Label(this, _("Mana:"))),
mManaField(new IntTextField(this, 0)),
@@ -306,15 +191,15 @@ void TextCommandEditor::postInit()
TextCommandEditor::~TextCommandEditor()
{
- delete mIconsModal;
- mIconsModal = nullptr;
+ delete mIconsModel;
+ mIconsModel = nullptr;
delete mTargetTypeModel;
mTargetTypeModel = nullptr;
delete mMagicSchoolModel;
mMagicSchoolModel = nullptr;
}
-void TextCommandEditor::action(const gcn::ActionEvent &event)
+void TextCommandEditor::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "magic")
diff --git a/src/gui/windows/textcommandeditor.h b/src/gui/windows/textcommandeditor.h
index a31cdbaf2..de7f3b1a4 100644
--- a/src/gui/windows/textcommandeditor.h
+++ b/src/gui/windows/textcommandeditor.h
@@ -25,11 +25,11 @@
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
class Button;
class DropDown;
-class IconsModal;
+class IconsModel;
class IntTextField;
class Label;
class MagicSchoolModel;
@@ -38,7 +38,8 @@ class TargetTypeModel;
class TextCommand;
class TextField;
-class TextCommandEditor final : public Window, public gcn::ActionListener
+class TextCommandEditor final : public Window,
+ public ActionListener
{
public:
/**
@@ -55,7 +56,7 @@ class TextCommandEditor final : public Window, public gcn::ActionListener
void postInit() override final;
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
void scheduleDelete() override final;
@@ -82,7 +83,7 @@ class TextCommandEditor final : public Window, public gcn::ActionListener
TargetTypeModel *mTargetTypeModel;
Label *mTypeLabel;
DropDown *mTypeDropDown;
- IconsModal *mIconsModal;
+ IconsModel *mIconsModel;
Label *mIconLabel;
DropDown *mIconDropDown;
Label *mManaLabel;
diff --git a/src/gui/windows/textdialog.cpp b/src/gui/windows/textdialog.cpp
index 936f08c76..9b7bb3eb1 100644
--- a/src/gui/windows/textdialog.cpp
+++ b/src/gui/windows/textdialog.cpp
@@ -30,7 +30,7 @@
#include "utils/gettext.h"
-#include <guichan/font.hpp>
+#include "gui/font.h"
#include "debug.h"
@@ -41,7 +41,7 @@ TextDialog::TextDialog(const std::string &restrict title,
Window *const parent,
const bool isPassword):
Window(title, true, parent, "textdialog.xml"),
- gcn::ActionListener(),
+ ActionListener(),
mTextField(nullptr),
mPasswordField(nullptr),
// TRANSLATORS: text dialog button
@@ -68,7 +68,7 @@ TextDialog::TextDialog(const std::string &restrict title,
place(2, 2, mOkButton);
place(3, 2, cancelButton);
- const gcn::Font *const font = getFont();
+ const Font *const font = getFont();
if (font)
{
int width = font->getWidth(title);
@@ -104,7 +104,7 @@ TextDialog::~TextDialog()
instances--;
}
-void TextDialog::action(const gcn::ActionEvent &event)
+void TextDialog::action(const ActionEvent &event)
{
if (event.getId() == "CANCEL")
setActionEventId("~" + getActionEventId());
diff --git a/src/gui/windows/textdialog.h b/src/gui/windows/textdialog.h
index 9bfb4ae5f..8e69e8a3d 100644
--- a/src/gui/windows/textdialog.h
+++ b/src/gui/windows/textdialog.h
@@ -25,7 +25,7 @@
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
class Button;
class PasswordField;
@@ -36,7 +36,8 @@ class TextField;
*
* \ingroup GUI
*/
-class TextDialog final : public Window, public gcn::ActionListener
+class TextDialog final : public Window,
+ public ActionListener
{
public:
/**
@@ -58,7 +59,7 @@ public:
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
/**
* Get the text in the textfield
diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp
index a379f0f28..506f25c17 100644
--- a/src/gui/windows/tradewindow.cpp
+++ b/src/gui/windows/tradewindow.cpp
@@ -31,7 +31,8 @@
#include "being/playerinfo.h"
#include "being/playerrelations.h"
-#include "gui/sdlfont.h"
+#include "gui/font.h"
+#include "gui/gui.h"
#include "gui/windows/inventorywindow.h"
#include "gui/windows/itemamountwindow.h"
@@ -51,8 +52,6 @@
#include "utils/gettext.h"
-#include <guichan/font.hpp>
-
#include "debug.h"
// TRANSLATORS: trade window button
@@ -67,8 +66,8 @@
TradeWindow::TradeWindow():
// TRANSLATORS: trade window caption
Window(_("Trade: You"), false, nullptr, "trade.xml"),
- gcn::ActionListener(),
- gcn::SelectionListener(),
+ ActionListener(),
+ SelectionListener(),
mMyInventory(new Inventory(Inventory::TRADE)),
mPartnerInventory(new Inventory(Inventory::TRADE)),
mMyItemContainer(new ItemContainer(this, mMyInventory.get())),
@@ -102,7 +101,7 @@ TradeWindow::TradeWindow():
if (setupWindow)
setupWindow->registerWindowForReset(this);
- const gcn::Font *const fnt = mOkButton->getFont();
+ const Font *const fnt = mOkButton->getFont();
int width = std::max(fnt->getWidth(CAPTION_PROPOSE),
fnt->getWidth(CAPTION_CONFIRMED));
width = std::max(width, fnt->getWidth(CAPTION_ACCEPT));
@@ -112,13 +111,14 @@ TradeWindow::TradeWindow():
mMyItemContainer->addSelectionListener(this);
- ScrollArea *const myScroll = new ScrollArea(mMyItemContainer,
+ ScrollArea *const myScroll = new ScrollArea(this, mMyItemContainer,
true, "trade_background.xml");
myScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
mPartnerItemContainer->addSelectionListener(this);
- ScrollArea *const partnerScroll = new ScrollArea(mPartnerItemContainer,
+ ScrollArea *const partnerScroll = new ScrollArea(this,
+ mPartnerItemContainer,
true, "trade_background.xml");
partnerScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);
@@ -130,8 +130,7 @@ TradeWindow::TradeWindow():
place(1, 0, mMoneyLabel);
place(0, 1, myScroll).setPadding(3);
place(1, 1, partnerScroll).setPadding(3);
- ContainerPlacer placer;
- placer = getPlacer(0, 0);
+ ContainerPlacer placer = getPlacer(0, 0);
placer(0, 0, moneyLabel2);
placer(1, 0, mMoneyField, 2);
placer(3, 0, mMoneyChangeButton).setHAlign(LayoutCell::LEFT);
@@ -268,7 +267,7 @@ void TradeWindow::tradeItem(const Item *const item, const int quantity,
Net::getTradeHandler()->addItem(item, quantity);
}
-void TradeWindow::valueChanged(const gcn::SelectionEvent &event)
+void TradeWindow::valueChanged(const SelectionEvent &event)
{
if (!mMyItemContainer || !mPartnerItemContainer)
return;
@@ -318,7 +317,7 @@ void TradeWindow::setStatus(const Status s)
mOkButton->setEnabled((s != PROPOSING && s != ACCEPTED));
}
-void TradeWindow::action(const gcn::ActionEvent &event)
+void TradeWindow::action(const ActionEvent &event)
{
if (!inventoryWindow)
return;
diff --git a/src/gui/windows/tradewindow.h b/src/gui/windows/tradewindow.h
index ac49c1f52..9704c1e80 100644
--- a/src/gui/windows/tradewindow.h
+++ b/src/gui/windows/tradewindow.h
@@ -25,8 +25,8 @@
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
-#include <guichan/selectionlistener.hpp>
+#include "listeners/actionlistener.h"
+#include "listeners/selectionlistener.h"
#include <memory>
@@ -43,8 +43,8 @@ class TextField;
* \ingroup Interface
*/
class TradeWindow final : public Window,
- private gcn::ActionListener,
- private gcn::SelectionListener
+ private ActionListener,
+ private SelectionListener
{
public:
/**
@@ -109,12 +109,12 @@ class TradeWindow final : public Window,
* Updates the labels and makes sure only one item is selected in
* either my inventory or partner inventory.
*/
- void valueChanged(const gcn::SelectionEvent &event) override final;
+ void valueChanged(const SelectionEvent &event) override final;
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
/**
* Closes the Trade Window, as well as telling the server that the
diff --git a/src/gui/windows/unregisterdialog.cpp b/src/gui/windows/unregisterdialog.cpp
index 76afb1539..3326ca2bb 100644
--- a/src/gui/windows/unregisterdialog.cpp
+++ b/src/gui/windows/unregisterdialog.cpp
@@ -45,7 +45,7 @@
UnRegisterDialog::UnRegisterDialog(LoginData *const data) :
// TRANSLATORS: unregister dialog name
Window(_("Unregister"), true, nullptr, "unregister.xml"),
- gcn::ActionListener(),
+ ActionListener(),
mLoginData(data),
mPasswordField(new PasswordField(this, mLoginData->password)),
// TRANSLATORS: unregister dialog. button.
@@ -101,7 +101,7 @@ UnRegisterDialog::~UnRegisterDialog()
mWrongDataNoticeListener = nullptr;
}
-void UnRegisterDialog::action(const gcn::ActionEvent &event)
+void UnRegisterDialog::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "cancel")
diff --git a/src/gui/windows/unregisterdialog.h b/src/gui/windows/unregisterdialog.h
index fd40810ac..206c05413 100644
--- a/src/gui/windows/unregisterdialog.h
+++ b/src/gui/windows/unregisterdialog.h
@@ -25,7 +25,7 @@
#include "gui/widgets/window.h"
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
class Button;
class LoginData;
@@ -37,7 +37,8 @@ class WrongDataNoticeListener;
*
* \ingroup Interface
*/
-class UnRegisterDialog final : public Window, public gcn::ActionListener
+class UnRegisterDialog final : public Window,
+ public ActionListener
{
public:
/**
@@ -56,7 +57,7 @@ class UnRegisterDialog final : public Window, public gcn::ActionListener
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
private:
LoginData *mLoginData;
diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp
index eab1bea1b..e72308da7 100644
--- a/src/gui/windows/updaterwindow.cpp
+++ b/src/gui/windows/updaterwindow.cpp
@@ -25,8 +25,9 @@
#include "client.h"
#include "configuration.h"
+#include "events/keyevent.h"
+
#include "input/keydata.h"
-#include "input/keyevent.h"
#include "gui/widgets/browserbox.h"
#include "gui/widgets/button.h"
@@ -156,8 +157,8 @@ UpdaterWindow::UpdaterWindow(const std::string &restrict updateHost,
const int updateType):
// TRANSLATORS: updater window name
Window(_("Updating..."), false, nullptr, "update.xml"),
- gcn::ActionListener(),
- gcn::KeyListener(),
+ ActionListener(),
+ KeyListener(),
mDownloadStatus(UPDATE_NEWS),
mUpdateHost(updateHost),
mUpdatesDir(updatesDir),
@@ -189,7 +190,8 @@ UpdaterWindow::UpdaterWindow(const std::string &restrict updateHost,
"updateprogressbar.xml", "updateprogressbar_fill.xml")),
mBrowserBox(new BrowserBox(this, BrowserBox::AUTO_SIZE, true,
"browserbox.xml")),
- mScrollArea(new ScrollArea(mBrowserBox, true, "update_background.xml")),
+ mScrollArea(new ScrollArea(this, mBrowserBox,
+ true, "update_background.xml")),
mUpdateServerPath(mUpdateHost)
{
setWindowName("UpdaterWindow");
@@ -270,7 +272,7 @@ void UpdaterWindow::enable()
client->setState(STATE_LOAD_DATA);
}
-void UpdaterWindow::action(const gcn::ActionEvent &event)
+void UpdaterWindow::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "cancel")
@@ -290,12 +292,12 @@ void UpdaterWindow::action(const gcn::ActionEvent &event)
}
}
-void UpdaterWindow::keyPressed(gcn::KeyEvent &keyEvent)
+void UpdaterWindow::keyPressed(KeyEvent &keyEvent)
{
- const int actionId = static_cast<KeyEvent*>(&keyEvent)->getActionId();
+ const int actionId = keyEvent.getActionId();
if (actionId == static_cast<int>(Input::KEY_GUI_CANCEL))
{
- action(gcn::ActionEvent(nullptr, mCancelButton->getActionEventId()));
+ action(ActionEvent(nullptr, mCancelButton->getActionEventId()));
client->setState(STATE_LOGIN);
}
else if (actionId == static_cast<int>(Input::KEY_GUI_SELECT)
@@ -304,12 +306,11 @@ void UpdaterWindow::keyPressed(gcn::KeyEvent &keyEvent)
if (mDownloadStatus == UPDATE_COMPLETE ||
mDownloadStatus == UPDATE_ERROR)
{
- action(gcn::ActionEvent(nullptr, mPlayButton->getActionEventId()));
+ action(ActionEvent(nullptr, mPlayButton->getActionEventId()));
}
else
{
- action(gcn::ActionEvent(nullptr,
- mCancelButton->getActionEventId()));
+ action(ActionEvent(nullptr, mCancelButton->getActionEventId()));
}
}
}
@@ -971,7 +972,7 @@ unsigned long UpdaterWindow::getFileHash(const std::string &filePath)
}
void UpdaterWindow::handleLink(const std::string &link,
- gcn::MouseEvent *event A_UNUSED)
+ MouseEvent *event A_UNUSED)
{
if (strStartWith(link, "http://") || strStartWith(link, "https://"))
openBrowser(link);
diff --git a/src/gui/windows/updaterwindow.h b/src/gui/windows/updaterwindow.h
index bddd3ef9e..79d764752 100644
--- a/src/gui/windows/updaterwindow.h
+++ b/src/gui/windows/updaterwindow.h
@@ -30,8 +30,8 @@
#include "utils/mutex.h"
-#include <guichan/actionlistener.hpp>
-#include <guichan/keylistener.hpp>
+#include "listeners/actionlistener.h"
+#include "listeners/keylistener.h"
#include <string>
#include <vector>
@@ -69,9 +69,9 @@ struct UpdateFile final
* \ingroup GUI
*/
class UpdaterWindow final : public Window,
- public gcn::ActionListener,
+ public ActionListener,
public LinkHandler,
- public gcn::KeyListener
+ public KeyListener
{
public:
/**
@@ -119,14 +119,14 @@ class UpdaterWindow final : public Window,
void loadPatch();
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
- void keyPressed(gcn::KeyEvent &keyEvent) override final;
+ void keyPressed(KeyEvent &keyEvent) override final;
void logic() override final;
void handleLink(const std::string &link,
- gcn::MouseEvent *event A_UNUSED) override final;
+ MouseEvent *event A_UNUSED) override final;
void loadFile(std::string file);
diff --git a/src/gui/windows/whoisonline.cpp b/src/gui/windows/whoisonline.cpp
index fd54076ed..dabc8c7c1 100644
--- a/src/gui/windows/whoisonline.cpp
+++ b/src/gui/windows/whoisonline.cpp
@@ -87,7 +87,7 @@ WhoIsOnline::WhoIsOnline() :
mCurlError(new char[CURL_ERROR_SIZE]),
mBrowserBox(new BrowserBox(this, BrowserBox::AUTO_SIZE, true,
"onlinebrowserbox.xml")),
- mScrollArea(new ScrollArea(mBrowserBox, false)),
+ mScrollArea(new ScrollArea(this, mBrowserBox, false)),
mUpdateTimer(0),
mOnlinePlayers(),
mOnlineNicks(),
@@ -116,10 +116,10 @@ void WhoIsOnline::postInit()
setSaveVisible(true);
mUpdateButton->setEnabled(false);
- mUpdateButton->setDimension(gcn::Rectangle(5, 5, w - 10, 20 + 5));
+ mUpdateButton->setDimension(Rect(5, 5, w - 10, 20 + 5));
mBrowserBox->setOpaque(false);
- mScrollArea->setDimension(gcn::Rectangle(5, 20 + 10, w - 10, h - 10 - 30));
+ mScrollArea->setDimension(Rect(5, 20 + 10, w - 10, h - 10 - 30));
mScrollArea->setSize(w - 10, h - 10 - 30);
mBrowserBox->setLinkHandler(this);
@@ -133,7 +133,7 @@ void WhoIsOnline::postInit()
download();
- widgetResized(gcn::Event(nullptr));
+ widgetResized(Event(nullptr));
config.addListener("updateOnlineList", this);
config.addListener("groupFriends", this);
mGroupFriends = config.getBoolValue("groupFriends");
@@ -159,9 +159,9 @@ WhoIsOnline::~WhoIsOnline()
mOnlineNicks.clear();
}
-void WhoIsOnline::handleLink(const std::string& link, gcn::MouseEvent *event)
+void WhoIsOnline::handleLink(const std::string& link, MouseEvent *event)
{
- if (!event || event->getButton() == gcn::MouseEvent::LEFT)
+ if (!event || event->getButton() == MouseEvent::LEFT)
{
if (chatWindow)
{
@@ -177,7 +177,7 @@ void WhoIsOnline::handleLink(const std::string& link, gcn::MouseEvent *event)
}
}
}
- else if (event->getButton() == gcn::MouseEvent::RIGHT)
+ else if (event->getButton() == MouseEvent::RIGHT)
{
if (player_node && link == player_node->getName())
return;
@@ -683,7 +683,7 @@ void WhoIsOnline::slowLogic()
BLOCK_END("WhoIsOnline::slowLogic")
}
-void WhoIsOnline::action(const gcn::ActionEvent &event)
+void WhoIsOnline::action(const ActionEvent &event)
{
if (event.getId() == "update")
{
@@ -715,7 +715,7 @@ void WhoIsOnline::action(const gcn::ActionEvent &event)
}
}
-void WhoIsOnline::widgetResized(const gcn::Event &event)
+void WhoIsOnline::widgetResized(const Event &event)
{
Window::widgetResized(event);
updateSize();
@@ -723,7 +723,7 @@ void WhoIsOnline::widgetResized(const gcn::Event &event)
void WhoIsOnline::updateSize()
{
- const gcn::Rectangle area = getChildrenArea();
+ const Rect area = getChildrenArea();
if (mUpdateButton)
mUpdateButton->setWidth(area.width - 10);
diff --git a/src/gui/windows/whoisonline.h b/src/gui/windows/whoisonline.h
index 10a8be4b5..bc04c8066 100644
--- a/src/gui/windows/whoisonline.h
+++ b/src/gui/windows/whoisonline.h
@@ -23,14 +23,14 @@
#ifndef GUI_WINDOWS_WHOISONLINE_H
#define GUI_WINDOWS_WHOISONLINE_H
-#include "configlistener.h"
+#include "listeners/configlistener.h"
#include "gui/widgets/linkhandler.h"
#include "gui/widgets/window.h"
#include <set>
-#include <guichan/actionlistener.hpp>
+#include "listeners/actionlistener.h"
class BrowserBox;
class Button;
@@ -102,7 +102,7 @@ class OnlinePlayer final
*/
class WhoIsOnline final : public Window,
public LinkHandler,
- public gcn::ActionListener,
+ public ActionListener,
public ConfigListener
{
public:
@@ -128,15 +128,15 @@ public:
void loadList(std::vector<OnlinePlayer*> &list);
void handleLink(const std::string& link,
- gcn::MouseEvent *event) override final;
+ MouseEvent *event) override final;
void logic() override final;
void slowLogic();
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
- void widgetResized(const gcn::Event &event) override final;
+ void widgetResized(const Event &event) override final;
const std::set<OnlinePlayer*> &getOnlinePlayers() const A_WARN_UNUSED
{ return mOnlinePlayers; }
diff --git a/src/gui/windows/worldselectdialog.cpp b/src/gui/windows/worldselectdialog.cpp
index a3fd0fc73..77d167c82 100644
--- a/src/gui/windows/worldselectdialog.cpp
+++ b/src/gui/windows/worldselectdialog.cpp
@@ -24,14 +24,17 @@
#include "client.h"
+#include "events/keyevent.h"
+
#include "input/keydata.h"
-#include "input/keyevent.h"
#include "gui/widgets/button.h"
#include "gui/widgets/layout.h"
#include "gui/widgets/listbox.h"
#include "gui/widgets/scrollarea.h"
+#include "gui/models/worldlistmodel.h"
+
#include "net/loginhandler.h"
#include "net/net.h"
@@ -41,49 +44,11 @@
extern WorldInfo **server_info;
-/**
- * The list model for the server list.
- */
-class WorldListModel final : public gcn::ListModel
-{
- public:
- explicit WorldListModel(Worlds worlds) :
- mWorlds(worlds)
- {
- }
-
- A_DELETE_COPY(WorldListModel)
-
- ~WorldListModel()
- { }
-
- int getNumberOfElements() override final
- {
- return static_cast<int>(mWorlds.size());
- }
-
- std::string getElementAt(int i) override final
- {
- const WorldInfo *const si = mWorlds[i];
- if (si)
- {
- return std::string(si->name).append(" (").append(
- toString(si->online_users)).append(")");
- }
- else
- {
- return "???";
- }
- }
- private:
- Worlds mWorlds;
-};
-
WorldSelectDialog::WorldSelectDialog(Worlds worlds):
// TRANSLATORS: world select dialog name
Window(_("Select World"), false, nullptr, "world.xml"),
- gcn::ActionListener(),
- gcn::KeyListener(),
+ ActionListener(),
+ KeyListener(),
mWorldListModel(new WorldListModel(worlds)),
mWorldList(new ListBox(this, mWorldListModel, "")),
// TRANSLATORS: world dialog button
@@ -92,7 +57,7 @@ WorldSelectDialog::WorldSelectDialog(Worlds worlds):
mChooseWorld(new Button(this, _("Choose World"), "world", this))
{
mWorldList->postInit();
- ScrollArea *const worldsScroll = new ScrollArea(mWorldList,
+ ScrollArea *const worldsScroll = new ScrollArea(this, mWorldList,
getOptionBool("showbackground"), "world_background.xml");
worldsScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
@@ -134,7 +99,7 @@ WorldSelectDialog::~WorldSelectDialog()
mWorldListModel = nullptr;
}
-void WorldSelectDialog::action(const gcn::ActionEvent &event)
+void WorldSelectDialog::action(const ActionEvent &event)
{
const std::string &eventId = event.getId();
if (eventId == "world")
@@ -153,19 +118,18 @@ void WorldSelectDialog::action(const gcn::ActionEvent &event)
}
}
-void WorldSelectDialog::keyPressed(gcn::KeyEvent &keyEvent)
+void WorldSelectDialog::keyPressed(KeyEvent &keyEvent)
{
- const int actionId = static_cast<KeyEvent*>(
- &keyEvent)->getActionId();
+ const int actionId = keyEvent.getActionId();
if (actionId == static_cast<int>(Input::KEY_GUI_CANCEL))
{
- action(gcn::ActionEvent(nullptr,
+ action(ActionEvent(nullptr,
mChangeLoginButton->getActionEventId()));
}
else if (actionId == static_cast<int>(Input::KEY_GUI_SELECT)
|| actionId == static_cast<int>(Input::KEY_GUI_SELECT2))
{
- action(gcn::ActionEvent(nullptr, mChooseWorld->getActionEventId()));
+ action(ActionEvent(nullptr, mChooseWorld->getActionEventId()));
}
}
diff --git a/src/gui/windows/worldselectdialog.h b/src/gui/windows/worldselectdialog.h
index f7491689b..9d06ac25e 100644
--- a/src/gui/windows/worldselectdialog.h
+++ b/src/gui/windows/worldselectdialog.h
@@ -27,8 +27,8 @@
#include "net/worldinfo.h"
-#include <guichan/actionlistener.hpp>
-#include <guichan/keylistener.hpp>
+#include "listeners/actionlistener.h"
+#include "listeners/keylistener.h"
class Button;
class ListBox;
@@ -39,8 +39,9 @@ class WorldListModel;
*
* \ingroup Interface
*/
-class WorldSelectDialog final : public Window, public gcn::ActionListener,
- public gcn::KeyListener
+class WorldSelectDialog final : public Window,
+ public ActionListener,
+ public KeyListener
{
public:
/**
@@ -62,9 +63,9 @@ class WorldSelectDialog final : public Window, public gcn::ActionListener,
/**
* Called when receiving actions from the widgets.
*/
- void action(const gcn::ActionEvent &event) override final;
+ void action(const ActionEvent &event) override final;
- void keyPressed(gcn::KeyEvent &keyEvent) override final;
+ void keyPressed(KeyEvent &keyEvent) override final;
private:
WorldListModel *mWorldListModel;