Skip to content

Commit

Permalink
* Now I can finally test party options, so they are successfully fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nate Fries committed Jun 14, 2009
1 parent fefa71a commit e89d132
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 94 deletions.
165 changes: 87 additions & 78 deletions mapui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,24 @@ bool MapUI::handlePopup(int x, int y)

void MapUI::makePopup(Popup* popup, void* owner, void* arg)
{
#define IS_LEADER(player, c, popup, s){\
if(c->getShield() == SHIELD_NONE){\
s.str("");\
s << gettext("Invite to Party");\
popup->addItem(s.str(),onInviteToParty,(void*)c->getID());\
}\
else if(c->getShield() == SHIELD_WHITEBLUE){\
s.str("");\
s << gettext("Revoke") << c->getName() << "'s " << gettext("Invitation");\
popup->addItem(s.str(), onRevokeInvite, (void*)c->getID());\
}\
else if(player != c){\
s.str("");\
s << gettext("Pass Leadership To") << " " << c->getName();\
popup->addItem(s.str(), onPassLeadership, (void*)c->getID());\
}\
}

MapUI *m = (MapUI*)(owner);
glictPos &pos = *((glictPos*)(arg));
uint32_t retx, rety, retz;
Expand All @@ -595,8 +613,6 @@ void MapUI::makePopup(Popup* popup, void* owner, void* arg)
m->m_lastRightclickTilePos.x = retx;
m->m_lastRightclickTilePos.y = rety;
m->m_lastRightclickTilePos.z = retz;


// TODO (ivucica#5#): if clicked on dark, right click must say "you cant see anything"
// but first we must implement lighting at all ... :)

Expand All @@ -622,60 +638,54 @@ void MapUI::makePopup(Popup* popup, void* owner, void* arg)
popup->addItem(s.str(), MapUI::onUse, m);
}



if (retx == playerpos.x && rety == playerpos.y && retz == playerpos.z)
{
popup->addItem("-",NULL,NULL);

s.str("");
s << gettext("Set Outfit") << "...";
popup->addItem(s.str(), GM_Gameworld::onSetOutfit);
popup->addItem("-",NULL,NULL);
popup->addItem(gettext("Copy Name"), GM_Gameworld::onCopyName, (void*)GlobalVariables::getPlayerID());
} else
// attack depends if there is a creature and we're NOT on player pos
if (const Creature *c = t->getTopCreature())
{
popup->addItem("-",NULL,NULL);


s.str("");
s << gettext("Attack") << " (Alt)";
popup->addItem(s.str(),onAttack,m);
m->m_popupCreatureID = c->getID();

s.str("");
s << gettext("Follow");
popup->addItem(s.str(),onFollow,m);
Creature* player = Creatures::getInstance().getPlayer();
if(c != player) {
popup->addItem("-",NULL,NULL);
s.str("");
s << gettext("Attack") << " (Alt)";
popup->addItem(s.str(),onAttack,m);
m->m_popupCreatureID = c->getID();

s.str("");
s << gettext("Follow");
popup->addItem(s.str(),onFollow,m);
}

if (c->isPlayer() && (c->getCurrentPos().z == GlobalVariables::getPlayerPosition().z))
{
popup->addItem("-",NULL,NULL);
if(c != player) {
s.str("");
s << gettext("Message to") << " " << c->getName();
popup->addItem(s.str(),onMessageTo,m);

s.str("");
s << gettext("Add to VIP list");
popup->addItem(s.str(),onUnimplemented);

s.str("");
s << gettext("Ignore") << " " << c->getName();
popup->addItem(s.str(),onUnimplemented);
}
else {
s.str("");
s << gettext("Set Outfit") << "...";
popup->addItem(s.str(), GM_Gameworld::onSetOutfit);
}

s.str("");
s << gettext("Message to") << " " << c->getName();
popup->addItem(s.str(),onMessageTo,m);

s.str("");
s << gettext("Add to VIP list");
popup->addItem(s.str(),onUnimplemented);

s.str("");
s << gettext("Ignore") << " " << c->getName();
popup->addItem(s.str(),onUnimplemented);

Creature* player = Creatures::getInstance().getPlayer();
switch(player->getShield())
switch(player->getShield())
{
case 0:
break;
case SHIELD_WHITEBLUE:
case SHIELD_NONE:
{
if(player != c && (c->getShield() == SHIELD_YELLOW_SHAREDEXP || c->getShield() == SHIELD_YELLOW_NOSHAREDEXP
|| c->getShield() == SHIELD_YELLOW_NOSHAREDEXP_BLINK || c->getShield() == SHIELD_YELLOW
|| c->getShield() == SHIELD_WHITEYELLOW)
){
if(player != c && c->getShield() == SHIELD_NONE){
s.str("");
s << gettext("Invite to Party");
popup->addItem(s.str(),onInviteToParty,(void*)c->getID());
}
else if(c->getShield() == SHIELD_WHITEYELLOW){
s.str("");
s << gettext("Accept") << c->getName() << "'s " << gettext("Invitation");
popup->addItem(s.str(), onAcceptInvite, (void*)c->getID());
Expand All @@ -684,52 +694,51 @@ void MapUI::makePopup(Popup* popup, void* owner, void* arg)
}
case SHIELD_YELLOW_SHAREDEXP: case SHIELD_YELLOW_NOSHAREDEXP_BLINK: case SHIELD_YELLOW_NOSHAREDEXP:
{
ClientVersion_t ver = options.protocol;
if(ver == CLIENT_VERSION_AUTO) {
ver = ProtocolConfig::detectVersion();
}
if((player == c) && (ver >= CLIENT_VERSION_781)){
if(player == c){
s.str("");
s << gettext("Disable Shaded Experience");
popup->addItem(s.str(), onSharedExp, (void*)false);
s << gettext("Leave Party");
popup->addItem(s.str(), onLeaveParty, (void*)c->getID());

ClientVersion_t ver = options.protocol;
if(ver == CLIENT_VERSION_AUTO) {
ver = ProtocolConfig::detectVersion();
}
if(ver >= CLIENT_VERSION_781){
s.str("");
s << gettext("Disable Shaded Experience");
popup->addItem(s.str(), onSharedExp, (void*)false);
}
}
// NOTE (nfries88): lack of break; is intentional!
else IS_LEADER(player, c, popup, s)
break;
}
case SHIELD_YELLOW:
{
ClientVersion_t ver = options.protocol;
if(ver == CLIENT_VERSION_AUTO) {
ver = ProtocolConfig::detectVersion();
}
if((player == c) && (ver >= CLIENT_VERSION_781)){
s.str("");
s << gettext("Enable Shaded Experience");
popup->addItem(s.str(), onSharedExp, (void*)true);
}
if(player != c){
if(player == c){
s.str("");
s << gettext("Pass Leadership To") << " " << c->getName();
popup->addItem(s.str(), onPassLeadership, (void*)c->getID());
s << gettext("Leave Party");
popup->addItem(s.str(), onLeaveParty, (void*)c->getID());

ClientVersion_t ver = options.protocol;
if(ver == CLIENT_VERSION_AUTO) {
ver = ProtocolConfig::detectVersion();
}
if(ver >= CLIENT_VERSION_781){
s.str("");
s << gettext("Enable Shaded Experience");
popup->addItem(s.str(), onSharedExp, (void*)true);
}
}
// NOTE (nfries88): lack of break; is intentional!
else IS_LEADER(player, c, popup, s)
break;
}
default:
default: // all the blue ones
{
if(player == c){
s.str("");
s << gettext("Leave Party");
popup->addItem(s.str(), onLeaveParty, (void*)c->getID());
}
else if(c->getShield() == SHIELD_NONE){
s.str("");
s << gettext("Invite to Party");
popup->addItem(s.str(),onInviteToParty,(void*)c->getID());
}
else if(c->getShield() == SHIELD_WHITEBLUE){
s.str("");
s << gettext("Revoke") << c->getName() << "'s " << gettext("Invitation");
popup->addItem(s.str(), onRevokeInvite, (void*)c->getID());
}
break;
}
}
Expand Down
37 changes: 21 additions & 16 deletions ui/battlewindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,36 +215,41 @@ void winBattle_t::makeConsolePopup(Popup* popup, void* owner, void* arg)
Creature* player = Creatures::getInstance().getPlayer();
switch(player->getShield())
{
case 0:
break;
case SHIELD_WHITEBLUE:
case SHIELD_NONE:
{
s.str("");
s << gettext("Accept") << c->getName() << "'s " << gettext("Invitation");
popup->addItem(s.str(), onAcceptInvite, (void*)c->getID());
if(c->getShield() == SHIELD_NONE){
s.str("");
s << gettext("Invite to Party");
popup->addItem(s.str(),onInviteToParty,(void*)c->getID());
}
else if(c->getShield() == SHIELD_WHITEYELLOW){
s.str("");
s << gettext("Accept") << c->getName() << "'s " << gettext("Invitation");
popup->addItem(s.str(), onAcceptInvite, (void*)c->getID());
}
break;
}
case SHIELD_YELLOW:
case SHIELD_YELLOW: case SHIELD_YELLOW_SHAREDEXP:
case SHIELD_YELLOW_NOSHAREDEXP_BLINK: case SHIELD_YELLOW_NOSHAREDEXP:
{
if(c->getShield() == SHIELD_WHITEBLUE){
s.str("");
s << gettext("Revoke") << c->getName() << "'s " << gettext("Invitation");
popup->addItem(s.str(), onRevokeInvite, (void*)c->getID());
break;
}

s.str("");
s << gettext("Pass Leadership To") << " " << c->getName();
popup->addItem(s.str(), onPassLeadership, (void*)c->getID());
// NOTE (nfries88): lack of break; is intentional!
}
default:
{
if(c->getShield() == SHIELD_NONE){
else if(c->getShield() == SHIELD_NONE){
s.str("");
s << gettext("Invite to Party");
popup->addItem(s.str(),onInviteToParty,(void*)c->getID());
}
else if(player->getShield() != SHIELD_WHITEYELLOW){
// NOTE (nfries88): Because of location, this will only affect players in party.
s.str("");
s << gettext("Pass Leadership To") << " " << c->getName();
popup->addItem(s.str(), onPassLeadership, (void*)c->getID());
}
break;
}
}
}
Expand Down

0 comments on commit e89d132

Please sign in to comment.