From e2a8586decf73849300cd3427a30f966360220c7 Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Fri, 4 Oct 2024 10:57:16 +0200 Subject: Small cleanup in OutfitWindow::load Based on MV commit db452921bafb2dd322b52c1e5d03e5e713849dd0. --- src/gui/outfitwindow.cpp | 18 +++++------------- src/gui/outfitwindow.h | 8 ++------ 2 files changed, 7 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp index 5dc05790..77de4b3a 100644 --- a/src/gui/outfitwindow.cpp +++ b/src/gui/outfitwindow.cpp @@ -38,8 +38,6 @@ #include "utils/gettext.h" #include "utils/stringutils.h" -#include - OutfitWindow::OutfitWindow(): Window(_("Outfits")) { @@ -86,15 +84,11 @@ void OutfitWindow::load() std::string buf; std::stringstream ss(outfit); - std::vector tokens; - - while (ss >> buf) - tokens.push_back(atoi(buf.c_str())); - - for (int i = 0; i < (int)tokens.size(); i++) + for (size_t i = 0; (ss >> buf) && i < OUTFIT_ITEM_COUNT; i++) { - mItems[o][i] = tokens[i]; + mItems[o][i] = atoi(buf.c_str()); } + mItemsUnequip[o] = config.getValue("OutfitUnequip" + toString(o), true); } } @@ -199,8 +193,7 @@ void OutfitWindow::draw(gcn::Graphics *graphics) if (item) { // Draw item icon. - Image* image = item->getImage(); - if (image) + if (Image *image = item->getImage()) { g->drawImage(image, itemX, itemY); } @@ -209,8 +202,7 @@ void OutfitWindow::draw(gcn::Graphics *graphics) if (mItemMoved) { // Draw the item image being dragged by the cursor. - Image* image = mItemMoved->getImage(); - if (image) + if (Image *image = mItemMoved->getImage()) { const int tPosX = mCursorPosX - (image->getWidth() / 2); const int tPosY = mCursorPosY - (image->getHeight() / 2); diff --git a/src/gui/outfitwindow.h b/src/gui/outfitwindow.h index a7f50b47..aa07e020 100644 --- a/src/gui/outfitwindow.h +++ b/src/gui/outfitwindow.h @@ -38,17 +38,13 @@ class OutfitWindow : public Window, gcn::ActionListener { public: OutfitWindow(); - ~OutfitWindow() override; void action(const gcn::ActionEvent &event) override; void draw(gcn::Graphics *graphics) override; - - void mousePressed(gcn::MouseEvent &event) override; - void mouseDragged(gcn::MouseEvent &event) override; - + void mousePressed(gcn::MouseEvent &event) override; void mouseReleased(gcn::MouseEvent &event) override; void load(); @@ -56,7 +52,7 @@ class OutfitWindow : public Window, gcn::ActionListener void setItemSelected(int itemId) { mItemSelected = itemId; } - bool isItemSelected() + bool isItemSelected() const { return mItemSelected > -1; } void wearOutfit(int outfit); -- cgit v1.2.3-70-g09d2