diff options
35 files changed, 320 insertions, 292 deletions
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 459f66052..6367f147e 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -106,7 +106,7 @@ Viewport::~Viewport() mTextPopup = nullptr; } -void Viewport::setMap(Map *map) +void Viewport::setMap(Map *const map) { if (mMap && map) map->setDebugFlags(mMap->getDebugFlags()); @@ -127,15 +127,15 @@ void Viewport::draw(gcn::Graphics *gcnGraphics) return; } - Graphics *graphics = static_cast<Graphics*>(gcnGraphics); + Graphics *const graphics = static_cast<Graphics* const>(gcnGraphics); // Avoid freaking out when tick_time overflows if (tick_time < lastTick) lastTick = tick_time; // Calculate viewpoint - int midTileX = (graphics->mWidth + mScrollCenterOffsetX) / 2; - int midTileY = (graphics->mHeight + mScrollCenterOffsetY) / 2; + const int midTileX = (graphics->mWidth + mScrollCenterOffsetX) / 2; + const int midTileY = (graphics->mHeight + mScrollCenterOffsetY) / 2; const Vector &playerPos = player_node->getPosition(); const int player_x = static_cast<int>(playerPos.x) @@ -255,7 +255,7 @@ void Viewport::draw(gcn::Graphics *gcnGraphics) { if ((*it)->getType() == ActorSprite::FLOOR_ITEM) continue; - Being *b = static_cast<Being*>(*it); + Being *const b = static_cast<Being*>(*it); b->drawSpeech(mPixelViewX, mPixelViewY); b->drawEmotion(graphics, mPixelViewX, mPixelViewY); @@ -279,12 +279,12 @@ void Viewport::logic() void Viewport::_followMouse() { - uint8_t button = SDL_GetMouseState(&mMouseX, &mMouseY); + const uint8_t button = SDL_GetMouseState(&mMouseX, &mMouseY); // If the left button is dragged if (mPlayerFollowMouse && (button & SDL_BUTTON(1))) { // We create a mouse event and send it to mouseDragged. - uint8_t *keys = SDL_GetKeyState(nullptr); + const uint8_t *const keys = SDL_GetKeyState(nullptr); gcn::MouseEvent mouseEvent(nullptr, (keys[SDLK_LSHIFT] || keys[SDLK_RSHIFT]), false, @@ -300,7 +300,7 @@ void Viewport::_followMouse() } } -void Viewport::_drawDebugPath(Graphics *graphics) +void Viewport::_drawDebugPath(Graphics *const graphics) { if (!player_node || !userPalette || !actorSpriteManager) return; @@ -336,7 +336,7 @@ void Viewport::_drawDebugPath(Graphics *graphics) for (ActorSpritesConstIterator it = actors.begin(), it_end = actors.end(); it != it_end; ++ it) { - Being *being = dynamic_cast<Being*>(*it); + const Being *const being = dynamic_cast<Being*>(*it); if (being && being != player_node) { Path beingPath = being->getPath(); @@ -347,8 +347,8 @@ void Viewport::_drawDebugPath(Graphics *graphics) } } -void Viewport::_drawPath(Graphics *graphics, const Path &path, - gcn::Color color) +void Viewport::_drawPath(Graphics *const graphics, const Path &path, + const gcn::Color color) const { graphics->setColor(color); @@ -359,8 +359,8 @@ void Viewport::_drawPath(Graphics *graphics, const Path &path, for (Path::const_iterator i = path.begin(), i_end = path.end(); i != i_end; ++i) { - int squareX = i->x * 32 - mPixelViewX + 12; - int squareY = i->y * 32 - mPixelViewY + 12; + const int squareX = i->x * 32 - mPixelViewX + 12; + const int squareY = i->y * 32 - mPixelViewY + 12; graphics->fillRectangle(gcn::Rectangle(squareX, squareY, 8, 8)); if (mMap) @@ -545,7 +545,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event) // Find the being nearest to the clicked position if (actorSpriteManager) { - Being *target = actorSpriteManager->findNearestLivingBeing( + Being *const target = actorSpriteManager->findNearestLivingBeing( pixelX, pixelY, 20, ActorSprite::MONSTER); if (target) @@ -579,9 +579,9 @@ void Viewport::mouseDragged(gcn::MouseEvent &event) if (mLocalWalkTime != player_node->getActionTime()) { mLocalWalkTime = cur_time; - int destX = (event.getX() + mPixelViewX) + const int destX = (event.getX() + mPixelViewX) / static_cast<float>(mMap->getTileWidth()); - int destY = (event.getY() + mPixelViewY) + const int destY = (event.getY() + mPixelViewY) / static_cast<float>(mMap->getTileHeight()); player_node->unSetPickUpTarget(); if (!player_node->navigateTo(destX, destY)) @@ -615,38 +615,39 @@ void Viewport::mouseReleased(gcn::MouseEvent &event A_UNUSED) mLocalWalkTime = -1; } -void Viewport::showPopup(Window *parent, int x, int y, Item *item, - bool isInventory) +void Viewport::showPopup(Window *const parent, const int x, const int y, + Item *const item, const bool isInventory) { mPopupMenu->showPopup(parent, x, y, item, isInventory); } -void Viewport::showPopup(MapItem *item) +void Viewport::showPopup(MapItem *const item) { mPopupMenu->showPopup(getMouseX(), getMouseY(), item); } -void Viewport::showPopup(Window *parent, Item *item, bool isInventory) +void Viewport::showPopup(Window *const parent, Item *const item, + const bool isInventory) { mPopupMenu->showPopup(parent, getMouseX(), getMouseY(), item, isInventory); } -void Viewport::showItemPopup(Item *item) +void Viewport::showItemPopup(Item *const item) { mPopupMenu->showItemPopup(getMouseX(), getMouseY(), item); } -void Viewport::showItemPopup(int itemId, unsigned char color) +void Viewport::showItemPopup(const int itemId, const unsigned char color) { mPopupMenu->showItemPopup(getMouseX(), getMouseY(), itemId, color); } -void Viewport::showDropPopup(Item *item) +void Viewport::showDropPopup(Item *const item) { mPopupMenu->showDropPopup(getMouseX(), getMouseY(), item); } -void Viewport::showOutfitsPopup(int x, int y) +void Viewport::showOutfitsPopup(const int x, const int y) { mPopupMenu->showOutfitsPopup(x, y); } @@ -656,27 +657,27 @@ void Viewport::showOutfitsPopup() mPopupMenu->showOutfitsPopup(getMouseX(), getMouseY()); } -void Viewport::showSpellPopup(TextCommand *cmd) +void Viewport::showSpellPopup(TextCommand *const cmd) { mPopupMenu->showSpellPopup(getMouseX(), getMouseY(), cmd); } -void Viewport::showChatPopup(int x, int y, ChatTab *tab) +void Viewport::showChatPopup(const int x, const int y, ChatTab *const tab) { mPopupMenu->showChatPopup(x, y, tab); } -void Viewport::showChatPopup(ChatTab *tab) +void Viewport::showChatPopup(ChatTab *const tab) { mPopupMenu->showChatPopup(getMouseX(), getMouseY(), tab); } -void Viewport::showPopup(int x, int y, Being *being) +void Viewport::showPopup(const int x, const int y, const Being *const being) { mPopupMenu->showPopup(x, y, being); } -void Viewport::showPopup(Being *being) +void Viewport::showPopup(const Being *const being) { mPopupMenu->showPopup(getMouseX(), getMouseY(), being); } @@ -686,17 +687,17 @@ void Viewport::showPlayerPopup(std::string nick) mPopupMenu->showPlayerPopup(getMouseX(), getMouseY(), nick); } -void Viewport::showPopup(int x, int y, Button *button) +void Viewport::showPopup(const int x, const int y, Button *const button) { mPopupMenu->showPopup(x, y, button); } -void Viewport::showPopup(int x, int y, ProgressBar *bar) +void Viewport::showPopup(const int x, const int y, const ProgressBar *const bar) { mPopupMenu->showPopup(x, y, bar); } -void Viewport::showAttackMonsterPopup(std::string name, int type) +void Viewport::showAttackMonsterPopup(const std::string &name, const int type) { mPopupMenu->showAttackMonsterPopup(getMouseX(), getMouseY(), name, type); @@ -707,12 +708,13 @@ void Viewport::showPickupItemPopup(std::string name) mPopupMenu->showPickupItemPopup(getMouseX(), getMouseY(), name); } -void Viewport::showUndressPopup(int x, int y, Being *being, Item *item) +void Viewport::showUndressPopup(const int x, const int y, + const Being *const being, Item *const item) { mPopupMenu->showUndressPopup(x, y, being, item); } -void Viewport::showMapPopup(int x, int y) +void Viewport::showMapPopup(const int x, const int y) { mPopupMenu->showMapPopup(getMouseX(), getMouseY(), x, y); } @@ -764,12 +766,12 @@ void Viewport::mouseMoved(gcn::MouseEvent &event A_UNUSED) if (!mHoverBeing && !mHoverItem) { - SpecialLayer *specialLayer = mMap->getSpecialLayer(); + const SpecialLayer *const specialLayer = mMap->getSpecialLayer(); if (specialLayer) { - int mouseTileX = (getMouseX() + getCameraX()) + const int mouseTileX = (getMouseX() + getCameraX()) / mMap->getTileWidth(); - int mouseTileY = (getMouseY() + getCameraY()) + const int mouseTileY = (getMouseY() + getCameraY()) / mMap->getTileHeight(); mHoverSign = specialLayer->getTile(mouseTileX, mouseTileY); @@ -858,7 +860,7 @@ void Viewport::hideBeingPopup() mTextPopup->setVisible(false); } -void Viewport::clearHover(ActorSprite *actor) +void Viewport::clearHover(const ActorSprite *const actor) { if (mHoverBeing == actor) mHoverBeing = nullptr; @@ -874,45 +876,45 @@ void Viewport::cleanHoverItems() mHoverSign = nullptr; } -void Viewport::moveCamera(int dx, int dy) +void Viewport::moveCamera(const int dx, const int dy) { mCameraRelativeX += dx; mCameraRelativeY += dy; } -bool Viewport::isPopupMenuVisible() +bool Viewport::isPopupMenuVisible() const { return mPopupMenu ? mPopupMenu->isVisible() : false; } -void Viewport::moveCameraToActor(int actorId, int x, int y) +void Viewport::moveCameraToActor(const int actorId, const int x, const int y) { if (!player_node || !actorSpriteManager) return; - Actor *actor = actorSpriteManager->findBeing(actorId); + const Actor *const actor = actorSpriteManager->findBeing(actorId); if (!actor) return; - Vector actorPos = actor->getPosition(); - Vector playerPos = player_node->getPosition(); + const Vector actorPos = actor->getPosition(); + const Vector playerPos = player_node->getPosition(); mCameraMode = 1; mCameraRelativeX = actorPos.x - playerPos.x + x; mCameraRelativeY = actorPos.y - playerPos.y + y; } -void Viewport::moveCameraToPosition(int x, int y) +void Viewport::moveCameraToPosition(const int x, const int y) { if (!player_node) return; - Vector playerPos = player_node->getPosition(); + const Vector playerPos = player_node->getPosition(); mCameraMode = 1; mCameraRelativeX = x - playerPos.x; mCameraRelativeY = y - playerPos.y; } -void Viewport::moveCameraRelative(int x, int y) +void Viewport::moveCameraRelative(const int x, const int y) { mCameraMode = 1; mCameraRelativeX += x; @@ -926,7 +928,7 @@ void Viewport::returnCamera() mCameraRelativeY = 0; } -void Viewport::validateSpeed() +void Viewport::validateSpeed() const { if (!inputManager.isActionActive(static_cast<int>( Input::KEY_TARGET_ATTACK)) && !inputManager.isActionActive( diff --git a/src/gui/viewport.h b/src/gui/viewport.h index 0d84837c8..c83e83173 100644 --- a/src/gui/viewport.h +++ b/src/gui/viewport.h @@ -77,7 +77,7 @@ class Viewport : public WindowContainer, public gcn::MouseListener, /** * Sets the map displayed by the viewport. */ - void setMap(Map *map); + void setMap(Map *const map); /** * Draws the viewport. @@ -122,43 +122,44 @@ class Viewport : public WindowContainer, public gcn::MouseListener, * Shows a popup for an item. * TODO Find some way to get rid of Item here */ - void showPopup(Window *parent, int x, int y, Item *item, - bool isInventory = true); + void showPopup(Window *parent, const int x, const int y, + Item *const item, const bool isInventory = true); /** * Shows a popup for an item. * TODO Find some way to get rid of Item here */ - void showPopup(Window *parent, Item *item, bool isInventory = true); + void showPopup(Window *const parent, Item *const item, + const bool isInventory = true); - void showPopup(int x, int y, Button *button); + void showPopup(const int x, const int y, Button *const button); - void showPopup(int x, int y, ProgressBar *bar); + void showPopup(const int x, const int y, const ProgressBar *const bar); - void showPopup(MapItem *item); + void showPopup(MapItem *const item); - void showItemPopup(Item *item); + void showItemPopup(Item *const item); - void showItemPopup(int itemId, unsigned char color = 1); + void showItemPopup(const int itemId, const unsigned char color = 1); - void showDropPopup(Item *item); + void showDropPopup(Item *const item); /** * Shows a popup for being. */ - void showPopup(int x, int y, Being *being); + void showPopup(const int x, const int y, const Being *const being); - void showPopup(Being *being); + void showPopup(const Being *const being); void showPlayerPopup(std::string nick); - void showOutfitsPopup(int x, int y); + void showOutfitsPopup(const int x, const int y); void showOutfitsPopup(); - void showSpellPopup(TextCommand *cmd); + void showSpellPopup(TextCommand *const cmd); - void showAttackMonsterPopup(std::string name, int type); + void showAttackMonsterPopup(const std::string &name, const int type); void showPickupItemPopup(std::string name); @@ -166,16 +167,17 @@ class Viewport : public WindowContainer, public gcn::MouseListener, * Shows the related popup menu when right click on the chat * at the specified mouse coordinates. */ - void showChatPopup(int x, int y, ChatTab *tab); + void showChatPopup(const int x, const int y, ChatTab *const tab); /** * Shows the related popup menu when right click on the chat */ - void showChatPopup(ChatTab *tab); + void showChatPopup(ChatTab *const tab); - void showUndressPopup(int x, int y, Being *being, Item *item); + void showUndressPopup(const int x, const int y, + const Being *const being, Item *const item); - void showMapPopup(int x, int y); + void showMapPopup(const int x, const int y); /** * Closes the popup menu. Needed for when the player dies or switching @@ -215,7 +217,7 @@ class Viewport : public WindowContainer, public gcn::MouseListener, /** * Changes viewpoint by relative pixel coordinates. */ - void scrollBy(int x, int y) + void scrollBy(const int x, const int y) { mPixelViewX += x; mPixelViewY += y; } /** @@ -227,7 +229,7 @@ class Viewport : public WindowContainer, public gcn::MouseListener, int getDebugPath() const { return mShowDebugPath; } - void setDebugPath(int n) + void setDebugPath(const int n) { mShowDebugPath = n; } int getCameraMode() const @@ -246,7 +248,7 @@ class Viewport : public WindowContainer, public gcn::MouseListener, Map *getMap() const { return mMap; } - void moveCamera(int dx, int dy); + void moveCamera(const int dx, const int dy); int getCameraRelativeX() const { return mCameraRelativeX; } @@ -254,19 +256,20 @@ class Viewport : public WindowContainer, public gcn::MouseListener, int getCameraRelativeY() const { return mCameraRelativeY; } - void setCameraRelativeX(int n) + void setCameraRelativeX(const int n) { mCameraRelativeX = n; } - void setCameraRelativeY(int n) + void setCameraRelativeY(const int n) { mCameraRelativeY = n; } - bool isPopupMenuVisible(); + bool isPopupMenuVisible() const; - void moveCameraToActor(int actorId, int x = 0, int y = 0); + void moveCameraToActor(const int actorId, const int x = 0, + const int y = 0); - void moveCameraToPosition(int x, int y); + void moveCameraToPosition(const int x, const int y); - void moveCameraRelative(int x, int y); + void moveCameraRelative(const int x, const int y); void returnCamera(); @@ -274,22 +277,22 @@ class Viewport : public WindowContainer, public gcn::MouseListener, friend class ActorSpriteManager; /// Clears any matching hovers - void clearHover(ActorSprite *actor); + void clearHover(const ActorSprite *const actor); - void validateSpeed(); + void validateSpeed() const; private: /** * Finds a path from the player to the mouse, and draws it. This is for * debug purposes. */ - void _drawDebugPath(Graphics *graphics); + void _drawDebugPath(Graphics *const graphics); /** * Draws the given path. */ - void _drawPath(Graphics *graphics, const Path &path, - gcn::Color color = gcn::Color(255, 0, 0)); + void _drawPath(Graphics *const graphics, const Path &path, + const gcn::Color color = gcn::Color(255, 0, 0)) const; /** * Make the player go to the mouse position. diff --git a/src/gui/whoisonline.h b/src/gui/whoisonline.h index 1158ce03c..57778e2d4 100644 --- a/src/gui/whoisonline.h +++ b/src/gui/whoisonline.h @@ -49,8 +49,9 @@ namespace gcn class OnlinePlayer { public: - OnlinePlayer(std::string nick, unsigned char status, - char level, unsigned char gender, char version) : + OnlinePlayer(const std::string &nick, const unsigned char status, + const char level, const unsigned char gender, + const char version) : mNick(nick), mText(""), mStatus(status), @@ -67,7 +68,7 @@ class OnlinePlayer unsigned char getStaus() const { return mStatus; } - void setIsGM(bool b) + void setIsGM(const bool b) { mIsGM = b; } char getVersion() const @@ -81,7 +82,7 @@ class OnlinePlayer void setText(std::string str); - void setLevel(char level) + void setLevel(const char level) { mLevel = level; } private: @@ -138,13 +139,13 @@ public: void widgetResized(const gcn::Event &event); - const std::set<OnlinePlayer*> &getOnlinePlayers() + const std::set<OnlinePlayer*> &getOnlinePlayers() const { return mOnlinePlayers; } - const std::set<std::string> &getOnlineNicks() + const std::set<std::string> &getOnlineNicks() const { return mOnlineNicks; } - void setAllowUpdate(bool n) + void setAllowUpdate(const bool n) { mAllowUpdate = n; } void optionChanged(const std::string &name); diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index 2a009bcc6..a3a4a2334 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -93,12 +93,13 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics) if (!mListModel || !player_node) return; - AvatarListModel *model = static_cast<AvatarListModel*>(mListModel); + AvatarListModel *const model = static_cast<AvatarListModel *const>( + mListModel); // Guild *guild = dynamic_cast<Guild*>(model); updateAlpha(); - Graphics *graphics = static_cast<Graphics*>(gcnGraphics); + Graphics *const graphics = static_cast<Graphics *const>(gcnGraphics); mHighlightColor.a = static_cast<int>(mAlpha * 255.0f); graphics->setColor(mHighlightColor); @@ -106,7 +107,7 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics) const int fontHeight = getFont()->getHeight(); - Widget *parent = mParent; + const Widget *const parent = mParent; const std::string name = player_node->getName(); @@ -116,14 +117,14 @@ void AvatarListBox::draw(gcn::Graphics *gcnGraphics) i < model->getNumberOfElements(); ++i, y += fontHeight) { - Avatar *a = model->getAvatarAt(i); + const Avatar *const a = model->getAvatarAt(i); if (!a) continue; if (a->getType() != MapItem::SEPARATOR) { // Draw online status - Image *icon = a->getOnline() ? onlineIcon : offlineIcon; + const Image *const icon = a->getOnline() ? onlineIcon : offlineIcon; if (icon) graphics->drawImage(icon, 2, y + 1); } @@ -304,17 +305,18 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event) return; } - int y = event.getY() / getFont()->getHeight(); + const int y = event.getY() / getFont()->getHeight(); if (!mListModel || y > mListModel->getNumberOfElements()) return; setSelected(y); distributeActionEvent(); - int selected = getSelected(); - AvatarListModel *model = static_cast<AvatarListModel*>(mListModel); + const int selected = getSelected(); + AvatarListModel *const model = static_cast<AvatarListModel *const>( + mListModel); if (!model) return; - Avatar *ava = model->getAvatarAt(selected); + const Avatar *ava = model->getAvatarAt(selected); if (!ava) return; @@ -322,8 +324,8 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event) { if (ava->getType() == AVATAR_PLAYER) { - Being* being = actorSpriteManager->findBeingByName(ava->getName(), - Being::PLAYER); + const Being *const being = actorSpriteManager->findBeingByName( + ava->getName(), Being::PLAYER); if (being) actorSpriteManager->heal(being); } @@ -338,10 +340,10 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event) { case AVATAR_PLAYER: { - Avatar *avatar = model->getAvatarAt(selected); + const Avatar *const avatar = model->getAvatarAt(selected); if (avatar) { - Being* being = actorSpriteManager->findBeingByName( + Being *const being = actorSpriteManager->findBeingByName( avatar->getName(), Being::PLAYER); if (being) viewport->showPopup(being); @@ -378,11 +380,11 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event) } default: { - Map *map = viewport->getMap(); + const Map *const map = viewport->getMap(); ava = model->getAvatarAt(selected); if (map && ava) { - MapItem *mapItem = map->findPortalXY( + MapItem *const mapItem = map->findPortalXY( ava->getX(), ava->getY()); viewport->showPopup(mapItem); } @@ -394,7 +396,7 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event) { if (ava->getType() == AVATAR_PLAYER && chatWindow) { - ChatTab *tab = chatWindow->addWhisperTab( + const ChatTab *const tab = chatWindow->addWhisperTab( model->getAvatarAt(selected)->getName(), true); if (chatWindow && tab) chatWindow->saveState(); diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index f61851e1f..fded0cbe7 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -45,7 +45,7 @@ #include "debug.h" -BrowserBox::BrowserBox(unsigned int mode, bool opaque): +BrowserBox::BrowserBox(const unsigned int mode, const bool opaque) : gcn::Widget(), mLinkHandler(nullptr), mMode(mode), @@ -94,17 +94,17 @@ void BrowserBox::setOpaque(bool opaque) mOpaque = opaque; } -void BrowserBox::setHighlightMode(unsigned int highMode) +void BrowserBox::setHighlightMode(const unsigned int highMode) { mHighMode = highMode; } -void BrowserBox::addRow(const std::string &row, bool atTop) +void BrowserBox::addRow(const std::string &row, const bool atTop) { std::string tmp = row; std::string newRow; size_t idx1; - gcn::Font *font = getFont(); + const gcn::Font *const font = getFont(); int linksCount = 0; if (getWidth() < 0) @@ -208,7 +208,7 @@ void BrowserBox::addRow(const std::string &row, bool atTop) } // Adjust the BrowserBox size - int w = font->getWidth(plain); + const int w = font->getWidth(plain); if (w > getWidth()) setWidth(w); } @@ -217,8 +217,8 @@ void BrowserBox::addRow(const std::string &row, bool atTop) { unsigned int y = 0; unsigned int nextChar; - const char *hyphen = "~"; - int hyphenWidth = font->getWidth(hyphen); + const char *const hyphen = "~"; + const int hyphenWidth = font->getWidth(hyphen); unsigned x = 0; for (TextRowCIter i = mTextRows.begin(), i_end = mTextRows.end(); @@ -240,7 +240,7 @@ void BrowserBox::addRow(const std::string &row, bool atTop) if (nextSpacePos <= 0) nextSpacePos = static_cast<int>(sz) - 1; - unsigned nextWordWidth = font->getWidth( + const unsigned nextWordWidth = font->getWidth( tempRow.substr(nextChar, (nextSpacePos - nextChar))); @@ -273,7 +273,7 @@ void BrowserBox::addRow(const std::string &row, bool atTop) updateHeight(); } -void BrowserBox::addRow(const std::string &cmd, char *text) +void BrowserBox::addRow(const std::string &cmd, const char *const text) { addRow(strprintf("@@%s|%s@@", cmd.c_str(), text)); } @@ -301,10 +301,11 @@ void BrowserBox::clearRows() struct MouseOverLink { - MouseOverLink(int x, int y) : mX(x), mY(y) + MouseOverLink(const int x, const int y) : + mX(x), mY(y) { } - bool operator() (BROWSER_LINK &link) const + bool operator() (const BROWSER_LINK &link) const { return (mX >= link.x1 && mX < link.x2 && mY >= link.y1 && mY < link.y2); @@ -317,7 +318,7 @@ void BrowserBox::mousePressed(gcn::MouseEvent &event) if (!mLinkHandler) return; - LinkIterator i = find_if(mLinks.begin(), mLinks.end(), + const LinkIterator i = find_if(mLinks.begin(), mLinks.end(), MouseOverLink(event.getX(), event.getY())); if (i != mLinks.end()) @@ -326,7 +327,7 @@ void BrowserBox::mousePressed(gcn::MouseEvent &event) void BrowserBox::mouseMoved(gcn::MouseEvent &event) { - LinkIterator i = find_if(mLinks.begin(), mLinks.end(), + const LinkIterator i = find_if(mLinks.begin(), mLinks.end(), MouseOverLink(event.getX(), event.getY())); mSelectedLink = (i != mLinks.end()) @@ -335,10 +336,10 @@ void BrowserBox::mouseMoved(gcn::MouseEvent &event) void BrowserBox::draw(gcn::Graphics *graphics) { - gcn::ClipRectangle cr = graphics->getCurrentClipArea(); - Graphics *graphics2 = static_cast<Graphics*>(graphics); + const gcn::ClipRectangle cr = graphics->getCurrentClipArea(); + Graphics *const graphics2 = static_cast<Graphics *const>(graphics); mYStart = cr.y - cr.yOffset; - int yEnd = mYStart + cr.height; + const int yEnd = mYStart + cr.height; if (mYStart < 0) mYStart = 0; @@ -376,7 +377,7 @@ void BrowserBox::draw(gcn::Graphics *graphics) } } - gcn::Font *font = getFont(); + gcn::Font *const font = getFont(); for (LinePartCIter i = mLineParts.begin(), i_end = mLineParts.end(); i != i_end; ++i) @@ -415,16 +416,16 @@ int BrowserBox::calcHeight() if (getWidth() < 0) return 1; - gcn::Font *font = getFont(); + const gcn::Font *const font = getFont(); - int fontHeight = font->getHeight(); - int fontWidthMinus = font->getWidth("-"); - char const *hyphen = "~"; - int hyphenWidth = font->getWidth(hyphen); + const int fontHeight = font->getHeight(); + const int fontWidthMinus = font->getWidth("-"); + char const *const hyphen = "~"; + const int hyphenWidth = font->getWidth(hyphen); gcn::Color selColor = getForegroundColor(); const gcn::Color textColor = getForegroundColor(); - ResourceManager *resman = ResourceManager::getInstance(); + ResourceManager *const resman = ResourceManager::getInstance(); mLineParts.clear(); @@ -453,7 +454,7 @@ int BrowserBox::calcHeight() std::string str = row.substr(3); if (str.size() > 2 && str.substr(str.size() - 1) == "~") str = str.substr(0, str.size() - 1); - Image *img = resman->getImage(str); + Image *const img = resman->getImage(str); if (img) { img->incRef(); diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h index c19256afa..ed7208031 100644 --- a/src/gui/widgets/browserbox.h +++ b/src/gui/widgets/browserbox.h @@ -46,13 +46,15 @@ struct BROWSER_LINK class LinePart { public: - LinePart(int x, int y, gcn::Color color, std::string text, bool bold) : + LinePart(const int x, const int y, const gcn::Color color, + const std::string &text, const bool bold) : mX(x), mY(y), mColor(color), mText(text), mType(0), mImage(nullptr), mBold(bold) { } - LinePart(int x, int y, gcn::Color color, Image *image) : + LinePart(const int x, const int y, const gcn::Color color, + Image *const image) : mX(x), mY(y), mColor(color), mText(""), mType(1), mImage(image), mBold(false) { @@ -79,7 +81,8 @@ class BrowserBox : public gcn::Widget, /** * Constructor. */ - BrowserBox(unsigned int mode = AUTO_SIZE, bool opaque = true); + BrowserBox(const unsigned int mode = AUTO_SIZE, + const bool opaque = true); /** * Destructor. @@ -99,7 +102,7 @@ class BrowserBox : public gcn::Widget, /** * Sets the Highlight mode for links. */ - void setHighlightMode(unsigned int highMode); + void setHighlightMode(const unsigned int highMode); /** * Sets the maximum numbers of rows in the browser box. 0 = no limit. @@ -116,12 +119,12 @@ class BrowserBox : public gcn::Widget, /** * Adds a text row to the browser. */ - void addRow(const std::string &row, bool atTop = false); + void addRow(const std::string &row, const bool atTop = false); /** * Adds a menu line to the browser. */ - void addRow(const std::string &cmd, char *text); + void addRow(const std::string &cmd, const char *const text); void addImage(const std::string &path); diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index d464940ec..2f475db88 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -82,7 +82,7 @@ Button::Button() : } Button::Button(const std::string &caption, const std::string &actionEventId, - gcn::ActionListener *listener) : + gcn::ActionListener *const listener) : gcn::Button(caption), mDescription(""), mClickCount(0), @@ -108,9 +108,9 @@ Button::Button(const std::string &caption, const std::string &actionEventId, } Button::Button(const std::string &caption, const std::string &imageName, - int imageWidth, int imageHeight, + const int imageWidth, const int imageHeight, const std::string &actionEventId, - gcn::ActionListener *listener) : + gcn::ActionListener *const listener) : gcn::Button(caption), mDescription(""), mClickCount(0), @@ -136,9 +136,10 @@ Button::Button(const std::string &caption, const std::string &imageName, addActionListener(listener); } -Button::Button(const std::string &imageName, int imageWidth, int imageHeight, +Button::Button(const std::string &imageName, + const int imageWidth, const int imageHeight, const std::string &actionEventId, - gcn::ActionListener *listener) : + gcn::ActionListener *const listener) : gcn::Button(""), mDescription(""), mClickCount(0), @@ -195,7 +196,7 @@ Button::~Button() if (mInstances == 0 && Theme::instance()) { - Theme *theme = Theme::instance(); + Theme *const theme = Theme::instance(); for (int mode = 0; mode < BUTTON_COUNT; mode ++) theme->unloadRect(button[mode]); } @@ -230,7 +231,7 @@ void Button::loadImage(const std::string &imageName) mImages[0] = nullptr; for (int f = 0; f < BUTTON_COUNT; f ++) { - Image *img = mImageSet->get(f); + Image *const img = mImageSet->get(f); if (img) mImages[f] = img; else @@ -240,7 +241,7 @@ void Button::loadImage(const std::string &imageName) void Button::updateAlpha() { - float alpha = std::max(Client::getGuiAlpha(), + const float alpha = std::max(Client::getGuiAlpha(), Theme::instance()->getMinimumOpacity()); if (mAlpha != alpha) @@ -275,7 +276,7 @@ void Button::draw(gcn::Graphics *graphics) updateAlpha(); - Graphics *g2 = static_cast<Graphics*>(graphics); + Graphics *const g2 = static_cast<Graphics *const>(graphics); bool recalc = false; if (mRedraw) @@ -321,7 +322,7 @@ void Button::draw(gcn::Graphics *graphics) graphics->setColor(mEnabledColor); int textX = 0; - int textY = getHeight() / 2 - getFont()->getHeight() / 2; + const int textY = getHeight() / 2 - getFont()->getHeight() / 2; int imageX = 0; int imageY = 0; if (mImages) @@ -346,7 +347,8 @@ void Button::draw(gcn::Graphics *graphics) case gcn::Graphics::CENTER: if (mImages) { - int width = getFont()->getWidth(mCaption) + mImageWidth + 2; + const int width = getFont()->getWidth(mCaption) + + mImageWidth + 2; imageX = getWidth() / 2 - width / 2; textX = imageX + mImageWidth + 2; } @@ -434,7 +436,7 @@ void Button::setCaption(const std::string& caption) void Button::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) { @@ -445,7 +447,7 @@ void Button::keyPressed(gcn::KeyEvent& keyEvent) void Button::keyReleased(gcn::KeyEvent& keyEvent) { - int action = static_cast<KeyEvent*>(&keyEvent)->getActionId(); + const int action = static_cast<KeyEvent*>(&keyEvent)->getActionId(); if (action == Input::KEY_GUI_SELECT && mKeyPressed) { @@ -458,7 +460,7 @@ void Button::keyReleased(gcn::KeyEvent& keyEvent) } -bool Button::isPressed2() +bool Button::isPressed2() const { return (mPressed || isPressed()); } diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h index c2d8b0b52..e3ff82f0f 100644 --- a/src/gui/widgets/button.h +++ b/src/gui/widgets/button.h @@ -52,24 +52,25 @@ class Button : public gcn::Button, public gcn::WidgetListener * adds the given action listener. */ Button(const std::string &caption, const std::string &actionEventId, - gcn::ActionListener *listener); + gcn::ActionListener *const listener); /** * Constructor, sets the caption of the button to the given string and * adds the given action listener. */ Button(const std::string &caption, const std::string &imageName, - int imageWidth, int imageHeight, + const int imageWidth, const int imageHeight, const std::string &actionEventId, - gcn::ActionListener *listener); + gcn::ActionListener *const listener); /** * Constructor, sets the caption of the button to the given string and * adds the given action listener. */ - Button(const std::string &imageName, int imageWidth, int imageHeight, + Button(const std::string &imageName, + const int imageWidth, const int imageHeight, const std::string &actionEventId, - gcn::ActionListener *listener); + gcn::ActionListener *const listener); /** * Destructor. @@ -123,7 +124,7 @@ class Button : public gcn::Button, public gcn::WidgetListener void keyReleased(gcn::KeyEvent &keyEvent); - bool isPressed2(); + bool isPressed2() const; private: void init(); diff --git a/src/gui/widgets/channeltab.cpp b/src/gui/widgets/channeltab.cpp index f362cc28c..b9ea96650 100644 --- a/src/gui/widgets/channeltab.cpp +++ b/src/gui/widgets/channeltab.cpp @@ -31,7 +31,7 @@ #include "debug.h" -ChannelTab::ChannelTab(Channel *channel) : +ChannelTab::ChannelTab(Channel *const channel) : ChatTab(channel->getName()), mChannel(channel) { diff --git a/src/gui/widgets/channeltab.h b/src/gui/widgets/channeltab.h index 39702a696..d78027b67 100644 --- a/src/gui/widgets/channeltab.h +++ b/src/gui/widgets/channeltab.h @@ -48,7 +48,7 @@ class ChannelTab : public ChatTab /** * Constructor. */ - ChannelTab(Channel *channel); + ChannelTab(Channel *const channel); /** * Destructor. diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index 0c1bab71a..a78d1f636 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -86,7 +86,7 @@ ChatTab::~ChatTab() } void ChatTab::chatLog(std::string line, Own own, - bool ignoreRecord, bool tryRemoveColors) + const bool ignoreRecord, const bool tryRemoveColors) { // Trim whitespace trim(line); @@ -102,7 +102,7 @@ void ChatTab::chatLog(std::string line, Own own, return; } - unsigned lineLim = config.getIntValue("chatMaxCharLimit"); + const unsigned lineLim = config.getIntValue("chatMaxCharLimit"); if (lineLim > 0 && line.length() > lineLim) line = line.substr(0, lineLim); @@ -220,7 +220,7 @@ void ChatTab::chatLog(std::string line, Own own, if (config.getBoolValue("useLocalTime")) { - struct tm *timeInfo; + const struct tm *timeInfo; timeInfo = localtime(&t); if (timeInfo) { @@ -326,7 +326,7 @@ void ChatTab::chatLog(std::string line, Own own, void ChatTab::chatLog(const std::string &nick, std::string msg) { - Own byWho = (nick == player_node->getName() ? BY_PLAYER : BY_OTHER); + const Own byWho = (nick == player_node->getName() ? BY_PLAYER : BY_OTHER); if (byWho == BY_OTHER && config.getBoolValue("removeColors")) msg = removeColors(msg); chatLog(nick + " : " + msg, byWho, false, false); @@ -395,9 +395,9 @@ void ChatTab::chatInput(const std::string &message) } } -void ChatTab::scroll(int amount) +void ChatTab::scroll(const int amount) { - int range = mScrollArea->getHeight() / 8 * amount; + const int range = mScrollArea->getHeight() / 8 * amount; gcn::Rectangle scr; scr.y = mScrollArea->getVerticalScrollAmount() + range; scr.height = abs(range); diff --git a/src/gui/widgets/chattab.h b/src/gui/widgets/chattab.h index 27149a9f1..0b4a287d0 100644 --- a/src/gui/widgets/chattab.h +++ b/src/gui/widgets/chattab.h @@ -67,7 +67,8 @@ class ChatTab : public Tab * @param removeColors try remove color if configured */ void chatLog(std::string line, Own own = BY_SERVER, - bool ignoreRecord = false, bool tryRemoveColors = true); + const bool ignoreRecord = false, + const bool tryRemoveColors = true); /** * Adds the text to the message list @@ -92,7 +93,7 @@ class ChatTab : public Tab * up, positive numbers scroll down. The absolute amount indicates the * amount of 1/8ths of chat window real estate that should be scrolled. */ - void scroll(int amount); + void scroll(const int amount); /** * Clears the text from the tab @@ -145,19 +146,19 @@ class ChatTab : public Tab bool getAllowHighlight() const { return mAllowHightlight; } - void setAllowHighlight(bool n) + void setAllowHighlight(const bool n) { mAllowHightlight = n; } bool getRemoveNames() const { return mRemoveNames; } - void setRemoveNames(bool n) + void setRemoveNames(const bool n) { mRemoveNames = n; } bool getNoAway() const { return mNoAway; } - void setNoAway(bool n) + void setNoAway(const bool n) { mNoAway = n; } void addNewRow(std::string &line); diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp index 72ca9eb8d..759ca9015 100644 --- a/src/gui/widgets/checkbox.cpp +++ b/src/gui/widgets/checkbox.cpp @@ -46,8 +46,9 @@ Image *CheckBox::checkBoxDisabledChecked; Image *CheckBox::checkBoxNormalHi; Image *CheckBox::checkBoxCheckedHi; -CheckBox::CheckBox(const std::string &caption, bool selected, - gcn::ActionListener* listener, std::string eventId): +CheckBox::CheckBox(const std::string &caption, const bool selected, + gcn::ActionListener *const listener, + const std::string &eventId) : gcn::CheckBox(caption, selected), mHasMouse(false) { @@ -152,7 +153,7 @@ void CheckBox::draw(gcn::Graphics* graphics) void CheckBox::updateAlpha() { - float alpha = std::max(Client::getGuiAlpha(), + const float alpha = std::max(Client::getGuiAlpha(), Theme::instance()->getMinimumOpacity()); if (mAlpha != alpha) @@ -173,9 +174,9 @@ void CheckBox::updateAlpha() } } -void CheckBox::drawBox(gcn::Graphics* graphics) +void CheckBox::drawBox(gcn::Graphics *const graphics) { - Image *box; + const Image *box; if (isEnabled()) { @@ -220,7 +221,7 @@ void CheckBox::mouseExited(gcn::MouseEvent& event A_UNUSED) void CheckBox::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/checkbox.h b/src/gui/widgets/checkbox.h index e86e4b214..ff1c2d56c 100644 --- a/src/gui/widgets/checkbox.h +++ b/src/gui/widgets/checkbox.h @@ -41,8 +41,8 @@ class CheckBox : public gcn::CheckBox * Constructor. */ CheckBox(const std::string &caption, bool selected = false, - gcn::ActionListener* listener = nullptr, - std::string eventId = ""); + gcn::ActionListener *const listener = nullptr, + const std::string &eventId = ""); /** * Destructor. @@ -52,7 +52,7 @@ class CheckBox : public gcn::CheckBox /** * Draws the caption, then calls drawBox to draw the check box. */ - void draw(gcn::Graphics* graphics); + void draw(gcn::Graphics *const graphics); /** * Update the alpha value to the checkbox components. diff --git a/src/gui/widgets/container.cpp b/src/gui/widgets/container.cpp index e085d609f..2a15c3044 100644 --- a/src/gui/widgets/container.cpp +++ b/src/gui/widgets/container.cpp @@ -35,7 +35,7 @@ Container::~Container() delete mWidgets.front(); } -bool Container::safeRemove(gcn::Widget* widget) +bool Container::safeRemove(gcn::Widget *const widget) { for (WidgetListConstIterator iter = mWidgets.begin(); iter != mWidgets.end(); ++iter) diff --git a/src/gui/widgets/container.h b/src/gui/widgets/container.h index d927f5379..26706722b 100644 --- a/src/gui/widgets/container.h +++ b/src/gui/widgets/container.h @@ -46,7 +46,7 @@ class Container : public gcn::Container ~Container(); - bool safeRemove(gcn::Widget* widget); + bool safeRemove(gcn::Widget *const widget); }; #endif diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp index b6bd62fa7..01002640a 100644 --- a/src/gui/widgets/desktop.cpp +++ b/src/gui/widgets/desktop.cpp @@ -86,7 +86,7 @@ void Desktop::widgetResized(const gcn::Event &event A_UNUSED) void Desktop::draw(gcn::Graphics *graphics) { - Graphics *g = static_cast<Graphics *>(graphics); + Graphics *const g = static_cast<Graphics *const>(graphics); if (!mWallpaper || (getWidth() > mWallpaper->getWidth() || getHeight() > mWallpaper->getHeight())) @@ -126,7 +126,7 @@ void Desktop::setBestFittingWallpaper() const std::string wallpaperName = Wallpaper::getWallpaper(getWidth(), getHeight()); - Image *nWallPaper = Theme::getImageFromTheme(wallpaperName); + Image *const nWallPaper = Theme::getImageFromTheme(wallpaperName); if (nWallPaper) { @@ -138,8 +138,8 @@ void Desktop::setBestFittingWallpaper() || nWallPaper->getHeight() != getHeight())) { // We rescale to obtain a fullscreen wallpaper... - Image *newRsclWlPpr = ResourceManager::getInstance()->getRescaled( - nWallPaper, getWidth(), getHeight()); + Image *const newRsclWlPpr = ResourceManager::getInstance() + ->getRescaled(nWallPaper, getWidth(), getHeight()); // We replace the resource in the resource manager nWallPaper->decRef(); diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 3012c5553..bb18ff2dd 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -54,8 +54,9 @@ static std::string const dropdownFiles[2] = "dropdown_pressed.xml" }; -DropDown::DropDown(gcn::ListModel *listModel, gcn::ActionListener* listener, - std::string eventId): +DropDown::DropDown(gcn::ListModel *const listModel, + gcn::ActionListener *const listener, + const std::string &eventId): gcn::DropDown::DropDown(listModel, new ScrollArea, new ListBox(listModel)), mShadowColor(Theme::getThemeColor(Theme::DROPDOWN_SHADOW)), @@ -69,7 +70,7 @@ DropDown::DropDown(gcn::ListModel *listModel, gcn::ActionListener* listener, // Load the background skin for (int i = 0; i < 2; i ++) { - Skin *skin = Theme::instance()->load( + Skin *const skin = Theme::instance()->load( dropdownFiles[i], "dropdown.xml"); if (skin) { @@ -217,7 +218,7 @@ void DropDown::drawFrame(gcn::Graphics *graphics) void DropDown::drawButton(gcn::Graphics *graphics) { - int height = mDroppedDown ? mFoldedUpHeight : getHeight(); + const int height = mDroppedDown ? mFoldedUpHeight : getHeight(); if (buttons[mDroppedDown][mPushed]) { @@ -233,7 +234,7 @@ void DropDown::keyPressed(gcn::KeyEvent& keyEvent) if (keyEvent.isConsumed()) return; - int actionId = static_cast<KeyEvent*>(&keyEvent)->getActionId(); + const int actionId = static_cast<KeyEvent*>(&keyEvent)->getActionId(); switch (actionId) { @@ -305,7 +306,7 @@ void DropDown::mouseWheelMovedDown(gcn::MouseEvent& mouseEvent) void DropDown::setSelectedString(std::string str) { - gcn::ListModel *listModel = mListBox->getListModel(); + gcn::ListModel *const listModel = mListBox->getListModel(); if (!listModel) return; @@ -321,7 +322,7 @@ void DropDown::setSelectedString(std::string str) std::string DropDown::getSelectedString() const { - gcn::ListModel *listModel = mListBox->getListModel(); + gcn::ListModel *const listModel = mListBox->getListModel(); if (!listModel) return ""; diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index c044e8a16..c01466c03 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -48,9 +48,9 @@ class DropDown : public gcn::DropDown * @param listBox the listBox to use. * @see ListModel, ScrollArea, ListBox. */ - DropDown(gcn::ListModel *listModel = nullptr, - gcn::ActionListener* listener = nullptr, - std::string eventId = ""); + DropDown(gcn::ListModel *const listModel = nullptr, + gcn::ActionListener *const listener = nullptr, + const std::string &eventId = ""); ~DropDown(); diff --git a/src/gui/widgets/dropshortcutcontainer.cpp b/src/gui/widgets/dropshortcutcontainer.cpp index af95ffa82..5adc4e343 100644 --- a/src/gui/widgets/dropshortcutcontainer.cpp +++ b/src/gui/widgets/dropshortcutcontainer.cpp @@ -93,7 +93,7 @@ void DropShortcutContainer::draw(gcn::Graphics *graphics) mBackgroundImg->setAlpha(mAlpha); } - Graphics *g = static_cast<Graphics*>(graphics); + Graphics *const g = static_cast<Graphics*>(graphics); graphics->setFont(getFont()); @@ -106,7 +106,7 @@ void DropShortcutContainer::draw(gcn::Graphics *graphics) } } - Inventory *inv = PlayerInfo::getInventory(); + const Inventory *const inv = PlayerInfo::getInventory(); if (!inv) return; @@ -118,13 +118,13 @@ void DropShortcutContainer::draw(gcn::Graphics *graphics) if (dropShortcut->getItem(i) < 0) continue; - Item *item = inv->findItem(dropShortcut->getItem(i), + const Item *const item = inv->findItem(dropShortcut->getItem(i), dropShortcut->getItemColor(i)); if (item) { // Draw item icon. - Image* image = item->getImage(); + Image *const image = item->getImage(); if (image) { @@ -149,7 +149,7 @@ void DropShortcutContainer::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); @@ -183,11 +183,11 @@ void DropShortcutContainer::mouseDragged(gcn::MouseEvent &event) if (itemId < 0) return; - Inventory *inv = PlayerInfo::getInventory(); + const Inventory *const inv = PlayerInfo::getInventory(); if (!inv) return; - Item *item = inv->findItem(itemId, itemColor); + Item *const item = inv->findItem(itemId, itemColor); if (item) { @@ -229,11 +229,11 @@ void DropShortcutContainer::mousePressed(gcn::MouseEvent &event) } else if (event.getButton() == gcn::MouseEvent::RIGHT) { - Inventory *inv = PlayerInfo::getInventory(); + const Inventory *const inv = PlayerInfo::getInventory(); if (!inv) return; - Item *item = inv->findItem(dropShortcut->getItem(index), + Item *const item = inv->findItem(dropShortcut->getItem(index), dropShortcut->getItemColor(index)); if (viewport) @@ -286,11 +286,11 @@ void DropShortcutContainer::mouseMoved(gcn::MouseEvent &event) if (itemId < 0) return; - Inventory *inv = PlayerInfo::getInventory(); + const Inventory *const inv = PlayerInfo::getInventory(); if (!inv) return; - Item *item = inv->findItem(itemId, itemColor); + const Item *const item = inv->findItem(itemId, itemColor); if (item && viewport) { diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp index cfbfad31d..905a3229b 100644 --- a/src/gui/widgets/emoteshortcutcontainer.cpp +++ b/src/gui/widgets/emoteshortcutcontainer.cpp @@ -63,7 +63,7 @@ EmoteShortcutContainer::EmoteShortcutContainer(): // Setup emote sprites for (int i = 0; i <= EmoteDB::getLast(); i++) { - const EmoteSprite* sprite = EmoteDB::getSprite(i, true); + const EmoteSprite *const sprite = EmoteDB::getSprite(i, true); if (sprite && sprite->sprite) mEmoteImg.push_back(sprite); } @@ -104,7 +104,7 @@ void EmoteShortcutContainer::draw(gcn::Graphics *graphics) if (Client::getGuiAlpha() != mAlpha && mBackgroundImg) mBackgroundImg->setAlpha(mAlpha); - Graphics *g = static_cast<Graphics*>(graphics); + Graphics *const g = static_cast<Graphics *const>(graphics); graphics->setFont(getFont()); @@ -129,7 +129,7 @@ void EmoteShortcutContainer::draw(gcn::Graphics *graphics) graphics->setColor(getForegroundColor()); g->drawText(key, emoteX + 2, emoteY + 2, gcn::Graphics::LEFT); } - unsigned sz = static_cast<unsigned>(mEmoteImg.size()); + const unsigned sz = static_cast<unsigned>(mEmoteImg.size()); for (unsigned i = 0; i < mMaxItems; i++) { if (i < sz && mEmoteImg[i] && mEmoteImg[i]->sprite) @@ -143,10 +143,10 @@ void EmoteShortcutContainer::draw(gcn::Graphics *graphics) && mEmoteMoved > 0) { // Draw the emote image being dragged by the cursor. - const EmoteSprite* sprite = mEmoteImg[mEmoteMoved - 1]; + const EmoteSprite *const sprite = mEmoteImg[mEmoteMoved - 1]; if (sprite && sprite->sprite) { - const AnimatedSprite *spr = sprite->sprite; + const AnimatedSprite *const spr = sprite->sprite; const int tPosX = mCursorPosX - (spr->getWidth() / 2); const int tPosY = mCursorPosY - (spr->getHeight() / 2); diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp index 8421c22df..c7d42338c 100644 --- a/src/gui/widgets/extendedlistbox.cpp +++ b/src/gui/widgets/extendedlistbox.cpp @@ -38,7 +38,7 @@ #include "debug.h" -ExtendedListBox::ExtendedListBox(gcn::ListModel *listModel): +ExtendedListBox::ExtendedListBox(gcn::ListModel *const listModel): ListBox(listModel), mRowHeight(13) { @@ -53,8 +53,9 @@ void ExtendedListBox::draw(gcn::Graphics *graphics) if (!mListModel) return; - ExtendedListModel *model = static_cast<ExtendedListModel*>(mListModel); - Graphics *g = static_cast<Graphics*>(graphics); + ExtendedListModel *const model = static_cast<ExtendedListModel* const>( + mListModel); + Graphics *const g = static_cast<Graphics *const>(graphics); updateAlpha(); graphics->setFont(getFont()); @@ -78,7 +79,7 @@ void ExtendedListBox::draw(gcn::Graphics *graphics) for (int i = 0, y = 0; i < mListModel->getNumberOfElements(); ++i, y += height) { - const Image *image = model->getImageAt(i); + const Image *const image = model->getImageAt(i); if (!image) { graphics->drawText(mListModel->getElementAt(i), 1, y + textPos); diff --git a/src/gui/widgets/extendedlistbox.h b/src/gui/widgets/extendedlistbox.h index c6f3278fc..44e160da3 100644 --- a/src/gui/widgets/extendedlistbox.h +++ b/src/gui/widgets/extendedlistbox.h @@ -29,7 +29,7 @@ class ExtendedListBox : public ListBox /** * Constructor. */ - ExtendedListBox(gcn::ListModel *listModel); + ExtendedListBox(gcn::ListModel *const listModel); ~ExtendedListBox(); diff --git a/src/gui/widgets/flowcontainer.cpp b/src/gui/widgets/flowcontainer.cpp index be7e3136d..7302a039b 100644 --- a/src/gui/widgets/flowcontainer.cpp +++ b/src/gui/widgets/flowcontainer.cpp @@ -23,7 +23,7 @@ #include "debug.h" -FlowContainer::FlowContainer(int boxWidth, int boxHeight): +FlowContainer::FlowContainer(const int boxWidth, const int boxHeight) : mBoxWidth(boxWidth), mBoxHeight(boxHeight), mGridWidth(1), mGridHeight(1) { @@ -42,7 +42,7 @@ void FlowContainer::widgetResized(const gcn::Event &event A_UNUSED) return; } - int itemCount = static_cast<int>(mWidgets.size()); + const int itemCount = static_cast<int>(mWidgets.size()); if (!mBoxWidth) mGridWidth = getWidth(); @@ -70,7 +70,7 @@ void FlowContainer::widgetResized(const gcn::Event &event A_UNUSED) for (WidgetList::const_iterator it = mWidgets.begin(); it != mWidgets.end(); ++it) { - int x = i % mGridWidth * mBoxWidth; + const int x = i % mGridWidth * mBoxWidth; (*it)->setPosition(x, height); i++; diff --git a/src/gui/widgets/flowcontainer.h b/src/gui/widgets/flowcontainer.h index e5eeebdcb..c58a8f121 100644 --- a/src/gui/widgets/flowcontainer.h +++ b/src/gui/widgets/flowcontainer.h @@ -38,7 +38,7 @@ class FlowContainer : public Container, /** * Constructor. Initializes the shortcut container. */ - FlowContainer(int boxWidth, int boxHeight); + FlowContainer(const int boxWidth, const int boxHeight); /** * Destructor. diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp index 63ea96db0..0101ed974 100644 --- a/src/gui/widgets/guitable.cpp +++ b/src/gui/widgets/guitable.cpp @@ -89,7 +89,7 @@ void GuiTableActionListener::action(const gcn::ActionEvent } -GuiTable::GuiTable(TableModel *initial_model, bool opacity) : +GuiTable::GuiTable(TableModel *const initial_model, const bool opacity) : mLinewiseMode(false), mWrappingEnabled(false), mOpaque(opacity), @@ -119,7 +119,7 @@ TableModel *GuiTable::getModel() const return mModel; } -void GuiTable::setModel(TableModel *new_model) +void GuiTable::setModel(TableModel *const new_model) { if (mModel) { @@ -142,8 +142,8 @@ void GuiTable::recomputeDimensions() if (!mModel) return; - int rows_nr = mModel->getRows(); - int columns_nr = mModel->getColumns(); + const int rows_nr = mModel->getRows(); + const int columns_nr = mModel->getColumns(); int width = 0; int height = 0; @@ -178,7 +178,7 @@ int GuiTable::getSelectedColumn() const return mSelectedColumn; } -void GuiTable::setLinewiseSelection(bool linewise) +void GuiTable::setLinewiseSelection(const bool linewise) { mLinewiseMode = linewise; } @@ -263,14 +263,14 @@ void GuiTable::installActionListeners() if (!mModel) return; - int rows = mModel->getRows(); - int columns = mModel->getColumns(); + const int rows = mModel->getRows(); + const int columns = mModel->getColumns(); for (int row = 0; row < rows; ++row) { for (int column = 0; column < columns; ++column) { - gcn::Widget *widget = mModel->getElementAt(row, column); + gcn::Widget *const widget = mModel->getElementAt(row, column); if (widget) { mActionListeners.push_back(new GuiTableActionListener( @@ -317,11 +317,11 @@ void GuiTable::draw(gcn::Graphics* graphics) // Now determine the first and last column // Take the easy way out; these are usually bounded and all visible. - unsigned first_column = 0; - unsigned last_column1 = mModel->getColumns(); + const unsigned first_column = 0; + const unsigned last_column1 = mModel->getColumns(); // Set up everything for drawing - int height = getRowHeight(); + const int height = getRowHeight(); int y_offset = first_row * height; for (unsigned r = first_row; r < first_row + rows_nr; ++r) @@ -330,8 +330,8 @@ void GuiTable::draw(gcn::Graphics* graphics) for (unsigned c = first_column; c + 1 <= last_column1; ++c) { - gcn::Widget *widget = mModel->getElementAt(r, c); - int width = getColumnWidth(c); + gcn::Widget *const widget = mModel->getElementAt(r, c); + const int width = getColumnWidth(c); if (widget) { gcn::Rectangle bounds(x_offset, y_offset, width, height); @@ -376,7 +376,7 @@ void GuiTable::draw(gcn::Graphics* graphics) if (mTopWidget) { - gcn::Rectangle bounds = mTopWidget->getDimension(); + const gcn::Rectangle bounds = mTopWidget->getDimension(); graphics->pushClipArea(bounds); mTopWidget->draw(graphics); graphics->popClipArea(); @@ -404,7 +404,7 @@ gcn::Rectangle GuiTable::getChildrenArea() // -- KeyListener notifications void GuiTable::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) { @@ -453,8 +453,8 @@ void GuiTable::mousePressed(gcn::MouseEvent& mouseEvent) if (mouseEvent.getButton() == gcn::MouseEvent::LEFT) { - int row = getRowForY(mouseEvent.getY()); - int column = getColumnForX(mouseEvent.getX()); + const int row = getRowForY(mouseEvent.getY()); + const int column = getColumnForX(mouseEvent.getX()); if (row > -1 && column > -1 && row < mModel->getRows() && column < mModel->getColumns()) @@ -521,15 +521,15 @@ void GuiTable::modelUpdated(bool completed) gcn::Widget *GuiTable::getWidgetAt(int x, int y) { - int row = getRowForY(y); - int column = getColumnForX(x); + const int row = getRowForY(y); + const int column = getColumnForX(x); if (mTopWidget && mTopWidget->getDimension().isPointInRect(x, y)) return mTopWidget; if (mModel && row > -1 && column > -1) { - gcn::Widget *w = mModel->getElementAt(row, column); + gcn::Widget *const w = mModel->getElementAt(row, column); if (w && w->isFocusable()) return w; else @@ -588,7 +588,7 @@ void GuiTable::_setFocusHandler(gcn::FocusHandler* focusHandler) { for (int c = 0; c < mModel->getColumns(); ++c) { - gcn::Widget *w = mModel->getElementAt(r, c); + gcn::Widget *const w = mModel->getElementAt(r, c); if (w) w->_setFocusHandler(focusHandler); } diff --git a/src/gui/widgets/guitable.h b/src/gui/widgets/guitable.h index d5810fcbf..f00a3cbf3 100644 --- a/src/gui/widgets/guitable.h +++ b/src/gui/widgets/guitable.h @@ -53,8 +53,8 @@ class GuiTable : public gcn::Widget, friend class GuiTableActionListener; public: - GuiTable(TableModel * initial_model = nullptr, - bool opacity = true); + GuiTable(TableModel *const initial_model = nullptr, + const bool opacity = true); virtual ~GuiTable(); @@ -71,7 +71,7 @@ public: * the widget have been triggered. To be notified after such an update, add * an action listener to the table instead. */ - void setModel(TableModel *m); + void setModel(TableModel *const m); void setSelected(int row, int column); diff --git a/src/gui/widgets/horizontcontainer.cpp b/src/gui/widgets/horizontcontainer.cpp index 5bf81c5d8..91632bf55 100644 --- a/src/gui/widgets/horizontcontainer.cpp +++ b/src/gui/widgets/horizontcontainer.cpp @@ -23,10 +23,10 @@ #include "debug.h" -HorizontContainer::HorizontContainer(int height, int spacing): - mSpacing(spacing), - mCount(0), - mLastX(spacing) +HorizontContainer::HorizontContainer(const int height, const int spacing) : + mSpacing(spacing), + mCount(0), + mLastX(spacing) { setHeight(height); addWidgetListener(this); diff --git a/src/gui/widgets/horizontcontainer.h b/src/gui/widgets/horizontcontainer.h index 8e1d082ac..b41370ac1 100644 --- a/src/gui/widgets/horizontcontainer.h +++ b/src/gui/widgets/horizontcontainer.h @@ -34,7 +34,7 @@ class HorizontContainer : public Container, public gcn::WidgetListener { public: - HorizontContainer(int height, int spacing); + HorizontContainer(const int height, const int spacing); virtual void add(gcn::Widget *widget); diff --git a/src/gui/widgets/icon.cpp b/src/gui/widgets/icon.cpp index 9cb42a9f7..e7404ad93 100644 --- a/src/gui/widgets/icon.cpp +++ b/src/gui/widgets/icon.cpp @@ -36,14 +36,14 @@ Icon::Icon(const std::string &file) setSize(mImage->mBounds.w, mImage->mBounds.h); } -Icon::Icon(Image *image) +Icon::Icon(Image *const image) : mImage(image) { if (mImage) setSize(mImage->mBounds.w, mImage->mBounds.h); } -void Icon::setImage(Image *image) +void Icon::setImage(Image *const image) { mImage = image; if (mImage) @@ -54,7 +54,7 @@ void Icon::draw(gcn::Graphics *g) { if (mImage) { - Graphics *graphics = static_cast<Graphics*>(g); + Graphics *const graphics = static_cast<Graphics*>(g); const int x = (getWidth() - mImage->mBounds.w) / 2; const int y = (getHeight() - mImage->mBounds.h) / 2; graphics->drawImage(mImage, x, y); diff --git a/src/gui/widgets/icon.h b/src/gui/widgets/icon.h index 98fee314a..150f34576 100644 --- a/src/gui/widgets/icon.h +++ b/src/gui/widgets/icon.h @@ -43,7 +43,7 @@ class Icon : public gcn::Widget /** * Constructor, uses an existing Image. */ - Icon(Image *image); + Icon(Image *const image); /** * Gets the current Image. @@ -54,7 +54,7 @@ class Icon : public gcn::Widget /** * Sets the image to display. */ - void setImage(Image *image); + void setImage(Image *const image); /** * Draws the Icon. diff --git a/src/gui/widgets/inttextfield.cpp b/src/gui/widgets/inttextfield.cpp index fbc51ee3d..bb7de3a13 100644 --- a/src/gui/widgets/inttextfield.cpp +++ b/src/gui/widgets/inttextfield.cpp @@ -31,8 +31,8 @@ #include "debug.h" -IntTextField::IntTextField(int def, int min, int max, - bool enabled, int width): +IntTextField::IntTextField(const int def, const int min, const int max, + const bool enabled, const int width) : TextField(toString(def)), mDefault(def), mValue(def) @@ -47,7 +47,7 @@ IntTextField::IntTextField(int def, int min, int max, void IntTextField::keyPressed(gcn::KeyEvent &event) { - int action = static_cast<KeyEvent*>(&event)->getActionId(); + const int action = static_cast<KeyEvent*>(&event)->getActionId(); if (action == Input::KEY_GUI_DELETE || action == Input::KEY_GUI_BACKSPACE) { @@ -71,7 +71,7 @@ void IntTextField::keyPressed(gcn::KeyEvent &event) distributeActionEvent(); } -void IntTextField::setRange(int min, int max) +void IntTextField::setRange(const int min, const int max) { mMin = min; mMax = max; @@ -87,12 +87,12 @@ void IntTextField::setRange(int min, int max) mDefault = mMax; } -int IntTextField::getValue() +int IntTextField::getValue() const { return getText().empty() ? mMin : mValue; } -void IntTextField::setValue(int i) +void IntTextField::setValue(const int i) { if (i < mMin) mValue = mMin; @@ -106,7 +106,7 @@ void IntTextField::setValue(int i) setCaretPosition(static_cast<unsigned>(valStr.length()) + 1); } -void IntTextField::setDefaultValue(int value) +void IntTextField::setDefaultValue(const int value) { if (value < mMin) mDefault = mMin; diff --git a/src/gui/widgets/inttextfield.h b/src/gui/widgets/inttextfield.h index 7284c9d03..0f92692f3 100644 --- a/src/gui/widgets/inttextfield.h +++ b/src/gui/widgets/inttextfield.h @@ -34,18 +34,18 @@ class IntTextField : public TextField /** * Constructor, sets default value. */ - IntTextField(int def = 0, int min = 0, int max = 0, - bool enabled = true, int width = 0); + IntTextField(const int def = 0, const int min = 0, const int max = 0, + const bool enabled = true, const int width = 0); /** * Sets the minimum and maximum values of the text box. */ - void setRange(int minimum, int maximum); + void setRange(const int minimum, const int maximum); /** * Returns the value in the text box. */ - int getValue(); + int getValue() const; /** * Reset the field to the default value. @@ -55,12 +55,12 @@ class IntTextField : public TextField /** * Set the value of the text box to the specified value. */ - void setValue(int value); + void setValue(const int value); /** * Set the default value of the text box to the specified value. */ - void setDefaultValue(int value); + void setDefaultValue(const int value); /** * Responds to key presses. diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index ba359118f..d0331fb37 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -58,7 +58,7 @@ static const int BOX_HEIGHT = 43; class ItemIdPair { public: - ItemIdPair(int id, Item* item) : + ItemIdPair(const int id, Item *const item) : mId(id), mItem(item) { } @@ -70,7 +70,8 @@ class ItemIdPair class SortItemAlphaFunctor { public: - bool operator() (ItemIdPair* pair1, ItemIdPair* pair2) + bool operator() (const ItemIdPair *const pair1, + const ItemIdPair *const pair2) const { if (!pair1 || !pair2) return false; @@ -83,7 +84,8 @@ class SortItemAlphaFunctor class SortItemIdFunctor { public: - bool operator() (ItemIdPair* pair1, ItemIdPair* pair2) + bool operator() (const ItemIdPair *const pair1, + const ItemIdPair *const pair2) const { if (!pair1 || !pair2) return false; @@ -95,7 +97,8 @@ class SortItemIdFunctor class SortItemWeightFunctor { public: - bool operator() (ItemIdPair* pair1, ItemIdPair* pair2) + bool operator() (const ItemIdPair *const pair1, + const ItemIdPair *const pair2) const { if (!pair1 || !pair2) return false; @@ -114,7 +117,8 @@ class SortItemWeightFunctor class SortItemAmountFunctor { public: - bool operator() (ItemIdPair* pair1, ItemIdPair* pair2) + bool operator() (const ItemIdPair *const pair1, + const ItemIdPair *const pair2) const { if (!pair1 || !pair2) return false; @@ -133,7 +137,8 @@ class SortItemAmountFunctor class SortItemTypeFunctor { public: - bool operator() (ItemIdPair* pair1, ItemIdPair* pair2) + bool operator() (const ItemIdPair *const pair1, + const ItemIdPair *const pair2) const { if (!pair1 || !pair2) return false; @@ -149,7 +154,8 @@ class SortItemTypeFunctor } } itemTypeSorter; -ItemContainer::ItemContainer(Inventory *inventory, bool forceQuantity): +ItemContainer::ItemContainer(Inventory *const inventory, + const bool forceQuantity) : mInventory(inventory), mGridColumns(1), mGridRows(1), @@ -208,7 +214,7 @@ void ItemContainer::draw(gcn::Graphics *graphics) if (!mInventory || !mShowMatrix) return; - Graphics *g = static_cast<Graphics*>(graphics); + Graphics *const g = static_cast<Graphics *const>(graphics); g->setFont(getFont()); @@ -218,16 +224,17 @@ void ItemContainer::draw(gcn::Graphics *graphics) { int itemX = i * BOX_WIDTH; int itemY = j * BOX_HEIGHT; - int itemIndex = j * mGridColumns + i; + const int itemIndex = j * mGridColumns + i; if (mShowMatrix[itemIndex] < 0) continue; - Item *item = mInventory->getItem(mShowMatrix[itemIndex]); + const Item *const item = mInventory->getItem( + mShowMatrix[itemIndex]); if (!item || item->getId() == 0) continue; - Image *image = item->getImage(); + Image *const image = item->getImage(); if (image) { if (mShowMatrix[itemIndex] == mSelectedIndex) @@ -289,7 +296,7 @@ void ItemContainer::selectNone() // skillDialog->setItemSelected(-1); } -void ItemContainer::setSelectedIndex(int newIndex) +void ItemContainer::setSelectedIndex(const int newIndex) { if (mSelectedIndex != newIndex) { @@ -348,7 +355,7 @@ void ItemContainer::mousePressed(gcn::MouseEvent &event) if (index == Inventory::NO_SLOT_INDEX) return; - Item *item = mInventory->getItem(index); + Item *const item = mInventory->getItem(index); // put item name into chat window if (item && mDescItems && chatWindow) @@ -363,7 +370,7 @@ void ItemContainer::mousePressed(gcn::MouseEvent &event) setSelectedIndex(index); mSelectionStatus = SEL_SELECTING; - int num = itemShortcutWindow->getTabIndex(); + const int num = itemShortcutWindow->getTabIndex(); if (num >= 0 && num < static_cast<int>(SHORTCUT_TABS)) { if (itemShortcut[num]) @@ -415,7 +422,7 @@ void ItemContainer::mouseReleased(gcn::MouseEvent &event) return; }; - int index = getSlotIndex(event.getX(), event.getY()); + const int index = getSlotIndex(event.getX(), event.getY()); if (index == Inventory::NO_SLOT_INDEX) return; if (index == mSelectedIndex || mSelectedIndex == -1) @@ -431,7 +438,8 @@ void ItemContainer::mouseMoved(gcn::MouseEvent &event) if (!mInventory) return; - Item *item = mInventory->getItem(getSlotIndex(event.getX(), event.getY())); + const Item *const item = mInventory->getItem( + getSlotIndex(event.getX(), event.getY())); if (item && viewport) { @@ -487,7 +495,7 @@ void ItemContainer::updateMatrix() for (unsigned idx = 0; idx < mInventory->getSize(); idx ++) { - Item *item = mInventory->getItem(idx); + Item *const item = mInventory->getItem(idx); if (!item || item->getId() == 0 || !item->isHaveTag(mTag)) continue; @@ -551,14 +559,14 @@ void ItemContainer::updateMatrix() delete sortedItems[idx]; } -int ItemContainer::getSlotIndex(int x, int y) const +int ItemContainer::getSlotIndex(const int x, const int y) const { if (!mShowMatrix) return Inventory::NO_SLOT_INDEX; if (x < getWidth() && y < getHeight()) { - int idx = (y / BOX_HEIGHT) * mGridColumns + (x / BOX_WIDTH); + const int idx = (y / BOX_HEIGHT) * mGridColumns + (x / BOX_WIDTH); if (idx < mGridRows * mGridColumns && mShowMatrix[idx] >= 0) return mShowMatrix[idx]; } @@ -599,7 +607,7 @@ void ItemContainer::keyAction() } } -void ItemContainer::moveHighlight(Direction direction) +void ItemContainer::moveHighlight(const Direction direction) { if (mHighlightedIndex == -1) { @@ -645,13 +653,13 @@ void ItemContainer::moveHighlight(Direction direction) } } -void ItemContainer::setFilter (int tag) +void ItemContainer::setFilter(const int tag) { mTag = tag; updateMatrix(); } -void ItemContainer::setSortType (int sortType) +void ItemContainer::setSortType(const int sortType) { mSortType = sortType; updateMatrix(); diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h index 0ad95fd1b..f39af8d7e 100644 --- a/src/gui/widgets/itemcontainer.h +++ b/src/gui/widgets/itemcontainer.h @@ -60,7 +60,8 @@ class ItemContainer : public gcn::Widget, * @param gridRows Amount of rows in grid. * @param offset Index offset */ - ItemContainer(Inventory *inventory, bool forceQuantity = false); + ItemContainer(Inventory *const inventory, + const bool forceQuantity = false); /** * Destructor. @@ -117,9 +118,9 @@ class ItemContainer : public gcn::Widget, void removeSelectionListener(gcn::SelectionListener *listener) { mSelectionListeners.remove(listener); } - void setFilter (int tag); + void setFilter(const int tag); - void setSortType (int sortType); + void setSortType(const int sortType); void setName(std::string str) { mName = str; } @@ -157,12 +158,12 @@ class ItemContainer : public gcn::Widget, * * @param direction The move direction of the highlighter. */ - void moveHighlight(Direction direction); + void moveHighlight(const Direction direction); /** * Sets the currently selected item. */ - void setSelectedIndex(int index); + void setSelectedIndex(const int index); /** * Determine and set the height of the container. @@ -181,7 +182,7 @@ class ItemContainer : public gcn::Widget, * @param y The Y coordinate position. * @return The slot index on success, -1 on failure. */ - int getSlotIndex(int x, int y) const; + int getSlotIndex(const int x, const int y) const; Inventory *mInventory; |