summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/game.cpp14
-rw-r--r--src/gui/chat.cpp2
-rw-r--r--src/gui/widgets/chattab.cpp13
-rw-r--r--src/gui/widgets/chattab.h7
-rw-r--r--src/gui/widgets/tab.cpp4
-rw-r--r--src/gui/widgets/tab.h5
-rw-r--r--src/gui/widgets/tabbedarea.cpp29
-rw-r--r--src/gui/widgets/tabbedarea.h32
-rw-r--r--src/gui/widgets/whispertab.cpp2
-rw-r--r--src/resources/itemdb.cpp6
-rw-r--r--src/resources/itemdb.h2
-rw-r--r--src/sound.cpp2
12 files changed, 47 insertions, 71 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 2ee4ad13..e074fc30 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -19,13 +19,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <fstream>
-#include <physfs.h>
-#include <sstream>
-#include <string>
-
-#include <guichan/exception.hpp>
-
#include "beingmanager.h"
#include "channelmanager.h"
#include "commandhandler.h"
@@ -96,6 +89,13 @@
#include "utils/gettext.h"
+#include <guichan/exception.hpp>
+
+#include <fstream>
+#include <physfs.h>
+#include <sstream>
+#include <string>
+
std::string map_path;
bool done = false;
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index 9580ffe1..7faf9bda 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -414,7 +414,7 @@ void ChatWindow::setRecordingFile(const std::string &msg)
void ChatWindow::whisper(const std::string &nick, std::string mes, bool own)
{
- if (mes.length() == 0)
+ if (mes.empty())
return;
std::string playerName = player_node->getName();
diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp
index 44840423..01d8b62b 100644
--- a/src/gui/widgets/chattab.cpp
+++ b/src/gui/widgets/chattab.cpp
@@ -125,11 +125,11 @@ void ChatTab::chatLog(std::string line, int own, bool ignoreRecord)
}
break;
case BY_PLAYER:
- tmp.nick += CAT_NORMAL;
+ tmp.nick += ": ";
lineColor = "##Y";
break;
case BY_OTHER:
- tmp.nick += CAT_NORMAL;
+ tmp.nick += ": ";
lineColor = "##C";
break;
case BY_SERVER:
@@ -148,7 +148,6 @@ void ChatTab::chatLog(std::string line, int own, bool ignoreRecord)
lineColor = "##W";
break;
case ACT_IS:
- tmp.nick += CAT_IS;
lineColor = "##I";
break;
case BY_LOGGER:
@@ -207,8 +206,9 @@ void ChatTab::chatLog(std::string line, int own, bool ignoreRecord)
void ChatTab::chatLog(const std::string &nick, const std::string &msg)
{
- chatLog(nick + CAT_NORMAL + msg, nick == player_node->getName() ?
- BY_PLAYER : BY_OTHER, false);
+ chatLog(nick + ": " + msg,
+ nick == player_node->getName() ? BY_PLAYER : BY_OTHER,
+ false);
}
void ChatTab::chatInput(std::string &msg)
@@ -270,7 +270,8 @@ void ChatTab::clearText()
mTextOutput->clearRows();
}
-void ChatTab::handleInput(const std::string &msg) {
+void ChatTab::handleInput(const std::string &msg)
+{
Net::getChatHandler()->talk(msg);
}
diff --git a/src/gui/widgets/chattab.h b/src/gui/widgets/chattab.h
index 27c27480..dc0d3047 100644
--- a/src/gui/widgets/chattab.h
+++ b/src/gui/widgets/chattab.h
@@ -42,13 +42,6 @@ enum
};
/**
- * gets in between usernick and message text depending on
- * message type
- */
-#define CAT_NORMAL ": "
-#define CAT_IS ""
-
-/**
* A tab for the chat window. This is special to ease chat handling.
*/
class ChatTab : public Tab
diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp
index 456735c4..071be06a 100644
--- a/src/gui/widgets/tab.cpp
+++ b/src/gui/widgets/tab.cpp
@@ -159,10 +159,8 @@ void Tab::draw(gcn::Graphics *graphics)
drawChildren(graphics);
}
-void Tab::setTabColor(gcn::Color color)
+void Tab::setTabColor(const gcn::Color &color)
{
- if (color == NULL)
- color = guiPalette->getColor(Palette::TEXT);
mTabColor = color;
}
diff --git a/src/gui/widgets/tab.h b/src/gui/widgets/tab.h
index 271316e4..134d5591 100644
--- a/src/gui/widgets/tab.h
+++ b/src/gui/widgets/tab.h
@@ -28,7 +28,8 @@ class ImageRect;
class TabbedArea;
/**
- * A tab, the same as the guichan tab in 0.8, but extended to allow transparancy
+ * A tab, the same as the Guichan tab in 0.8, but extended to allow
+ * transparency.
*/
class Tab : public gcn::Tab
{
@@ -44,7 +45,7 @@ class Tab : public gcn::Tab
/**
* Set the normal color fo the tab's text.
*/
- void setTabColor(gcn::Color color);
+ void setTabColor(const gcn::Color &color);
/**
* Set tab highlighted
diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp
index 86730c51..07f46a94 100644
--- a/src/gui/widgets/tabbedarea.cpp
+++ b/src/gui/widgets/tabbedarea.cpp
@@ -29,14 +29,14 @@ TabbedArea::TabbedArea() : gcn::TabbedArea()
mWidgetContainer->setOpaque(false);
}
-int TabbedArea::getNumberOfTabs()
+int TabbedArea::getNumberOfTabs() const
{
return mTabs.size();
}
-Tab* TabbedArea::getTab(const std::string &name)
+Tab *TabbedArea::getTab(const std::string &name) const
{
- TabContainer::iterator itr = mTabs.begin(), itr_end = mTabs.end();
+ TabContainer::const_iterator itr = mTabs.begin(), itr_end = mTabs.end();
while (itr != itr_end)
{
if ((*itr).first->getCaption() == name)
@@ -55,9 +55,9 @@ void TabbedArea::draw(gcn::Graphics *graphics)
drawChildren(graphics);
}
-gcn::Widget* TabbedArea::getWidget(const std::string &name)
+gcn::Widget *TabbedArea::getWidget(const std::string &name) const
{
- TabContainer::iterator itr = mTabs.begin(), itr_end = mTabs.end();
+ TabContainer::const_iterator itr = mTabs.begin(), itr_end = mTabs.end();
while (itr != itr_end)
{
if ((*itr).first->getCaption() == name)
@@ -71,28 +71,13 @@ gcn::Widget* TabbedArea::getWidget(const std::string &name)
void TabbedArea::addTab(const std::string &caption, gcn::Widget *widget)
{
- Tab* tab = new Tab;
+ Tab *tab = new Tab;
tab->setCaption(caption);
mTabsToDelete.push_back(tab);
addTab(tab, widget);
}
-void TabbedArea::addTab(Tab *tab, gcn::Widget *widget)
-{
- tab->setTabbedArea(this);
- tab->addActionListener(this);
-
- mTabContainer->add(tab);
- mTabs.push_back(std::pair<Tab*, gcn::Widget*>(tab, widget));
-
- if (!mSelectedTab)
- setSelectedTab(tab);
-
- adjustTabPositions();
- adjustSize();
-}
-
void TabbedArea::removeTab(Tab *tab)
{
int tabIndexToBeSelected = -1;
@@ -146,8 +131,8 @@ void TabbedArea::removeTab(Tab *tab)
void TabbedArea::logic()
{
logicChildren();
-
}
+
void TabbedArea::setSelectedTab(gcn::Tab *tab)
{
gcn::TabbedArea::setSelectedTab(tab);
diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h
index b4fc1ded..6aaafe16 100644
--- a/src/gui/widgets/tabbedarea.h
+++ b/src/gui/widgets/tabbedarea.h
@@ -47,45 +47,45 @@ class TabbedArea : public gcn::TabbedArea
void draw(gcn::Graphics *graphics);
/**
- * Return how many tabs have been created
+ * Return how many tabs have been created.
+ *
+ * @todo Remove this method when upgrading to Guichan 0.9.0
*/
- int getNumberOfTabs();
+ int getNumberOfTabs() const;
/**
- * Return tab with specified name as caption
+ * Return tab with specified name as caption.
*/
- Tab* getTab(const std::string &name);
+ Tab *getTab(const std::string &name) const;
/**
* Returns the widget with the tab that has specified caption
*/
- gcn::Widget* getWidget(const std::string &name);
+ gcn::Widget *getWidget(const std::string &name) const;
+
+ using gcn::TabbedArea::addTab;
/**
- * Add a tab
+ * Add a tab. Overridden since it needs to create an instance of Tab
+ * instead of gcn::Tab.
+ *
* @param caption The Caption to display
* @param widget The widget to show when tab is selected
*/
void addTab(const std::string &caption, gcn::Widget *widget);
/**
- * Add a tab
- * @param tab The tab
- * @param widget The widget to display
- */
- void addTab(Tab *tab, gcn::Widget *widget);
-
- /**
- * Overload the remove tab function as its broken in guichan 0.8
+ * Overload the remove tab function as it's broken in guichan 0.8.
*/
void removeTab(Tab *tab);
/**
- * Overload the logic function since it's broken in guichan 0.8
+ * Overload the logic function since it's broken in guichan 0.8.
*/
void logic();
- int getContainerHeight() { return mWidgetContainer->getHeight(); }
+ int getContainerHeight() const
+ { return mWidgetContainer->getHeight(); }
void setSelectedTab(unsigned int index)
{ gcn::TabbedArea::setSelectedTab(index); }
diff --git a/src/gui/widgets/whispertab.cpp b/src/gui/widgets/whispertab.cpp
index 87a88222..0c6503a6 100644
--- a/src/gui/widgets/whispertab.cpp
+++ b/src/gui/widgets/whispertab.cpp
@@ -45,7 +45,7 @@ WhisperTab::~WhisperTab()
void WhisperTab::handleInput(const std::string &msg)
{
- if (msg.length() == 0) {
+ if (msg.empty()) {
chatLog(_("Cannot send empty chat!"), BY_SERVER, false);
return;
}
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp
index 36be4d0c..807fa0a4 100644
--- a/src/resources/itemdb.cpp
+++ b/src/resources/itemdb.cpp
@@ -200,7 +200,7 @@ void ItemDB::load()
std::string temp = name;
toLower(trim(temp));
- NamedItemInfoIterator itr = mNamedItemInfos.find(temp);
+ NamedItemInfos::const_iterator itr = mNamedItemInfos.find(temp);
if (itr == mNamedItemInfos.end())
{
mNamedItemInfos[temp] = itemInfo;
@@ -248,7 +248,7 @@ const ItemInfo& ItemDB::get(int id)
{
assert(mLoaded);
- ItemInfoIterator i = mItemInfos.find(id);
+ ItemInfos::const_iterator i = mItemInfos.find(id);
if (i == mItemInfos.end())
{
@@ -265,7 +265,7 @@ const ItemInfo& ItemDB::get(const std::string &name)
{
assert(mLoaded && !name.empty());
- NamedItemInfoIterator i = mNamedItemInfos.find(name);
+ NamedItemInfos::const_iterator i = mNamedItemInfos.find(name);
if (i == mNamedItemInfos.end())
{
diff --git a/src/resources/itemdb.h b/src/resources/itemdb.h
index 2a76eecd..2bb8fd5e 100644
--- a/src/resources/itemdb.h
+++ b/src/resources/itemdb.h
@@ -56,8 +56,6 @@ namespace ItemDB
// Items database
typedef std::map<int, ItemInfo*> ItemInfos;
typedef std::map<std::string, ItemInfo*> NamedItemInfos;
- typedef ItemInfos::iterator ItemInfoIterator;
- typedef NamedItemInfos::iterator NamedItemInfoIterator;
}
#endif
diff --git a/src/sound.cpp b/src/sound.cpp
index e2663fa8..6fb75d84 100644
--- a/src/sound.cpp
+++ b/src/sound.cpp
@@ -229,7 +229,7 @@ void Sound::fadeOutMusic(int ms)
void Sound::playSfx(const std::string &path)
{
- if (!mInstalled || path.length() == 0)
+ if (!mInstalled || path.empty())
return;
ResourceManager *resman = ResourceManager::getInstance();