diff options
author | Björn Steinbrink <B.Steinbrink@gmx.de> | 2006-03-19 15:09:27 +0000 |
---|---|---|
committer | Björn Steinbrink <B.Steinbrink@gmx.de> | 2006-03-19 15:09:27 +0000 |
commit | 3ddaec5f355ed1d231514cf0a863c4b9e35cf2a6 (patch) | |
tree | 5084eaa47d4874a3a573de226f19c4be072e4888 /src/gui | |
parent | 19d5cc3a6bbbd911361b7e8b956840d0189d4c2b (diff) | |
download | mana-3ddaec5f355ed1d231514cf0a863c4b9e35cf2a6.tar.gz mana-3ddaec5f355ed1d231514cf0a863c4b9e35cf2a6.tar.bz2 mana-3ddaec5f355ed1d231514cf0a863c4b9e35cf2a6.tar.xz mana-3ddaec5f355ed1d231514cf0a863c4b9e35cf2a6.zip |
Reverted changeset r2269 (toString) as requested by ElvenProgrammer.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/buy.cpp | 18 | ||||
-rw-r--r-- | src/gui/char_select.cpp | 24 | ||||
-rw-r--r-- | src/gui/char_server.cpp | 9 | ||||
-rw-r--r-- | src/gui/debugwindow.cpp | 35 | ||||
-rw-r--r-- | src/gui/debugwindow.h | 7 | ||||
-rw-r--r-- | src/gui/equipmentwindow.cpp | 7 | ||||
-rw-r--r-- | src/gui/inttextbox.cpp | 16 | ||||
-rw-r--r-- | src/gui/inventorywindow.cpp | 10 | ||||
-rw-r--r-- | src/gui/itemcontainer.cpp | 16 | ||||
-rw-r--r-- | src/gui/ministatus.cpp | 11 | ||||
-rw-r--r-- | src/gui/register.cpp | 2 | ||||
-rw-r--r-- | src/gui/sell.cpp | 18 | ||||
-rw-r--r-- | src/gui/setup_video.cpp | 11 | ||||
-rw-r--r-- | src/gui/status.cpp | 109 | ||||
-rw-r--r-- | src/gui/tabbedcontainer.cpp | 17 | ||||
-rw-r--r-- | src/gui/trade.cpp | 16 | ||||
-rw-r--r-- | src/gui/updatewindow.cpp | 9 |
17 files changed, 204 insertions, 131 deletions
diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp index 86bd5413..18542385 100644 --- a/src/gui/buy.cpp +++ b/src/gui/buy.cpp @@ -23,6 +23,8 @@ #include "buy.h" +#include <sstream> + #include <guichan/widgets/label.hpp> #include "button.h" @@ -39,8 +41,6 @@ #include "../net/messageout.h" #include "../net/protocol.h" -#include "../utils/tostring.h" - BuyDialog::BuyDialog(Network *network): Window("Buy"), mNetwork(network), @@ -139,8 +139,10 @@ void BuyDialog::reset() void BuyDialog::addItem(short id, int price) { ITEM_SHOP item_shop; + std::stringstream ss; - item_shop.name = itemDb->getItemInfo(id)->getName() + " " + toString(price) + " GP"; + ss << itemDb->getItemInfo(id)->getName() << " " << price << " GP"; + item_shop.name = ss.str(); item_shop.price = price; item_shop.id = id; @@ -240,17 +242,21 @@ 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 - mQuantityLabel->setCaption(toString(mAmountItems)); + oss << mAmountItems; + mQuantityLabel->setCaption(oss.str()); mQuantityLabel->adjustSize(); - int price = mAmountItems * mShopItems->at(selectedItem).price; - mMoneyLabel->setCaption("Price : " + toString(price) + " GP"); + oss.str(""); + oss << "Price : " << mAmountItems * mShopItems->at(selectedItem).price << " GP"; + mMoneyLabel->setCaption(oss.str()); mMoneyLabel->adjustSize(); } } diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp index 40c1d145..b1d08951 100644 --- a/src/gui/char_select.cpp +++ b/src/gui/char_select.cpp @@ -23,6 +23,7 @@ #include "char_select.h" +#include <sstream> #include <string> #include <guichan/widgets/label.hpp> @@ -39,8 +40,6 @@ #include "../net/messageout.h" -#include "./utils/tostring.h" - /** * Listener for confirming character deletion. */ @@ -70,8 +69,7 @@ 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); @@ -173,10 +171,17 @@ void CharSelectDialog::updatePlayerInfo() LocalPlayer *pi = mCharInfo->getEntry(); if (pi) { - mNameLabel->setCaption(pi->getName()); - mLevelLabel->setCaption("Lvl: " + toString(pi->mLevel)); - mJobLevelLabel->setCaption("Job Lvl: " + toString(pi->mJobLevel)); - mMoneyLabel->setCaption("Gold: " + toString(pi->mGp)); + 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()); if (!mCharSelected) { mNewCharButton->setEnabled(false); @@ -186,7 +191,8 @@ 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 ad0df223..8a0a67ab 100644 --- a/src/gui/char_server.cpp +++ b/src/gui/char_server.cpp @@ -23,6 +23,8 @@ #include "char_server.h" +#include <sstream> + #include "button.h" #include "listbox.h" #include "scrollarea.h" @@ -33,8 +35,6 @@ #include "../net/network.h" // TODO this is just for iptostring, move that? -#include "../utils/tostring.h" - extern SERVER_INFO **server_info; /** @@ -120,6 +120,7 @@ ServerListModel::getNumberOfElements() std::string ServerListModel::getElementAt(int i) { - const SERVER_INFO *si = server_info[i]; - return si->name + " (" + toString(si->online_users) + ")"; + std::stringstream s; + s << server_info[i]->name << " (" << server_info[i]->online_users << ")"; + return s.str(); } diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp index 66681a8b..cf30df93 100644 --- a/src/gui/debugwindow.cpp +++ b/src/gui/debugwindow.cpp @@ -23,9 +23,9 @@ #include "debugwindow.h" -#include <SDL_mouse.h> - #include <guichan/widgets/label.hpp> +#include <sstream> +#include <SDL_mouse.h> #include "button.h" @@ -33,8 +33,6 @@ #include "../engine.h" #include "../map.h" -#include "../utils/tostring.h" - DebugWindow::DebugWindow(): Window("Debug") { @@ -75,24 +73,29 @@ DebugWindow::logic() int mouseTileX = mouseX / 32 + camera_x; int mouseTileY = mouseY / 32 + camera_y; - mFPSLabel->setCaption("[" + toString(fps) + " FPS"); + std::stringstream updatedText; + updatedText << "[" << fps << " FPS]"; + mFPSLabel->setCaption(updatedText.str()); mFPSLabel->adjustSize(); - mTileMouseLabel->setCaption("[Mouse: " + - toString(mouseTileX) + ", " + toString(mouseTileY) + "]"); + updatedText.str(""); + updatedText << "[Mouse: " << mouseTileX << ", " << mouseTileY << "]"; + mTileMouseLabel->setCaption(updatedText.str()); mTileMouseLabel->adjustSize(); - Map *currentMap = engine->getCurrentMap(); - if (currentMap != NULL) + updatedText.str(""); + mCurrentMap = engine->getCurrentMap(); + + if (mCurrentMap != NULL) { - const std::string music = - " [Music File: " + currentMap->getProperty("music") + "]"; - mMusicFileLabel->setCaption(music); + updatedText << " [Music File: " + << mCurrentMap->getProperty("music") << "]"; + mMusicFileLabel->setCaption(updatedText.str()); mMusicFileLabel->adjustSize(); - - const std::string minimap = - " [MiniMap File: " + currentMap->getProperty("minimap") + "]"; - mMapFileLabel->setCaption(minimap); + updatedText.str(""); + updatedText << " [MiniMap File: " + << mCurrentMap->getProperty("minimap") << "]"; + mMapFileLabel->setCaption(updatedText.str()); mMapFileLabel->adjustSize(); } } diff --git a/src/gui/debugwindow.h b/src/gui/debugwindow.h index 80524ffa..d318df16 100644 --- a/src/gui/debugwindow.h +++ b/src/gui/debugwindow.h @@ -24,14 +24,15 @@ #ifndef _TMW_DEBUGWINDOW_H #define _TMW_DEBUGWINDOW_H -#include <iosfwd> +#include <string> #include <guichan/actionlistener.hpp> #include "window.h" - #include "../guichanfwd.h" +class Map; + /** * The chat window. * @@ -58,6 +59,8 @@ 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 1b9cfc55..64c368bc 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -33,7 +33,7 @@ #include "../resources/iteminfo.h" #include "../resources/resourcemanager.h" -#include "../utils/tostring.h" +#include <sstream> EquipmentWindow::EquipmentWindow(Equipment *equipment): Window("Equipment"), mEquipment(equipment) @@ -85,6 +85,7 @@ void EquipmentWindow::draw(gcn::Graphics *graphics) image = mItemset->get(item->getInfo()->getImage() - 1); dynamic_cast<Graphics*>(graphics)->drawImage(image, 160, 25); - graphics->drawText(toString(item->getQuantity()), 170, 62, - gcn::Graphics::CENTER); + std::stringstream n; + n << item->getQuantity(); + graphics->drawText(n.str(), 170, 62, gcn::Graphics::CENTER); } diff --git a/src/gui/inttextbox.cpp b/src/gui/inttextbox.cpp index 92f21e5f..560a6cec 100644 --- a/src/gui/inttextbox.cpp +++ b/src/gui/inttextbox.cpp @@ -23,9 +23,9 @@ #include "inttextbox.h" -#include <guichan/key.hpp> +#include <sstream> -#include "../utils/tostring.h" +#include <guichan/key.hpp> IntTextBox::IntTextBox(int i): mValue(i) @@ -40,8 +40,9 @@ void IntTextBox::keyPress(const gcn::Key &key) gcn::TextBox::keyPress(key); } - std::stringstream s(gcn::TextBox::getText()); + std::stringstream s; int i; + s << gcn::TextBox::getText(); s >> i; if (gcn::TextBox::getText() != "") setInt(i); @@ -62,10 +63,11 @@ int IntTextBox::getInt() void IntTextBox::setInt(int i) { + std::stringstream s; + if (i >= mMin && i <= mMax) mValue = i; - - const std::string valStr = toString(mValue); - setText(valStr); - setCaretPosition(valStr.length() + 1); + s << mValue; + setText(s.str()); + setCaretPosition(s.str().length() + 1); } diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index 8f672bc9..422d92af 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -24,6 +24,7 @@ #include "inventorywindow.h" #include <string> +#include <sstream> #include <guichan/mouseinput.hpp> @@ -40,8 +41,6 @@ #include "../resources/iteminfo.h" -#include "../utils/tostring.h" - InventoryWindow::InventoryWindow(): Window("Inventory") { @@ -89,9 +88,10 @@ void InventoryWindow::logic() updateButtons(); // Update weight information - mWeightLabel->setCaption( - "Total Weight: " + toString(player_node->mTotalWeight) + " - " - "Maximum Weight: " + toString(player_node->mMaxWeight)); + std::stringstream tempstr; + tempstr << "Total Weight: " << player_node->mTotalWeight + << " - Maximum Weight: " << player_node->mMaxWeight; + mWeightLabel->setCaption(tempstr.str()); mWeightLabel->adjustSize(); } diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp index 9b8dc09b..e0730ced 100644 --- a/src/gui/itemcontainer.cpp +++ b/src/gui/itemcontainer.cpp @@ -23,6 +23,8 @@ #include "itemcontainer.h" +#include <sstream> + #include <guichan/mouseinput.hpp> #include "../graphics.h" @@ -36,8 +38,6 @@ #include "../resources/iteminfo.h" #include "../resources/resourcemanager.h" -#include "../utils/tostring.h" - ItemContainer::ItemContainer(Inventory *inventory): mInventory(inventory) { @@ -122,8 +122,16 @@ void ItemContainer::draw(gcn::Graphics* graphics) } // Draw item caption - graphics->drawText( - (item->isEquipped() ? "Eq." : toString(item->getQuantity())), + std::stringstream ss; + + if (!item->isEquipped()) { + ss << item->getQuantity(); + } + else { + ss << "Eq."; + } + + graphics->drawText(ss.str(), itemX + gridWidth / 2, itemY + gridHeight - 11, gcn::Graphics::CENTER); diff --git a/src/gui/ministatus.cpp b/src/gui/ministatus.cpp index be089b68..fc2f451b 100644 --- a/src/gui/ministatus.cpp +++ b/src/gui/ministatus.cpp @@ -24,14 +24,13 @@ #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("") { @@ -89,8 +88,12 @@ void MiniStatusWindow::update() // mpBar->setProgress((float)player_node->mp / (float)player_node->maxMp); // Update and center labels - mHpLabel->setCaption(toString(player_node->mHp)); - mMpLabel->setCaption(toString(player_node->mMp)); + std::stringstream updatedText; + updatedText << player_node->mHp; + mHpLabel->setCaption(updatedText.str()); + updatedText.str(""); + updatedText << player_node->mMp; + mMpLabel->setCaption(updatedText.str()); } void MiniStatusWindow::draw(gcn::Graphics *graphics) diff --git a/src/gui/register.cpp b/src/gui/register.cpp index 39c918f7..a5e511b3 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.empty()) + if (user.length() == 0) { // No username errorMsg << "Enter your username first."; diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp index bde8906b..aa67adab 100644 --- a/src/gui/sell.cpp +++ b/src/gui/sell.cpp @@ -24,6 +24,7 @@ #include "sell.h" #include <cassert> +#include <sstream> #include <guichan/widgets/label.hpp> @@ -42,7 +43,6 @@ #include "../net/messageout.h" #include "../net/protocol.h" -#include "../utils/tostring.h" SellDialog::SellDialog(Network *network): Window("Sell"), @@ -141,8 +141,11 @@ void SellDialog::addItem(Item *item, int price) return; ITEM_SHOP item_shop; + std::stringstream ss; - item_shop.name = item->getInfo()->getName() + " " + toString(price) + " GP"; + ss << item->getInfo()->getName() << " " << price << " GP"; + + item_shop.name = ss.str(); item_shop.price = price; item_shop.index = item->getInvIndex(); item_shop.id = item->getId(); @@ -237,12 +240,15 @@ 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 - mQuantityLabel->setCaption(toString(mAmountItems)); + oss << mAmountItems; + mQuantityLabel->setCaption(oss.str()); mQuantityLabel->adjustSize(); - - int price = mAmountItems * mShopItems->at(selectedItem).price; - mMoneyLabel->setCaption("Price: " + toString(price)); + oss.str(""); + oss << "Price: " << mAmountItems * mShopItems->at(selectedItem).price; + mMoneyLabel->setCaption(oss.str()); mMoneyLabel->adjustSize(); // Update Buttons diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index a009d2d5..143f86ed 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -23,6 +23,7 @@ #include "setup_video.h" +#include <sstream> #include <string> #include <vector> #include <SDL.h> @@ -41,8 +42,6 @@ #include "../graphics.h" #include "../log.h" -#include "../utils/tostring.h" - extern Graphics *graphics; /** @@ -90,10 +89,10 @@ ModeListModel::ModeListModel() } else { //logger->log("Available Modes"); for (int i = 0; modes[i]; ++i) { - const std::string modeString = - toString((int)modes[i]->w) + "x" + toString((int)modes[i]->h); - //logger->log(modeString.c_str()); - mVideoModes.push_back(modeString); + std::stringstream ss; + ss << (int)modes[i]->w << "x" << (int)modes[i]->h; + //logger->log(ss.str().c_str()); + mVideoModes.push_back(ss.str()); } } } diff --git a/src/gui/status.cpp b/src/gui/status.cpp index 7d6cabac..54412129 100644 --- a/src/gui/status.cpp +++ b/src/gui/status.cpp @@ -24,6 +24,7 @@ #include "status.h" #include <guichan/widgets/label.hpp> +#include <sstream> #include "button.h" #include "progressbar.h" @@ -31,8 +32,6 @@ #include "../localplayer.h" -#include "../utils/tostring.h" - StatusWindow::StatusWindow(LocalPlayer *player): Window(player->getName()), mPlayer(player) @@ -222,31 +221,43 @@ StatusWindow::StatusWindow(LocalPlayer *player): void StatusWindow::update() { + std::stringstream updateText; + // Status Part // ----------- - mLvlLabel->setCaption("Level: " + toString(mPlayer->mLevel)); + updateText.str(""); + updateText << "Level: " << mPlayer->mLevel; + mLvlLabel->setCaption(updateText.str()); mLvlLabel->adjustSize(); - mGpLabel->setCaption("Money: " + toString(mPlayer->mGp) + " GP"); + updateText.str(""); + updateText << "Money: " << mPlayer->mGp << " GP"; + mGpLabel->setCaption(updateText.str()); mGpLabel->adjustSize(); - mJobXpLabel->setCaption("Job: " + toString(mPlayer->mJobLevel)); + updateText.str(""); + updateText << "Job: " << mPlayer->mJobLevel; + mJobXpLabel->setCaption(updateText.str()); mJobXpLabel->adjustSize(); - mHpValueLabel->setCaption(toString(mPlayer->mHp) + - "/" + toString(mPlayer->mMaxHp)); + updateText.str(""); + updateText << mPlayer->mHp << "/" << mPlayer->mMaxHp; + mHpValueLabel->setCaption(updateText.str()); mHpValueLabel->adjustSize(); - mMpValueLabel->setCaption(toString(mPlayer->mMp) + - "/" + toString(mPlayer->mMaxMp)); + updateText.str(""); + updateText << mPlayer->mMp << "/" << mPlayer->mMaxMp; + mMpValueLabel->setCaption(updateText.str()); mMpValueLabel->adjustSize(); - mXpValueLabel->setCaption(toString(mPlayer->mXp) + - "/" + toString(mPlayer->mXpForNextLevel)); + updateText.str(""); + updateText << (int)mPlayer->mXp << "/" << (int)mPlayer->mXpForNextLevel; + mXpValueLabel->setCaption(updateText.str()); mXpValueLabel->adjustSize(); - mJobValueLabel->setCaption(toString(mPlayer->mJobXp) + - "/" + toString(mPlayer->mJobXpForNextLevel)); + updateText.str(""); + updateText << (int)mPlayer->mJobXp << "/" << (int)mPlayer->mJobXpForNextLevel; + mJobValueLabel->setCaption(updateText.str()); mJobValueLabel->adjustSize(); // HP Bar coloration @@ -281,76 +292,92 @@ 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++) { - mStatsLabel[i]->setCaption(attrNames[i]); - mStatsDisplayLabel[i]->setCaption(toString((int)mPlayer->mAttr[i])); - mPointsLabel[i]->setCaption(toString((int)mPlayer->mAttrUp[i])); + std::stringstream sstr; + mStatsLabel[i]->setCaption(attrNames[i]); mStatsLabel[i]->adjustSize(); + + sstr.str(""); + sstr << (int)mPlayer->mAttr[i]; + mStatsDisplayLabel[i]->setCaption(sstr.str()); 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("Remaining Status Points: " + - toString(statusPoints)); + mRemainingStatsPointsLabel->setCaption(updateText.str()); mRemainingStatsPointsLabel->adjustSize(); // Derived Stats Points // Attack TODO: Count equipped Weapons and items attack bonuses - mStatsAttackPoints->setCaption( - toString(mPlayer->ATK + mPlayer->ATK_BONUS)); + updateText.str(""); + updateText << int(mPlayer->ATK + mPlayer->ATK_BONUS); + mStatsAttackPoints->setCaption(updateText.str()); mStatsAttackPoints->adjustSize(); // Defense TODO: Count equipped Armors and items defense bonuses - mStatsDefensePoints->setCaption( - toString(mPlayer->DEF + mPlayer->DEF_BONUS)); + updateText.str(""); + updateText << int(mPlayer->DEF + mPlayer->DEF_BONUS); + mStatsDefensePoints->setCaption(updateText.str()); mStatsDefensePoints->adjustSize(); // Magic Attack TODO: Count equipped items M.Attack bonuses - mStatsMagicAttackPoints->setCaption( - toString(mPlayer->MATK + mPlayer->MATK_BONUS)); + updateText.str(""); + updateText << int(mPlayer->MATK + mPlayer->MATK_BONUS); + mStatsMagicAttackPoints->setCaption(updateText.str()); mStatsMagicAttackPoints->adjustSize(); // Magic Defense TODO: Count equipped items M.Defense bonuses - mStatsMagicDefensePoints->setCaption( - toString(mPlayer->MDEF + mPlayer->MDEF_BONUS)); + updateText.str(""); + updateText << int(mPlayer->MDEF + mPlayer->MDEF_BONUS); + mStatsMagicDefensePoints->setCaption(updateText.str()); mStatsMagicDefensePoints->adjustSize(); // Accuracy % - mStatsAccuracyPoints->setCaption(toString(mPlayer->HIT)); + updateText.str(""); + updateText << (int)mPlayer->HIT; + mStatsAccuracyPoints->setCaption(updateText.str()); mStatsAccuracyPoints->adjustSize(); // Evasion % - mStatsEvadePoints->setCaption(toString(mPlayer->FLEE)); + updateText.str(""); + updateText << (int)mPlayer->FLEE; + mStatsEvadePoints->setCaption(updateText.str()); mStatsEvadePoints->adjustSize(); // Reflex % - mStatsReflexPoints->setCaption(toString(mPlayer->DEX / 4)); // + counter + updateText.str(""); + updateText << ((int)mPlayer->DEX / 4); // + counter + mStatsReflexPoints->setCaption(updateText.str()); 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 f1927c6f..f19524e1 100644 --- a/src/gui/tabbedcontainer.cpp +++ b/src/gui/tabbedcontainer.cpp @@ -23,9 +23,9 @@ #include "tabbedcontainer.h" -#include "button.h" +#include <sstream> -#include "../utils/tostring.h" +#include "button.h" #define TABWIDTH 60 #define TABHEIGHT 20 @@ -48,9 +48,12 @@ TabbedContainer::~TabbedContainer() void TabbedContainer::addTab(gcn::Widget *widget, const std::string &caption) { + std::stringstream ss; int tabNumber = mTabs.size(); - Button *tab = new Button(caption, toString(tabNumber), this); + ss << tabNumber; + + Button *tab = new Button(caption, ss.str(), this); tab->setSize(TABWIDTH, TABHEIGHT); add(tab, TABWIDTH * tabNumber, 0); @@ -80,12 +83,14 @@ 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; - gcn::Widget *newContent = mContents[tabNo]; - if (newContent) { + if ((newContent = mContents[tabNo])) { if (mActiveContent) { remove(mActiveContent); } diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp index 9b98fa09..ee7bca06 100644 --- a/src/gui/trade.cpp +++ b/src/gui/trade.cpp @@ -43,8 +43,6 @@ #include "../resources/iteminfo.h" -#include "../utils/tostring.h" - TradeWindow::TradeWindow(Network *network): Window("Trade: You"), mNetwork(network), @@ -132,7 +130,9 @@ TradeWindow::~TradeWindow() void TradeWindow::addMoney(int amount) { - mMoneyLabel->setCaption("You get: " + toString(amount) + "z"); + std::stringstream tempMoney; + tempMoney << "You get: " << amount << "z"; + mMoneyLabel->setCaption(tempMoney.str()); mMoneyLabel->adjustSize(); } @@ -292,12 +292,14 @@ void TradeWindow::action(const std::string &eventId) } else if (eventId == "ok") { - std::stringstream tempMoney(mMoneyField->getText()); + std::stringstream tempMoney[2]; + tempMoney[0] << mMoneyField->getText(); int tempInt; - if (tempMoney >> tempInt) + if (tempMoney[0] >> tempInt) { - mMoneyField->setText(toString(tempInt)); - + tempMoney[1] << tempInt; + mMoneyField->setText(tempMoney[1].str()); + 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 4f43d1fc..9db09f27 100644 --- a/src/gui/updatewindow.cpp +++ b/src/gui/updatewindow.cpp @@ -24,6 +24,7 @@ #include "updatewindow.h" #include <iostream> +#include <sstream> #include <SDL.h> #include <SDL_thread.h> @@ -40,8 +41,6 @@ #include "../log.h" #include "../main.h" -#include "../utils/tostring.h" - UpdaterWindow::UpdaterWindow(): Window("Updating..."), mThread(NULL), mMutex(NULL), mDownloadStatus(UPDATE_NEWS), @@ -191,8 +190,10 @@ int UpdaterWindow::updateProgress(void *ptr, if (progress < 0) progress = 0.0f; if (progress > 1) progress = 1.0f; - uw->setLabel( - uw->mCurrentFile + " (" + toString((int)progress * 100) + "%)"); + std::stringstream progressString; + progressString << uw->mCurrentFile + << " (" << ((int)(progress * 100)) << "%)"; + uw->setLabel(progressString.str().c_str()); uw->setProgress(progress); if (state != UPDATE_STATE || uw->mDownloadStatus == UPDATE_ERROR) |