summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-10-04 10:57:16 +0200
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-10-08 21:15:04 +0200
commite2a8586decf73849300cd3427a30f966360220c7 (patch)
tree6e9e98797b7d8d57a8fec52309d2bc61bae5f6bb
parente4a44416226eba6f5e594e68a028672c8b8e600b (diff)
downloadmana-e2a8586decf73849300cd3427a30f966360220c7.tar.gz
mana-e2a8586decf73849300cd3427a30f966360220c7.tar.bz2
mana-e2a8586decf73849300cd3427a30f966360220c7.tar.xz
mana-e2a8586decf73849300cd3427a30f966360220c7.zip
Small cleanup in OutfitWindow::load
Based on MV commit db452921bafb2dd322b52c1e5d03e5e713849dd0.
-rw-r--r--src/gui/outfitwindow.cpp18
-rw-r--r--src/gui/outfitwindow.h8
2 files changed, 7 insertions, 19 deletions
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 <vector>
-
OutfitWindow::OutfitWindow():
Window(_("Outfits"))
{
@@ -86,15 +84,11 @@ void OutfitWindow::load()
std::string buf;
std::stringstream ss(outfit);
- std::vector<int> 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);