diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-01-26 16:07:54 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-01-26 16:07:54 +0100 |
commit | 5afe88df2538274859a162ffd63ed52118e80c19 (patch) | |
tree | b610dfd58dc748fd63f49565b2a43eea2316714f /src/gui | |
parent | 73ba2a95f5bd4a0dd09af52d5864800be2b0a4c6 (diff) | |
download | mana-5afe88df2538274859a162ffd63ed52118e80c19.tar.gz mana-5afe88df2538274859a162ffd63ed52118e80c19.tar.bz2 mana-5afe88df2538274859a162ffd63ed52118e80c19.tar.xz mana-5afe88df2538274859a162ffd63ed52118e80c19.zip |
Apply C++11 fixits
modernize-use-auto
modernize-use-nullptr
modernize-use-override
modernize-use-using
Diffstat (limited to 'src/gui')
172 files changed, 801 insertions, 801 deletions
diff --git a/src/gui/beingpopup.h b/src/gui/beingpopup.h index 7022ebbe..45169464 100644 --- a/src/gui/beingpopup.h +++ b/src/gui/beingpopup.h @@ -34,7 +34,7 @@ class BeingPopup : public Popup public: BeingPopup(); - ~BeingPopup(); + ~BeingPopup() override; /** * Sets the info to be displayed given a particular player. diff --git a/src/gui/buydialog.cpp b/src/gui/buydialog.cpp index e1f99f5a..56c3c261 100644 --- a/src/gui/buydialog.cpp +++ b/src/gui/buydialog.cpp @@ -295,8 +295,8 @@ void BuyDialog::setVisible(bool visible) void BuyDialog::closeAll() { - DialogList::iterator it = instances.begin(); - DialogList::iterator it_end = instances.end(); + auto it = instances.begin(); + auto it_end = instances.end(); for (; it != it_end; it++) { diff --git a/src/gui/buydialog.h b/src/gui/buydialog.h index 7dd00019..b1126225 100644 --- a/src/gui/buydialog.h +++ b/src/gui/buydialog.h @@ -44,7 +44,7 @@ class BuyDialog : public Window, public gcn::ActionListener, public: BuyDialog(int npcId); - ~BuyDialog(); + ~BuyDialog() override; /** * Resets the dialog, clearing shop inventory. @@ -64,7 +64,7 @@ class BuyDialog : public Window, public gcn::ActionListener, /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; /** * Returns the number of items in the shop inventory. @@ -74,12 +74,12 @@ class BuyDialog : public Window, public gcn::ActionListener, /** * Updates the labels according to the selected item. */ - void valueChanged(const gcn::SelectionEvent &event); + void valueChanged(const gcn::SelectionEvent &event) override; /** * Allows for quick-buying by extending double-click events. */ - void mouseClicked(gcn::MouseEvent &mouseEvent); + void mouseClicked(gcn::MouseEvent &mouseEvent) override; /** * Returns the name of item number i in the shop inventory. @@ -94,7 +94,7 @@ class BuyDialog : public Window, public gcn::ActionListener, /** * Sets the visibility of this window. */ - void setVisible(bool visible); + void setVisible(bool visible) override; /** * Closes all instances. @@ -102,7 +102,7 @@ class BuyDialog : public Window, public gcn::ActionListener, static void closeAll(); private: - typedef std::list<BuyDialog*> DialogList; + using DialogList = std::list<BuyDialog *>; static DialogList instances; int mNpcId; diff --git a/src/gui/buyselldialog.cpp b/src/gui/buyselldialog.cpp index e22607f0..be49ba58 100644 --- a/src/gui/buyselldialog.cpp +++ b/src/gui/buyselldialog.cpp @@ -37,20 +37,20 @@ BuySellDialog::DialogList BuySellDialog::instances; BuySellDialog::BuySellDialog(int npcId): Window(_("Shop")), mNpcId(npcId), - mBuyButton(0) + mBuyButton(nullptr) { setWindowName("BuySell"); //setupWindow->registerWindowForReset(this); setCloseButton(true); static const char *buttonNames[] = { - N_("Buy"), N_("Sell"), N_("Cancel"), 0 + N_("Buy"), N_("Sell"), N_("Cancel"), nullptr }; int x = 10, y = 10; for (const char **curBtn = buttonNames; *curBtn; curBtn++) { - Button *btn = new Button(gettext(*curBtn), *curBtn, this); + auto *btn = new Button(gettext(*curBtn), *curBtn, this); if (!mBuyButton) mBuyButton = btn; // For focus request btn->setPosition(x, y); @@ -109,8 +109,8 @@ void BuySellDialog::action(const gcn::ActionEvent &event) void BuySellDialog::closeAll() { - DialogList::iterator it = instances.begin(); - DialogList::iterator it_end = instances.end(); + auto it = instances.begin(); + auto it_end = instances.end(); for (; it != it_end; it++) { diff --git a/src/gui/buyselldialog.h b/src/gui/buyselldialog.h index f296126e..2e324d42 100644 --- a/src/gui/buyselldialog.h +++ b/src/gui/buyselldialog.h @@ -42,14 +42,14 @@ class BuySellDialog : public Window, public gcn::ActionListener */ BuySellDialog(int npcId); - ~BuySellDialog(); + ~BuySellDialog() override; - void setVisible(bool visible); + void setVisible(bool visible) override; /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; /** * Closes all instances. @@ -57,7 +57,7 @@ class BuySellDialog : public Window, public gcn::ActionListener static void closeAll(); private: - typedef std::list<BuySellDialog*> DialogList; + using DialogList = std::list<BuySellDialog *>; static DialogList instances; int mNpcId; diff --git a/src/gui/changeemaildialog.cpp b/src/gui/changeemaildialog.cpp index c42cecc3..ce83087b 100644 --- a/src/gui/changeemaildialog.cpp +++ b/src/gui/changeemaildialog.cpp @@ -153,7 +153,7 @@ void ChangeEmailDialog::action(const gcn::ActionEvent &event) mWrongDataNoticeListener->setTarget(this->mSecondEmailField); } - OkDialog *dlg = new OkDialog(_("Error"), errorMessage.str()); + auto *dlg = new OkDialog(_("Error"), errorMessage.str()); dlg->addActionListener(mWrongDataNoticeListener); } else diff --git a/src/gui/changeemaildialog.h b/src/gui/changeemaildialog.h index 7715db8c..37d3ce01 100644 --- a/src/gui/changeemaildialog.h +++ b/src/gui/changeemaildialog.h @@ -40,12 +40,12 @@ class ChangeEmailDialog : public Window, public gcn::ActionListener public: ChangeEmailDialog(LoginData *loginData); - ~ChangeEmailDialog(); + ~ChangeEmailDialog() override; /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; /** * This is used to pass the pointer to where the new email should be diff --git a/src/gui/changepassworddialog.cpp b/src/gui/changepassworddialog.cpp index 6b668496..437a8c90 100644 --- a/src/gui/changepassworddialog.cpp +++ b/src/gui/changepassworddialog.cpp @@ -146,7 +146,7 @@ void ChangePasswordDialog::action(const gcn::ActionEvent &event) mWrongDataNoticeListener->setTarget(this->mSecondPassField); } - OkDialog *dlg = new OkDialog(_("Error"), errorMessage.str()); + auto *dlg = new OkDialog(_("Error"), errorMessage.str()); dlg->addActionListener(mWrongDataNoticeListener); } else diff --git a/src/gui/changepassworddialog.h b/src/gui/changepassworddialog.h index 308a6970..22d449d1 100644 --- a/src/gui/changepassworddialog.h +++ b/src/gui/changepassworddialog.h @@ -40,12 +40,12 @@ class ChangePasswordDialog : public Window, public gcn::ActionListener public: ChangePasswordDialog(LoginData *loginData); - ~ChangePasswordDialog(); + ~ChangePasswordDialog() override; /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; private: gcn::TextField *mOldPassField; diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp index 26383d48..8cec4279 100644 --- a/src/gui/charcreatedialog.cpp +++ b/src/gui/charcreatedialog.cpp @@ -54,7 +54,7 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot): mCharSelectDialog(parent), mSlot(slot) { - mPlayer = new Being(0, ActorSprite::PLAYER, 0, NULL); + mPlayer = new Being(0, ActorSprite::PLAYER, 0, nullptr); mPlayer->setGender(GENDER_MALE); const std::vector<int> &items = CharDB::getDefaultItems(); @@ -160,7 +160,7 @@ CharCreateDialog::~CharCreateDialog() delete mPlayer; // Make sure the char server handler knows that we're gone - Net::getCharHandler()->setCharCreateDialog(0); + Net::getCharHandler()->setCharCreateDialog(nullptr); } void CharCreateDialog::action(const gcn::ActionEvent &event) @@ -330,18 +330,18 @@ void CharCreateDialog::setAttributes(const std::vector<std::string> &labels, { const int y = 140 + i * 20; - Label *attributeLabel = new Label(labels[i]); + auto *attributeLabel = new Label(labels[i]); attributeLabel->setWidth(70); attributeLabel->setPosition(5, y); add(attributeLabel); - Slider *attributeSlider = new Slider(min, max); + auto *attributeSlider = new Slider(min, max); attributeSlider->setDimension(gcn::Rectangle(75, y, 100, 10)); attributeSlider->setActionEventId("statslider"); attributeSlider->addActionListener(this); add(attributeSlider); - Label *attributeValue = new Label(toString(min)); + auto *attributeValue = new Label(toString(min)); attributeValue->setPosition(180, y); add(attributeValue); diff --git a/src/gui/charcreatedialog.h b/src/gui/charcreatedialog.h index 9f49f6c5..89706b54 100644 --- a/src/gui/charcreatedialog.h +++ b/src/gui/charcreatedialog.h @@ -48,9 +48,9 @@ class CharCreateDialog : public Window, public gcn::ActionListener public: CharCreateDialog(CharSelectDialog *parent, int slot); - ~CharCreateDialog(); + ~CharCreateDialog() override; - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; /** * Unlocks the dialog, enabling the create character button again. diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp index dff648ec..e4d5f371 100644 --- a/src/gui/charselectdialog.cpp +++ b/src/gui/charselectdialog.cpp @@ -74,7 +74,7 @@ class CharDeleteConfirm : public ConfirmDialog { } - void action(const gcn::ActionEvent &event) + void action(const gcn::ActionEvent &event) override { if (event.getId() == "yes") mMaster->attemptCharacterDelete(mIndex); @@ -97,7 +97,7 @@ class CharacterDisplay : public Container Net::Character *getCharacter() const { return mCharacter; } - void requestFocus(); + void requestFocus() override; void setActive(bool active); @@ -117,8 +117,8 @@ class CharacterDisplay : public Container CharSelectDialog::CharSelectDialog(LoginData *loginData): Window(_("Account and Character Management")), mLocked(false), - mUnregisterButton(0), - mChangeEmailButton(0), + mUnregisterButton(nullptr), + mChangeEmailButton(nullptr), mCharacterEntries(0), mLoginData(loginData), mCharHandler(Net::getCharHandler()) @@ -203,7 +203,7 @@ void CharSelectDialog::action(const gcn::ActionEvent &event) && !mCharacterEntries[selected]->getCharacter()) { // Start new character dialog - CharCreateDialog *charCreateDialog = + auto *charCreateDialog = new CharCreateDialog(this, selected); mCharHandler->setCharCreateDialog(charCreateDialog); } @@ -273,7 +273,7 @@ void CharSelectDialog::setCharacters(const Net::Characters &characters) std::vector<CharacterDisplay*>::iterator iter, iter_end; for (iter = mCharacterEntries.begin(), iter_end = mCharacterEntries.end(); iter != iter_end; ++iter) - (*iter)->setCharacter(0); + (*iter)->setCharacter(nullptr); Net::Characters::const_iterator i, i_end = characters.end(); for (i = characters.begin(); i != i_end; ++i) @@ -347,7 +347,7 @@ bool CharSelectDialog::selectByName(const std::string &name, CharacterDisplay::CharacterDisplay(CharSelectDialog *charSelectDialog): - mCharacter(0), + mCharacter(nullptr), mPlayerBox(new PlayerBox) { mButton = new Button("", "go", charSelectDialog); @@ -376,7 +376,7 @@ void CharacterDisplay::setCharacter(Net::Character *character) return; mCharacter = character; - mPlayerBox->setPlayer(character ? character->dummy : 0); + mPlayerBox->setPlayer(character ? character->dummy : nullptr); update(); } diff --git a/src/gui/charselectdialog.h b/src/gui/charselectdialog.h index a0307b00..d30e4e68 100644 --- a/src/gui/charselectdialog.h +++ b/src/gui/charselectdialog.h @@ -52,11 +52,11 @@ class CharSelectDialog : public Window, public gcn::ActionListener, CharSelectDialog(LoginData *loginData); - ~CharSelectDialog(); + ~CharSelectDialog() override; - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; - void keyPressed(gcn::KeyEvent &keyEvent); + void keyPressed(gcn::KeyEvent &keyEvent) override; enum SelectAction { Focus, diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index cc09d19e..1ae2fcbd 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -71,7 +71,7 @@ class ChatInput : public TextField, public gcn::FocusListener * Called if the chat input loses focus. It will set itself to * invisible as result. */ - void focusLost(const gcn::Event &event) + void focusLost(const gcn::Event &event) override { setVisible(false); } @@ -79,9 +79,9 @@ class ChatInput : public TextField, public gcn::FocusListener class ChatAutoComplete : public AutoCompleteLister { - void getAutoCompleteList(std::vector<std::string> &list) const + void getAutoCompleteList(std::vector<std::string> &list) const override { - ChatTab *tab = static_cast<ChatTab*>(chatWindow->mChatTabs + auto *tab = static_cast<ChatTab*>(chatWindow->mChatTabs ->getSelectedTab()); return tab->getAutoCompleteList(list); @@ -278,7 +278,7 @@ void ChatWindow::removeAllWhispers() tabs.push_back(iter->second); } - for (std::list<ChatTab*>::iterator it = tabs.begin(); + for (auto it = tabs.begin(); it != tabs.end(); ++it) { delete *it; @@ -299,7 +299,7 @@ void ChatWindow::doPresent() std::string response = ""; int playercount = 0; - for (ActorSpritesConstIterator it = actors.begin(), it_end = actors.end(); + for (auto it = actors.begin(), it_end = actors.end(); it != it_end; it++) { if ((*it)->getType() == ActorSprite::PLAYER) @@ -471,7 +471,7 @@ void ChatWindow::whisper(const std::string &nick, if (tempNick.compare(playerName) == 0) return; - ChatTab *tab = 0; + ChatTab *tab = nullptr; TabMap::const_iterator i = mWhispers.find(tempNick); if (i != mWhispers.end()) @@ -521,7 +521,7 @@ ChatTab *ChatWindow::addWhisperTab(const std::string &nick, bool switchTo) if (mWhispers.find(tempNick) != mWhispers.end() || tempNick.compare(playerName) == 0) - return NULL; + return nullptr; ChatTab *ret = new WhisperTab(nick); mWhispers[tempNick] = ret; diff --git a/src/gui/chatwindow.h b/src/gui/chatwindow.h index 77c42cc0..b3072d4a 100644 --- a/src/gui/chatwindow.h +++ b/src/gui/chatwindow.h @@ -85,13 +85,13 @@ class ChatWindow : public Window, /** * Destructor: used to write back values to the config file */ - ~ChatWindow(); + ~ChatWindow() override; /** * Reset the chat window and recorder window attached to it to their * default positions. */ - void resetToDefaultSize(); + void resetToDefaultSize() override; /** * Gets the focused tab. @@ -121,7 +121,7 @@ class ChatWindow : public Window, /** * Performs action. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; /** * Request focus for typing chat message. @@ -150,12 +150,12 @@ class ChatWindow : public Window, void addItemText(const std::string &item); /** Override to reset mTmpVisible */ - void setVisible(bool visible); + void setVisible(bool visible) override; - void mousePressed(gcn::MouseEvent &event); - void mouseDragged(gcn::MouseEvent &event); + void mousePressed(gcn::MouseEvent &event) override; + void mouseDragged(gcn::MouseEvent &event) override; - void event(Event::Channel channel, const Event &event); + void event(Event::Channel channel, const Event &event) override; /** * Scrolls the chat window @@ -214,7 +214,7 @@ class ChatWindow : public Window, /** Tabbed area for holding each channel. */ TabbedArea *mChatTabs; - typedef std::map<const std::string, ChatTab*> TabMap; + using TabMap = std::map<const std::string, ChatTab *>; /** Manage whisper tabs */ TabMap mWhispers; diff --git a/src/gui/confirmdialog.h b/src/gui/confirmdialog.h index af769a42..8eb3f46b 100644 --- a/src/gui/confirmdialog.h +++ b/src/gui/confirmdialog.h @@ -37,12 +37,12 @@ class ConfirmDialog : public Window, public gcn::ActionListener { public: ConfirmDialog(const std::string &title, const std::string &msg, - Window *parent = NULL); + Window *parent = nullptr); /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; private: TextBox *mTextBox; diff --git a/src/gui/connectiondialog.cpp b/src/gui/connectiondialog.cpp index 237269c8..963005cf 100644 --- a/src/gui/connectiondialog.cpp +++ b/src/gui/connectiondialog.cpp @@ -39,9 +39,9 @@ ConnectionDialog::ConnectionDialog(const std::string &text, setMovable(false); setMinWidth(0); - ProgressIndicator *progressIndicator = new ProgressIndicator; + auto *progressIndicator = new ProgressIndicator; gcn::Label *label = new Label(text); - Button *cancelButton = new Button(_("Cancel"), "cancelButton", this); + auto *cancelButton = new Button(_("Cancel"), "cancelButton", this); place(0, 0, progressIndicator); place(0, 1, label); diff --git a/src/gui/connectiondialog.h b/src/gui/connectiondialog.h index 129fe5c6..e76a0a3e 100644 --- a/src/gui/connectiondialog.h +++ b/src/gui/connectiondialog.h @@ -50,9 +50,9 @@ class ConnectionDialog : public Window, gcn::ActionListener * Called when the user presses Cancel. Restores the global state to * the previous one. */ - void action(const gcn::ActionEvent &); + void action(const gcn::ActionEvent &) override; - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; private: gcn::Label *mLabel; diff --git a/src/gui/customserverdialog.cpp b/src/gui/customserverdialog.cpp index e0d25928..733a6b5c 100644 --- a/src/gui/customserverdialog.cpp +++ b/src/gui/customserverdialog.cpp @@ -53,13 +53,13 @@ CustomServerDialog::CustomServerDialog(ServerDialog *parent, int index): { setWindowName("CustomServerDialog"); - Label *nameLabel = new Label(_("Name:")); - Label *serverAdressLabel = new Label(_("Address:")); - Label *portLabel = new Label(_("Port:")); + auto *nameLabel = new Label(_("Name:")); + auto *serverAdressLabel = new Label(_("Address:")); + auto *portLabel = new Label(_("Port:")); #ifdef MANASERV_SUPPORT - Label *typeLabel = new Label(_("Server type:")); + auto *typeLabel = new Label(_("Server type:")); #endif - Label *descriptionLabel = new Label(_("Description:")); + auto *descriptionLabel = new Label(_("Description:")); mServerAddressField = new TextField(std::string()); mPortField = new TextField(std::string()); @@ -163,7 +163,7 @@ void CustomServerDialog::action(const gcn::ActionEvent &event) // Check the given information if (mServerAddressField->getText().empty()) { - OkDialog *dlg = new OkDialog(_("Error"), + auto *dlg = new OkDialog(_("Error"), _("Please type in at least the address of the server.")); dlg->addActionListener(this); } @@ -220,6 +220,6 @@ void CustomServerDialog::keyPressed(gcn::KeyEvent &keyEvent) } else if (key.getValue() == Key::ENTER) { - action(gcn::ActionEvent(NULL, mOkButton->getActionEventId())); + action(gcn::ActionEvent(nullptr, mOkButton->getActionEventId())); } } diff --git a/src/gui/customserverdialog.h b/src/gui/customserverdialog.h index 19812875..59c1d2cc 100644 --- a/src/gui/customserverdialog.h +++ b/src/gui/customserverdialog.h @@ -48,12 +48,12 @@ class TypeListModel : public gcn::ListModel /** * Used to get number of line in the list */ - int getNumberOfElements() { return 2; } + int getNumberOfElements() override { return 2; } /** * Used to get an element from the list */ - std::string getElementAt(int elementIndex); + std::string getElementAt(int elementIndex) override; }; /** @@ -68,16 +68,16 @@ class CustomServerDialog : public Window, public: CustomServerDialog(ServerDialog *parent, int index = -1); - ~CustomServerDialog(); + ~CustomServerDialog() override; /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; - void keyPressed(gcn::KeyEvent &keyEvent); + void keyPressed(gcn::KeyEvent &keyEvent) override; - void logic(); + void logic() override; private: TextField *mServerAddressField; diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp index 37c68673..43d84f61 100644 --- a/src/gui/debugwindow.cpp +++ b/src/gui/debugwindow.cpp @@ -79,7 +79,7 @@ public: h.reflowLayout(0, 0); } - void logic() + void logic() override { if (!isVisible()) return; @@ -130,7 +130,7 @@ class DebugSwitches : public Container, public gcn::ActionListener public: DebugSwitches() { - Label *showLabel = new Label(_("Show:")); + auto *showLabel = new Label(_("Show:")); mGrid = new CheckBox(_("Grid")); mCollisionTiles = new CheckBox(_("Collision tiles")); mBeingCollisionRadius = new CheckBox(_("Being collision radius")); @@ -139,7 +139,7 @@ public: mMousePath = new CheckBox(_("Mouse path")); mBeingIds = new CheckBox(_("Being Ids")); - Label *specialsLabel = new Label(_("Specials:")); + auto *specialsLabel = new Label(_("Specials:")); mSpecialNormal = new RadioButton(_("Normal"), "mapdebug"); mSpecial1 = new RadioButton(_("Special 1"), "mapdebug"); mSpecial2 = new RadioButton(_("Special 2"), "mapdebug"); @@ -179,7 +179,7 @@ public: mSpecial3->addActionListener(this); } - void action(const gcn::ActionEvent &event) + void action(const gcn::ActionEvent &event) override { int flags = 0; @@ -233,7 +233,7 @@ DebugWindow::DebugWindow() setMinHeight(100); setDefaultSize(0, 120, 300, 190); - TabbedArea *tabs = new TabbedArea; + auto *tabs = new TabbedArea; place(0, 0, tabs, 2, 2); loadWindowState(); diff --git a/src/gui/emotepopup.h b/src/gui/emotepopup.h index 9a7b3f3e..cb1c7b89 100644 --- a/src/gui/emotepopup.h +++ b/src/gui/emotepopup.h @@ -50,15 +50,15 @@ class EmotePopup : public Popup */ EmotePopup(); - virtual ~EmotePopup(); + ~EmotePopup() override; /** * Draws the emotes. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; - void mousePressed(gcn::MouseEvent &event); - void mouseMoved(gcn::MouseEvent &event); + void mousePressed(gcn::MouseEvent &event) override; + void mouseMoved(gcn::MouseEvent &event) override; /** * Returns the selected emote. @@ -113,7 +113,7 @@ class EmotePopup : public Popup int mRowCount; int mColumnCount; - typedef std::list<gcn::SelectionListener*> Listeners; + using Listeners = std::list<gcn::SelectionListener *>; Listeners mListeners; diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp index 85a4c766..d646b78c 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -52,7 +52,7 @@ static const int BOX_HEIGHT = 36; EquipmentWindow::EquipmentWindow(Equipment *equipment): Window(_("Equipment")), - mEquipBox(0), + mEquipBox(nullptr), mSelected(-1), mEquipment(equipment), mBoxesNumber(0) @@ -61,7 +61,7 @@ EquipmentWindow::EquipmentWindow(Equipment *equipment): setupWindow->registerWindowForReset(this); // Control that shows the Player - PlayerBox *playerBox = new PlayerBox; + auto *playerBox = new PlayerBox; playerBox->setDimension(gcn::Rectangle(50, 80, 74, 123)); playerBox->setPlayer(local_player); @@ -122,7 +122,7 @@ void EquipmentWindow::draw(gcn::Graphics *graphics) Window::drawChildren(graphics); // Draw equipment boxes - Graphics *g = static_cast<Graphics*>(graphics); + auto *g = static_cast<Graphics*>(graphics); for (int i = 0; i < mBoxesNumber; i++) { @@ -194,7 +194,7 @@ Item *EquipmentWindow::getItem(int x, int y) const if (tRect.isPointInRect(x, y)) return mEquipment->getEquipment(i); } - return 0; + return nullptr; } std::string EquipmentWindow::getSlotName(int x, int y) const @@ -216,7 +216,7 @@ void EquipmentWindow::mousePressed(gcn::MouseEvent& mouseEvent) const int x = mouseEvent.getX(); const int y = mouseEvent.getY(); - Item *item = 0; + Item *item = nullptr; // Checks if any of the presses were in the equip boxes. for (int i = 0; i < mBoxesNumber; ++i) diff --git a/src/gui/equipmentwindow.h b/src/gui/equipmentwindow.h index 29814dc5..1bfc5f00 100644 --- a/src/gui/equipmentwindow.h +++ b/src/gui/equipmentwindow.h @@ -43,16 +43,16 @@ class EquipmentWindow : public Window, public gcn::ActionListener public: EquipmentWindow(Equipment *equipment); - ~EquipmentWindow(); + ~EquipmentWindow() override; /** * Draws the equipment window. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; - void mousePressed(gcn::MouseEvent& mouseEvent); + void mousePressed(gcn::MouseEvent& mouseEvent) override; /** * Loads the correct amount of displayed equip boxes. @@ -74,7 +74,7 @@ class EquipmentWindow : public Window, public gcn::ActionListener EquipBox() : posX(0), posY(0), - backgroundImage(0) + backgroundImage(nullptr) {} int posX; @@ -89,8 +89,8 @@ class EquipmentWindow : public Window, public gcn::ActionListener int mBoxesNumber; /**< Number of equipment boxes to display */ private: - void mouseExited(gcn::MouseEvent &event); - void mouseMoved(gcn::MouseEvent &event); + void mouseExited(gcn::MouseEvent &event) override; + void mouseMoved(gcn::MouseEvent &event) override; Item *getItem(int x, int y) const; std::string getSlotName(int x, int y) const; diff --git a/src/gui/focushandler.cpp b/src/gui/focushandler.cpp index ba6c834b..bef00125 100644 --- a/src/gui/focushandler.cpp +++ b/src/gui/focushandler.cpp @@ -31,7 +31,7 @@ void FocusHandler::requestModalFocus(gcn::Widget *widget) if (mModalFocusedWidget && mModalFocusedWidget != widget) { mModalStack.push_front(mModalFocusedWidget); - mModalFocusedWidget = NULL; + mModalFocusedWidget = nullptr; } gcn::FocusHandler::requestModalFocus(widget); @@ -85,7 +85,7 @@ void FocusHandler::checkForWindow() while (widget) { - Window *window = dynamic_cast<Window*>(widget); + auto *window = dynamic_cast<Window*>(widget); if (window) { diff --git a/src/gui/focushandler.h b/src/gui/focushandler.h index debfefe8..eb59bcf3 100644 --- a/src/gui/focushandler.h +++ b/src/gui/focushandler.h @@ -39,27 +39,27 @@ class FocusHandler : public gcn::FocusHandler * then that widget loses modal focus and will regain it after this * widget releases his modal focus. */ - void requestModalFocus(gcn::Widget *widget); + void requestModalFocus(gcn::Widget *widget) override; /** * Releases modal focus of a widget. When this widget had modal focus * and there are other widgets that had also requested modal focus, * then modal focus will be transfered to the last of those. */ - void releaseModalFocus(gcn::Widget *widget); + void releaseModalFocus(gcn::Widget *widget) override; /** * Removes a widget from the focus handler. Also makes sure no dangling * pointers remain in modal focus stack. */ - void remove(gcn::Widget *widget); + void remove(gcn::Widget *widget) override; /** * Overloaded to allow windows to move to the top when one of their * widgets is tabbed to when tabbing through focusable elements. */ - void tabNext(); - void tabPrevious(); + void tabNext() override; + void tabPrevious() override; private: /** diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 64509e21..e0487d95 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -45,14 +45,14 @@ #include <guichan/image.hpp> // Guichan stuff -Gui *gui = 0; -SDLInput *guiInput = 0; +Gui *gui = nullptr; +SDLInput *guiInput = nullptr; // Bolded font -gcn::Font *boldFont = 0; +gcn::Font *boldFont = nullptr; // Mono font -gcn::Font *monoFont = 0; +gcn::Font *monoFont = nullptr; class GuiConfigListener : public EventListener { @@ -61,7 +61,7 @@ class GuiConfigListener : public EventListener mGui(g) {} - void event(Event::Channel channel, const Event &event) + void event(Event::Channel channel, const Event &event) override { if (channel == Event::ConfigChannel) { @@ -79,7 +79,7 @@ class GuiConfigListener : public EventListener Gui::Gui(Graphics *graphics): mCustomCursor(false), - mMouseCursors(NULL), + mMouseCursors(nullptr), mMouseCursorAlpha(1.0f), mMouseInactivityTimer(0), mCursorType(CURSOR_POINTER) @@ -97,7 +97,7 @@ Gui::Gui(Graphics *graphics): mFocusHandler = new FocusHandler; // Initialize top GUI widget - WindowContainer *guiTop = new WindowContainer; + auto *guiTop = new WindowContainer; guiTop->setFocusable(true); guiTop->setSize(graphics->getWidth(), graphics->getHeight()); guiTop->setOpaque(false); @@ -225,7 +225,7 @@ void Gui::draw() void Gui::videoResized() { - WindowContainer *top = static_cast<WindowContainer*>(getTop()); + auto *top = static_cast<WindowContainer*>(getTop()); int oldWidth = top->getWidth(); int oldHeight = top->getHeight(); @@ -260,7 +260,7 @@ void Gui::setUseCustomCursor(bool customCursor) if (mMouseCursors) { mMouseCursors->decRef(); - mMouseCursors = NULL; + mMouseCursors = nullptr; } } } diff --git a/src/gui/gui.h b/src/gui/gui.h index 998b6ec8..c70ed9ad 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -50,19 +50,19 @@ class Gui : public gcn::Gui public: Gui(Graphics *screen); - ~Gui(); + ~Gui() override; /** * Performs logic of the GUI. Overridden to track mouse pointer * activity. */ - void logic(); + void logic() override; /** * Draws the whole Gui by calling draw functions down in the * Gui hierarchy. It also draws the mouse pointer. */ - void draw(); + void draw() override; /** * Called when the application window has been resized. @@ -114,7 +114,7 @@ class Gui : public gcn::Gui }; protected: - void handleMouseMoved(const gcn::MouseInput &mouseInput); + void handleMouseMoved(const gcn::MouseInput &mouseInput) override; void handleTextInput(const TextInput &textInput); private: diff --git a/src/gui/helpwindow.cpp b/src/gui/helpwindow.cpp index e4ded03a..077f3091 100644 --- a/src/gui/helpwindow.cpp +++ b/src/gui/helpwindow.cpp @@ -49,7 +49,7 @@ HelpWindow::HelpWindow(): mBrowserBox = new BrowserBox; mBrowserBox->setOpaque(false); mScrollArea = new ScrollArea(mBrowserBox); - Button *okButton = new Button(_("Close"), "close", this); + auto *okButton = new Button(_("Close"), "close", this); mScrollArea->setDimension(gcn::Rectangle(5, 5, 445, 335 - okButton->getHeight())); diff --git a/src/gui/helpwindow.h b/src/gui/helpwindow.h index 0295db7d..30fa450e 100644 --- a/src/gui/helpwindow.h +++ b/src/gui/helpwindow.h @@ -42,12 +42,12 @@ class HelpWindow : public Window, public LinkHandler, /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; /** * Handles link action. */ - void handleLink(const std::string &link); + void handleLink(const std::string &link) override; /** * Loads help in the dialog. diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index c6b93723..e5f6b00c 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -452,8 +452,8 @@ bool InventoryWindow::isInputFocused() const bool InventoryWindow::isAnyInputFocused() { - WindowList::iterator it = instances.begin(); - WindowList::iterator it_end = instances.end(); + auto it = instances.begin(); + auto it_end = instances.end(); for (; it != it_end; it++) { diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h index 39876e53..389312b3 100644 --- a/src/gui/inventorywindow.h +++ b/src/gui/inventorywindow.h @@ -54,12 +54,12 @@ class InventoryWindow : public Window, public: InventoryWindow(Inventory *inventory); - ~InventoryWindow(); + ~InventoryWindow() override; /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; /** * Returns the selected item. @@ -69,27 +69,27 @@ class InventoryWindow : public Window, /** * Handles closing of the window */ - virtual void widgetHidden(const gcn::Event &event); + void widgetHidden(const gcn::Event &event) override; /** * Handles the mouse clicks. */ - void mouseClicked(gcn::MouseEvent &event); + void mouseClicked(gcn::MouseEvent &event) override; /** * Handles the key presses. */ - void keyPressed(gcn::KeyEvent &event); + void keyPressed(gcn::KeyEvent &event) override; /** * Handles the key releases. */ - void keyReleased(gcn::KeyEvent &event); + void keyReleased(gcn::KeyEvent &event) override; /** * Updates labels to currently selected item. */ - void valueChanged(const gcn::SelectionEvent &event); + void valueChanged(const gcn::SelectionEvent &event) override; /** * Sets whether the split button should be shown. @@ -100,7 +100,7 @@ class InventoryWindow : public Window, * Closes the Storage Window, as well as telling the server that the * window has been closed. */ - void close(); + void close() override; /** * Updates the buttons. @@ -111,11 +111,11 @@ class InventoryWindow : public Window, static bool isAnyInputFocused(); - void slotsChanged(Inventory* inventory); + void slotsChanged(Inventory* inventory) override; bool isMainInventory() { return mInventory->isMainInventory(); } - void event(Event::Channel channel, const Event &event); + void event(Event::Channel channel, const Event &event) override; private: /** @@ -124,7 +124,7 @@ class InventoryWindow : public Window, void updateWeight(); - typedef std::list<InventoryWindow*> WindowList; + using WindowList = std::list<InventoryWindow *>; static WindowList instances; Inventory *mInventory; diff --git a/src/gui/itemamountwindow.cpp b/src/gui/itemamountwindow.cpp index a2c2ca55..285936a5 100644 --- a/src/gui/itemamountwindow.cpp +++ b/src/gui/itemamountwindow.cpp @@ -108,11 +108,11 @@ ItemAmountWindow::ItemAmountWindow(Usage usage, Window *parent, Item *item, mItemIcon = new Icon(image); // Buttons - Button *minusButton = new Button(_("-"), "dec", this); - Button *plusButton = new Button(_("+"), "inc", this); - Button *okButton = new Button(_("OK"), "ok", this); - Button *cancelButton = new Button(_("Cancel"), "cancel", this); - Button *addAllButton = new Button(_("All"), "all", this); + auto *minusButton = new Button(_("-"), "dec", this); + auto *plusButton = new Button(_("+"), "inc", this); + auto *okButton = new Button(_("OK"), "ok", this); + auto *cancelButton = new Button(_("Cancel"), "cancel", this); + auto *addAllButton = new Button(_("All"), "all", this); minusButton->adjustSize(); minusButton->setWidth(plusButton->getWidth()); diff --git a/src/gui/itemamountwindow.h b/src/gui/itemamountwindow.h index cf18d72a..d0ac52d5 100644 --- a/src/gui/itemamountwindow.h +++ b/src/gui/itemamountwindow.h @@ -53,7 +53,7 @@ class ItemAmountWindow : public Window, /** * Called when receiving actions from widget. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; /** * Sets default amount value. @@ -61,15 +61,15 @@ class ItemAmountWindow : public Window, void resetAmount(); // MouseListener - void mouseMoved(gcn::MouseEvent &event); - void mouseExited(gcn::MouseEvent &event); + void mouseMoved(gcn::MouseEvent &event) override; + void mouseExited(gcn::MouseEvent &event) override; /** * Schedules the Item Amount window for deletion. */ - void close(); + void close() override; - void keyReleased(gcn::KeyEvent &keyEvent); + void keyReleased(gcn::KeyEvent &keyEvent) override; /** * Creates the dialog, or bypass it if there aren't enough items. @@ -77,7 +77,7 @@ class ItemAmountWindow : public Window, static void showWindow(Usage usage, Window *parent, Item *item, int maxRange = 0); - ~ItemAmountWindow(); + ~ItemAmountWindow() override; private: static void finish(Item *item, int amount, Usage usage); diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp index c09a0504..f096e5ca 100644 --- a/src/gui/itempopup.cpp +++ b/src/gui/itempopup.cpp @@ -83,7 +83,7 @@ static gcn::Color getColorFromItemType(ItemType type) ItemPopup::ItemPopup(): Popup("ItemPopup"), - mIcon(0) + mIcon(nullptr) { // Item Name mItemName = new Label; @@ -102,7 +102,7 @@ ItemPopup::ItemPopup(): mItemWeight = new TextBox; mItemWeight->setEditable(false); - mIcon = new Icon(0); + mIcon = new Icon(nullptr); add(mItemName); add(mItemDesc); @@ -130,7 +130,7 @@ void ItemPopup::setEquipmentText(const std::string& text) void ItemPopup::setNoItem() { - mIcon->setImage(0); + mIcon->setImage(nullptr); std::string caption = _("No item"); if (!mItemEquipSlot.empty()) @@ -180,7 +180,7 @@ void ItemPopup::setItem(const ItemInfo &item, bool showImage) } else { - mIcon->setImage(0); + mIcon->setImage(nullptr); } mItemType = item.getItemType(); @@ -198,7 +198,7 @@ void ItemPopup::setItem(const ItemInfo &item, bool showImage) { const std::vector<std::string> &effect = item.getEffect(); std::string temp = ""; - for (std::vector<std::string>::const_iterator it = effect.begin(), + for (auto it = effect.begin(), it_end = effect.end(); it != it_end; ++it) temp += temp.empty() ? *it : "\n" + *it; mItemEffect->setTextWrapped(temp, ITEMPOPUP_WRAP_WIDTH); diff --git a/src/gui/itempopup.h b/src/gui/itempopup.h index ca1b4179..3b213633 100644 --- a/src/gui/itempopup.h +++ b/src/gui/itempopup.h @@ -46,7 +46,7 @@ class ItemPopup : public Popup /** * Destructor. Cleans up the item popup on deletion. */ - ~ItemPopup(); + ~ItemPopup() override; /** * Tells the item popup to say: No Item. @@ -63,7 +63,7 @@ class ItemPopup : public Popup */ void setItem(const ItemInfo &item, bool showImage = false); - void mouseMoved(gcn::MouseEvent &mouseEvent); + void mouseMoved(gcn::MouseEvent &mouseEvent) override; private: gcn::Label *mItemName; diff --git a/src/gui/logindialog.cpp b/src/gui/logindialog.cpp index 5c73c27f..4d065d65 100644 --- a/src/gui/logindialog.cpp +++ b/src/gui/logindialog.cpp @@ -138,11 +138,11 @@ void LoginDialog::keyPressed(gcn::KeyEvent &keyEvent) if (key.getValue() == Key::ESCAPE) { - action(gcn::ActionEvent(NULL, mServerButton->getActionEventId())); + action(gcn::ActionEvent(nullptr, mServerButton->getActionEventId())); } else if (key.getValue() == Key::ENTER) { - action(gcn::ActionEvent(NULL, mLoginButton->getActionEventId())); + action(gcn::ActionEvent(nullptr, mLoginButton->getActionEventId())); } else { diff --git a/src/gui/logindialog.h b/src/gui/logindialog.h index 87281b00..5761f4a6 100644 --- a/src/gui/logindialog.h +++ b/src/gui/logindialog.h @@ -44,17 +44,17 @@ class LoginDialog : public Window, public gcn::ActionListener, public: LoginDialog(LoginData *loginData); - ~LoginDialog(); + ~LoginDialog() override; /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; /** * Called when a key is pressed in one of the text fields. */ - void keyPressed(gcn::KeyEvent &keyEvent); + void keyPressed(gcn::KeyEvent &keyEvent) override; private: /** diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index 59e385c4..1682b972 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -43,8 +43,8 @@ bool Minimap::mShow = true; Minimap::Minimap(): Window(_("Map")), - mMap(0), - mMapImage(0), + mMap(nullptr), + mMapImage(nullptr), mWidthProportion(0.5), mHeightProportion(0.5) { @@ -92,7 +92,7 @@ void Minimap::setMap(Map *map) if (mMapImage) { mMapImage->decRef(); - mMapImage = 0; + mMapImage = nullptr; } if (map) @@ -192,7 +192,7 @@ void Minimap::draw(gcn::Graphics *graphics) const ActorSprites &actors = actorSpriteManager->getAll(); - for (ActorSpritesConstIterator it = actors.begin(), it_end = actors.end(); + for (auto it = actors.begin(), it_end = actors.end(); it != it_end; it++) { if ((*it)->getType() == ActorSprite::FLOOR_ITEM) diff --git a/src/gui/minimap.h b/src/gui/minimap.h index e44753e3..3a122230 100644 --- a/src/gui/minimap.h +++ b/src/gui/minimap.h @@ -40,7 +40,7 @@ class Minimap : public Window { public: Minimap(); - ~Minimap(); + ~Minimap() override; /** * Sets the map image that should be displayed. @@ -55,7 +55,7 @@ class Minimap : public Window /** * Draws the minimap. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; private: Map *mMap; diff --git a/src/gui/ministatuswindow.cpp b/src/gui/ministatuswindow.cpp index a4fd358f..3cd97a6d 100644 --- a/src/gui/ministatuswindow.cpp +++ b/src/gui/ministatuswindow.cpp @@ -64,7 +64,7 @@ MiniStatusWindow::MiniStatusWindow(): StatusWindow::updateMPBar(mMpBar); } else - mMpBar = 0; + mMpBar = nullptr; mXpBar = new ProgressBar(0, 100, 20, Theme::PROG_EXP); StatusWindow::updateXPBar(mXpBar); diff --git a/src/gui/ministatuswindow.h b/src/gui/ministatuswindow.h index b4392b6f..db9e4c69 100644 --- a/src/gui/ministatuswindow.h +++ b/src/gui/ministatuswindow.h @@ -45,15 +45,15 @@ class MiniStatusWindow : public Popup, public EventListener void drawIcons(Graphics *graphics); - void event(Event::Channel channel, const Event &event); + void event(Event::Channel channel, const Event &event) override; - void logic(); // Updates icons + void logic() override; // Updates icons - void draw(gcn::Graphics *graphics) + void draw(gcn::Graphics *graphics) override { drawChildren(graphics); } - void mouseMoved(gcn::MouseEvent &mouseEvent); - void mouseExited(gcn::MouseEvent &event); + void mouseMoved(gcn::MouseEvent &mouseEvent) override; + void mouseExited(gcn::MouseEvent &event) override; private: bool isInBar(ProgressBar *bar, int x, int y) const; diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp index 74d8a4aa..8b348480 100644 --- a/src/gui/npcdialog.cpp +++ b/src/gui/npcdialog.cpp @@ -51,12 +51,12 @@ #define CAPTION_CLOSE _("Close") #define CAPTION_SUBMIT _("Submit") -typedef std::map<int, NpcDialog*> NpcDialogs; +using NpcDialogs = std::map<int, NpcDialog *>; class NpcEventListener : public EventListener { public: - void event(Event::Channel channel, const Event &event); + void event(Event::Channel channel, const Event &event) override; NpcDialog *getDialog(int id, bool make = true); @@ -66,7 +66,7 @@ private: NpcDialogs mNpcDialogs; }; -static NpcEventListener *npcListener = NULL; +static NpcEventListener *npcListener = nullptr; NpcDialog::DialogList NpcDialog::instances; @@ -333,8 +333,8 @@ bool NpcDialog::isInputFocused() const bool NpcDialog::isAnyInputFocused() { - DialogList::iterator it = instances.begin(); - DialogList::iterator it_end = instances.end(); + auto it = instances.begin(); + auto it_end = instances.end(); for (; it != it_end; it++) { @@ -425,8 +425,8 @@ NpcDialog *NpcDialog::getActive() if (instances.size() == 1) return instances.front(); - DialogList::iterator it = instances.begin(); - DialogList::iterator it_end = instances.end(); + auto it = instances.begin(); + auto it_end = instances.end(); for (; it != it_end; it++) { @@ -436,13 +436,13 @@ NpcDialog *NpcDialog::getActive() } } - return 0; + return nullptr; } void NpcDialog::closeAll() { - DialogList::iterator it = instances.begin(); - DialogList::iterator it_end = instances.end(); + auto it = instances.begin(); + auto it_end = instances.end(); for (; it != it_end; it++) { @@ -623,8 +623,8 @@ void NpcEventListener::event(Event::Channel channel, NpcDialog *NpcEventListener::getDialog(int id, bool make) { - NpcDialogs::iterator diag = mNpcDialogs.find(id); - NpcDialog *dialog = 0; + auto diag = mNpcDialogs.find(id); + NpcDialog *dialog = nullptr; if (diag == mNpcDialogs.end()) { @@ -645,7 +645,7 @@ NpcDialog *NpcEventListener::getDialog(int id, bool make) void NpcEventListener::removeDialog(int id) { - NpcDialogs::iterator it = mNpcDialogs.find(id); + auto it = mNpcDialogs.find(id); if (it != mNpcDialogs.end()) mNpcDialogs.erase(it); } diff --git a/src/gui/npcdialog.h b/src/gui/npcdialog.h index 9c6839b0..49ec5f8a 100644 --- a/src/gui/npcdialog.h +++ b/src/gui/npcdialog.h @@ -52,12 +52,12 @@ class NpcDialog : public Window, public: NpcDialog(int npcId); - ~NpcDialog(); + ~NpcDialog() override; /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; /** * Sets the text shows in the dialog. @@ -94,17 +94,17 @@ class NpcDialog : public Window, * Notifies the server that the client has performed a close action. * @overrides Window::close() */ - void close(); + void close() override; /** * Returns the number of items in the choices list. */ - int getNumberOfElements(); + int getNumberOfElements() override; /** * Returns the name of item number i of the choices list. */ - std::string getElementAt(int i); + std::string getElementAt(int i) override; /** * Makes this dialog request a choice selection from the user. @@ -144,13 +144,13 @@ class NpcDialog : public Window, * * @param event The calling event */ - void widgetResized(const gcn::Event &event); + void widgetResized(const gcn::Event &event) override; - void setVisible(bool visible); + void setVisible(bool visible) override; - void event(Event::Channel channel, const Event &event); + void event(Event::Channel channel, const Event &event) override; - void mouseClicked(gcn::MouseEvent &mouseEvent); + void mouseClicked(gcn::MouseEvent &mouseEvent) override; /** * Returns the first active instance. Useful for pushing user @@ -169,7 +169,7 @@ class NpcDialog : public Window, static void setup(); private: - typedef std::list<NpcDialog*> DialogList; + using DialogList = std::list<NpcDialog *>; static DialogList instances; void buildLayout(); diff --git a/src/gui/npcpostdialog.cpp b/src/gui/npcpostdialog.cpp index 6f673f5c..3567472a 100644 --- a/src/gui/npcpostdialog.cpp +++ b/src/gui/npcpostdialog.cpp @@ -51,10 +51,10 @@ NpcPostDialog::NpcPostDialog(int npcId): mSender->setWidth(65); // create button for sending - Button *sendButton = new Button(_("Send"), "send", this); + auto *sendButton = new Button(_("Send"), "send", this); sendButton->setPosition(400 - sendButton->getWidth(), 170 - sendButton->getHeight()); - Button *cancelButton = new Button(_("Cancel"), "cancel", this); + auto *cancelButton = new Button(_("Cancel"), "cancel", this); cancelButton->setPosition(sendButton->getX() - (cancelButton->getWidth() + 2), sendButton->getY()); @@ -64,7 +64,7 @@ NpcPostDialog::NpcPostDialog(int npcId): mText->setEditable(true); // create scroll box for letter text - ScrollArea *scrollArea = new ScrollArea(mText); + auto *scrollArea = new ScrollArea(mText); scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); scrollArea->setDimension(gcn::Rectangle( 5, mSender->getHeight() + 5, @@ -124,8 +124,8 @@ void NpcPostDialog::setVisible(bool visible) void NpcPostDialog::closeAll() { - DialogList::iterator it = instances.begin(); - DialogList::iterator it_end = instances.end(); + auto it = instances.begin(); + auto it_end = instances.end(); for (; it != it_end; it++) { diff --git a/src/gui/npcpostdialog.h b/src/gui/npcpostdialog.h index cda44a66..61c17ca6 100644 --- a/src/gui/npcpostdialog.h +++ b/src/gui/npcpostdialog.h @@ -34,14 +34,14 @@ class NpcPostDialog : public Window, public gcn::ActionListener public: NpcPostDialog(int npcId); - ~NpcPostDialog(); + ~NpcPostDialog() override; /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; - void setVisible(bool visible); + void setVisible(bool visible) override; /** * Closes all instances. @@ -49,7 +49,7 @@ public: static void closeAll(); private: - typedef std::list<NpcPostDialog*> DialogList; + using DialogList = std::list<NpcPostDialog *>; static DialogList instances; int mNpcId; diff --git a/src/gui/okdialog.h b/src/gui/okdialog.h index 72f923b7..fcb327a9 100644 --- a/src/gui/okdialog.h +++ b/src/gui/okdialog.h @@ -37,12 +37,12 @@ class OkDialog : public Window, public gcn::ActionListener { public: OkDialog(const std::string &title, const std::string &msg, - bool modal = true, Window *parent = NULL); + bool modal = true, Window *parent = nullptr); /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; private: TextBox *mTextBox; diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp index d9730441..cd6c7d3d 100644 --- a/src/gui/outfitwindow.cpp +++ b/src/gui/outfitwindow.cpp @@ -54,7 +54,7 @@ OutfitWindow::OutfitWindow(): mGridWidth(3), mGridHeight(3), mItemClicked(false), - mItemMoved(NULL), + mItemMoved(nullptr), mItemSelected(-1), mCurrentOutfit(0) { @@ -188,7 +188,7 @@ void OutfitWindow::copyOutfit(int outfit) void OutfitWindow::draw(gcn::Graphics *graphics) { Window::draw(graphics); - Graphics *g = static_cast<Graphics*>(graphics); + auto *g = static_cast<Graphics*>(graphics); for (int i = 0; i < OUTFIT_ITEM_COUNT; i++) { @@ -295,13 +295,13 @@ void OutfitWindow::mouseReleased(gcn::MouseEvent &event) const int index = getIndexFromGrid(event.getX(), event.getY()); if (index == -1) { - mItemMoved = NULL; + mItemMoved = nullptr; return; } if (mItemMoved) { mItems[mCurrentOutfit][index] = mItemMoved->getId(); - mItemMoved = NULL; + mItemMoved = nullptr; } if (mItemClicked) mItemClicked = false; diff --git a/src/gui/outfitwindow.h b/src/gui/outfitwindow.h index 65b22235..c5e24b9b 100644 --- a/src/gui/outfitwindow.h +++ b/src/gui/outfitwindow.h @@ -39,17 +39,17 @@ class OutfitWindow : public Window, gcn::ActionListener public: OutfitWindow(); - ~OutfitWindow(); + ~OutfitWindow() override; - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; - void mousePressed(gcn::MouseEvent &event); + void mousePressed(gcn::MouseEvent &event) override; - void mouseDragged(gcn::MouseEvent &event); + void mouseDragged(gcn::MouseEvent &event) override; - void mouseReleased(gcn::MouseEvent &event); + void mouseReleased(gcn::MouseEvent &event) override; void load(); diff --git a/src/gui/palette.cpp b/src/gui/palette.cpp index db51db4b..23ba75ee 100644 --- a/src/gui/palette.cpp +++ b/src/gui/palette.cpp @@ -77,8 +77,8 @@ const gcn::Color& Palette::getColor(char c, bool &valid) void Palette::advanceGradients() { - Palettes::iterator it = mInstances.begin(); - Palettes::iterator it_end = mInstances.end(); + auto it = mInstances.begin(); + auto it_end = mInstances.end(); for (; it != it_end; it++) { diff --git a/src/gui/palette.h b/src/gui/palette.h index a6347a5b..1ea7c467 100644 --- a/src/gui/palette.h +++ b/src/gui/palette.h @@ -124,7 +124,7 @@ class Palette /** Time tick, that gradient-type colors were updated the last time. */ int mRainbowTime; - typedef std::set<Palette*> Palettes; + using Palettes = std::set<Palette *>; static Palettes mInstances; Palette(int size); @@ -163,7 +163,7 @@ class Palette committedColor.b; } }; - typedef std::vector<ColorElem> Colors; + using Colors = std::vector<ColorElem>; /** Vector containing the colors. */ Colors mColors; std::vector<ColorElem*> mGradVector; diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 41b62bad..d63fe2f3 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -57,8 +57,8 @@ std::string tradePartnerName; PopupMenu::PopupMenu(): Popup("PopupMenu"), mBeingId(0), - mFloorItem(NULL), - mItem(NULL) + mFloorItem(nullptr), + mItem(nullptr) { mBrowserBox = new BrowserBox; mBrowserBox->setPosition(4, 4); @@ -348,8 +348,8 @@ void PopupMenu::handleLink(const std::string &link) setVisible(false); mBeingId = 0; - mFloorItem = NULL; - mItem = NULL; + mFloorItem = nullptr; + mItem = nullptr; } void PopupMenu::showPopup(Window *parent, int x, int y, Item *item, diff --git a/src/gui/popupmenu.h b/src/gui/popupmenu.h index d1526da2..c5be561d 100644 --- a/src/gui/popupmenu.h +++ b/src/gui/popupmenu.h @@ -60,7 +60,7 @@ class PopupMenu : public Popup, public LinkHandler /** * Handles link action. */ - void handleLink(const std::string &link); + void handleLink(const std::string &link) override; private: BrowserBox* mBrowserBox; diff --git a/src/gui/quitdialog.cpp b/src/gui/quitdialog.cpp index 21c9fdc1..4262f9cc 100644 --- a/src/gui/quitdialog.cpp +++ b/src/gui/quitdialog.cpp @@ -37,7 +37,7 @@ #include <assert.h> QuitDialog::QuitDialog(QuitDialog** pointerToMe): - Window(_("Quit"), true, NULL), mMyPointer(pointerToMe) + Window(_("Quit"), true, nullptr), mMyPointer(pointerToMe) { mForceQuit = new RadioButton(_("Quit"), "quitdialog"); mLogoutQuit = new RadioButton(_("Quit"), "quitdialog"); @@ -90,7 +90,7 @@ QuitDialog::QuitDialog(QuitDialog** pointerToMe): QuitDialog::~QuitDialog() { - if (mMyPointer) *mMyPointer = NULL; + if (mMyPointer) *mMyPointer = nullptr; // Optional widgets, so delete them by hand. delete mForceQuit; delete mLogoutQuit; @@ -138,10 +138,10 @@ void QuitDialog::keyPressed(gcn::KeyEvent &keyEvent) switch (key.getValue()) { case Key::ENTER: - action(gcn::ActionEvent(NULL, mOkButton->getActionEventId())); + action(gcn::ActionEvent(nullptr, mOkButton->getActionEventId())); break; case Key::ESCAPE: - action(gcn::ActionEvent(NULL, mCancelButton->getActionEventId())); + action(gcn::ActionEvent(nullptr, mCancelButton->getActionEventId())); break; case Key::UP: dir = -1; @@ -153,7 +153,7 @@ void QuitDialog::keyPressed(gcn::KeyEvent &keyEvent) if (dir != 0) { - std::vector<gcn::RadioButton*>::iterator it = mOptions.begin(); + auto it = mOptions.begin(); for (; it < mOptions.end(); it++) { diff --git a/src/gui/quitdialog.h b/src/gui/quitdialog.h index f3852642..d62d5c51 100644 --- a/src/gui/quitdialog.h +++ b/src/gui/quitdialog.h @@ -47,14 +47,14 @@ class QuitDialog : public Window, public gcn::ActionListener, */ QuitDialog(QuitDialog **pointerToMe); - ~QuitDialog(); + ~QuitDialog() override; /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; - void keyPressed(gcn::KeyEvent &keyEvent); + void keyPressed(gcn::KeyEvent &keyEvent) override; private: void placeOption(ContainerPlacer &place, gcn::RadioButton *option); diff --git a/src/gui/recorder.cpp b/src/gui/recorder.cpp index 8c71c63a..a7a9b25a 100644 --- a/src/gui/recorder.cpp +++ b/src/gui/recorder.cpp @@ -42,7 +42,7 @@ Recorder::Recorder(ChatWindow *chat, const std::string &title, const int offsetY = getTitleBarHeight() + getPadding() + 10; mChat = chat; - Button *button = new Button(buttonTxt, "activate", this); + auto *button = new Button(buttonTxt, "activate", this); // 123 is the default chat window height. If you change this in Chat, please // change it here as well diff --git a/src/gui/recorder.h b/src/gui/recorder.h index 79a2b60e..efd73021 100644 --- a/src/gui/recorder.h +++ b/src/gui/recorder.h @@ -39,7 +39,7 @@ class Recorder : public Window, public gcn::ActionListener Recorder(ChatWindow *chat, const std::string &title = _("Recording..."), const std::string &buttonTxt = _("Stop recording")); - virtual ~Recorder(); + ~Recorder() override; /** * Outputs the message to the recorder file @@ -65,7 +65,7 @@ class Recorder : public Window, public gcn::ActionListener * * @param event is the event that is generated */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; private: ChatWindow *mChat; diff --git a/src/gui/register.cpp b/src/gui/register.cpp index c220ab0c..e394e59b 100644 --- a/src/gui/register.cpp +++ b/src/gui/register.cpp @@ -56,9 +56,9 @@ void WrongDataNoticeListener::action(const gcn::ActionEvent &event) RegisterDialog::RegisterDialog(LoginData *loginData): Window(_("Register")), - mEmailField(0), - mMaleButton(0), - mFemaleButton(0), + mEmailField(nullptr), + mMaleButton(nullptr), + mFemaleButton(nullptr), mWrongDataNoticeListener(new WrongDataNoticeListener), mLoginData(loginData) { @@ -215,7 +215,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event) mWrongDataNoticeListener->setTarget(this->mPasswordField); } - OkDialog *dlg = new OkDialog(_("Error"), errorMessage); + auto *dlg = new OkDialog(_("Error"), errorMessage); dlg->addActionListener(mWrongDataNoticeListener); } else diff --git a/src/gui/register.h b/src/gui/register.h index dbab8e62..a8f875cb 100644 --- a/src/gui/register.h +++ b/src/gui/register.h @@ -41,7 +41,7 @@ class WrongDataNoticeListener : public gcn::ActionListener { public: void setTarget(gcn::TextField *textField); - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; private: gcn::TextField *mTarget; }; @@ -63,17 +63,17 @@ class RegisterDialog : public Window, public gcn::ActionListener, */ RegisterDialog(LoginData *loginData); - ~RegisterDialog(); + ~RegisterDialog() override; /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; /** * Called when a key is pressed in one of the text fields. */ - void keyPressed(gcn::KeyEvent &keyEvent); + void keyPressed(gcn::KeyEvent &keyEvent) override; private: /** diff --git a/src/gui/selldialog.cpp b/src/gui/selldialog.cpp index 41ee349a..76a4b3ac 100644 --- a/src/gui/selldialog.cpp +++ b/src/gui/selldialog.cpp @@ -316,8 +316,8 @@ void SellDialog::setVisible(bool visible) void SellDialog::closeAll() { - DialogList::iterator it = instances.begin(); - DialogList::iterator it_end = instances.end(); + auto it = instances.begin(); + auto it_end = instances.end(); for (; it != it_end; it++) { diff --git a/src/gui/selldialog.h b/src/gui/selldialog.h index c94e7250..7e37d860 100644 --- a/src/gui/selldialog.h +++ b/src/gui/selldialog.h @@ -41,7 +41,7 @@ class SellDialog : public Window, gcn::ActionListener, gcn::SelectionListener public: SellDialog(int npcId); - virtual ~SellDialog(); + ~SellDialog() override; /** * Resets the dialog, clearing inventory. @@ -56,19 +56,19 @@ class SellDialog : public Window, gcn::ActionListener, gcn::SelectionListener /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; /** * Updates labels according to selected item. * * @see SelectionListener::selectionChanged */ - void valueChanged(const gcn::SelectionEvent &event); + void valueChanged(const gcn::SelectionEvent &event) override; /** * Allows for quick-selling by extending double-click events. */ - void mouseClicked(gcn::MouseEvent &mouseEvent); + void mouseClicked(gcn::MouseEvent &mouseEvent) override; /** * Gives Player's Money amount @@ -78,7 +78,7 @@ class SellDialog : public Window, gcn::ActionListener, gcn::SelectionListener /** * Sets the visibility of this window. */ - void setVisible(bool visible); + void setVisible(bool visible) override; /** * Closes all instances. @@ -86,7 +86,7 @@ class SellDialog : public Window, gcn::ActionListener, gcn::SelectionListener static void closeAll(); private: - typedef std::list<SellDialog*> DialogList; + using DialogList = std::list<SellDialog *>; static DialogList instances; /** diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index 3ea978e1..f0016322 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -112,12 +112,12 @@ public: { } - void draw(gcn::Graphics *graphics) + void draw(gcn::Graphics *graphics) override { if (!mListModel) return; - ServersListModel *model = static_cast<ServersListModel*>(mListModel); + auto *model = static_cast<ServersListModel*>(mListModel); updateAlpha(); @@ -165,7 +165,7 @@ public: } } - unsigned int getRowHeight() const + unsigned int getRowHeight() const override { return 2 * getFont()->getHeight(); } @@ -188,7 +188,7 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir): mServersList = new ServersListBox(mServersListModel); - ScrollArea *usedScroll = new ScrollArea(mServersList); + auto *usedScroll = new ScrollArea(mServersList); usedScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mDescription = new Label(std::string()); @@ -252,7 +252,7 @@ ServerDialog::~ServerDialog() { mDownload->cancel(); delete mDownload; - mDownload = 0; + mDownload = nullptr; } delete mServersListModel; } @@ -275,7 +275,7 @@ void ServerDialog::action(const gcn::ActionEvent &event) #endif ) { - OkDialog *dlg = new OkDialog(_("Error"), + auto *dlg = new OkDialog(_("Error"), _("Please select a valid server.")); dlg->addActionListener(this); } @@ -319,7 +319,7 @@ void ServerDialog::action(const gcn::ActionEvent &event) // Check whether a server is selected. if (index < 0) { - OkDialog *dlg = new OkDialog(_("Error"), + auto *dlg = new OkDialog(_("Error"), _("Please select a custom server.")); dlg->addActionListener(this); } @@ -348,7 +348,7 @@ void ServerDialog::keyPressed(gcn::KeyEvent &keyEvent) } else if (key.getValue() == Key::ENTER) { - action(gcn::ActionEvent(NULL, mConnectButton->getActionEventId())); + action(gcn::ActionEvent(nullptr, mConnectButton->getActionEventId())); } } @@ -523,7 +523,7 @@ void ServerDialog::loadServers() // Add the server to the local list if it's not already present bool found = false; int i = 0; - for (ServerInfos::iterator it = mServers.begin(); it != mServers.end(); + for (auto it = mServers.begin(); it != mServers.end(); ++it) { if (*it == server) @@ -641,7 +641,7 @@ int ServerDialog::downloadUpdate(void *ptr, DownloadStatus status, if (status == DOWNLOAD_STATUS_CANCELLED) return -1; - ServerDialog *sd = reinterpret_cast<ServerDialog*>(ptr); + auto *sd = reinterpret_cast<ServerDialog*>(ptr); bool finished = false; if (status == DOWNLOAD_STATUS_COMPLETE) diff --git a/src/gui/serverdialog.h b/src/gui/serverdialog.h index cf9e62e7..d0ef0e55 100644 --- a/src/gui/serverdialog.h +++ b/src/gui/serverdialog.h @@ -50,19 +50,19 @@ class DropDown; class ServersListModel : public gcn::ListModel { public: - typedef std::pair<int, std::string> VersionString; + using VersionString = std::pair<int, std::string>; ServersListModel(ServerInfos *servers, ServerDialog *parent); /** * Used to get number of line in the list */ - int getNumberOfElements(); + int getNumberOfElements() override; /** * Used to get an element from the list */ - std::string getElementAt(int elementIndex); + std::string getElementAt(int elementIndex) override; /** * Used to get the corresponding Server struct @@ -73,7 +73,7 @@ class ServersListModel : public gcn::ListModel void setVersionString(int index, const std::string &version); private: - typedef std::vector<VersionString> VersionStrings; + using VersionStrings = std::vector<VersionString>; ServerInfos *mServers; VersionStrings mVersionStrings; @@ -93,23 +93,23 @@ class ServerDialog : public Window, public: ServerDialog(ServerInfo *serverInfo, const std::string &dir); - ~ServerDialog(); + ~ServerDialog() override; /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; - void keyPressed(gcn::KeyEvent &keyEvent); + void keyPressed(gcn::KeyEvent &keyEvent) override; /** * Called when the selected value changed in the servers list box. */ - void valueChanged(const gcn::SelectionEvent &event); + void valueChanged(const gcn::SelectionEvent &event) override; - void mouseClicked(gcn::MouseEvent &mouseEvent); + void mouseClicked(gcn::MouseEvent &mouseEvent) override; - void logic(); + void logic() override; protected: friend class ServersListModel; diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index 930408ac..daced0fa 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -51,12 +51,12 @@ Setup::Setup(): setContentSize(width, height); static const char *buttonNames[] = { - N_("Apply"), N_("Cancel"), N_("Reset Windows"), 0 + N_("Apply"), N_("Cancel"), N_("Reset Windows"), nullptr }; int x = width; for (const char **curBtn = buttonNames; *curBtn; ++curBtn) { - Button *btn = new Button(gettext(*curBtn), *curBtn, this); + auto *btn = new Button(gettext(*curBtn), *curBtn, this); x -= btn->getWidth() + 5; btn->setPosition(x, height - btn->getHeight() - 5); add(btn); @@ -66,7 +66,7 @@ Setup::Setup(): mResetWindows = btn; } - TabbedArea *panel = new TabbedArea; + auto *panel = new TabbedArea; panel->setDimension(gcn::Rectangle(5, 5, width - 10, height - 40)); mTabs.push_back(new Setup_Video); @@ -77,7 +77,7 @@ Setup::Setup(): mTabs.push_back(new Setup_Colors); mTabs.push_back(new Setup_Players); - for (std::list<SetupTab*>::iterator i = mTabs.begin(), i_end = mTabs.end(); + for (auto i = mTabs.begin(), i_end = mTabs.end(); i != i_end; ++i) { SetupTab *tab = *i; @@ -86,7 +86,7 @@ Setup::Setup(): add(panel); - Label *version = new Label(FULL_VERSION); + auto *version = new Label(FULL_VERSION); version->setPosition(9, height - version->getHeight() - 9); add(version); @@ -119,7 +119,7 @@ void Setup::action(const gcn::ActionEvent &event) if (!statusWindow) return; - for (std::list<Window*>::iterator it = mWindowsToReset.begin(); + for (auto it = mWindowsToReset.begin(); it != mWindowsToReset.end(); it++) { (*it)->resetToDefaultSize(); diff --git a/src/gui/setup.h b/src/gui/setup.h index c2f1ac04..d510267d 100644 --- a/src/gui/setup.h +++ b/src/gui/setup.h @@ -48,12 +48,12 @@ class Setup : public Window, public gcn::ActionListener { public: Setup(); - ~Setup(); + ~Setup() override; /** * Event handling method. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; /** * Enables the reset button when in game. diff --git a/src/gui/setup_audio.h b/src/gui/setup_audio.h index ac81bdb7..4ee277ef 100644 --- a/src/gui/setup_audio.h +++ b/src/gui/setup_audio.h @@ -33,10 +33,10 @@ class Setup_Audio : public SetupTab, public gcn::ActionListener public: Setup_Audio(); - void apply(); - void cancel(); + void apply() override; + void cancel() override; - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; private: int mMusicVolume; diff --git a/src/gui/setup_colors.cpp b/src/gui/setup_colors.cpp index cf234eb3..bf86a93b 100644 --- a/src/gui/setup_colors.cpp +++ b/src/gui/setup_colors.cpp @@ -63,7 +63,7 @@ Setup_Colors::Setup_Colors() : mPreview->setOpaque(false); // don't do anything with links - mPreview->setLinkHandler(NULL); + mPreview->setLinkHandler(nullptr); mPreviewBox = new ScrollArea(mPreview); mPreviewBox->setHeight(20); @@ -234,7 +234,7 @@ void Setup_Colors::valueChanged(const gcn::SelectionEvent &event) mPreviewBox->setContent(mTextPreview); mTextPreview->setFont(boldFont); mTextPreview->setTextColor(col); - mTextPreview->setTextBGColor(NULL); + mTextPreview->setTextBGColor(nullptr); mTextPreview->setOpaque(false); mTextPreview->setShadow(true); mTextPreview->setOutline(true); @@ -348,7 +348,7 @@ void Setup_Colors::updateColor() return; int type = userPalette->getColorTypeAt(mSelected); - Palette::GradientType grad = static_cast<Palette::GradientType>((int) + auto grad = static_cast<Palette::GradientType>((int) mGradTypeSlider->getValue()); int delay = (int) mGradDelaySlider->getValue(); userPalette->setGradient(type, grad); diff --git a/src/gui/setup_colors.h b/src/gui/setup_colors.h index e9144c73..b534ca8a 100644 --- a/src/gui/setup_colors.h +++ b/src/gui/setup_colors.h @@ -41,14 +41,14 @@ class Setup_Colors : public SetupTab, { public: Setup_Colors(); - ~Setup_Colors(); + ~Setup_Colors() override; - void apply(); - void cancel(); + void apply() override; + void cancel() override; - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; - void valueChanged(const gcn::SelectionEvent &event); + void valueChanged(const gcn::SelectionEvent &event) override; private: static const std::string rawmsg; diff --git a/src/gui/setup_interface.cpp b/src/gui/setup_interface.cpp index b35a30fe..619a250c 100644 --- a/src/gui/setup_interface.cpp +++ b/src/gui/setup_interface.cpp @@ -65,14 +65,14 @@ const char *SIZE_NAME[4] = class FontSizeChoiceListModel : public gcn::ListModel { public: - virtual ~FontSizeChoiceListModel() { } + ~FontSizeChoiceListModel() override { } - virtual int getNumberOfElements() + int getNumberOfElements() override { return 4; } - virtual std::string getElementAt(int i) + std::string getElementAt(int i) override { if (i >= getNumberOfElements()) return _("???"); @@ -120,7 +120,7 @@ Setup_Interface::Setup_Interface(): setName(_("Interface")); // Create widgets - Spacer *space = new Spacer(0,10); + auto *space = new Spacer(0,10); mShowMonsterDamageCheckBox = new CheckBox(_("Show damage"), mShowMonsterDamageEnabled); @@ -260,7 +260,7 @@ void Setup_Interface::action(const gcn::ActionEvent &event) } else if (id == "speech") { - Being::Speech val = (Being::Speech)mSpeechSlider->getValue(); + auto val = (Being::Speech)mSpeechSlider->getValue(); mSpeechLabel->setCaption(speechModeToString(val)); mSpeechSlider->setValue(val); config.setValue("speech", val); diff --git a/src/gui/setup_interface.h b/src/gui/setup_interface.h index 2b1de5b7..530d575a 100644 --- a/src/gui/setup_interface.h +++ b/src/gui/setup_interface.h @@ -37,12 +37,12 @@ class Setup_Interface : public SetupTab, public gcn::ActionListener, { public: Setup_Interface(); - ~Setup_Interface(); + ~Setup_Interface() override; - void apply(); - void cancel(); + void apply() override; + void cancel() override; - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; private: bool mShowMonsterDamageEnabled; diff --git a/src/gui/setup_joystick.h b/src/gui/setup_joystick.h index 2329ab4d..e51ccbe8 100644 --- a/src/gui/setup_joystick.h +++ b/src/gui/setup_joystick.h @@ -33,10 +33,10 @@ class Setup_Joystick : public SetupTab, public gcn::ActionListener public: Setup_Joystick(); - void apply(); - void cancel(); + void apply() override; + void cancel() override; - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; private: gcn::Label *mCalibrateLabel; diff --git a/src/gui/setup_keyboard.cpp b/src/gui/setup_keyboard.cpp index b66ba3aa..0ac64447 100644 --- a/src/gui/setup_keyboard.cpp +++ b/src/gui/setup_keyboard.cpp @@ -51,12 +51,12 @@ class KeyListModel : public gcn::ListModel /** * Returns the number of elements in container. */ - int getNumberOfElements() { return keyboard.KEY_TOTAL; } + int getNumberOfElements() override { return keyboard.KEY_TOTAL; } /** * Returns element from container. */ - std::string getElementAt(int i) { return mKeyFunctions[i]; } + std::string getElementAt(int i) override { return mKeyFunctions[i]; } /** * Sets element from container. @@ -83,7 +83,7 @@ Setup_Keyboard::Setup_Keyboard(): mKeyList->addActionListener(this); mKeyList->setFont(monoFont); - ScrollArea *scrollArea = new ScrollArea(mKeyList); + auto *scrollArea = new ScrollArea(mKeyList); scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mAssignKeyButton = new Button(_("Assign"), "assign", this); diff --git a/src/gui/setup_keyboard.h b/src/gui/setup_keyboard.h index 14eee5b9..1ecb5ea3 100644 --- a/src/gui/setup_keyboard.h +++ b/src/gui/setup_keyboard.h @@ -36,12 +36,12 @@ class Setup_Keyboard : public SetupTab, public gcn::ActionListener public: Setup_Keyboard(); - ~Setup_Keyboard(); + ~Setup_Keyboard() override; - void apply(); - void cancel(); + void apply() override; + void cancel() override; - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; /** * Get an update on the assigned key. diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp index ad50baad..a3b0ef53 100644 --- a/src/gui/setup_players.cpp +++ b/src/gui/setup_players.cpp @@ -70,14 +70,14 @@ static const char *RELATION_NAMES[PlayerRelation::RELATIONS_NR] = class PlayerRelationListModel : public gcn::ListModel { public: - virtual ~PlayerRelationListModel() { } + ~PlayerRelationListModel() override { } - virtual int getNumberOfElements() + int getNumberOfElements() override { return PlayerRelation::RELATIONS_NR; } - virtual std::string getElementAt(int i) + std::string getElementAt(int i) override { if (i >= getNumberOfElements() || i < 0) return ""; @@ -89,35 +89,35 @@ class PlayerTableModel : public TableModel { public: PlayerTableModel() : - mPlayers(NULL), + mPlayers(nullptr), mListModel(new PlayerRelationListModel) { playerRelationsUpdated(); } - virtual ~PlayerTableModel() + ~PlayerTableModel() override { freeWidgets(); delete mListModel; delete mPlayers; } - virtual int getRows() const + int getRows() const override { return mPlayers->size(); } - virtual int getColumns() const + int getColumns() const override { return COLUMNS_NR; } - virtual int getRowHeight() const + int getRowHeight() const override { return ROW_HEIGHT; } - virtual int getColumnWidth(int index) const + int getColumnWidth(int index) const override { if (index == NAME_COLUMN) return NAME_COLUMN_WIDTH; @@ -151,7 +151,7 @@ public: virtual void updateModelInRow(int row) { - gcn::DropDown *choicebox = static_cast<gcn::DropDown *>( + auto *choicebox = static_cast<gcn::DropDown *>( getElementAt(row, RELATION_CHOICE_COLUMN)); player_relations.setRelation(getPlayerAt(row), static_cast<PlayerRelation::Relation>( @@ -159,7 +159,7 @@ public: } - virtual gcn::Widget *getElementAt(int row, int column) const + gcn::Widget *getElementAt(int row, int column) const override { return mWidgets[WIDGET_AT(row, column)]; } @@ -168,7 +168,7 @@ public: { if (mPlayers) delete mPlayers; - mPlayers = NULL; + mPlayers = nullptr; delete_all(mWidgets); mWidgets.clear(); @@ -191,14 +191,14 @@ protected: class IgnoreChoicesListModel : public gcn::ListModel { public: - virtual ~IgnoreChoicesListModel() { } + ~IgnoreChoicesListModel() override { } - virtual int getNumberOfElements() + int getNumberOfElements() override { return player_relations.getPlayerIgnoreStrategies()->size(); } - virtual std::string getElementAt(int i) + std::string getElementAt(int i) override { if (i >= getNumberOfElements()) return _("???"); diff --git a/src/gui/setup_players.h b/src/gui/setup_players.h index ed2361b9..90663029 100644 --- a/src/gui/setup_players.h +++ b/src/gui/setup_players.h @@ -39,16 +39,16 @@ class Setup_Players : public SetupTab, { public: Setup_Players(); - virtual ~Setup_Players(); + ~Setup_Players() override; - void apply(); - void cancel(); + void apply() override; + void cancel() override; void reset(); - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; - virtual void updatedPlayer(const std::string &name); + void updatedPlayer(const std::string &name) override; private: StaticTableModel *mPlayerTableTitleModel; diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index 709a7685..2d4835ec 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -61,17 +61,17 @@ class ModeListModel : public gcn::ListModel public: ModeListModel(); - virtual ~ModeListModel() { } + ~ModeListModel() override { } /** * Returns the number of elements in container. */ - int getNumberOfElements() { return mVideoModes.size(); } + int getNumberOfElements() override { return mVideoModes.size(); } /** * Returns element from container. */ - std::string getElementAt(int i) { return mVideoModes[i]; } + std::string getElementAt(int i) override { return mVideoModes[i]; } /** * Returns the index corresponding to the given video mode. @@ -173,9 +173,9 @@ Setup_Video::Setup_Video(): { setName(_("Video")); - Spacer *space = new Spacer(0,10); + auto *space = new Spacer(0,10); - ScrollArea *scrollArea = new ScrollArea(mModeList); + auto *scrollArea = new ScrollArea(mModeList); scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); scrollArea->setSize(100, 200); diff --git a/src/gui/setup_video.h b/src/gui/setup_video.h index 7002a936..1352aa53 100644 --- a/src/gui/setup_video.h +++ b/src/gui/setup_video.h @@ -37,12 +37,12 @@ class Setup_Video : public SetupTab, public gcn::ActionListener, { public: Setup_Video(); - ~Setup_Video(); + ~Setup_Video() override; - void apply(); - void cancel(); + void apply() override; + void cancel() override; - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; static const char *overlayDetailToString(int detail = -1); diff --git a/src/gui/shortcutwindow.h b/src/gui/shortcutwindow.h index f33ddf50..6fdafcb8 100644 --- a/src/gui/shortcutwindow.h +++ b/src/gui/shortcutwindow.h @@ -37,7 +37,7 @@ class ShortcutWindow : public Window public: ShortcutWindow(const std::string &title, ShortcutContainer *content); - ~ShortcutWindow(); + ~ShortcutWindow() override; private: ShortcutWindow(); diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp index a0c3e46b..09bde167 100644 --- a/src/gui/skilldialog.cpp +++ b/src/gui/skilldialog.cpp @@ -77,7 +77,7 @@ struct SkillInfo gcn::Color color; SkillInfo() : - icon(NULL) + icon(nullptr) {} ~SkillInfo() @@ -106,18 +106,18 @@ struct SkillInfo void draw(Graphics *graphics, int y, int width); }; -typedef std::vector<SkillInfo*> SkillList; +using SkillList = std::vector<SkillInfo *>; class SkillModel : public gcn::ListModel { public: - int getNumberOfElements() + int getNumberOfElements() override { return mVisibleSkills.size(); } SkillInfo *getSkillAt(int i) const { return mVisibleSkills.at(i); } - std::string getElementAt(int i) + std::string getElementAt(int i) override { return getSkillAt(i)->name; } void updateVisibilities(); @@ -141,21 +141,21 @@ public: { const int selected = getSelected(); if (selected < 0 || selected > mListModel->getNumberOfElements()) - return 0; + return nullptr; return static_cast<SkillModel*>(mListModel)->getSkillAt(selected); } - void draw(gcn::Graphics *gcnGraphics) + void draw(gcn::Graphics *gcnGraphics) override { if (!mListModel) return; - SkillModel* model = static_cast<SkillModel*>(mListModel); + auto* model = static_cast<SkillModel*>(mListModel); updateAlpha(); - Graphics *graphics = static_cast<Graphics*>(gcnGraphics); + auto *graphics = static_cast<Graphics*>(gcnGraphics); graphics->setColor(Theme::getThemeColor(Theme::HIGHLIGHT, (int) (mAlpha * 255.0f))); @@ -183,7 +183,7 @@ public: } } - unsigned int getRowHeight() const { return 34; } + unsigned int getRowHeight() const override { return 34; } }; class SkillTab : public Tab @@ -195,10 +195,10 @@ public: setCaption(name); } - ~SkillTab() + ~SkillTab() override { delete mListBox; - mListBox = 0; + mListBox = nullptr; } SkillInfo *getSelectedInfo() @@ -245,7 +245,7 @@ void SkillDialog::action(const gcn::ActionEvent &event) { if (event.getId() == "inc") { - SkillTab *tab = static_cast<SkillTab*>(mTabs->getSelectedTab()); + auto *tab = static_cast<SkillTab*>(mTabs->getSelectedTab()); if (SkillInfo *info = tab->getSelectedInfo()) Net::getPlayerHandler()->increaseSkill(info->id); } @@ -257,7 +257,7 @@ void SkillDialog::action(const gcn::ActionEvent &event) std::string SkillDialog::update(int id) { - SkillMap::iterator i = mSkills.find(id); + auto i = mSkills.find(id); if (i != mSkills.end()) { @@ -275,7 +275,7 @@ void SkillDialog::update() PlayerInfo::getAttribute(SKILL_POINTS))); mPointsLabel->adjustSize(); - for (SkillMap::iterator it = mSkills.begin(); it != mSkills.end(); it++) + for (auto it = mSkills.begin(); it != mSkills.end(); it++) { (*it).second->update(); } @@ -292,7 +292,7 @@ void SkillDialog::event(Event::Channel channel, const Event &event) } else if (event.getType() == Event::UpdateStat) { - SkillMap::iterator it = mSkills.find(event.getInt("id")); + auto it = mSkills.find(event.getInt("id")); if (it != mSkills.end()) it->second->update(); } @@ -336,8 +336,8 @@ void SkillDialog::loadSkills() if (Net::getNetworkType() == ServerInfo::TMWATHENA) { - SkillModel *model = new SkillModel(); - SkillInfo *skill = new SkillInfo; + auto *model = new SkillModel(); + auto *skill = new SkillInfo; skill->id = 1; skill->name = "basic"; skill->setIcon(""); @@ -374,7 +374,7 @@ void SkillDialog::loadSkills() setCount++; setName = XML::getProperty(set, "name", strprintf(_("Skill Set %d"), setCount)); - SkillModel *model = new SkillModel(); + auto *model = new SkillModel(); for_each_xml_child_node(node, set) { @@ -384,7 +384,7 @@ void SkillDialog::loadSkills() std::string name = XML::getProperty(node, "name", strprintf(_("Skill %d"), id)); std::string icon = XML::getProperty(node, "icon", ""); - SkillInfo *skill = new SkillInfo; + auto *skill = new SkillInfo; skill->id = id; skill->name = name; skill->setIcon(icon); @@ -417,7 +417,7 @@ void SkillDialog::loadSkills() void SkillDialog::setModifiable(int id, bool modifiable) { - SkillMap::iterator it = mSkills.find(id); + auto it = mSkills.find(id); if (it != mSkills.end()) { @@ -431,7 +431,7 @@ void SkillModel::updateVisibilities() { mVisibleSkills.clear(); - for (SkillList::iterator it = mSkills.begin(); it != mSkills.end(); it++) + for (auto it = mSkills.begin(); it != mSkills.end(); it++) { if ((*it)->visible) { diff --git a/src/gui/skilldialog.h b/src/gui/skilldialog.h index 8487c1ae..ebf29ff8 100644 --- a/src/gui/skilldialog.h +++ b/src/gui/skilldialog.h @@ -47,14 +47,14 @@ class SkillDialog : public Window, public gcn::ActionListener, public EventListe public: SkillDialog(); - ~SkillDialog(); + ~SkillDialog() override; - void event(Event::Channel channel, const Event &event); + void event(Event::Channel channel, const Event &event) override; /** * Called when receiving actions from widget. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; /** * Update the given skill's display @@ -75,7 +75,7 @@ class SkillDialog : public Window, public gcn::ActionListener, public EventListe bool hasSkills() { return !mSkills.empty(); } private: - typedef std::map<int, SkillInfo*> SkillMap; + using SkillMap = std::map<int, SkillInfo *>; SkillMap mSkills; TabbedArea *mTabs; Label *mPointsLabel; diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp index 437f9d01..d58d12ad 100644 --- a/src/gui/socialwindow.cpp +++ b/src/gui/socialwindow.cpp @@ -54,25 +54,25 @@ protected: friend class SocialWindow; SocialTab(): - mInviteDialog(NULL), - mConfirmDialog(NULL) + mInviteDialog(nullptr), + mConfirmDialog(nullptr) {} - virtual ~SocialTab() + ~SocialTab() override { // Cleanup dialogs if (mInviteDialog) { mInviteDialog->close(); mInviteDialog->scheduleDelete(); - mInviteDialog = NULL; + mInviteDialog = nullptr; } if (mConfirmDialog) { mConfirmDialog->close(); mConfirmDialog->scheduleDelete(); - mConfirmDialog = NULL; + mConfirmDialog = nullptr; } } @@ -103,15 +103,15 @@ public: mScroll->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_ALWAYS); } - ~GuildTab() + ~GuildTab() override { delete mList; - mList = 0; + mList = nullptr; delete mScroll; - mScroll = 0; + mScroll = nullptr; } - void action(const gcn::ActionEvent &event) + void action(const gcn::ActionEvent &event) override { if (event.getId() == "do invite") { @@ -124,27 +124,27 @@ public: name.c_str(), mGuild->getName().c_str())) } - mInviteDialog = NULL; + mInviteDialog = nullptr; } else if (event.getId() == "~do invite") { - mInviteDialog = NULL; + mInviteDialog = nullptr; } else if (event.getId() == "yes") { Net::getGuildHandler()->leave(mGuild->getId()); SERVER_NOTICE(strprintf(_("Guild %s quit requested."), mGuild->getName().c_str())) - mConfirmDialog = NULL; + mConfirmDialog = nullptr; } else if (event.getId() == "no") { - mConfirmDialog = NULL; + mConfirmDialog = nullptr; } } protected: - void invite() + void invite() override { // TODO - Give feedback on whether the invite succeeded mInviteDialog = new TextDialog(_("Member Invite to Guild"), @@ -155,7 +155,7 @@ protected: mInviteDialog->addActionListener(this); } - void leave() + void leave() override { mConfirmDialog = new ConfirmDialog(_("Leave Guild?"), strprintf(_("Are you sure you want to leave guild %s?"), @@ -186,15 +186,15 @@ public: mScroll->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_AUTO); } - ~PartyTab() + ~PartyTab() override { delete mList; - mList = 0; + mList = nullptr; delete mScroll; - mScroll = 0; + mScroll = nullptr; } - void action(const gcn::ActionEvent &event) + void action(const gcn::ActionEvent &event) override { if (event.getId() == "do invite") { @@ -203,27 +203,27 @@ public: if (!name.empty()) SERVER_NOTICE(strprintf(_("Invited user %s to party."), name.c_str())) - mInviteDialog = NULL; + mInviteDialog = nullptr; } else if (event.getId() == "~do invite") { - mInviteDialog = NULL; + mInviteDialog = nullptr; } else if (event.getId() == "yes") { Net::getPartyHandler()->leave(); SERVER_NOTICE(strprintf(_("Party %s quit requested."), mParty->getName().c_str())) - mConfirmDialog = NULL; + mConfirmDialog = nullptr; } else if (event.getId() == "no") { - mConfirmDialog = NULL; + mConfirmDialog = nullptr; } } protected: - void invite() + void invite() override { // TODO - Give feedback on whether the invite succeeded mInviteDialog = new TextDialog(_("Member Invite to Party"), @@ -234,7 +234,7 @@ protected: mInviteDialog->addActionListener(this); } - void leave() + void leave() override { mConfirmDialog = new ConfirmDialog(_("Leave Party?"), strprintf(_("Are you sure you want to leave party %s?"), @@ -277,7 +277,7 @@ public: mBrowserBox->getHeight() + 8); } - void handleLink(const std::string &link) + void handleLink(const std::string &link) override { if (link == "guild") { @@ -308,8 +308,8 @@ private: SocialWindow::SocialWindow() : Window(_("Social")), mGuildInvited(0), - mGuildAcceptDialog(NULL), - mPartyAcceptDialog(NULL) + mGuildAcceptDialog(nullptr), + mPartyAcceptDialog(nullptr) { setWindowName("Social"); setVisible(false); @@ -334,7 +334,7 @@ SocialWindow::SocialWindow() : place(2, 0, mLeaveButton); place(0, 1, mTabs, 4, 4); - widgetResized(NULL); + widgetResized(nullptr); mCreatePopup = new CreatePopup(); @@ -353,7 +353,7 @@ SocialWindow::~SocialWindow() { mGuildAcceptDialog->close(); mGuildAcceptDialog->scheduleDelete(); - mGuildAcceptDialog = NULL; + mGuildAcceptDialog = nullptr; mGuildInvited = 0; } @@ -362,7 +362,7 @@ SocialWindow::~SocialWindow() { mPartyAcceptDialog->close(); mPartyAcceptDialog->scheduleDelete(); - mPartyAcceptDialog = NULL; + mPartyAcceptDialog = nullptr; mPartyInviter = ""; } @@ -374,7 +374,7 @@ bool SocialWindow::addTab(Guild *guild) if (mGuilds.find(guild) != mGuilds.end()) return false; - GuildTab *tab = new GuildTab(guild); + auto *tab = new GuildTab(guild); mGuilds[guild] = tab; mTabs->addTab(tab, tab->mScroll); @@ -386,7 +386,7 @@ bool SocialWindow::addTab(Guild *guild) bool SocialWindow::removeTab(Guild *guild) { - GuildMap::iterator it = mGuilds.find(guild); + auto it = mGuilds.find(guild); if (it == mGuilds.end()) return false; @@ -404,7 +404,7 @@ bool SocialWindow::addTab(Party *party) if (mParties.find(party) != mParties.end()) return false; - PartyTab *tab = new PartyTab(party); + auto *tab = new PartyTab(party); mParties[party] = tab; mTabs->addTab(tab, tab->mScroll); @@ -416,7 +416,7 @@ bool SocialWindow::addTab(Party *party) bool SocialWindow::removeTab(Party *party) { - PartyMap::iterator it = mParties.find(party); + auto it = mParties.find(party); if (it == mParties.end()) return false; @@ -450,7 +450,7 @@ void SocialWindow::action(const gcn::ActionEvent &event) } mPartyInviter = ""; - mPartyAcceptDialog = NULL; + mPartyAcceptDialog = nullptr; } else if (event.getSource() == mGuildAcceptDialog) { @@ -467,7 +467,7 @@ void SocialWindow::action(const gcn::ActionEvent &event) } mGuildInvited = 0; - mGuildAcceptDialog = NULL; + mGuildAcceptDialog = nullptr; } else if (event.getId() == "create") { @@ -501,11 +501,11 @@ void SocialWindow::action(const gcn::ActionEvent &event) name.c_str())); } - mGuildCreateDialog = NULL; + mGuildCreateDialog = nullptr; } else if (event.getId() == "~create guild") { - mGuildCreateDialog = NULL; + mGuildCreateDialog = nullptr; } else if (event.getId() == "create party") { @@ -524,11 +524,11 @@ void SocialWindow::action(const gcn::ActionEvent &event) name.c_str())); } - mPartyCreateDialog = NULL; + mPartyCreateDialog = nullptr; } else if (event.getId() == "~create party") { - mPartyCreateDialog = NULL; + mPartyCreateDialog = nullptr; } } diff --git a/src/gui/socialwindow.h b/src/gui/socialwindow.h index 0964c999..495d9b54 100644 --- a/src/gui/socialwindow.h +++ b/src/gui/socialwindow.h @@ -49,7 +49,7 @@ class SocialWindow : public Window, gcn::ActionListener public: SocialWindow(); - ~SocialWindow(); + ~SocialWindow() override; bool addTab(Guild *guild); @@ -62,7 +62,7 @@ public: /** * Handle events. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; void showGuildInvite(const std::string &guildName, const int guildId, const std::string &inviterName); @@ -87,10 +87,10 @@ protected: ConfirmDialog *mPartyAcceptDialog; TextDialog *mPartyCreateDialog; - typedef std::map<Guild*, SocialTab*> GuildMap; + using GuildMap = std::map<Guild *, SocialTab *>; GuildMap mGuilds; - typedef std::map<Party*, SocialTab*> PartyMap; + using PartyMap = std::map<Party *, SocialTab *>; PartyMap mParties; CreatePopup *mCreatePopup; diff --git a/src/gui/specialswindow.cpp b/src/gui/specialswindow.cpp index ac1f460b..d114d6e3 100644 --- a/src/gui/specialswindow.cpp +++ b/src/gui/specialswindow.cpp @@ -94,7 +94,7 @@ void SpecialsWindow::action(const gcn::ActionEvent &event) { if (event.getId() == "use") { - SpecialEntry *disp = dynamic_cast<SpecialEntry*>(event.getSource()->getParent()); + auto *disp = dynamic_cast<SpecialEntry*>(event.getSource()->getParent()); if (disp) { @@ -127,10 +127,10 @@ void SpecialsWindow::draw(gcn::Graphics *graphics) bool foundNew = false; unsigned int found = 0; // number of entries in specialData which match mEntries - for (std::map<int, Special>::iterator it = specialData.begin(); + for (auto it = specialData.begin(); it != specialData.end(); ++it) { - std::map<int, SpecialEntry *>::iterator e = mEntries.find(it->first); + auto e = mEntries.find(it->first); if (e == mEntries.end()) { // found a new special - abort update and rebuild from scratch @@ -158,7 +158,7 @@ void SpecialsWindow::rebuild(const std::map<int, Special> &specialData) mEntries.clear(); int vPos = 0; //vertical position of next placed element - for (std::map<int, Special>::const_iterator it = specialData.begin(); + for (auto it = specialData.begin(); it != specialData.end(); ++it) { logger->log("Updating special GUI for %d", it->first); @@ -168,7 +168,7 @@ void SpecialsWindow::rebuild(const std::map<int, Special> &specialData) { info->rechargeCurrent = it->second.currentMana; info->rechargeNeeded = it->second.neededMana; - SpecialEntry* entry = new SpecialEntry(info); + auto* entry = new SpecialEntry(info); entry->setPosition(0, vPos); vPos += entry->getHeight() + 3; add(entry); @@ -184,10 +184,10 @@ void SpecialsWindow::rebuild(const std::map<int, Special> &specialData) SpecialEntry::SpecialEntry(SpecialInfo *info) : mInfo(info), - mIcon(NULL), - mLevelLabel(NULL), - mUse(NULL), - mRechargeBar(NULL) + mIcon(nullptr), + mLevelLabel(nullptr), + mUse(nullptr), + mRechargeBar(nullptr) { setSize(SPECIALS_WIDTH, SPECIALS_HEIGHT); diff --git a/src/gui/specialswindow.h b/src/gui/specialswindow.h index 75ad3ef0..1da05c5c 100644 --- a/src/gui/specialswindow.h +++ b/src/gui/specialswindow.h @@ -38,14 +38,14 @@ class SpecialsWindow : public Window, public gcn::ActionListener public: SpecialsWindow(); - ~SpecialsWindow(); + ~SpecialsWindow() override; /** * Called when receiving actions from widget. */ - void action(const gcn::ActionEvent &actionEvent); + void action(const gcn::ActionEvent &actionEvent) override; - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; bool hasSpecials() const { return !mEntries.empty(); } diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp index 430d47ed..eee832ec 100644 --- a/src/gui/statuswindow.cpp +++ b/src/gui/statuswindow.cpp @@ -54,7 +54,7 @@ class AttrDisplay : public Container DERIVED, CHANGEABLE, UNKNOWN }; - ~AttrDisplay(); + ~AttrDisplay() override; virtual std::string update(); virtual Type getType() { return UNKNOWN; } @@ -73,19 +73,19 @@ class DerDisplay : public AttrDisplay { public: DerDisplay(int id, const std::string &name); - virtual Type getType() { return DERIVED; } + Type getType() override { return DERIVED; } }; class ChangeDisplay : public AttrDisplay, gcn::ActionListener { public: ChangeDisplay(int id, const std::string &name); - std::string update(); - virtual Type getType() { return CHANGEABLE; } + std::string update() override; + Type getType() override { return CHANGEABLE; } void setPointsNeeded(int needed); private: - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; int mNeeded; @@ -284,7 +284,7 @@ void StatusWindow::event(Event::Channel channel, } else { - Attrs::iterator it = mAttrs.find(id); + auto it = mAttrs.find(id); if (it != mAttrs.end()) { it->second->update(); @@ -301,7 +301,7 @@ void StatusWindow::event(Event::Channel channel, void StatusWindow::updateAttrs() { - for (Attrs::iterator it = mAttrs.begin(); it != mAttrs.end(); it++) + for (auto it = mAttrs.begin(); it != mAttrs.end(); it++) { it->second->update(); } @@ -309,7 +309,7 @@ void StatusWindow::updateAttrs() void StatusWindow::setPointsNeeded(int id, int needed) { - Attrs::iterator it = mAttrs.find(id); + auto it = mAttrs.find(id); if (it != mAttrs.end()) { @@ -481,7 +481,7 @@ ChangeDisplay::ChangeDisplay(int id, const std::string &name): } else { - mDec = 0; + mDec = nullptr; } update(); diff --git a/src/gui/statuswindow.h b/src/gui/statuswindow.h index f866c56d..d1350bec 100644 --- a/src/gui/statuswindow.h +++ b/src/gui/statuswindow.h @@ -45,7 +45,7 @@ class StatusWindow : public Window, public EventListener public: StatusWindow(); - void event(Event::Channel channel, const Event &event); + void event(Event::Channel channel, const Event &event) override; void updateAttrs(); @@ -81,7 +81,7 @@ class StatusWindow : public Window, public EventListener gcn::Label *mCharacterPointsLabel; gcn::Label *mCorrectionPointsLabel; - typedef std::map<int, AttrDisplay*> Attrs; + using Attrs = std::map<int, AttrDisplay *>; Attrs mAttrs; }; diff --git a/src/gui/textdialog.h b/src/gui/textdialog.h index 51cb3eba..66ab3e53 100644 --- a/src/gui/textdialog.h +++ b/src/gui/textdialog.h @@ -37,14 +37,14 @@ class TextDialog : public Window, public gcn::ActionListener { public: TextDialog(const std::string &title, const std::string &msg, - Window *parent = NULL, bool autoCompleteEnabled = false); + Window *parent = nullptr, bool autoCompleteEnabled = false); - ~TextDialog(); + ~TextDialog() override; /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; /** * Get the text in the textfield diff --git a/src/gui/textpopup.h b/src/gui/textpopup.h index 374435fb..cda8d14a 100644 --- a/src/gui/textpopup.h +++ b/src/gui/textpopup.h @@ -38,7 +38,7 @@ class TextPopup : public Popup public: TextPopup(); - ~TextPopup(); + ~TextPopup() override; /** * Sets the text to be displayed. @@ -51,7 +51,7 @@ class TextPopup : public Popup */ void show(int x, int y, const std::string &str1, const std::string &str2); - void mouseMoved(gcn::MouseEvent &mouseEvent); + void mouseMoved(gcn::MouseEvent &mouseEvent) override; private: gcn::Label *mText1; diff --git a/src/gui/tradewindow.cpp b/src/gui/tradewindow.cpp index ae38f023..cf237d5a 100644 --- a/src/gui/tradewindow.cpp +++ b/src/gui/tradewindow.cpp @@ -86,13 +86,13 @@ TradeWindow::TradeWindow(): mMyItemContainer = new ItemContainer(mMyInventory.get()); mMyItemContainer->addSelectionListener(this); - ScrollArea *myScroll = new ScrollArea(mMyItemContainer); + auto *myScroll = new ScrollArea(mMyItemContainer); myScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mPartnerItemContainer = new ItemContainer(mPartnerInventory.get()); mPartnerItemContainer->addSelectionListener(this); - ScrollArea *partnerScroll = new ScrollArea(mPartnerItemContainer); + auto *partnerScroll = new ScrollArea(mPartnerItemContainer); partnerScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mMoneyLabel = new Label(strprintf(_("You get %s"), "")); diff --git a/src/gui/tradewindow.h b/src/gui/tradewindow.h index 20da4574..cf2bb70e 100644 --- a/src/gui/tradewindow.h +++ b/src/gui/tradewindow.h @@ -44,7 +44,7 @@ class TradeWindow : public Window, gcn::ActionListener, gcn::SelectionListener public: TradeWindow(); - ~TradeWindow(); + ~TradeWindow() override; /** * Displays expected money in the trade window. @@ -90,18 +90,18 @@ class TradeWindow : public Window, gcn::ActionListener, gcn::SelectionListener * Updates the labels and makes sure only one item is selected in * either my inventory or partner inventory. */ - void valueChanged(const gcn::SelectionEvent &event); + void valueChanged(const gcn::SelectionEvent &event) override; /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; /** * Closes the Trade Window, as well as telling the server that the * window has been closed. */ - void close(); + void close() override; private: enum Status @@ -117,7 +117,7 @@ class TradeWindow : public Window, gcn::ActionListener, gcn::SelectionListener */ void setStatus(Status s); - typedef const std::unique_ptr<Inventory> InventoryPtr; + using InventoryPtr = const std::unique_ptr<Inventory>; InventoryPtr mMyInventory; InventoryPtr mPartnerInventory; diff --git a/src/gui/truetypefont.cpp b/src/gui/truetypefont.cpp index 443adaa5..76706849 100644 --- a/src/gui/truetypefont.cpp +++ b/src/gui/truetypefont.cpp @@ -37,7 +37,7 @@ class TextChunk { public: TextChunk(const std::string &text, const gcn::Color &color) : - img(NULL), text(text), color(color) + img(nullptr), text(text), color(color) { } @@ -66,7 +66,7 @@ class TextChunk if (!surface) { - img = 0; + img = nullptr; return; } @@ -80,7 +80,7 @@ class TextChunk gcn::Color color; }; -typedef std::list<TextChunk>::iterator CacheIterator; +using CacheIterator = std::list<TextChunk>::iterator; static int fontCounter; @@ -120,7 +120,7 @@ void TrueTypeFont::drawString(gcn::Graphics *graphics, if (text.empty()) return; - Graphics *g = dynamic_cast<Graphics *>(graphics); + auto *g = dynamic_cast<Graphics *>(graphics); if (!g) throw "Not a valid graphics object!"; @@ -137,7 +137,7 @@ void TrueTypeFont::drawString(gcn::Graphics *graphics, bool found = false; - for (CacheIterator i = mCache.begin(); i != mCache.end(); ++i) + for (auto i = mCache.begin(); i != mCache.end(); ++i) { if (chunk == (*i)) { @@ -166,7 +166,7 @@ void TrueTypeFont::drawString(gcn::Graphics *graphics, int TrueTypeFont::getWidth(const std::string &text) const { - for (CacheIterator i = mCache.begin(); i != mCache.end(); i++) + for (auto i = mCache.begin(); i != mCache.end(); i++) { if (i->text == text) { diff --git a/src/gui/truetypefont.h b/src/gui/truetypefont.h index a01e2a62..d42400d8 100644 --- a/src/gui/truetypefont.h +++ b/src/gui/truetypefont.h @@ -52,11 +52,11 @@ class TrueTypeFont : public gcn::Font */ TrueTypeFont(const std::string &filename, int size, int style = 0); - ~TrueTypeFont(); + ~TrueTypeFont() override; - virtual int getWidth(const std::string &text) const; + int getWidth(const std::string &text) const override; - virtual int getHeight() const; + int getHeight() const override; /** * Returns the height of a line of text. This is not the visual height @@ -70,7 +70,7 @@ class TrueTypeFont : public gcn::Font */ void drawString(gcn::Graphics *graphics, const std::string &text, - int x, int y); + int x, int y) override; private: TTF_Font *mFont; diff --git a/src/gui/unregisterdialog.cpp b/src/gui/unregisterdialog.cpp index 1d510760..787865ae 100644 --- a/src/gui/unregisterdialog.cpp +++ b/src/gui/unregisterdialog.cpp @@ -130,7 +130,7 @@ void UnRegisterDialog::action(const gcn::ActionEvent &event) { mWrongDataNoticeListener->setTarget(this->mPasswordField); - OkDialog *dlg = new OkDialog(_("Error"), errorMessage.str()); + auto *dlg = new OkDialog(_("Error"), errorMessage.str()); dlg->addActionListener(mWrongDataNoticeListener); } else diff --git a/src/gui/unregisterdialog.h b/src/gui/unregisterdialog.h index 1c926082..c82d7a78 100644 --- a/src/gui/unregisterdialog.h +++ b/src/gui/unregisterdialog.h @@ -40,12 +40,12 @@ class UnRegisterDialog : public Window, public gcn::ActionListener public: UnRegisterDialog(LoginData *loginData); - ~UnRegisterDialog(); + ~UnRegisterDialog() override; /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; private: gcn::TextField *mPasswordField; diff --git a/src/gui/updaterwindow.cpp b/src/gui/updaterwindow.cpp index fe036814..1964c1bf 100644 --- a/src/gui/updaterwindow.cpp +++ b/src/gui/updaterwindow.cpp @@ -133,8 +133,8 @@ UpdaterWindow::UpdaterWindow(const std::string &updateHost, mDownloadComplete(true), mUserCancel(false), mDownloadedBytes(0), - mMemoryBuffer(NULL), - mDownload(NULL), + mMemoryBuffer(nullptr), + mDownload(nullptr), mUpdateIndex(0), mLoadUpdates(applyUpdates) { @@ -184,7 +184,7 @@ UpdaterWindow::~UpdaterWindow() mDownload->cancel(); delete mDownload; - mDownload = 0; + mDownload = nullptr; } free(mMemoryBuffer); } @@ -235,7 +235,7 @@ void UpdaterWindow::keyPressed(gcn::KeyEvent &keyEvent) if (key.getValue() == Key::ESCAPE) { - action(gcn::ActionEvent(NULL, mCancelButton->getActionEventId())); + action(gcn::ActionEvent(nullptr, mCancelButton->getActionEventId())); Client::setState(STATE_WORLD_SELECT); } else if (key.getValue() == Key::ENTER) @@ -243,11 +243,11 @@ void UpdaterWindow::keyPressed(gcn::KeyEvent &keyEvent) if (mDownloadStatus == UPDATE_COMPLETE || mDownloadStatus == UPDATE_ERROR) { - action(gcn::ActionEvent(NULL, mPlayButton->getActionEventId())); + action(gcn::ActionEvent(nullptr, mPlayButton->getActionEventId())); } else { - action(gcn::ActionEvent(NULL, mCancelButton->getActionEventId())); + action(gcn::ActionEvent(nullptr, mCancelButton->getActionEventId())); } } } @@ -271,12 +271,12 @@ void UpdaterWindow::loadNews() while (line) { mBrowserBox->addRow(line); - line = strtok(NULL, "\n"); + line = strtok(nullptr, "\n"); } // Free the memory buffer now that we don't need it anymore free(mMemoryBuffer); - mMemoryBuffer = NULL; + mMemoryBuffer = nullptr; mScrollArea->setVerticalScrollAmount(0); } @@ -284,7 +284,7 @@ void UpdaterWindow::loadNews() int UpdaterWindow::updateProgress(void *ptr, DownloadStatus status, size_t dt, size_t dn) { - UpdaterWindow *uw = reinterpret_cast<UpdaterWindow *>(ptr); + auto *uw = reinterpret_cast<UpdaterWindow *>(ptr); if (status == DOWNLOAD_STATUS_COMPLETE) { @@ -320,7 +320,7 @@ int UpdaterWindow::updateProgress(void *ptr, DownloadStatus status, size_t UpdaterWindow::memoryWrite(void *ptr, size_t size, size_t nmemb, void *stream) { - UpdaterWindow *uw = reinterpret_cast<UpdaterWindow *>(stream); + auto *uw = reinterpret_cast<UpdaterWindow *>(stream); size_t totalMem = size * nmemb; uw->mMemoryBuffer = (char*) realloc(uw->mMemoryBuffer, uw->mDownloadedBytes + totalMem); diff --git a/src/gui/updaterwindow.h b/src/gui/updaterwindow.h index 95a7600e..faf7a9a5 100644 --- a/src/gui/updaterwindow.h +++ b/src/gui/updaterwindow.h @@ -71,7 +71,7 @@ class UpdaterWindow : public Window, public gcn::ActionListener, const std::string &updatesDir, bool applyUpdates); - ~UpdaterWindow(); + ~UpdaterWindow() override; /** * Set's progress bar status @@ -94,11 +94,11 @@ class UpdaterWindow : public Window, public gcn::ActionListener, */ void loadNews(); - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; - void keyPressed(gcn::KeyEvent &keyEvent); + void keyPressed(gcn::KeyEvent &keyEvent) override; - void logic(); + void logic() override; int updateState; diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index b4ad1b1d..96a1d79c 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -48,7 +48,7 @@ extern volatile int tick_time; Viewport::Viewport(): - mMap(0), + mMap(nullptr), mMouseX(0), mMouseY(0), mPixelViewX(0.0f), @@ -56,8 +56,8 @@ Viewport::Viewport(): mDebugFlags(0), mPlayerFollowMouse(false), mLocalWalkTime(-1), - mHoverBeing(0), - mHoverItem(0) + mHoverBeing(nullptr), + mHoverItem(nullptr) { setOpaque(false); addMouseListener(this); @@ -109,7 +109,7 @@ void Viewport::draw(gcn::Graphics *gcnGraphics) return; } - Graphics *graphics = static_cast<Graphics*>(gcnGraphics); + auto *graphics = static_cast<Graphics*>(gcnGraphics); // Avoid freaking out when tick_time overflows if (tick_time < lastTick) @@ -153,7 +153,7 @@ void Viewport::draw(gcn::Graphics *gcnGraphics) } // manage shake effect - for (ShakeEffects::iterator i = mShakeEffects.begin(); + for (auto i = mShakeEffects.begin(); i != mShakeEffects.end(); i++) { @@ -239,13 +239,13 @@ void Viewport::draw(gcn::Graphics *gcnGraphics) // Draw player names, speech, and emotion sprite as needed const ActorSprites &actors = actorSpriteManager->getAll(); - for (ActorSpritesConstIterator it = actors.begin(), it_end = actors.end(); + for (auto it = actors.begin(), it_end = actors.end(); it != it_end; it++) { if ((*it)->getType() == ActorSprite::FLOOR_ITEM) continue; - Being *b = static_cast<Being*>(*it); + auto *b = static_cast<Being*>(*it); b->drawSpeech((int) mPixelViewX, (int) mPixelViewY); } @@ -256,7 +256,7 @@ void Viewport::draw(gcn::Graphics *gcnGraphics) const ActorSprites &actors = actorSpriteManager->getAll(); for (it = actors.begin(), it_end = actors.end(); it != it_end; ++it) { - Being *being = dynamic_cast<Being*>(*it); + auto *being = dynamic_cast<Being*>(*it); if (!being) continue; @@ -310,8 +310,8 @@ void Viewport::_followMouse() if (mPlayerFollowMouse && button & SDL_BUTTON(1)) { // We create a mouse event and send it to mouseDragged. - const Uint8 *keys = SDL_GetKeyboardState(NULL); - gcn::MouseEvent mouseEvent(NULL, + const Uint8 *keys = SDL_GetKeyboardState(nullptr); + gcn::MouseEvent mouseEvent(nullptr, (keys[SDLK_LSHIFT] || keys[SDLK_RSHIFT]), false, false, @@ -386,7 +386,7 @@ void Viewport::_drawDebugPath(Graphics *graphics) const ActorSprites &actors = actorSpriteManager->getAll(); for (it = actors.begin(), it_end = actors.end(); it != it_end; it++) { - Being *being = dynamic_cast<Being*>(*it); + auto *being = dynamic_cast<Being*>(*it); if (!being) continue; @@ -428,7 +428,7 @@ void Viewport::_drawPath(Graphics *graphics, const Path &path, { graphics->setColor(color); - for (Path::const_iterator i = path.begin(); i != path.end(); ++i) + for (auto i = path.begin(); i != path.end(); ++i) { int squareX = i->x - (int) mPixelViewX; int squareY = i->y - (int) mPixelViewY; @@ -648,10 +648,10 @@ void Viewport::event(Event::Channel channel, const Event &event) ActorSprite *actor = event.getActor("source"); if (mHoverBeing == actor) - mHoverBeing = 0; + mHoverBeing = nullptr; if (mHoverItem == actor) - mHoverItem = 0; + mHoverItem = nullptr; } else if (channel == Event::ConfigChannel && event.getType() == Event::ConfigOptionChanged) diff --git a/src/gui/viewport.h b/src/gui/viewport.h index 0d0f057a..f3f82ce5 100644 --- a/src/gui/viewport.h +++ b/src/gui/viewport.h @@ -59,7 +59,7 @@ class Viewport : public WindowContainer, public gcn::MouseListener, public: Viewport(); - ~Viewport(); + ~Viewport() override; /** * Sets the map displayed by the viewport. @@ -69,12 +69,12 @@ class Viewport : public WindowContainer, public gcn::MouseListener, /** * Draws the viewport. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; /** * Implements player to keep following mouse. */ - void logic(); + void logic() override; /** * Sets whether the path debug graphics are shown @@ -84,22 +84,22 @@ class Viewport : public WindowContainer, public gcn::MouseListener, /** * Handles mouse press on map. */ - void mousePressed(gcn::MouseEvent &event); + void mousePressed(gcn::MouseEvent &event) override; /** * Handles mouse move on map */ - void mouseDragged(gcn::MouseEvent &event); + void mouseDragged(gcn::MouseEvent &event) override; /** * Handles mouse button release on map. */ - void mouseReleased(gcn::MouseEvent &event); + void mouseReleased(gcn::MouseEvent &event) override; /** * Handles mouse move on map. */ - void mouseMoved(gcn::MouseEvent &event); + void mouseMoved(gcn::MouseEvent &event) override; /** * Shows a popup for an item. @@ -165,7 +165,7 @@ class Viewport : public WindowContainer, public gcn::MouseListener, void shakeScreenStop() { mShakeEffects.clear(); } - void event(Event::Channel channel, const Event &event); + void event(Event::Channel channel, const Event &event) override; private: /** @@ -209,7 +209,7 @@ class Viewport : public WindowContainer, public gcn::MouseListener, float decay; unsigned duration; }; - typedef std::list<ShakeEffect> ShakeEffects; + using ShakeEffects = std::list<ShakeEffect>; ShakeEffects mShakeEffects; bool mPlayerFollowMouse; diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index eac7ad13..d397ecfb 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -34,8 +34,8 @@ #include <guichan/font.hpp> int AvatarListBox::instances = 0; -Image *AvatarListBox::onlineIcon = 0; -Image *AvatarListBox::offlineIcon = 0; +Image *AvatarListBox::onlineIcon = nullptr; +Image *AvatarListBox::offlineIcon = nullptr; AvatarListBox::AvatarListBox(AvatarListModel *model): ListBox(model) @@ -67,11 +67,11 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics) if (!mListModel) return; - AvatarListModel* model = static_cast<AvatarListModel*>(mListModel); + auto* model = static_cast<AvatarListModel*>(mListModel); updateAlpha(); - Graphics *graphics = static_cast<Graphics*>(gcnGraphics); + auto *graphics = static_cast<Graphics*>(gcnGraphics); graphics->setColor(Theme::getThemeColor(Theme::HIGHLIGHT, (int) (mAlpha * 255.0f))); diff --git a/src/gui/widgets/avatarlistbox.h b/src/gui/widgets/avatarlistbox.h index ec6cc6c5..ab402329 100644 --- a/src/gui/widgets/avatarlistbox.h +++ b/src/gui/widgets/avatarlistbox.h @@ -36,7 +36,7 @@ class AvatarListModel : public gcn::ListModel public: virtual Avatar *getAvatarAt(int i) = 0; - std::string getElementAt(int i) + std::string getElementAt(int i) override { return getAvatarAt(i)->getName(); } }; @@ -45,14 +45,14 @@ class AvatarListBox : public ListBox public: AvatarListBox(AvatarListModel *model); - ~AvatarListBox(); + ~AvatarListBox() override; /** * Draws the list box. */ - void draw(gcn::Graphics *gcnGraphics); + void draw(gcn::Graphics *gcnGraphics) override; - void mousePressed(gcn::MouseEvent &event); + void mousePressed(gcn::MouseEvent &event) override; private: static int instances; diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index 29847639..d5b853b2 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -86,7 +86,7 @@ void BrowserBox::addRow(const std::string &row) const int fontHeight = font->getHeight(); int lineHeight = fontHeight; - if (TrueTypeFont *ttf = dynamic_cast<TrueTypeFont*>(font)) + if (auto *ttf = dynamic_cast<TrueTypeFont*>(font)) lineHeight = ttf->getLineHeight(); // Use links and user defined colors @@ -185,7 +185,7 @@ void BrowserBox::addRow(const std::string &row) int tildeWidth = font->getWidth(tilde); int x = 0; - for (TextRowIterator i = mTextRows.begin(); i != mTextRows.end(); i++) + for (auto i = mTextRows.begin(); i != mTextRows.end(); i++) { std::string row = *i; for (unsigned int j = 0; j < row.size(); ++j) @@ -259,7 +259,7 @@ struct MouseOverLink void BrowserBox::mousePressed(gcn::MouseEvent &event) { if (!mLinkHandler) return; - LinkIterator i = find_if(mLinks.begin(), mLinks.end(), + auto i = find_if(mLinks.begin(), mLinks.end(), MouseOverLink(event.getX(), event.getY())); if (i != mLinks.end()) @@ -268,7 +268,7 @@ void BrowserBox::mousePressed(gcn::MouseEvent &event) void BrowserBox::mouseMoved(gcn::MouseEvent &event) { - LinkIterator i = find_if(mLinks.begin(), mLinks.end(), + auto i = find_if(mLinks.begin(), mLinks.end(), MouseOverLink(event.getX(), event.getY())); mSelectedLink = (i != mLinks.end()) @@ -316,7 +316,7 @@ void BrowserBox::draw(gcn::Graphics *graphics) } } - for (LinePartIterator i = mLineParts.begin(); + for (auto i = mLineParts.begin(); i != mLineParts.end(); i ++) { @@ -377,7 +377,7 @@ int BrowserBox::calcHeight() const int tildeWidth = font->getWidth("~"); int lineHeight = fontHeight; - if (TrueTypeFont *ttf = dynamic_cast<TrueTypeFont*>(font)) + if (auto *ttf = dynamic_cast<TrueTypeFont*>(font)) lineHeight = ttf->getLineHeight(); gcn::Color selColor = Theme::getThemeColor(Theme::TEXT); @@ -385,7 +385,7 @@ int BrowserBox::calcHeight() mLineParts.clear(); - for (TextRowIterator i = mTextRows.begin(); i != mTextRows.end(); i++) + for (auto i = mTextRows.begin(); i != mTextRows.end(); i++) { const std::string row = *(i); bool wrapped = false; diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h index 46af14ab..5f29e72a 100644 --- a/src/gui/widgets/browserbox.h +++ b/src/gui/widgets/browserbox.h @@ -74,7 +74,7 @@ class BrowserBox : public gcn::Widget, public: BrowserBox(unsigned int mode = AUTO_SIZE, bool opaque = true); - ~BrowserBox(); + ~BrowserBox() override; /** * Sets the handler for links. @@ -124,13 +124,13 @@ class BrowserBox : public gcn::Widget, /** * Handles mouse actions. */ - void mousePressed(gcn::MouseEvent &event); - void mouseMoved(gcn::MouseEvent &event); + void mousePressed(gcn::MouseEvent &event) override; + void mouseMoved(gcn::MouseEvent &event) override; /** * Draws the browser box. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; void updateHeight(); @@ -176,7 +176,7 @@ class BrowserBox : public gcn::Widget, BACKGROUND = 2 }; - typedef std::list<std::string> TextRows; + using TextRows = std::list<std::string>; TextRows &getRows() { return mTextRows; } @@ -187,15 +187,15 @@ class BrowserBox : public gcn::Widget, private: int calcHeight(); - typedef TextRows::iterator TextRowIterator; + using TextRowIterator = TextRows::iterator; TextRows mTextRows; - typedef std::list<LinePart> LinePartList; - typedef LinePartList::iterator LinePartIterator; + using LinePartList = std::list<LinePart>; + using LinePartIterator = LinePartList::iterator; LinePartList mLineParts; - typedef std::vector<BrowserLink> Links; - typedef Links::iterator LinkIterator; + using Links = std::vector<BrowserLink>; + using LinkIterator = Links::iterator; Links mLinks; LinkHandler *mLinkHandler; diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index 9247f67a..fb0d4cbe 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -38,7 +38,7 @@ int Button::mInstances = 0; float Button::mAlpha = 1.0; ImageRect *Button::mButton; -TextPopup *Button::mTextPopup = 0; +TextPopup *Button::mTextPopup = nullptr; enum{ BUTTON_STANDARD, // 0 @@ -63,7 +63,7 @@ static ButtonData const data[BUTTON_COUNT] = { }; Button::Button(): - mButtonIcon(0) + mButtonIcon(nullptr) { init(); adjustSize(); @@ -72,7 +72,7 @@ Button::Button(): Button::Button(const std::string &caption, const std::string &actionEventId, gcn::ActionListener *listener): gcn::Button(caption), - mButtonIcon(0) + mButtonIcon(nullptr) { init(); setActionEventId(actionEventId); @@ -127,10 +127,10 @@ void Button::removeButtonIcon(bool adjustButtonSize) for (int mode = 0; mode < BUTTON_COUNT; ++mode) { delete mButtonIcon[mode]; - mButtonIcon[mode] = 0; + mButtonIcon[mode] = nullptr; } delete[] mButtonIcon; - mButtonIcon = 0; + mButtonIcon = nullptr; if (adjustButtonSize) adjustSize(); @@ -189,7 +189,7 @@ Button::~Button() // Remove the popup delete mTextPopup; - mTextPopup = 0; + mTextPopup = nullptr; } // Don' try to readjust the size when it's about to be deleted. removeButtonIcon(false); diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h index f31c3436..e4a28d80 100644 --- a/src/gui/widgets/button.h +++ b/src/gui/widgets/button.h @@ -48,12 +48,12 @@ class Button : public gcn::Button Button(const std::string &caption, const std::string &actionEventId, gcn::ActionListener *listener); - ~Button(); + ~Button() override; /** * Draws the button. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; /** * Update the alpha value to the button components. @@ -82,9 +82,9 @@ class Button : public gcn::Button void setButtonPopupText(const std::string &text) { mPopupText = text; } - void logic(); - void mouseMoved(gcn::MouseEvent &event); - void mouseExited(gcn::MouseEvent &event); + void logic() override; + void mouseMoved(gcn::MouseEvent &event) override; + void mouseExited(gcn::MouseEvent &event) override; private: void init(); diff --git a/src/gui/widgets/channeltab.h b/src/gui/widgets/channeltab.h index ad27c4c8..ec8af1cd 100644 --- a/src/gui/widgets/channeltab.h +++ b/src/gui/widgets/channeltab.h @@ -35,19 +35,19 @@ class ChannelTab : public ChatTab Channel *getChannel() const { return mChannel; } - void showHelp(); + void showHelp() override; bool handleCommand(const std::string &type, - const std::string &args); + const std::string &args) override; protected: friend class Channel; ChannelTab(Channel *channel); - ~ChannelTab(); + ~ChannelTab() override; - void handleInput(const std::string &msg); + void handleInput(const std::string &msg) override; private: Channel *mChannel; diff --git a/src/gui/widgets/chattab.h b/src/gui/widgets/chattab.h index 200ad55a..3d19a9ad 100644 --- a/src/gui/widgets/chattab.h +++ b/src/gui/widgets/chattab.h @@ -38,7 +38,7 @@ class ChatTab : public Tab, public AutoCompleteLister, public EventListener { public: ChatTab(const std::string &name); - ~ChatTab(); + ~ChatTab() override; /** * Adds a line of text to our message list. Parameters: @@ -98,17 +98,17 @@ class ChatTab : public Tab, public AutoCompleteLister, public EventListener { return false; } - void getAutoCompleteList(std::vector<std::string> &names) const; + void getAutoCompleteList(std::vector<std::string> &names) const override; virtual void saveToLogFile(std::string &msg); - void event(Event::Channel channel, const Event &event); + void event(Event::Channel channel, const Event &event) override; protected: friend class ChatWindow; friend class WhisperWindow; - virtual void setCurrent() { setFlash(false); } + void setCurrent() override { setFlash(false); } virtual void handleInput(const std::string &msg); diff --git a/src/gui/widgets/checkbox.h b/src/gui/widgets/checkbox.h index 62e196c8..6eb53c38 100644 --- a/src/gui/widgets/checkbox.h +++ b/src/gui/widgets/checkbox.h @@ -36,12 +36,12 @@ class CheckBox : public gcn::CheckBox public: CheckBox(const std::string &caption, bool selected = false); - ~CheckBox(); + ~CheckBox() override; /** * Draws the caption, then calls drawBox to draw the check box. */ - void draw(gcn::Graphics* graphics); + void draw(gcn::Graphics* graphics) override; /** * Update the alpha value to the checkbox components. @@ -51,17 +51,17 @@ class CheckBox : public gcn::CheckBox /** * Draws the check box, not the caption. */ - void drawBox(gcn::Graphics* graphics); + void drawBox(gcn::Graphics* graphics) override; /** * Called when the mouse enteres the widget area. */ - void mouseEntered(gcn::MouseEvent& event); + void mouseEntered(gcn::MouseEvent& event) override; /** * Called when the mouse leaves the widget area. */ - void mouseExited(gcn::MouseEvent& event); + void mouseExited(gcn::MouseEvent& event) override; private: static int instances; diff --git a/src/gui/widgets/container.cpp b/src/gui/widgets/container.cpp index e1b99af7..74b82f07 100644 --- a/src/gui/widgets/container.cpp +++ b/src/gui/widgets/container.cpp @@ -24,7 +24,7 @@ #include "gui/widgets/layouthelper.h" Container::Container(): - mLayoutHelper(0) + mLayoutHelper(nullptr) { setOpaque(false); } diff --git a/src/gui/widgets/container.h b/src/gui/widgets/container.h index 46b719a1..6c5caa3a 100644 --- a/src/gui/widgets/container.h +++ b/src/gui/widgets/container.h @@ -42,7 +42,7 @@ class Container : public gcn::Container { public: Container(); - ~Container(); + ~Container() override; protected: /** diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp index 07d1d887..3b26ef3a 100644 --- a/src/gui/widgets/desktop.cpp +++ b/src/gui/widgets/desktop.cpp @@ -37,7 +37,7 @@ #include "utils/stringutils.h" Desktop::Desktop() - : mWallpaper(0) + : mWallpaper(nullptr) { addWidgetListener(this); @@ -74,7 +74,7 @@ void Desktop::widgetResized(const gcn::Event &) void Desktop::draw(gcn::Graphics *graphics) { - Graphics *g = static_cast<Graphics *>(graphics); + auto *g = static_cast<Graphics *>(graphics); if (!mWallpaper || (getWidth() > mWallpaper->getWidth() || getHeight() > mWallpaper->getHeight())) diff --git a/src/gui/widgets/desktop.h b/src/gui/widgets/desktop.h index 8ecb7e03..e10813ef 100644 --- a/src/gui/widgets/desktop.h +++ b/src/gui/widgets/desktop.h @@ -47,16 +47,16 @@ class Desktop : public Container, gcn::WidgetListener { public: Desktop(); - ~Desktop(); + ~Desktop() override; /** * Has to be called after updates have been loaded. */ void reloadWallpaper(); - void widgetResized(const gcn::Event &); + void widgetResized(const gcn::Event &) override; - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; private: void setBestFittingWallpaper(); diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index ebc76184..f0b721f6 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -43,34 +43,34 @@ class DropDown : public gcn::DropDown * @param listModel the ListModel to use. * @see ListModel */ - DropDown(gcn::ListModel *listModel = 0); + DropDown(gcn::ListModel *listModel = nullptr); - ~DropDown(); + ~DropDown() override; /** * Update the alpha value to the graphic components. */ void updateAlpha(); - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; - void drawFrame(gcn::Graphics *graphics); + void drawFrame(gcn::Graphics *graphics) override; // Inherited from FocusListener - void focusLost(const gcn::Event& event); + void focusLost(const gcn::Event& event) override; // Inherited from KeyListener - void keyPressed(gcn::KeyEvent& keyEvent); + void keyPressed(gcn::KeyEvent& keyEvent) override; // Inherited from MouseListener - void mousePressed(gcn::MouseEvent& mouseEvent); + void mousePressed(gcn::MouseEvent& mouseEvent) override; - void mouseWheelMovedUp(gcn::MouseEvent& mouseEvent); + void mouseWheelMovedUp(gcn::MouseEvent& mouseEvent) override; - void mouseWheelMovedDown(gcn::MouseEvent& mouseEvent); + void mouseWheelMovedDown(gcn::MouseEvent& mouseEvent) override; protected: /** @@ -78,7 +78,7 @@ class DropDown : public gcn::DropDown * * @param graphics a Graphics object to draw with. */ - void drawButton(gcn::Graphics *graphics); + void drawButton(gcn::Graphics *graphics) override; // Add own Images. static int instances; diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp index cdb2d3c4..fa74cf20 100644 --- a/src/gui/widgets/emoteshortcutcontainer.cpp +++ b/src/gui/widgets/emoteshortcutcontainer.cpp @@ -79,7 +79,7 @@ void EmoteShortcutContainer::draw(gcn::Graphics *graphics) mBackgroundImg->setAlpha(mAlpha); } - Graphics *g = static_cast<Graphics*>(graphics); + auto *g = static_cast<Graphics*>(graphics); graphics->setFont(getFont()); diff --git a/src/gui/widgets/emoteshortcutcontainer.h b/src/gui/widgets/emoteshortcutcontainer.h index cc388580..2d62b500 100644 --- a/src/gui/widgets/emoteshortcutcontainer.h +++ b/src/gui/widgets/emoteshortcutcontainer.h @@ -38,27 +38,27 @@ class EmoteShortcutContainer : public ShortcutContainer public: EmoteShortcutContainer(); - virtual ~EmoteShortcutContainer(); + ~EmoteShortcutContainer() override; /** * Draws the items. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; /** * Handles mouse when dragged. */ - void mouseDragged(gcn::MouseEvent &event); + void mouseDragged(gcn::MouseEvent &event) override; /** * Handles mouse when pressed. */ - void mousePressed(gcn::MouseEvent &event); + void mousePressed(gcn::MouseEvent &event) override; /** * Handles mouse release. */ - void mouseReleased(gcn::MouseEvent &event); + void mouseReleased(gcn::MouseEvent &event) override; private: std::vector<const ImageSprite*> mEmoteImg; diff --git a/src/gui/widgets/flowcontainer.cpp b/src/gui/widgets/flowcontainer.cpp index d04c5153..bf34c4c7 100644 --- a/src/gui/widgets/flowcontainer.cpp +++ b/src/gui/widgets/flowcontainer.cpp @@ -57,7 +57,7 @@ void FlowContainer::widgetResized(const gcn::Event &event) int i = 0; height = 0; - for (WidgetList::iterator it = mWidgets.begin(); it != mWidgets.end(); it++) + for (auto it = mWidgets.begin(); it != mWidgets.end(); it++) { int x = i % mGridWidth * mBoxWidth; (*it)->setPosition(x, height); @@ -73,5 +73,5 @@ void FlowContainer::add(gcn::Widget *widget) { Container::add(widget); widget->setSize(mBoxWidth, mBoxHeight); - widgetResized(NULL); + widgetResized(nullptr); } diff --git a/src/gui/widgets/flowcontainer.h b/src/gui/widgets/flowcontainer.h index 0109ab64..28d148d5 100644 --- a/src/gui/widgets/flowcontainer.h +++ b/src/gui/widgets/flowcontainer.h @@ -40,7 +40,7 @@ class FlowContainer : public Container, * Invoked when a widget changes its size. This is used to determine * the new height of the container. */ - void widgetResized(const gcn::Event &event); + void widgetResized(const gcn::Event &event) override; int getBoxWidth() const { return mBoxWidth; } @@ -48,7 +48,7 @@ class FlowContainer : public Container, int getBoxHeight() const { return mBoxHeight; } - void add(gcn::Widget *widget); + void add(gcn::Widget *widget) override; private: int mBoxWidth; diff --git a/src/gui/widgets/icon.cpp b/src/gui/widgets/icon.cpp index 6b5120e6..5d7d62f7 100644 --- a/src/gui/widgets/icon.cpp +++ b/src/gui/widgets/icon.cpp @@ -27,7 +27,7 @@ #include "resources/resourcemanager.h" Icon::Icon(const std::string &file) - : mImage(0) + : mImage(nullptr) { mImage = ResourceManager::getInstance()->getImage(file); if (mImage) @@ -52,7 +52,7 @@ void Icon::draw(gcn::Graphics *g) { if (mImage) { - Graphics *graphics = static_cast<Graphics*>(g); + auto *graphics = static_cast<Graphics*>(g); const int x = (getWidth() - mImage->getWidth()) / 2; const int y = (getHeight() - mImage->getHeight()) / 2; graphics->drawImage(mImage, x, y); diff --git a/src/gui/widgets/icon.h b/src/gui/widgets/icon.h index 6945e4c9..896b26c1 100644 --- a/src/gui/widgets/icon.h +++ b/src/gui/widgets/icon.h @@ -59,7 +59,7 @@ class Icon : public gcn::Widget /** * Draws the Icon. */ - void draw(gcn::Graphics *g); + void draw(gcn::Graphics *g) override; private: Image *mImage; diff --git a/src/gui/widgets/inttextfield.h b/src/gui/widgets/inttextfield.h index 19058a46..d5829404 100644 --- a/src/gui/widgets/inttextfield.h +++ b/src/gui/widgets/inttextfield.h @@ -63,7 +63,7 @@ class IntTextField : public TextField /** * Responds to key presses. */ - void keyPressed(gcn::KeyEvent &event); + void keyPressed(gcn::KeyEvent &event) override; private: int mMin; /**< Minimum value */ diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index f15fe682..5b373bb6 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -96,7 +96,7 @@ void ItemContainer::logic() void ItemContainer::draw(gcn::Graphics *graphics) { - Graphics *g = static_cast<Graphics*>(graphics); + auto *g = static_cast<Graphics*>(graphics); g->setFont(getFont()); @@ -209,7 +209,7 @@ Item *ItemContainer::getSelectedItem() const Item *ItemContainer::getItemAt(int index) const { - std::map<int, Item*>::const_iterator i = mFilteredMap.find(index); + auto i = mFilteredMap.find(index); return i == mFilteredMap.end() ? 0 : i->second; } diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h index aba12644..fe5b73e5 100644 --- a/src/gui/widgets/itemcontainer.h +++ b/src/gui/widgets/itemcontainer.h @@ -57,33 +57,33 @@ class ItemContainer : public gcn::Widget, */ ItemContainer(Inventory *inventory); - virtual ~ItemContainer(); + ~ItemContainer() override; void hidePopup(); /** * Necessary for checking how full the inventory is. */ - void logic(); + void logic() override; /** * Draws the items. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; // KeyListener - void keyPressed(gcn::KeyEvent &event); - void keyReleased(gcn::KeyEvent &event); + void keyPressed(gcn::KeyEvent &event) override; + void keyReleased(gcn::KeyEvent &event) override; // MouseListener - void mousePressed(gcn::MouseEvent &event); - void mouseDragged(gcn::MouseEvent &event); - void mouseReleased(gcn::MouseEvent &event); - void mouseMoved(gcn::MouseEvent &event); - void mouseExited(gcn::MouseEvent &event); + void mousePressed(gcn::MouseEvent &event) override; + void mouseDragged(gcn::MouseEvent &event) override; + void mouseReleased(gcn::MouseEvent &event) override; + void mouseMoved(gcn::MouseEvent &event) override; + void mouseExited(gcn::MouseEvent &event) override; // WidgetListener - void widgetResized(const gcn::Event &event); + void widgetResized(const gcn::Event &event) override; /** * Returns the selected item. @@ -191,8 +191,8 @@ class ItemContainer : public gcn::Widget, ItemPopup *mItemPopup; - typedef std::list<gcn::SelectionListener*> SelectionListenerList; - typedef SelectionListenerList::iterator SelectionListenerIterator; + using SelectionListenerList = std::list<gcn::SelectionListener *>; + using SelectionListenerIterator = SelectionListenerList::iterator; SelectionListenerList mSelectionListeners; }; diff --git a/src/gui/widgets/itemlinkhandler.h b/src/gui/widgets/itemlinkhandler.h index e499f3e4..dd9eeedc 100644 --- a/src/gui/widgets/itemlinkhandler.h +++ b/src/gui/widgets/itemlinkhandler.h @@ -30,8 +30,8 @@ class ItemLinkHandler : public LinkHandler { public: ItemLinkHandler(); - ~ItemLinkHandler(); - void handleLink(const std::string &link); + ~ItemLinkHandler() override; + void handleLink(const std::string &link) override; private: ItemPopup *mItemPopup; diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp index 396de3bd..a43596f8 100644 --- a/src/gui/widgets/itemshortcutcontainer.cpp +++ b/src/gui/widgets/itemshortcutcontainer.cpp @@ -43,7 +43,7 @@ ItemShortcutContainer::ItemShortcutContainer(): ShortcutContainer(), mItemClicked(false), - mItemMoved(NULL) + mItemMoved(nullptr) { addMouseListener(this); addWidgetListener(this); @@ -73,7 +73,7 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics) mBackgroundImg->setAlpha(mAlpha); } - Graphics *g = static_cast<Graphics*>(graphics); + auto *g = static_cast<Graphics*>(graphics); graphics->setFont(getFont()); @@ -196,7 +196,7 @@ void ItemShortcutContainer::mousePressed(gcn::MouseEvent &event) // Convert relative to the window coordinates to absolute screen // coordinates. - viewport->showPopup(NULL, viewport->getMouseX(), viewport->getMouseY(), item); + viewport->showPopup(nullptr, viewport->getMouseX(), viewport->getMouseY(), item); } } @@ -210,13 +210,13 @@ void ItemShortcutContainer::mouseReleased(gcn::MouseEvent &event) const int index = getIndexFromGrid(event.getX(), event.getY()); if (index == -1) { - mItemMoved = NULL; + mItemMoved = nullptr; return; } if (mItemMoved) { itemShortcut->setItems(index, mItemMoved->getId()); - mItemMoved = NULL; + mItemMoved = nullptr; } else if (itemShortcut->getItem(index) && mItemClicked) { diff --git a/src/gui/widgets/itemshortcutcontainer.h b/src/gui/widgets/itemshortcutcontainer.h index 2441d2f8..55d14977 100644 --- a/src/gui/widgets/itemshortcutcontainer.h +++ b/src/gui/widgets/itemshortcutcontainer.h @@ -40,31 +40,31 @@ class ItemShortcutContainer : public ShortcutContainer public: ItemShortcutContainer(); - virtual ~ItemShortcutContainer(); + ~ItemShortcutContainer() override; /** * Draws the items. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; /** * Handles mouse when dragged. */ - void mouseDragged(gcn::MouseEvent &event); + void mouseDragged(gcn::MouseEvent &event) override; /** * Handles mouse when pressed. */ - void mousePressed(gcn::MouseEvent &event); + void mousePressed(gcn::MouseEvent &event) override; /** * Handles mouse release. */ - void mouseReleased(gcn::MouseEvent &event); + void mouseReleased(gcn::MouseEvent &event) override; private: - void mouseExited(gcn::MouseEvent &event); - void mouseMoved(gcn::MouseEvent &event); + void mouseExited(gcn::MouseEvent &event) override; + void mouseMoved(gcn::MouseEvent &event) override; bool mItemClicked; Item *mItemMoved; diff --git a/src/gui/widgets/label.h b/src/gui/widgets/label.h index f30308cd..cb7a8b1c 100644 --- a/src/gui/widgets/label.h +++ b/src/gui/widgets/label.h @@ -44,7 +44,7 @@ class Label : public gcn::Label /** * Draws the label. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; }; #endif diff --git a/src/gui/widgets/layout.cpp b/src/gui/widgets/layout.cpp index 68783ddc..ac8488e0 100644 --- a/src/gui/widgets/layout.cpp +++ b/src/gui/widgets/layout.cpp @@ -71,11 +71,11 @@ void LayoutCell::computeSizes() { assert(mType == ARRAY); - for (std::vector< std::vector< LayoutCell * > >::iterator + for (auto i = mArray->mCells.begin(), i_end = mArray->mCells.end(); i != i_end; ++i) { - for (std::vector< LayoutCell * >::iterator + for (auto j = i->begin(), j_end = i->end(); j != j_end; ++j) { LayoutCell *cell = *j; @@ -93,10 +93,10 @@ LayoutArray::LayoutArray(): mSpacing(4) LayoutArray::~LayoutArray() { - for (std::vector< std::vector< LayoutCell * > >::iterator + for (auto i = mCells.begin(), i_end = mCells.end(); i != i_end; ++i) { - for (std::vector< LayoutCell * >::iterator + for (auto j = i->begin(), j_end = i->end(); j != j_end; ++j) { delete *j; @@ -133,10 +133,10 @@ void LayoutArray::resizeGrid(int w, int h) mSizes[0].resize(w, Layout::AUTO_DEF); } - for (std::vector< std::vector< LayoutCell * > >::iterator + for (auto i = mCells.begin(), i_end = mCells.end(); i != i_end; ++i) { - i->resize(w, NULL); + i->resize(w, nullptr); } } diff --git a/src/gui/widgets/layout.h b/src/gui/widgets/layout.h index 5652bdf5..8fd7a405 100644 --- a/src/gui/widgets/layout.h +++ b/src/gui/widgets/layout.h @@ -34,7 +34,7 @@ class LayoutCell; class ContainerPlacer { public: - ContainerPlacer(gcn::Container *c = NULL, LayoutCell *l = NULL): + ContainerPlacer(gcn::Container *c = nullptr, LayoutCell *l = nullptr): mContainer(c), mCell(l) {} diff --git a/src/gui/widgets/layouthelper.h b/src/gui/widgets/layouthelper.h index b8512212..26360a9a 100644 --- a/src/gui/widgets/layouthelper.h +++ b/src/gui/widgets/layouthelper.h @@ -36,7 +36,7 @@ class LayoutHelper : public gcn::WidgetListener public: explicit LayoutHelper(gcn::Container *container); - ~LayoutHelper(); + ~LayoutHelper() override; /** * Gets the layout handler. @@ -68,7 +68,7 @@ class LayoutHelper : public gcn::WidgetListener /** * Called whenever the managed container changes size. */ - void widgetResized(const gcn::Event &event); + void widgetResized(const gcn::Event &event) override; private: Layout mLayout; /**< Layout handler */ diff --git a/src/gui/widgets/listbox.h b/src/gui/widgets/listbox.h index bc22da30..25787ca7 100644 --- a/src/gui/widgets/listbox.h +++ b/src/gui/widgets/listbox.h @@ -38,7 +38,7 @@ class ListBox : public gcn::ListBox public: ListBox(gcn::ListModel *listModel); - ~ListBox(); + ~ListBox() override; /** * Sets the font to render the text in. @@ -53,7 +53,7 @@ class ListBox : public gcn::ListBox /** * Draws the list box. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; /** * Update the alpha value to the graphic components. @@ -62,17 +62,17 @@ class ListBox : public gcn::ListBox // Inherited from KeyListener - void keyPressed(gcn::KeyEvent& keyEvent); + void keyPressed(gcn::KeyEvent& keyEvent) override; // Inherited from MouseListener - void mousePressed(gcn::MouseEvent& mouseEvent); + void mousePressed(gcn::MouseEvent& mouseEvent) override; - void mouseWheelMovedUp(gcn::MouseEvent& mouseEvent); + void mouseWheelMovedUp(gcn::MouseEvent& mouseEvent) override; - void mouseWheelMovedDown(gcn::MouseEvent& mouseEvent); + void mouseWheelMovedDown(gcn::MouseEvent& mouseEvent) override; - void mouseDragged(gcn::MouseEvent &event); + void mouseDragged(gcn::MouseEvent &event) override; private: gcn::Font *mFont; diff --git a/src/gui/widgets/passwordfield.h b/src/gui/widgets/passwordfield.h index 83e7e53b..4bed0e05 100644 --- a/src/gui/widgets/passwordfield.h +++ b/src/gui/widgets/passwordfield.h @@ -40,7 +40,7 @@ class PasswordField : public TextField /** * Draws the password field. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; }; #endif diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp index 4f341af0..1d3325ee 100644 --- a/src/gui/widgets/playerbox.cpp +++ b/src/gui/widgets/playerbox.cpp @@ -71,7 +71,7 @@ PlayerBox::~PlayerBox() { instances--; - mBeing = 0; + mBeing = nullptr; if (instances == 0) { diff --git a/src/gui/widgets/playerbox.h b/src/gui/widgets/playerbox.h index 070bd82b..68dd670e 100644 --- a/src/gui/widgets/playerbox.h +++ b/src/gui/widgets/playerbox.h @@ -39,9 +39,9 @@ class PlayerBox : public gcn::ScrollArea * Constructor. Takes the initial player character that this box should * display, which defaults to <code>NULL</code>. */ - PlayerBox(const Being *being = 0); + PlayerBox(const Being *being = nullptr); - ~PlayerBox(); + ~PlayerBox() override; /** * Sets a new player character to be displayed by this box. Setting the @@ -54,12 +54,12 @@ class PlayerBox : public gcn::ScrollArea /** * Draws the scroll area. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; /** * Draws the background and border of the scroll area. */ - void drawFrame(gcn::Graphics *graphics); + void drawFrame(gcn::Graphics *graphics) override; private: const Being *mBeing; /**< The character used for display */ diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp index 1c7cfdd1..298443e7 100644 --- a/src/gui/widgets/popup.cpp +++ b/src/gui/widgets/popup.cpp @@ -73,7 +73,7 @@ void Popup::setWindowContainer(WindowContainer *wc) void Popup::draw(gcn::Graphics *graphics) { - Graphics *g = static_cast<Graphics*>(graphics); + auto *g = static_cast<Graphics*>(graphics); g->drawImageRect(0, 0, getWidth(), getHeight(), mSkin->getBorder()); diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h index 5ec6ecd0..af37b211 100644 --- a/src/gui/widgets/popup.h +++ b/src/gui/widgets/popup.h @@ -62,7 +62,7 @@ class Popup : public Container, public gcn::MouseListener /** * Destructor. Deletes all the added widgets. */ - ~Popup(); + ~Popup() override; /** * Sets the window container to be used by new popups. @@ -72,7 +72,7 @@ class Popup : public Container, public gcn::MouseListener /** * Draws the popup. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; /** * Sets the size of this popup. @@ -84,7 +84,7 @@ class Popup : public Container, public gcn::MouseListener */ void setLocationRelativeTo(gcn::Widget *widget); - void mouseMoved(gcn::MouseEvent &event); + void mouseMoved(gcn::MouseEvent &event) override; /** * Sets the minimum width of the popup. @@ -142,7 +142,7 @@ class Popup : public Container, public gcn::MouseListener // Inherited from BasicContainer - virtual gcn::Rectangle getChildrenArea(); + gcn::Rectangle getChildrenArea() override; /** * Sets the location to display the popup. Tries to horizontally center diff --git a/src/gui/widgets/progressbar.h b/src/gui/widgets/progressbar.h index 56b2fe92..d3a4c100 100644 --- a/src/gui/widgets/progressbar.h +++ b/src/gui/widgets/progressbar.h @@ -44,12 +44,12 @@ class ProgressBar : public gcn::Widget int width = 40, int height = 7, int color = -1); - ~ProgressBar(); + ~ProgressBar() override; /** * Performs progress bar logic (fading colors) */ - void logic(); + void logic() override; /** * Update the alpha value to the graphic components. @@ -59,7 +59,7 @@ class ProgressBar : public gcn::Widget /** * Draws the progress bar. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; /** * Sets the current progress. diff --git a/src/gui/widgets/progressindicator.cpp b/src/gui/widgets/progressindicator.cpp index 9971d144..2495a62d 100644 --- a/src/gui/widgets/progressindicator.cpp +++ b/src/gui/widgets/progressindicator.cpp @@ -35,7 +35,7 @@ ProgressIndicator::ProgressIndicator() ImageSet *images = Theme::getImageSetFromTheme("progress-indicator.png", 32, 32); - Animation *anim = new Animation; + auto *anim = new Animation; for (ImageSet::size_type i = 0; i < images->size(); ++i) anim->addFrame(images->get(i), 100, 0, 0); diff --git a/src/gui/widgets/progressindicator.h b/src/gui/widgets/progressindicator.h index cb469c07..13cab227 100644 --- a/src/gui/widgets/progressindicator.h +++ b/src/gui/widgets/progressindicator.h @@ -33,10 +33,10 @@ class ProgressIndicator : public gcn::Widget { public: ProgressIndicator(); - ~ProgressIndicator(); + ~ProgressIndicator() override; - void logic(); - void draw(gcn::Graphics *graphics); + void logic() override; + void draw(gcn::Graphics *graphics) override; private: SimpleAnimation *mIndicator; diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp index b0a92784..676daede 100644 --- a/src/gui/widgets/radiobutton.cpp +++ b/src/gui/widgets/radiobutton.cpp @@ -88,7 +88,7 @@ void RadioButton::drawBox(gcn::Graphics* graphics) radioCheckedHi->setAlpha(mAlpha); } - Image *box = NULL; + Image *box = nullptr; if (isEnabled()) if (isSelected()) diff --git a/src/gui/widgets/radiobutton.h b/src/gui/widgets/radiobutton.h index 5a868fea..014acd06 100644 --- a/src/gui/widgets/radiobutton.h +++ b/src/gui/widgets/radiobutton.h @@ -35,28 +35,28 @@ class RadioButton : public gcn::RadioButton RadioButton(const std::string &caption,const std::string &group, bool marked = false); - ~RadioButton(); + ~RadioButton() override; /** * Draws the radiobutton, not the caption. */ - void drawBox(gcn::Graphics* graphics); + void drawBox(gcn::Graphics* graphics) override; /** * Implementation of the draw methods. * Thus, avoiding the rhomb around the radio button. */ - void draw(gcn::Graphics* graphics); + void draw(gcn::Graphics* graphics) override; /** * Called when the mouse enteres the widget area. */ - void mouseEntered(gcn::MouseEvent& event); + void mouseEntered(gcn::MouseEvent& event) override; /** * Called when the mouse leaves the widget area. */ - void mouseExited(gcn::MouseEvent& event); + void mouseExited(gcn::MouseEvent& event) override; private: static int instances; diff --git a/src/gui/widgets/resizegrip.cpp b/src/gui/widgets/resizegrip.cpp index da97ac69..1770fcb1 100644 --- a/src/gui/widgets/resizegrip.cpp +++ b/src/gui/widgets/resizegrip.cpp @@ -29,7 +29,7 @@ #include <guichan/graphics.hpp> -Image *ResizeGrip::gripImage = 0; +Image *ResizeGrip::gripImage = nullptr; int ResizeGrip::mInstances = 0; float ResizeGrip::mAlpha = 1.0; diff --git a/src/gui/widgets/resizegrip.h b/src/gui/widgets/resizegrip.h index 9e478cd9..d2f8ca4d 100644 --- a/src/gui/widgets/resizegrip.h +++ b/src/gui/widgets/resizegrip.h @@ -38,12 +38,12 @@ class ResizeGrip : public gcn::Widget public: ResizeGrip(const std::string &image = "resize.png"); - ~ResizeGrip(); + ~ResizeGrip() override; /** * Draws the resize grip. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; private: static Image *gripImage; /**< Resize grip image */ diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h index d3e308c7..266b5a31 100644 --- a/src/gui/widgets/scrollarea.h +++ b/src/gui/widgets/scrollarea.h @@ -56,13 +56,13 @@ class ScrollArea : public gcn::ScrollArea, public gcn::WidgetListener /** * Destructor. Also deletes the content. */ - ~ScrollArea(); + ~ScrollArea() override; /** * Logic function optionally adapts width or height of contents. This * depends on the scrollbar settings. */ - void logic(); + void logic() override; /** * Update the alpha value to the graphic components. @@ -72,12 +72,12 @@ class ScrollArea : public gcn::ScrollArea, public gcn::WidgetListener /** * Draws the scroll area. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; /** * Draws the background and border of the scroll area. */ - void drawFrame(gcn::Graphics *graphics); + void drawFrame(gcn::Graphics *graphics) override; /** * Sets whether the widget should draw its background or not. @@ -92,19 +92,19 @@ class ScrollArea : public gcn::ScrollArea, public gcn::WidgetListener /** * Called when the mouse moves in the widget area. */ - void mouseMoved(gcn::MouseEvent& event); + void mouseMoved(gcn::MouseEvent& event) override; /** * Called when the mouse enteres the widget area. */ - void mouseEntered(gcn::MouseEvent& event); + void mouseEntered(gcn::MouseEvent& event) override; /** * Called when the mouse leaves the widget area. */ - void mouseExited(gcn::MouseEvent& event); + void mouseExited(gcn::MouseEvent& event) override; - void widgetResized(const gcn::Event &event); + void widgetResized(const gcn::Event &event) override; protected: enum BUTTON_DIR { @@ -120,14 +120,14 @@ class ScrollArea : public gcn::ScrollArea, public gcn::WidgetListener void init(); void drawButton(gcn::Graphics *graphics, BUTTON_DIR dir); - void drawUpButton(gcn::Graphics *graphics); - void drawDownButton(gcn::Graphics *graphics); - void drawLeftButton(gcn::Graphics *graphics); - void drawRightButton(gcn::Graphics *graphics); - void drawVBar(gcn::Graphics *graphics); - void drawHBar(gcn::Graphics *graphics); - void drawVMarker(gcn::Graphics *graphics); - void drawHMarker(gcn::Graphics *graphics); + void drawUpButton(gcn::Graphics *graphics) override; + void drawDownButton(gcn::Graphics *graphics) override; + void drawLeftButton(gcn::Graphics *graphics) override; + void drawRightButton(gcn::Graphics *graphics) override; + void drawVBar(gcn::Graphics *graphics) override; + void drawHBar(gcn::Graphics *graphics) override; + void drawVMarker(gcn::Graphics *graphics) override; + void drawHMarker(gcn::Graphics *graphics) override; static int instances; static float mAlpha; diff --git a/src/gui/widgets/shopitems.cpp b/src/gui/widgets/shopitems.cpp index 59711754..91829131 100644 --- a/src/gui/widgets/shopitems.cpp +++ b/src/gui/widgets/shopitems.cpp @@ -52,7 +52,7 @@ void ShopItems::addItem(int id, int amount, int price) void ShopItems::addItem(int inventoryIndex, int id, int quantity, int price) { - ShopItem *item = 0; + ShopItem *item = nullptr; if (mMergeDuplicates) { item = findItem(id); @@ -99,5 +99,5 @@ ShopItem *ShopItems::findItem(int id) } } - return 0; + return nullptr; } diff --git a/src/gui/widgets/shopitems.h b/src/gui/widgets/shopitems.h index 338dc0cd..e213f67c 100644 --- a/src/gui/widgets/shopitems.h +++ b/src/gui/widgets/shopitems.h @@ -49,7 +49,7 @@ class ShopItems : public gcn::ListModel */ ShopItems(bool mergeDuplicates = false); - ~ShopItems(); + ~ShopItems() override; /** * Adds an item to the list. @@ -70,14 +70,14 @@ class ShopItems : public gcn::ListModel /** * Returns the number of items in the shop. */ - int getNumberOfElements(); + int getNumberOfElements() override; /** * Returns the name of item number i in the shop. * * @param i the index to retrieve */ - std::string getElementAt(int i); + std::string getElementAt(int i) override; /** * Returns the item number i in the shop. diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp index e2e03e18..d6dd087a 100644 --- a/src/gui/widgets/shoplistbox.cpp +++ b/src/gui/widgets/shoplistbox.cpp @@ -87,7 +87,7 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics) const gcn::Color &textColor = Theme::getThemeColor(Theme::TEXT); - Graphics *graphics = static_cast<Graphics*>(gcnGraphics); + auto *graphics = static_cast<Graphics*>(gcnGraphics); graphics->setFont(getFont()); const int fontHeight = getFont()->getHeight(); @@ -97,7 +97,7 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics) i < mListModel->getNumberOfElements(); ++i, y += mRowHeight) { - ShopItem *shopItem = mShopItems ? mShopItems->at(i) : 0; + ShopItem *shopItem = mShopItems ? mShopItems->at(i) : nullptr; if (shopItem && mPlayerMoney < shopItem->getPrice() && mPriceCheck) { diff --git a/src/gui/widgets/shoplistbox.h b/src/gui/widgets/shoplistbox.h index a1554c6e..c3d10a4a 100644 --- a/src/gui/widgets/shoplistbox.h +++ b/src/gui/widgets/shoplistbox.h @@ -44,17 +44,17 @@ class ShopListBox : public ListBox */ ShopListBox(gcn::ListModel *listModel, ShopItems *shopListModel); - ~ShopListBox(); + ~ShopListBox() override; /** * Draws the list box. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; /** * Returns the height of a row. */ - unsigned int getRowHeight() const { return mRowHeight; } + unsigned int getRowHeight() const override { return mRowHeight; } /** * gives information about the current player's money @@ -75,12 +75,12 @@ class ShopListBox : public ListBox /** ** Show ItemTooltip */ - void mouseMoved(gcn::MouseEvent &event); + void mouseMoved(gcn::MouseEvent &event) override; /** ** Hide ItemTooltip */ - void mouseExited(gcn::MouseEvent &event); + void mouseExited(gcn::MouseEvent &event) override; private: int mPlayerMoney; diff --git a/src/gui/widgets/shortcutcontainer.h b/src/gui/widgets/shortcutcontainer.h index e7f05c48..f0f9b730 100644 --- a/src/gui/widgets/shortcutcontainer.h +++ b/src/gui/widgets/shortcutcontainer.h @@ -40,33 +40,33 @@ class ShortcutContainer : public gcn::Widget, public: ShortcutContainer(); - ~ShortcutContainer() {} + ~ShortcutContainer() override {} /** * Draws the shortcuts */ - virtual void draw(gcn::Graphics *graphics) = 0; + void draw(gcn::Graphics *graphics) override = 0; /** * Invoked when a widget changes its size. This is used to determine * the new height of the container. */ - virtual void widgetResized(const gcn::Event &event); + void widgetResized(const gcn::Event &event) override; /** * Handles mouse when dragged. */ - virtual void mouseDragged(gcn::MouseEvent &event) = 0; + void mouseDragged(gcn::MouseEvent &event) override = 0; /** * Handles mouse when pressed. */ - virtual void mousePressed(gcn::MouseEvent &event) = 0; + void mousePressed(gcn::MouseEvent &event) override = 0; /** * Handles mouse release. */ - virtual void mouseReleased(gcn::MouseEvent &event) = 0; + void mouseReleased(gcn::MouseEvent &event) override = 0; int getMaxItems() const { return mMaxItems; } diff --git a/src/gui/widgets/slider.h b/src/gui/widgets/slider.h index a7ad6abf..d5b9d5ec 100644 --- a/src/gui/widgets/slider.h +++ b/src/gui/widgets/slider.h @@ -47,7 +47,7 @@ class Slider : public gcn::Slider */ Slider(double scaleStart, double scaleEnd); - ~Slider(); + ~Slider() override; /** * Update the alpha value to the graphic components. @@ -57,22 +57,22 @@ class Slider : public gcn::Slider /** * Draws the slider. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; /** * Draws the marker. */ - void drawMarker(gcn::Graphics *graphics); + void drawMarker(gcn::Graphics *graphics) override; /** * Called when the mouse enteres the widget area. */ - void mouseEntered(gcn::MouseEvent& event); + void mouseEntered(gcn::MouseEvent& event) override; /** * Called when the mouse leaves the widget area. */ - void mouseExited(gcn::MouseEvent& event); + void mouseExited(gcn::MouseEvent& event) override; private: /** diff --git a/src/gui/widgets/spacer.h b/src/gui/widgets/spacer.h index 75a83afd..11e0ac66 100644 --- a/src/gui/widgets/spacer.h +++ b/src/gui/widgets/spacer.h @@ -47,7 +47,7 @@ class Spacer : public gcn::Widget /** * Draws nothing. */ - void draw(gcn::Graphics *g) {} + void draw(gcn::Graphics *g) override {} }; #endif // SPACER_H diff --git a/src/gui/widgets/tab.h b/src/gui/widgets/tab.h index 49537e76..9dc5291e 100644 --- a/src/gui/widgets/tab.h +++ b/src/gui/widgets/tab.h @@ -35,7 +35,7 @@ class Tab : public gcn::Tab { public: Tab(); - ~Tab(); + ~Tab() override; /** * Update the alpha value to the graphic components. @@ -45,7 +45,7 @@ class Tab : public gcn::Tab /** * Draw the tabbed area. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; /** * Set the normal color fo the tab's text. diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index 52690657..cd2c0f03 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -41,7 +41,7 @@ TabbedArea::TabbedArea() : gcn::TabbedArea(), add(mArrowButton[0]); add(mArrowButton[1]); - widgetResized(NULL); + widgetResized(nullptr); } int TabbedArea::getNumberOfTabs() const @@ -51,7 +51,7 @@ int TabbedArea::getNumberOfTabs() const Tab *TabbedArea::getTab(const std::string &name) const { - TabContainer::const_iterator itr = mTabs.begin(), itr_end = mTabs.end(); + auto itr = mTabs.begin(), itr_end = mTabs.end(); while (itr != itr_end) { if ((*itr).first->getCaption() == name) @@ -59,7 +59,7 @@ Tab *TabbedArea::getTab(const std::string &name) const ++itr; } - return NULL; + return nullptr; } void TabbedArea::draw(gcn::Graphics *graphics) @@ -72,7 +72,7 @@ void TabbedArea::draw(gcn::Graphics *graphics) gcn::Widget *TabbedArea::getWidget(const std::string &name) const { - TabContainer::const_iterator itr = mTabs.begin(), itr_end = mTabs.end(); + auto itr = mTabs.begin(), itr_end = mTabs.end(); while (itr != itr_end) { if ((*itr).first->getCaption() == name) @@ -81,7 +81,7 @@ gcn::Widget *TabbedArea::getWidget(const std::string &name) const ++itr; } - return NULL; + return nullptr; } gcn::Widget *TabbedArea::getCurrentWidget() @@ -89,7 +89,7 @@ gcn::Widget *TabbedArea::getCurrentWidget() if (gcn::Tab *tab = getSelectedTab()) return getWidget(tab->getCaption()); - return NULL; + return nullptr; } void TabbedArea::addTab(gcn::Tab* tab, gcn::Widget* widget) @@ -119,7 +119,7 @@ void TabbedArea::removeTab(Tab *tab) if (getNumberOfTabs() > 1) setSelectedTab(std::max(0, getSelectedTabIndex() - 1)); else - mSelectedTab = 0; + mSelectedTab = nullptr; } TabContainer::iterator iter; @@ -163,7 +163,7 @@ void TabbedArea::mousePressed(gcn::MouseEvent &mouseEvent) { gcn::Widget *widget = mTabContainer->getWidgetAt(mouseEvent.getX(), mouseEvent.getY()); - gcn::Tab *tab = dynamic_cast<gcn::Tab*>(widget); + auto *tab = dynamic_cast<gcn::Tab*>(widget); if (tab) { @@ -180,7 +180,7 @@ void TabbedArea::setSelectedTab(gcn::Tab *tab) if (Tab *newTab = dynamic_cast<Tab*>(tab)) newTab->setCurrent(); - widgetResized(NULL); + widgetResized(nullptr); } void TabbedArea::widgetResized(const gcn::Event &event) diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h index b43078a4..53bb2bb2 100644 --- a/src/gui/widgets/tabbedarea.h +++ b/src/gui/widgets/tabbedarea.h @@ -44,7 +44,7 @@ class TabbedArea : public gcn::TabbedArea, public gcn::WidgetListener /** * Draw the tabbed area. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; /** * Return how many tabs have been created. @@ -74,7 +74,7 @@ class TabbedArea : public gcn::TabbedArea, public gcn::WidgetListener * @param tab The tab widget for the tab. * @param widget The widget to view when the tab is selected. */ - void addTab(gcn::Tab* tab, gcn::Widget* widget); + void addTab(gcn::Tab* tab, gcn::Widget* widget) override; /** * Add a tab. Overridden since it needs to create an instance of Tab @@ -83,7 +83,7 @@ class TabbedArea : public gcn::TabbedArea, public gcn::WidgetListener * @param caption The Caption to display * @param widget The widget to show when tab is selected */ - void addTab(const std::string &caption, gcn::Widget *widget); + void addTab(const std::string &caption, gcn::Widget *widget) override; /** * Overload the remove tab function as it's broken in guichan 0.8. @@ -93,27 +93,27 @@ class TabbedArea : public gcn::TabbedArea, public gcn::WidgetListener /** * Overload the logic function since it's broken in guichan 0.8. */ - void logic(); + void logic() override; int getContainerHeight() const { return mWidgetContainer->getHeight(); } - void setSelectedTab(unsigned int index) + void setSelectedTab(unsigned int index) override { gcn::TabbedArea::setSelectedTab(index); } - void setSelectedTab(gcn::Tab *tab); + void setSelectedTab(gcn::Tab *tab) override; - void widgetResized(const gcn::Event &event); + void widgetResized(const gcn::Event &event) override; void adjustTabPositions(); - void action(const gcn::ActionEvent& actionEvent); + void action(const gcn::ActionEvent& actionEvent) override; // Inherited from MouseListener - void mousePressed(gcn::MouseEvent &mouseEvent); + void mousePressed(gcn::MouseEvent &mouseEvent) override; private: - typedef std::vector< std::pair<gcn::Tab*, gcn::Widget*> > TabContainer; + using TabContainer = std::vector<std::pair<gcn::Tab *, gcn::Widget *>>; /** The tab arrows */ Button *mArrowButton[2]; diff --git a/src/gui/widgets/table.cpp b/src/gui/widgets/table.cpp index 08aae006..465fbc61 100644 --- a/src/gui/widgets/table.cpp +++ b/src/gui/widgets/table.cpp @@ -40,9 +40,9 @@ class GuiTableActionListener : public gcn::ActionListener public: GuiTableActionListener(GuiTable *_table, gcn::Widget *_widget, int _row, int _column); - virtual ~GuiTableActionListener(); + ~GuiTableActionListener() override; - virtual void action(const gcn::ActionEvent& actionEvent); + void action(const gcn::ActionEvent& actionEvent) override; protected: GuiTable *mTable; @@ -70,7 +70,7 @@ GuiTableActionListener::~GuiTableActionListener() if (mWidget) { mWidget->removeActionListener(this); - mWidget->_setParent(NULL); + mWidget->_setParent(nullptr); } } @@ -87,10 +87,10 @@ GuiTable::GuiTable(TableModel *initial_model, gcn::Color background, mWrappingEnabled(false), mOpaque(opacity), mBackgroundColor(background), - mModel(NULL), + mModel(nullptr), mSelectedRow(0), mSelectedColumn(0), - mTopWidget(NULL) + mTopWidget(nullptr) { setModel(initial_model); setFocusable(true); @@ -367,7 +367,7 @@ void GuiTable::moveToBottom(gcn::Widget *widget) { gcn::Widget::moveToBottom(widget); if (widget == mTopWidget) - mTopWidget = NULL; + mTopWidget = nullptr; } gcn::Rectangle GuiTable::getChildrenArea() const @@ -484,7 +484,7 @@ void GuiTable::modelUpdated(bool completed) } else { // before the update? - mTopWidget = NULL; // No longer valid in general + mTopWidget = nullptr; // No longer valid in general uninstallActionListeners(); } } @@ -503,10 +503,10 @@ gcn::Widget *GuiTable::getWidgetAt(int x, int y) const if (w && w->isFocusable()) return w; else - return NULL; // Grab the event locally + return nullptr; // Grab the event locally } else - return NULL; + return nullptr; } int GuiTable::getRowForY(int y) const diff --git a/src/gui/widgets/table.h b/src/gui/widgets/table.h index 1a412b6f..a9202022 100644 --- a/src/gui/widgets/table.h +++ b/src/gui/widgets/table.h @@ -50,10 +50,10 @@ class GuiTable : public gcn::Widget, friend class GuiTableActionListener; public: - GuiTable(TableModel * initial_model = NULL, gcn::Color background = 0xffffff, + GuiTable(TableModel * initial_model = nullptr, gcn::Color background = 0xffffff, bool opacity = true); - virtual ~GuiTable(); + ~GuiTable() override; /** * Retrieves the active table model @@ -101,18 +101,18 @@ public: void setLinewiseSelection(bool linewise); // Inherited from Widget - virtual void draw(gcn::Graphics* graphics); + void draw(gcn::Graphics* graphics) override; virtual gcn::Widget *getWidgetAt(int x, int y) const; - virtual void moveToTop(gcn::Widget *child); + void moveToTop(gcn::Widget *child) override; - virtual void moveToBottom(gcn::Widget *child); + void moveToBottom(gcn::Widget *child) override; - virtual void _setFocusHandler(gcn::FocusHandler* focusHandler); + void _setFocusHandler(gcn::FocusHandler* focusHandler) override; // Inherited from KeyListener - virtual void keyPressed(gcn::KeyEvent& keyEvent); + void keyPressed(gcn::KeyEvent& keyEvent) override; /** * Sets the table to be opaque, that is sets the table @@ -131,16 +131,16 @@ public: virtual bool isOpaque() const {return mOpaque;} // Inherited from MouseListener - virtual void mousePressed(gcn::MouseEvent& mouseEvent); + void mousePressed(gcn::MouseEvent& mouseEvent) override; - virtual void mouseWheelMovedUp(gcn::MouseEvent& mouseEvent); + void mouseWheelMovedUp(gcn::MouseEvent& mouseEvent) override; - virtual void mouseWheelMovedDown(gcn::MouseEvent& mouseEvent); + void mouseWheelMovedDown(gcn::MouseEvent& mouseEvent) override; - virtual void mouseDragged(gcn::MouseEvent& mouseEvent); + void mouseDragged(gcn::MouseEvent& mouseEvent) override; // Constraints inherited from TableModelListener - virtual void modelUpdated(bool); + void modelUpdated(bool) override; protected: /** Frees all action listeners on inner widgets. */ diff --git a/src/gui/widgets/tablemodel.cpp b/src/gui/widgets/tablemodel.cpp index 501e9c31..5273e929 100644 --- a/src/gui/widgets/tablemodel.cpp +++ b/src/gui/widgets/tablemodel.cpp @@ -37,13 +37,13 @@ void TableModel::removeListener(TableModelListener *listener) void TableModel::signalBeforeUpdate() { - for (std::set<TableModelListener *>::const_iterator it = listeners.begin(); it != listeners.end(); it++) + for (auto it = listeners.begin(); it != listeners.end(); it++) (*it)->modelUpdated(false); } void TableModel::signalAfterUpdate() { - for (std::set<TableModelListener *>::const_iterator it = listeners.begin(); it != listeners.end(); it++) + for (auto it = listeners.begin(); it != listeners.end(); it++) (*it)->modelUpdated(true); } diff --git a/src/gui/widgets/tablemodel.h b/src/gui/widgets/tablemodel.h index ca657415..2e36992a 100644 --- a/src/gui/widgets/tablemodel.h +++ b/src/gui/widgets/tablemodel.h @@ -101,7 +101,7 @@ class StaticTableModel : public TableModel { public: StaticTableModel(int width, int height); - virtual ~StaticTableModel(); + ~StaticTableModel() override; /** * Inserts a widget into the table model. @@ -130,13 +130,13 @@ public: */ virtual void resize(); - virtual int getRows() const; - virtual int getColumns() const; - virtual int getRowHeight() const; + int getRows() const override; + int getColumns() const override; + int getRowHeight() const override; virtual int getWidth() const; virtual int getHeight() const; - virtual int getColumnWidth(int index) const; - virtual gcn::Widget *getElementAt(int row, int column) const; + int getColumnWidth(int index) const override; + gcn::Widget *getElementAt(int row, int column) const override; protected: int mRows, mColumns; diff --git a/src/gui/widgets/textbox.h b/src/gui/widgets/textbox.h index dc003036..bcf09ee2 100644 --- a/src/gui/widgets/textbox.h +++ b/src/gui/widgets/textbox.h @@ -52,7 +52,7 @@ class TextBox : public gcn::TextBox /** * Draws the text. */ - void draw(gcn::Graphics *graphics) + void draw(gcn::Graphics *graphics) override { setForegroundColor(*mTextColor); gcn::TextBox::draw(graphics); diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index 35ce09c5..1609e002 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -46,8 +46,8 @@ ImageRect TextField::skin; TextField::TextField(const std::string &text, bool loseFocusOnTab): gcn::TextField(text), mNumeric(false), - mAutoComplete(NULL), - mHistory(NULL) + mAutoComplete(nullptr), + mHistory(nullptr) { setFrameSize(2); @@ -203,7 +203,7 @@ void TextField::keyPressed(gcn::KeyEvent &keyEvent) if (mHistory && !mHistory->atEnd()) { // Move forward through the history - TextHistoryIterator prevHist = mHistory->current++; + auto prevHist = mHistory->current++; if (!mHistory->atEnd()) { @@ -324,7 +324,7 @@ void TextField::autoComplete() if (newName == "" && mHistory) { - TextHistoryIterator i = mHistory->history.begin(); + auto i = mHistory->history.begin(); std::vector<std::string> nameList; while (i != mHistory->history.end()) diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h index bf60cbc3..b1b7a6a4 100644 --- a/src/gui/widgets/textfield.h +++ b/src/gui/widgets/textfield.h @@ -30,8 +30,8 @@ class TextInput; class ImageRect; class TextField; -typedef std::list<std::string> TextHistoryList; -typedef TextHistoryList::iterator TextHistoryIterator; +using TextHistoryList = std::list<std::string>; +using TextHistoryIterator = TextHistoryList::iterator; struct TextHistory { TextHistoryList history; /**< Command history. */ @@ -80,12 +80,12 @@ class TextField : public gcn::TextField * Constructor, initializes the text field with the given string. */ TextField(const std::string &text = "", bool loseFocusOnTab = true); - ~TextField(); + ~TextField() override; /** * Draws the text field. */ - virtual void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; /** * Update the alpha value to the graphic components. @@ -95,7 +95,7 @@ class TextField : public gcn::TextField /** * Draws the background and border. */ - void drawFrame(gcn::Graphics *graphics); + void drawFrame(gcn::Graphics *graphics) override; /** * Determine whether the field should be numeric or not @@ -114,7 +114,7 @@ class TextField : public gcn::TextField /** * Processes one keypress. */ - void keyPressed(gcn::KeyEvent &keyEvent); + void keyPressed(gcn::KeyEvent &keyEvent) override; /** * Handle text input (should possibly be new event in Guichan). diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp index b0963d30..d6ef172c 100644 --- a/src/gui/widgets/textpreview.cpp +++ b/src/gui/widgets/textpreview.cpp @@ -38,7 +38,7 @@ TextPreview::TextPreview(const std::string &text): mTextAlpha = false; mFont = gui->getFont(); mTextColor = &Theme::getThemeColor(Theme::TEXT); - mTextBGColor = NULL; + mTextBGColor = nullptr; mBGColor = &Theme::getThemeColor(Theme::BACKGROUND); mOpaque = false; } @@ -64,7 +64,7 @@ void TextPreview::draw(gcn::Graphics* graphics) if (mTextBGColor && typeid(*mFont) == typeid(TrueTypeFont)) { - TrueTypeFont *font = static_cast<TrueTypeFont*>(mFont); + auto *font = static_cast<TrueTypeFont*>(mFont); int x = font->getWidth(mText) + 1 + 2 * ((mOutline || mShadow) ? 1 :0); int y = font->getHeight() + 1 + 2 * ((mOutline || mShadow) ? 1 : 0); graphics->setColor(gcn::Color((int) mTextBGColor->r, diff --git a/src/gui/widgets/textpreview.h b/src/gui/widgets/textpreview.h index 6a0cb28b..0cda7c8b 100644 --- a/src/gui/widgets/textpreview.h +++ b/src/gui/widgets/textpreview.h @@ -110,7 +110,7 @@ class TextPreview : public gcn::Widget * * @param graphics graphics to draw into */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; /** * Set opacity for this widget (whether or not to show the background diff --git a/src/gui/widgets/vertcontainer.cpp b/src/gui/widgets/vertcontainer.cpp index e21e9d75..ad87788f 100644 --- a/src/gui/widgets/vertcontainer.cpp +++ b/src/gui/widgets/vertcontainer.cpp @@ -45,7 +45,7 @@ void VertContainer::clear() void VertContainer::widgetResized(const gcn::Event &event) { - for (WidgetListIterator it = mWidgets.begin(); it != mWidgets.end(); it++) + for (auto it = mWidgets.begin(); it != mWidgets.end(); it++) { (*it)->setWidth(getWidth()); } diff --git a/src/gui/widgets/vertcontainer.h b/src/gui/widgets/vertcontainer.h index c2403afb..439f7ca1 100644 --- a/src/gui/widgets/vertcontainer.h +++ b/src/gui/widgets/vertcontainer.h @@ -34,9 +34,9 @@ class VertContainer : public Container, public gcn::WidgetListener { public: VertContainer(int spacing); - virtual void add(gcn::Widget *widget); - virtual void clear(); - void widgetResized(const gcn::Event &event); + void add(gcn::Widget *widget) override; + void clear() override; + void widgetResized(const gcn::Event &event) override; private: int mSpacing; diff --git a/src/gui/widgets/whispertab.h b/src/gui/widgets/whispertab.h index a0dcfc14..0f01bacc 100644 --- a/src/gui/widgets/whispertab.h +++ b/src/gui/widgets/whispertab.h @@ -34,12 +34,12 @@ class WhisperTab : public ChatTab public: const std::string &getNick() const { return mNick; } - void showHelp(); + void showHelp() override; bool handleCommand(const std::string &type, - const std::string &args); + const std::string &args) override; - void saveToLogFile(std::string &msg); + void saveToLogFile(std::string &msg) override; protected: friend class ChatWindow; @@ -51,13 +51,13 @@ class WhisperTab : public ChatTab */ WhisperTab(const std::string &nick); - ~WhisperTab(); + ~WhisperTab() override; - void handleInput(const std::string &msg); + void handleInput(const std::string &msg) override; - void handleCommand(const std::string &msg); + void handleCommand(const std::string &msg) override; - bool checkNotify(Own) const + bool checkNotify(Own) const override { return true; } private: diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index c8788c75..05638470 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -44,9 +44,9 @@ int Window::mouseResize = 0; Window::Window(const std::string &caption, bool modal, Window *parent, const std::string &skin): gcn::Window(caption), - mGrip(0), + mGrip(nullptr), mParent(parent), - mLayout(NULL), + mLayout(nullptr), mWindowName("window"), mShowTitle(true), mModal(modal), @@ -114,7 +114,7 @@ void Window::setWindowContainer(WindowContainer *wc) void Window::draw(gcn::Graphics *graphics) { - Graphics *g = static_cast<Graphics*>(graphics); + auto *g = static_cast<Graphics*>(graphics); g->drawImageRect(0, 0, getWidth(), getHeight(), mSkin->getBorder()); @@ -260,7 +260,7 @@ void Window::setResizable(bool r) { remove(mGrip); delete mGrip; - mGrip = 0; + mGrip = nullptr; } } @@ -757,7 +757,7 @@ void Window::reflowLayout(int w, int h) assert(mLayout); mLayout->reflow(w, h); delete mLayout; - mLayout = NULL; + mLayout = nullptr; setContentSize(w, h); } diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index fc44ec5f..fe2b217c 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -57,12 +57,12 @@ class Window : public gcn::Window, gcn::WidgetListener * @param skin The location where the window's skin XML can be found. */ Window(const std::string &caption = "Window", bool modal = false, - Window *parent = NULL, const std::string &skin = "window.xml"); + Window *parent = nullptr, const std::string &skin = "window.xml"); /** * Destructor. Deletes all the added widgets. */ - ~Window(); + ~Window() override; /** * Sets the window container to be used by new windows. @@ -72,7 +72,7 @@ class Window : public gcn::Window, gcn::WidgetListener /** * Draws the window. */ - void draw(gcn::Graphics *graphics); + void draw(gcn::Graphics *graphics) override; /** * Sets the size of this window. @@ -100,12 +100,12 @@ class Window : public gcn::Window, gcn::WidgetListener /** * Called whenever the widget changes size. */ - void widgetResized(const gcn::Event &event); + void widgetResized(const gcn::Event &event) override; /** * Called whenever the widget is hidden. */ - virtual void widgetHidden(const gcn::Event &event); + void widgetHidden(const gcn::Event &event) override; /** * Sets whether or not the window has a close button. @@ -215,31 +215,31 @@ class Window : public gcn::Window, gcn::WidgetListener /** * Starts window resizing when appropriate. */ - void mousePressed(gcn::MouseEvent &event); + void mousePressed(gcn::MouseEvent &event) override; /** * Implements window resizing and makes sure the window is not * dragged/resized outside of the screen. */ - void mouseDragged(gcn::MouseEvent &event); + void mouseDragged(gcn::MouseEvent &event) override; /** * Implements custom cursor image changing context, based on mouse * relative position. */ - void mouseMoved(gcn::MouseEvent &event); + void mouseMoved(gcn::MouseEvent &event) override; /** * When the mouse button has been let go, this ensures that the mouse * custom cursor is restored back to it's standard image. */ - void mouseReleased(gcn::MouseEvent &event); + void mouseReleased(gcn::MouseEvent &event) override; /** * When the mouse leaves the window this ensures that the custom cursor * is restored back to it's standard image. */ - void mouseExited(gcn::MouseEvent &event); + void mouseExited(gcn::MouseEvent &event) override; /** * Sets the name of the window. This is not the window title. diff --git a/src/gui/widgets/windowcontainer.cpp b/src/gui/widgets/windowcontainer.cpp index 5cff4999..c7ac5d99 100644 --- a/src/gui/widgets/windowcontainer.cpp +++ b/src/gui/widgets/windowcontainer.cpp @@ -25,7 +25,7 @@ #include "utils/dtor.h" -WindowContainer *windowContainer = NULL; +WindowContainer *windowContainer = nullptr; void WindowContainer::logic() { @@ -43,7 +43,7 @@ void WindowContainer::scheduleDelete(gcn::Widget *widget) void WindowContainer::adjustAfterResize(int oldScreenWidth, int oldScreenHeight) { - for (WidgetListIterator i = mWidgets.begin(); i != mWidgets.end(); ++i) - if (Window *window = dynamic_cast<Window*>(*i)) + for (auto i = mWidgets.begin(); i != mWidgets.end(); ++i) + if (auto *window = dynamic_cast<Window*>(*i)) window->adjustPositionAfterResize(oldScreenWidth, oldScreenHeight); } diff --git a/src/gui/widgets/windowcontainer.h b/src/gui/widgets/windowcontainer.h index 1da5a2cd..3e01bb36 100644 --- a/src/gui/widgets/windowcontainer.h +++ b/src/gui/widgets/windowcontainer.h @@ -37,7 +37,7 @@ class WindowContainer : public Container * Do GUI logic. This functions adds automatic deletion of objects that * volunteered to be deleted. */ - void logic(); + void logic() override; /** * Schedule a widget for deletion. It will be deleted at the start of @@ -55,8 +55,8 @@ class WindowContainer : public Container /** * List of widgets that are scheduled to be deleted. */ - typedef std::list<gcn::Widget*> Widgets; - typedef Widgets::iterator WidgetIterator; + using Widgets = std::list<gcn::Widget *>; + using WidgetIterator = Widgets::iterator; Widgets mDeathList; }; diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index 9a53479e..5b13d0f3 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -46,7 +46,7 @@ extern Window *statusWindow; extern Window *socialWindow; WindowMenu::WindowMenu(): - mEmotePopup(0) + mEmotePopup(nullptr) { int x = 0, h = 0; @@ -84,7 +84,7 @@ WindowMenu::~WindowMenu() void WindowMenu::action(const gcn::ActionEvent &event) { - Window *window = 0; + Window *window = nullptr; if (event.getId() == ":-)") { @@ -104,7 +104,7 @@ void WindowMenu::action(const gcn::ActionEvent &event) else { windowContainer->scheduleDelete(mEmotePopup); - mEmotePopup = 0; + mEmotePopup = nullptr; } } else if (event.getId() == "Status") @@ -159,7 +159,7 @@ void WindowMenu::valueChanged(const gcn::SelectionEvent &event) Net::getPlayerHandler()->emote(emote); windowContainer->scheduleDelete(mEmotePopup); - mEmotePopup = 0; + mEmotePopup = nullptr; } } @@ -180,7 +180,7 @@ void WindowMenu::addButton(const std::string& text, int &x, int &h, const std::string& iconPath, KeyboardConfig::KeyAction key) { - Button *btn = new Button("", text, this); + auto *btn = new Button("", text, this); if (!iconPath.empty() && btn->setButtonIcon(iconPath)) { btn->setButtonPopupText(createShortcutCaption(text, key)); @@ -199,9 +199,9 @@ void WindowMenu::addButton(const std::string& text, int &x, int &h, void WindowMenu::updatePopUpCaptions() { - for (WidgetList::iterator it = mWidgets.begin(); it != mWidgets.end(); ++it) + for (auto it = mWidgets.begin(); it != mWidgets.end(); ++it) { - Button *button = dynamic_cast<Button*> (*it); + auto *button = dynamic_cast<Button*> (*it); if (!button) continue; diff --git a/src/gui/windowmenu.h b/src/gui/windowmenu.h index ed2ea8df..92b3b9b4 100644 --- a/src/gui/windowmenu.h +++ b/src/gui/windowmenu.h @@ -43,11 +43,11 @@ class WindowMenu : public Container, { public: WindowMenu(); - ~WindowMenu(); + ~WindowMenu() override; - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; - void valueChanged(const gcn::SelectionEvent &event); + void valueChanged(const gcn::SelectionEvent &event) override; /** * Update the pop-up captions with new key shortcuts. diff --git a/src/gui/worldselectdialog.cpp b/src/gui/worldselectdialog.cpp index f6084f32..f2b31085 100644 --- a/src/gui/worldselectdialog.cpp +++ b/src/gui/worldselectdialog.cpp @@ -51,14 +51,14 @@ class WorldListModel : public gcn::ListModel { } - virtual ~WorldListModel() {} + ~WorldListModel() override {} - int getNumberOfElements() + int getNumberOfElements() override { return mWorlds.size(); } - std::string getElementAt(int i) + std::string getElementAt(int i) override { const WorldInfo *si = mWorlds[i]; return si->name + " (" + toString(si->online_users) + ")"; @@ -72,7 +72,7 @@ WorldSelectDialog::WorldSelectDialog(Worlds worlds): { mWorldListModel = new WorldListModel(worlds); mWorldList = new ListBox(mWorldListModel); - ScrollArea *worldsScroll = new ScrollArea(mWorldList); + auto *worldsScroll = new ScrollArea(mWorldList); mChangeLoginButton = new Button(_("Change Login"), "login", this); mChooseWorld = new Button(_("Choose World"), "world", this); @@ -130,11 +130,11 @@ void WorldSelectDialog::keyPressed(gcn::KeyEvent &keyEvent) if (key.getValue() == Key::ESCAPE) { - action(gcn::ActionEvent(NULL, mChangeLoginButton->getActionEventId())); + action(gcn::ActionEvent(nullptr, mChangeLoginButton->getActionEventId())); } else if (key.getValue() == Key::ENTER) { - action(gcn::ActionEvent(NULL, mChooseWorld->getActionEventId())); + action(gcn::ActionEvent(nullptr, mChooseWorld->getActionEventId())); } } diff --git a/src/gui/worldselectdialog.h b/src/gui/worldselectdialog.h index 368b005b..f2b74582 100644 --- a/src/gui/worldselectdialog.h +++ b/src/gui/worldselectdialog.h @@ -45,16 +45,16 @@ class WorldSelectDialog : public Window, public gcn::ActionListener, public: WorldSelectDialog(Worlds worlds); - ~WorldSelectDialog(); + ~WorldSelectDialog() override; /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event); + void action(const gcn::ActionEvent &event) override; - void keyPressed(gcn::KeyEvent &keyEvent); + void keyPressed(gcn::KeyEvent &keyEvent) override; - void mouseClicked(gcn::MouseEvent &mouseEvent); + void mouseClicked(gcn::MouseEvent &mouseEvent) override; private: WorldListModel *mWorldListModel; |