diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-09-07 22:09:11 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-09-07 22:09:11 +0300 |
commit | b7e35a7bbd41c39fa675e77b2af6a11bb4d86dd2 (patch) | |
tree | ee27a5a1ace7e5dbc588466dc623013e4d5cea99 /src/gui | |
parent | 7d3059516fc25134d0d29b497e546f2846162399 (diff) | |
download | manaplus-b7e35a7bbd41c39fa675e77b2af6a11bb4d86dd2.tar.gz manaplus-b7e35a7bbd41c39fa675e77b2af6a11bb4d86dd2.tar.bz2 manaplus-b7e35a7bbd41c39fa675e77b2af6a11bb4d86dd2.tar.xz manaplus-b7e35a7bbd41c39fa675e77b2af6a11bb4d86dd2.zip |
Improve constructors in some classes.
Diffstat (limited to 'src/gui')
79 files changed, 585 insertions, 498 deletions
diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp index 36eb0528f..35c219846 100644 --- a/src/gui/npcdialog.cpp +++ b/src/gui/npcdialog.cpp @@ -61,9 +61,25 @@ NpcDialog::DialogList NpcDialog::instances; NpcDialog::NpcDialog(const int npcId) : Window(_("NPC"), false, nullptr, "npc.xml"), + ActionListener(), mNpcId(npcId), mLogInteraction(config.getBoolValue("logNpcInGui")), mDefaultInt(0), + mTextBox(new BrowserBox(BrowserBox::AUTO_WRAP)), + mScrollArea(new ScrollArea(mTextBox, + getOptionBool("showtextbackground"), "npc_textbackground.xml")), + mItemList(new ExtendedListBox(this)), + mListScrollArea(new ScrollArea(mItemList, + getOptionBool("showlistbackground"), "npc_listbackground.xml")), + mItemLinkHandler(new ItemLinkHandler), + mTextField(new TextField("")), + mIntField(new IntTextField), + mPlusButton(new Button(_("+"), "inc", this)), + mMinusButton(new Button(_("-"), "dec", this)), + mClearButton(new Button(_("Clear"), "clear", this)), + mButton(new Button("", "ok", this)), + mButton2(new Button(_("Close"), "close", this)), + mResetButton(new Button(_("Reset"), "reset", this)), mInputState(NPC_INPUT_NONE), mActionState(NPC_ACTION_WAIT), mLastNextTime(0), @@ -89,21 +105,16 @@ NpcDialog::NpcDialog(const int npcId) : mPlayerBox->setWidth(70); mPlayerBox->setHeight(100); - mItemLinkHandler = new ItemLinkHandler; // Setup output text box - mTextBox = new BrowserBox(BrowserBox::AUTO_WRAP); mTextBox->setOpaque(false); mTextBox->setMaxRow(config.getIntValue("ChatLogLength")); mTextBox->setLinkHandler(mItemLinkHandler); mTextBox->setFont(gui->getNpcFont()); - mScrollArea = new ScrollArea(mTextBox, - getOptionBool("showtextbackground"), "npc_textbackground.xml"); mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mScrollArea->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_ALWAYS); // Setup listbox - mItemList = new ExtendedListBox(this); mItemList->setWrappingEnabled(true); mItemList->setActionEventId("ok"); mItemList->addActionListener(this); @@ -116,29 +127,20 @@ NpcDialog::NpcDialog(const int npcId) : setContentSize(260, 175); - mListScrollArea = new ScrollArea(mItemList, - getOptionBool("showlistbackground"), "npc_listbackground.xml"); mListScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mItemList->setVisible(true); // Setup string input box - mTextField = new TextField(""); mTextField->setVisible(true); // Setup int input box - mIntField = new IntTextField; mIntField->setVisible(true); - mClearButton = new Button(_("Clear"), "clear", this); // Setup button - mButton = new Button("", "ok", this); - mButton2 = new Button(_("Close"), "close", this); //Setup more and less buttons (int input) - mPlusButton = new Button(_("+"), "inc", this); - mMinusButton = new Button(_("-"), "dec", this); const gcn::Font *const fnt = mButton->getFont(); int width = std::max(fnt->getWidth(CAPTION_WAITING), @@ -148,7 +150,6 @@ NpcDialog::NpcDialog(const int npcId) : mButton->setWidth(8 + width); - mResetButton = new Button(_("Reset"), "reset", this); // Place widgets buildLayout(); diff --git a/src/gui/npcdialog.h b/src/gui/npcdialog.h index 2d7ed5149..02479c4b1 100644 --- a/src/gui/npcdialog.h +++ b/src/gui/npcdialog.h @@ -223,8 +223,8 @@ class NpcDialog : public Window, public gcn::ActionListener, std::string mDefaultString; // Used for the main input area - gcn::ScrollArea *mScrollArea; BrowserBox *mTextBox; + gcn::ScrollArea *mScrollArea; //TextBox *mTextBox; std::string mText; std::string mNewText; @@ -241,12 +241,10 @@ class NpcDialog : public Window, public gcn::ActionListener, IntTextField *mIntField; Button *mPlusButton; Button *mMinusButton; - Button *mClearButton; // Used for the button Button *mButton; - Button *mButton2; // Will reset the text and integer input to the provided default diff --git a/src/gui/okdialog.cpp b/src/gui/okdialog.cpp index 4b816794e..38174c9bd 100644 --- a/src/gui/okdialog.cpp +++ b/src/gui/okdialog.cpp @@ -38,9 +38,10 @@ OkDialog::OkDialog(const std::string &title, const std::string &msg, const int soundEvent, const bool modal, const bool showCenter, Window *const parent): - Window(title, modal, parent, "ok.xml") + Window(title, modal, parent, "ok.xml"), + ActionListener(), + mTextBox(new TextBox) { - mTextBox = new TextBox; mTextBox->setEditable(false); mTextBox->setOpaque(false); mTextBox->setTextWrapped(msg, 260); diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp index cf66fae76..8afc92b43 100644 --- a/src/gui/outfitwindow.cpp +++ b/src/gui/outfitwindow.cpp @@ -57,8 +57,21 @@ float OutfitWindow::mAlpha = 1.0; OutfitWindow::OutfitWindow(): Window(_("Outfits"), false, nullptr, "outfits.xml"), + ActionListener(), + mPreviousButton(new Button(_("<"), "previous", this)), + mNextButton(new Button(_(">"), "next", this)), + mEquipButtom(new Button(_("Equip"), "equip", this)), + mCurrentLabel(new Label(strprintf(_("Outfit: %d"), 1))), + mUnequipCheck(new CheckBox(_("Unequip first"), + serverConfig.getValueBool("OutfitUnequip0", true))), + mAwayOutfitCheck(new CheckBox(_("Away outfit"), + serverConfig.getValue("OutfitAwayIndex", OUTFITS_COUNT - 1))), + mKeyLabel(new Label(strprintf(_("Key: %s"), + keyName(mCurrentOutfit).c_str()))), mBoxWidth(33), mBoxHeight(33), + mCursorPosX(0), + mCursorPosY(0), mGridWidth(4), mGridHeight(4), mItemClicked(false), @@ -80,19 +93,8 @@ OutfitWindow::OutfitWindow(): mBorderColor = Theme::getThemeColor(Theme::BORDER, 64); mBackgroundColor = Theme::getThemeColor(Theme::BACKGROUND, 32); - mPreviousButton = new Button(_("<"), "previous", this); - mNextButton = new Button(_(">"), "next", this); - mCurrentLabel = new Label(strprintf(_("Outfit: %d"), 1)); mCurrentLabel->setAlignment(gcn::Graphics::CENTER); - mKeyLabel = new Label(strprintf(_("Key: %s"), - keyName(mCurrentOutfit).c_str())); mKeyLabel->setAlignment(gcn::Graphics::CENTER); - mUnequipCheck = new CheckBox(_("Unequip first"), - serverConfig.getValueBool("OutfitUnequip0", true)); - mEquipButtom = new Button(_("Equip"), "equip", this); - - mAwayOutfitCheck = new CheckBox(_("Away outfit"), - serverConfig.getValue("OutfitAwayIndex", OUTFITS_COUNT - 1)); mUnequipCheck->setActionEventId("unequip"); mUnequipCheck->addActionListener(this); diff --git a/src/gui/outfitwindow.h b/src/gui/outfitwindow.h index 19ad53a6f..7ab15c7c1 100644 --- a/src/gui/outfitwindow.h +++ b/src/gui/outfitwindow.h @@ -119,8 +119,10 @@ class OutfitWindow : public Window, private gcn::ActionListener int mBoxWidth; int mBoxHeight; - int mCursorPosX, mCursorPosY; - int mGridWidth, mGridHeight; + int mCursorPosX; + int mCursorPosY; + int mGridWidth; + int mGridHeight; bool mItemClicked; Item *mItemMoved; @@ -135,7 +137,6 @@ class OutfitWindow : public Window, private gcn::ActionListener int mCurrentOutfit; int mAwayOutfit; - Image *mBackgroundImg; gcn::Color mBorderColor; gcn::Color mBackgroundColor; diff --git a/src/gui/questswindow.cpp b/src/gui/questswindow.cpp index 51ad76505..092fdc6c3 100644 --- a/src/gui/questswindow.cpp +++ b/src/gui/questswindow.cpp @@ -75,7 +75,8 @@ struct QuestItem class QuestsModel : public ExtendedNamesModel { public: - QuestsModel() + QuestsModel() : + ExtendedNamesModel() { } @@ -85,6 +86,7 @@ class QuestsModel : public ExtendedNamesModel QuestsWindow::QuestsWindow() : Window(_("Quests"), false, nullptr, "quests.xml"), + ActionListener(), mQuestsModel(new QuestsModel), mQuestsListBox(new ExtendedListBox(mQuestsModel)), mQuestScrollArea(new ScrollArea(mQuestsListBox, diff --git a/src/gui/quitdialog.cpp b/src/gui/quitdialog.cpp index d5a4d8504..f8f37bdec 100644 --- a/src/gui/quitdialog.cpp +++ b/src/gui/quitdialog.cpp @@ -48,6 +48,8 @@ QuitDialog::QuitDialog(QuitDialog **const pointerToMe): Window(_("Quit"), true, nullptr, "quit.xml"), + ActionListener(), + KeyListener(), mLogoutQuit(new RadioButton(_("Quit"), "quitdialog")), mForceQuit(new RadioButton(_("Quit"), "quitdialog")), mSwitchAccountServer(new RadioButton(_("Switch server"), "quitdialog")), diff --git a/src/gui/registerdialog.cpp b/src/gui/registerdialog.cpp index 8710ad9c6..7beec0abc 100644 --- a/src/gui/registerdialog.cpp +++ b/src/gui/registerdialog.cpp @@ -45,6 +45,7 @@ #include "debug.h" WrongDataNoticeListener::WrongDataNoticeListener(): + ActionListener(), mTarget(nullptr) { } @@ -62,23 +63,25 @@ void WrongDataNoticeListener::action(const gcn::ActionEvent &event) RegisterDialog::RegisterDialog(LoginData *const data): Window(_("Register"), false, nullptr, "register.xml"), + ActionListener(), + KeyListener(), + mLoginData(data), + mUserField(new TextField(mLoginData->username)), + mPasswordField(new PasswordField(mLoginData->password)), + mConfirmField(new PasswordField), mEmailField(nullptr), + mRegisterButton(new Button(_("Register"), "register", this)), + mCancelButton(new Button(_("Cancel"), "cancel", this)), mMaleButton(nullptr), mFemaleButton(nullptr), mOtherButton(nullptr), - mWrongDataNoticeListener(new WrongDataNoticeListener), - mLoginData(data) + mWrongDataNoticeListener(new WrongDataNoticeListener) { int optionalActions = Net::getLoginHandler()->supportedOptionalActions(); gcn::Label *const userLabel = new Label(_("Name:")); gcn::Label *const passwordLabel = new Label(_("Password:")); gcn::Label *const confirmLabel = new Label(_("Confirm:")); - mUserField = new TextField(mLoginData->username); - mPasswordField = new PasswordField(mLoginData->password); - mConfirmField = new PasswordField; - mRegisterButton = new Button(_("Register"), "register", this); - mCancelButton = new Button(_("Cancel"), "cancel", this); ContainerPlacer placer; placer = getPlacer(0, 0); diff --git a/src/gui/registerdialog.h b/src/gui/registerdialog.h index ada378251..138695177 100644 --- a/src/gui/registerdialog.h +++ b/src/gui/registerdialog.h @@ -94,11 +94,12 @@ class RegisterDialog : public Window, public gcn::ActionListener, */ bool canSubmit() const; + LoginData *mLoginData; + gcn::TextField *mUserField; gcn::TextField *mPasswordField; gcn::TextField *mConfirmField; gcn::TextField *mEmailField; - gcn::Button *mRegisterButton; gcn::Button *mCancelButton; gcn::RadioButton *mMaleButton; @@ -106,8 +107,6 @@ class RegisterDialog : public Window, public gcn::ActionListener, gcn::RadioButton *mOtherButton; WrongDataNoticeListener *mWrongDataNoticeListener; - - LoginData *mLoginData; }; #endif diff --git a/src/gui/sdlfont.cpp b/src/gui/sdlfont.cpp index 2dbf880a5..5422a4c67 100644 --- a/src/gui/sdlfont.cpp +++ b/src/gui/sdlfont.cpp @@ -98,7 +98,8 @@ static int fontCounter; SDLFont::SDLFont(std::string filename, const int size, const int style) : mCreateCounter(0), - mDeleteCounter(0) + mDeleteCounter(0), + mCleanTime(cur_time + CLEAN_TIME) { const ResourceManager *const resman = ResourceManager::getInstance(); @@ -133,7 +134,6 @@ SDLFont::SDLFont(std::string filename, const int size, const int style) : } TTF_SetFontStyle(mFont, style); - mCleanTime = cur_time + CLEAN_TIME; } SDLFont::~SDLFont() diff --git a/src/gui/selldialog.cpp b/src/gui/selldialog.cpp index 8f8969883..777c60c10 100644 --- a/src/gui/selldialog.cpp +++ b/src/gui/selldialog.cpp @@ -47,8 +47,10 @@ SellDialog::DialogList SellDialog::instances; -SellDialog::SellDialog(const int npcId): +SellDialog::SellDialog(const int npcId) : Window(_("Sell"), false, nullptr, "sell.xml"), + ActionListener(), + SelectionListener(), mNpcId(npcId), mMaxItems(0), mAmountItems(0), mNick("") { init(); @@ -56,6 +58,8 @@ SellDialog::SellDialog(const int npcId): SellDialog::SellDialog(std::string nick): Window(_("Sell"), false, nullptr, "sell.xml"), + ActionListener(), + SelectionListener(), mNpcId(-1), mMaxItems(0), mAmountItems(0), mNick(nick) { init(); diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index 0104e2aa5..472d01223 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -243,12 +243,23 @@ private: ServerDialog::ServerDialog(ServerInfo *const serverInfo, const std::string &dir) : Window(_("Choose Your Server"), false, nullptr, "server.xml"), + ActionListener(), + KeyListener(), + SelectionListener(), + mDescription(new Label(std::string())), + mQuitButton(new Button(_("Quit"), "quit", this)), + mConnectButton(new Button(_("Connect"), "connect", this)), + mAddEntryButton(new Button(_("Add"), "addEntry", this)), + mEditEntryButton(new Button(_("Edit"), "editEntry", this)), + mDeleteButton(new Button(_("Delete"), "remove", this)), + mLoadButton(new Button(_("Load"), "load", this)), + mServers(ServerInfos()), + mServersListModel(new ServersListModel(&mServers, this)), + mServersList(new ServersListBox(mServersListModel)), mDir(dir), -// mDownloadStatus(DOWNLOADING_PREPARING), mDownloadStatus(DOWNLOADING_UNKNOWN), mDownload(nullptr), mDownloadProgress(-1.0f), - mServers(ServerInfos()), mServerInfo(serverInfo), mPersistentIPCheckBox(nullptr) { @@ -263,29 +274,16 @@ ServerDialog::ServerDialog(ServerInfo *const serverInfo, loadCustomServers(); - mServersListModel = new ServersListModel(&mServers, this); - - mServersList = new ServersListBox(mServersListModel); mServersList->addMouseListener(this); ScrollArea *const usedScroll = new ScrollArea(mServersList, getOptionBool("showbackground"), "server_background.xml"); usedScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); - const int n = 0; - - mDescription = new Label(std::string()); - - mQuitButton = new Button(_("Quit"), "quit", this); - mLoadButton = new Button(_("Load"), "load", this); - mConnectButton = new Button(_("Connect"), "connect", this); - mAddEntryButton = new Button(_("Add"), "addEntry", this); - mEditEntryButton = new Button(_("Edit"), "editEntry", this); - mDeleteButton = new Button(_("Delete"), "remove", this); - mServersList->addSelectionListener(this); usedScroll->setVerticalScrollAmount(0); + const int n = 0; place(0, 0 + n, usedScroll, 7, 5).setPadding(3); place(0, 5 + n, mDescription, 7); place(0, 6 + n, mPersistentIPCheckBox, 7); diff --git a/src/gui/serverdialog.h b/src/gui/serverdialog.h index d493a86b9..58d942434 100644 --- a/src/gui/serverdialog.h +++ b/src/gui/serverdialog.h @@ -162,8 +162,9 @@ class ServerDialog : public Window, Button *mDeleteButton; Button *mLoadButton; - ListBox *mServersList; + ServerInfos mServers; ServersListModel *mServersListModel; + ListBox *mServersList; const std::string &mDir; @@ -186,7 +187,6 @@ class ServerDialog : public Window, Mutex mMutex; float mDownloadProgress; - ServerInfos mServers; ServerInfo *mServerInfo; CheckBox *mPersistentIPCheckBox; }; diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index 161b2326d..51c8eb9f8 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -51,7 +51,9 @@ extern Window *statusWindow; Setup::Setup(): Window(_("Setup"), false, nullptr, "setup.xml"), - mResetWindows(nullptr) + ActionListener(), + mResetWindows(nullptr), + mPanel(new TabbedArea) { setCloseButton(true); setResizable(true); @@ -88,7 +90,6 @@ Setup::Setup(): mResetWindows = btn; } - mPanel = new TabbedArea; mPanel->setDimension(gcn::Rectangle(5, 5, width - 10, height - 40)); mPanel->enableScrollButtons(true); diff --git a/src/gui/setup_audio.cpp b/src/gui/setup_audio.cpp index b649bc23d..27fceee92 100644 --- a/src/gui/setup_audio.cpp +++ b/src/gui/setup_audio.cpp @@ -39,7 +39,8 @@ class SoundsModel : public NamesModel { public: - SoundsModel() + SoundsModel() : + NamesModel() { mNames.push_back(gettext("(no sound)")); Theme::fillSoundsList(mNames); @@ -49,7 +50,10 @@ public: { } }; -Setup_Audio::Setup_Audio() +Setup_Audio::Setup_Audio() : + SetupTabScroll(), + mSoundModel(new SoundsModel()), + mChannelsList(new SetupItemNames()) { setName(_("Audio")); @@ -58,8 +62,6 @@ Setup_Audio::Setup_Audio() ContainerPlacer place = h.getPlacer(0, 0); place(0, 0, mScroll, 10, 10); - mSoundModel = new SoundsModel(); - new SetupItemLabel(_("Basic settings"), "", this); new SetupItemCheckBox(_("Enable Audio"), "", "sound", this, "soundEvent"); @@ -82,7 +84,6 @@ Setup_Audio::Setup_Audio() new SetupItemIntTextField(_("Audio frequency"), "", "audioFrequency", this, "audioFrequencyEvent", 14000, 192000); - mChannelsList = new SetupItemNames(); mChannelsList->push_back(_("mono")); mChannelsList->push_back(_("stereo")); mChannelsList->push_back(_("surround")); diff --git a/src/gui/setup_chat.cpp b/src/gui/setup_chat.cpp index ee6a85eaf..6a4abdf81 100644 --- a/src/gui/setup_chat.cpp +++ b/src/gui/setup_chat.cpp @@ -41,7 +41,8 @@ #include "debug.h" -Setup_Chat::Setup_Chat() +Setup_Chat::Setup_Chat() : + SetupTabScroll() { setName(_("Chat")); diff --git a/src/gui/setup_colors.cpp b/src/gui/setup_colors.cpp index 80cb89d8a..b8ccc7bf2 100644 --- a/src/gui/setup_colors.cpp +++ b/src/gui/setup_colors.cpp @@ -49,41 +49,52 @@ const std::string Setup_Colors::rawmsg = _("This is what the color looks like"); Setup_Colors::Setup_Colors() : - mSelected(-1) + SetupTab(), + SelectionListener(), + mColorBox(new ListBox(userPalette)), + mScroll(new ScrollArea(mColorBox, true, "setup_colors_background.xml")), + mPreview(new BrowserBox(BrowserBox::AUTO_WRAP)), + mTextPreview(new TextPreview(rawmsg)), + mPreviewBox(new ScrollArea(mPreview, true, + "setup_colors_preview_background.xml")), + mSelected(-1), + mGradTypeLabel(new Label(_("Type:"))), + mGradTypeSlider(new Slider(0, 3)), + mGradTypeText(new Label), + mGradDelayLabel(new Label(_("Delay:"))), + mGradDelaySlider(new Slider(20, 100)), + mGradDelayText(new TextField()), + mRedLabel(new Label(_("Red:"))), + mRedSlider(new Slider(0, 255)), + mRedText(new TextField), + mRedValue(0), + mGreenLabel(new Label(_("Green:"))), + mGreenSlider(new Slider(0, 255)), + mGreenText(new TextField), + mGreenValue(0), + mBlueLabel(new Label(_("Blue:"))), + mBlueSlider(new Slider(0, 255)), + mBlueText(new TextField), + mBlueValue(0) { setName(_("Colors")); - - mColorBox = new ListBox(userPalette); mColorBox->addSelectionListener(this); - - mScroll = new ScrollArea(mColorBox, true, "setup_colors_background.xml"); mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); - - mTextPreview = new TextPreview(rawmsg); - - mPreview = new BrowserBox(BrowserBox::AUTO_WRAP); mPreview->setOpaque(false); // don't do anything with links mPreview->setLinkHandler(nullptr); - mPreviewBox = new ScrollArea(mPreview, true, - "setup_colors_preview_background.xml"); mPreviewBox->setHeight(20); mPreviewBox->setScrollPolicy(gcn::ScrollArea::SHOW_NEVER, gcn::ScrollArea::SHOW_NEVER); - mGradTypeLabel = new Label(_("Type:")); - - mGradTypeSlider = new Slider(0, 3); mGradTypeSlider->setWidth(180); mGradTypeSlider->setActionEventId("slider_grad"); mGradTypeSlider->setValue(0); mGradTypeSlider->addActionListener(this); mGradTypeSlider->setEnabled(false); - mGradTypeText = new Label; - std::string longText = _("Static"); if (getFont()->getWidth(_("Pulse")) > getFont()->getWidth(longText)) @@ -95,60 +106,44 @@ Setup_Colors::Setup_Colors() : mGradTypeText->setCaption(longText); - mGradDelayLabel = new Label(_("Delay:")); - - mGradDelayText = new TextField(); mGradDelayText->setWidth(40); mGradDelayText->setRange(20, 100); mGradDelayText->setNumeric(true); mGradDelayText->setEnabled(false); - mGradDelaySlider = new Slider(20, 100); mGradDelaySlider->setWidth(180); mGradDelaySlider->setValue(mGradDelayText->getValue()); mGradDelaySlider->setActionEventId("slider_graddelay"); mGradDelaySlider->addActionListener(this); mGradDelaySlider->setEnabled(false); - mRedLabel = new Label(_("Red:")); - - mRedText = new TextField; mRedText->setWidth(40); mRedText->setRange(0, 255); mRedText->setNumeric(true); mRedText->setEnabled(false); - mRedSlider = new Slider(0, 255); mRedSlider->setWidth(180); mRedSlider->setValue(mRedText->getValue()); mRedSlider->setActionEventId("slider_red"); mRedSlider->addActionListener(this); mRedSlider->setEnabled(false); - mGreenLabel = new Label(_("Green:")); - - mGreenText = new TextField; mGreenText->setWidth(40); mGreenText->setRange(0, 255); mGreenText->setNumeric(true); mGreenText->setEnabled(false); - mGreenSlider = new Slider(0, 255); mGreenSlider->setWidth(180); mGreenSlider->setValue(mGreenText->getValue()); mGreenSlider->setActionEventId("slider_green"); mGreenSlider->addActionListener(this); mGreenSlider->setEnabled(false); - mBlueLabel = new Label(_("Blue:")); - - mBlueText = new TextField; mBlueText->setWidth(40); mBlueText->setRange(0, 255); mBlueText->setNumeric(true); mBlueText->setEnabled(false); - mBlueSlider = new Slider(0, 255); mBlueSlider->setWidth(180); mBlueSlider->setValue(mBlueText->getValue()); mBlueSlider->setActionEventId("slider_blue"); diff --git a/src/gui/setup_joystick.cpp b/src/gui/setup_joystick.cpp index acc8407bb..851869d75 100644 --- a/src/gui/setup_joystick.cpp +++ b/src/gui/setup_joystick.cpp @@ -41,7 +41,8 @@ extern Joystick *joystick; -Setup_Joystick::Setup_Joystick(): +Setup_Joystick::Setup_Joystick() : + SetupTab(), mCalibrateLabel(new Label(_("Press the button to start calibration"))), mCalibrateButton(new Button(_("Calibrate"), "calibrate", this)), mJoystickEnabled(new CheckBox(_("Enable joystick"))), diff --git a/src/gui/setup_other.cpp b/src/gui/setup_other.cpp index e727f7f39..424a518f2 100644 --- a/src/gui/setup_other.cpp +++ b/src/gui/setup_other.cpp @@ -32,7 +32,10 @@ #include "debug.h" -Setup_Other::Setup_Other() +Setup_Other::Setup_Other() : + SetupTabScroll(), + mProxyTypeList(new SetupItemNames()), + mShortcutsList(new SetupItemNames()) { setName(_("Misc")); @@ -182,7 +185,6 @@ Setup_Other::Setup_Other() new SetupItemLabel(_("Windows"), "", this); - mShortcutsList = new SetupItemNames(); mShortcutsList->push_back(_("Always show")); mShortcutsList->push_back(_("Auto hide in small resolution")); mShortcutsList->push_back(_("Always auto hide")); @@ -192,7 +194,6 @@ Setup_Other::Setup_Other() new SetupItemLabel(_("Proxy server"), "", this); - mProxyTypeList = new SetupItemNames(); mProxyTypeList->push_back(_("System proxy")); mProxyTypeList->push_back(_("Direct connection")); mProxyTypeList->push_back("HTTP"); diff --git a/src/gui/setup_perfomance.cpp b/src/gui/setup_perfomance.cpp index d9c3e3fb1..3e673df36 100644 --- a/src/gui/setup_perfomance.cpp +++ b/src/gui/setup_perfomance.cpp @@ -41,7 +41,8 @@ #include "debug.h" -Setup_Perfomance::Setup_Perfomance() +Setup_Perfomance::Setup_Perfomance() : + SetupTabScroll() { setName(_("Perfomance")); diff --git a/src/gui/setup_relations.cpp b/src/gui/setup_relations.cpp index b8b8627f1..50a41e3e6 100644 --- a/src/gui/setup_relations.cpp +++ b/src/gui/setup_relations.cpp @@ -95,6 +95,7 @@ class PlayerTableModel : public TableModel { public: PlayerTableModel() : + TableModel(), mPlayers(nullptr), mListModel(new PlayerRelationListModel) { @@ -231,7 +232,9 @@ static const std::string ACTION_DELETE = "delete"; static const std::string ACTION_TABLE = "table"; static const std::string ACTION_STRATEGY = "strategy"; -Setup_Relations::Setup_Relations(): +Setup_Relations::Setup_Relations() : + SetupTab(), + PlayerRelationsListener(), mPlayerTableTitleModel(new StaticTableModel(1, COLUMNS_NR)), mPlayerTableModel(new PlayerTableModel), mPlayerTable(new GuiTable(mPlayerTableModel)), diff --git a/src/gui/setup_theme.cpp b/src/gui/setup_theme.cpp index 8b53e73b7..ddfd52291 100644 --- a/src/gui/setup_theme.cpp +++ b/src/gui/setup_theme.cpp @@ -55,7 +55,8 @@ const char* ACTION_JAPAN_FONT = "japan font"; class ThemesModel : public NamesModel { public: - ThemesModel() + ThemesModel() : + NamesModel() { mNames.push_back(gettext("(default)")); Theme::fillSkinsList(mNames); @@ -68,7 +69,8 @@ public: class FontsModel : public NamesModel { public: - FontsModel() + FontsModel() : + NamesModel() { Theme::fillFontsList(mNames); } virtual ~FontsModel() @@ -157,73 +159,64 @@ public: } }; -Setup_Theme::Setup_Theme(): +Setup_Theme::Setup_Theme() : + SetupTab(), + mThemeLabel(new Label(_("Gui theme"))), + mThemesModel(new ThemesModel), + mThemeDropDown(new DropDown(mThemesModel)), mTheme(config.getValue("theme", config.getValue("selectedSkin", ""))), + mFontsModel(new FontsModel), + mFontLabel(new Label(_("Main Font"))), + mFontDropDown(new DropDown(mFontsModel)), mFont(config.getStringValue("font")), + mLangListModel(new LangListModel), + mLangLabel(new Label(_("Language"))), + mLangDropDown(new DropDown(mLangListModel)), mLang(config.getStringValue("lang")), + mBoldFontLabel(new Label(_("Bold font"))), + mBoldFontDropDown(new DropDown(mFontsModel)), mBoldFont(config.getStringValue("boldFont")), + mParticleFontLabel(new Label(_("Particle font"))), + mParticleFontDropDown(new DropDown(mFontsModel)), mParticleFont(config.getStringValue("particleFont")), + mHelpFontLabel(new Label(_("Help font"))), + mHelpFontDropDown(new DropDown(mFontsModel)), mHelpFont(config.getStringValue("helpFont")), + mSecureFontLabel(new Label(_("Secure font"))), + mSecureFontDropDown(new DropDown(mFontsModel)), mSecureFont(config.getStringValue("secureFont")), + mJapanFontLabel(new Label(_("Japanese font"))), + mJapanFontDropDown(new DropDown(mFontsModel)), mJapanFont(config.getStringValue("japanFont")), + mFontSizeListModel(new FontSizeChoiceListModel), + mFontSizeLabel(new Label(_("Font size"))), mFontSize(config.getIntValue("fontSize")), - mNpcFontSize(config.getIntValue("npcfontSize")) + mFontSizeDropDown(new DropDown(mFontSizeListModel)), + mNpcFontSizeListModel(new FontSizeChoiceListModel), + mNpcFontSizeLabel(new Label(_("Npc font size"))), + mNpcFontSize(config.getIntValue("npcfontSize")), + mNpcFontSizeDropDown(new DropDown(mNpcFontSizeListModel)) { setName(_("Theme")); - mThemeLabel = new Label(_("Gui theme")); - mLangLabel = new Label(_("Language")); - mFontLabel = new Label(_("Main Font")); - mBoldFontLabel = new Label(_("Bold font")); - mParticleFontLabel = new Label(_("Particle font")); - mHelpFontLabel = new Label(_("Help font")); - mSecureFontLabel = new Label(_("Secure font")); - mJapanFontLabel = new Label(_("Japanese font")); - mThemesModel = new ThemesModel(); - mFontsModel = new FontsModel(); - mLangListModel = new LangListModel(); - - mThemeDropDown = new DropDown(mThemesModel); mThemeDropDown->setActionEventId(ACTION_THEME); mThemeDropDown->addActionListener(this); - - mFontDropDown = new DropDown(mFontsModel); mFontDropDown->setActionEventId(ACTION_FONT); mFontDropDown->addActionListener(this); - - mLangDropDown = new DropDown(mLangListModel); mLangDropDown->setActionEventId(ACTION_LANG); mLangDropDown->addActionListener(this); - - mBoldFontDropDown = new DropDown(mFontsModel); mBoldFontDropDown->setActionEventId(ACTION_BOLD_FONT); mBoldFontDropDown->addActionListener(this); - - mParticleFontDropDown = new DropDown(mFontsModel); mParticleFontDropDown->setActionEventId(ACTION_PARTICLE_FONT); mParticleFontDropDown->addActionListener(this); - - mHelpFontDropDown = new DropDown(mFontsModel); mHelpFontDropDown->setActionEventId(ACTION_HELP_FONT); mHelpFontDropDown->addActionListener(this); - - mSecureFontDropDown = new DropDown(mFontsModel); mSecureFontDropDown->setActionEventId(ACTION_SECURE_FONT); mSecureFontDropDown->addActionListener(this); - - mJapanFontDropDown = new DropDown(mFontsModel); mJapanFontDropDown->setActionEventId(ACTION_JAPAN_FONT); mJapanFontDropDown->addActionListener(this); - - mFontSizeLabel = new Label(_("Font size")); - mFontSizeListModel = new FontSizeChoiceListModel; - mFontSizeDropDown = new DropDown(mFontSizeListModel); mFontSizeDropDown->setSelected(mFontSize - 9); mFontSizeDropDown->adjustHeight(); - - mNpcFontSizeLabel = new Label(_("Npc font size")); - mNpcFontSizeListModel = new FontSizeChoiceListModel; - mNpcFontSizeDropDown = new DropDown(mNpcFontSizeListModel); mNpcFontSizeDropDown->setSelected(mNpcFontSize - 9); mNpcFontSizeDropDown->adjustHeight(); diff --git a/src/gui/setup_theme.h b/src/gui/setup_theme.h index f22fc2fd1..cc8b01fbe 100644 --- a/src/gui/setup_theme.h +++ b/src/gui/setup_theme.h @@ -53,11 +53,11 @@ class Setup_Theme : public SetupTab private: gcn::Label *mThemeLabel; + ThemesModel *mThemesModel; DropDown *mThemeDropDown; std::string mTheme; - ThemesModel *mThemesModel; - FontsModel *mFontsModel; + FontsModel *mFontsModel; gcn::Label *mFontLabel; DropDown *mFontDropDown; std::string mFont; @@ -98,7 +98,7 @@ class Setup_Theme : public SetupTab int mNpcFontSize; gcn::DropDown *mNpcFontSizeDropDown; - EditDialog *mEditDialog; +// EditDialog *mEditDialog; }; #endif diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index 6daf87bf2..5250028d2 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -217,7 +217,9 @@ public: } }; -Setup_Video::Setup_Video(): +Setup_Video::Setup_Video() : + SetupTab(), + KeyListener(), mFullScreenEnabled(config.getBoolValue("screen")), mOpenGLEnabled(config.getIntValue("opengl")), mCustomCursorEnabled(config.getBoolValue("customcursor")), diff --git a/src/gui/setup_visual.cpp b/src/gui/setup_visual.cpp index 276387abb..77321127a 100644 --- a/src/gui/setup_visual.cpp +++ b/src/gui/setup_visual.cpp @@ -30,7 +30,13 @@ #include "debug.h" -Setup_Visual::Setup_Visual() +Setup_Visual::Setup_Visual() : + SetupTabScroll(), + mSpeachList(new SetupItemNames), + mAmbientFxList(new SetupItemNames), + mParticleList(new SetupItemNames), + mParticleTypeList(new SetupItemNames), + mVSyncList(new SetupItemNames) { setName(_("Visual")); // Do the layout @@ -59,7 +65,6 @@ Setup_Visual::Setup_Visual() new SetupItemSlider(_("Gui opacity"), "", "guialpha", this, "guialphaEvent", 0.1, 1.0, 150, true); - mSpeachList = new SetupItemNames(); mSpeachList->push_back(_("No text")); mSpeachList->push_back(_("Text")); mSpeachList->push_back(_("Bubbles, no names")); @@ -67,7 +72,6 @@ Setup_Visual::Setup_Visual() new SetupItemSlider2(_("Overhead text"), "", "speech", this, "speechEvent", 0, 3, mSpeachList); - mAmbientFxList = new SetupItemNames(); mAmbientFxList->push_back(_("off")); mAmbientFxList->push_back(_("low")); mAmbientFxList->push_back(_("high")); @@ -77,7 +81,6 @@ Setup_Visual::Setup_Visual() new SetupItemCheckBox(_("Particle effects"), "", "particleeffects", this, "particleeffectsEvent"); - mParticleList = new SetupItemNames(); mParticleList->push_back(_("low")); mParticleList->push_back(_("medium")); mParticleList->push_back(_("high")); @@ -86,7 +89,6 @@ Setup_Visual::Setup_Visual() this, "particleEmitterSkipEvent", 0, 3, mParticleList, true))->setInvertValue(3); - mParticleTypeList = new SetupItemNames(); mParticleTypeList->push_back(_("best quality")); mParticleTypeList->push_back(_("normal")); mParticleTypeList->push_back(_("best perfomance")); @@ -98,7 +100,6 @@ Setup_Visual::Setup_Visual() new SetupItemSlider(_("Gamma"), "", "gamma", this, "gammeEvent", 1, 20, 350, true); - mVSyncList = new SetupItemNames(); mVSyncList->push_back(_("default")); mVSyncList->push_back(_("off")); mVSyncList->push_back(_("on")); diff --git a/src/gui/shopwindow.cpp b/src/gui/shopwindow.cpp index 9ebe7a2a5..95ee92f9f 100644 --- a/src/gui/shopwindow.cpp +++ b/src/gui/shopwindow.cpp @@ -73,6 +73,29 @@ ShopWindow::DialogList ShopWindow::instances; ShopWindow::ShopWindow(): Window(_("Personal Shop"), false, nullptr, "shop.xml"), + ActionListener(), + SelectionListener(), + mCloseButton(new Button(_("Close"), "close", this)), + mBuyShopItems(new ShopItems), + mSellShopItems(new ShopItems), + mBuyShopItemList(new ShopListBox(mBuyShopItems, mBuyShopItems)), + mSellShopItemList(new ShopListBox(mSellShopItems, mSellShopItems)), + mBuyScrollArea(new ScrollArea(mBuyShopItemList, + getOptionBool("showbuybackground"), "shop_buy_background.xml")), + mSellScrollArea(new ScrollArea(mSellShopItemList, + getOptionBool("showsellbackground"), "shop_sell_background.xml")), + mBuyLabel(new Label(_("Buy items"))), + mSellLabel(new Label(_("Sell items"))), + mBuyAddButton(new Button(_("Add"), "add buy", this)), + mBuyDeleteButton(new Button(_("Delete"), "delete buy", this)), + mBuyAnnounceButton(new Button(_("Announce"), "announce buy", this)), + mBuyAuctionButton(nullptr), + mSellAddButton(new Button(_("Add"), "add sell", this)), + mSellDeleteButton(new Button(_("Delete"), "delete sell", this)), + mSellAnnounceButton(new Button(_("Announce"), "announce sell", this)), + mSellAuctionButton(nullptr), + mAnnounceLinks(new CheckBox(_("Show links in announce"), false, + this, "link announce")), mSelectedItem(-1), mAnnonceTime(0), mLastRequestTimeList(0), @@ -91,43 +114,24 @@ ShopWindow::ShopWindow(): setMinHeight(230); setDefaultSize(380, 300, ImageRect::CENTER); - mBuyShopItems = new ShopItems; - mSellShopItems = new ShopItems; mAnnounceCounter[BUY] = 0; mAnnounceCounter[SELL] = 0; loadList(); - mBuyShopItemList = new ShopListBox(mBuyShopItems, mBuyShopItems); - mSellShopItemList = new ShopListBox(mSellShopItems, mSellShopItems); mBuyShopItemList->setPriceCheck(false); mSellShopItemList->setPriceCheck(false); - mBuyScrollArea = new ScrollArea(mBuyShopItemList, - getOptionBool("showbuybackground"), "shop_buy_background.xml"); mBuyScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); - mSellScrollArea = new ScrollArea(mSellShopItemList, - getOptionBool("showsellbackground"), "shop_sell_background.xml"); mSellScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); - mCloseButton = new Button(_("Close"), "close", this); mBuyShopItemList->addSelectionListener(this); mSellShopItemList->addSelectionListener(this); - mBuyLabel = new Label(_("Buy items")); - mSellLabel = new Label(_("Sell items")); - - mBuyAddButton = new Button(_("Add"), "add buy", this); - mBuyDeleteButton = new Button(_("Delete"), "delete buy", this); - mBuyAnnounceButton = new Button(_("Announce"), "announce buy", this); - mSellAddButton = new Button(_("Add"), "add sell", this); - mSellDeleteButton = new Button(_("Delete"), "delete sell", this); - mSellAnnounceButton = new Button(_("Announce"), "announce sell", this); - mAnnounceLinks = new CheckBox(_("Show links in announce"), false, - this, "link announce"); + ContainerPlacer placer; placer = getPlacer(0, 0); diff --git a/src/gui/shopwindow.h b/src/gui/shopwindow.h index 874353873..fe830c52d 100644 --- a/src/gui/shopwindow.h +++ b/src/gui/shopwindow.h @@ -49,7 +49,7 @@ namespace gcn * \ingroup Interface */ class ShopWindow : public Window, public gcn::ActionListener, - public gcn::SelectionListener + public gcn::SelectionListener { public: @@ -145,6 +145,10 @@ class ShopWindow : public Window, public gcn::ActionListener, static DialogList instances; gcn::Button *mCloseButton; + + ShopItems *mBuyShopItems; + ShopItems *mSellShopItems; + ShopListBox *mBuyShopItemList; ShopListBox *mSellShopItemList; gcn::ScrollArea *mBuyScrollArea; @@ -161,9 +165,6 @@ class ShopWindow : public Window, public gcn::ActionListener, gcn::Button *mSellAuctionButton; gcn::CheckBox *mAnnounceLinks; - ShopItems *mBuyShopItems; - ShopItems *mSellShopItems; - int mSelectedItem; int mAnnonceTime; int mLastRequestTimeList; diff --git a/src/gui/shortcutwindow.cpp b/src/gui/shortcutwindow.cpp index 3a142cbc2..52ac58757 100644 --- a/src/gui/shortcutwindow.cpp +++ b/src/gui/shortcutwindow.cpp @@ -41,10 +41,11 @@ int ShortcutWindow::mBoxesWidth = 0; class ShortcutTab : public Tab { public: - ShortcutTab(std::string name, ShortcutContainer *const content) + ShortcutTab(std::string name, ShortcutContainer *const content) : + Tab(), + mContent(content) { setCaption(name); - mContent = content; } ShortcutContainer* mContent; @@ -54,7 +55,10 @@ ShortcutWindow::ShortcutWindow(const std::string &title, ShortcutContainer *const content, std::string skinFile, int width, int height) : - Window("Window", false, nullptr, skinFile) + Window("Window", false, nullptr, skinFile), + mItems(content), + mScrollArea(new ScrollArea(mItems, false)), + mTabs(nullptr) { setWindowName(title); setTitleBarHeight(getPadding() + getTitlePadding()); @@ -69,9 +73,6 @@ ShortcutWindow::ShortcutWindow(const std::string &title, setupWindow->registerWindowForReset(this); - mTabs = nullptr; - mItems = content; - const int border = SCROLL_PADDING * 2 + getPadding() * 2; setMinWidth(mItems->getBoxWidth() + border); setMinHeight(mItems->getBoxHeight() + border); @@ -87,7 +88,6 @@ ShortcutWindow::ShortcutWindow(const std::string &title, mBoxesWidth += mItems->getBoxWidth() + border; - mScrollArea = new ScrollArea(mItems, false); mScrollArea->setPosition(SCROLL_PADDING, SCROLL_PADDING); mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); @@ -102,7 +102,10 @@ ShortcutWindow::ShortcutWindow(const std::string &title, ShortcutWindow::ShortcutWindow(const std::string &title, std::string skinFile, const int width, const int height) : - Window("Window", false, nullptr, skinFile) + Window("Window", false, nullptr, skinFile), + mItems(nullptr), + mScrollArea(nullptr), + mTabs(new TabbedArea) { setWindowName(title); setTitleBarHeight(getPadding() + getTitlePadding()); @@ -116,10 +119,6 @@ ShortcutWindow::ShortcutWindow(const std::string &title, std::string skinFile, setupWindow->registerWindowForReset(this); - mTabs = new TabbedArea; - - mItems = nullptr; - const int border = SCROLL_PADDING * 2 + getPadding() * 2; if (width && height) diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp index 5bd18f540..d25b44941 100644 --- a/src/gui/skilldialog.cpp +++ b/src/gui/skilldialog.cpp @@ -62,165 +62,171 @@ class SkillEntry; class SkillModel : public gcn::ListModel { -public: - int getNumberOfElements() - { return static_cast<int>(mVisibleSkills.size()); } + public: + int getNumberOfElements() + { return static_cast<int>(mVisibleSkills.size()); } - SkillInfo *getSkillAt(const int i) const - { return mVisibleSkills.at(i); } + SkillInfo *getSkillAt(const int i) const + { return mVisibleSkills.at(i); } - std::string getElementAt(int i) - { - if (getSkillAt(i)) - return getSkillAt(i)->name; - else - return ""; - } + std::string getElementAt(int i) + { + if (getSkillAt(i)) + return getSkillAt(i)->name; + else + return ""; + } - void updateVisibilities(); + void updateVisibilities(); - void addSkill(SkillInfo *const info) - { mSkills.push_back(info); } + void addSkill(SkillInfo *const info) + { mSkills.push_back(info); } -private: - SkillList mSkills; - SkillList mVisibleSkills; + private: + SkillList mSkills; + SkillList mVisibleSkills; }; class SkillListBox : public ListBox { -public: - SkillListBox(SkillModel *const model): - ListBox(model), - mModel(model), - mPopup(new TextPopup()), - mHighlightColor(Theme::getThemeColor(Theme::HIGHLIGHT)), - mTextColor(Theme::getThemeColor(Theme::TEXT)) - { - } + public: + SkillListBox(SkillModel *const model): + ListBox(model), + mModel(model), + mPopup(new TextPopup()), + mHighlightColor(Theme::getThemeColor(Theme::HIGHLIGHT)), + mTextColor(Theme::getThemeColor(Theme::TEXT)) + { + } - ~SkillListBox() - { - delete mModel; - mModel = nullptr; - delete mPopup; - mPopup = nullptr; - } + ~SkillListBox() + { + delete mModel; + mModel = nullptr; + delete mPopup; + mPopup = nullptr; + } - SkillInfo *getSelectedInfo() const - { - const int selected = getSelected(); - if (!mListModel || selected < 0 - || selected > mListModel->getNumberOfElements()) + SkillInfo *getSelectedInfo() const { - return nullptr; + const int selected = getSelected(); + if (!mListModel || selected < 0 + || selected > mListModel->getNumberOfElements()) + { + return nullptr; + } + + return static_cast<SkillModel*>(mListModel)->getSkillAt(selected); } - return static_cast<SkillModel*>(mListModel)->getSkillAt(selected); - } + void draw(gcn::Graphics *gcnGraphics) + { + if (!mListModel) + return; - void draw(gcn::Graphics *gcnGraphics) - { - if (!mListModel) - return; + SkillModel *const model = static_cast<SkillModel*>(mListModel); + updateAlpha(); + Graphics *const graphics = static_cast<Graphics *const>( + gcnGraphics); - SkillModel *const model = static_cast<SkillModel*>(mListModel); + mHighlightColor.a = static_cast<int>(mAlpha * 255.0f); + graphics->setColor(mHighlightColor); + graphics->setFont(getFont()); - updateAlpha(); + // Draw filled rectangle around the selected list element + if (mSelected >= 0) + { + graphics->fillRectangle(gcn::Rectangle(0, getRowHeight() + * mSelected, getWidth(), getRowHeight())); + } - Graphics *const graphics = static_cast<Graphics *const>(gcnGraphics); + // Draw the list elements + graphics->setColor(mTextColor); + for (int i = 0, y = 1; + i < model->getNumberOfElements(); + ++i, y += getRowHeight()) + { + SkillInfo *const e = model->getSkillAt(i); + if (e) + e->draw(graphics, y, getWidth()); + } + } - mHighlightColor.a = static_cast<int>(mAlpha * 255.0f); - graphics->setColor(mHighlightColor); - graphics->setFont(getFont()); + unsigned int getRowHeight() const + { return 34; } - // Draw filled rectangle around the selected list element - if (mSelected >= 0) + void mouseMoved(gcn::MouseEvent &event) { - graphics->fillRectangle(gcn::Rectangle(0, getRowHeight() - * mSelected, getWidth(), getRowHeight())); + ListBox::mouseMoved(event); + if (!viewport) + return; + + const int y = event.getY() / getRowHeight(); + if (!mModel || y >= mModel->getNumberOfElements()) + return; + const SkillInfo *const skill = mModel->getSkillAt(y); + if (!skill) + return; + + mPopup->show(viewport->getMouseX(), viewport->getMouseY(), + skill->dispName); } - // Draw the list elements - graphics->setColor(mTextColor); - for (int i = 0, y = 1; - i < model->getNumberOfElements(); - ++i, y += getRowHeight()) + void mouseExited(gcn::MouseEvent &event A_UNUSED) { - SkillInfo *const e = model->getSkillAt(i); - - if (e) - e->draw(graphics, y, getWidth()); + mPopup->hide(); } - } - - unsigned int getRowHeight() const - { return 34; } - void mouseMoved(gcn::MouseEvent &event) - { - ListBox::mouseMoved(event); - if (!viewport) - return; - - const int y = event.getY() / getRowHeight(); - if (!mModel || y >= mModel->getNumberOfElements()) - return; - const SkillInfo *const skill = mModel->getSkillAt(y); - if (!skill) - return; - - mPopup->show(viewport->getMouseX(), viewport->getMouseY(), - skill->dispName); - } - - void mouseExited(gcn::MouseEvent &event A_UNUSED) - { - mPopup->hide(); - } - -private: - SkillModel *mModel; - TextPopup *mPopup; - gcn::Color mHighlightColor; - gcn::Color mTextColor; + private: + SkillModel *mModel; + TextPopup *mPopup; + gcn::Color mHighlightColor; + gcn::Color mTextColor; }; class SkillTab : public Tab { -public: - SkillTab(const std::string &name, SkillListBox *const listBox) : + public: + SkillTab(const std::string &name, SkillListBox *const listBox) : + Tab(), mListBox(listBox) - { - setCaption(name); - } + { + setCaption(name); + } - ~SkillTab() - { - delete mListBox; - mListBox = nullptr; - } + ~SkillTab() + { + delete mListBox; + mListBox = nullptr; + } - SkillInfo *getSelectedInfo() const - { - if (mListBox) - return mListBox->getSelectedInfo(); - else - return nullptr; - } + SkillInfo *getSelectedInfo() const + { + if (mListBox) + return mListBox->getSelectedInfo(); + else + return nullptr; + } - void setCurrent() - { - if (skillDialog) - skillDialog->updateTabSelection(); - } + protected: + void setCurrent() + { + if (skillDialog) + skillDialog->updateTabSelection(); + } -private: - SkillListBox *mListBox; + private: + SkillListBox *mListBox; }; -SkillDialog::SkillDialog(): - Window(_("Skills"), false, nullptr, "skills.xml") +SkillDialog::SkillDialog() : + Window(_("Skills"), false, nullptr, "skills.xml"), + ActionListener(), + mTabs(new TabbedArea()), + mPointsLabel(new Label("0")), + mUseButton(new Button(_("Use"), "use", this)), + mIncreaseButton(new Button(_("Up"), "inc", this)), + mDefaultModel(nullptr) { setWindowName("Skills"); setCloseButton(true); @@ -230,12 +236,7 @@ SkillDialog::SkillDialog(): setDefaultSize(windowContainer->getWidth() - 280, 30, 275, 425); setupWindow->registerWindowForReset(this); - mTabs = new TabbedArea(); - mPointsLabel = new Label("0"); - mUseButton = new Button(_("Use"), "use", this); mUseButton->setEnabled(false); - mIncreaseButton = new Button(_("Up"), "inc", this); - mDefaultModel = nullptr; place(0, 0, mTabs, 5, 5); place(0, 5, mPointsLabel, 4); diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp index 403e2c78c..ccbbf2059 100644 --- a/src/gui/socialwindow.cpp +++ b/src/gui/socialwindow.cpp @@ -132,8 +132,10 @@ protected: class SocialGuildTab : public SocialTab, public gcn::ActionListener { public: - SocialGuildTab(Guild *const guild, const bool showBackground): - mGuild(guild) + SocialGuildTab(Guild *const guild, const bool showBackground) : + ActionListener(), + SocialTab(), + mGuild(guild) { setCaption(_("Guild")); @@ -202,7 +204,6 @@ public: { } -protected: void invite() { // TODO - Give feedback on whether the invite succeeded @@ -231,8 +232,10 @@ private: class SocialGuildTab2 : public SocialTab, public gcn::ActionListener { public: - SocialGuildTab2(Guild *const guild, const bool showBackground): - mGuild(guild) + SocialGuildTab2(Guild *const guild, const bool showBackground) : + SocialTab(), + ActionListener(), + mGuild(guild) { setCaption(_("Guild")); @@ -270,7 +273,6 @@ public: { } -protected: void invite() { } @@ -286,8 +288,10 @@ private: class SocialPartyTab : public SocialTab, public gcn::ActionListener { public: - SocialPartyTab(Party *const party, const bool showBackground): - mParty(party) + SocialPartyTab(Party *const party, const bool showBackground) : + SocialTab(), + ActionListener(), + mParty(party) { setCaption(_("Party")); @@ -355,7 +359,6 @@ public: { } -protected: void invite() { // TODO - Give feedback on whether the invite succeeded @@ -384,7 +387,8 @@ private: class BeingsListModal : public AvatarListModel { public: - BeingsListModal() + BeingsListModal() : + AvatarListModel() { } @@ -416,6 +420,7 @@ class SocialPlayersTab : public SocialTab { public: SocialPlayersTab(std::string name, const bool showBackground) : + SocialTab(), mBeings(new BeingsListModal()) { mList = new AvatarListBox(mBeings); @@ -564,7 +569,6 @@ public: } } -protected: void invite() { } @@ -582,6 +586,7 @@ class SocialNavigationTab : public SocialTab { public: SocialNavigationTab(const bool showBackground) : + SocialTab(), mBeings(new BeingsListModal()) { mList = new AvatarListBox(mBeings); @@ -917,6 +922,7 @@ class SocialAttackTab : public SocialTab { public: SocialAttackTab(const bool showBackground) : + SocialTab(), mBeings(new BeingsListModal()) { mList = new AvatarListBox(mBeings); @@ -972,6 +978,7 @@ class SocialPickupTab : public SocialTab { public: SocialPickupTab(const bool showBackground) : + SocialTab(), mBeings(new BeingsListModal()) { mList = new AvatarListBox(mBeings); @@ -1027,6 +1034,7 @@ class SocialFriendsTab : public SocialTab { public: SocialFriendsTab(std::string name, const bool showBackground) : + SocialTab(), mBeings(new BeingsListModal()) { mList = new AvatarListBox(mBeings); @@ -1103,7 +1111,6 @@ public: delete players; } -protected: void invite() { } @@ -1120,10 +1127,11 @@ private: class CreatePopup : public Popup, public LinkHandler { public: - CreatePopup(): - Popup("SocialCreatePopup") + CreatePopup() : + Popup("SocialCreatePopup"), + LinkHandler(), + mBrowserBox(new BrowserBox) { - mBrowserBox = new BrowserBox; mBrowserBox->setPosition(4, 4); mBrowserBox->setHighlightMode(BrowserBox::BACKGROUND); mBrowserBox->setOpaque(false); @@ -1176,7 +1184,23 @@ SocialWindow::SocialWindow() : Window(_("Social"), false, nullptr, "social.xml"), mGuildInvited(0), mGuildAcceptDialog(nullptr), + mGuildCreateDialog(nullptr), mPartyAcceptDialog(nullptr), + mPartyCreateDialog(nullptr), + mAttackFilter(nullptr), + mPickupFilter(nullptr), + // TRANSLATORS: here P is title for visible players tab in social window + mPlayers(new SocialPlayersTab(_("P"), + getOptionBool("showtabbackground"))), + mNavigation(new SocialNavigationTab(getOptionBool("showtabbackground"))), + // TRANSLATORS: here F is title for friends tab in social window + mFriends(new SocialFriendsTab(_("F"), + getOptionBool("showtabbackground"))), + mCreatePopup(new CreatePopup), + mCreateButton(new Button(_("Create"), "create", this)), + mInviteButton(new Button(_("Invite"), "invite", this)), + mLeaveButton(new Button(_("Leave"), "leave", this)), + mTabs(new TabbedArea), mMap(nullptr), mLastUpdateTime(0), mNeedUpdate(false), @@ -1195,10 +1219,6 @@ SocialWindow::SocialWindow() : setDefaultSize(590, 200, 180, 300); setupWindow->registerWindowForReset(this); - mCreateButton = new Button(_("Create"), "create", this); - mInviteButton = new Button(_("Invite"), "invite", this); - mLeaveButton = new Button(_("Leave"), "leave", this); - mTabs = new TabbedArea; place(0, 0, mCreateButton); place(1, 0, mInviteButton); @@ -1207,21 +1227,13 @@ SocialWindow::SocialWindow() : widgetResized(nullptr); - mCreatePopup = new CreatePopup(); loadWindowState(); - // TRANSLATORS: here P is title for visible players tab in social window - mPlayers = new SocialPlayersTab(_("P"), - getOptionBool("showtabbackground")); mTabs->addTab(mPlayers, mPlayers->mScroll); - // TRANSLATORS: here F is title for friends tab in social window - mFriends = new SocialFriendsTab(_("F"), - getOptionBool("showtabbackground")); mTabs->addTab(mFriends, mFriends->mScroll); - mNavigation = new SocialNavigationTab(getOptionBool("showtabbackground")); mTabs->addTab(mNavigation, mNavigation->mScroll); if (config.getBoolValue("enableAttackFilter")) diff --git a/src/gui/speechbubble.cpp b/src/gui/speechbubble.cpp index 31877f310..fc820793c 100644 --- a/src/gui/speechbubble.cpp +++ b/src/gui/speechbubble.cpp @@ -33,17 +33,16 @@ #include "debug.h" -SpeechBubble::SpeechBubble(): - Popup("Speech", "speechbubble.xml") +SpeechBubble::SpeechBubble() : + Popup("Speech", "speechbubble.xml"), + mCaption(new Label), + mSpeechBox(new TextBox) { setContentSize(140, 46); setMinWidth(29); setMinHeight(29); - mCaption = new Label; mCaption->setFont(boldFont); - - mSpeechBox = new TextBox; mSpeechBox->setEditable(false); mSpeechBox->setOpaque(false); mSpeechBox->setTextColor(&Theme::getThemeColor(Theme::BUBBLE_TEXT)); diff --git a/src/gui/statuspopup.cpp b/src/gui/statuspopup.cpp index a593f2fe3..0bba7a505 100644 --- a/src/gui/statuspopup.cpp +++ b/src/gui/statuspopup.cpp @@ -42,61 +42,46 @@ #include "debug.h" -StatusPopup::StatusPopup(): - Popup("StatusPopup", "statuspopup.xml") +StatusPopup::StatusPopup() : + Popup("StatusPopup", "statuspopup.xml"), + mMoveType(new Label), + mCrazyMoveType(new Label), + mMoveToTargetType(new Label), + mFollowMode(new Label), + mAttackType(new Label), + mAttackWeaponType(new Label), + mDropCounter(new Label), + mPickUpType(new Label), + mMapType(new Label), + mMagicAttackType(new Label), + mPvpAttackType(new Label), + mDisableGameModifiers(new Label), + mImitationMode(new Label), + mAwayMode(new Label), + mCameraMode(new Label) { - const int fontHeight = getFont()->getHeight(); - mMoveType = new Label; mMoveType->setPosition(getPadding(), getPadding()); - - mCrazyMoveType = new Label; mCrazyMoveType->setPosition(getPadding(), fontHeight + getPadding()); - - mMoveToTargetType = new Label; mMoveToTargetType->setPosition(getPadding(), 2 * fontHeight + getPadding()); - - mFollowMode = new Label; mFollowMode->setPosition(getPadding(), 3 * fontHeight + getPadding()); - - mAttackWeaponType = new Label; mAttackWeaponType->setPosition(getPadding(), 4 + 4 * fontHeight + getPadding()); - - mAttackType = new Label; mAttackType->setPosition(getPadding(), 4 + 5 * fontHeight + getPadding()); - - mMagicAttackType = new Label; mMagicAttackType->setPosition(getPadding(), 4 + 6 * fontHeight + getPadding()); - - mPvpAttackType = new Label; mPvpAttackType->setPosition(getPadding(), 4 + 7 * fontHeight + getPadding()); - - mDropCounter = new Label; mDropCounter->setPosition(getPadding(), 8 + 8 * fontHeight + getPadding()); - - mPickUpType = new Label; mPickUpType->setPosition(getPadding(), 8 + 9 * fontHeight + getPadding()); - - mMapType = new Label; mMapType->setPosition(getPadding(), 12 + 10 * fontHeight + getPadding()); - - mImitationMode = new Label; mImitationMode->setPosition(getPadding(), 16 + 11 * fontHeight + getPadding()); - - mAwayMode = new Label; mAwayMode->setPosition(getPadding(), 16 + 12 * fontHeight + getPadding()); - - mCameraMode = new Label; mCameraMode->setPosition(getPadding(), 16 + 13 * fontHeight + getPadding()); - - mDisableGameModifiers = new Label; mDisableGameModifiers->setPosition(getPadding(), 20 + 14 * fontHeight + getPadding()); diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp index a4c47553c..cf88bf7ff 100644 --- a/src/gui/statuswindow.cpp +++ b/src/gui/statuswindow.cpp @@ -118,9 +118,28 @@ class ChangeDisplay : public AttrDisplay, gcn::ActionListener Button *mInc; }; -StatusWindow::StatusWindow(): +StatusWindow::StatusWindow() : Window(player_node ? player_node->getName() : - "?", false, nullptr, "status.xml") + "?", false, nullptr, "status.xml"), + ActionListener(), + mLvlLabel(new Label(strprintf(_("Level: %d"), 0))), + mMoneyLabel(new Label(strprintf(_("Money: %s"), ""))), + mHpLabel(new Label(_("HP:"))), + mMpLabel(nullptr), + mXpLabel(new Label(_("Exp:"))), + mHpBar(nullptr), + mMpBar(nullptr), + mXpBar(nullptr), + mJobLvlLabel(nullptr), + mJobLabel(nullptr), + mJobBar(nullptr), + mAttrCont(new VertContainer(32)), + mAttrScroll(new ScrollArea(mAttrCont, false)), + mDAttrCont(new VertContainer(32)), + mDAttrScroll(new ScrollArea(mDAttrCont, false)), + mCharacterPointsLabel(new Label("C")), + mCorrectionPointsLabel(nullptr), + mCopyButton(new Button(_("Copy to chat"), "copy", this)) { listen(CHANNEL_ATTRIBUTES); @@ -139,32 +158,22 @@ StatusWindow::StatusWindow(): player_node->getRaceName().c_str())); } - // ---------------------- - // Status Part - // ---------------------- - - mLvlLabel = new Label(strprintf(_("Level: %d"), 0)); - mMoneyLabel = new Label(strprintf(_("Money: %s"), "")); - int max = PlayerInfo::getAttribute(PlayerInfo::MAX_HP); if (!max) max = 1; - mHpLabel = new Label(_("HP:")); mHpBar = new ProgressBar(max ? static_cast<float>(PlayerInfo::getAttribute(PlayerInfo::HP)) / static_cast<float>(max): static_cast<float>(0), 80, 15, Theme::PROG_HP); max = PlayerInfo::getAttribute(PlayerInfo::EXP_NEEDED); - mXpLabel = new Label(_("Exp:")); mXpBar = new ProgressBar(max ? static_cast<float>(PlayerInfo::getAttribute(PlayerInfo::EXP)) / static_cast<float>(max): static_cast<float>(0), 80, 15, Theme::PROG_EXP); const bool magicBar = Net::getGameHandler()->canUseMagicBar(); - const int job = Net::getPlayerHandler()->getJobLocation() && serverConfig.getValueBool("showJob", false); @@ -222,24 +231,18 @@ StatusWindow::StatusWindow(): // Stats Part // ---------------------- - mAttrCont = new VertContainer(32); - mAttrScroll = new ScrollArea(mAttrCont, false); mAttrScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); mAttrScroll->setVerticalScrollPolicy(ScrollArea::SHOW_AUTO); place(0, 3, mAttrScroll, 5, 3); - mDAttrCont = new VertContainer(32); - mDAttrScroll = new ScrollArea(mDAttrCont, false); mDAttrScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); mDAttrScroll->setVerticalScrollPolicy(ScrollArea::SHOW_AUTO); place(6, 3, mDAttrScroll, 5, 3); getLayout().setRowHeight(3, Layout::AUTO_SET); - mCharacterPointsLabel = new Label("C"); place(0, 6, mCharacterPointsLabel, 5); - mCopyButton = new Button(_("Copy to chat"), "copy", this); place(0, 5, mCopyButton); @@ -738,18 +741,18 @@ void StatusWindow::action(const gcn::ActionEvent &event) } } -AttrDisplay::AttrDisplay(const int id, const std::string &name): - mId(id), - mName(name) +AttrDisplay::AttrDisplay(const int id, const std::string &name) : + Container(), + mId(id), + mName(name), + mLayout(new LayoutHelper(this)), + mLabel(new Label(name)), + mValue(new Label("1 ")) { setSize(100, 32); - mLabel = new Label(name); - mValue = new Label("1 "); mLabel->setAlignment(Graphics::CENTER); mValue->setAlignment(Graphics::CENTER); - - mLayout = new LayoutHelper(this); } AttrDisplay::~AttrDisplay() @@ -771,11 +774,10 @@ std::string AttrDisplay::update() return mName; } -DerDisplay::DerDisplay(const int id, const std::string &name): - AttrDisplay(id, name) +DerDisplay::DerDisplay(const int id, const std::string &name) : + AttrDisplay(id, name) { - // Do the layout - LayoutHelper h(this); +// LayoutHelper h(this); ContainerPlacer place = mLayout->getPlacer(0, 0); place(0, 0, mLabel, 3); @@ -784,12 +786,14 @@ DerDisplay::DerDisplay(const int id, const std::string &name): update(); } -ChangeDisplay::ChangeDisplay(const int id, const std::string &name): - AttrDisplay(id, name), mNeeded(1) +ChangeDisplay::ChangeDisplay(const int id, const std::string &name) : + AttrDisplay(id, name), + ActionListener(), + mNeeded(1), + mPoints(new Label(_("Max"))), + mDec(nullptr), + mInc(new Button(_("+"), "inc", this)) { - mPoints = new Label(_("Max")); - mInc = new Button(_("+"), "inc", this); - // Do the layout ContainerPlacer place = mLayout->getPlacer(0, 0); @@ -805,10 +809,6 @@ ChangeDisplay::ChangeDisplay(const int id, const std::string &name): place(3, 0, mDec); } - else - { - mDec = nullptr; - } update(); } diff --git a/src/gui/statuswindow.h b/src/gui/statuswindow.h index 4002ee741..94ce9b42c 100644 --- a/src/gui/statuswindow.h +++ b/src/gui/statuswindow.h @@ -95,11 +95,17 @@ class StatusWindow : public Window, /** * Status Part */ - gcn::Label *mLvlLabel, *mMoneyLabel; - gcn::Label *mHpLabel, *mMpLabel, *mXpLabel; - ProgressBar *mHpBar, *mMpBar, *mXpBar; - - gcn::Label *mJobLvlLabel, *mJobLabel; + gcn::Label *mLvlLabel; + gcn::Label *mMoneyLabel; + gcn::Label *mHpLabel; + gcn::Label *mMpLabel; + gcn::Label *mXpLabel; + ProgressBar *mHpBar; + ProgressBar *mMpBar; + ProgressBar *mXpBar; + + gcn::Label *mJobLvlLabel; + gcn::Label *mJobLabel; ProgressBar *mJobBar; VertContainer *mAttrCont; diff --git a/src/gui/textcommandeditor.cpp b/src/gui/textcommandeditor.cpp index b071c78d4..d58a5094e 100644 --- a/src/gui/textcommandeditor.cpp +++ b/src/gui/textcommandeditor.cpp @@ -163,6 +163,7 @@ public: TextCommandEditor::TextCommandEditor(TextCommand *const command) : Window(_("Command Editor"), false, nullptr, "commandeditor.xml"), + ActionListener(), mIsMagicCommand(command->getCommandType() == TEXT_COMMAND_MAGIC), mCommand(command), mIsMagic(new RadioButton(_("magic"), "magic", mIsMagicCommand)), diff --git a/src/gui/textdialog.cpp b/src/gui/textdialog.cpp index 3e49eea97..96b653d76 100644 --- a/src/gui/textdialog.cpp +++ b/src/gui/textdialog.cpp @@ -39,14 +39,15 @@ int TextDialog::instances = 0; TextDialog::TextDialog(const std::string &title, const std::string &msg, Window *const parent, const bool isPassword): Window(title, true, parent, "textdialog.xml"), + ActionListener(), mTextField(nullptr), - mPasswordField(nullptr) + mPasswordField(nullptr), + mOkButton(new Button(_("OK"), "OK", this)), + mEnabledKeyboard(keyboard.isEnabled()) { - mEnabledKeyboard = keyboard.isEnabled(); keyboard.setEnabled(false); gcn::Label *const textLabel = new Label(msg); - mOkButton = new Button(_("OK"), "OK", this); gcn::Button *const cancelButton = new Button(_("Cancel"), "CANCEL", this); place(0, 0, textLabel, 4); diff --git a/src/gui/textpopup.cpp b/src/gui/textpopup.cpp index c65c34804..219b25633 100644 --- a/src/gui/textpopup.cpp +++ b/src/gui/textpopup.cpp @@ -38,17 +38,15 @@ #include "debug.h" TextPopup::TextPopup(): - Popup("TextPopup", "textpopup.xml") + Popup("TextPopup", "textpopup.xml"), + mText1(new Label), + mText2(new Label), + mText3(new Label) { const int fontHeight = getFont()->getHeight(); - mText1 = new Label; mText1->setPosition(getPadding(), getPadding()); - - mText2 = new Label; mText2->setPosition(getPadding(), fontHeight + 2 * getPadding()); - - mText3 = new Label; mText3->setPosition(getPadding(), (2 * fontHeight) + 2 * getPadding()); add(mText1); diff --git a/src/gui/unregisterdialog.cpp b/src/gui/unregisterdialog.cpp index 6464ce7e7..59441f9e1 100644 --- a/src/gui/unregisterdialog.cpp +++ b/src/gui/unregisterdialog.cpp @@ -46,15 +46,16 @@ UnRegisterDialog::UnRegisterDialog(LoginData *const data): Window(_("Unregister"), true, nullptr, "unregister.xml"), + ActionListener(), + mPasswordField(new PasswordField(mLoginData->password)), + mUnRegisterButton(new Button(_("Unregister"), "unregister", this)), + mCancelButton(new Button(_("Cancel"), "cancel", this)), mWrongDataNoticeListener(new WrongDataNoticeListener), mLoginData(data) { gcn::Label *const userLabel = new Label(strprintf(_("Name: %s"), mLoginData->username.c_str())); gcn::Label *const passwordLabel = new Label(_("Password:")); - mPasswordField = new PasswordField(mLoginData->password); - mUnRegisterButton = new Button(_("Unregister"), "unregister", this); - mCancelButton = new Button(_("Cancel"), "cancel", this); const int width = 210; const int height = 80; diff --git a/src/gui/updaterwindow.cpp b/src/gui/updaterwindow.cpp index 496e651b3..83b0756c9 100644 --- a/src/gui/updaterwindow.cpp +++ b/src/gui/updaterwindow.cpp @@ -137,6 +137,8 @@ UpdaterWindow::UpdaterWindow(const std::string &updateHost, const bool applyUpdates, const int updateType): Window(_("Updating..."), false, nullptr, "update.xml"), + ActionListener(), + KeyListener(), mDownloadStatus(UPDATE_NEWS), mUpdateHost(updateHost), mUpdatesDir(updatesDir), @@ -153,7 +155,14 @@ UpdaterWindow::UpdaterWindow(const std::string &updateHost, mUpdateIndex(0), mUpdateIndexOffset(0), mLoadUpdates(applyUpdates), - mUpdateType(updateType) + mUpdateType(updateType), + mLabel(new Label(_("Connecting..."))), + mCancelButton(new Button(_("Cancel"), "cancel", this)), + mPlayButton(new Button(_("Play"), "play", this)), + mProgressBar(new ProgressBar(0.0, 310, 20)), + mBrowserBox(new BrowserBox), + mScrollArea(new ScrollArea(mBrowserBox, true, "update_background.xml")), + mUpdateServerPath(mUpdateHost) { setWindowName("UpdaterWindow"); setResizable(true); @@ -161,13 +170,6 @@ UpdaterWindow::UpdaterWindow(const std::string &updateHost, setMinWidth(320); setMinHeight(240); - mBrowserBox = new BrowserBox; - mScrollArea = new ScrollArea(mBrowserBox, true, "update_background.xml"); - mLabel = new Label(_("Connecting...")); - mProgressBar = new ProgressBar(0.0, 310, 20); - mCancelButton = new Button(_("Cancel"), "cancel", this); - mPlayButton = new Button(_("Play"), "play", this); - mProgressBar->setSmoothProgress(false); mBrowserBox->setOpaque(false); mBrowserBox->setLinkHandler(this); @@ -191,7 +193,6 @@ UpdaterWindow::UpdaterWindow(const std::string &updateHost, setVisible(true); mCancelButton->requestFocus(); - mUpdateServerPath = mUpdateHost; removeProtocol(mUpdateServerPath); // Try to download the updates list diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 34c10f891..b9abb4952 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -54,7 +54,9 @@ extern volatile int tick_time; -Viewport::Viewport(): +Viewport::Viewport() : + WindowContainer(), + MouseListener(), mMap(nullptr), mMouseX(0), mMouseY(0), @@ -64,9 +66,12 @@ Viewport::Viewport(): mCameraMode(0), mPlayerFollowMouse(false), mLocalWalkTime(-1), + mPopupMenu(new PopupMenu), mHoverBeing(nullptr), mHoverItem(nullptr), mHoverSign(nullptr), + mBeingPopup(new BeingPopup), + mTextPopup(new TextPopup), mCameraRelativeX(0), mCameraRelativeY(0) { @@ -87,10 +92,6 @@ Viewport::Viewport(): config.addListener("selfMouseHeal", this); config.addListener("enableLazyScrolling", this); - mPopupMenu = new PopupMenu; - mBeingPopup = new BeingPopup; - mTextPopup = new TextPopup; - setFocusable(true); } diff --git a/src/gui/viewport.h b/src/gui/viewport.h index ec35ef3d6..3f80cea1c 100644 --- a/src/gui/viewport.h +++ b/src/gui/viewport.h @@ -60,8 +60,9 @@ const int walkingMouseDelay = 500; * of it such as NPC messages, which are positioned using map pixel * coordinates. */ -class Viewport : public WindowContainer, public gcn::MouseListener, - public ConfigListener +class Viewport : public WindowContainer, + public gcn::MouseListener, + public ConfigListener { public: /** diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index fded0cbe7..9c281de86 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -47,6 +47,7 @@ BrowserBox::BrowserBox(const unsigned int mode, const bool opaque) : gcn::Widget(), + MouseListener(), mLinkHandler(nullptr), mMode(mode), mHighMode(UNDERLINE | BACKGROUND), diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index 3f253932b..5d0a36f32 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -65,6 +65,8 @@ static std::string const data[BUTTON_COUNT] = ImageRect Button::button[BUTTON_COUNT]; Button::Button() : + gcn::Button(), + WidgetListener(), mDescription(""), mClickCount(0), mTag(0), mVertexes(new GraphicsVertexes()), @@ -74,6 +76,8 @@ Button::Button() : mYOffset(0), mImages(nullptr), mImageSet(nullptr), + mImageWidth(0), + mImageHeight(0), mStick(false), mPressed(false) { @@ -84,6 +88,7 @@ Button::Button() : Button::Button(const std::string &caption, const std::string &actionEventId, gcn::ActionListener *const listener) : gcn::Button(caption), + WidgetListener(), mDescription(""), mClickCount(0), mTag(0), @@ -141,6 +146,7 @@ Button::Button(const std::string &imageName, const std::string &actionEventId, gcn::ActionListener *const listener) : gcn::Button(""), + WidgetListener(), mDescription(""), mClickCount(0), mTag(0), diff --git a/src/gui/widgets/container.cpp b/src/gui/widgets/container.cpp index 2a15c3044..3ac0cf0e3 100644 --- a/src/gui/widgets/container.cpp +++ b/src/gui/widgets/container.cpp @@ -24,7 +24,8 @@ #include "debug.h" -Container::Container() +Container::Container() : + gcn::Container() { setOpaque(false); } diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp index 01002640a..7cf6b2608 100644 --- a/src/gui/widgets/desktop.cpp +++ b/src/gui/widgets/desktop.cpp @@ -39,6 +39,8 @@ #include "debug.h" Desktop::Desktop() : + Container(), + WidgetListener(), mWallpaper(nullptr), mBackgroundColor(Theme::getThemeColor(Theme::BACKGROUND, 128)), mBackgroundGrayColor(Theme::getThemeColor(Theme::BACKGROUND_GRAY)) diff --git a/src/gui/widgets/flowcontainer.cpp b/src/gui/widgets/flowcontainer.cpp index 7302a039b..240ec41f7 100644 --- a/src/gui/widgets/flowcontainer.cpp +++ b/src/gui/widgets/flowcontainer.cpp @@ -24,8 +24,12 @@ #include "debug.h" FlowContainer::FlowContainer(const int boxWidth, const int boxHeight) : - mBoxWidth(boxWidth), mBoxHeight(boxHeight), - mGridWidth(1), mGridHeight(1) + Container(), + WidgetListener(), + mBoxWidth(boxWidth), + mBoxHeight(boxHeight), + mGridWidth(1), + mGridHeight(1) { addWidgetListener(this); if (!mBoxWidth) diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp index 4ffe8221f..dc158b95f 100644 --- a/src/gui/widgets/guitable.cpp +++ b/src/gui/widgets/guitable.cpp @@ -60,6 +60,7 @@ protected: GuiTableActionListener::GuiTableActionListener(GuiTable *table, gcn::Widget *widget, int row, int column) : + ActionListener(), mTable(table), mRow(row), mColumn(column), diff --git a/src/gui/widgets/guitable.h b/src/gui/widgets/guitable.h index f00a3cbf3..77abfdd4b 100644 --- a/src/gui/widgets/guitable.h +++ b/src/gui/widgets/guitable.h @@ -177,9 +177,6 @@ private: int mSelectedRow; int mSelectedColumn; - /** Number of frames to skip upwards when drawing the selected widget. */ - int mPopFramesNr; - /** If someone moves a fresh widget to the top, we must display it. */ gcn::Widget *mTopWidget; diff --git a/src/gui/widgets/horizontcontainer.cpp b/src/gui/widgets/horizontcontainer.cpp index 91632bf55..83a430b47 100644 --- a/src/gui/widgets/horizontcontainer.cpp +++ b/src/gui/widgets/horizontcontainer.cpp @@ -24,6 +24,8 @@ #include "debug.h" HorizontContainer::HorizontContainer(const int height, const int spacing) : + Container(), + WidgetListener(), mSpacing(spacing), mCount(0), mLastX(spacing) diff --git a/src/gui/widgets/icon.cpp b/src/gui/widgets/icon.cpp index e7404ad93..e43f85af0 100644 --- a/src/gui/widgets/icon.cpp +++ b/src/gui/widgets/icon.cpp @@ -29,15 +29,17 @@ #include "debug.h" -Icon::Icon(const std::string &file) - : mImage(ResourceManager::getInstance()->getImage(file)) +Icon::Icon(const std::string &file) : + Widget(), + mImage(ResourceManager::getInstance()->getImage(file)) { if (mImage) setSize(mImage->mBounds.w, mImage->mBounds.h); } -Icon::Icon(Image *const image) - : mImage(image) +Icon::Icon(Image *const image) : + Widget(), + mImage(image) { if (mImage) setSize(mImage->mBounds.w, mImage->mBounds.h); diff --git a/src/gui/widgets/inttextfield.cpp b/src/gui/widgets/inttextfield.cpp index bb7de3a13..d8612cc96 100644 --- a/src/gui/widgets/inttextfield.cpp +++ b/src/gui/widgets/inttextfield.cpp @@ -34,6 +34,8 @@ IntTextField::IntTextField(const int def, const int min, const int max, const bool enabled, const int width) : TextField(toString(def)), + mMin(0), + mMax(0), mDefault(def), mValue(def) { diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index d0331fb37..08c26d152 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -156,6 +156,10 @@ class SortItemTypeFunctor ItemContainer::ItemContainer(Inventory *const inventory, const bool forceQuantity) : + Widget(), + KeyListener(), + MouseListener(), + WidgetListener(), mInventory(inventory), mGridColumns(1), mGridRows(1), @@ -167,6 +171,8 @@ ItemContainer::ItemContainer(Inventory *const inventory, mForceQuantity(forceQuantity), mSwapItems(false), mDescItems(false), + mDragPosX(0), + mDragPosY(0), mTag(0), mSortType(0), mItemPopup(new ItemPopup), diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h index f39af8d7e..02309ebc9 100644 --- a/src/gui/widgets/itemcontainer.h +++ b/src/gui/widgets/itemcontainer.h @@ -194,7 +194,8 @@ class ItemContainer : public gcn::Widget, bool mForceQuantity; bool mSwapItems; bool mDescItems; - int mDragPosX, mDragPosY; + int mDragPosX; + int mDragPosY; int mTag; int mSortType; std::string mName; diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp index c0d708975..2e17b7d80 100644 --- a/src/gui/widgets/label.cpp +++ b/src/gui/widgets/label.cpp @@ -25,7 +25,8 @@ #include "debug.h" -Label::Label() +Label::Label() : + gcn::Label() { setForegroundColor(Theme::getThemeColor(Theme::LABEL)); } diff --git a/src/gui/widgets/layout.cpp b/src/gui/widgets/layout.cpp index bfb190e41..6ad1bb71b 100644 --- a/src/gui/widgets/layout.cpp +++ b/src/gui/widgets/layout.cpp @@ -364,7 +364,9 @@ void LayoutArray::reflow(const int nx, const int ny, } } -Layout::Layout(): mComputed(false) +Layout::Layout() : + LayoutCell(), + mComputed(false) { getArray(); setPadding(6); diff --git a/src/gui/widgets/layouthelper.cpp b/src/gui/widgets/layouthelper.cpp index e0dc82b8f..c3b219415 100644 --- a/src/gui/widgets/layouthelper.cpp +++ b/src/gui/widgets/layouthelper.cpp @@ -25,6 +25,7 @@ #include "debug.h" LayoutHelper::LayoutHelper(gcn::Container *const container) : + WidgetListener(), mContainer(container) { mContainer->addWidgetListener(this); diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp index 745e37e31..0b0e548b2 100644 --- a/src/gui/widgets/playerbox.cpp +++ b/src/gui/widgets/playerbox.cpp @@ -36,6 +36,7 @@ #include "debug.h" PlayerBox::PlayerBox(Being *const being, const std::string &skin) : + ScrollArea(), mBeing(being), mAlpha(1.0), mSkin(nullptr), @@ -44,7 +45,8 @@ PlayerBox::PlayerBox(Being *const being, const std::string &skin) : init(skin); } -PlayerBox::PlayerBox(std::string skin): +PlayerBox::PlayerBox(std::string skin) : + ScrollArea(), mBeing(nullptr), mAlpha(1.0), mSkin(nullptr), diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp index 8c0e938ba..fe3b63bf2 100644 --- a/src/gui/widgets/popup.cpp +++ b/src/gui/widgets/popup.cpp @@ -36,7 +36,10 @@ #include "debug.h" -Popup::Popup(const std::string &name, std::string skin): +Popup::Popup(const std::string &name, std::string skin) : + Container(), + MouseListener(), + WidgetListener(), mPopupName(name), mMinWidth(100), mMinHeight(40), diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp index 3980d0330..c85eb6220 100644 --- a/src/gui/widgets/progressbar.cpp +++ b/src/gui/widgets/progressbar.cpp @@ -45,6 +45,9 @@ ProgressBar::ProgressBar(float progress, const int width, const int height, const int color): gcn::Widget(), + WidgetListener(), + mProgress(progress), + mProgressToGo(progress), mSmoothProgress(true), mProgressPalette(color), mSmoothColorChange(true), @@ -55,14 +58,9 @@ ProgressBar::ProgressBar(float progress, if (progress > 1.0f || progress < 0.0f) progress = 1.0f; - mProgress = progress; - mProgressToGo = progress; - mColor = Theme::getProgressColor(color >= 0 ? color : 0, mProgress); mColorToGo = mColor; - addWidgetListener(this); - setSize(width, height); if (mInstances == 0) diff --git a/src/gui/widgets/progressbar.h b/src/gui/widgets/progressbar.h index 5a188c0d0..0b4927cc9 100644 --- a/src/gui/widgets/progressbar.h +++ b/src/gui/widgets/progressbar.h @@ -137,7 +137,8 @@ class ProgressBar : public gcn::Widget, public gcn::WidgetListener void widgetMoved(const gcn::Event &event); private: - float mProgress, mProgressToGo; + float mProgress; + float mProgressToGo; bool mSmoothProgress; int mProgressPalette; /** < Entry in ProgressPalette or -1 for none. */ diff --git a/src/gui/widgets/progressindicator.cpp b/src/gui/widgets/progressindicator.cpp index 27fb104c7..565d83da7 100644 --- a/src/gui/widgets/progressindicator.cpp +++ b/src/gui/widgets/progressindicator.cpp @@ -34,7 +34,8 @@ #include "debug.h" -ProgressIndicator::ProgressIndicator() +ProgressIndicator::ProgressIndicator() : + gcn::Widget() { ImageSet *const images = Theme::getImageSetFromTheme( "progress-indicator.png", 32, 32); diff --git a/src/gui/widgets/resizegrip.cpp b/src/gui/widgets/resizegrip.cpp index 53254193d..d1c9ee8a9 100644 --- a/src/gui/widgets/resizegrip.cpp +++ b/src/gui/widgets/resizegrip.cpp @@ -38,7 +38,8 @@ Image *ResizeGrip::gripImage = nullptr; int ResizeGrip::mInstances = 0; float ResizeGrip::mAlpha = 1.0; -ResizeGrip::ResizeGrip(const std::string &image) +ResizeGrip::ResizeGrip(const std::string &image) : + gcn::Widget() { if (mInstances == 0) { diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index 28532927b..c290a720a 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -49,6 +49,7 @@ static std::string const buttonFiles[2] = ScrollArea::ScrollArea(const bool opaque, const std::string &skin) : gcn::ScrollArea(), + gcn::WidgetListener(), mX(0), mY(0), mClickX(0), @@ -69,6 +70,7 @@ ScrollArea::ScrollArea(const bool opaque, const std::string &skin) : ScrollArea::ScrollArea(gcn::Widget *const widget, const bool opaque, const std::string &skin) : gcn::ScrollArea(widget), + gcn::WidgetListener(), mX(0), mY(0), mClickX(0), diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index f569fddb5..618011dee 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -50,6 +50,7 @@ SetupItem::SetupItem(std::string text, std::string description, std::string keyName, SetupTabScroll *const parent, std::string eventName, const bool mainConfig) : + ActionListener(), mText(text), mDescription(description), mKeyName(keyName), @@ -68,6 +69,7 @@ SetupItem::SetupItem(std::string text, std::string description, std::string keyName, SetupTabScroll *const parent, std::string eventName, std::string def, const bool mainConfig) : + ActionListener(), mText(text), mDescription(description), mKeyName(keyName), diff --git a/src/gui/widgets/setuptab.cpp b/src/gui/widgets/setuptab.cpp index d4ae46eb8..9f2560134 100644 --- a/src/gui/widgets/setuptab.cpp +++ b/src/gui/widgets/setuptab.cpp @@ -24,7 +24,9 @@ #include "debug.h" -SetupTab::SetupTab() +SetupTab::SetupTab() : + Container(), + gcn::ActionListener() { setOpaque(false); } diff --git a/src/gui/widgets/shortcutcontainer.cpp b/src/gui/widgets/shortcutcontainer.cpp index b54364ebd..97c4d1b7d 100644 --- a/src/gui/widgets/shortcutcontainer.cpp +++ b/src/gui/widgets/shortcutcontainer.cpp @@ -30,7 +30,10 @@ float ShortcutContainer::mAlpha = 1.0; -ShortcutContainer::ShortcutContainer(): +ShortcutContainer::ShortcutContainer() : + gcn::Widget(), + gcn::WidgetListener(), + gcn::MouseListener(), mBackgroundImg(nullptr), mMaxItems(0), mBoxWidth(1), diff --git a/src/gui/widgets/sliderlist.cpp b/src/gui/widgets/sliderlist.cpp index dd27cfbe5..ad7fde18f 100644 --- a/src/gui/widgets/sliderlist.cpp +++ b/src/gui/widgets/sliderlist.cpp @@ -42,6 +42,9 @@ static const int sliderHeight = 30; SliderList::SliderList(gcn::ListModel *const listModel, gcn::ActionListener *const listener, std::string eventId) : + Container(), + gcn::ActionListener(), + gcn::MouseListener(), mLabel(new Label), mListModel(listModel), mOldWidth(0), diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp index 2a3799ca8..7b02b3281 100644 --- a/src/gui/widgets/spellshortcutcontainer.cpp +++ b/src/gui/widgets/spellshortcutcontainer.cpp @@ -48,6 +48,7 @@ SpellShortcutContainer::SpellShortcutContainer(const unsigned number) : ShortcutContainer(), mSpellClicked(false), mSpellMoved(nullptr), + mSpellPopup(new SpellPopup), mNumber(number) { mBoxWidth = mBoxWidth; @@ -55,8 +56,6 @@ SpellShortcutContainer::SpellShortcutContainer(const unsigned number) : addMouseListener(this); addWidgetListener(this); - mSpellPopup = new SpellPopup; - mBackgroundImg = Theme::getImageFromThemeXml( "item_shortcut_background.xml", "background.xml"); if (spellShortcut) diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp index 479735e7c..0999dc7a9 100644 --- a/src/gui/widgets/tab.cpp +++ b/src/gui/widgets/tab.cpp @@ -63,6 +63,7 @@ ImageRect Tab::tabImg[TAB_COUNT]; Tab::Tab() : gcn::Tab(), + gcn::WidgetListener(), mTabColor(&Theme::getThemeColor(Theme::TAB)), mTabHighlightedColor(&Theme::getThemeColor(Theme::TAB_HIGHLIGHTED)), mTabSelectedColor(&Theme::getThemeColor(Theme::TAB_SELECTED)), diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index ae5f92fd9..06af8a83a 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -36,6 +36,7 @@ TabbedArea::TabbedArea() : gcn::TabbedArea(), + gcn::WidgetListener(), mTabsWidth(0), mVisibleTabsWidth(0), mTabScrollIndex(0), diff --git a/src/gui/widgets/tablemodel.cpp b/src/gui/widgets/tablemodel.cpp index f43622a9c..59cd58ba7 100644 --- a/src/gui/widgets/tablemodel.cpp +++ b/src/gui/widgets/tablemodel.cpp @@ -64,6 +64,7 @@ void TableModel::signalAfterUpdate() #define DYN_SIZE(h) ((h) >= 0) StaticTableModel::StaticTableModel(const int row, const int column) : + TableModel(), mRows(row), mColumns(column), mHeight(1) diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp index 5079b8bf2..541308e5e 100644 --- a/src/gui/widgets/textbox.cpp +++ b/src/gui/widgets/textbox.cpp @@ -34,11 +34,12 @@ #include "debug.h" TextBox::TextBox() : + gcn::TextBox(), + mMinWidth(getWidth()), mTextColor(&Theme::getThemeColor(Theme::TEXTBOX)) { setOpaque(false); setFrameSize(0); - mMinWidth = getWidth(); } void TextBox::setTextWrapped(const std::string &text, const int minDimension) diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp index f78d4a4b7..43b81b2ce 100644 --- a/src/gui/widgets/textpreview.cpp +++ b/src/gui/widgets/textpreview.cpp @@ -35,7 +35,8 @@ float TextPreview::mAlpha = 1.0; -TextPreview::TextPreview(const std::string &text): +TextPreview::TextPreview(const std::string &text) : + gcn::Widget(), mFont(gui->getFont()), mText(text), mTextColor(&Theme::getThemeColor(Theme::TEXT)), diff --git a/src/gui/widgets/vertcontainer.cpp b/src/gui/widgets/vertcontainer.cpp index 46ea86c0e..a6a4748f3 100644 --- a/src/gui/widgets/vertcontainer.cpp +++ b/src/gui/widgets/vertcontainer.cpp @@ -24,7 +24,9 @@ #include "debug.h" VertContainer::VertContainer(const int verticalItemSize, const bool resizable, - const int leftSpacing): + const int leftSpacing) : + Container(), + gcn::WidgetListener(), mVerticalItemSize(verticalItemSize), mCount(0), mNextY(0), diff --git a/src/gui/widgets/widgetgroup.cpp b/src/gui/widgets/widgetgroup.cpp index 104d319a0..aacabd0f1 100644 --- a/src/gui/widgets/widgetgroup.cpp +++ b/src/gui/widgets/widgetgroup.cpp @@ -26,6 +26,9 @@ WidgetGroup::WidgetGroup(const std::string &group, const int height, const int spacing) : + Container(), + gcn::WidgetListener(), + gcn::ActionListener(), mSpacing(spacing), mCount(0), mGroup(group), diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 58247870f..f2266dfd1 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -46,8 +46,10 @@ int Window::instances = 0; int Window::mouseResize = 0; Window::Window(const std::string &caption, const bool modal, - Window *const parent, std::string skin): + Window *const parent, std::string skin) : gcn::Window(caption), + gcn::WidgetListener(), + mSkin(nullptr), mGrip(nullptr), mParent(parent), mLayout(nullptr), @@ -64,12 +66,17 @@ Window::Window(const std::string &caption, const bool modal, mMinWinHeight(40), mMaxWinWidth(mainGraphics->mWidth), mMaxWinHeight(mainGraphics->mHeight), + mDefaultX(0), + mDefaultY(0), + mDefaultWidth(0), + mDefaultHeight(0), mVertexes(new GraphicsVertexes()), mCaptionOffsetX(7), mCaptionOffsetY(5), mCaptionAlign(gcn::Graphics::LEFT), mTitlePadding(4), - mRedraw(true) + mRedraw(true), + mCaptionFont(getFont()) { logger->log("Window::Window(\"%s\")", caption.c_str()); @@ -108,10 +115,6 @@ Window::Window(const std::string &caption, const bool modal, } } } - else - { - mSkin = nullptr; - } // Add this window to the window container windowContainer->add(this); @@ -126,7 +129,6 @@ Window::Window(const std::string &caption, const bool modal, setVisible(false); addWidgetListener(this); - mCaptionFont = getFont(); setForegroundColor(Theme::getThemeColor(Theme::WINDOW)); } diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index 18a53b93d..f33fe3e87 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -59,6 +59,11 @@ extern Window *socialWindow; extern Window *questsWindow; WindowMenu::WindowMenu() : + Container(), + gcn::ActionListener(), + gcn::SelectionListener(), + gcn::MouseListener(), + mTextPopup(new TextPopup), mHaveMouse(false), mAutoHide(1) { @@ -112,7 +117,6 @@ WindowMenu::WindowMenu() : } loadButtons(); - mTextPopup = new TextPopup; addMouseListener(this); setVisible(true); diff --git a/src/gui/windowmenu.h b/src/gui/windowmenu.h index 490b24d87..c0be9a1fe 100644 --- a/src/gui/windowmenu.h +++ b/src/gui/windowmenu.h @@ -79,9 +79,10 @@ class WindowMenu : public Container, void optionChanged(const std::string &name); - private: + protected: void drawChildren(gcn::Graphics* graphics); + private: inline void addButton(const char *const text, const std::string &description, int &x, int &h, const int key, diff --git a/src/gui/worldselectdialog.cpp b/src/gui/worldselectdialog.cpp index 4463442f9..d98dd97b4 100644 --- a/src/gui/worldselectdialog.cpp +++ b/src/gui/worldselectdialog.cpp @@ -76,6 +76,8 @@ class WorldListModel : public gcn::ListModel WorldSelectDialog::WorldSelectDialog(Worlds worlds): Window(_("Select World"), false, nullptr, "world.xml"), + gcn::ActionListener(), + gcn::KeyListener(), mWorldListModel(new WorldListModel(worlds)), mWorldList(new ListBox(mWorldListModel)), mChangeLoginButton(new Button(_("Change Login"), "login", this)), |