summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/buy.cpp18
-rw-r--r--src/gui/char_select.cpp24
-rw-r--r--src/gui/char_server.cpp9
-rw-r--r--src/gui/debugwindow.cpp35
-rw-r--r--src/gui/debugwindow.h7
-rw-r--r--src/gui/equipmentwindow.cpp7
-rw-r--r--src/gui/inttextbox.cpp16
-rw-r--r--src/gui/inventorywindow.cpp10
-rw-r--r--src/gui/itemcontainer.cpp16
-rw-r--r--src/gui/ministatus.cpp11
-rw-r--r--src/gui/register.cpp2
-rw-r--r--src/gui/sell.cpp18
-rw-r--r--src/gui/setup.cpp6
-rw-r--r--src/gui/status.cpp109
-rw-r--r--src/gui/tabbedcontainer.cpp17
-rw-r--r--src/gui/trade.cpp16
-rw-r--r--src/gui/updatewindow.cpp9
17 files changed, 128 insertions, 202 deletions
diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp
index 18542385..86bd5413 100644
--- a/src/gui/buy.cpp
+++ b/src/gui/buy.cpp
@@ -23,8 +23,6 @@
#include "buy.h"
-#include <sstream>
-
#include <guichan/widgets/label.hpp>
#include "button.h"
@@ -41,6 +39,8 @@
#include "../net/messageout.h"
#include "../net/protocol.h"
+#include "../utils/tostring.h"
+
BuyDialog::BuyDialog(Network *network):
Window("Buy"), mNetwork(network),
@@ -139,10 +139,8 @@ void BuyDialog::reset()
void BuyDialog::addItem(short id, int price)
{
ITEM_SHOP item_shop;
- std::stringstream ss;
- ss << itemDb->getItemInfo(id)->getName() << " " << price << " GP";
- item_shop.name = ss.str();
+ item_shop.name = itemDb->getItemInfo(id)->getName() + " " + toString(price) + " GP";
item_shop.price = price;
item_shop.id = id;
@@ -242,21 +240,17 @@ void BuyDialog::action(const std::string& eventId)
// If anything has changed, we have to update the buttons and labels
if (updateButtonsAndLabels) {
- std::stringstream oss;
-
// Update buttons
mIncreaseButton->setEnabled(mAmountItems < mMaxItems);
mDecreaseButton->setEnabled(mAmountItems > 0);
mBuyButton->setEnabled(mAmountItems > 0);
// Update labels
- oss << mAmountItems;
- mQuantityLabel->setCaption(oss.str());
+ mQuantityLabel->setCaption(toString(mAmountItems));
mQuantityLabel->adjustSize();
- oss.str("");
- oss << "Price : " << mAmountItems * mShopItems->at(selectedItem).price << " GP";
- mMoneyLabel->setCaption(oss.str());
+ int price = mAmountItems * mShopItems->at(selectedItem).price;
+ mMoneyLabel->setCaption("Price : " + toString(price) + " GP");
mMoneyLabel->adjustSize();
}
}
diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp
index b1d08951..40c1d145 100644
--- a/src/gui/char_select.cpp
+++ b/src/gui/char_select.cpp
@@ -23,7 +23,6 @@
#include "char_select.h"
-#include <sstream>
#include <string>
#include <guichan/widgets/label.hpp>
@@ -40,6 +39,8 @@
#include "../net/messageout.h"
+#include "./utils/tostring.h"
+
/**
* Listener for confirming character deletion.
*/
@@ -69,7 +70,8 @@ void CharDeleteConfirm::action(const std::string &eventId)
}
CharSelectDialog::CharSelectDialog(Network *network, LockedArray<LocalPlayer*> *charInfo):
- Window("Select Character"), mNetwork(network), mCharInfo(charInfo), mCharSelected(false)
+ Window("Select Character"), mNetwork(network),
+ mCharInfo(charInfo), mCharSelected(false)
{
mSelectButton = new Button("Ok", "ok", this);
mCancelButton = new Button("Cancel", "cancel", this);
@@ -171,17 +173,10 @@ void CharSelectDialog::updatePlayerInfo()
LocalPlayer *pi = mCharInfo->getEntry();
if (pi) {
- std::stringstream nameCaption, levelCaption, jobCaption, moneyCaption;
-
- nameCaption << pi->getName();
- levelCaption << "Lvl: " << pi->mLevel;
- jobCaption << "Job Lvl: " << pi->mJobLevel;
- moneyCaption << "Gold: " << pi->mGp;
-
- mNameLabel->setCaption(nameCaption.str());
- mLevelLabel->setCaption(levelCaption.str());
- mJobLevelLabel->setCaption(jobCaption.str());
- mMoneyLabel->setCaption(moneyCaption.str());
+ mNameLabel->setCaption(pi->getName());
+ mLevelLabel->setCaption("Lvl: " + toString(pi->mLevel));
+ mJobLevelLabel->setCaption("Job Lvl: " + toString(pi->mJobLevel));
+ mMoneyLabel->setCaption("Gold: " + toString(pi->mGp));
if (!mCharSelected)
{
mNewCharButton->setEnabled(false);
@@ -191,8 +186,7 @@ void CharSelectDialog::updatePlayerInfo()
mPlayerBox->mHairStyle = pi->getHairStyle() - 1;
mPlayerBox->mHairColor = pi->getHairColor() - 1;
mPlayerBox->mShowPlayer = true;
- }
- else {
+ } else {
mNameLabel->setCaption("Name");
mLevelLabel->setCaption("Level");
mJobLevelLabel->setCaption("Job Level");
diff --git a/src/gui/char_server.cpp b/src/gui/char_server.cpp
index 8a0a67ab..ad0df223 100644
--- a/src/gui/char_server.cpp
+++ b/src/gui/char_server.cpp
@@ -23,8 +23,6 @@
#include "char_server.h"
-#include <sstream>
-
#include "button.h"
#include "listbox.h"
#include "scrollarea.h"
@@ -35,6 +33,8 @@
#include "../net/network.h" // TODO this is just for iptostring, move that?
+#include "../utils/tostring.h"
+
extern SERVER_INFO **server_info;
/**
@@ -120,7 +120,6 @@ ServerListModel::getNumberOfElements()
std::string
ServerListModel::getElementAt(int i)
{
- std::stringstream s;
- s << server_info[i]->name << " (" << server_info[i]->online_users << ")";
- return s.str();
+ const SERVER_INFO *si = server_info[i];
+ return si->name + " (" + toString(si->online_users) + ")";
}
diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp
index cf30df93..66681a8b 100644
--- a/src/gui/debugwindow.cpp
+++ b/src/gui/debugwindow.cpp
@@ -23,16 +23,18 @@
#include "debugwindow.h"
-#include <guichan/widgets/label.hpp>
-#include <sstream>
#include <SDL_mouse.h>
+#include <guichan/widgets/label.hpp>
+
#include "button.h"
#include "../game.h"
#include "../engine.h"
#include "../map.h"
+#include "../utils/tostring.h"
+
DebugWindow::DebugWindow():
Window("Debug")
{
@@ -73,29 +75,24 @@ DebugWindow::logic()
int mouseTileX = mouseX / 32 + camera_x;
int mouseTileY = mouseY / 32 + camera_y;
- std::stringstream updatedText;
- updatedText << "[" << fps << " FPS]";
- mFPSLabel->setCaption(updatedText.str());
+ mFPSLabel->setCaption("[" + toString(fps) + " FPS");
mFPSLabel->adjustSize();
- updatedText.str("");
- updatedText << "[Mouse: " << mouseTileX << ", " << mouseTileY << "]";
- mTileMouseLabel->setCaption(updatedText.str());
+ mTileMouseLabel->setCaption("[Mouse: " +
+ toString(mouseTileX) + ", " + toString(mouseTileY) + "]");
mTileMouseLabel->adjustSize();
- updatedText.str("");
- mCurrentMap = engine->getCurrentMap();
-
- if (mCurrentMap != NULL)
+ Map *currentMap = engine->getCurrentMap();
+ if (currentMap != NULL)
{
- updatedText << " [Music File: "
- << mCurrentMap->getProperty("music") << "]";
- mMusicFileLabel->setCaption(updatedText.str());
+ const std::string music =
+ " [Music File: " + currentMap->getProperty("music") + "]";
+ mMusicFileLabel->setCaption(music);
mMusicFileLabel->adjustSize();
- updatedText.str("");
- updatedText << " [MiniMap File: "
- << mCurrentMap->getProperty("minimap") << "]";
- mMapFileLabel->setCaption(updatedText.str());
+
+ const std::string minimap =
+ " [MiniMap File: " + currentMap->getProperty("minimap") + "]";
+ mMapFileLabel->setCaption(minimap);
mMapFileLabel->adjustSize();
}
}
diff --git a/src/gui/debugwindow.h b/src/gui/debugwindow.h
index d318df16..80524ffa 100644
--- a/src/gui/debugwindow.h
+++ b/src/gui/debugwindow.h
@@ -24,14 +24,13 @@
#ifndef _TMW_DEBUGWINDOW_H
#define _TMW_DEBUGWINDOW_H
-#include <string>
+#include <iosfwd>
#include <guichan/actionlistener.hpp>
#include "window.h"
-#include "../guichanfwd.h"
-class Map;
+#include "../guichanfwd.h"
/**
* The chat window.
@@ -59,8 +58,6 @@ class DebugWindow : public Window, public gcn::ActionListener
private:
gcn::Label *mMusicFileLabel, *mMapFileLabel;
gcn::Label *mTileMouseLabel, *mFPSLabel;
- Map *mCurrentMap;
-
};
#endif
diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp
index 64c368bc..1b9cfc55 100644
--- a/src/gui/equipmentwindow.cpp
+++ b/src/gui/equipmentwindow.cpp
@@ -33,7 +33,7 @@
#include "../resources/iteminfo.h"
#include "../resources/resourcemanager.h"
-#include <sstream>
+#include "../utils/tostring.h"
EquipmentWindow::EquipmentWindow(Equipment *equipment):
Window("Equipment"), mEquipment(equipment)
@@ -85,7 +85,6 @@ void EquipmentWindow::draw(gcn::Graphics *graphics)
image = mItemset->get(item->getInfo()->getImage() - 1);
dynamic_cast<Graphics*>(graphics)->drawImage(image, 160, 25);
- std::stringstream n;
- n << item->getQuantity();
- graphics->drawText(n.str(), 170, 62, gcn::Graphics::CENTER);
+ graphics->drawText(toString(item->getQuantity()), 170, 62,
+ gcn::Graphics::CENTER);
}
diff --git a/src/gui/inttextbox.cpp b/src/gui/inttextbox.cpp
index 560a6cec..92f21e5f 100644
--- a/src/gui/inttextbox.cpp
+++ b/src/gui/inttextbox.cpp
@@ -23,10 +23,10 @@
#include "inttextbox.h"
-#include <sstream>
-
#include <guichan/key.hpp>
+#include "../utils/tostring.h"
+
IntTextBox::IntTextBox(int i):
mValue(i)
{
@@ -40,9 +40,8 @@ void IntTextBox::keyPress(const gcn::Key &key)
gcn::TextBox::keyPress(key);
}
- std::stringstream s;
+ std::stringstream s(gcn::TextBox::getText());
int i;
- s << gcn::TextBox::getText();
s >> i;
if (gcn::TextBox::getText() != "")
setInt(i);
@@ -63,11 +62,10 @@ int IntTextBox::getInt()
void IntTextBox::setInt(int i)
{
- std::stringstream s;
-
if (i >= mMin && i <= mMax)
mValue = i;
- s << mValue;
- setText(s.str());
- setCaretPosition(s.str().length() + 1);
+
+ const std::string valStr = toString(mValue);
+ setText(valStr);
+ setCaretPosition(valStr.length() + 1);
}
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index 422d92af..8f672bc9 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -24,7 +24,6 @@
#include "inventorywindow.h"
#include <string>
-#include <sstream>
#include <guichan/mouseinput.hpp>
@@ -41,6 +40,8 @@
#include "../resources/iteminfo.h"
+#include "../utils/tostring.h"
+
InventoryWindow::InventoryWindow():
Window("Inventory")
{
@@ -88,10 +89,9 @@ void InventoryWindow::logic()
updateButtons();
// Update weight information
- std::stringstream tempstr;
- tempstr << "Total Weight: " << player_node->mTotalWeight
- << " - Maximum Weight: " << player_node->mMaxWeight;
- mWeightLabel->setCaption(tempstr.str());
+ mWeightLabel->setCaption(
+ "Total Weight: " + toString(player_node->mTotalWeight) + " - "
+ "Maximum Weight: " + toString(player_node->mMaxWeight));
mWeightLabel->adjustSize();
}
diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp
index e0730ced..9b8dc09b 100644
--- a/src/gui/itemcontainer.cpp
+++ b/src/gui/itemcontainer.cpp
@@ -23,8 +23,6 @@
#include "itemcontainer.h"
-#include <sstream>
-
#include <guichan/mouseinput.hpp>
#include "../graphics.h"
@@ -38,6 +36,8 @@
#include "../resources/iteminfo.h"
#include "../resources/resourcemanager.h"
+#include "../utils/tostring.h"
+
ItemContainer::ItemContainer(Inventory *inventory):
mInventory(inventory)
{
@@ -122,16 +122,8 @@ void ItemContainer::draw(gcn::Graphics* graphics)
}
// Draw item caption
- std::stringstream ss;
-
- if (!item->isEquipped()) {
- ss << item->getQuantity();
- }
- else {
- ss << "Eq.";
- }
-
- graphics->drawText(ss.str(),
+ graphics->drawText(
+ (item->isEquipped() ? "Eq." : toString(item->getQuantity())),
itemX + gridWidth / 2,
itemY + gridHeight - 11,
gcn::Graphics::CENTER);
diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp
index fc2f451b..be089b68 100644
--- a/src/gui/ministatus.cpp
+++ b/src/gui/ministatus.cpp
@@ -24,13 +24,14 @@
#include "ministatus.h"
#include <guichan/widgets/label.hpp>
-#include <sstream>
#include "gui.h"
#include "progressbar.h"
#include "../localplayer.h"
+#include "../utils/tostring.h"
+
MiniStatusWindow::MiniStatusWindow():
Window("")
{
@@ -88,12 +89,8 @@ void MiniStatusWindow::update()
// mpBar->setProgress((float)player_node->mp / (float)player_node->maxMp);
// Update and center labels
- std::stringstream updatedText;
- updatedText << player_node->mHp;
- mHpLabel->setCaption(updatedText.str());
- updatedText.str("");
- updatedText << player_node->mMp;
- mMpLabel->setCaption(updatedText.str());
+ mHpLabel->setCaption(toString(player_node->mHp));
+ mMpLabel->setCaption(toString(player_node->mMp));
}
void MiniStatusWindow::draw(gcn::Graphics *graphics)
diff --git a/src/gui/register.cpp b/src/gui/register.cpp
index a5e511b3..39c918f7 100644
--- a/src/gui/register.cpp
+++ b/src/gui/register.cpp
@@ -139,7 +139,7 @@ RegisterDialog::action(const std::string& eventId)
int error = 0;
// Check login
- if (user.length() == 0)
+ if (user.empty())
{
// No username
errorMsg << "Enter your username first.";
diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp
index aa67adab..bde8906b 100644
--- a/src/gui/sell.cpp
+++ b/src/gui/sell.cpp
@@ -24,7 +24,6 @@
#include "sell.h"
#include <cassert>
-#include <sstream>
#include <guichan/widgets/label.hpp>
@@ -43,6 +42,7 @@
#include "../net/messageout.h"
#include "../net/protocol.h"
+#include "../utils/tostring.h"
SellDialog::SellDialog(Network *network):
Window("Sell"),
@@ -141,11 +141,8 @@ void SellDialog::addItem(Item *item, int price)
return;
ITEM_SHOP item_shop;
- std::stringstream ss;
- ss << item->getInfo()->getName() << " " << price << " GP";
-
- item_shop.name = ss.str();
+ item_shop.name = item->getInfo()->getName() + " " + toString(price) + " GP";
item_shop.price = price;
item_shop.index = item->getInvIndex();
item_shop.id = item->getId();
@@ -240,15 +237,12 @@ void SellDialog::action(const std::string& eventId)
// If anything changed, we need to update the buttons and labels
if (updateButtonsAndLabels) {
- std::stringstream oss;
-
// Update labels
- oss << mAmountItems;
- mQuantityLabel->setCaption(oss.str());
+ mQuantityLabel->setCaption(toString(mAmountItems));
mQuantityLabel->adjustSize();
- oss.str("");
- oss << "Price: " << mAmountItems * mShopItems->at(selectedItem).price;
- mMoneyLabel->setCaption(oss.str());
+
+ int price = mAmountItems * mShopItems->at(selectedItem).price;
+ mMoneyLabel->setCaption("Price: " + toString(price));
mMoneyLabel->adjustSize();
// Update Buttons
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp
index f680d6ac..2fd99e1c 100644
--- a/src/gui/setup.cpp
+++ b/src/gui/setup.cpp
@@ -308,9 +308,9 @@ void Setup::action(const std::string &eventId)
{
std::stringstream error;
error << "Failed to switch to " <<
- (fullscreen ? "windowed" : "fullscreen") <<
- "mode and restoration of old mode also failed!" <<
- std::endl;
+ (fullscreen ? "windowed" : "fullscreen") <<
+ "mode and restoration of old mode also failed!" <<
+ std::endl;
logger->error(error.str());
}
}
diff --git a/src/gui/status.cpp b/src/gui/status.cpp
index 28108fca..d7cae2f0 100644
--- a/src/gui/status.cpp
+++ b/src/gui/status.cpp
@@ -24,7 +24,6 @@
#include "status.h"
#include <guichan/widgets/label.hpp>
-#include <sstream>
#include "button.h"
#include "progressbar.h"
@@ -33,6 +32,8 @@
#include "../graphics.h"
+#include "../utils/tostring.h"
+
extern Graphics *graphics;
StatusWindow::StatusWindow(LocalPlayer *player):
@@ -224,43 +225,31 @@ StatusWindow::StatusWindow(LocalPlayer *player):
void StatusWindow::update()
{
- std::stringstream updateText;
-
// Status Part
// -----------
- updateText.str("");
- updateText << "Level: " << mPlayer->mLevel;
- mLvlLabel->setCaption(updateText.str());
+ mLvlLabel->setCaption("Level: " + toString(mPlayer->mLevel));
mLvlLabel->adjustSize();
- updateText.str("");
- updateText << "Money: " << mPlayer->mGp << " GP";
- mGpLabel->setCaption(updateText.str());
+ mGpLabel->setCaption("Money: " + toString(mPlayer->mGp) + " GP");
mGpLabel->adjustSize();
- updateText.str("");
- updateText << "Job: " << mPlayer->mJobLevel;
- mJobXpLabel->setCaption(updateText.str());
+ mJobXpLabel->setCaption("Job: " + toString(mPlayer->mJobLevel));
mJobXpLabel->adjustSize();
- updateText.str("");
- updateText << mPlayer->mHp << "/" << mPlayer->mMaxHp;
- mHpValueLabel->setCaption(updateText.str());
+ mHpValueLabel->setCaption(toString(mPlayer->mHp) +
+ "/" + toString(mPlayer->mMaxHp));
mHpValueLabel->adjustSize();
- updateText.str("");
- updateText << mPlayer->mMp << "/" << mPlayer->mMaxMp;
- mMpValueLabel->setCaption(updateText.str());
+ mMpValueLabel->setCaption(toString(mPlayer->mMp) +
+ "/" + toString(mPlayer->mMaxMp));
mMpValueLabel->adjustSize();
- updateText.str("");
- updateText << (int)mPlayer->mXp << "/" << (int)mPlayer->mXpForNextLevel;
- mXpValueLabel->setCaption(updateText.str());
+ mXpValueLabel->setCaption(toString(mPlayer->mXp) +
+ "/" + toString(mPlayer->mXpForNextLevel));
mXpValueLabel->adjustSize();
- updateText.str("");
- updateText << (int)mPlayer->mJobXp << "/" << (int)mPlayer->mJobXpForNextLevel;
- mJobValueLabel->setCaption(updateText.str());
+ mJobValueLabel->setCaption(toString(mPlayer->mJobXp) +
+ "/" + toString(mPlayer->mJobXpForNextLevel));
mJobValueLabel->adjustSize();
// HP Bar coloration
@@ -295,92 +284,76 @@ void StatusWindow::update()
"Dexterity",
"Luck"
};
-
int statusPoints = mPlayer->mStatsPointsToAttribute;
- updateText.str("");
- updateText << "Remaining Status Points: " << statusPoints;
-
// Update labels
for (int i = 0; i < 6; i++) {
- std::stringstream sstr;
-
mStatsLabel[i]->setCaption(attrNames[i]);
- mStatsLabel[i]->adjustSize();
+ mStatsDisplayLabel[i]->setCaption(toString((int)mPlayer->mAttr[i]));
+ mPointsLabel[i]->setCaption(toString((int)mPlayer->mAttrUp[i]));
- sstr.str("");
- sstr << (int)mPlayer->mAttr[i];
- mStatsDisplayLabel[i]->setCaption(sstr.str());
+ mStatsLabel[i]->adjustSize();
mStatsDisplayLabel[i]->adjustSize();
-
- sstr.str("");
- sstr << (int)mPlayer->mAttrUp[i];
- mPointsLabel[i]->setCaption(sstr.str());
mPointsLabel[i]->adjustSize();
mStatsButton[i]->setEnabled(mPlayer->mAttrUp[i] <= statusPoints);
}
- mRemainingStatsPointsLabel->setCaption(updateText.str());
+ mRemainingStatsPointsLabel->setCaption("Remaining Status Points: " +
+ toString(statusPoints));
mRemainingStatsPointsLabel->adjustSize();
// Derived Stats Points
// Attack TODO: Count equipped Weapons and items attack bonuses
- updateText.str("");
- updateText << int(mPlayer->ATK + mPlayer->ATK_BONUS);
- mStatsAttackPoints->setCaption(updateText.str());
+ mStatsAttackPoints->setCaption(
+ toString(mPlayer->ATK + mPlayer->ATK_BONUS));
mStatsAttackPoints->adjustSize();
// Defense TODO: Count equipped Armors and items defense bonuses
- updateText.str("");
- updateText << int(mPlayer->DEF + mPlayer->DEF_BONUS);
- mStatsDefensePoints->setCaption(updateText.str());
+ mStatsDefensePoints->setCaption(
+ toString(mPlayer->DEF + mPlayer->DEF_BONUS));
mStatsDefensePoints->adjustSize();
// Magic Attack TODO: Count equipped items M.Attack bonuses
- updateText.str("");
- updateText << int(mPlayer->MATK + mPlayer->MATK_BONUS);
- mStatsMagicAttackPoints->setCaption(updateText.str());
+ mStatsMagicAttackPoints->setCaption(
+ toString(mPlayer->MATK + mPlayer->MATK_BONUS));
mStatsMagicAttackPoints->adjustSize();
// Magic Defense TODO: Count equipped items M.Defense bonuses
- updateText.str("");
- updateText << int(mPlayer->MDEF + mPlayer->MDEF_BONUS);
- mStatsMagicDefensePoints->setCaption(updateText.str());
+ mStatsMagicDefensePoints->setCaption(
+ toString(mPlayer->MDEF + mPlayer->MDEF_BONUS));
mStatsMagicDefensePoints->adjustSize();
// Accuracy %
- updateText.str("");
- updateText << (int)mPlayer->HIT;
- mStatsAccuracyPoints->setCaption(updateText.str());
+ mStatsAccuracyPoints->setCaption(toString(mPlayer->HIT));
mStatsAccuracyPoints->adjustSize();
// Evasion %
- updateText.str("");
- updateText << (int)mPlayer->FLEE;
- mStatsEvadePoints->setCaption(updateText.str());
+ mStatsEvadePoints->setCaption(toString(mPlayer->FLEE));
mStatsEvadePoints->adjustSize();
// Reflex %
- updateText.str("");
- updateText << ((int)mPlayer->DEX / 4); // + counter
- mStatsReflexPoints->setCaption(updateText.str());
+ mStatsReflexPoints->setCaption(toString(mPlayer->DEX / 4)); // + counter
mStatsReflexPoints->adjustSize();
// Update Second column widgets position
mGpLabel->setPosition(mLvlLabel->getX() + mLvlLabel->getWidth() + 20,
mLvlLabel->getY());
- mXpLabel->setPosition(mHpValueLabel->getX() + mHpValueLabel->getWidth() + 10,
- mHpLabel->getY());
- mXpBar->setPosition(mXpLabel->getX() + mXpLabel->getWidth() + 5,
- mXpLabel->getY());
- mXpValueLabel->setPosition(mXpBar->getX() + mXpBar->getWidth() + 5,
- mXpLabel->getY());
+ mXpLabel->setPosition(
+ mHpValueLabel->getX() + mHpValueLabel->getWidth() + 10,
+ mHpLabel->getY());
+ mXpBar->setPosition(
+ mXpLabel->getX() + mXpLabel->getWidth() + 5,
+ mXpLabel->getY());
+ mXpValueLabel->setPosition(
+ mXpBar->getX() + mXpBar->getWidth() + 5,
+ mXpLabel->getY());
mJobXpLabel->setPosition(mXpLabel->getX(), mMpLabel->getY());
- mJobXpBar->setPosition(mXpBar->getX() + mXpBar->getWidth() -
- mJobXpBar->getWidth(), mJobXpLabel->getY());
+ mJobXpBar->setPosition(
+ mXpBar->getX() + mXpBar->getWidth() - mJobXpBar->getWidth(),
+ mJobXpLabel->getY());
mJobValueLabel->setPosition(290, mJobXpLabel->getY());
}
diff --git a/src/gui/tabbedcontainer.cpp b/src/gui/tabbedcontainer.cpp
index f19524e1..f1927c6f 100644
--- a/src/gui/tabbedcontainer.cpp
+++ b/src/gui/tabbedcontainer.cpp
@@ -23,10 +23,10 @@
#include "tabbedcontainer.h"
-#include <sstream>
-
#include "button.h"
+#include "../utils/tostring.h"
+
#define TABWIDTH 60
#define TABHEIGHT 20
@@ -48,12 +48,9 @@ TabbedContainer::~TabbedContainer()
void TabbedContainer::addTab(gcn::Widget *widget, const std::string &caption)
{
- std::stringstream ss;
int tabNumber = mTabs.size();
- ss << tabNumber;
-
- Button *tab = new Button(caption, ss.str(), this);
+ Button *tab = new Button(caption, toString(tabNumber), this);
tab->setSize(TABWIDTH, TABHEIGHT);
add(tab, TABWIDTH * tabNumber, 0);
@@ -83,14 +80,12 @@ void TabbedContainer::logic()
void TabbedContainer::action(const std::string &event)
{
+ std::stringstream ss(event);
int tabNo;
- std::stringstream ss;
- gcn::Widget *newContent;
-
- ss << event;
ss >> tabNo;
- if ((newContent = mContents[tabNo])) {
+ gcn::Widget *newContent = mContents[tabNo];
+ if (newContent) {
if (mActiveContent) {
remove(mActiveContent);
}
diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp
index ee7bca06..9b98fa09 100644
--- a/src/gui/trade.cpp
+++ b/src/gui/trade.cpp
@@ -43,6 +43,8 @@
#include "../resources/iteminfo.h"
+#include "../utils/tostring.h"
+
TradeWindow::TradeWindow(Network *network):
Window("Trade: You"),
mNetwork(network),
@@ -130,9 +132,7 @@ TradeWindow::~TradeWindow()
void TradeWindow::addMoney(int amount)
{
- std::stringstream tempMoney;
- tempMoney << "You get: " << amount << "z";
- mMoneyLabel->setCaption(tempMoney.str());
+ mMoneyLabel->setCaption("You get: " + toString(amount) + "z");
mMoneyLabel->adjustSize();
}
@@ -292,14 +292,12 @@ void TradeWindow::action(const std::string &eventId)
}
else if (eventId == "ok")
{
- std::stringstream tempMoney[2];
- tempMoney[0] << mMoneyField->getText();
+ std::stringstream tempMoney(mMoneyField->getText());
int tempInt;
- if (tempMoney[0] >> tempInt)
+ if (tempMoney >> tempInt)
{
- tempMoney[1] << tempInt;
- mMoneyField->setText(tempMoney[1].str());
-
+ mMoneyField->setText(toString(tempInt));
+
MessageOut outMsg(mNetwork);
outMsg.writeInt16(CMSG_TRADE_ITEM_ADD_REQUEST);
outMsg.writeInt16(0);
diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp
index 9db09f27..4f43d1fc 100644
--- a/src/gui/updatewindow.cpp
+++ b/src/gui/updatewindow.cpp
@@ -24,7 +24,6 @@
#include "updatewindow.h"
#include <iostream>
-#include <sstream>
#include <SDL.h>
#include <SDL_thread.h>
@@ -41,6 +40,8 @@
#include "../log.h"
#include "../main.h"
+#include "../utils/tostring.h"
+
UpdaterWindow::UpdaterWindow():
Window("Updating..."),
mThread(NULL), mMutex(NULL), mDownloadStatus(UPDATE_NEWS),
@@ -190,10 +191,8 @@ int UpdaterWindow::updateProgress(void *ptr,
if (progress < 0) progress = 0.0f;
if (progress > 1) progress = 1.0f;
- std::stringstream progressString;
- progressString << uw->mCurrentFile
- << " (" << ((int)(progress * 100)) << "%)";
- uw->setLabel(progressString.str().c_str());
+ uw->setLabel(
+ uw->mCurrentFile + " (" + toString((int)progress * 100) + "%)");
uw->setProgress(progress);
if (state != UPDATE_STATE || uw->mDownloadStatus == UPDATE_ERROR)