diff options
-rw-r--r-- | src/gui/popupmenu.cpp | 21 | ||||
-rw-r--r-- | src/gui/widgets/chattab.cpp | 2 | ||||
-rw-r--r-- | src/localplayer.cpp | 8 | ||||
-rw-r--r-- | src/localplayer.h | 2 | ||||
-rw-r--r-- | src/net/ea/beinghandler.cpp | 5 | ||||
-rw-r--r-- | src/player.cpp | 60 | ||||
-rw-r--r-- | src/player.h | 2 |
7 files changed, 49 insertions, 51 deletions
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index fdb8c5ac..e12ca822 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -118,9 +118,11 @@ void PopupMenu::showPopup(int x, int y, Being *being) if (player_node->isInParty()) mBrowserBox->addRow(strprintf(_("@@party|Invite %s to join your party@@"), name.c_str())); - /* - mBrowserBox->addRow("##3---"); - mBrowserBox->addRow(_("@@admin-kick|Kick player@@"));*/ + if (player_node->isGM()) + { + mBrowserBox->addRow("##3---"); + mBrowserBox->addRow(_("@@admin-kick|Kick player@@")); + } } break; @@ -131,13 +133,14 @@ void PopupMenu::showPopup(int x, int y, Being *being) break; case Being::MONSTER: - // Monsters can be attacked - mBrowserBox->addRow(strprintf(_("@@attack|Attack %s@@"), name.c_str())); - break; + { + // Monsters can be attacked + mBrowserBox->addRow(strprintf(_("@@attack|Attack %s@@"), name.c_str())); - /*case Being::MONSTER: - mBrowserBox->addRow(_("@@admin-kick|Kick monster@@")); - break;*/ + if (player_node->isGM()) + mBrowserBox->addRow(_("@@admin-kick|Kick monster@@")); + } + break; default: /* Other beings aren't interesting... */ diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index d55e5da8..defc06f0 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -165,7 +165,7 @@ void ChatTab::chatLog(std::string line, int own, bool ignoreRecord) #ifdef EATHENA_SUPPORT if (tmp.nick.empty() && tmp.text.substr(0, 17) == "Visible GM status") { - player_node->setGM(); + player_node->setGM(true); } #endif diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 059ccd31..24502dd1 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -236,13 +236,9 @@ void LocalPlayer::setAction(Action action, int attackType) Player::setAction(action, attackType); } -void LocalPlayer::setGM() +void LocalPlayer::setGM(bool gm) { - mIsGM = !mIsGM; - mNameColor = mIsGM ? - &guiPalette->getColor(Palette::GM) : - &guiPalette->getColor(Palette::PLAYER); - setName(getName()); + mIsGM = gm; config.setValue(getName() + "GMassert", mIsGM); } diff --git a/src/localplayer.h b/src/localplayer.h index bab254ab..39f438d1 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -223,7 +223,7 @@ class LocalPlayer : public Player /** * Triggers whether or not to show the name as a GM name. */ - virtual void setGM(); + virtual void setGM(bool gm); void stopAttack(); diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp index 5a49442c..34a0d70a 100644 --- a/src/net/ea/beinghandler.cpp +++ b/src/net/ea/beinghandler.cpp @@ -508,8 +508,9 @@ void BeingHandler::handleMessage(MessageIn &msg) } gmstatus = msg.readInt16(); - if ((gmstatus & 0x80) && dstBeing->getType() == Being::PLAYER) - static_cast<Player*>(dstBeing)->setGM(); + if (gmstatus & 0x80) + if (Player *player = dynamic_cast<Player*>(dstBeing)) + player->setGM(true); if (msg.getId() == SMSG_PLAYER_UPDATE_1) { diff --git a/src/player.cpp b/src/player.cpp index 453b8bdd..520342e3 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -58,44 +58,34 @@ void Player::setName(const std::string &name) { if (!mName && mShowName) { - if (mIsGM) + mNameColor = &guiPalette->getColor(Palette::PLAYER); + + const gcn::Color *color; + if (this == player_node) + { + color = &guiPalette->getColor(Palette::SELF); + } + else if (mIsGM) { mNameColor = &guiPalette->getColor(Palette::GM); - mName = new FlashText("(GM) " + name, - getPixelX(), - getPixelY(), - gcn::Graphics::CENTER, - &guiPalette->getColor(Palette::GM_NAME)); + color = &guiPalette->getColor(Palette::GM_NAME); + } + else if (mInParty) + { + color = &guiPalette->getColor(Palette::PARTY); } else { - mNameColor = &guiPalette->getColor(Palette::PLAYER); - - const gcn::Color *color; - if (this == player_node) - { - color = &guiPalette->getColor(Palette::SELF); - } - else if (mIsGM) - { - color = &guiPalette->getColor(Palette::GM); - } - else if (mInParty) - { - color = &guiPalette->getColor(Palette::PARTY); - } - else - { - color = &guiPalette->getColor(Palette::PC); - } - - mName = new FlashText(name, - getPixelX(), - getPixelY(), - gcn::Graphics::CENTER, - color); + color = &guiPalette->getColor(Palette::PC); } + + mName = new FlashText(name, + getPixelX(), + getPixelY(), + gcn::Graphics::CENTER, + color); } + Being::setName(name); } @@ -191,6 +181,14 @@ void Player::setGender(Gender gender) } } +void Player::setGM(bool gm) +{ + mIsGM = gm; + + if (gm && mName) + mName->setColor(&guiPalette->getColor(Palette::GM)); +} + void Player::setHairStyle(int style, int color) { style = style < 0 ? mHairStyle : style % mNumberOfHairstyles; diff --git a/src/player.h b/src/player.h index 330d0c14..bb44f462 100644 --- a/src/player.h +++ b/src/player.h @@ -67,7 +67,7 @@ class Player : public Being /** * Triggers whether or not to show the name as a GM name. */ - virtual void setGM() { mIsGM = true; } + virtual void setGM(bool gm); /** * Sets the hair style and color for this player. |