summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-01-26 16:21:43 +0100
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-01-29 14:18:06 +0100
commite7c285e3423ddd660447f6a6fc6bbae25f99f386 (patch)
tree1d700f09a5e96a2a0d390af30581097bdec0bf77 /src/gui
parente1a7c1d0ca30c2c4a293ffbff6b9c51c881d23e3 (diff)
downloadmana-e7c285e3423ddd660447f6a6fc6bbae25f99f386.tar.gz
mana-e7c285e3423ddd660447f6a6fc6bbae25f99f386.tar.bz2
mana-e7c285e3423ddd660447f6a6fc6bbae25f99f386.tar.xz
mana-e7c285e3423ddd660447f6a6fc6bbae25f99f386.zip
Apply C++11 fixits
modernize-loop-convert modernize-deprecated-headers
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/charselectdialog.cpp4
-rw-r--r--src/gui/chatwindow.cpp13
-rw-r--r--src/gui/helpwindow.cpp4
-rw-r--r--src/gui/itempopup.cpp5
-rw-r--r--src/gui/minimap.cpp9
-rw-r--r--src/gui/ministatuswindow.cpp14
-rw-r--r--src/gui/palette.cpp55
-rw-r--r--src/gui/quitdialog.cpp2
-rw-r--r--src/gui/serverdialog.cpp11
-rw-r--r--src/gui/setup.cpp9
-rw-r--r--src/gui/setup_players.cpp3
-rw-r--r--src/gui/skilldialog.cpp10
-rw-r--r--src/gui/specialswindow.cpp25
-rw-r--r--src/gui/specialswindow.h2
-rw-r--r--src/gui/statuswindow.cpp4
-rw-r--r--src/gui/viewport.cpp32
-rw-r--r--src/gui/widgets/browserbox.cpp11
-rw-r--r--src/gui/widgets/button.cpp3
-rw-r--r--src/gui/widgets/dropdown.cpp8
-rw-r--r--src/gui/widgets/flowcontainer.cpp4
-rw-r--r--src/gui/widgets/layout.cpp24
-rw-r--r--src/gui/widgets/playerbox.cpp8
-rw-r--r--src/gui/widgets/progressbar.cpp11
-rw-r--r--src/gui/widgets/scrollarea.cpp17
-rw-r--r--src/gui/widgets/tab.cpp14
-rw-r--r--src/gui/widgets/tabbedarea.cpp11
-rw-r--r--src/gui/widgets/tablemodel.cpp12
-rw-r--r--src/gui/widgets/textfield.cpp5
-rw-r--r--src/gui/widgets/vertcontainer.cpp4
-rw-r--r--src/gui/widgets/windowcontainer.cpp4
-rw-r--r--src/gui/windowmenu.cpp4
31 files changed, 145 insertions, 197 deletions
diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp
index e4d5f371..46f28fe8 100644
--- a/src/gui/charselectdialog.cpp
+++ b/src/gui/charselectdialog.cpp
@@ -318,8 +318,8 @@ void CharSelectDialog::setLocked(bool locked)
if (mChangeEmailButton)
mChangeEmailButton->setEnabled(!locked);
- for (int i = 0; i < (int)mCharacterEntries.size(); ++i)
- mCharacterEntries[i]->setActive(!mLocked);
+ for (auto &characterEntry : mCharacterEntries)
+ characterEntry->setActive(!mLocked);
}
bool CharSelectDialog::selectByName(const std::string &name,
diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp
index 1ae2fcbd..e1bbed5f 100644
--- a/src/gui/chatwindow.cpp
+++ b/src/gui/chatwindow.cpp
@@ -278,10 +278,9 @@ void ChatWindow::removeAllWhispers()
tabs.push_back(iter->second);
}
- for (auto it = tabs.begin();
- it != tabs.end(); ++it)
+ for (auto &tab : tabs)
{
- delete *it;
+ delete tab;
}
mWhispers.clear();
@@ -295,20 +294,18 @@ void ChatWindow::chatInput(const std::string &msg)
void ChatWindow::doPresent()
{
- const ActorSprites &actors = actorSpriteManager->getAll();
std::string response = "";
int playercount = 0;
- for (auto it = actors.begin(), it_end = actors.end();
- it != it_end; it++)
+ for (auto actor : actorSpriteManager->getAll())
{
- if ((*it)->getType() == ActorSprite::PLAYER)
+ if (actor->getType() == ActorSprite::PLAYER)
{
if (!response.empty())
{
response += ", ";
}
- response += static_cast<Being*>(*it)->getName();
+ response += static_cast<Being*>(actor)->getName();
++playercount;
}
}
diff --git a/src/gui/helpwindow.cpp b/src/gui/helpwindow.cpp
index 077f3091..35e65bd6 100644
--- a/src/gui/helpwindow.cpp
+++ b/src/gui/helpwindow.cpp
@@ -102,8 +102,8 @@ void HelpWindow::loadFile(const std::string &file)
std::vector<std::string> lines =
resman->loadTextFile(helpPath + file + ".txt");
- for (unsigned int i = 0; i < lines.size(); ++i)
+ for (const auto &line : lines)
{
- mBrowserBox->addRow(lines[i]);
+ mBrowserBox->addRow(line);
}
}
diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp
index f096e5ca..3b3dfcd3 100644
--- a/src/gui/itempopup.cpp
+++ b/src/gui/itempopup.cpp
@@ -198,9 +198,8 @@ void ItemPopup::setItem(const ItemInfo &item, bool showImage)
{
const std::vector<std::string> &effect = item.getEffect();
std::string temp = "";
- for (auto it = effect.begin(),
- it_end = effect.end(); it != it_end; ++it)
- temp += temp.empty() ? *it : "\n" + *it;
+ for (const auto &it : effect)
+ temp += temp.empty() ? it : "\n" + it;
mItemEffect->setTextWrapped(temp, ITEMPOPUP_WRAP_WIDTH);
}
mItemWeight->setTextWrapped(strprintf(_("Weight: %s"),
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp
index 1682b972..388a032a 100644
--- a/src/gui/minimap.cpp
+++ b/src/gui/minimap.cpp
@@ -190,15 +190,12 @@ void Minimap::draw(gcn::Graphics *graphics)
drawImage(mMapImage, mapOriginX, mapOriginY);
}
- const ActorSprites &actors = actorSpriteManager->getAll();
-
- for (auto it = actors.begin(), it_end = actors.end();
- it != it_end; it++)
+ for (auto actor : actorSpriteManager->getAll())
{
- if ((*it)->getType() == ActorSprite::FLOOR_ITEM)
+ if (actor->getType() == ActorSprite::FLOOR_ITEM)
continue;
- const Being *being = static_cast<Being*>(*it);
+ const Being *being = static_cast<Being*>(actor);
if (!being->isAlive())
continue;
diff --git a/src/gui/ministatuswindow.cpp b/src/gui/ministatuswindow.cpp
index 3cd97a6d..29718ed6 100644
--- a/src/gui/ministatuswindow.cpp
+++ b/src/gui/ministatuswindow.cpp
@@ -110,12 +110,12 @@ void MiniStatusWindow::drawIcons(Graphics *graphics)
{
// Draw icons
int icon_x = mXpBar->getX() + mXpBar->getWidth() + 14;
- for (unsigned int i = 0; i < mIcons.size(); i++)
+ for (auto &icon : mIcons)
{
- if (mIcons[i])
+ if (icon)
{
- mIcons[i]->draw(graphics, icon_x, 3);
- icon_x += 2 + mIcons[i]->getWidth();
+ icon->draw(graphics, icon_x, 3);
+ icon_x += 2 + icon->getWidth();
}
}
}
@@ -223,9 +223,9 @@ void MiniStatusWindow::logic()
}
*/
- for (unsigned int i = 0; i < mIcons.size(); i++)
- if (mIcons[i])
- mIcons[i]->update(tick_time * 10);
+ for (auto &icon : mIcons)
+ if (icon)
+ icon->update(tick_time * 10);
}
void MiniStatusWindow::mouseMoved(gcn::MouseEvent &event)
diff --git a/src/gui/palette.cpp b/src/gui/palette.cpp
index 23ba75ee..aee78b29 100644
--- a/src/gui/palette.cpp
+++ b/src/gui/palette.cpp
@@ -30,7 +30,7 @@
#include "utils/gettext.h"
#include "utils/stringutils.h"
-#include <math.h>
+#include <cmath>
static const double PI = 3.14159265;
const gcn::Color Palette::BLACK = gcn::Color(0, 0, 0);
@@ -60,15 +60,14 @@ Palette::~Palette()
mInstances.erase(this);
}
-const gcn::Color& Palette::getColor(char c, bool &valid)
+const gcn::Color &Palette::getColor(char c, bool &valid)
{
- for (Colors::const_iterator col = mColors.begin(),
- colEnd = mColors.end(); col != colEnd; ++col)
+ for (const auto &color : mColors)
{
- if (col->ch == c)
+ if (color.ch == c)
{
valid = true;
- return col->color;
+ return color.color;
}
}
valid = false;
@@ -97,35 +96,35 @@ void Palette::advanceGradient()
int advance = get_elapsed_time(mRainbowTime) / 5;
double startColVal, destColVal;
- for (size_t i = 0; i < mGradVector.size(); i++)
+ for (auto &elem : mGradVector)
{
- delay = mGradVector[i]->delay;
+ delay = elem->delay;
- if (mGradVector[i]->grad == PULSE)
+ if (elem->grad == PULSE)
delay = delay / 20;
- numOfColors = (mGradVector[i]->grad == SPECTRUM ? 6 :
- mGradVector[i]->grad == PULSE ? 127 :
+ numOfColors = (elem->grad == SPECTRUM ? 6 :
+ elem->grad == PULSE ? 127 :
RAINBOW_COLOR_COUNT);
- mGradVector[i]->gradientIndex =
- (mGradVector[i]->gradientIndex + advance) %
+ elem->gradientIndex =
+ (elem->gradientIndex + advance) %
(delay * numOfColors);
- pos = mGradVector[i]->gradientIndex % delay;
- colIndex = mGradVector[i]->gradientIndex / delay;
+ pos = elem->gradientIndex % delay;
+ colIndex = elem->gradientIndex / delay;
- if (mGradVector[i]->grad == PULSE)
+ if (elem->grad == PULSE)
{
colVal = (int) (255.0 * sin(PI * colIndex / numOfColors));
- const gcn::Color &col = mGradVector[i]->testColor;
+ const gcn::Color &col = elem->testColor;
- mGradVector[i]->color.r = ((colVal * col.r) / 255) % (col.r + 1);
- mGradVector[i]->color.g = ((colVal * col.g) / 255) % (col.g + 1);
- mGradVector[i]->color.b = ((colVal * col.b) / 255) % (col.b + 1);
+ elem->color.r = ((colVal * col.r) / 255) % (col.r + 1);
+ elem->color.g = ((colVal * col.g) / 255) % (col.g + 1);
+ elem->color.b = ((colVal * col.b) / 255) % (col.b + 1);
}
- if (mGradVector[i]->grad == SPECTRUM)
+ if (elem->grad == SPECTRUM)
{
if (colIndex % 2)
{ // falling curve
@@ -137,17 +136,17 @@ void Palette::advanceGradient()
1) / 2);
}
- mGradVector[i]->color.r =
+ elem->color.r =
(colIndex == 0 || colIndex == 5) ? 255 :
(colIndex == 1 || colIndex == 4) ? colVal : 0;
- mGradVector[i]->color.g =
+ elem->color.g =
(colIndex == 1 || colIndex == 2) ? 255 :
(colIndex == 0 || colIndex == 3) ? colVal : 0;
- mGradVector[i]->color.b =
+ elem->color.b =
(colIndex == 3 || colIndex == 4) ? 255 :
(colIndex == 2 || colIndex == 5) ? colVal : 0;
}
- else if (mGradVector[i]->grad == RAINBOW)
+ else if (elem->grad == RAINBOW)
{
const gcn::Color &startCol = RAINBOW_COLORS[colIndex];
const gcn::Color &destCol =
@@ -156,13 +155,13 @@ void Palette::advanceGradient()
startColVal = (cos(PI * pos / delay) + 1) / 2;
destColVal = 1 - startColVal;
- mGradVector[i]->color.r =(int)(startColVal * startCol.r +
+ elem->color.r =(int)(startColVal * startCol.r +
destColVal * destCol.r);
- mGradVector[i]->color.g =(int)(startColVal * startCol.g +
+ elem->color.g =(int)(startColVal * startCol.g +
destColVal * destCol.g);
- mGradVector[i]->color.b =(int)(startColVal * startCol.b +
+ elem->color.b =(int)(startColVal * startCol.b +
destColVal * destCol.b);
}
}
diff --git a/src/gui/quitdialog.cpp b/src/gui/quitdialog.cpp
index 4262f9cc..4afbd419 100644
--- a/src/gui/quitdialog.cpp
+++ b/src/gui/quitdialog.cpp
@@ -34,7 +34,7 @@
#include "utils/gettext.h"
-#include <assert.h>
+#include <cassert>
QuitDialog::QuitDialog(QuitDialog** pointerToMe):
Window(_("Quit"), true, nullptr), mMyPointer(pointerToMe)
diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp
index f0016322..6a7f6ab5 100644
--- a/src/gui/serverdialog.cpp
+++ b/src/gui/serverdialog.cpp
@@ -523,15 +523,14 @@ void ServerDialog::loadServers()
// Add the server to the local list if it's not already present
bool found = false;
int i = 0;
- for (auto it = mServers.begin(); it != mServers.end();
- ++it)
+ for (auto &s : mServers)
{
- if (*it == server)
+ if (s == server)
{
// Use the name listed in the server list
- (*it).name = server.name;
- (*it).version = server.version;
- (*it).description = server.description;
+ s.name = server.name;
+ s.version = server.version;
+ s.description = server.description;
mServersListModel->setVersionString(i, version);
found = true;
break;
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp
index daced0fa..357f1921 100644
--- a/src/gui/setup.cpp
+++ b/src/gui/setup.cpp
@@ -77,10 +77,8 @@ Setup::Setup():
mTabs.push_back(new Setup_Colors);
mTabs.push_back(new Setup_Players);
- for (auto i = mTabs.begin(), i_end = mTabs.end();
- i != i_end; ++i)
+ for (auto tab : mTabs)
{
- SetupTab *tab = *i;
panel->addTab(tab->getName(), tab);
}
@@ -119,10 +117,9 @@ void Setup::action(const gcn::ActionEvent &event)
if (!statusWindow)
return;
- for (auto it = mWindowsToReset.begin();
- it != mWindowsToReset.end(); it++)
+ for (auto &window : mWindowsToReset)
{
- (*it)->resetToDefaultSize();
+ window->resetToDefaultSize();
}
}
}
diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp
index a3b0ef53..6a77e229 100644
--- a/src/gui/setup_players.cpp
+++ b/src/gui/setup_players.cpp
@@ -135,9 +135,8 @@ public:
mPlayers = player_relations.getPlayers();
// set up widgets
- for (unsigned int r = 0; r < mPlayers->size(); ++r)
+ for (const auto &name : *mPlayers)
{
- std::string name = (*mPlayers)[r];
gcn::Widget *widget = new Label(name);
mWidgets.push_back(widget);
diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp
index 09bde167..7f42b016 100644
--- a/src/gui/skilldialog.cpp
+++ b/src/gui/skilldialog.cpp
@@ -275,9 +275,9 @@ void SkillDialog::update()
PlayerInfo::getAttribute(SKILL_POINTS)));
mPointsLabel->adjustSize();
- for (auto it = mSkills.begin(); it != mSkills.end(); it++)
+ for (auto &skill : mSkills)
{
- (*it).second->update();
+ skill.second->update();
}
}
@@ -431,11 +431,11 @@ void SkillModel::updateVisibilities()
{
mVisibleSkills.clear();
- for (auto it = mSkills.begin(); it != mSkills.end(); it++)
+ for (auto &skill : mSkills)
{
- if ((*it)->visible)
+ if (skill->visible)
{
- mVisibleSkills.push_back((*it));
+ mVisibleSkills.push_back(skill);
}
}
}
diff --git a/src/gui/specialswindow.cpp b/src/gui/specialswindow.cpp
index d114d6e3..194e6afe 100644
--- a/src/gui/specialswindow.cpp
+++ b/src/gui/specialswindow.cpp
@@ -49,9 +49,6 @@
#define SPECIALS_WIDTH 200
#define SPECIALS_HEIGHT 32
-class SpecialEntry;
-
-
class SpecialEntry : public Container
{
public:
@@ -127,10 +124,9 @@ void SpecialsWindow::draw(gcn::Graphics *graphics)
bool foundNew = false;
unsigned int found = 0; // number of entries in specialData which match mEntries
- for (auto it = specialData.begin();
- it != specialData.end(); ++it)
+ for (auto &special : specialData)
{
- auto e = mEntries.find(it->first);
+ auto e = mEntries.find(special.first);
if (e == mEntries.end())
{
// found a new special - abort update and rebuild from scratch
@@ -140,7 +136,7 @@ void SpecialsWindow::draw(gcn::Graphics *graphics)
else
{
// update progress bar of special
- e->second->update(it->second.currentMana, it->second.neededMana);
+ e->second->update(special.second.currentMana, special.second.neededMana);
found++;
}
}
@@ -158,25 +154,24 @@ void SpecialsWindow::rebuild(const std::map<int, Special> &specialData)
mEntries.clear();
int vPos = 0; //vertical position of next placed element
- for (auto it = specialData.begin();
- it != specialData.end(); ++it)
+ for (auto special : specialData)
{
- logger->log("Updating special GUI for %d", it->first);
+ logger->log("Updating special GUI for %d", special.first);
- SpecialInfo *info = SpecialDB::get(it->first);
+ SpecialInfo *info = SpecialDB::get(special.first);
if (info)
{
- info->rechargeCurrent = it->second.currentMana;
- info->rechargeNeeded = it->second.neededMana;
+ info->rechargeCurrent = special.second.currentMana;
+ info->rechargeNeeded = special.second.neededMana;
auto* entry = new SpecialEntry(info);
entry->setPosition(0, vPos);
vPos += entry->getHeight() + 3;
add(entry);
- mEntries[it->first] = entry;
+ mEntries[special.first] = entry;
}
else
{
- logger->log("Warning: No info available of special %d", it->first);
+ logger->log("Warning: No info available of special %d", special.first);
}
}
}
diff --git a/src/gui/specialswindow.h b/src/gui/specialswindow.h
index 1da05c5c..c945fd4b 100644
--- a/src/gui/specialswindow.h
+++ b/src/gui/specialswindow.h
@@ -31,7 +31,7 @@
#include <map>
-struct SpecialEntry;
+class SpecialEntry;
class SpecialsWindow : public Window, public gcn::ActionListener
{
diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp
index eee832ec..c2486b89 100644
--- a/src/gui/statuswindow.cpp
+++ b/src/gui/statuswindow.cpp
@@ -301,9 +301,9 @@ void StatusWindow::event(Event::Channel channel,
void StatusWindow::updateAttrs()
{
- for (auto it = mAttrs.begin(); it != mAttrs.end(); it++)
+ for (auto &attr : mAttrs)
{
- it->second->update();
+ attr.second->update();
}
}
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 3fb11d2c..456196ce 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -238,25 +238,21 @@ void Viewport::draw(gcn::Graphics *gcnGraphics)
}
// Draw player names, speech, and emotion sprite as needed
- const ActorSprites &actors = actorSpriteManager->getAll();
- for (auto it = actors.begin(), it_end = actors.end();
- it != it_end; it++)
+ for (auto actor : actorSpriteManager->getAll())
{
- if ((*it)->getType() == ActorSprite::FLOOR_ITEM)
+ if (actor->getType() == ActorSprite::FLOOR_ITEM)
continue;
- auto *b = static_cast<Being*>(*it);
- b->drawSpeech((int) mPixelViewX, (int) mPixelViewY);
+ auto *being = static_cast<Being*>(actor);
+ being->drawSpeech((int) mPixelViewX, (int) mPixelViewY);
}
if (mDebugFlags & Map::DEBUG_BEING_IDS)
{
graphics->setColor(gcn::Color(255, 0, 255, 255));
- ActorSpritesConstIterator it, it_end;
- const ActorSprites &actors = actorSpriteManager->getAll();
- for (it = actors.begin(), it_end = actors.end(); it != it_end; ++it)
+ for (auto actor : actorSpriteManager->getAll())
{
- auto *being = dynamic_cast<Being*>(*it);
+ auto *being = dynamic_cast<Being*>(actor);
if (!being)
continue;
@@ -382,11 +378,9 @@ void Viewport::_drawDebugPath(Graphics *graphics)
}
// Draw the path debug information for every beings.
- ActorSpritesConstIterator it, it_end;
- const ActorSprites &actors = actorSpriteManager->getAll();
- for (it = actors.begin(), it_end = actors.end(); it != it_end; it++)
+ for (auto actor : actorSpriteManager->getAll())
{
- auto *being = dynamic_cast<Being*>(*it);
+ auto *being = dynamic_cast<Being*>(actor);
if (!being)
continue;
@@ -428,16 +422,16 @@ void Viewport::_drawPath(Graphics *graphics, const Path &path,
{
graphics->setColor(color);
- for (auto i = path.begin(); i != path.end(); ++i)
+ for (auto pos : path)
{
- int squareX = i->x - (int) mPixelViewX;
- int squareY = i->y - (int) mPixelViewY;
+ int squareX = pos.x - (int) mPixelViewX;
+ int squareY = pos.y - (int) mPixelViewY;
graphics->fillRectangle(gcn::Rectangle(squareX - 4, squareY - 4,
8, 8));
graphics->drawText(
- toString(mMap->getMetaTile(i->x / mMap->getTileWidth(),
- i->y / mMap->getTileHeight())->Gcost),
+ toString(mMap->getMetaTile(pos.x / mMap->getTileWidth(),
+ pos.y / mMap->getTileHeight())->Gcost),
squareX + 4, squareY + 12, gcn::Graphics::CENTER);
}
}
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index d5b853b2..2fe3b5b1 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -185,9 +185,8 @@ void BrowserBox::addRow(const std::string &row)
int tildeWidth = font->getWidth(tilde);
int x = 0;
- for (auto i = mTextRows.begin(); i != mTextRows.end(); i++)
+ for (auto row : mTextRows)
{
- std::string row = *i;
for (unsigned int j = 0; j < row.size(); ++j)
{
std::string character = row.substr(j, 1);
@@ -316,11 +315,8 @@ void BrowserBox::draw(gcn::Graphics *graphics)
}
}
- for (auto i = mLineParts.begin();
- i != mLineParts.end();
- i ++)
+ for (auto &part : mLineParts)
{
- const LinePart &part = *i;
if (part.getY() + 50 < mYStart)
continue;
if (part.getY() > yEnd)
@@ -385,9 +381,8 @@ int BrowserBox::calcHeight()
mLineParts.clear();
- for (auto i = mTextRows.begin(); i != mTextRows.end(); i++)
+ for (auto row : mTextRows)
{
- const std::string row = *(i);
bool wrapped = false;
x = 0;
diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp
index fb0d4cbe..b2a395e9 100644
--- a/src/gui/widgets/button.cpp
+++ b/src/gui/widgets/button.cpp
@@ -205,8 +205,7 @@ void Button::updateAlpha()
mAlpha = alpha;
for (int mode = 0; mode < BUTTON_COUNT; ++mode)
{
- for (int a = 0; a < 9; ++a)
- mButton[mode].grid[a]->setAlpha(mAlpha);
+ mButton[mode].setAlpha(mAlpha);
}
}
}
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index 101afaef..81a0ea46 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -80,11 +80,12 @@ DropDown::DropDown(gcn::ListModel *listModel):
gridx[x] + 1,
gridy[y + 1] -
gridy[y] + 1);
- skin.grid[a]->setAlpha(mAlpha);
a++;
}
}
+ skin.setAlpha(mAlpha);
+
boxBorder->decRef();
}
@@ -122,10 +123,7 @@ void DropDown::updateAlpha()
buttons[1][0]->setAlpha(mAlpha);
buttons[1][1]->setAlpha(mAlpha);
- for (int a = 0; a < 9; a++)
- {
- skin.grid[a]->setAlpha(mAlpha);
- }
+ skin.setAlpha(mAlpha);
}
}
diff --git a/src/gui/widgets/flowcontainer.cpp b/src/gui/widgets/flowcontainer.cpp
index bf34c4c7..0110c534 100644
--- a/src/gui/widgets/flowcontainer.cpp
+++ b/src/gui/widgets/flowcontainer.cpp
@@ -57,10 +57,10 @@ void FlowContainer::widgetResized(const gcn::Event &event)
int i = 0;
height = 0;
- for (auto it = mWidgets.begin(); it != mWidgets.end(); it++)
+ for (auto &widget : mWidgets)
{
int x = i % mGridWidth * mBoxWidth;
- (*it)->setPosition(x, height);
+ widget->setPosition(x, height);
i++;
diff --git a/src/gui/widgets/layout.cpp b/src/gui/widgets/layout.cpp
index ac8488e0..3659baa1 100644
--- a/src/gui/widgets/layout.cpp
+++ b/src/gui/widgets/layout.cpp
@@ -71,15 +71,12 @@ void LayoutCell::computeSizes()
{
assert(mType == ARRAY);
- for (auto
- i = mArray->mCells.begin(), i_end = mArray->mCells.end();
- i != i_end; ++i)
+ for (auto &row : mArray->mCells)
{
- for (auto
- j = i->begin(), j_end = i->end(); j != j_end; ++j)
+ for (auto cell : row)
{
- LayoutCell *cell = *j;
- if (cell && cell->mType == ARRAY) cell->computeSizes();
+ if (cell && cell->mType == ARRAY)
+ cell->computeSizes();
}
}
@@ -93,13 +90,11 @@ LayoutArray::LayoutArray(): mSpacing(4)
LayoutArray::~LayoutArray()
{
- for (auto
- i = mCells.begin(), i_end = mCells.end(); i != i_end; ++i)
+ for (auto &row : mCells)
{
- for (auto
- j = i->begin(), j_end = i->end(); j != j_end; ++j)
+ for (auto &cell : row)
{
- delete *j;
+ delete cell;
}
}
}
@@ -133,10 +128,9 @@ void LayoutArray::resizeGrid(int w, int h)
mSizes[0].resize(w, Layout::AUTO_DEF);
}
- for (auto
- i = mCells.begin(), i_end = mCells.end(); i != i_end; ++i)
+ for (auto &row : mCells)
{
- i->resize(w, nullptr);
+ row.resize(w, nullptr);
}
}
diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp
index 1d3325ee..0d63ddf2 100644
--- a/src/gui/widgets/playerbox.cpp
+++ b/src/gui/widgets/playerbox.cpp
@@ -56,11 +56,12 @@ PlayerBox::PlayerBox(const Being *being):
bggridx[x], bggridy[y],
bggridx[x + 1] - bggridx[x] + 1,
bggridy[y + 1] - bggridy[y] + 1);
- background.grid[a]->setAlpha(config.getFloatValue("guialpha"));
a++;
}
}
+ background.setAlpha(config.getFloatValue("guialpha"));
+
textbox->decRef();
}
@@ -92,10 +93,7 @@ void PlayerBox::draw(gcn::Graphics *graphics)
if (config.getFloatValue("guialpha") != mAlpha)
{
- for (int a = 0; a < 9; a++)
- {
- background.grid[a]->setAlpha(config.getFloatValue("guialpha"));
- }
+ background.setAlpha(config.getFloatValue("guialpha"));
}
}
diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp
index 4695f5ab..9397d59e 100644
--- a/src/gui/widgets/progressbar.cpp
+++ b/src/gui/widgets/progressbar.cpp
@@ -71,10 +71,7 @@ ProgressBar::ProgressBar(float progress,
mBorder.grid[7] = dBorders->getSubImage(4, 15, 3, 4);
mBorder.grid[8] = dBorders->getSubImage(7, 15, 4, 4);
- for (int i = 0; i < 9; i++)
- {
- mBorder.grid[i]->setAlpha(mAlpha);
- }
+ mBorder.setAlpha(mAlpha);
dBorders->decRef();
}
@@ -129,12 +126,8 @@ void ProgressBar::updateAlpha()
if (mAlpha != alpha)
{
mAlpha = alpha;
- for (int i = 0; i < 9; i++)
- {
- mBorder.grid[i]->setAlpha(mAlpha);
- }
+ mBorder.setAlpha(mAlpha);
}
-
}
void ProgressBar::draw(gcn::Graphics *graphics)
diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp
index c95adeaa..f4d8007a 100644
--- a/src/gui/widgets/scrollarea.cpp
+++ b/src/gui/widgets/scrollarea.cpp
@@ -107,10 +107,10 @@ void ScrollArea::init()
bggridx[x], bggridy[y],
bggridx[x + 1] - bggridx[x] + 1,
bggridy[y + 1] - bggridy[y] + 1);
- background.grid[a]->setAlpha(config.getFloatValue("guialpha"));
a++;
}
}
+ background.setAlpha(config.getFloatValue("guialpha"));
textbox->decRef();
@@ -134,12 +134,13 @@ void ScrollArea::init()
vsgridx[x], vsgridy[y],
vsgridx[x + 1] - vsgridx[x],
vsgridy[y + 1] - vsgridy[y]);
- vMarker.grid[a]->setAlpha(config.getFloatValue("guialpha"));
- vMarkerHi.grid[a]->setAlpha(config.getFloatValue("guialpha"));
a++;
}
}
+ vMarker.setAlpha(config.getFloatValue("guialpha"));
+ vMarkerHi.setAlpha(config.getFloatValue("guialpha"));
+
vscroll->decRef();
vscrollHi->decRef();
@@ -218,12 +219,10 @@ void ScrollArea::updateAlpha()
if (alpha != mAlpha)
{
mAlpha = alpha;
- for (int a = 0; a < 9; a++)
- {
- background.grid[a]->setAlpha(mAlpha);
- vMarker.grid[a]->setAlpha(mAlpha);
- vMarkerHi.grid[a]->setAlpha(mAlpha);
- }
+
+ background.setAlpha(mAlpha);
+ vMarker.setAlpha(mAlpha);
+ vMarkerHi.setAlpha(mAlpha);
}
}
diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp
index c8ed2141..15a10d33 100644
--- a/src/gui/widgets/tab.cpp
+++ b/src/gui/widgets/tab.cpp
@@ -74,9 +74,9 @@ Tab::~Tab()
if (mInstances == 0)
{
- for (int mode = 0; mode < TAB_COUNT; mode++)
+ for (auto &imgRect : tabImg)
{
- std::for_each(tabImg[mode].grid, tabImg[mode].grid + 9, dtor<Image*>());
+ std::for_each(imgRect.grid, imgRect.grid + 9, dtor<Image*>());
}
}
}
@@ -106,10 +106,10 @@ void Tab::init()
data[mode].gridX[x], data[mode].gridY[y],
data[mode].gridX[x + 1] - data[mode].gridX[x] + 1,
data[mode].gridY[y + 1] - data[mode].gridY[y] + 1);
- tabImg[mode].grid[a]->setAlpha(mAlpha);
a++;
}
}
+ tabImg[mode].setAlpha(mAlpha);
tab[mode]->decRef();
}
}
@@ -126,12 +126,10 @@ void Tab::updateAlpha()
if (alpha != mAlpha)
{
mAlpha = alpha;
- for (int a = 0; a < 9; a++)
+
+ for (auto &t : tabImg)
{
- for (int t = 0; t < TAB_COUNT; t++)
- {
- tabImg[t].grid[a]->setAlpha(mAlpha);
- }
+ t.setAlpha(mAlpha);
}
}
}
diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp
index cd2c0f03..1fdd276f 100644
--- a/src/gui/widgets/tabbedarea.cpp
+++ b/src/gui/widgets/tabbedarea.cpp
@@ -214,10 +214,9 @@ void TabbedArea::widgetResized(const gcn::Event &event)
void TabbedArea::updateTabsWidth()
{
mTabsWidth = 0;
- for (TabContainer::const_iterator itr = mTabs.begin(), itr_end = mTabs.end();
- itr != itr_end; ++itr)
+ for (const auto &tab : mTabs)
{
- mTabsWidth += (*itr).first->getWidth();
+ mTabsWidth += tab.first->getWidth();
}
updateVisibleTabsWidth();
}
@@ -234,11 +233,11 @@ void TabbedArea::updateVisibleTabsWidth()
void TabbedArea::adjustTabPositions()
{
int maxTabHeight = 0;
- for (unsigned i = 0; i < mTabs.size(); ++i)
+ for (auto &tab : mTabs)
{
- if (mTabs[i].first->getHeight() > maxTabHeight)
+ if (tab.first->getHeight() > maxTabHeight)
{
- maxTabHeight = mTabs[i].first->getHeight();
+ maxTabHeight = tab.first->getHeight();
}
}
diff --git a/src/gui/widgets/tablemodel.cpp b/src/gui/widgets/tablemodel.cpp
index 5273e929..9c7bc92d 100644
--- a/src/gui/widgets/tablemodel.cpp
+++ b/src/gui/widgets/tablemodel.cpp
@@ -37,14 +37,14 @@ void TableModel::removeListener(TableModelListener *listener)
void TableModel::signalBeforeUpdate()
{
- for (auto it = listeners.begin(); it != listeners.end(); it++)
- (*it)->modelUpdated(false);
+ for (auto listener : listeners)
+ listener->modelUpdated(false);
}
void TableModel::signalAfterUpdate()
{
- for (auto it = listeners.begin(); it != listeners.end(); it++)
- (*it)->modelUpdated(true);
+ for (auto listener : listeners)
+ listener->modelUpdated(true);
}
@@ -146,9 +146,9 @@ int StaticTableModel::getWidth() const
{
int width = 0;
- for (unsigned int i = 0; i < mWidths.size(); i++)
+ for (int w : mWidths)
{
- width += mWidths[i];
+ width += w;
}
return width;
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index 1609e002..2239bed4 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -69,10 +69,10 @@ TextField::TextField(const std::string &text, bool loseFocusOnTab):
gridx[x], gridy[y],
gridx[x + 1] - gridx[x] + 1,
gridy[y + 1] - gridy[y] + 1);
- skin.grid[a]->setAlpha(config.getFloatValue("guialpha"));
a++;
}
}
+ skin.setAlpha(config.getFloatValue("guialpha"));
textbox->decRef();
}
@@ -96,8 +96,7 @@ void TextField::updateAlpha()
if (alpha != mAlpha)
{
mAlpha = alpha;
- for (int a = 0; a < 9; a++)
- skin.grid[a]->setAlpha(mAlpha);
+ skin.setAlpha(mAlpha);
}
}
diff --git a/src/gui/widgets/vertcontainer.cpp b/src/gui/widgets/vertcontainer.cpp
index ad87788f..a0c227ab 100644
--- a/src/gui/widgets/vertcontainer.cpp
+++ b/src/gui/widgets/vertcontainer.cpp
@@ -45,8 +45,8 @@ void VertContainer::clear()
void VertContainer::widgetResized(const gcn::Event &event)
{
- for (auto it = mWidgets.begin(); it != mWidgets.end(); it++)
+ for (auto &widget : mWidgets)
{
- (*it)->setWidth(getWidth());
+ widget->setWidth(getWidth());
}
}
diff --git a/src/gui/widgets/windowcontainer.cpp b/src/gui/widgets/windowcontainer.cpp
index c7ac5d99..8cee550b 100644
--- a/src/gui/widgets/windowcontainer.cpp
+++ b/src/gui/widgets/windowcontainer.cpp
@@ -43,7 +43,7 @@ void WindowContainer::scheduleDelete(gcn::Widget *widget)
void WindowContainer::adjustAfterResize(int oldScreenWidth,
int oldScreenHeight)
{
- for (auto i = mWidgets.begin(); i != mWidgets.end(); ++i)
- if (auto *window = dynamic_cast<Window*>(*i))
+ for (auto &widget : mWidgets)
+ if (auto *window = dynamic_cast<Window*>(widget))
window->adjustPositionAfterResize(oldScreenWidth, oldScreenHeight);
}
diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp
index 5b13d0f3..0da51928 100644
--- a/src/gui/windowmenu.cpp
+++ b/src/gui/windowmenu.cpp
@@ -199,9 +199,9 @@ void WindowMenu::addButton(const std::string& text, int &x, int &h,
void WindowMenu::updatePopUpCaptions()
{
- for (auto it = mWidgets.begin(); it != mWidgets.end(); ++it)
+ for (auto &widget : mWidgets)
{
- auto *button = dynamic_cast<Button*> (*it);
+ auto *button = dynamic_cast<Button*>(widget);
if (!button)
continue;