summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-01-28 21:00:12 +0300
committerAndrei Karas <akaras@inbox.ru>2012-01-28 21:00:12 +0300
commita93722a53e2d50466dfd5512c4a6a1c3dfc60fb1 (patch)
treeb4ade374e591f520ae49b1dcb3317b19d503f089 /src/gui
parente5695ad6c41d4deb79504998b2bc5caeb1e61285 (diff)
downloadmv-a93722a53e2d50466dfd5512c4a6a1c3dfc60fb1.tar.gz
mv-a93722a53e2d50466dfd5512c4a6a1c3dfc60fb1.tar.bz2
mv-a93722a53e2d50466dfd5512c4a6a1c3dfc60fb1.tar.xz
mv-a93722a53e2d50466dfd5512c4a6a1c3dfc60fb1.zip
Add support for processing player statuses in evol server.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/shopwindow.cpp13
-rw-r--r--src/gui/whoisonline.cpp36
-rw-r--r--src/gui/whoisonline.h47
3 files changed, 66 insertions, 30 deletions
diff --git a/src/gui/shopwindow.cpp b/src/gui/shopwindow.cpp
index b6b87edb7..1a27b8b0c 100644
--- a/src/gui/shopwindow.cpp
+++ b/src/gui/shopwindow.cpp
@@ -55,6 +55,7 @@
#include "net/net.h"
#include "net/chathandler.h"
#include "net/npchandler.h"
+#include "net/playerhandler.h"
#include "net/tradehandler.h"
#include "resources/iteminfo.h"
@@ -206,11 +207,15 @@ void ShopWindow::action(const gcn::ActionEvent &event)
&& mBuyShopItemList->getSelected() >= 0)
{
mBuyShopItems->del(mBuyShopItemList->getSelected());
+ if (isShopEmpty() && player_node)
+ player_node->updateStatus();
}
else if (event.getId() == "delete sell" && mSellShopItemList
&& mSellShopItemList->getSelected() >= 0)
{
mSellShopItems->del(mSellShopItemList->getSelected());
+ if (isShopEmpty() && player_node)
+ player_node->updateStatus();
}
else if (event.getId() == "announce buy" && mBuyShopItems
&& mBuyShopItems->getNumberOfElements() > 0)
@@ -306,8 +311,12 @@ void ShopWindow::addBuyItem(Item *item, int amount, int price)
{
if (!mBuyShopItems || !item)
return;
+ bool emp = isShopEmpty();
mBuyShopItems->addItemNoDup(item->getId(),
item->getColor(), amount, price);
+ if (emp && player_node)
+ player_node->updateStatus();
+
updateButtonsAndLabels();
}
@@ -315,8 +324,12 @@ void ShopWindow::addSellItem(Item *item, int amount, int price)
{
if (!mBuyShopItems || !item)
return;
+ bool emp = isShopEmpty();
mSellShopItems->addItemNoDup(item->getId(),
item->getColor(), amount, price);
+ if (emp && player_node)
+ player_node->updateStatus();
+
updateButtonsAndLabels();
}
diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp
index 34cfc1a57..e38f6ad73 100644
--- a/src/gui/whoisonline.cpp
+++ b/src/gui/whoisonline.cpp
@@ -402,7 +402,8 @@ void WhoIsOnline::loadWebList()
if (!mShowLevel)
level = 0;
- OnlinePlayer *player = new OnlinePlayer(nick, -1, level, -1);
+ OnlinePlayer *player = new OnlinePlayer(nick, 0, level,
+ GENDER_UNSPECIFIED, -1);
mOnlinePlayers.insert(player);
mOnlineNicks.insert(nick);
@@ -709,11 +710,40 @@ void WhoIsOnline::optionChanged(const std::string &name)
void OnlinePlayer::setText(std::string color)
{
- mText = strprintf("@@%s|##%s%s", mNick.c_str(),
+ mText = strprintf("@@%s|##%s%s ", mNick.c_str(),
color.c_str(), mNick.c_str());
+ if (actorSpriteManager)
+ {
+ Being *being = actorSpriteManager->findBeingByName(
+ mNick, Being::PLAYER);
+ if (being)
+ being->setState(mStatus);
+ }
+
if (mLevel > 0)
- mText += strprintf(" (%d)", mLevel);
+ mText += strprintf("%d", mLevel);
+
+ if (mGender == GENDER_FEMALE)
+ mText += "\u2640";
+ else if (mGender == GENDER_MALE)
+ mText += "\u2642";
+
+ if (mStatus > 0)
+ {
+ if (mStatus & Being::FLAG_SHOP)
+ mText += "$";
+ if (mStatus & Being::FLAG_AWAY)
+ {
+ // TRANSLATORS: this away status writed in player nick
+ mText += _("A");
+ }
+ if (mStatus & Being::FLAG_INACTIVE)
+ {
+ // TRANSLATORS: this inactive status writed in player nick
+ mText += _("I");
+ }
+ }
if (mVersion > 0)
mText += strprintf(" - %d", mVersion);
diff --git a/src/gui/whoisonline.h b/src/gui/whoisonline.h
index ef25257da..feaec3ab4 100644
--- a/src/gui/whoisonline.h
+++ b/src/gui/whoisonline.h
@@ -45,57 +45,50 @@ struct SDL_Thread;
class OnlinePlayer
{
public:
- OnlinePlayer(std::string nick, int status, int level, int version) :
+ OnlinePlayer(std::string nick, unsigned char status,
+ unsigned char level, unsigned char gender,
+ unsigned char version) :
mNick(nick),
mText(""),
mStatus(status),
mLevel(level),
- mVersion(version)
+ mVersion(version),
+ mGender(gender)
{
}
const std::string getNick() const
- {
- return mNick;
- }
+ { return mNick; }
- int getStaus() const
- {
- return mStatus;
- }
+ unsigned char getStaus() const
+ { return mStatus; }
- int getVersion() const
- {
- return mVersion;
- }
+ unsigned char getVersion() const
+ { return mVersion; }
- int getLevel() const
- {
- return mLevel;
- }
+ unsigned char getLevel() const
+ { return mLevel; }
const std::string getText()
- {
- return mText;
- }
+ { return mText; }
void setText(std::string str);
- void setLevel(int level)
- {
- mLevel = level;
- }
+ void setLevel(unsigned char level)
+ { mLevel = level; }
private:
std::string mNick;
std::string mText;
- int mStatus;
+ unsigned char mStatus;
+
+ unsigned char mLevel;
- int mLevel;
+ unsigned char mVersion;
- int mVersion;
+ unsigned char mGender;
};
/**