From 1bd3c1b9db33cb9dff2570f4224fae73970d5895 Mon Sep 17 00:00:00 2001 From: David Athay Date: Thu, 3 Apr 2008 10:26:00 +0000 Subject: Added right click to invite to guild --- ChangeLog | 5 +++++ src/gui/popupmenu.cpp | 17 +++++++++++++++++ src/localplayer.cpp | 17 +++++++++++++++++ src/localplayer.h | 5 +++++ tmw.cbp | 5 +---- 5 files changed, 45 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index b423d66f..afdc9e59 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-04-02 David Athay + + * src/localplayer.cpp, src/gui/popupmenu.cpp, src/localplayer.h, + tmw.cbp: Added ability to right click a player and invite to guild. + 2008-04-01 David Athay * src/game.cpp, src/gui/guildwindow.h, src/gui/chat.cpp, diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index a1148379..dfd85815 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -81,6 +81,8 @@ void PopupMenu::showPopup(int x, int y, Being *being) mBrowserBox->addRow(strprintf(_("@@attack|Attack %s@@"), name.c_str())); //mBrowserBox->addRow("@@follow|Follow " + name + "@@"); //mBrowserBox->addRow("@@buddy|Add " + name + " to Buddy List@@"); + mBrowserBox->addRow(strprintf(_("@@guild|Invite %s@@"), name.c_str())); + //mBrowserBox->addRow(strprintf(_("@@party|Invite %s to join your party@@"), name.c_str())); } break; @@ -137,6 +139,21 @@ void PopupMenu::handleLink(const std::string& link) tradePartnerName = mBeing->getName(); } + // Guild action + else if (link == "guild" && + mBeing != NULL && + mBeing->getType() == Being::PLAYER) + { + player_node->invite(mBeing); + } + + /* + // Add player to your party + else if (link == "party") + { + } + */ + /* // Follow Player action else if (link == "follow") diff --git a/src/localplayer.cpp b/src/localplayer.cpp index aa3bb6ba..5cb77692 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -35,6 +35,7 @@ #include "log.h" #include "net/gameserver/player.h" +#include "net/chatserver/guild.h" #include "gui/gui.h" @@ -128,6 +129,22 @@ bool LocalPlayer::checkInviteRights(const std::string &guildName) return false; } +void LocalPlayer::invite(Being *being) +{ + // TODO: Allow user to choose which guild to invite being to + // For now, just invite to the first guild you have permissions to invite with + std::map::iterator itr = mGuilds.begin(); + std::map::iterator itr_end = mGuilds.end(); + for (; itr != itr_end; ++itr) + { + if (checkInviteRights(itr->second->getName())) + { + Net::ChatServer::Guild::invitePlayer(being->getName(), itr->second->getId()); + return; + } + } +} + void LocalPlayer::clearInventory() { mEquipment->clear(); diff --git a/src/localplayer.h b/src/localplayer.h index f325e19a..8ae8aa19 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -158,6 +158,11 @@ class LocalPlayer : public Player */ bool checkInviteRights(const std::string &guildName); + /** + * Invite a player to join guild + */ + void invite(Being* being); + void clearInventory(); void setInvItem(int index, int id, int amount); diff --git a/tmw.cbp b/tmw.cbp index 4b508fbf..d503d01d 100644 --- a/tmw.cbp +++ b/tmw.cbp @@ -104,9 +104,6 @@ - -