diff options
Diffstat (limited to 'src')
73 files changed, 710 insertions, 622 deletions
diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp index 2e4da8cbe..d530a1594 100644 --- a/src/gui/widgets/itemshortcutcontainer.cpp +++ b/src/gui/widgets/itemshortcutcontainer.cpp @@ -45,7 +45,7 @@ #include "debug.h" -ItemShortcutContainer::ItemShortcutContainer(unsigned number): +ItemShortcutContainer::ItemShortcutContainer(const unsigned number) : ShortcutContainer(), mItemClicked(false), mItemMoved(nullptr), @@ -104,7 +104,7 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics) mBackgroundImg->setAlpha(mAlpha); } - Graphics *g = static_cast<Graphics*>(graphics); + Graphics *const g = static_cast<Graphics*>(graphics); graphics->setFont(getFont()); @@ -117,7 +117,7 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics) } } - Inventory *inv = PlayerInfo::getInventory(); + const Inventory *const inv = PlayerInfo::getInventory(); if (!inv) return; @@ -142,12 +142,12 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics) // this is item if (itemId < SPELL_MIN_ID) { - Item *item = inv->findItem(itemId, itemColor); + const Item *const item = inv->findItem(itemId, itemColor); if (item) { // Draw item icon. - Image* image = item->getImage(); + Image *const image = item->getImage(); if (image) { @@ -170,12 +170,13 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics) } else if (itemId < SKILL_MIN_ID && spellManager) { // this is magic shortcut - TextCommand *spell = spellManager->getSpellByItem(itemId); + const TextCommand *const spell = spellManager + ->getSpellByItem(itemId); if (spell) { if (!spell->isEmpty()) { - Image* image = spell->getImage(); + Image *const image = spell->getImage(); if (image) { @@ -190,10 +191,11 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics) } else if (skillDialog) { - SkillInfo *skill = skillDialog->getSkill(itemId - SKILL_MIN_ID); + const SkillInfo *const skill = skillDialog->getSkill( + itemId - SKILL_MIN_ID); if (skill) { - Image* image = skill->icon; + Image *const image = skill->icon; if (image) { @@ -210,7 +212,7 @@ void ItemShortcutContainer::draw(gcn::Graphics *graphics) if (mItemMoved) { // Draw the item image being dragged by the cursor. - Image* image = mItemMoved->getImage(); + const Image *const image = mItemMoved->getImage(); if (image) { const int tPosX = mCursorPosX - (image->mBounds.w / 2); @@ -250,7 +252,7 @@ void ItemShortcutContainer::mouseDragged(gcn::MouseEvent &event) if (!PlayerInfo::getInventory()) return; - Item *item = PlayerInfo::getInventory()->findItem( + Item *const item = PlayerInfo::getInventory()->findItem( itemId, itemColor); if (item) @@ -261,7 +263,8 @@ void ItemShortcutContainer::mouseDragged(gcn::MouseEvent &event) } else if (itemId < SKILL_MIN_ID && spellManager) { - TextCommand *spell = spellManager->getSpellByItem(itemId); + const TextCommand *const spell = spellManager->getSpellByItem( + itemId); if (spell) itemShortcut[mNumber]->removeItem(index); } @@ -372,7 +375,8 @@ void ItemShortcutContainer::mouseMoved(gcn::MouseEvent &event) if (!PlayerInfo::getInventory()) return; - Item *item = PlayerInfo::getInventory()->findItem(itemId, itemColor); + const Item *const item = PlayerInfo::getInventory()->findItem( + itemId, itemColor); if (item && viewport) { @@ -387,7 +391,7 @@ void ItemShortcutContainer::mouseMoved(gcn::MouseEvent &event) else if (itemId < SKILL_MIN_ID && spellManager) { mItemPopup->setVisible(false); - TextCommand *spell = spellManager->getSpellByItem(itemId); + TextCommand *const spell = spellManager->getSpellByItem(itemId); if (spell && viewport) { mSpellPopup->setItem(spell); diff --git a/src/gui/widgets/itemshortcutcontainer.h b/src/gui/widgets/itemshortcutcontainer.h index 1ed0bf627..f5135fbb3 100644 --- a/src/gui/widgets/itemshortcutcontainer.h +++ b/src/gui/widgets/itemshortcutcontainer.h @@ -43,7 +43,7 @@ class ItemShortcutContainer : public ShortcutContainer /** * Constructor. Initializes the graphic. */ - ItemShortcutContainer(unsigned number); + ItemShortcutContainer(const unsigned number); /** * Destructor. diff --git a/src/gui/widgets/layout.cpp b/src/gui/widgets/layout.cpp index b7856da81..1597cdc33 100644 --- a/src/gui/widgets/layout.cpp +++ b/src/gui/widgets/layout.cpp @@ -28,13 +28,13 @@ #include "debug.h" -ContainerPlacer ContainerPlacer::at(int x, int y) +ContainerPlacer ContainerPlacer::at(const int x, const int y) { return ContainerPlacer(mContainer, &mCell->at(x, y)); } LayoutCell &ContainerPlacer::operator() - (int x, int y, gcn::Widget *wg, int w, int h) + (const int x, const int y, gcn::Widget *const wg, const int w, const int h) { mContainer->add(wg); return mCell->place(wg, x, y, w, h); @@ -94,7 +94,7 @@ void LayoutCell::computeSizes() std::vector <LayoutCell *>::const_iterator j = i->begin(); while (j != i->end()) { - LayoutCell *cell = *j; + LayoutCell *const cell = *j; if (cell && cell->mType == ARRAY) cell->computeSizes(); @@ -127,7 +127,8 @@ LayoutArray::~LayoutArray() } } -LayoutCell &LayoutArray::at(int x, int y, int w, int h) +LayoutCell &LayoutArray::at(const int x, const int y, + const int w, const int h) { resizeGrid(x + w, y + h); LayoutCell *&cell = mCells[y][x]; @@ -136,10 +137,10 @@ LayoutCell &LayoutArray::at(int x, int y, int w, int h) return *cell; } -void LayoutArray::resizeGrid(int w, int h) +void LayoutArray::resizeGrid(int w, const int h) { - bool extW = w && w > static_cast<int>(mSizes[0].size()), - extH = h && h > static_cast<int>(mSizes[1].size()); + const bool extW = w && w > static_cast<int>(mSizes[0].size()); + const bool extH = h && h > static_cast<int>(mSizes[1].size()); if (!extW && !extH) return; @@ -164,35 +165,36 @@ void LayoutArray::resizeGrid(int w, int h) } } -void LayoutArray::setColWidth(int n, int w) +void LayoutArray::setColWidth(const int n, const int w) { resizeGrid(n + 1, 0); mSizes[0][n] = w; } -void LayoutArray::setRowHeight(int n, int h) +void LayoutArray::setRowHeight(const int n, const int h) { resizeGrid(0, n + 1); mSizes[1][n] = h; } -void LayoutArray::matchColWidth(int n1, int n2) +void LayoutArray::matchColWidth(const int n1, const int n2) { resizeGrid(std::max(n1, n2) + 1, 0); - std::vector<int> widths = getSizes(0, Layout::AUTO_DEF); + const std::vector<int> widths = getSizes(0, Layout::AUTO_DEF); int s = std::max(widths[n1], widths[n2]); mSizes[0][n1] = s; mSizes[0][n2] = s; } -void LayoutArray::extend(int x, int y, int w, int h) +void LayoutArray::extend(const int x, const int y, const int w, const int h) { LayoutCell &cell = at(x, y, w, h); cell.mExtent[0] = w; cell.mExtent[1] = h; } -LayoutCell &LayoutArray::place(gcn::Widget *widget, int x, int y, int w, int h) +LayoutCell &LayoutArray::place(gcn::Widget *const widget, const int x, + const int y, const int w, const int h) { LayoutCell &cell = at(x, y, w, h); assert(cell.mType == LayoutCell::NONE); @@ -222,8 +224,9 @@ LayoutCell &LayoutArray::place(gcn::Widget *widget, int x, int y, int w, int h) return cell; } -void LayoutArray::align(int &pos, int &size, int dim, LayoutCell const &cell, - int *sizes, int sizeCount) const +void LayoutArray::align(int &pos, int &size, const int dim, + LayoutCell const &cell, const int *const sizes, + int sizeCount) const { int size_max = sizes[0]; int cnt = cell.mExtent[dim]; @@ -253,10 +256,10 @@ void LayoutArray::align(int &pos, int &size, int dim, LayoutCell const &cell, } } -std::vector<int> LayoutArray::getSizes(int dim, int upp) const +std::vector<int> LayoutArray::getSizes(const int dim, int upp) const { - int gridW = static_cast<int>(mSizes[0].size()), - gridH = static_cast<int>(mSizes[1].size()); + const int gridW = static_cast<int>(mSizes[0].size()); + const int gridH = static_cast<int>(mSizes[1].size()); std::vector<int> sizes = mSizes[dim]; // Compute minimum sizes. @@ -270,8 +273,8 @@ std::vector<int> LayoutArray::getSizes(int dim, int upp) const if (cell->mExtent[dim] == 1) { - int n = (dim == 0 ? gridX : gridY); - int s = cell->mSize[dim] + cell->mVPadding * 2; + const int n = (dim == 0 ? gridX : gridY); + const int s = cell->mSize[dim] + cell->mVPadding * 2; if (s > sizes[n]) sizes[n] = s; } @@ -282,7 +285,7 @@ std::vector<int> LayoutArray::getSizes(int dim, int upp) const return sizes; // Compute the FILL sizes. - int nb = static_cast<int>(sizes.size()); + const int nb = static_cast<int>(sizes.size()); int nbFill = 0; for (int i = 0; i < nb; ++i) { @@ -307,7 +310,7 @@ std::vector<int> LayoutArray::getSizes(int dim, int upp) const if (mSizes[dim][i] > Layout::AUTO_DEF) continue; - int s = upp / nbFill; + const int s = upp / nbFill; sizes[i] += s; upp -= s; --nbFill; @@ -316,11 +319,11 @@ std::vector<int> LayoutArray::getSizes(int dim, int upp) const return sizes; } -int LayoutArray::getSize(int dim) const +int LayoutArray::getSize(const int dim) const { std::vector<int> sizes = getSizes(dim, Layout::AUTO_DEF); int size = 0; - int nb = static_cast<int>(sizes.size()); + const int nb = static_cast<int>(sizes.size()); for (int i = 0; i < nb; ++i) { if (sizes[i] > Layout::AUTO_DEF) @@ -330,10 +333,11 @@ int LayoutArray::getSize(int dim) const return size - mSpacing; } -void LayoutArray::reflow(int nx, int ny, int nw, int nh) +void LayoutArray::reflow(const int nx, const int ny, + const int nw, const int nh) { - int gridW = static_cast<int>(mSizes[0].size()), - gridH = static_cast<int>(mSizes[1].size()); + const int gridW = static_cast<int>(mSizes[0].size()); + const int gridH = static_cast<int>(mSizes[1].size()); std::vector<int> widths = getSizes(0, nw); std::vector<int> heights = getSizes(1, nh); @@ -346,7 +350,7 @@ void LayoutArray::reflow(int nx, int ny, int nw, int nh) int x = nx; for (int gridX = 0; gridX < gridW; ++gridX) { - LayoutCell *cell = mCells[gridY][gridX]; + LayoutCell *const cell = mCells[gridY][gridX]; if (cell && cell->mType != LayoutCell::NONE) { int dx = x, dy = y, dw = 0, dh = 0; diff --git a/src/gui/widgets/layout.h b/src/gui/widgets/layout.h index 3c42554b6..a30cff1e1 100644 --- a/src/gui/widgets/layout.h +++ b/src/gui/widgets/layout.h @@ -50,14 +50,14 @@ class ContainerPlacer /** * Returns a placer for the same container but to an inner cell. */ - ContainerPlacer at(int x, int y); + ContainerPlacer at(const int x, const int y); /** * Adds the given widget to the container and places it in the layout. * @see LayoutArray::place */ - LayoutCell &operator() - (int x, int y, gcn::Widget *, int w = 1, int h = 1); + LayoutCell &operator()(const int x, const int y, gcn::Widget *const wg, + const int w = 1, const int h = 1); private: gcn::Container *mContainer; @@ -80,7 +80,8 @@ class LayoutArray /** * Returns a reference on the cell at given position. */ - LayoutCell &at(int x, int y, int w = 1, int h = 1); + LayoutCell &at(const int x, const int y, + const int w = 1, const int h = 1); /** * Places a widget in a given cell. @@ -89,34 +90,35 @@ class LayoutArray * @note When @a w is 1, the width of column @a x is reset to zero if * it was AUTO_DEF. Similarly for @a h. */ - LayoutCell &place(gcn::Widget *, int x, int y, int w = 1, int h = 1); + LayoutCell &place(gcn::Widget *const widget, const int x, const int y, + const int w = 1, const int h = 1); /** * Sets the minimum width of a column. */ - void setColWidth(int n, int w); + void setColWidth(const int n, const int w); /** * Sets the minimum height of a row. */ - void setRowHeight(int n, int h); + void setRowHeight(const int n, const int h); /** * Sets the widths of two columns to the maximum of their widths. */ - void matchColWidth(int n1, int n2); + void matchColWidth(const int n1, const int n2); /** * Spawns a cell over several columns/rows. */ - void extend(int x, int y, int w, int h); + void extend(const int x, const int y, const int w, const int h); /** * Computes and sets the positions of all the widgets. * @param nW width of the array, used to resize the AUTO_ columns. * @param nH height of the array, used to resize the AUTO_ rows. */ - void reflow(int nX, int nY, int nW, int nH); + void reflow(const int nX, const int nY, const int nW, const int nH); private: @@ -127,24 +129,24 @@ class LayoutArray /** * Gets the position and size of a widget along a given axis */ - void align(int &pos, int &size, int dim, LayoutCell const &cell, - int *sizes, int sizeCount) const; + void align(int &pos, int &size, const int dim, LayoutCell const &cell, + const int *const sizes, int sizeCount) const; /** * Ensures the private vectors are large enough. */ - void resizeGrid(int w, int h); + void resizeGrid(int w, const int h); /** * Gets the column/row sizes along a given axis. * @param upp target size for the array. Ignored if AUTO_DEF. */ - std::vector<int> getSizes(int dim, int upp) const; + std::vector<int> getSizes(const int dim, int upp) const; /** * Gets the total size along a given axis. */ - int getSize(int dim) const; + int getSize(const int dim) const; std::vector<int> mSizes[2]; std::vector< std::vector < LayoutCell * > > mCells; diff --git a/src/gui/widgets/layouthelper.cpp b/src/gui/widgets/layouthelper.cpp index 2b79609b9..9e93f6de5 100644 --- a/src/gui/widgets/layouthelper.cpp +++ b/src/gui/widgets/layouthelper.cpp @@ -24,7 +24,7 @@ #include "debug.h" -LayoutHelper::LayoutHelper(gcn::Container *container): +LayoutHelper::LayoutHelper(gcn::Container *const container) : mContainer(container) { mContainer->addWidgetListener(this); @@ -40,13 +40,14 @@ const Layout &LayoutHelper::getLayout() const return mLayout; } -LayoutCell &LayoutHelper::place(int x, int y, gcn::Widget *wg, int w, int h) +LayoutCell &LayoutHelper::place(const int x, const int y, gcn::Widget *const wg, + const int w, const int h) { mContainer->add(wg); return mLayout.place(wg, x, y, w, h); } -ContainerPlacer LayoutHelper::getPlacer(int x, int y) +ContainerPlacer LayoutHelper::getPlacer(const int x, const int y) { return ContainerPlacer(mContainer, &mLayout.at(x, y)); } diff --git a/src/gui/widgets/layouthelper.h b/src/gui/widgets/layouthelper.h index b0f4d435d..c9c5e2471 100644 --- a/src/gui/widgets/layouthelper.h +++ b/src/gui/widgets/layouthelper.h @@ -38,7 +38,7 @@ class LayoutHelper : public gcn::WidgetListener /** * Constructor. */ - LayoutHelper(gcn::Container *container); + LayoutHelper(gcn::Container *const container); /** * Destructor. @@ -65,12 +65,13 @@ class LayoutHelper : public gcn::WidgetListener /** * Adds a widget to the container and sets it at given cell. */ - LayoutCell &place(int x, int y, gcn::Widget *, int w = 1, int h = 1); + LayoutCell &place(const int x, const int y, gcn::Widget *const wg, + const int w = 1, const int h = 1); /** * Returns a proxy for adding widgets in an inner table of the layout. */ - ContainerPlacer getPlacer(int x, int y); + ContainerPlacer getPlacer(const int x, const int y); /** * Called whenever the managed container changes size. diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index f11632675..dcd27e671 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -40,7 +40,7 @@ float ListBox::mAlpha = 1.0; -ListBox::ListBox(gcn::ListModel *listModel): +ListBox::ListBox(gcn::ListModel *const listModel): gcn::ListBox(listModel), mHighlightColor(Theme::getThemeColor(Theme::HIGHLIGHT)), mDistributeMousePressed(true) @@ -54,7 +54,7 @@ ListBox::~ListBox() void ListBox::updateAlpha() { - float alpha = std::max(Client::getGuiAlpha(), + const float alpha = std::max(Client::getGuiAlpha(), Theme::instance()->getMinimumOpacity()); if (mAlpha != alpha) @@ -92,7 +92,7 @@ void ListBox::draw(gcn::Graphics *graphics) void ListBox::keyPressed(gcn::KeyEvent &keyEvent) { - int action = static_cast<KeyEvent*>(&keyEvent)->getActionId(); + const int action = static_cast<KeyEvent*>(&keyEvent)->getActionId(); if (action == Input::KEY_GUI_SELECT) { @@ -156,9 +156,8 @@ void ListBox::mouseDragged(gcn::MouseEvent &event) return; // Make list selection update on drag, but guard against negative y - int y = std::max(0, event.getY()); if (getRowHeight()) - setSelected(y / getRowHeight()); + setSelected(std::max(0, event.getY()) / getRowHeight()); } void ListBox::refocus() diff --git a/src/gui/widgets/listbox.h b/src/gui/widgets/listbox.h index b02357752..fdb6350c5 100644 --- a/src/gui/widgets/listbox.h +++ b/src/gui/widgets/listbox.h @@ -40,7 +40,7 @@ class ListBox : public gcn::ListBox /** * Constructor. */ - ListBox(gcn::ListModel *listModel); + ListBox(gcn::ListModel *const listModel); ~ListBox(); diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp index 51f057621..745e37e31 100644 --- a/src/gui/widgets/playerbox.cpp +++ b/src/gui/widgets/playerbox.cpp @@ -35,7 +35,7 @@ #include "debug.h" -PlayerBox::PlayerBox(Being *being, std::string skin): +PlayerBox::PlayerBox(Being *const being, const std::string &skin) : mBeing(being), mAlpha(1.0), mSkin(nullptr), diff --git a/src/gui/widgets/playerbox.h b/src/gui/widgets/playerbox.h index 4f413f23c..81fe87f52 100644 --- a/src/gui/widgets/playerbox.h +++ b/src/gui/widgets/playerbox.h @@ -45,7 +45,7 @@ class PlayerBox : public gcn::ScrollArea * Constructor. Takes the initial player character that this box should * display, which defaults to <code>NULL</code>. */ - PlayerBox(Being *being, std::string skin = ""); + PlayerBox(Being *const being, const std::string &skin = ""); PlayerBox(std::string skin = ""); diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp index e02c973dd..2a4065ac2 100644 --- a/src/gui/widgets/popup.cpp +++ b/src/gui/widgets/popup.cpp @@ -91,14 +91,14 @@ Popup::~Popup() } } -void Popup::setWindowContainer(WindowContainer *wc) +void Popup::setWindowContainer(WindowContainer *const wc) { windowContainer = wc; } void Popup::draw(gcn::Graphics *graphics) { - Graphics *g = static_cast<Graphics*>(graphics); + Graphics *const g = static_cast<Graphics*>(graphics); if (mRedraw) { @@ -138,7 +138,7 @@ void Popup::setContentSize(int width, int height) mRedraw = true; } -void Popup::setLocationRelativeTo(gcn::Widget *widget) +void Popup::setLocationRelativeTo(gcn::Widget *const widget) { if (!widget) return; @@ -154,7 +154,7 @@ void Popup::setLocationRelativeTo(gcn::Widget *widget) mRedraw = true; } -void Popup::setMinWidth(int width) +void Popup::setMinWidth(const int width) { if (mSkin) { @@ -167,7 +167,7 @@ void Popup::setMinWidth(int width) } } -void Popup::setMinHeight(int height) +void Popup::setMinHeight(const int height) { if (mSkin) { @@ -180,12 +180,12 @@ void Popup::setMinHeight(int height) } } -void Popup::setMaxWidth(int width) +void Popup::setMaxWidth(const int width) { mMaxWidth = width; } -void Popup::setMaxHeight(int height) +void Popup::setMaxHeight(const int height) { mMaxHeight = height; } @@ -195,7 +195,7 @@ void Popup::scheduleDelete() windowContainer->scheduleDelete(this); } -void Popup::position(int x, int y) +void Popup::position(const int x, const int y) { const int distance = 20; diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h index 39ced1119..61aac98c1 100644 --- a/src/gui/widgets/popup.h +++ b/src/gui/widgets/popup.h @@ -68,7 +68,7 @@ class Popup : public Container, public gcn::MouseListener, /** * Sets the window container to be used by new popups. */ - static void setWindowContainer(WindowContainer *windowContainer); + static void setWindowContainer(WindowContainer *const windowContainer); /** * Draws the popup. @@ -83,14 +83,14 @@ class Popup : public Container, public gcn::MouseListener, /** * Sets the location relative to the given widget. */ - void setLocationRelativeTo(gcn::Widget *widget); + void setLocationRelativeTo(gcn::Widget *const widget); void mouseMoved(gcn::MouseEvent &event); /** * Sets the minimum width of the popup. */ - void setMinWidth(int width); + void setMinWidth(const int width); int getMinWidth() const { return mMinWidth; } @@ -98,7 +98,7 @@ class Popup : public Container, public gcn::MouseListener, /** * Sets the minimum height of the popup. */ - void setMinHeight(int height); + void setMinHeight(const int height); int getMinHeight() const { return mMinHeight; } @@ -106,7 +106,7 @@ class Popup : public Container, public gcn::MouseListener, /** * Sets the maximum width of the popup. */ - void setMaxWidth(int width); + void setMaxWidth(const int width); int getMaxWidth() const { return mMaxWidth; } @@ -114,7 +114,7 @@ class Popup : public Container, public gcn::MouseListener, /** * Sets the minimum height of the popup. */ - void setMaxHeight(int height); + void setMaxHeight(const int height); int getMaxHeight() const { return mMaxHeight; } @@ -157,7 +157,7 @@ class Popup : public Container, public gcn::MouseListener, * the popup. Prevents the popup from extending off-screen, if * possible. */ - void position(int x, int y); + void position(const int x, const int y); void hide(); diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp index 6dd24ce56..3980d0330 100644 --- a/src/gui/widgets/progressbar.cpp +++ b/src/gui/widgets/progressbar.cpp @@ -42,8 +42,8 @@ int ProgressBar::mInstances = 0; float ProgressBar::mAlpha = 1.0; ProgressBar::ProgressBar(float progress, - int width, int height, - int color): + const int width, const int height, + const int color): gcn::Widget(), mSmoothProgress(true), mProgressPalette(color), @@ -119,7 +119,7 @@ void ProgressBar::logic() void ProgressBar::updateAlpha() { - float alpha = std::max(Client::getGuiAlpha(), + const float alpha = std::max(Client::getGuiAlpha(), Theme::instance()->getMinimumOpacity()); if (mAlpha != alpha) @@ -148,7 +148,7 @@ void ProgressBar::draw(gcn::Graphics *graphics) mProgress, mText, mVertexes, &mRedraw); } -void ProgressBar::setProgress(float progress) +void ProgressBar::setProgress(const float progress) { const float p = std::min(1.0f, std::max(0.0f, progress)); mProgressToGo = p; @@ -160,9 +160,9 @@ void ProgressBar::setProgress(float progress) mColorToGo = Theme::getProgressColor(mProgressPalette, progress); } -void ProgressBar::setProgressPalette(int progressPalette) +void ProgressBar::setProgressPalette(const int progressPalette) { - int oldPalette = mProgressPalette; + const int oldPalette = mProgressPalette; mProgressPalette = progressPalette; if (mProgressPalette != oldPalette && mProgressPalette >= 0) @@ -178,12 +178,12 @@ void ProgressBar::setColor(const gcn::Color &color) } void ProgressBar::render(Graphics *graphics, const gcn::Rectangle &area, - const gcn::Color &color, float progress, - const std::string &text, GraphicsVertexes *vert, - bool *redraw) + const gcn::Color &color, const float progress, + const std::string &text, GraphicsVertexes *const vert, + bool *const redraw) { - gcn::Font *oldFont = graphics->getFont(); - gcn::Color oldColor = graphics->getColor(); + gcn::Font *const oldFont = graphics->getFont(); + const gcn::Color oldColor = graphics->getColor(); if (*redraw || graphics->getRedraw()) { @@ -220,11 +220,11 @@ void ProgressBar::render(Graphics *graphics, const gcn::Rectangle &area, } void ProgressBar::render(Graphics *graphics, const gcn::Rectangle &area, - const gcn::Color &color, float progress, + const gcn::Color &color, const float progress, const std::string &text) { - gcn::Font *oldFont = graphics->getFont(); - gcn::Color oldColor = graphics->getColor(); + gcn::Font *const oldFont = graphics->getFont(); + const gcn::Color oldColor = graphics->getColor(); graphics->drawImageRect(area, mBorder); diff --git a/src/gui/widgets/progressbar.h b/src/gui/widgets/progressbar.h index 603df6157..5a188c0d0 100644 --- a/src/gui/widgets/progressbar.h +++ b/src/gui/widgets/progressbar.h @@ -45,8 +45,8 @@ class ProgressBar : public gcn::Widget, public gcn::WidgetListener * Constructor, initializes the progress with the given value. */ ProgressBar(float progress = 0.0f, - int width = 40, int height = 7, - int color = -1); + const int width = 40, const int height = 7, + const int color = -1); ~ProgressBar(); @@ -68,7 +68,7 @@ class ProgressBar : public gcn::Widget, public gcn::WidgetListener /** * Sets the current progress. */ - void setProgress(float progress); + void setProgress(const float progress); /** * Returns the current progress. @@ -80,7 +80,7 @@ class ProgressBar : public gcn::Widget, public gcn::WidgetListener * Change the ProgressPalette for this ProgressBar to follow or -1 to * disable this and manage color manually. */ - void setProgressPalette(int progressPalette); + void setProgressPalette(const int progressPalette); /** * Change the color of the progress bar. @@ -121,15 +121,15 @@ class ProgressBar : public gcn::Widget, public gcn::WidgetListener * Renders a progressbar with the given properties. */ static void render(Graphics *graphics, const gcn::Rectangle &area, - const gcn::Color &color, float progress, + const gcn::Color &color, const float progress, const std::string &text, - GraphicsVertexes *vert, bool *redraw); + GraphicsVertexes *const vert, bool *const redraw); /** * Renders a progressbar with the given properties. */ static void render(Graphics *graphics, const gcn::Rectangle &area, - const gcn::Color &color, float progress, + const gcn::Color &color, const float progress, const std::string &text = ""); void widgetResized(const gcn::Event &event); diff --git a/src/gui/widgets/progressindicator.cpp b/src/gui/widgets/progressindicator.cpp index 681da7ae4..27fb104c7 100644 --- a/src/gui/widgets/progressindicator.cpp +++ b/src/gui/widgets/progressindicator.cpp @@ -36,10 +36,10 @@ ProgressIndicator::ProgressIndicator() { - ImageSet *images = Theme::getImageSetFromTheme("progress-indicator.png", - 32, 32); + ImageSet *const images = Theme::getImageSetFromTheme( + "progress-indicator.png", 32, 32); - Animation *anim = new Animation; + Animation *const anim = new Animation; if (images) { for (ImageSet::size_type i = 0, sz = images->size(); i < sz; ++i) diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp index 7d3c67671..21e318955 100644 --- a/src/gui/widgets/radiobutton.cpp +++ b/src/gui/widgets/radiobutton.cpp @@ -44,7 +44,7 @@ Image *RadioButton::radioNormalHi; Image *RadioButton::radioCheckedHi; RadioButton::RadioButton(const std::string &caption, const std::string &group, - bool marked): + const bool marked): gcn::RadioButton(caption, group, marked), mHasMouse(false) { @@ -119,7 +119,7 @@ void RadioButton::drawBox(gcn::Graphics* graphics) radioCheckedHi->setAlpha(mAlpha); } - Image *box = nullptr; + const Image *box = nullptr; if (isEnabled()) { @@ -168,7 +168,7 @@ void RadioButton::mouseExited(gcn::MouseEvent& event A_UNUSED) void RadioButton::keyPressed(gcn::KeyEvent& keyEvent) { - int action = static_cast<KeyEvent*>(&keyEvent)->getActionId(); + const int action = static_cast<KeyEvent*>(&keyEvent)->getActionId(); if (action == Input::KEY_GUI_SELECT) { diff --git a/src/gui/widgets/radiobutton.h b/src/gui/widgets/radiobutton.h index f796a4fc9..2db41cd78 100644 --- a/src/gui/widgets/radiobutton.h +++ b/src/gui/widgets/radiobutton.h @@ -37,7 +37,7 @@ class RadioButton : public gcn::RadioButton * Constructor. */ RadioButton(const std::string &caption, const std::string &group, - bool marked = false); + const bool marked = false); /** * Destructor. diff --git a/src/gui/widgets/radiogroup.cpp b/src/gui/widgets/radiogroup.cpp index 24813f6e2..e07b3782c 100644 --- a/src/gui/widgets/radiogroup.cpp +++ b/src/gui/widgets/radiogroup.cpp @@ -26,14 +26,15 @@ #include "debug.h" -RadioGroup::RadioGroup(std::string group, int height, int spacing) : +RadioGroup::RadioGroup(const std::string &group, const int height, + const int spacing) : WidgetGroup(group, height, spacing) { } -gcn::Widget *RadioGroup::createWidget(std::string text) +gcn::Widget *RadioGroup::createWidget(const std::string &text) { - RadioButton *widget = new RadioButton(text, mGroup, mCount == 0); + RadioButton *const widget = new RadioButton(text, mGroup, mCount == 0); widget->adjustSize(); return widget; } diff --git a/src/gui/widgets/radiogroup.h b/src/gui/widgets/radiogroup.h index 07f2a8e34..fb511971d 100644 --- a/src/gui/widgets/radiogroup.h +++ b/src/gui/widgets/radiogroup.h @@ -28,9 +28,10 @@ class RadioGroup : public WidgetGroup { public: - RadioGroup(std::string group, int height, int spacing); + RadioGroup(const std::string &group, const int height, + const int spacing); - gcn::Widget *createWidget(std::string name); + gcn::Widget *createWidget(const std::string &name); }; #endif diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index 2af6ad3be..b752eb245 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -47,7 +47,7 @@ static std::string const buttonFiles[2] = "scrollbuttons_pressed.xml" }; -ScrollArea::ScrollArea(bool opaque, const std::string &skin): +ScrollArea::ScrollArea(const bool opaque, const std::string &skin) : gcn::ScrollArea(), mX(0), mY(0), @@ -66,8 +66,8 @@ ScrollArea::ScrollArea(bool opaque, const std::string &skin): init(skin); } -ScrollArea::ScrollArea(gcn::Widget *widget, bool opaque, - const std::string &skin): +ScrollArea::ScrollArea(gcn::Widget *const widget, const bool opaque, + const std::string &skin) : gcn::ScrollArea(widget), mX(0), mY(0), @@ -91,7 +91,7 @@ ScrollArea::~ScrollArea() delete getContent(); instances--; - Theme *theme = Theme::instance(); + Theme *const theme = Theme::instance(); if (theme) { theme->unloadRect(background); @@ -144,7 +144,7 @@ void ScrollArea::init(std::string skinName) for (int i = 0; i < 2; i ++) { - Skin *skin = Theme::instance()->load( + Skin *const skin = Theme::instance()->load( buttonFiles[i], "scrollbuttons.xml"); if (skin) { @@ -176,7 +176,7 @@ void ScrollArea::logic() return; gcn::ScrollArea::logic(); - gcn::Widget *content = getContent(); + gcn::Widget *const content = getContent(); // When no scrollbar in a certain direction, adapt content size to match // the content dimension exactly. @@ -218,8 +218,8 @@ void ScrollArea::logic() void ScrollArea::updateAlpha() { - float alpha = std::max(Client::getGuiAlpha(), - Theme::instance()->getMinimumOpacity()); + const float alpha = std::max(Client::getGuiAlpha(), + Theme::instance()->getMinimumOpacity()); if (alpha != mAlpha) { @@ -329,7 +329,8 @@ void ScrollArea::setOpaque(bool opaque) setFrameSize(mOpaque ? 2 : 0); } -void ScrollArea::drawButton(gcn::Graphics *graphics, BUTTON_DIR dir) +void ScrollArea::drawButton(gcn::Graphics *const graphics, + const BUTTON_DIR dir) { int state = 0; gcn::Rectangle dim; @@ -366,27 +367,27 @@ void ScrollArea::drawButton(gcn::Graphics *graphics, BUTTON_DIR dir) } } -void ScrollArea::drawUpButton(gcn::Graphics *graphics) +void ScrollArea::drawUpButton(gcn::Graphics *const graphics) { drawButton(graphics, UP); } -void ScrollArea::drawDownButton(gcn::Graphics *graphics) +void ScrollArea::drawDownButton(gcn::Graphics *const graphics) { drawButton(graphics, DOWN); } -void ScrollArea::drawLeftButton(gcn::Graphics *graphics) +void ScrollArea::drawLeftButton(gcn::Graphics *const graphics) { drawButton(graphics, LEFT); } -void ScrollArea::drawRightButton(gcn::Graphics *graphics) +void ScrollArea::drawRightButton(gcn::Graphics *const graphics) { drawButton(graphics, RIGHT); } -void ScrollArea::drawVBar(gcn::Graphics *graphics) +void ScrollArea::drawVBar(gcn::Graphics *const graphics) { const gcn::Rectangle dim = getVerticalBarDimension(); graphics->setColor(mGray); @@ -394,7 +395,7 @@ void ScrollArea::drawVBar(gcn::Graphics *graphics) graphics->setColor(mBackground); } -void ScrollArea::drawHBar(gcn::Graphics *graphics) +void ScrollArea::drawHBar(gcn::Graphics *const graphics) { const gcn::Rectangle dim = getHorizontalBarDimension(); graphics->setColor(mGray); @@ -402,9 +403,9 @@ void ScrollArea::drawHBar(gcn::Graphics *graphics) graphics->setColor(mBackground); } -void ScrollArea::drawVMarker(gcn::Graphics *graphics) +void ScrollArea::drawVMarker(gcn::Graphics *const graphics) { - gcn::Rectangle dim = getVerticalMarkerDimension(); + const gcn::Rectangle dim = getVerticalMarkerDimension(); if ((mHasMouse) && (mX > (getWidth() - getScrollbarWidth()))) { @@ -418,9 +419,9 @@ void ScrollArea::drawVMarker(gcn::Graphics *graphics) } } -void ScrollArea::drawHMarker(gcn::Graphics *graphics) +void ScrollArea::drawHMarker(gcn::Graphics *const graphics) { - gcn::Rectangle dim = getHorizontalMarkerDimension(); + const gcn::Rectangle dim = getHorizontalMarkerDimension(); if ((mHasMouse) && (mY > (getHeight() - getScrollbarWidth()))) { diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h index d2032b379..6d99be1ae 100644 --- a/src/gui/widgets/scrollarea.h +++ b/src/gui/widgets/scrollarea.h @@ -46,14 +46,14 @@ class ScrollArea : public gcn::ScrollArea, public gcn::WidgetListener * Constructor that takes no content. Needed for use with the DropDown * class. */ - ScrollArea(bool opaque = true, const std::string &skin = ""); + ScrollArea(const bool opaque = true, const std::string &skin = ""); /** * Constructor. * * @param content the initial content to show in the scroll area */ - ScrollArea(gcn::Widget *content, bool opaque = true, + ScrollArea(gcn::Widget *const widget, const bool opaque = true, const std::string &skin = ""); /** @@ -131,15 +131,15 @@ class ScrollArea : public gcn::ScrollArea, public gcn::WidgetListener */ void init(std::string skinName); - 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 drawButton(gcn::Graphics *const graphics, const BUTTON_DIR dir); + void drawUpButton(gcn::Graphics *const graphics); + void drawDownButton(gcn::Graphics *const graphics); + void drawLeftButton(gcn::Graphics *const graphics); + void drawRightButton(gcn::Graphics *const graphics); + void drawVBar(gcn::Graphics *const graphics); + void drawHBar(gcn::Graphics *const graphics); + void drawVMarker(gcn::Graphics *const graphics); + void drawHMarker(gcn::Graphics *const graphics); static int instances; static float mAlpha; diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index ca640421e..a835bf51a 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -48,8 +48,8 @@ #include "debug.h" SetupItem::SetupItem(std::string text, std::string description, - std::string keyName, SetupTabScroll *parent, - std::string eventName, bool mainConfig) : + std::string keyName, SetupTabScroll *const parent, + std::string eventName, const bool mainConfig) : mText(text), mDescription(description), mKeyName(keyName), @@ -65,8 +65,9 @@ SetupItem::SetupItem(std::string text, std::string description, } SetupItem::SetupItem(std::string text, std::string description, - std::string keyName, SetupTabScroll *parent, - std::string eventName, std::string def, bool mainConfig) : + std::string keyName, SetupTabScroll *const parent, + std::string eventName, std::string def, + const bool mainConfig) : mText(text), mDescription(description), mKeyName(keyName), @@ -86,7 +87,7 @@ SetupItem::~SetupItem() } -Configuration *SetupItem::getConfig() +Configuration *SetupItem::getConfig() const { if (mMainConfig) return &config; @@ -96,7 +97,7 @@ Configuration *SetupItem::getConfig() void SetupItem::load() { - Configuration *cfg = getConfig(); + const Configuration *const cfg = getConfig(); if (mUseDefault) { mValue = cfg->getValue(mKeyName, mDefault); @@ -126,7 +127,7 @@ void SetupItem::load() void SetupItem::save() { - Configuration *cfg = getConfig(); + Configuration *const cfg = getConfig(); cfg->setValue(mKeyName, mValue); } @@ -169,7 +170,7 @@ void SetupItem::externalUpdated(std::string eventName A_UNUSED) toWidget(); } -void SetupItem::fixFirstItemSize(gcn::Widget *widget) +void SetupItem::fixFirstItemSize(gcn::Widget *const widget) { if (widget->getWidth() < mParent->getPreferredFirstItemSize()) widget->setWidth(mParent->getPreferredFirstItemSize()); @@ -177,8 +178,9 @@ void SetupItem::fixFirstItemSize(gcn::Widget *widget) SetupItemCheckBox::SetupItemCheckBox(std::string text, std::string description, std::string keyName, - SetupTabScroll *parent, - std::string eventName, bool mainConfig) : + SetupTabScroll *const parent, + std::string eventName, + const bool mainConfig) : SetupItem(text, description, keyName, parent, eventName, mainConfig) { createControls(); @@ -186,9 +188,9 @@ SetupItemCheckBox::SetupItemCheckBox(std::string text, std::string description, SetupItemCheckBox::SetupItemCheckBox(std::string text, std::string description, std::string keyName, - SetupTabScroll *parent, + SetupTabScroll *const parent, std::string eventName, std::string def, - bool mainConfig) : + const bool mainConfig) : SetupItem(text, description, keyName, parent, eventName, def, mainConfig) { createControls(); @@ -233,9 +235,9 @@ void SetupItemCheckBox::toWidget() SetupItemTextField::SetupItemTextField(std::string text, std::string description, std::string keyName, - SetupTabScroll *parent, + SetupTabScroll *const parent, std::string eventName, - bool mainConfig) : + const bool mainConfig) : SetupItem(text, description, keyName, parent, eventName, mainConfig), mHorizont(nullptr), mLabel(nullptr), @@ -250,9 +252,9 @@ SetupItemTextField::SetupItemTextField(std::string text, SetupItemTextField::SetupItemTextField(std::string text, std::string description, std::string keyName, - SetupTabScroll *parent, + SetupTabScroll *const parent, std::string eventName, std::string def, - bool mainConfig) : + const bool mainConfig) : SetupItem(text, description, keyName, parent, eventName, def, mainConfig), mHorizont(nullptr), mLabel(nullptr), @@ -347,10 +349,10 @@ void SetupItemTextField::apply(std::string eventName) SetupItemIntTextField::SetupItemIntTextField(std::string text, std::string description, std::string keyName, - SetupTabScroll *parent, + SetupTabScroll *const parent, std::string eventName, - int min, int max, - bool mainConfig) : + const int min, const int max, + const bool mainConfig) : SetupItem(text, description, keyName, parent, eventName, mainConfig), mHorizont(nullptr), mLabel(nullptr), @@ -367,11 +369,11 @@ SetupItemIntTextField::SetupItemIntTextField(std::string text, SetupItemIntTextField::SetupItemIntTextField(std::string text, std::string description, std::string keyName, - SetupTabScroll *parent, + SetupTabScroll *const parent, std::string eventName, - int min, int max, + const int min, const int max, std::string def, - bool mainConfig) : + const bool mainConfig) : SetupItem(text, description, keyName, parent, eventName, def, mainConfig), mHorizont(nullptr), mLabel(nullptr), @@ -470,7 +472,8 @@ void SetupItemIntTextField::apply(std::string eventName) SetupItemLabel::SetupItemLabel(std::string text, std::string description, - SetupTabScroll *parent, bool separator) : + SetupTabScroll *const parent, + const bool separator) : SetupItem(text, description, "", parent, "", "", true), mLabel(nullptr), mIsSeparator(separator) @@ -525,10 +528,10 @@ void SetupItemLabel::apply(std::string eventName A_UNUSED) SetupItemDropDown::SetupItemDropDown(std::string text, std::string description, std::string keyName, - SetupTabScroll *parent, + SetupTabScroll *const parent, std::string eventName, - gcn::ListModel *model, - bool mainConfig) : + gcn::ListModel *const model, + const bool mainConfig) : SetupItem(text, description, keyName, parent, eventName, mainConfig), mHorizont(nullptr), mLabel(nullptr), @@ -542,11 +545,11 @@ SetupItemDropDown::SetupItemDropDown(std::string text, SetupItemDropDown::SetupItemDropDown(std::string text, std::string description, std::string keyName, - SetupTabScroll *parent, + SetupTabScroll *const parent, std::string eventName, - gcn::ListModel *model, + gcn::ListModel *const model, std::string def, - bool mainConfig) : + const bool mainConfig) : SetupItem(text, description, keyName, parent, eventName, def, mainConfig), mHorizont(nullptr), mLabel(nullptr), @@ -606,9 +609,12 @@ void SetupItemDropDown::toWidget() SetupItemSlider::SetupItemSlider(std::string text, std::string description, - std::string keyName, SetupTabScroll *parent, - std::string eventName, double min, double max, - int width, bool onTheFly, bool mainConfig) : + std::string keyName, + SetupTabScroll *const parent, + std::string eventName, + const double min, const double max, + const int width, const bool onTheFly, + const bool mainConfig) : SetupItem(text, description, keyName, parent, eventName, mainConfig), mHorizont(nullptr), mLabel(nullptr), @@ -624,9 +630,11 @@ SetupItemSlider::SetupItemSlider(std::string text, std::string description, SetupItemSlider::SetupItemSlider(std::string text, std::string description, std::string keyName, SetupTabScroll *parent, - std::string eventName, double min, double max, - std::string def, int width, bool onTheFly, - bool mainConfig) : + std::string eventName, + const double min, const double max, + std::string def, const int width, + const bool onTheFly, + const bool mainConfig) : SetupItem(text, description, keyName, parent, eventName, def, mainConfig), mHorizont(nullptr), mLabel(nullptr), @@ -707,10 +715,14 @@ void SetupItemSlider::apply(std::string eventName) SetupItemSlider2::SetupItemSlider2(std::string text, std::string description, - std::string keyName, SetupTabScroll *parent, - std::string eventName, int min, int max, - SetupItemNames *values, bool onTheFly, - bool mainConfig, bool doNotAlign) : + std::string keyName, + SetupTabScroll *const parent, + std::string eventName, + const int min, const int max, + SetupItemNames *const values, + const bool onTheFly, + const bool mainConfig, + const bool doNotAlign) : SetupItem(text, description, keyName, parent, eventName, mainConfig), mHorizont(nullptr), mLabel(nullptr), @@ -729,11 +741,14 @@ SetupItemSlider2::SetupItemSlider2(std::string text, std::string description, } SetupItemSlider2::SetupItemSlider2(std::string text, std::string description, - std::string keyName, SetupTabScroll *parent, - std::string eventName, int min, int max, - SetupItemNames *values, std::string def, - bool onTheFly, bool mainConfig, - bool doNotAlign) : + std::string keyName, + SetupTabScroll *const parent, + std::string eventName, + const int min, const int max, + SetupItemNames *const values, + std::string def, + const bool onTheFly, const bool mainConfig, + const bool doNotAlign) : SetupItem(text, description, keyName, parent, eventName, def, mainConfig), mHorizont(nullptr), mLabel(nullptr), @@ -764,7 +779,7 @@ void SetupItemSlider2::createControls() load(); mHorizont = new HorizontContainer(32, 2); - int width = getMaxWidth(); + const int width = getMaxWidth(); mLabel = new Label(mText); mLabel2 = new Label(""); @@ -798,12 +813,12 @@ int SetupItemSlider2::getMaxWidth() int maxWidth = 0; SetupItemNamesConstIter it = mValues->begin(); - SetupItemNamesConstIter it_end = mValues->end(); - gcn::Font *font = gui->getFont(); + const SetupItemNamesConstIter it_end = mValues->end(); + const gcn::Font *const font = gui->getFont(); while (it != it_end) { - int w = font->getWidth(*it); + const int w = font->getWidth(*it); if (w > maxWidth) maxWidth = w; @@ -863,7 +878,7 @@ void SetupItemSlider2::apply(std::string eventName) save(); } -void SetupItemSlider2::setInvertValue(int v) +void SetupItemSlider2::setInvertValue(const int v) { mInvert = true; mInvertValue = v; @@ -874,11 +889,11 @@ void SetupItemSlider2::setInvertValue(int v) SetupItemSliderList::SetupItemSliderList(std::string text, std::string description, std::string keyName, - SetupTabScroll *parent, + SetupTabScroll *const parent, std::string eventName, - gcn::ListModel *model, - int width, bool onTheFly, - bool mainConfig) : + gcn::ListModel *const model, + const int width, const bool onTheFly, + const bool mainConfig) : SetupItem(text, description, keyName, parent, eventName, mainConfig), mHorizont(nullptr), mLabel(nullptr), @@ -894,11 +909,12 @@ SetupItemSliderList::SetupItemSliderList(std::string text, SetupItemSliderList::SetupItemSliderList(std::string text, std::string description, std::string keyName, - SetupTabScroll *parent, + SetupTabScroll *const parent, std::string eventName, - gcn::ListModel *model, - std::string def, int width, - bool onTheFly, bool mainConfig) : + gcn::ListModel *const model, + std::string def, const int width, + const bool onTheFly, + const bool mainConfig) : SetupItem(text, description, keyName, parent, eventName, def, mainConfig), mHorizont(nullptr), mLabel(nullptr), @@ -975,9 +991,12 @@ void SetupItemSliderList::apply(std::string eventName) } SetupItemSound::SetupItemSound(std::string text, std::string description, - std::string keyName, SetupTabScroll *parent, - std::string eventName, gcn::ListModel *model, - int width, bool onTheFly, bool mainConfig) : + std::string keyName, + SetupTabScroll *const parent, + std::string eventName, + gcn::ListModel *const model, + const int width, const bool onTheFly, + const bool mainConfig) : SetupItemSliderList(text, description, keyName, parent, eventName, model, width, onTheFly, mainConfig), mButton(nullptr) diff --git a/src/gui/widgets/setupitem.h b/src/gui/widgets/setupitem.h index 6a1fdc026..32304ac22 100644 --- a/src/gui/widgets/setupitem.h +++ b/src/gui/widgets/setupitem.h @@ -60,12 +60,13 @@ class SetupItem : public gcn::ActionListener }; SetupItem(std::string text, std::string description, - std::string keyName, SetupTabScroll *parent, - std::string eventName, bool mainConfig); + std::string keyName, SetupTabScroll *const parent, + std::string eventName, const bool mainConfig); SetupItem(std::string text, std::string description, - std::string keyName, SetupTabScroll *parent, - std::string eventName, std::string def, bool mainConfig); + std::string keyName, SetupTabScroll *const parent, + std::string eventName, std::string def, + const bool mainConfig); ~SetupItem(); @@ -83,7 +84,7 @@ class SetupItem : public gcn::ActionListener gcn::Widget *getWidget() const { return mWidget; } - Configuration *getConfig(); + Configuration *getConfig() const; virtual std::string getActionEventId(); @@ -100,7 +101,7 @@ class SetupItem : public gcn::ActionListener bool isMainConfig() const { return mMainConfig; } - void fixFirstItemSize(gcn::Widget *widget); + void fixFirstItemSize(gcn::Widget *const widget); protected: std::string mText; @@ -132,13 +133,13 @@ class SetupItemCheckBox : public SetupItem { public: SetupItemCheckBox(std::string text, std::string description, - std::string keyName, SetupTabScroll *parent, - std::string eventName, bool mainConfig = true); + std::string keyName, SetupTabScroll *const parent, + std::string eventName, const bool mainConfig = true); SetupItemCheckBox(std::string text, std::string description, - std::string keyName, SetupTabScroll *parent, + std::string keyName, SetupTabScroll *const parent, std::string eventName, std::string def, - bool mainConfig = true); + const bool mainConfig = true); ~SetupItemCheckBox(); @@ -156,13 +157,14 @@ class SetupItemTextField : public SetupItem { public: SetupItemTextField(std::string text, std::string description, - std::string keyName, SetupTabScroll *parent, - std::string eventName, bool mainConfig = true); + std::string keyName, SetupTabScroll *const parent, + std::string eventName, + const bool mainConfig = true); SetupItemTextField(std::string text, std::string description, - std::string keyName, SetupTabScroll *parent, + std::string keyName, SetupTabScroll *const parent, std::string eventName, std::string def, - bool mainConfig = true); + const bool mainConfig = true); ~SetupItemTextField(); @@ -188,14 +190,18 @@ class SetupItemIntTextField : public SetupItem { public: SetupItemIntTextField(std::string text, std::string description, - std::string keyName, SetupTabScroll *parent, - std::string eventName, int min, int max, - bool mainConfig = true); + std::string keyName, + SetupTabScroll *const parent, + std::string eventName, + const int min, const int max, + const bool mainConfig = true); SetupItemIntTextField(std::string text, std::string description, - std::string keyName, SetupTabScroll *parent, - std::string eventName, int min, int max, - std::string def, bool mainConfig = true); + std::string keyName, + SetupTabScroll *const parent, + std::string eventName, + const int min, const int max, + std::string def, const bool mainConfig = true); ~SetupItemIntTextField(); @@ -223,7 +229,8 @@ class SetupItemLabel : public SetupItem { public: SetupItemLabel(std::string text, std::string description, - SetupTabScroll *parent, bool separator = true); + SetupTabScroll *const parent, + const bool separator = true); ~SetupItemLabel(); @@ -246,14 +253,14 @@ class SetupItemDropDown : public SetupItem { public: SetupItemDropDown(std::string text, std::string description, - std::string keyName, SetupTabScroll *parent, - std::string eventName, gcn::ListModel *model, - bool mainConfig = true); + std::string keyName, SetupTabScroll *const parent, + std::string eventName, gcn::ListModel *const model, + const bool mainConfig = true); SetupItemDropDown(std::string text, std::string description, - std::string keyName, SetupTabScroll *parent, - std::string eventName, gcn::ListModel *model, - std::string def, bool mainConfig = true); + std::string keyName, SetupTabScroll *const parent, + std::string eventName, gcn::ListModel *const model, + std::string def, const bool mainConfig = true); ~SetupItemDropDown(); @@ -274,16 +281,19 @@ class SetupItemSlider : public SetupItem { public: SetupItemSlider(std::string text, std::string description, - std::string keyName, SetupTabScroll *parent, - std::string eventName, double min, double max, - int width = 150, bool onTheFly = false, - bool mainConfig = true); + std::string keyName, SetupTabScroll *const parent, + std::string eventName, + const double min, const double max, + const int width = 150, const bool onTheFly = false, + const bool mainConfig = true); SetupItemSlider(std::string text, std::string description, std::string keyName, SetupTabScroll *parent, - std::string eventName, double min, double max, - std::string def, int width = 150, - bool onTheFly = false, bool mainConfig = true); + std::string eventName, + const double min, const double max, + std::string def, const int width = 150, + const bool onTheFly = false, + const bool mainConfig = true); ~SetupItemSlider(); @@ -317,17 +327,20 @@ class SetupItemSlider2 : public SetupItem { public: SetupItemSlider2(std::string text, std::string description, - std::string keyName, SetupTabScroll *parent, - std::string eventName, int min, int max, - SetupItemNames *values, bool onTheFly = false, - bool mainConfig = true, bool doNotAlign = false); + std::string keyName, SetupTabScroll *const parent, + std::string eventName, const int min, const int max, + SetupItemNames *const values, + const bool onTheFly = false, + const bool mainConfig = true, + const bool doNotAlign = false); SetupItemSlider2(std::string text, std::string description, - std::string keyName, SetupTabScroll *parent, - std::string eventName, int min, int max, - SetupItemNames *values, std::string def, - bool onTheFly = false, bool mainConfig = true, - bool doNotAlign = false); + std::string keyName, SetupTabScroll *const parent, + std::string eventName, const int min, const int max, + SetupItemNames *const values, std::string def, + const bool onTheFly = false, + const bool mainConfig = true, + const bool doNotAlign = false); ~SetupItemSlider2(); @@ -341,7 +354,7 @@ class SetupItemSlider2 : public SetupItem void apply(std::string eventName); - void setInvertValue(int v); + void setInvertValue(const int v); protected: void updateLabel(); @@ -365,16 +378,17 @@ class SetupItemSliderList : public SetupItem { public: SetupItemSliderList(std::string text, std::string description, - std::string keyName, SetupTabScroll *parent, - std::string eventName, gcn::ListModel *model, - int width = 150, bool onTheFly = false, - bool mainConfig = true); + std::string keyName, SetupTabScroll *const parent, + std::string eventName, gcn::ListModel *const model, + const int width = 150, const bool onTheFly = false, + const bool mainConfig = true); SetupItemSliderList(std::string text, std::string description, - std::string keyName, SetupTabScroll *parent, - std::string eventName, gcn::ListModel *model, - std::string def, int width = 150, - bool onTheFly = false, bool mainConfig = true); + std::string keyName, SetupTabScroll *const parent, + std::string eventName, gcn::ListModel *const model, + std::string def, const int width = 150, + const bool onTheFly = false, + const bool mainConfig = true); ~SetupItemSliderList(); @@ -403,10 +417,10 @@ class SetupItemSound : public SetupItemSliderList { public: SetupItemSound(std::string text, std::string description, - std::string keyName, SetupTabScroll *parent, - std::string eventName, gcn::ListModel *model, - int width = 150, bool onTheFly = false, - bool mainConfig = true); + std::string keyName, SetupTabScroll *const parent, + std::string eventName, gcn::ListModel *const model, + const int width = 150, const bool onTheFly = false, + const bool mainConfig = true); void action(const gcn::ActionEvent &event); diff --git a/src/gui/widgets/setuptabscroll.cpp b/src/gui/widgets/setuptabscroll.cpp index 6bf627cdd..c668308c5 100644 --- a/src/gui/widgets/setuptabscroll.cpp +++ b/src/gui/widgets/setuptabscroll.cpp @@ -45,7 +45,7 @@ SetupTabScroll::~SetupTabScroll() mContainer = nullptr; std::set<SetupItem*>::iterator it = mAllItems.begin(); - std::set<SetupItem*>::iterator it_end = mAllItems.end(); + const std::set<SetupItem*>::iterator it_end = mAllItems.end(); while (it != it_end) { delete *it; @@ -54,12 +54,12 @@ SetupTabScroll::~SetupTabScroll() mAllItems.clear(); } -void SetupTabScroll::addControl(SetupItem *widget) +void SetupTabScroll::addControl(SetupItem *const widget) { const std::string actionId = widget->getActionEventId(); if (!actionId.empty()) { - std::map<std::string, SetupItem*>::iterator iter + const std::map<std::string, SetupItem*>::iterator iter = mItems.find(actionId); if (iter != mItems.end()) { @@ -71,9 +71,9 @@ void SetupTabScroll::addControl(SetupItem *widget) mAllItems.insert(widget); } -void SetupTabScroll::addControl(SetupItem *widget, std::string event) +void SetupTabScroll::addControl(SetupItem *const widget, std::string event) { - std::map<std::string, SetupItem*>::iterator iter + const std::map<std::string, SetupItem*>::iterator iter = mItems.find(event); if (iter != mItems.end()) { @@ -109,7 +109,7 @@ void SetupTabScroll::externalUpdated() for (std::map<std::string, SetupItem*>::const_iterator iter = mItems.begin(); iter != mItems.end(); ++ iter) { - SetupItem *widget = (*iter).second; + const SetupItem *const widget = (*iter).second; if (widget && !widget->isMainConfig()) (*iter).second->externalUpdated((*iter).first); } diff --git a/src/gui/widgets/setuptabscroll.h b/src/gui/widgets/setuptabscroll.h index e7151769e..2bd723434 100644 --- a/src/gui/widgets/setuptabscroll.h +++ b/src/gui/widgets/setuptabscroll.h @@ -39,9 +39,9 @@ class SetupTabScroll : public SetupTab ~SetupTabScroll(); - void addControl(SetupItem *widget); + void addControl(SetupItem *const widget); - void addControl(SetupItem *widget, std::string event); + void addControl(SetupItem *const widget, std::string event); VertContainer *getContainer() const { return mContainer; } diff --git a/src/gui/widgets/shopitems.cpp b/src/gui/widgets/shopitems.cpp index 5f13e5f71..d91e25304 100644 --- a/src/gui/widgets/shopitems.cpp +++ b/src/gui/widgets/shopitems.cpp @@ -28,7 +28,7 @@ #include "debug.h" -ShopItems::ShopItems(bool mergeDuplicates) : +ShopItems::ShopItems(const bool mergeDuplicates) : mMergeDuplicates(mergeDuplicates) { } @@ -43,7 +43,7 @@ int ShopItems::getNumberOfElements() return static_cast<int>(mShopItems.size()); } -bool ShopItems::empty() +bool ShopItems::empty() const { return mShopItems.empty(); } @@ -59,21 +59,23 @@ std::string ShopItems::getElementAt(int i) return mShopItems.at(i)->getDisplayName(); } -void ShopItems::addItem(int id, unsigned char color, int amount, int price) +void ShopItems::addItem(const int id, const unsigned char color, + const int amount, const int price) { mShopItems.push_back(new ShopItem(-1, id, color, amount, price)); } -void ShopItems::addItemNoDup(int id, unsigned char color, - int amount, int price) +void ShopItems::addItemNoDup(const int id, const unsigned char color, + const int amount, const int price) { - ShopItem *item = findItem(id, color); + const ShopItem *const item = findItem(id, color); if (!item) mShopItems.push_back(new ShopItem(-1, id, color, amount, price)); } -void ShopItems::addItem2(int inventoryIndex, int id, unsigned char color, - int quantity, int price) +void ShopItems::addItem2(const int inventoryIndex, const int id, + const unsigned char color, + const int quantity, const int price) { ShopItem *item = nullptr; if (mMergeDuplicates) @@ -98,7 +100,7 @@ ShopItem *ShopItems::at(unsigned int i) const return mShopItems.at(i); } -void ShopItems::erase(unsigned int i) +void ShopItems::erase(const unsigned int i) { if (i >= mShopItems.size()) return; @@ -106,7 +108,7 @@ void ShopItems::erase(unsigned int i) mShopItems.erase(mShopItems.begin() + i); } -void ShopItems::del(unsigned int i) +void ShopItems::del(const unsigned int i) { if (i >= mShopItems.size()) return; @@ -122,12 +124,12 @@ void ShopItems::clear() mShopItems.clear(); } -ShopItem *ShopItems::findItem(int id, unsigned char color) const +ShopItem *ShopItems::findItem(const int id, const unsigned char color) const { ShopItem *item; std::vector<ShopItem*>::const_iterator it = mShopItems.begin(); - std::vector<ShopItem*>::const_iterator e = mShopItems.end(); + const std::vector<ShopItem*>::const_iterator e = mShopItems.end(); while (it != e) { item = *(it); diff --git a/src/gui/widgets/shopitems.h b/src/gui/widgets/shopitems.h index c013f1810..ff1b0ca7a 100644 --- a/src/gui/widgets/shopitems.h +++ b/src/gui/widgets/shopitems.h @@ -48,14 +48,15 @@ class ShopItems : public gcn::ListModel * @param mergeDuplicates lets the Shop look for duplicate entries and * merges them to one item. */ - ShopItems(bool mergeDuplicates = false); + ShopItems(const bool mergeDuplicates = false); ~ShopItems(); /** * Adds an item to the list. */ - void addItem(int id, unsigned char color, int amount, int price); + void addItem(const int id, const unsigned char color, + const int amount, const int price); /** * Adds an item to the list (used by sell dialog). Looks for @@ -66,17 +67,19 @@ class ShopItems : public gcn::ListModel * @param quantity number of available copies of the item * @param price price of the item */ - void addItem2(int inventoryIndex, int id, unsigned char color, - int amount, int price); + void addItem2(const int inventoryIndex, const int id, + const unsigned char color, + const int amount, const int price); - void addItemNoDup(int id, unsigned char color, int amount, int price); + void addItemNoDup(const int id, const unsigned char color, + const int amount, const int price); /** * Returns the number of items in the shop. */ int getNumberOfElements(); - bool empty(); + bool empty() const; /** * Returns the name of item number i in the shop. @@ -95,14 +98,14 @@ class ShopItems : public gcn::ListModel * * @param i index to remove */ - void erase(unsigned int i); + void erase(const unsigned int i); /** * Removes an element from the shop and destroy it. * * @param i index to remove */ - void del(unsigned int i); + void del(const unsigned int i); /** * Clears the list of items in the shop. @@ -119,7 +122,7 @@ class ShopItems : public gcn::ListModel * * @return the item found or 0 */ - ShopItem *findItem(int id, unsigned char color) const; + ShopItem *findItem(const int id, const unsigned char color) const; /** The list of items in the shop. */ std::vector<ShopItem*> mShopItems; diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp index 2ee60d56f..0bd126482 100644 --- a/src/gui/widgets/shoplistbox.cpp +++ b/src/gui/widgets/shoplistbox.cpp @@ -44,7 +44,7 @@ const int ITEM_ICON_SIZE = 32; float ShopListBox::mAlpha = 1.0; -ShopListBox::ShopListBox(gcn::ListModel *listModel): +ShopListBox::ShopListBox(gcn::ListModel *const listModel) : ListBox(listModel), mPlayerMoney(0), mShopItems(nullptr), @@ -58,7 +58,8 @@ ShopListBox::ShopListBox(gcn::ListModel *listModel): setForegroundColor(Theme::getThemeColor(Theme::LISTBOX)); } -ShopListBox::ShopListBox(gcn::ListModel *listModel, ShopItems *shopListModel): +ShopListBox::ShopListBox(gcn::ListModel *const listModel, + ShopItems *const shopListModel) : ListBox(listModel), mPlayerMoney(0), mShopItems(shopListModel), @@ -76,7 +77,7 @@ void ShopListBox::init() { } -void ShopListBox::setPlayersMoney(int money) +void ShopListBox::setPlayersMoney(const int money) { mPlayerMoney = money; } @@ -89,7 +90,7 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics) if (Client::getGuiAlpha() != mAlpha) mAlpha = Client::getGuiAlpha(); - int alpha = static_cast<int>(mAlpha * 255.0f); + const int alpha = static_cast<int>(mAlpha * 255.0f); mHighlightColor.a = alpha; Graphics *graphics = static_cast<Graphics*>(gcnGraphics); @@ -141,7 +142,7 @@ void ShopListBox::draw(gcn::Graphics *gcnGraphics) if (mShopItems) { - Image *icon = mShopItems->at(i)->getImage(); + Image *const icon = mShopItems->at(i)->getImage(); if (icon) { icon->setAlpha(1.0f); @@ -160,7 +161,7 @@ void ShopListBox::adjustSize() setHeight(mRowHeight * mListModel->getNumberOfElements()); } -void ShopListBox::setPriceCheck(bool check) +void ShopListBox::setPriceCheck(const bool check) { mPriceCheck = check; } @@ -176,7 +177,7 @@ void ShopListBox::mouseMoved(gcn::MouseEvent &event) return; } - int index = event.getY() / mRowHeight; + const int index = event.getY() / mRowHeight; if (index < 0 || index >= mShopItems->getNumberOfElements()) { @@ -184,7 +185,7 @@ void ShopListBox::mouseMoved(gcn::MouseEvent &event) } else { - Item *item = mShopItems->at(index); + const Item *const item = mShopItems->at(index); if (item) { mItemPopup->setItem(item); diff --git a/src/gui/widgets/shoplistbox.h b/src/gui/widgets/shoplistbox.h index 75598aa94..f34c8d772 100644 --- a/src/gui/widgets/shoplistbox.h +++ b/src/gui/widgets/shoplistbox.h @@ -41,12 +41,13 @@ class ShopListBox : public ListBox /** * Constructor. */ - ShopListBox(gcn::ListModel *listModel); + ShopListBox(gcn::ListModel *const listModel); /** * Constructor with shopitems */ - ShopListBox(gcn::ListModel *listModel, ShopItems *shopListModel); + ShopListBox(gcn::ListModel *const listModel, + ShopItems *const shopListModel); /** * Draws the list box. @@ -62,7 +63,7 @@ class ShopListBox : public ListBox /** * gives information about the current player's money */ - void setPlayersMoney(int money); + void setPlayersMoney(const int money); /** * Adjust List draw size @@ -73,7 +74,7 @@ class ShopListBox : public ListBox * Set on/off the disabling of too expensive items. * (Good for selling mode.) */ - void setPriceCheck(bool check); + void setPriceCheck(const bool check); void mouseMoved(gcn::MouseEvent &event); diff --git a/src/gui/widgets/shortcutcontainer.cpp b/src/gui/widgets/shortcutcontainer.cpp index 10bdf4045..b54364ebd 100644 --- a/src/gui/widgets/shortcutcontainer.cpp +++ b/src/gui/widgets/shortcutcontainer.cpp @@ -57,7 +57,8 @@ void ShortcutContainer::widgetResized(const gcn::Event &event A_UNUSED) setHeight(mGridHeight * mBoxHeight); } -int ShortcutContainer::getIndexFromGrid(int pointX, int pointY) const +int ShortcutContainer::getIndexFromGrid(const int pointX, + const int pointY) const { const gcn::Rectangle tRect = gcn::Rectangle(0, 0, mGridWidth * mBoxWidth, mGridHeight * mBoxHeight); diff --git a/src/gui/widgets/shortcutcontainer.h b/src/gui/widgets/shortcutcontainer.h index 72f8b9cac..6de2d1963 100644 --- a/src/gui/widgets/shortcutcontainer.h +++ b/src/gui/widgets/shortcutcontainer.h @@ -95,7 +95,7 @@ class ShortcutContainer : public gcn::Widget, * @param pointY Y coordinate of the point. * @return index on success, -1 on failure. */ - int getIndexFromGrid(int pointX, int pointY) const; + int getIndexFromGrid(const int pointX, const int pointY) const; Image *mBackgroundImg; static float mAlpha; diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp index 0a130f60e..c5eac9769 100644 --- a/src/gui/widgets/slider.cpp +++ b/src/gui/widgets/slider.cpp @@ -43,14 +43,14 @@ static std::string const data[2] = "slider_highlighted.xml" }; -Slider::Slider(double scaleEnd): +Slider::Slider(const double scaleEnd) : gcn::Slider(scaleEnd), mHasMouse(false) { init(); } -Slider::Slider(double scaleStart, double scaleEnd): +Slider::Slider(const double scaleStart, const double scaleEnd) : gcn::Slider(scaleStart, scaleEnd), mHasMouse(false) { @@ -62,7 +62,7 @@ Slider::~Slider() mInstances--; if (mInstances == 0 && Theme::instance()) { - Theme *theme = Theme::instance(); + Theme *const theme = Theme::instance(); for (int mode = 0; mode < 2; mode ++) theme->unloadRect(buttons[mode]); } @@ -94,8 +94,8 @@ void Slider::init() void Slider::updateAlpha() { - float alpha = std::max(Client::getGuiAlpha(), - Theme::instance()->getMinimumOpacity()); + const float alpha = std::max(Client::getGuiAlpha(), + Theme::instance()->getMinimumOpacity()); if (alpha != mAlpha) { @@ -120,9 +120,9 @@ void Slider::draw(gcn::Graphics *graphics) } int w = getWidth(); - int h = getHeight(); + const int h = getHeight(); int x = 0; - int y = mHasMouse ? (h - buttons[1].grid[HSTART]->getHeight()) / 2 : + const int y = mHasMouse ? (h - buttons[1].grid[HSTART]->getHeight()) / 2 : (h - buttons[0].grid[HSTART]->getHeight()) / 2; updateAlpha(); @@ -138,7 +138,7 @@ void Slider::draw(gcn::Graphics *graphics) if (buttons[0].grid[HMID]) { - const Image *hMid = buttons[0].grid[HMID]; + const Image *const hMid = buttons[0].grid[HMID]; static_cast<Graphics*>(graphics)-> drawImagePattern(hMid, x, y, w, hMid->getHeight()); } @@ -160,7 +160,7 @@ void Slider::draw(gcn::Graphics *graphics) if (buttons[1].grid[HMID]) { - const Image *hMid = buttons[1].grid[HMID]; + const Image *const hMid = buttons[1].grid[HMID]; static_cast<Graphics*>(graphics)->drawImagePattern( hMid, x, y, w, hMid->getHeight()); @@ -177,9 +177,9 @@ void Slider::draw(gcn::Graphics *graphics) drawMarker(graphics); } -void Slider::drawMarker(gcn::Graphics *graphics) +void Slider::drawMarker(gcn::Graphics *const graphics) { - const Image *img = (mHasMouse ? buttons[1].grid[HGRIP] + const Image *const img = (mHasMouse ? buttons[1].grid[HGRIP] : buttons[0].grid[HGRIP]); if (!img) return; @@ -200,7 +200,7 @@ void Slider::mouseExited(gcn::MouseEvent& event A_UNUSED) void Slider::keyPressed(gcn::KeyEvent& keyEvent) { - int action = static_cast<KeyEvent*>(&keyEvent)->getActionId(); + const int action = static_cast<KeyEvent*>(&keyEvent)->getActionId(); if (getOrientation() == HORIZONTAL) { diff --git a/src/gui/widgets/slider.h b/src/gui/widgets/slider.h index 9afc05fcf..7ef121346 100644 --- a/src/gui/widgets/slider.h +++ b/src/gui/widgets/slider.h @@ -39,12 +39,12 @@ class Slider : public gcn::Slider /** * Constructor with scale start equal to 0. */ - Slider(double scaleEnd = 1.0); + Slider(const double scaleEnd = 1.0); /** * Constructor. */ - Slider(double scaleStart, double scaleEnd); + Slider(const double scaleStart, const double scaleEnd); /** * Destructor. @@ -64,7 +64,7 @@ class Slider : public gcn::Slider /** * Draws the marker. */ - void drawMarker(gcn::Graphics *graphics); + void drawMarker(gcn::Graphics *const graphics); /** * Called when the mouse enteres the widget area. diff --git a/src/gui/widgets/sliderlist.cpp b/src/gui/widgets/sliderlist.cpp index 50af87205..dd27cfbe5 100644 --- a/src/gui/widgets/sliderlist.cpp +++ b/src/gui/widgets/sliderlist.cpp @@ -39,8 +39,8 @@ static const int buttonWidth = 27; static const int buttonSpace = 30; static const int sliderHeight = 30; -SliderList::SliderList(gcn::ListModel *listModel, - gcn::ActionListener* listener, +SliderList::SliderList(gcn::ListModel *const listModel, + gcn::ActionListener *const listener, std::string eventId) : mLabel(new Label), mListModel(listModel), @@ -204,11 +204,11 @@ int SliderList::getMaxLabelWidth() return 1; int maxWidth = 0; - SDLFont *font = gui->getFont(); + const SDLFont *const font = gui->getFont(); for (int f = 0; f < mListModel->getNumberOfElements(); f ++) { - int w = font->getWidth(mListModel->getElementAt(f)); + const int w = font->getWidth(mListModel->getElementAt(f)); if (w > maxWidth) maxWidth = w; } diff --git a/src/gui/widgets/sliderlist.h b/src/gui/widgets/sliderlist.h index b2239834d..992316a1b 100644 --- a/src/gui/widgets/sliderlist.h +++ b/src/gui/widgets/sliderlist.h @@ -37,8 +37,8 @@ class SliderList : public Container, public gcn::MouseListener { public: - SliderList(gcn::ListModel *listModel = nullptr, - gcn::ActionListener* listener = nullptr, + SliderList(gcn::ListModel *const listModel = nullptr, + gcn::ActionListener *const listener = nullptr, std::string eventId = ""); ~SliderList(); diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp index 5236daec4..ec79ccb93 100644 --- a/src/gui/widgets/spellshortcutcontainer.cpp +++ b/src/gui/widgets/spellshortcutcontainer.cpp @@ -44,7 +44,7 @@ #include "debug.h" -SpellShortcutContainer::SpellShortcutContainer(unsigned number): +SpellShortcutContainer::SpellShortcutContainer(const unsigned number) : ShortcutContainer(), mSpellClicked(false), mSpellMoved(nullptr), @@ -99,11 +99,11 @@ void SpellShortcutContainer::draw(gcn::Graphics *graphics) mBackgroundImg->setAlpha(mAlpha); } - Graphics *g = static_cast<Graphics*>(graphics); + Graphics *const g = static_cast<Graphics *const>(graphics); graphics->setFont(getFont()); - int selectedId = spellShortcut->getSelectedItem(); + const int selectedId = spellShortcut->getSelectedItem(); g->setColor(getForegroundColor()); if (mBackgroundImg) @@ -120,7 +120,7 @@ void SpellShortcutContainer::draw(gcn::Graphics *graphics) const int itemX = (i % mGridWidth) * mBoxWidth; const int itemY = (i / mGridWidth) * mBoxHeight; - int itemId = spellShortcut->getItem( + const int itemId = spellShortcut->getItem( (mNumber * SPELL_SHORTCUT_ITEMS) + i); if (selectedId >= 0 && itemId == selectedId) { @@ -131,12 +131,12 @@ void SpellShortcutContainer::draw(gcn::Graphics *graphics) if (!spellManager) continue; - TextCommand *spell = spellManager->getSpell(itemId); + const TextCommand *const spell = spellManager->getSpell(itemId); if (spell) { if (!spell->isEmpty()) { - Image* image = spell->getImage(); + Image *const image = spell->getImage(); if (image) { @@ -229,10 +229,10 @@ void SpellShortcutContainer::mouseReleased(gcn::MouseEvent &event) if (selectedId != itemId) { - TextCommand *spell = spellManager->getSpell(itemId); + const TextCommand *const spell = spellManager->getSpell(itemId); if (spell && !spell->isEmpty()) { - int num = itemShortcutWindow->getTabIndex(); + const int num = itemShortcutWindow->getTabIndex(); if (num >= 0 && num < static_cast<int>(SHORTCUT_TABS) && itemShortcut[num]) { @@ -244,7 +244,7 @@ void SpellShortcutContainer::mouseReleased(gcn::MouseEvent &event) } else { - int num = itemShortcutWindow->getTabIndex(); + const int num = itemShortcutWindow->getTabIndex(); if (num >= 0 && num < static_cast<int>(SHORTCUT_TABS) && itemShortcut[num]) { @@ -279,7 +279,7 @@ void SpellShortcutContainer::mouseMoved(gcn::MouseEvent &event) (mNumber * SPELL_SHORTCUT_ITEMS) + index); mSpellPopup->setVisible(false); - TextCommand *spell = spellManager->getSpell(itemId); + TextCommand *const spell = spellManager->getSpell(itemId); if (spell && !spell->isEmpty()) { mSpellPopup->setItem(spell); diff --git a/src/gui/widgets/spellshortcutcontainer.h b/src/gui/widgets/spellshortcutcontainer.h index e8f4cc2dc..22fe15d95 100644 --- a/src/gui/widgets/spellshortcutcontainer.h +++ b/src/gui/widgets/spellshortcutcontainer.h @@ -42,7 +42,7 @@ class SpellShortcutContainer : public ShortcutContainer /** * Constructor. Initializes the graphic. */ - SpellShortcutContainer(unsigned number); + SpellShortcutContainer(const unsigned number); /** * Destructor. diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp index a9f3763b5..bf37a643e 100644 --- a/src/gui/widgets/tab.cpp +++ b/src/gui/widgets/tab.cpp @@ -78,7 +78,7 @@ Tab::~Tab() mInstances--; if (mInstances == 0 && Theme::instance()) { - Theme *theme = Theme::instance(); + Theme *const theme = Theme::instance(); for (int mode = 0; mode < TAB_COUNT; mode ++) theme->unloadRect(tabImg[mode]); } @@ -112,7 +112,7 @@ void Tab::init() void Tab::updateAlpha() { - float alpha = std::max(Client::getGuiAlpha(), + const float alpha = std::max(Client::getGuiAlpha(), Theme::instance()->getMinimumOpacity()); // TODO We don't need to do this for every tab on every draw @@ -184,12 +184,12 @@ void Tab::draw(gcn::Graphics *graphics) drawChildren(graphics); } -void Tab::setTabColor(const gcn::Color *color) +void Tab::setTabColor(const gcn::Color *const color) { mTabColor = color; } -void Tab::setFlash(int flash) +void Tab::setFlash(const int flash) { mFlash = flash; } @@ -204,7 +204,7 @@ void Tab::widgetMoved(const gcn::Event &event A_UNUSED) mRedraw = true; } -void Tab::setLabelFont(gcn::Font *font) +void Tab::setLabelFont(gcn::Font *const font) { if (!mLabel) return; diff --git a/src/gui/widgets/tab.h b/src/gui/widgets/tab.h index 829689543..0907379d0 100644 --- a/src/gui/widgets/tab.h +++ b/src/gui/widgets/tab.h @@ -54,12 +54,12 @@ class Tab : public gcn::Tab, public gcn::WidgetListener /** * Set the normal color fo the tab's text. */ - void setTabColor(const gcn::Color *color); + void setTabColor(const gcn::Color *const color); /** * Set tab flashing state */ - void setFlash(int flash); + void setFlash(const int flash); int getFlash() const { return mFlash; } @@ -68,7 +68,7 @@ class Tab : public gcn::Tab, public gcn::WidgetListener void widgetMoved(const gcn::Event &event); - void setLabelFont(gcn::Font *font); + void setLabelFont(gcn::Font *const font); gcn::Label *getLabel() const { return mLabel; } diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index 43e829a4e..ae5f92fd9 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -61,7 +61,7 @@ TabbedArea::~TabbedArea() mArrowButton[1] = nullptr; } -void TabbedArea::enableScrollButtons(bool enable) +void TabbedArea::enableScrollButtons(const bool enable) { if (mEnableScrollButtons && !enable) { @@ -86,7 +86,8 @@ int TabbedArea::getNumberOfTabs() const Tab *TabbedArea::getTab(const std::string &name) const { - TabContainer::const_iterator itr = mTabs.begin(), itr_end = mTabs.end(); + TabContainer::const_iterator itr = mTabs.begin(); + const TabContainer::const_iterator itr_end = mTabs.end(); while (itr != itr_end) { if ((*itr).first->getCaption() == name) @@ -107,7 +108,8 @@ 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(); + TabContainer::const_iterator itr = mTabs.begin(); + const TabContainer::const_iterator itr_end = mTabs.end(); while (itr != itr_end) { if ((*itr).first->getCaption() == name) @@ -121,7 +123,7 @@ gcn::Widget *TabbedArea::getWidget(const std::string &name) const gcn::Widget *TabbedArea::getCurrentWidget() { - gcn::Tab *tab = getSelectedTab(); + const gcn::Tab *const tab = getSelectedTab(); if (tab) return getWidget(tab->getCaption()); @@ -136,17 +138,18 @@ void TabbedArea::addTab(gcn::Tab* tab, gcn::Widget* widget) gcn::TabbedArea::addTab(tab, widget); - int width = getWidth() - 2 * getFrameSize(); - int height = getHeight() - 2 * getFrameSize() - mTabContainer->getHeight(); + const int width = getWidth() - 2 * getFrameSize(); + const int height = getHeight() - 2 * getFrameSize() + - mTabContainer->getHeight(); widget->setSize(width, height); updateTabsWidth(); updateArrowEnableState(); } -void TabbedArea::addTab(const std::string &caption, gcn::Widget *widget) +void TabbedArea::addTab(const std::string &caption, gcn::Widget *const widget) { - Tab *tab = new Tab; + Tab *const tab = new Tab; tab->setCaption(caption); mTabsToDelete.push_back(tab); @@ -159,7 +162,7 @@ void TabbedArea::removeTab(gcn::Tab *tab) if (tab == mSelectedTab) { - int index = getSelectedTabIndex(); + const int index = getSelectedTabIndex(); if (index == static_cast<int>(mTabs.size()) - 1 && mTabs.size() == 1) tabIndexToBeSelected = -1; @@ -221,9 +224,9 @@ void TabbedArea::mousePressed(gcn::MouseEvent &mouseEvent) if (mouseEvent.getButton() == gcn::MouseEvent::LEFT) { - gcn::Widget *widget = mTabContainer->getWidgetAt(mouseEvent.getX(), - mouseEvent.getY()); - gcn::Tab *tab = dynamic_cast<gcn::Tab*>(widget); + gcn::Widget *const widget = mTabContainer->getWidgetAt( + mouseEvent.getX(), mouseEvent.getY()); + gcn::Tab *const tab = dynamic_cast<gcn::Tab *const>(widget); if (tab) { @@ -237,7 +240,7 @@ void TabbedArea::setSelectedTab(gcn::Tab *tab) { gcn::TabbedArea::setSelectedTab(tab); - Tab *newTab = dynamic_cast<Tab*>(tab); + Tab *const newTab = dynamic_cast<Tab *const>(tab); if (newTab) newTab->setCurrent(); @@ -265,20 +268,20 @@ void TabbedArea::setSelectedTabByPos(int tab) void TabbedArea::widgetResized(const gcn::Event &event A_UNUSED) { - int width = getWidth() - 2 * getFrameSize() - - 2 * mWidgetContainer->getFrameSize(); - int height = getHeight() - 2 * getFrameSize() - mWidgetContainer->getY() - - 2 * mWidgetContainer->getFrameSize(); + const int width = getWidth() - 2 * getFrameSize() + - 2 * mWidgetContainer->getFrameSize(); + const int height = getHeight() - 2 * getFrameSize() + - mWidgetContainer->getY() - 2 * mWidgetContainer->getFrameSize(); mWidgetContainer->setSize(width, height); - gcn::Widget *w = getCurrentWidget(); + gcn::Widget *const w = getCurrentWidget(); if (w) { int newScroll = 0; ScrollArea* scr = nullptr; if (mFollowDownScroll && height != 0) { - gcn::Rectangle rect = w->getDimension(); + const gcn::Rectangle rect = w->getDimension(); if (rect.height != 0 && rect.height > height + 2) { scr = dynamic_cast<ScrollArea*>(w); @@ -362,7 +365,7 @@ void TabbedArea::adjustTabPositions() int x = mArrowButton[0]->isVisible() ? mArrowButton[0]->getWidth() : 0; for (size_t i = mTabScrollIndex; i < sz; ++i) { - gcn::Tab* tab = mTabs[i].first; + gcn::Tab *const tab = mTabs[i].first; if (!tab) continue; tab->setPosition(x, maxTabHeight - tab->getHeight()); @@ -375,7 +378,7 @@ void TabbedArea::adjustTabPositions() x = 0; for (unsigned i = 0; i < mTabScrollIndex; ++i) { - gcn::Tab* tab = mTabs[i].first; + gcn::Tab *const tab = mTabs[i].first; if (tab) { x -= tab->getWidth(); @@ -387,8 +390,8 @@ void TabbedArea::adjustTabPositions() void TabbedArea::action(const gcn::ActionEvent& actionEvent) { - Widget* source = actionEvent.getSource(); - Tab* tab = dynamic_cast<Tab*>(source); + Widget *const source = actionEvent.getSource(); + Tab *const tab = dynamic_cast<Tab *const>(source); if (tab) { @@ -451,14 +454,14 @@ void TabbedArea::updateArrowEnableState() } } -Tab *TabbedArea::getTabByIndex(int index) const +Tab *TabbedArea::getTabByIndex(const int index) const { if (index < 0 || index >= static_cast<int>(mTabs.size())) return nullptr; return static_cast<Tab*>(mTabs[index].first); } -gcn::Widget *TabbedArea::getWidgetByIndex(int index) const +gcn::Widget *TabbedArea::getWidgetByIndex(const int index) const { if (index < 0 || index >= static_cast<int>(mTabs.size())) return nullptr; @@ -487,7 +490,7 @@ void TabbedArea::keyPressed(gcn::KeyEvent& keyEvent) if (mBlockSwitching || keyEvent.isConsumed() || !isFocused()) return; - int actionId = static_cast<KeyEvent*>(&keyEvent)->getActionId(); + const int actionId = static_cast<KeyEvent*>(&keyEvent)->getActionId(); if (actionId == Input::KEY_GUI_LEFT) { diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h index 85209691b..0513c2858 100644 --- a/src/gui/widgets/tabbedarea.h +++ b/src/gui/widgets/tabbedarea.h @@ -64,9 +64,9 @@ class TabbedArea : public gcn::TabbedArea, public gcn::WidgetListener */ Tab *getTab(const std::string &name) const; - Tab *getTabByIndex(int index) const; + Tab *getTabByIndex(const int index) const; - gcn::Widget *getWidgetByIndex(int index) const; + gcn::Widget *getWidgetByIndex(const int index) const; /** * Returns the widget with the tab that has specified caption @@ -93,7 +93,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 *const widget); /** * Overload the remove tab function as it's broken in guichan 0.8. @@ -131,7 +131,7 @@ class TabbedArea : public gcn::TabbedArea, public gcn::WidgetListener void mousePressed(gcn::MouseEvent &mouseEvent); - void enableScrollButtons(bool enable); + void enableScrollButtons(const bool enable); void setRightMargin(int n) { mRightMargin = n; } diff --git a/src/gui/widgets/tablemodel.cpp b/src/gui/widgets/tablemodel.cpp index 04f81fdd6..f43622a9c 100644 --- a/src/gui/widgets/tablemodel.cpp +++ b/src/gui/widgets/tablemodel.cpp @@ -28,13 +28,13 @@ #include "debug.h" -void TableModel::installListener(TableModelListener *listener) +void TableModel::installListener(TableModelListener *const listener) { if (listener) listeners.insert(listener); } -void TableModel::removeListener(TableModelListener *listener) +void TableModel::removeListener(TableModelListener *const listener) { if (listener) listeners.erase(listener); @@ -63,7 +63,7 @@ void TableModel::signalAfterUpdate() #define WIDGET_AT(row, column) (((row) * mColumns) + (column)) #define DYN_SIZE(h) ((h) >= 0) -StaticTableModel::StaticTableModel(int row, int column) : +StaticTableModel::StaticTableModel(const int row, const int column) : mRows(row), mColumns(column), mHeight(1) @@ -85,7 +85,8 @@ void StaticTableModel::resize() mTableModel.resize(mRows * mColumns, nullptr); } -void StaticTableModel::set(int row, int column, gcn::Widget *widget) +void StaticTableModel::set(const int row, const int column, + gcn::Widget *const widget) { if (!widget || row >= mRows || row < 0 || column >= mColumns || column < 0) @@ -120,7 +121,7 @@ gcn::Widget *StaticTableModel::getElementAt(int row, int column) const return mTableModel[WIDGET_AT(row, column)]; } -void StaticTableModel::fixColumnWidth(int column, int width) +void StaticTableModel::fixColumnWidth(const int column, const int width) { if (width < 0 || column < 0 || column >= mColumns) return; @@ -128,7 +129,7 @@ void StaticTableModel::fixColumnWidth(int column, int width) mWidths[column] = -width; // Negate to tag as fixed } -void StaticTableModel::fixRowHeight(int height) +void StaticTableModel::fixRowHeight(const int height) { if (height < 0) return; diff --git a/src/gui/widgets/tablemodel.h b/src/gui/widgets/tablemodel.h index 0e459a014..86acd0cc9 100644 --- a/src/gui/widgets/tablemodel.h +++ b/src/gui/widgets/tablemodel.h @@ -83,9 +83,9 @@ public: */ virtual gcn::Widget *getElementAt(int row, int column) const = 0; - virtual void installListener(TableModelListener *listener); + virtual void installListener(TableModelListener *const listener); - virtual void removeListener(TableModelListener *listener); + virtual void removeListener(TableModelListener *const listener); protected: /** @@ -106,7 +106,8 @@ private: class StaticTableModel : public TableModel { public: - StaticTableModel(int width, int height); + StaticTableModel(const int width, const int height); + virtual ~StaticTableModel(); /** @@ -114,7 +115,8 @@ public: * The model is resized to accomodate the widget's width and height, * unless column width / row height have been fixed. */ - virtual void set(int row, int column, gcn::Widget *widget); + virtual void set(const int row, const int column, + gcn::Widget *const widget); /** * Fixes the column width for a given column; this overrides dynamic width @@ -122,14 +124,14 @@ public: * * Semantics are undefined for width 0. */ - virtual void fixColumnWidth(int column, int width); + virtual void fixColumnWidth(const int column, const int width); /** * Fixes the row height; this overrides dynamic height inference. * * Semantics are undefined for width 0. */ - virtual void fixRowHeight(int height); + virtual void fixRowHeight(const int height); /** * Resizes the table model diff --git a/src/gui/widgets/tabstrip.cpp b/src/gui/widgets/tabstrip.cpp index 758b69846..3e408288d 100644 --- a/src/gui/widgets/tabstrip.cpp +++ b/src/gui/widgets/tabstrip.cpp @@ -27,19 +27,20 @@ #include "debug.h" -TabStrip::TabStrip(std::string group, int height, int spacing) : +TabStrip::TabStrip(const std::string &group, const int height, + const int spacing) : WidgetGroup(group, height, spacing) { } -TabStrip::TabStrip(int height, int spacing) : +TabStrip::TabStrip(const int height, const int spacing) : WidgetGroup("", height, spacing) { } gcn::Widget *TabStrip::createWidget(std::string text) { - Button *widget = new Button(); + Button *const widget = new Button(); widget->setStick(true); widget->setCaption(text); widget->adjustSize(); @@ -53,7 +54,7 @@ void TabStrip::action(const gcn::ActionEvent &event) WidgetGroup::action(event); if (event.getSource()) { - gcn::Widget *widget = event.getSource(); + gcn::Widget *const widget = event.getSource(); if (static_cast<Button*>(widget)->isPressed2()) { for (WidgetListConstIterator iter = mWidgets.begin(); @@ -61,7 +62,7 @@ void TabStrip::action(const gcn::ActionEvent &event) { if (*iter != widget) { - Button *button = static_cast<Button*>(*iter); + Button *const button = static_cast<Button*>(*iter); button->setPressed(false); } } diff --git a/src/gui/widgets/tabstrip.h b/src/gui/widgets/tabstrip.h index 078845b39..d7aa2a700 100644 --- a/src/gui/widgets/tabstrip.h +++ b/src/gui/widgets/tabstrip.h @@ -29,9 +29,10 @@ class TabStrip : public WidgetGroup { public: - TabStrip(std::string group, int height, int spacing = 0); + TabStrip(const std::string &group, const int height, + const int spacing = 0); - TabStrip(int height, int spacing = 0); + TabStrip(const int height, const int spacing = 0); gcn::Widget *createWidget(std::string name); diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp index 06a24c68f..5079b8bf2 100644 --- a/src/gui/widgets/textbox.cpp +++ b/src/gui/widgets/textbox.cpp @@ -41,7 +41,7 @@ TextBox::TextBox() : mMinWidth = getWidth(); } -void TextBox::setTextWrapped(const std::string &text, int minDimension) +void TextBox::setTextWrapped(const std::string &text, const int minDimension) { // Make sure parent scroll area sets width of this widget if (getParent()) @@ -91,7 +91,7 @@ void TextBox::setTextWrapped(const std::string &text, int minDimension) std::string word = line.substr(lastSpacePos, spacePos - lastSpacePos); - int width = getFont()->getWidth(word); + const int width = getFont()->getWidth(word); if (xpos == 0 && width > mMinWidth) { @@ -158,8 +158,8 @@ void TextBox::setTextWrapped(const std::string &text, int minDimension) void TextBox::keyPressed(gcn::KeyEvent& keyEvent) { - gcn::Key key = keyEvent.getKey(); - int action = static_cast<KeyEvent*>(&keyEvent)->getActionId(); + const gcn::Key key = keyEvent.getKey(); + const int action = static_cast<KeyEvent*>(&keyEvent)->getActionId(); switch (action) { @@ -282,11 +282,11 @@ void TextBox::keyPressed(gcn::KeyEvent& keyEvent) case Input::KEY_GUI_PAGE_UP: { - gcn::Widget* par = getParent(); + gcn::Widget *const par = getParent(); if (par) { - int rowsPerPage = par->getChildrenArea().height + const int rowsPerPage = par->getChildrenArea().height / getFont()->getHeight(); mCaretRow -= rowsPerPage; @@ -298,11 +298,11 @@ void TextBox::keyPressed(gcn::KeyEvent& keyEvent) case Input::KEY_GUI_PAGE_DOWN: { - gcn::Widget* par = getParent(); + gcn::Widget *const par = getParent(); if (par) { - int rowsPerPage = par->getChildrenArea().height + const int rowsPerPage = par->getChildrenArea().height / getFont()->getHeight(); mCaretRow += rowsPerPage; diff --git a/src/gui/widgets/textbox.h b/src/gui/widgets/textbox.h index 5f69dcf51..aafd79627 100644 --- a/src/gui/widgets/textbox.h +++ b/src/gui/widgets/textbox.h @@ -46,7 +46,7 @@ class TextBox : public gcn::TextBox /** * Sets the text after wrapping it to the current width of the widget. */ - void setTextWrapped(const std::string &text, int minDimension); + void setTextWrapped(const std::string &text, const int minDimension); /** * Get the minimum text width for the text box. diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index 1c22a0a7b..c2189e74a 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -47,9 +47,9 @@ int TextField::instances = 0; float TextField::mAlpha = 1.0; ImageRect TextField::skin; -TextField::TextField(const std::string &text, bool loseFocusOnTab, - gcn::ActionListener* listener, std::string eventId, - bool sendAlwaysEvents): +TextField::TextField(const std::string &text, const bool loseFocusOnTab, + gcn::ActionListener *const listener, std::string eventId, + const bool sendAlwaysEvents): gcn::TextField(text), mSendAlwaysEvents(sendAlwaysEvents), mNumeric(false), @@ -86,7 +86,7 @@ TextField::~TextField() void TextField::updateAlpha() { - float alpha = std::max(Client::getGuiAlpha(), + const float alpha = std::max(Client::getGuiAlpha(), Theme::instance()->getMinimumOpacity()); if (alpha != mAlpha) @@ -128,13 +128,13 @@ void TextField::drawFrame(gcn::Graphics *graphics) static_cast<Graphics*>(graphics)->drawImageRect(0, 0, w, h, skin); } -void TextField::setNumeric(bool numeric) +void TextField::setNumeric(const bool numeric) { mNumeric = numeric; if (!numeric) return; - const char *text = mText.c_str(); + const char *const text = mText.c_str(); for (const char *textPtr = text; *textPtr; ++textPtr) { if (*textPtr < '0' || *textPtr > '9') @@ -150,7 +150,7 @@ int TextField::getValue() const if (!mNumeric) return 0; - int value = atoi(mText.c_str()); + const int value = atoi(mText.c_str()); if (value < mMinimum) return mMinimum; @@ -162,7 +162,7 @@ int TextField::getValue() const void TextField::keyPressed(gcn::KeyEvent &keyEvent) { - int val = keyEvent.getKey().getValue(); + const int val = keyEvent.getKey().getValue(); if (val >= 32) { @@ -335,7 +335,7 @@ void TextField::keyPressed(gcn::KeyEvent &keyEvent) return; } - int action = static_cast<KeyEvent*>(&keyEvent)->getActionId(); + const int action = static_cast<KeyEvent*>(&keyEvent)->getActionId(); switch (action) { @@ -435,7 +435,7 @@ void TextField::handlePaste() } } -void TextField::handleCopy() +void TextField::handleCopy() const { std::string text = getText(); sendBuffer(text); diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h index fef606526..12a101b0e 100644 --- a/src/gui/widgets/textfield.h +++ b/src/gui/widgets/textfield.h @@ -41,9 +41,11 @@ class TextField : public gcn::TextField /** * Constructor, initializes the text field with the given string. */ - TextField(const std::string &text = "", bool loseFocusOnTab = true, - gcn::ActionListener* listener = nullptr, - std::string eventId = "", bool sendAlwaysEvents = false); + TextField(const std::string &text = "", + const bool loseFocusOnTab = true, + gcn::ActionListener *const listener = nullptr, + std::string eventId = "", + const bool sendAlwaysEvents = false); ~TextField(); @@ -65,7 +67,7 @@ class TextField : public gcn::TextField /** * Determine whether the field should be numeric or not */ - void setNumeric(bool numeric); + void setNumeric(const bool numeric); /** * Set the range on the field if it is numeric @@ -107,7 +109,7 @@ class TextField : public gcn::TextField private: void handlePaste(); - void handleCopy(); + void handleCopy() const; static int instances; static float mAlpha; diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp index 0ec79a5c5..f78d4a4b7 100644 --- a/src/gui/widgets/textpreview.cpp +++ b/src/gui/widgets/textpreview.cpp @@ -69,9 +69,11 @@ void TextPreview::draw(gcn::Graphics* graphics) if (mTextBGColor && typeid(*mFont) == typeid(SDLFont)) { - SDLFont *font = static_cast<SDLFont*>(mFont); - int x = font->getWidth(mText) + 1 + 2 * ((mOutline || mShadow) ? 1 :0); - int y = font->getHeight() + 1 + 2 * ((mOutline || mShadow) ? 1 : 0); + const SDLFont *const font = static_cast<SDLFont*>(mFont); + const int x = font->getWidth(mText) + 1 + + 2 * ((mOutline || mShadow) ? 1 :0); + const int y = font->getHeight() + 1 + + 2 * ((mOutline || mShadow) ? 1 : 0); graphics->setColor(gcn::Color(static_cast<int>(mTextBGColor->r), static_cast<int>(mTextBGColor->g), static_cast<int>(mTextBGColor->b), diff --git a/src/gui/widgets/vertcontainer.cpp b/src/gui/widgets/vertcontainer.cpp index 0eb59c8f9..46ea86c0e 100644 --- a/src/gui/widgets/vertcontainer.cpp +++ b/src/gui/widgets/vertcontainer.cpp @@ -23,8 +23,8 @@ #include "debug.h" -VertContainer::VertContainer(int verticalItemSize, bool resizable, - int leftSpacing): +VertContainer::VertContainer(const int verticalItemSize, const bool resizable, + const int leftSpacing): mVerticalItemSize(verticalItemSize), mCount(0), mNextY(0), @@ -35,12 +35,13 @@ VertContainer::VertContainer(int verticalItemSize, bool resizable, addWidgetListener(this); } -void VertContainer::add1(gcn::Widget *widget, int spacing) +void VertContainer::add1(gcn::Widget *const widget, const int spacing) { add2(widget, mResizable, spacing); } -void VertContainer::add2(gcn::Widget *widget, bool resizable, int spacing) +void VertContainer::add2(gcn::Widget *const widget, const bool resizable, + const int spacing) { if (!widget) return; diff --git a/src/gui/widgets/vertcontainer.h b/src/gui/widgets/vertcontainer.h index b4e43d31d..e02d43c24 100644 --- a/src/gui/widgets/vertcontainer.h +++ b/src/gui/widgets/vertcontainer.h @@ -36,13 +36,13 @@ class VertContainer : public Container, public gcn::WidgetListener { public: - VertContainer(int verticalItemSize, bool resizable = true, - int leftSpacing = 0); + VertContainer(const int verticalItemSize, const bool resizable = true, + const int leftSpacing = 0); - virtual void add2(gcn::Widget *widget, bool resizable, - int spacing = -1); + virtual void add2(gcn::Widget *const widget, const bool resizable, + const int spacing = -1); - virtual void add1(gcn::Widget *widget, int spacing = -1); + virtual void add1(gcn::Widget *const widget, const int spacing = -1); virtual void clear(); diff --git a/src/gui/widgets/widgetgroup.cpp b/src/gui/widgets/widgetgroup.cpp index 076cf059c..104d319a0 100644 --- a/src/gui/widgets/widgetgroup.cpp +++ b/src/gui/widgets/widgetgroup.cpp @@ -24,7 +24,8 @@ #include "debug.h" -WidgetGroup::WidgetGroup(std::string group, int height, int spacing) : +WidgetGroup::WidgetGroup(const std::string &group, const int height, + const int spacing) : mSpacing(spacing), mCount(0), mGroup(group), @@ -44,7 +45,7 @@ void WidgetGroup::addButton(std::string text, std::string tag) if (text.empty() || tag.empty()) return; - Widget *widget = createWidget(text); + Widget *const widget = createWidget(text); if (widget) { widget->setActionEventId(mActionEventId + tag); @@ -62,7 +63,7 @@ void WidgetGroup::action(const gcn::ActionEvent &event) } } -void WidgetGroup::add(gcn::Widget *widget, int spacing) +void WidgetGroup::add(gcn::Widget *const widget, const int spacing) { if (!widget) return; diff --git a/src/gui/widgets/widgetgroup.h b/src/gui/widgets/widgetgroup.h index 7b8abd8e9..d70aa977f 100644 --- a/src/gui/widgets/widgetgroup.h +++ b/src/gui/widgets/widgetgroup.h @@ -31,7 +31,8 @@ class WidgetGroup : public Container, public gcn::ActionListener { public: - WidgetGroup(std::string group, int height, int spacing); + WidgetGroup(const std::string &group, const int height, + const int spacing); virtual void addButton(std::string tag); @@ -39,7 +40,7 @@ class WidgetGroup : public Container, void action(const gcn::ActionEvent &event); - virtual void add(gcn::Widget *widget, int spacing); + virtual void add(gcn::Widget *const widget, const int spacing); virtual void clear(); diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 355f12bee..e08908c7a 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -45,8 +45,8 @@ int Window::instances = 0; int Window::mouseResize = 0; -Window::Window(const std::string &caption, bool modal, Window *parent, - std::string skin): +Window::Window(const std::string &caption, const bool modal, + Window *const parent, std::string skin): gcn::Window(caption), mGrip(nullptr), mParent(parent), @@ -165,7 +165,7 @@ void Window::draw(gcn::Graphics *graphics) if (!mSkin) return; - Graphics *g = static_cast<Graphics*>(graphics); + Graphics *const g = static_cast<Graphics*>(graphics); bool update = false; if (mRedraw) @@ -190,7 +190,7 @@ void Window::draw(gcn::Graphics *graphics) // Draw Close Button if (mCloseButton && mSkin->getCloseImage()) { - Image *button = mSkin->getCloseImage(); + const Image *const button = mSkin->getCloseImage(); const int x = getWidth() - button->getWidth() - getPadding(); g->drawImage(button, x, getPadding()); } @@ -198,7 +198,7 @@ void Window::draw(gcn::Graphics *graphics) // Draw Sticky Button if (mStickyButton) { - Image *button = mSkin->getStickyImage(mSticky); + const Image *const button = mSkin->getStickyImage(mSticky); if (button) { int x = getWidth() - button->getWidth() - getPadding(); @@ -238,7 +238,7 @@ void Window::setContentSize(int width, int height) setSize(width, height); } -void Window::setLocationRelativeTo(gcn::Widget *widget) +void Window::setLocationRelativeTo(const gcn::Widget *const widget) { if (!widget) return; @@ -253,7 +253,7 @@ void Window::setLocationRelativeTo(gcn::Widget *widget) getY() + (wy + (widget->getHeight() - getHeight()) / 2 - y)); } -void Window::setLocationHorisontallyRelativeTo(gcn::Widget *widget) +void Window::setLocationHorisontallyRelativeTo(const gcn::Widget *const widget) { if (!widget) return; @@ -267,7 +267,7 @@ void Window::setLocationHorisontallyRelativeTo(gcn::Widget *widget) setPosition(getX() + (wx + (widget->getWidth() - getWidth()) / 2 - x), 0); } -void Window::setLocationRelativeTo(ImageRect::ImagePosition position, +void Window::setLocationRelativeTo(const ImageRect::ImagePosition position, int offsetX, int offsetY) { if (position == ImageRect::UPPER_LEFT) @@ -339,17 +339,17 @@ void Window::setMinHeight(int height) } } -void Window::setMaxWidth(int width) +void Window::setMaxWidth(const int width) { mMaxWinWidth = width; } -void Window::setMaxHeight(int height) +void Window::setMaxHeight(const int height) { mMaxWinHeight = height; } -void Window::setResizable(bool r) +void Window::setResizable(const bool r) { if (static_cast<bool>(mGrip) == r) return; @@ -415,7 +415,7 @@ void Window::widgetHidden(const gcn::Event &event A_UNUSED) } } -void Window::setCloseButton(bool flag) +void Window::setCloseButton(const bool flag) { mCloseButton = flag; } @@ -425,17 +425,17 @@ bool Window::isResizable() const return mGrip; } -void Window::setStickyButton(bool flag) +void Window::setStickyButton(const bool flag) { mStickyButton = flag; } -void Window::setSticky(bool sticky) +void Window::setSticky(const bool sticky) { mSticky = sticky; } -void Window::setStickyButtonLock(bool lock) +void Window::setStickyButtonLock(const bool lock) { mStickyButtonLock = lock; mStickyButton = lock; @@ -480,7 +480,7 @@ void Window::mousePressed(gcn::MouseEvent &event) // Handle close button if (mCloseButton && mSkin) { - Image *img = mSkin->getCloseImage(); + const Image *const img = mSkin->getCloseImage(); if (img) { gcn::Rectangle closeButtonRect( @@ -501,13 +501,13 @@ void Window::mousePressed(gcn::MouseEvent &event) // Handle sticky button if (mStickyButton && mSkin) { - Image *button = mSkin->getStickyImage(mSticky); + const Image *const button = mSkin->getStickyImage(mSticky); if (button) { int rx = getWidth() - button->getWidth() - getPadding(); if (mCloseButton) { - Image *img = mSkin->getCloseImage(); + const Image *const img = mSkin->getCloseImage(); if (img) rx -= img->getWidth(); } @@ -561,7 +561,7 @@ void Window::mouseMoved(gcn::MouseEvent &event) if (!gui) return; - int resizeHandles = getResizeHandles(event); + const int resizeHandles = getResizeHandles(event); // Changes the custom mouse cursor based on it's current position. switch (resizeHandles) @@ -590,7 +590,7 @@ void Window::mouseMoved(gcn::MouseEvent &event) viewport->hideBeingPopup(); } -bool Window::canMove() +bool Window::canMove() const { return !mStickyButtonLock || !mSticky; } @@ -627,7 +627,8 @@ void Window::mouseDragged(gcn::MouseEvent &event) if (mouseResize & (TOP | BOTTOM)) { - int newHeight = newDim.height + ((mouseResize & TOP) ? -dy : dy); + const int newHeight = newDim.height + + ((mouseResize & TOP) ? -dy : dy); newDim.height = std::min(mMaxWinHeight, std::max(mMinWinHeight, newHeight)); @@ -637,7 +638,8 @@ void Window::mouseDragged(gcn::MouseEvent &event) if (mouseResize & (LEFT | RIGHT)) { - int newWidth = newDim.width + ((mouseResize & LEFT) ? -dx : dx); + const int newWidth = newDim.width + + ((mouseResize & LEFT) ? -dx : dx); newDim.width = std::min(mMaxWinWidth, std::max(mMinWinWidth, newWidth)); @@ -811,8 +813,8 @@ void Window::setDefaultSize() } void Window::setDefaultSize(int defaultWidth, int defaultHeight, - ImageRect::ImagePosition position, - int offsetX, int offsetY) + const ImageRect::ImagePosition position, + const int offsetX, const int offsetY) { int x = 0, y = 0; @@ -869,7 +871,8 @@ void Window::resetToDefaultSize() saveWindowState(); } -void Window::adjustPositionAfterResize(int oldScreenWidth, int oldScreenHeight) +void Window::adjustPositionAfterResize(const int oldScreenWidth, + const int oldScreenHeight) { gcn::Rectangle dimension = getDimension(); @@ -885,7 +888,7 @@ void Window::adjustPositionAfterResize(int oldScreenWidth, int oldScreenHeight) ensureOnScreen(); } -int Window::getResizeHandles(gcn::MouseEvent &event) +int Window::getResizeHandles(const gcn::MouseEvent &event) { if ((mStickyButtonLock && mSticky) || event.getX() < 0 || event.getY() < 0) return 0; @@ -917,7 +920,7 @@ int Window::getResizeHandles(gcn::MouseEvent &event) return resizeHandles; } -bool Window::isResizeAllowed(gcn::MouseEvent &event) +bool Window::isResizeAllowed(const gcn::MouseEvent &event) { const int y = event.getY(); @@ -938,7 +941,7 @@ bool Window::isResizeAllowed(gcn::MouseEvent &event) int Window::getGuiAlpha() { - float alpha = std::max(Client::getGuiAlpha(), + const float alpha = std::max(Client::getGuiAlpha(), Theme::instance()->getMinimumOpacity()); return static_cast<int>(alpha * 255.0f); } @@ -966,13 +969,14 @@ void Window::clearLayout() } } -LayoutCell &Window::place(int x, int y, gcn::Widget *wg, int w, int h) +LayoutCell &Window::place(const int x, const int y, gcn::Widget *const wg, + const int w, const int h) { add(wg); return getLayout().place(wg, x, y, w, h); } -ContainerPlacer Window::getPlacer(int x, int y) +ContainerPlacer Window::getPlacer(const int x, const int y) { return ContainerPlacer(this, &getLayout().at(x, y)); } @@ -1032,7 +1036,7 @@ void Window::ensureOnScreen() setDimension(dimension); } -gcn::Rectangle Window::getWindowArea() +gcn::Rectangle Window::getWindowArea() const { return gcn::Rectangle(getPadding(), getPadding(), @@ -1040,11 +1044,11 @@ gcn::Rectangle Window::getWindowArea() getHeight() - getPadding() * 2); } -int Window::getOption(std::string name, int def) +int Window::getOption(const std::string &name, const int def) const { if (mSkin) { - int val = mSkin->getOption(name); + const int val = mSkin->getOption(name); if (val) return val; return def; @@ -1059,7 +1063,7 @@ bool Window::getOptionBool(std::string name) return 0; } -int Window::getTitlePadding() +int Window::getTitlePadding() const { if (mSkin) mSkin->getTitlePadding(); diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index 86f225db4..38742a73e 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -58,8 +58,8 @@ class Window : public gcn::Window, private gcn::WidgetListener * a window will never go below its parent window. * @param skin The location where the window's skin XML can be found. */ - Window(const std::string &caption = "Window", bool modal = false, - Window *parent = nullptr, std::string skin = ""); + Window(const std::string &caption = "Window", const bool modal = false, + Window *const parent = nullptr, std::string skin = ""); /** * Destructor. Deletes all the added widgets. @@ -84,23 +84,23 @@ class Window : public gcn::Window, private gcn::WidgetListener /** * Sets the location relative to the given widget. */ - void setLocationRelativeTo(gcn::Widget *widget); + void setLocationRelativeTo(const gcn::Widget *const widget); /** * Sets the location relative to the given widget (only horisontally) */ - void setLocationHorisontallyRelativeTo(gcn::Widget *widget); + void setLocationHorisontallyRelativeTo(const gcn::Widget *const widget); /** * Sets the location relative to the given enumerated position. */ - void setLocationRelativeTo(ImageRect::ImagePosition position, + void setLocationRelativeTo(const ImageRect::ImagePosition position, int offsetX = 0, int offsetY = 0); /** * Sets whether or not the window can be resized. */ - void setResizable(bool resize); + void setResizable(const bool resize); void redraw(); @@ -119,7 +119,7 @@ class Window : public gcn::Window, private gcn::WidgetListener /** * Sets whether or not the window has a close button. */ - void setCloseButton(bool flag); + void setCloseButton(const bool flag); /** * Returns whether the window can be resized. @@ -145,7 +145,7 @@ class Window : public gcn::Window, private gcn::WidgetListener /** * Sets the maximum width of the window. */ - void setMaxWidth(int width); + void setMaxWidth(const int width); int getMaxWidth() const { return mMaxWinWidth; } @@ -153,7 +153,7 @@ class Window : public gcn::Window, private gcn::WidgetListener /** * Sets the minimum height of the window. */ - void setMaxHeight(int height); + void setMaxHeight(const int height); int getMaxHeight() const { return mMaxWinHeight; } @@ -167,14 +167,14 @@ class Window : public gcn::Window, private gcn::WidgetListener /** * Sets whether or not the window has a sticky button. */ - void setStickyButton(bool flag); + void setStickyButton(const bool flag); /** * Sets whether the window is sticky. A sticky window will not have * its visibility set to false on a general setVisible(false) call. * Use this to set the default before you call loadWindowState(). */ - void setSticky(bool sticky); + void setSticky(const bool sticky); /** * Returns whether the window is sticky. @@ -185,7 +185,7 @@ class Window : public gcn::Window, private gcn::WidgetListener /** * Sets whether the window sticky mean window locked or not. */ - void setStickyButtonLock(bool sticky); + void setStickyButtonLock(const bool sticky); /** * Returns whether the window sticky locking window. @@ -318,8 +318,8 @@ class Window : public gcn::Window, private gcn::WidgetListener * on a relative enumerated position, rather than a coordinate position. */ void setDefaultSize(int defaultWidth, int defaultHeight, - ImageRect::ImagePosition position, - int offsetx = 0, int offsetY = 0); + const ImageRect::ImagePosition position, + const int offsetx = 0, const int offsetY = 0); /** * Reset the win pos and size to default. Don't forget to set defaults @@ -331,8 +331,8 @@ class Window : public gcn::Window, private gcn::WidgetListener * Adjusts the window position after the application window has been * resized. */ - void adjustPositionAfterResize(int oldScreenWidth, - int oldScreenHeight); + void adjustPositionAfterResize(const int oldScreenWidth, + const int oldScreenHeight); /** * Gets the layout handler for this window. @@ -358,12 +358,13 @@ class Window : public gcn::Window, private gcn::WidgetListener /** * Adds a widget to the window and sets it at given cell. */ - LayoutCell &place(int x, int y, gcn::Widget *, int w = 1, int h = 1); + LayoutCell &place(const int x, const int y, gcn::Widget *const wg, + const int w = 1, const int h = 1); /** * Returns a proxy for adding widgets in an inner table of the layout. */ - ContainerPlacer getPlacer(int x, int y); + ContainerPlacer getPlacer(const int x, const int y); /** * Positions the window in the center of it's parent. @@ -392,21 +393,21 @@ class Window : public gcn::Window, private gcn::WidgetListener */ int getGuiAlpha(); - gcn::Rectangle getWindowArea(); + gcn::Rectangle getWindowArea() const; - bool isResizeAllowed(gcn::MouseEvent &event); + bool isResizeAllowed(const gcn::MouseEvent &event); void setCaptionFont(gcn::Font *font) { mCaptionFont = font; } protected: - bool canMove(); + bool canMove() const; - int getOption(std::string name, int def = 0); + int getOption(const std::string &name, const int def = 0) const; bool getOptionBool(std::string name); - int getTitlePadding(); + int getTitlePadding() const; Skin *mSkin; /**< Skin in use by this window */ @@ -433,7 +434,7 @@ class Window : public gcn::Window, private gcn::WidgetListener * * @see ResizeHandles */ - int getResizeHandles(gcn::MouseEvent &event); + int getResizeHandles(const gcn::MouseEvent &event); ResizeGrip *mGrip; /**< Resize grip */ Window *mParent; /**< The parent window */ diff --git a/src/gui/widgets/windowcontainer.cpp b/src/gui/widgets/windowcontainer.cpp index 2e40d88d2..41aed2ba3 100644 --- a/src/gui/widgets/windowcontainer.cpp +++ b/src/gui/widgets/windowcontainer.cpp @@ -38,19 +38,19 @@ void WindowContainer::logic() gcn::Container::logic(); } -void WindowContainer::scheduleDelete(gcn::Widget *widget) +void WindowContainer::scheduleDelete(gcn::Widget *const widget) { if (widget) mDeathList.push_back(widget); } -void WindowContainer::adjustAfterResize(int oldScreenWidth, - int oldScreenHeight) +void WindowContainer::adjustAfterResize(const int oldScreenWidth, + const int oldScreenHeight) { for (WidgetListIterator i = mWidgets.begin(), i_end = mWidgets.end(); i != i_end; ++i) { - if (Window *window = dynamic_cast<Window*>(*i)) + if (Window *const window = dynamic_cast<Window*>(*i)) window->adjustPositionAfterResize(oldScreenWidth, oldScreenHeight); } } diff --git a/src/gui/widgets/windowcontainer.h b/src/gui/widgets/windowcontainer.h index 1cec11861..a2d560cbb 100644 --- a/src/gui/widgets/windowcontainer.h +++ b/src/gui/widgets/windowcontainer.h @@ -46,13 +46,14 @@ class WindowContainer : public Container * Schedule a widget for deletion. It will be deleted at the start of * the next logic update. */ - void scheduleDelete(gcn::Widget *widget); + void scheduleDelete(gcn::Widget *const widget); /** * Ensures that all visible windows are on the screen after the screen * has been resized. */ - void adjustAfterResize(int oldScreenWidth, int oldScreenHeight); + void adjustAfterResize(const int oldScreenWidth, + const int oldScreenHeight); private: /** diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index 361b5287e..0e25c1f18 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -224,8 +224,9 @@ void WindowMenu::action(const gcn::ActionEvent &event) //{ //} -void WindowMenu::addButton(const char* text, std::string description, - int &x, int &h, int key, bool visible) +void WindowMenu::addButton(const char *const text, + const std::string &description, + int &x, int &h, const int key, const bool visible) { Button *btn = new Button(gettext(text), text, this); btn->setPosition(x, 0); @@ -248,7 +249,7 @@ void WindowMenu::mousePressed(gcn::MouseEvent &event) if (event.getButton() == gcn::MouseEvent::RIGHT) { - Button *btn = dynamic_cast<Button*>(event.getSource()); + Button *const btn = dynamic_cast<Button*>(event.getSource()); if (!btn) return; if (viewport) @@ -272,7 +273,8 @@ void WindowMenu::mouseMoved(gcn::MouseEvent &event) return; } - Button *btn = dynamic_cast<Button*>(event.getSource()); + const Button *const btn = dynamic_cast<const Button *const>( + event.getSource()); if (!btn) { @@ -282,7 +284,7 @@ void WindowMenu::mouseMoved(gcn::MouseEvent &event) const int x = event.getX(); const int y = event.getY(); - int key = btn->getTag(); + const int key = btn->getTag(); if (key != Input::KEY_NO_VALUE) { mTextPopup->show(x + getX(), y + getY(), btn->getDescription(), @@ -304,9 +306,9 @@ void WindowMenu::mouseExited(gcn::MouseEvent& mouseEvent A_UNUSED) mTextPopup->hide(); } -void WindowMenu::showButton(std::string name, bool visible) +void WindowMenu::showButton(const std::string &name, const bool visible) { - Button *btn = dynamic_cast<Button*>(mButtonNames[name]); + Button *const btn = dynamic_cast<Button *const>(mButtonNames[name]); if (!btn) return; @@ -323,7 +325,7 @@ void WindowMenu::updateButtons() safeRemove(*it); for (it = mButtons.begin(), it_end = mButtons.end(); it != it_end; ++it) { - Button *btn = dynamic_cast<Button*>(*it); + Button *const btn = dynamic_cast<Button *const>(*it); if (!btn) continue; if (btn->isVisible()) @@ -351,7 +353,7 @@ void WindowMenu::loadButtons() std::string str = config.getValue("windowmenu" + toString(f), ""); if (str == "" || str == "SET") continue; - Button *btn = dynamic_cast<Button*>(mButtonNames[str]); + Button *const btn = dynamic_cast<Button *const>(mButtonNames[str]); if (!btn) continue; btn->setVisible(false); @@ -366,7 +368,7 @@ void WindowMenu::saveButtons() it_end = mButtons.end(); it != it_end; ++it) { - Button *btn = dynamic_cast<Button*>(*it); + const Button *const btn = dynamic_cast<const Button *const>(*it); if (!btn->isVisible()) { config.setValue("windowmenu" + toString(i), diff --git a/src/gui/windowmenu.h b/src/gui/windowmenu.h index 3538a9b83..490b24d87 100644 --- a/src/gui/windowmenu.h +++ b/src/gui/windowmenu.h @@ -71,7 +71,7 @@ class WindowMenu : public Container, std::vector <gcn::Button*> &getButtons() { return mButtons; } - void showButton(std::string name, bool visible); + void showButton(const std::string &name, const bool visible); void loadButtons(); @@ -82,8 +82,10 @@ class WindowMenu : public Container, private: void drawChildren(gcn::Graphics* graphics); - inline void addButton(const char* text, std::string description, - int &x, int &h, int key, bool visible = true); + inline void addButton(const char *const text, + const std::string &description, + int &x, int &h, const int key, + const bool visible = true); void updateButtons(); diff --git a/src/gui/worldselectdialog.cpp b/src/gui/worldselectdialog.cpp index d8b204140..4463442f9 100644 --- a/src/gui/worldselectdialog.cpp +++ b/src/gui/worldselectdialog.cpp @@ -64,7 +64,7 @@ class WorldListModel : public gcn::ListModel std::string getElementAt(int i) { - const WorldInfo *si = mWorlds[i]; + const WorldInfo *const si = mWorlds[i]; if (si) return si->name + " (" + toString(si->online_users) + ")"; else @@ -81,7 +81,7 @@ WorldSelectDialog::WorldSelectDialog(Worlds worlds): mChangeLoginButton(new Button(_("Change Login"), "login", this)), mChooseWorld(new Button(_("Choose World"), "world", this)) { - ScrollArea *worldsScroll = new ScrollArea(mWorldList, + ScrollArea *const worldsScroll = new ScrollArea(mWorldList, getOptionBool("showbackground"), "world_background.xml"); worldsScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); diff --git a/src/imageparticle.cpp b/src/imageparticle.cpp index 5e0b93d7a..863cb8ba8 100644 --- a/src/imageparticle.cpp +++ b/src/imageparticle.cpp @@ -30,7 +30,7 @@ std::map<std::string, int> ImageParticle::imageParticleCountByName; -ImageParticle::ImageParticle(Map *map, Image *image): +ImageParticle::ImageParticle(Map *const map, Image *const image): Particle(map), mImage(image) { @@ -70,8 +70,9 @@ bool ImageParticle::draw(Graphics *graphics, int offsetX, int offsetY) const if (!isAlive() || !mImage) return false; - int screenX = static_cast<int>(mPos.x) + offsetX - mImage->mBounds.w / 2; - int screenY = static_cast<int>(mPos.y) - static_cast<int>(mPos.z) + const int screenX = static_cast<int>(mPos.x) + + offsetX - mImage->mBounds.w / 2; + const int screenY = static_cast<int>(mPos.y) - static_cast<int>(mPos.z) + offsetY - mImage->mBounds.h / 2; // Check if on screen diff --git a/src/imageparticle.h b/src/imageparticle.h index 16b4b8cb7..7196748fe 100644 --- a/src/imageparticle.h +++ b/src/imageparticle.h @@ -42,7 +42,7 @@ class ImageParticle : public Particle * @param map the map this particle appears on * @param image an Image instance, may not be NULL */ - ImageParticle(Map *map, Image *image); + ImageParticle(Map *const map, Image *const image); /** * Destructor. diff --git a/src/imagesprite.cpp b/src/imagesprite.cpp index f969717f2..e827476db 100644 --- a/src/imagesprite.cpp +++ b/src/imagesprite.cpp @@ -25,7 +25,7 @@ #include "debug.h" -ImageSprite::ImageSprite(Image *image): +ImageSprite::ImageSprite(Image *const image): mImage(image) { if (mImage) diff --git a/src/imagesprite.h b/src/imagesprite.h index 4735070c5..debee945e 100644 --- a/src/imagesprite.h +++ b/src/imagesprite.h @@ -31,7 +31,7 @@ class Graphics; class ImageSprite : public Sprite { public: - ImageSprite(Image *image); + ImageSprite(Image *const image); ~ImageSprite(); @@ -58,7 +58,7 @@ public: virtual bool setSpriteDirection(SpriteDirection direction A_UNUSED) { return false; } - int getNumberOfLayers() + int getNumberOfLayers() const { return 1; } unsigned int getCurrentFrame() const diff --git a/src/inputevent.cpp b/src/inputevent.cpp index 614be71f1..3b580dd36 100644 --- a/src/inputevent.cpp +++ b/src/inputevent.cpp @@ -22,7 +22,7 @@ #include "debug.h" -InputEvent::InputEvent(int action0, int mask0) : +InputEvent::InputEvent(const int action0, const int mask0) : action(action0), mask(mask0) { diff --git a/src/inputevent.h b/src/inputevent.h index cbcc9cc99..cc2fbe5fb 100644 --- a/src/inputevent.h +++ b/src/inputevent.h @@ -39,7 +39,7 @@ typedef KeyTimeMap::iterator KeyTimeMapIter; struct InputEvent { - InputEvent(int action0, int mask0); + InputEvent(const int action0, const int mask0); int action; diff --git a/src/inputmanager.cpp b/src/inputmanager.cpp index c22e9192f..7f62862be 100644 --- a/src/inputmanager.cpp +++ b/src/inputmanager.cpp @@ -53,7 +53,7 @@ extern QuitDialog *quitDialog; class KeyFunctor { public: - bool operator() (int key1, int key2) + bool operator() (const int key1, const int key2) const { return keys[key1].priority >= keys[key2].priority; } @@ -88,7 +88,7 @@ void InputManager::init() update(); } -void InputManager::update() +void InputManager::update() const { keyboard.update(); if (joystick) @@ -132,7 +132,7 @@ void InputManager::retrieve() } keyStr2 = keyStr2.substr(1); } - int key = atoi(keyStr2.c_str()); + const int key = atoi(keyStr2.c_str()); if (key >= -255 && key < SDLK_LAST) { kf.values[i2] = KeyItem(type, key); @@ -143,7 +143,7 @@ void InputManager::retrieve() } } -void InputManager::store() +void InputManager::store() const { for (int i = 0; i < Input::KEY_TOTAL; i++) { @@ -207,7 +207,7 @@ void InputManager::resetKeys() } } -void InputManager::makeDefault(int i) +void InputManager::makeDefault(const int i) { if (i >= 0 && i < Input::KEY_TOTAL) { @@ -226,7 +226,7 @@ void InputManager::makeDefault(int i) } } -bool InputManager::hasConflicts(int &key1, int &key2) +bool InputManager::hasConflicts(int &key1, int &key2) const { size_t i; size_t j; @@ -277,7 +277,7 @@ void InputManager::callbackNewKey() mSetupInput->newKeyCallback(mNewKeyIndex); } -bool InputManager::isActionActive(int index) const +bool InputManager::isActionActive(const int index) const { if (keyboard.isActionActive(index)) return true; @@ -293,7 +293,7 @@ KeyFunction &InputManager::getKey(int index) return mKey[index]; } -std::string InputManager::getKeyStringLong(int index) const +std::string InputManager::getKeyStringLong(const int index) const { std::string keyStr; @@ -327,7 +327,7 @@ std::string InputManager::getKeyStringLong(int index) const return keyStr; } -std::string InputManager::getKeyValueString(int index) const +std::string InputManager::getKeyValueString(const int index) const { std::string keyStr; @@ -366,7 +366,8 @@ std::string InputManager::getKeyValueString(int index) const return keyStr; } -void InputManager::addActionKey(int action, int type, int val) +void InputManager::addActionKey(const int action, const int type, + const int val) { if (action < 0 || action >= Input::KEY_TOTAL) return; @@ -396,7 +397,7 @@ void InputManager::addActionKey(int action, int type, int val) key.values[idx] = KeyItem(type, val); } -void InputManager::setNewKey(const SDL_Event &event, int type) +void InputManager::setNewKey(const SDL_Event &event, const int type) { int val = -1; if (type == INPUT_KEYBOARD) @@ -422,7 +423,7 @@ void InputManager::unassignKey() update(); } -bool InputManager::handleAssignKey(const SDL_Event &event, int type) +bool InputManager::handleAssignKey(const SDL_Event &event, const int type) { if (setupWindow && setupWindow->isVisible() && getNewKeyIndex() > Input::KEY_NO_VALUE) @@ -459,7 +460,7 @@ bool InputManager::handleEvent(const SDL_Event &event) } catch (const gcn::Exception &e) { - const char* err = e.getMessage().c_str(); + const char *const err = e.getMessage().c_str(); logger->log("Warning: guichan input exception: %s", err); } return true; @@ -497,7 +498,7 @@ bool InputManager::handleEvent(const SDL_Event &event) } catch (const gcn::Exception &e) { - const char *err = e.getMessage().c_str(); + const char *const err = e.getMessage().c_str(); logger->log("Warning: guichan input exception: %s", err); } if (gui) @@ -528,7 +529,7 @@ bool InputManager::handleEvent(const SDL_Event &event) return false; } -void InputManager::handleRepeat() +void InputManager::handleRepeat() const { const int time = tick_time; keyboard.handleRepeat(time); @@ -561,7 +562,7 @@ void InputManager::updateConditionMask() if (gui && !gui->getFocusHandler()->getModalFocused()) mMask += COND_NOMODAL; - NpcDialog *dialog = NpcDialog::getActive(); + const NpcDialog *const dialog = NpcDialog::getActive(); if (!dialog || !dialog->isTextInputFocused()) mMask += COND_NONPCINPUT; @@ -578,7 +579,7 @@ void InputManager::updateConditionMask() mMask += COND_NOFOLLOW; } -bool InputManager::checkKey(const KeyData *key) +bool InputManager::checkKey(const KeyData *const key) const { // logger->log("mask=%d, condition=%d", mMask, key->condition); if (!key || (key->condition & mMask) != key->condition) @@ -588,7 +589,7 @@ bool InputManager::checkKey(const KeyData *key) || isActionActive(key->modKeyIndex)); } -bool InputManager::invokeKey(const KeyData *key, int keyNum) +bool InputManager::invokeKey(const KeyData *const key, const int keyNum) { if (checkKey(key)) { @@ -602,14 +603,14 @@ bool InputManager::invokeKey(const KeyData *key, int keyNum) void InputManager::updateKeyActionMap(KeyToActionMap &actionMap, KeyToIdMap &idMap, KeyTimeMap &keyTimeMap, - int type) + const int type) const { actionMap.clear(); keyTimeMap.clear(); for (size_t i = 0; i < Input::KEY_TOTAL; i ++) { - KeyFunction &key = mKey[i]; + const KeyFunction &key = mKey[i]; if (keyData[i].action) { for (size_t i2 = 0; i2 < KeyFunctionSize; i2 ++) @@ -643,13 +644,13 @@ void InputManager::updateKeyActionMap(KeyToActionMap &actionMap, for (KeyToActionMapIter it = actionMap.begin(), it_end = actionMap.end(); it != it_end; ++ it) { - KeysVector *keys = &it->second; + KeysVector *const keys = &it->second; if (keys && keys->size() > 1) sort(keys->begin(), keys->end(), keySorter); } } -bool InputManager::triggerAction(const KeysVector *ptrs) +bool InputManager::triggerAction(const KeysVector *const ptrs) { if (!ptrs) return false; @@ -669,7 +670,8 @@ bool InputManager::triggerAction(const KeysVector *ptrs) return false; } -int InputManager::getKeyIndex(int value, int grp, int type) const +int InputManager::getKeyIndex(const int value, const int grp, + const int type) const { for (size_t i = 0; i < Input::KEY_TOTAL; i++) { @@ -692,7 +694,7 @@ int InputManager::getActionByKey(const SDL_Event &event) // for now support only keyboard events if (event.type == SDL_KEYDOWN || event.type == SDL_KEYUP) { - int idx = keyboard.getActionId(event); + const int idx = keyboard.getActionId(event); if (idx >= 0 && checkKey(&keyData[idx])) return idx; } diff --git a/src/inputmanager.h b/src/inputmanager.h index ce1724077..394819816 100644 --- a/src/inputmanager.h +++ b/src/inputmanager.h @@ -53,10 +53,12 @@ enum KeyTypes struct KeyItem { - KeyItem() : type(-1), value(-1) + KeyItem() : + type(-1), value(-1) { } - KeyItem(int type0, int value0) : type(type0), value(value0) + KeyItem(const int type0, const int value0) : + type(type0), value(value0) { } int type; @@ -96,44 +98,44 @@ class InputManager bool handleEvent(const SDL_Event &event); - bool checkKey(const KeyData *key); + bool checkKey(const KeyData *const key) const; void retrieve(); - void store(); + void store() const; void resetKeys(); - void makeDefault(int i); + void makeDefault(const int i); - bool hasConflicts(int &key1, int &key2); + bool hasConflicts(int &key1, int &key2) const; void callbackNewKey(); KeyFunction &getKey(int index); - std::string getKeyValueString(int index) const; + std::string getKeyValueString(const int index) const; - std::string getKeyStringLong(int index) const; + std::string getKeyStringLong(const int index) const; - void addActionKey(int action, int type, int val); + void addActionKey(const int action, const int type, const int val); - void setNewKey(const SDL_Event &event, int type); + void setNewKey(const SDL_Event &event, const int type); void unassignKey(); - bool isActionActive(int index) const; + bool isActionActive(const int index) const; /** * Set the index of the new key to be assigned. */ - void setNewKeyIndex(int value) + void setNewKeyIndex(const int value) { mNewKeyIndex = value; } /** * Set a reference to the key setup window. */ - void setSetupInput(Setup_Input *setupInput) + void setSetupInput(Setup_Input *const setupInput) { mSetupInput = setupInput; } /** @@ -144,19 +146,19 @@ class InputManager void updateKeyActionMap(KeyToActionMap &actionMap, KeyToIdMap &idMap, KeyTimeMap &keyTimeMap, - int type); + const int type) const; - bool invokeKey(const KeyData *key, int keyNum); + bool invokeKey(const KeyData *const key, const int keyNum); - bool handleAssignKey(const SDL_Event &event, int type); + bool handleAssignKey(const SDL_Event &event, const int type); - void handleRepeat(); + void handleRepeat() const; - bool triggerAction(const KeysVector *ptrs); + bool triggerAction(const KeysVector *const ptrs); - int getKeyIndex(int value, int grp, int type) const; + int getKeyIndex(const int value, const int grp, const int type) const; - void update(); + void update() const; void updateConditionMask(); diff --git a/src/inventory.cpp b/src/inventory.cpp index 75729a28b..ebbf31326 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -39,13 +39,13 @@ struct SlotUsed : public std::unary_function<Item*, bool> { - bool operator()(const Item *item) const + bool operator()(const Item *const item) const { return item && item->getId() >= 0 && item->getQuantity() > 0; } }; -Inventory::Inventory(int type, int size): +Inventory::Inventory(const int type, const int size) : mType(type), mSize(size == -1 ? static_cast<unsigned>( Net::getInventoryHandler()->getSize(type)) @@ -65,7 +65,7 @@ Inventory::~Inventory() mItems = nullptr; } -Item *Inventory::getItem(int index) const +Item *Inventory::getItem(const int index) const { if (index < 0 || index >= static_cast<int>(mSize) || !mItems[index] || mItems[index]->getQuantity() <= 0) @@ -76,7 +76,7 @@ Item *Inventory::getItem(int index) const return mItems[index]; } -Item *Inventory::findItem(int itemId, unsigned char color) const +Item *Inventory::findItem(const int itemId, const unsigned char color) const { for (unsigned i = 0; i < mSize; i++) { @@ -93,14 +93,15 @@ Item *Inventory::findItem(int itemId, unsigned char color) const return nullptr; } -void Inventory::addItem(int id, int quantity, int refine, - unsigned char color, bool equipment) +void Inventory::addItem(const int id, const int quantity, const int refine, + const unsigned char color, const bool equipment) { setItem(getFreeSlot(), id, quantity, refine, color, equipment); } -void Inventory::setItem(int index, int id, int quantity, - int refine, unsigned char color, bool equipment) +void Inventory::setItem(const int index, const int id, const int quantity, + const int refine, const unsigned char color, + const bool equipment) { if (index < 0 || index >= static_cast<int>(mSize)) { @@ -110,7 +111,7 @@ void Inventory::setItem(int index, int id, int quantity, if (!mItems[index] && id > 0) { - Item *item = new Item(id, quantity, refine, color, equipment); + Item *const item = new Item(id, quantity, refine, color, equipment); item->setInvIndex(index); mItems[index] = item; mUsed++; @@ -135,7 +136,7 @@ void Inventory::clear() removeItemAt(i); } -void Inventory::removeItem(int id) +void Inventory::removeItem(const int id) { for (unsigned i = 0; i < mSize; i++) { @@ -144,7 +145,7 @@ void Inventory::removeItem(int id) } } -void Inventory::removeItemAt(int index) +void Inventory::removeItemAt(const int index) { delete mItems[index]; mItems[index] = nullptr; @@ -155,7 +156,7 @@ void Inventory::removeItemAt(int index) distributeSlotsChangedEvent(); } -bool Inventory::contains(Item *item) const +bool Inventory::contains(const Item *const item) const { if (!item) return false; @@ -171,7 +172,7 @@ bool Inventory::contains(Item *item) const int Inventory::getFreeSlot() const { - Item **i = std::find_if(mItems, mItems + mSize, + Item **const i = std::find_if(mItems, mItems + mSize, std::not1(SlotUsed())); return (i == mItems + static_cast<int>(mSize)) ? -1 : static_cast<int>(i - mItems); @@ -188,12 +189,12 @@ int Inventory::getLastUsedSlot() const return -1; } -void Inventory::addInventoyListener(InventoryListener* listener) +void Inventory::addInventoyListener(InventoryListener* const listener) { mInventoryListeners.push_back(listener); } -void Inventory::removeInventoyListener(InventoryListener* listener) +void Inventory::removeInventoyListener(InventoryListener* const listener) { mInventoryListeners.remove(listener); } @@ -208,7 +209,7 @@ void Inventory::distributeSlotsChangedEvent() } Item *Inventory::findItemBySprite(std::string spritePath, - Gender gender, int race) + const Gender gender, const int race) const { spritePath = removeSpriteIndex(spritePath); // logger->log1("Inventory::FindItemBySprite sprite: " + spritePath); @@ -244,7 +245,7 @@ Item *Inventory::findItemBySprite(std::string spritePath, return nullptr; } -std::string Inventory::getName() +std::string Inventory::getName() const { switch (mType) { diff --git a/src/inventory.h b/src/inventory.h index 6cfcc3f86..f7d3e448f 100644 --- a/src/inventory.h +++ b/src/inventory.h @@ -64,7 +64,7 @@ class Inventory * * @param size the number of items that fit in the inventory */ - Inventory(int type, int size = -1); + Inventory(const int type, const int size = -1); /** * Destructor. @@ -80,7 +80,7 @@ class Inventory /** * Returns the item at the specified index. */ - Item *getItem(int index) const; + Item *getItem(const int index) const; /** * Searches for the specified item by it's id. @@ -89,34 +89,35 @@ class Inventory * @param color The color of the item to be searched. * @return Item found on success, NULL on failure. */ - Item *findItem(int itemId, unsigned char color) const; + Item *findItem(const int itemId, const unsigned char color) const; /** * Adds a new item in a free slot. */ - void addItem(int id, int quantity, int refine, unsigned char color, - bool equipment = false); + void addItem(const int id, const int quantity, const int refine, + const unsigned char color, bool equipment = false); /** * Sets the item at the given position. */ - void setItem(int index, int id, int quantity, int refine, - unsigned char color, bool equipment = false); + void setItem(const int index, const int id, const int quantity, + const int refine, const unsigned char color, + const bool equipment = false); /** * Remove a item from the inventory. */ - void removeItem(int id); + void removeItem(const int id); /** * Remove the item at the specified index from the inventory. */ - void removeItemAt(int index); + void removeItemAt(const int index); /** * Checks if the given item is in the inventory. */ - bool contains(Item *item) const; + bool contains(const Item *const item) const; /** * Returns id of next free slot or -1 if all occupied. @@ -139,9 +140,9 @@ class Inventory */ int getLastUsedSlot() const; - void addInventoyListener(InventoryListener* listener); + void addInventoyListener(InventoryListener *const listener); - void removeInventoyListener(InventoryListener* listener); + void removeInventoyListener(InventoryListener *const listener); int getType() const { return mType; } @@ -150,9 +151,9 @@ class Inventory { return mType == INVENTORY; } Item *findItemBySprite(std::string spritePath, - Gender gender, int race); + const Gender gender, const int race) const; - std::string getName(); + std::string getName() const; protected: typedef std::list<InventoryListener*> InventoryListenerList; diff --git a/src/item.cpp b/src/item.cpp index 1311a7354..0c12020aa 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -33,8 +33,9 @@ extern int serverVersion; -Item::Item(int id, int quantity, int refine, unsigned char color, - bool equipment, bool equipped): +Item::Item(const int id, const int quantity, const int refine, + const unsigned char color, const bool equipment, + const bool equipped): mImage(nullptr), mDrawImage(nullptr), mQuantity(quantity), @@ -61,7 +62,7 @@ Item::~Item() } } -void Item::setId(int id, unsigned char color) +void Item::setId(const int id, const unsigned char color) { mId = id; mColor = color; @@ -76,7 +77,7 @@ void Item::setId(int id, unsigned char color) if (mDrawImage) mDrawImage->decRef(); - ResourceManager *resman = ResourceManager::getInstance(); + ResourceManager *const resman = ResourceManager::getInstance(); const ItemInfo &info = getInfo(); mTags = info.getTags(); @@ -99,16 +100,16 @@ void Item::setId(int id, unsigned char color) } } -bool Item::isHaveTag(int tagId) +bool Item::isHaveTag(const int tagId) { if (mTags.find(tagId) == mTags.end()) return false; return mTags[tagId] > 0; } -Image *Item::getImage(int id, unsigned char color) +Image *Item::getImage(const int id, const unsigned char color) { - ResourceManager *resman = ResourceManager::getInstance(); + ResourceManager *const resman = ResourceManager::getInstance(); const ItemInfo &info = ItemDB::get(id); SpriteDisplay display = info.getDisplay(); std::string imagePath = paths.getStringValue("itemIcons") + display.image; diff --git a/src/item.h b/src/item.h index 4683f8816..bc5ed9098 100644 --- a/src/item.h +++ b/src/item.h @@ -38,9 +38,9 @@ class Item /** * Constructor. */ - Item(int id = -1, int quantity = 0, int refine = 0, - unsigned char color = 1, bool equipment = false, - bool equipped = false); + Item(const int id = -1, const int quantity = 0, const int refine = 0, + const unsigned char color = 1, const bool equipment = false, + const bool equipped = false); /** * Destructor. @@ -50,7 +50,7 @@ class Item /** * Sets the item id, identifying the item type. */ - void setId(int id, unsigned char color); + void setId(const int id, const unsigned char color); /** * Returns the item id. @@ -73,13 +73,13 @@ class Item /** * Sets the number of items. */ - void setQuantity(int quantity) + void setQuantity(const int quantity) { mQuantity = quantity; } /** * Increases the number of items by the given amount. */ - void increaseQuantity(int amount) + void increaseQuantity(const int amount) { mQuantity += amount; } /** @@ -91,7 +91,7 @@ class Item /** * Sets whether this item is considered equipment. */ - void setEquipment(bool equipment) + void setEquipment(const bool equipment) { mEquipment = equipment; } /** @@ -103,7 +103,7 @@ class Item /** * Sets whether this item is equipped. */ - void setEquipped(bool equipped) + void setEquipped(const bool equipped) { mEquipped = equipped; } /** @@ -115,7 +115,7 @@ class Item /** * Sets this item refine level. */ - void setRefine(int refine) + void setRefine(const int refine) { mRefine = refine; } /** @@ -127,7 +127,7 @@ class Item /** * Sets whether this item is in equipment. */ - void setInEquipment(bool inEquipment) + void setInEquipment(const bool inEquipment) { mInEquipment = inEquipment; } /** @@ -139,7 +139,7 @@ class Item /** * Sets the inventory index of this item. */ - void setInvIndex(int index) + void setInvIndex(const int index) { mInvIndex = index; } /** @@ -156,9 +156,9 @@ class Item std::string getName(); - static Image *getImage(int id, unsigned char color); + static Image *getImage(const int id, const unsigned char color); - bool isHaveTag(int tagId); + bool isHaveTag(const int tagId); unsigned char getColor() const { return mColor; } |