summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-03-31 16:54:22 +0300
committerAndrei Karas <akaras@inbox.ru>2012-04-01 03:56:16 +0300
commit761682b6254a3d43e65ff45e07683c61afa6f1e4 (patch)
tree2ee462840f3aadb1e96bfa5c6784ec2cc0d2861a /src/gui
parenta39f63cdfa5ce15b22f294a8bb1db3a036ce462d (diff)
downloadplus-761682b6254a3d43e65ff45e07683c61afa6f1e4.tar.gz
plus-761682b6254a3d43e65ff45e07683c61afa6f1e4.tar.bz2
plus-761682b6254a3d43e65ff45e07683c61afa6f1e4.tar.xz
plus-761682b6254a3d43e65ff45e07683c61afa6f1e4.zip
Last part of fixes.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/botcheckerwindow.cpp2
-rw-r--r--src/gui/chatwindow.cpp12
-rw-r--r--src/gui/npcdialog.cpp9
-rw-r--r--src/gui/outfitwindow.cpp7
-rw-r--r--src/gui/palette.cpp47
-rw-r--r--src/gui/sdlfont.cpp16
-rw-r--r--src/gui/shopwindow.cpp13
-rw-r--r--src/gui/tradewindow.cpp9
-rw-r--r--src/gui/userpalette.cpp23
-rw-r--r--src/gui/viewport.cpp18
-rw-r--r--src/gui/whoisonline.cpp2
-rw-r--r--src/gui/widgets/browserbox.cpp9
-rw-r--r--src/gui/widgets/chattab.cpp10
-rw-r--r--src/gui/widgets/slider.cpp5
-rw-r--r--src/gui/widgets/tab.cpp3
-rw-r--r--src/gui/widgets/textbox.cpp6
-rw-r--r--src/gui/widgets/textfield.cpp2
-rw-r--r--src/gui/widgets/whispertab.cpp2
18 files changed, 97 insertions, 98 deletions
diff --git a/src/gui/botcheckerwindow.cpp b/src/gui/botcheckerwindow.cpp
index 9265ff203..f7a6db823 100644
--- a/src/gui/botcheckerwindow.cpp
+++ b/src/gui/botcheckerwindow.cpp
@@ -127,7 +127,7 @@ public:
if (!mPlayers.at(r))
continue;
- Being *player = mPlayers.at(r);
+ const Being *player = mPlayers.at(r);
std::string name = player->getName();
gcn::Widget *widget = new Label(name);
diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp
index 29c3abe51..223737a59 100644
--- a/src/gui/chatwindow.cpp
+++ b/src/gui/chatwindow.cpp
@@ -1284,7 +1284,7 @@ std::string ChatWindow::autoComplete(StringVect &names,
std::string name = *i;
toLower(name);
- std::string::size_type pos = name.find(partName, 0);
+ size_t pos = name.find(partName, 0);
if (pos == 0)
{
if (newName != "")
@@ -1314,7 +1314,7 @@ std::string ChatWindow::autoComplete(std::string partName, History *words)
while (i != words->end())
{
std::string line = *i;
- std::string::size_type pos = line.find(partName, 0);
+ size_t pos = line.find(partName, 0);
if (pos == 0)
nameList.push_back(line);
++i;
@@ -1370,7 +1370,7 @@ void ChatWindow::resortChatLog(std::string line, Own own,
return;
}
- std::string::size_type idx = line.find(": \302\202");
+ size_t idx = line.find(": \302\202");
if (idx != std::string::npos)
{
line = line.erase(idx + 2, 2);
@@ -1378,13 +1378,13 @@ void ChatWindow::resortChatLog(std::string line, Own own,
return;
}
- std::string::size_type idx1 = line.find("@@");
+ size_t idx1 = line.find("@@");
if (idx1 != std::string::npos)
{
- std::string::size_type idx2 = line.find("|", idx1);
+ size_t idx2 = line.find("|", idx1);
if (idx2 != std::string::npos)
{
- std::string::size_type idx3 = line.find("@@", idx2);
+ size_t idx3 = line.find("@@", idx2);
if (idx3 != std::string::npos)
{
tradeChatTab->chatLog(line, own, ignoreRecord,
diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp
index 12b3e1244..39af0c71d 100644
--- a/src/gui/npcdialog.cpp
+++ b/src/gui/npcdialog.cpp
@@ -118,10 +118,11 @@ NpcDialog::NpcDialog(int npcId) :
mPlusButton = new Button(_("+"), "inc", this);
mMinusButton = new Button(_("-"), "dec", this);
- int width = std::max(mButton->getFont()->getWidth(CAPTION_WAITING),
- mButton->getFont()->getWidth(CAPTION_NEXT));
- width = std::max(width, mButton->getFont()->getWidth(CAPTION_CLOSE));
- width = std::max(width, mButton->getFont()->getWidth(CAPTION_SUBMIT));
+ gcn::Font *fnt = mButton->getFont();
+ int width = std::max(fnt->getWidth(CAPTION_WAITING),
+ fnt->getWidth(CAPTION_NEXT));
+ width = std::max(width, fnt->getWidth(CAPTION_CLOSE));
+ width = std::max(width, fnt->getWidth(CAPTION_SUBMIT));
mButton->setWidth(8 + width);
diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp
index 502e9d96b..265932cbb 100644
--- a/src/gui/outfitwindow.cpp
+++ b/src/gui/outfitwindow.cpp
@@ -593,10 +593,11 @@ void OutfitWindow::copyFromEquiped(int dst)
for (unsigned i = 0; i < inventory->getSize(); i++)
{
- if (inventory->getItem(i) && inventory->getItem(i)->isEquipped())
+ const Item *item = inventory->getItem(i);
+ if (item && item->isEquipped())
{
- mItems[dst][outfitCell] = inventory->getItem(i)->getId();
- mItemColors[dst][outfitCell++] = inventory->getItem(i)->getColor();
+ mItems[dst][outfitCell] = item->getId();
+ mItemColors[dst][outfitCell++] = item->getColor();
if (outfitCell >= OUTFIT_ITEM_COUNT)
break;
}
diff --git a/src/gui/palette.cpp b/src/gui/palette.cpp
index 3b36fa6ce..b48522faa 100644
--- a/src/gui/palette.cpp
+++ b/src/gui/palette.cpp
@@ -122,21 +122,21 @@ void Palette::advanceGradient()
else
colIndex = mGradVector[i]->gradientIndex;
- if (mGradVector[i]->grad == PULSE)
+ ColorElem *elem = mGradVector[i];
+ gcn::Color &color = elem->color;
+
+ if (elem->grad == PULSE)
{
colVal = static_cast<int>(255.0 *
sin(M_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);
+ color.r = ((colVal * col.r) / 255) % (col.r + 1);
+ color.g = ((colVal * col.g) / 255) % (col.g + 1);
+ color.b = ((colVal * col.b) / 255) % (col.b + 1);
}
- if (mGradVector[i]->grad == SPECTRUM)
+ if (elem->grad == SPECTRUM)
{
if (colIndex % 2)
{ // falling curve
@@ -165,17 +165,14 @@ void Palette::advanceGradient()
}
}
- mGradVector[i]->color.r =
- (colIndex == 0 || colIndex == 5) ? 255 :
- (colIndex == 1 || colIndex == 4) ? colVal : 0;
- mGradVector[i]->color.g =
- (colIndex == 1 || colIndex == 2) ? 255 :
- (colIndex == 0 || colIndex == 3) ? colVal : 0;
- mGradVector[i]->color.b =
- (colIndex == 3 || colIndex == 4) ? 255 :
- (colIndex == 2 || colIndex == 5) ? colVal : 0;
+ color.r = (colIndex == 0 || colIndex == 5) ? 255 :
+ (colIndex == 1 || colIndex == 4) ? colVal : 0;
+ color.g = (colIndex == 1 || colIndex == 2) ? 255 :
+ (colIndex == 0 || colIndex == 3) ? colVal : 0;
+ 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 =
@@ -188,14 +185,14 @@ void Palette::advanceGradient()
destColVal = 1 - startColVal;
- mGradVector[i]->color.r = static_cast<int>(startColVal
- * startCol.r + destColVal * destCol.r);
+ color.r = static_cast<int>(startColVal
+ * startCol.r + destColVal * destCol.r);
- mGradVector[i]->color.g = static_cast<int>(startColVal
- * startCol.g + destColVal * destCol.g);
+ color.g = static_cast<int>(startColVal
+ * startCol.g + destColVal * destCol.g);
- mGradVector[i]->color.b = static_cast<int>(startColVal
- * startCol.b + destColVal * destCol.b);
+ color.b = static_cast<int>(startColVal
+ * startCol.b + destColVal * destCol.b);
}
}
diff --git a/src/gui/sdlfont.cpp b/src/gui/sdlfont.cpp
index 7e0114cb8..197b0f9cd 100644
--- a/src/gui/sdlfont.cpp
+++ b/src/gui/sdlfont.cpp
@@ -249,7 +249,11 @@ void SDLFont::drawString(gcn::Graphics *graphics,
mCreateCounter ++;
#endif
cache->push_front(chunk);
- cache->front().generate(mFont, alpha);
+ SDLTextChunk &data = cache->front();
+ data.generate(mFont, alpha);
+
+ if (data.img)
+ g->drawImage(data.img, x, y);
if (!mCleanTime)
{
@@ -260,16 +264,12 @@ void SDLFont::drawString(gcn::Graphics *graphics,
doClean();
mCleanTime = cur_time + CLEAN_TIME;
}
- if (cache->front().img)
- {
-// cache->front().img->setAlpha(alpha);
- g->drawImage(cache->front().img, x, y);
- }
}
else if (cache->front().img)
{
- cache->front().img->setAlpha(alpha);
- g->drawImage(cache->front().img, x, y);
+ Image *image = cache->front().img;
+ image->setAlpha(alpha);
+ g->drawImage(image, x, y);
}
}
diff --git a/src/gui/shopwindow.cpp b/src/gui/shopwindow.cpp
index 01b589ab6..fccb953b6 100644
--- a/src/gui/shopwindow.cpp
+++ b/src/gui/shopwindow.cpp
@@ -419,6 +419,8 @@ void ShopWindow::saveList()
items = mSellShopItems->items();
for (it = items.begin(); it != items.end(); ++it)
{
+ if (!(*it))
+ continue;
ShopItem *sellItem = *(it);
ShopItem *buyItem = mapItems[sellItem->getId()];
@@ -426,7 +428,7 @@ void ShopWindow::saveList()
if (buyItem)
{
shopFile << strprintf(" %d %d ", buyItem->getQuantity(),
- buyItem->getPrice());
+ buyItem->getPrice());
mapItems.erase(sellItem->getId());
}
else
@@ -434,11 +436,8 @@ void ShopWindow::saveList()
shopFile << " 0 0 ";
}
- if (sellItem)
- {
- shopFile << strprintf("%d %d", sellItem->getQuantity(),
- sellItem->getPrice()) << std::endl;
- }
+ shopFile << strprintf("%d %d", sellItem->getQuantity(),
+ sellItem->getPrice()) << std::endl;
}
std::map<int, ShopItem*>::const_iterator mapIt;
@@ -682,7 +681,7 @@ void ShopWindow::processRequest(std::string nick, std::string data, int mode)
if (!inv)
return;
- unsigned long idx = 0;
+ size_t idx = 0;
idx = data.find(" ");
if (idx == std::string::npos)
diff --git a/src/gui/tradewindow.cpp b/src/gui/tradewindow.cpp
index 43393fc09..8f85f677f 100644
--- a/src/gui/tradewindow.cpp
+++ b/src/gui/tradewindow.cpp
@@ -89,10 +89,11 @@ TradeWindow::TradeWindow():
mAddButton = new Button(_("Add"), "add", this);
mOkButton = new Button("", "", this); // Will be filled in later
- int width = std::max(mOkButton->getFont()->getWidth(CAPTION_PROPOSE),
- mOkButton->getFont()->getWidth(CAPTION_CONFIRMED));
- width = std::max(width, mOkButton->getFont()->getWidth(CAPTION_ACCEPT));
- width = std::max(width, mOkButton->getFont()->getWidth(CAPTION_ACCEPTED));
+ gcn::Font *fnt = mOkButton->getFont();
+ int width = std::max(fnt->getWidth(CAPTION_PROPOSE),
+ fnt->getWidth(CAPTION_CONFIRMED));
+ width = std::max(width, fnt->getWidth(CAPTION_ACCEPT));
+ width = std::max(width, fnt->getWidth(CAPTION_ACCEPTED));
mOkButton->setWidth(8 + width);
diff --git a/src/gui/userpalette.cpp b/src/gui/userpalette.cpp
index a3299fb7b..49a81c4dc 100644
--- a/src/gui/userpalette.cpp
+++ b/src/gui/userpalette.cpp
@@ -82,7 +82,7 @@ std::string UserPalette::getConfigName(const std::string &typeName)
{
std::string res = "Color" + typeName;
- int pos = 5;
+ size_t pos = 5;
for (size_t i = 0; i < typeName.length(); i++)
{
if (i == 0 || typeName[i] == '_')
@@ -96,7 +96,7 @@ std::string UserPalette::getConfigName(const std::string &typeName)
{
res[pos] = static_cast<char>(tolower(typeName[i]));
}
- pos++;
+ pos ++;
}
res.erase(pos, res.length() - pos);
@@ -191,9 +191,10 @@ UserPalette::~UserPalette()
void UserPalette::setColor(int type, int r, int g, int b)
{
- mColors[type].color.r = r;
- mColors[type].color.g = g;
- mColors[type].color.b = b;
+ gcn::Color &color = mColors[type].color;
+ color.r = r;
+ color.g = g;
+ color.b = b;
}
void UserPalette::setGradient(int type, GradientType grad)
@@ -252,15 +253,17 @@ void UserPalette::rollback()
if (i->grad != i->committedGrad)
setGradient(i->type, i->committedGrad);
+ const gcn::Color &committedColor = i->committedColor;
setGradientDelay(i->type, i->committedDelay);
- setColor(i->type, i->committedColor.r,
- i->committedColor.g, i->committedColor.b);
+ setColor(i->type, committedColor.r,
+ committedColor.g, committedColor.b);
if (i->grad == PULSE)
{
- i->testColor.r = i->committedColor.r;
- i->testColor.g = i->committedColor.g;
- i->testColor.b = i->committedColor.b;
+ gcn::Color &testColor = i->testColor;
+ testColor.r = committedColor.r;
+ testColor.g = committedColor.g;
+ testColor.b = committedColor.b;
}
}
}
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index f55385029..7fa0dc464 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -228,11 +228,8 @@ void Viewport::draw(gcn::Graphics *gcnGraphics)
mPixelViewX = static_cast<float>(viewXmax);
if (mPixelViewY > viewYmax)
mPixelViewY = static_cast<float>(viewYmax);
- }
- // Draw tiles and sprites
- if (mMap)
- {
+ // Draw tiles and sprites
mMap->draw(graphics, static_cast<int>(mPixelViewX),
static_cast<int>(mPixelViewY));
@@ -255,8 +252,10 @@ void Viewport::draw(gcn::Graphics *gcnGraphics)
// Draw text
if (textManager)
+ {
textManager->draw(graphics, static_cast<int>(mPixelViewX),
- static_cast<int>(mPixelViewY));
+ static_cast<int>(mPixelViewY));
+ }
// Draw player names, speech, and emotion sprite as needed
const ActorSprites &actors = actorSpriteManager->getAll();
@@ -764,12 +763,9 @@ void Viewport::mouseMoved(gcn::MouseEvent &event A_UNUSED)
mBeingPopup->setVisible(false);
}
- mHoverItem = nullptr;
- if (actorSpriteManager)
- {
- mHoverItem = actorSpriteManager->findItem(x / mMap->getTileWidth(),
- y / mMap->getTileHeight());
- }
+ mHoverItem = actorSpriteManager->findItem(x / mMap->getTileWidth(),
+ y / mMap->getTileHeight());
+
if (!mHoverBeing && !mHoverItem)
{
SpecialLayer *specialLayer = mMap->getSpecialLayer();
diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp
index 698a0468f..aece25115 100644
--- a/src/gui/whoisonline.cpp
+++ b/src/gui/whoisonline.cpp
@@ -365,7 +365,7 @@ void WhoIsOnline::loadWebList()
{
int level = 0;
- std::string::size_type pos = 0;
+ size_t pos = 0;
if (lineStr.length() > 24)
{
nick = lineStr.substr(0, 24);
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index 5ef7adfcd..6b5263aa9 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -105,7 +105,9 @@ void BrowserBox::addRow(const std::string &row, bool atTop)
{
std::string tmp = row;
std::string newRow;
- std::string::size_type idx1, idx2, idx3;
+ size_t idx1;
+ size_t idx2;
+ size_t idx3;
gcn::Font *font = getFont();
if (getWidth() < 0)
@@ -479,7 +481,7 @@ int BrowserBox::calcHeight()
// TODO: Check if we must take texture size limits into account here
// TODO: Check if some of the O(n) calls can be removed
- for (std::string::size_type start = 0, end = std::string::npos;
+ for (size_t start = 0, end = std::string::npos;
start != std::string::npos;
start = end, end = std::string::npos)
{
@@ -566,8 +568,7 @@ int BrowserBox::calcHeight()
}
}
- std::string::size_type len =
- end == std::string::npos ? end : end - start;
+ size_t len = (end == std::string::npos) ? end : end - start;
if (start >= row.length())
break;
diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp
index 5f1b02d98..9b3a00963 100644
--- a/src/gui/widgets/chattab.cpp
+++ b/src/gui/widgets/chattab.cpp
@@ -116,7 +116,7 @@ void ChatTab::chatLog(std::string line, Own own,
tmp.nick = "";
tmp.text = line;
- std::string::size_type pos = line.find(" : ");
+ size_t pos = line.find(" : ");
if (pos != std::string::npos)
{
if (line.length() <= pos + 3)
@@ -343,11 +343,11 @@ void ChatTab::chatInput(const std::string &message)
return;
// Check for item link
- std::string::size_type start = msg.find('[');
+ size_t start = msg.find('[');
while (start + 1 < msg.size() && start != std::string::npos
&& msg[start + 1] != '@')
{
- std::string::size_type end = msg.find(']', start);
+ size_t end = msg.find(']', start);
if (start + 1 != end && end != std::string::npos)
{
// Catch multiple embeds and ignore them
@@ -440,9 +440,9 @@ int ChatTab::getType() const
void ChatTab::addRow(std::string &line)
{
- std::string::size_type idx = 0;
+ size_t idx = 0;
- for (unsigned int f = 0; f < line.length(); f++)
+ for (size_t f = 0; f < line.length(); f++)
{
if (line.at(f) == ' ')
{
diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp
index c6b57858c..7142cd202 100644
--- a/src/gui/widgets/slider.cpp
+++ b/src/gui/widgets/slider.cpp
@@ -228,7 +228,7 @@ void Slider::updateAlpha()
void Slider::draw(gcn::Graphics *graphics)
{
- if (!hStart || !hStartHi)
+ if (!hStart || !hStartHi || !hEnd)
return;
int w = getWidth();
@@ -253,8 +253,7 @@ void Slider::draw(gcn::Graphics *graphics)
}
x += w;
- if (hEnd)
- static_cast<Graphics*>(graphics)->drawImage(hEnd, x, y);
+ static_cast<Graphics*>(graphics)->drawImage(hEnd, x, y);
}
else
{
diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp
index c09fb423d..4dbfe45e4 100644
--- a/src/gui/widgets/tab.cpp
+++ b/src/gui/widgets/tab.cpp
@@ -129,8 +129,7 @@ void Tab::init()
a++;
}
}
- if (tab[mode])
- tab[mode]->decRef();
+ tab[mode]->decRef();
}
}
mInstances++;
diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp
index 575036612..01cb4bddb 100644
--- a/src/gui/widgets/textbox.cpp
+++ b/src/gui/widgets/textbox.cpp
@@ -48,7 +48,9 @@ void TextBox::setTextWrapped(const std::string &text, int minDimension)
mMinWidth = minDimension;
std::stringstream wrappedStream;
- std::string::size_type spacePos, newlinePos, lastNewlinePos = 0;
+ size_t spacePos;
+ size_t newlinePos;
+ size_t lastNewlinePos = 0;
int minWidth = 0;
int xpos;
@@ -73,7 +75,7 @@ void TextBox::setTextWrapped(const std::string &text, int minDimension)
std::string line =
text.substr(lastNewlinePos, newlinePos - lastNewlinePos);
- std::string::size_type lastSpacePos = 0;
+ size_t lastSpacePos = 0;
xpos = 0;
do
diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp
index a90712340..7892b3c0d 100644
--- a/src/gui/widgets/textfield.cpp
+++ b/src/gui/widgets/textfield.cpp
@@ -365,7 +365,7 @@ void TextField::keyPressed(gcn::KeyEvent &keyEvent)
void TextField::handlePaste()
{
std::string text = getText();
- std::string::size_type caretPos = getCaretPosition();
+ size_t caretPos = getCaretPosition();
if (retrieveBuffer(text, caretPos))
{
diff --git a/src/gui/widgets/whispertab.cpp b/src/gui/widgets/whispertab.cpp
index 007002e21..2b3b0436f 100644
--- a/src/gui/widgets/whispertab.cpp
+++ b/src/gui/widgets/whispertab.cpp
@@ -82,7 +82,7 @@ void WhisperTab::handleCommand(const std::string &msg)
return;
}
- std::string::size_type pos = msg.find(' ');
+ size_t pos = msg.find(' ');
std::string type(msg, 0, pos);
std::string args(msg, pos == std::string::npos
? msg.size() : pos + 1);