summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-09-16 00:57:59 +0300
committerAndrei Karas <akaras@inbox.ru>2011-09-16 00:57:59 +0300
commitae9577c6a52a1e4eb1ff647905672ca840ad3e44 (patch)
tree172eeedbaea5004a92f100dee37a43ffb8d27672 /src/gui
parentc91bc5201596eda73f9df2222d76d9f413426a85 (diff)
downloadmanaplus-ae9577c6a52a1e4eb1ff647905672ca840ad3e44.tar.gz
manaplus-ae9577c6a52a1e4eb1ff647905672ca840ad3e44.tar.bz2
manaplus-ae9577c6a52a1e4eb1ff647905672ca840ad3e44.tar.xz
manaplus-ae9577c6a52a1e4eb1ff647905672ca840ad3e44.zip
Simplify menu creation in popupmenu class.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/popupmenu.cpp546
-rw-r--r--src/gui/widgets/browserbox.cpp5
-rw-r--r--src/gui/widgets/browserbox.h5
3 files changed, 227 insertions, 329 deletions
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index 711a0e250..715b1d983 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -129,60 +129,45 @@ void PopupMenu::showPopup(int x, int y, Being *being)
{
case ActorSprite::PLAYER:
{
- mBrowserBox->addRow(strprintf("@@trade|%s@@", _("Trade")));
- mBrowserBox->addRow(strprintf("@@attack|%s@@", _("Attack")));
- mBrowserBox->addRow(strprintf("@@whisper|%s@@", _("Whisper")));
+ mBrowserBox->addRow("trade", _("Trade"));
+ mBrowserBox->addRow("attack", _("Attack"));
+ mBrowserBox->addRow("whisper", _("Whisper"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@heal|%s@@", _("Heal")));
+ mBrowserBox->addRow("heal", _("Heal"));
mBrowserBox->addRow("##3---");
switch (player_relations.getRelation(name))
{
case PlayerRelation::NEUTRAL:
- mBrowserBox->addRow(strprintf(
- "@@friend|%s@@", _("Be friend")));
- mBrowserBox->addRow(strprintf(
- "@@disregard|%s@@", _("Disregard")));
- mBrowserBox->addRow(strprintf(
- "@@ignore|%s@@", _("Ignore")));
- mBrowserBox->addRow(strprintf(
- "@@erase|%s@@", _("Erase")));
+ mBrowserBox->addRow("friend", _("Be friend"));
+ mBrowserBox->addRow("disregard", _("Disregard"));
+ mBrowserBox->addRow("ignore", _("Ignore"));
+ mBrowserBox->addRow("erase", _("Erase"));
break;
case PlayerRelation::FRIEND:
- mBrowserBox->addRow(strprintf(
- "@@disregard|%s@@", _("Disregard")));
- mBrowserBox->addRow(strprintf(
- "@@ignore|%s@@", _("Ignore")));
- mBrowserBox->addRow(strprintf(
- "@@erase|%s@@", _("Erase")));
+ mBrowserBox->addRow("disregard", _("Disregard"));
+ mBrowserBox->addRow("ignore", _("Ignore"));
+ mBrowserBox->addRow("erase", _("Erase"));
break;
case PlayerRelation::DISREGARDED:
- mBrowserBox->addRow(strprintf(
- "@@unignore|%s@@", _("Unignore")));
- mBrowserBox->addRow(strprintf(
- "@@ignore|%s@@", _("Completely ignore")));
- mBrowserBox->addRow(strprintf(
- "@@erase|%s@@", _("Erase")));
+ mBrowserBox->addRow("unignore", _("Unignore"));
+ mBrowserBox->addRow("ignore", _("Completely ignore"));
+ mBrowserBox->addRow("erase", _("Erase"));
break;
case PlayerRelation::IGNORED:
- mBrowserBox->addRow(strprintf(
- "@@unignore|%s@@", _("Unignore")));
- mBrowserBox->addRow(strprintf(
- "@@erase|%s@@", _("Erase")));
+ mBrowserBox->addRow("unignore", _("Unignore"));
+ mBrowserBox->addRow("erase", _("Erase"));
break;
case PlayerRelation::ERASED:
- mBrowserBox->addRow(strprintf(
- "@@unignore|%s@@", _("Unignore")));
- mBrowserBox->addRow(strprintf(
- "@@disregard|%s@@", _("Disregard")));
- mBrowserBox->addRow(strprintf(
- "@@ignore|%s@@", _("Completely ignore")));
+ mBrowserBox->addRow("unignore", _("Unignore"));
+ mBrowserBox->addRow("disregard", _("Disregard"));
+ mBrowserBox->addRow("ignore", _("Completely ignore"));
break;
default:
@@ -190,9 +175,8 @@ void PopupMenu::showPopup(int x, int y, Being *being)
}
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@follow|%s@@", _("Follow")));
- mBrowserBox->addRow(strprintf(
- "@@imitation|%s@@", _("Imitation")));
+ mBrowserBox->addRow("follow", _("Follow"));
+ mBrowserBox->addRow("imitation", _("Imitation"));
if (player_node->isInParty())
{
@@ -201,13 +185,12 @@ void PopupMenu::showPopup(int x, int y, Being *being)
if (player_node->getParty()->getName()
!= being->getPartyName())
{
- mBrowserBox->addRow(strprintf(
- "@@party|%s@@", _("Invite to party")));
+ mBrowserBox->addRow("party", _("Invite to party"));
}
else
{
- mBrowserBox->addRow(strprintf(
- "@@kick party|%s@@", _("Kick from party")));
+ mBrowserBox->addRow("kick party",
+ _("Kick from party"));
}
mBrowserBox->addRow("##3---");
}
@@ -221,8 +204,8 @@ void PopupMenu::showPopup(int x, int y, Being *being)
{
if (guild1->getId() == guild2->getId())
{
- mBrowserBox->addRow(strprintf(
- "@@guild-kick|%s@@", _("Kick from guild")));
+ mBrowserBox->addRow("guild-kick",
+ _("Kick from guild"));
if (guild2->getServerGuild())
{
mBrowserBox->addRow(strprintf(
@@ -233,8 +216,8 @@ void PopupMenu::showPopup(int x, int y, Being *being)
}
else if (guild2->getMember(mNick))
{
- mBrowserBox->addRow(strprintf(
- "@@guild-kick|%s@@", _("Kick from guild")));
+ mBrowserBox->addRow("guild-kick",
+ _("Kick from guild"));
if (guild2->getServerGuild())
{
mBrowserBox->addRow(strprintf(
@@ -247,8 +230,7 @@ void PopupMenu::showPopup(int x, int y, Being *being)
if (guild2->getServerGuild()
|| (guildManager && guildManager->havePower()))
{
- mBrowserBox->addRow(strprintf(
- "@@guild|%s@@", _("Invite to guild")));
+ mBrowserBox->addRow("guild", _("Invite to guild"));
}
}
}
@@ -256,16 +238,13 @@ void PopupMenu::showPopup(int x, int y, Being *being)
if (player_node->isGM())
{
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf(
- "@@admin-kick|%s@@", _("Kick player")));
+ mBrowserBox->addRow("admin-kick", _("Kick player"));
}
- mBrowserBox->addRow(strprintf("@@nuke|%s@@", _("Nuke")));
- mBrowserBox->addRow(strprintf("@@move|%s@@", _("Move")));
- mBrowserBox->addRow(strprintf("@@items|%s@@",
- _("Show Items")));
- mBrowserBox->addRow(strprintf("@@undress|%s@@", _("Undress")));
- mBrowserBox->addRow(strprintf(
- "@@addcomment|%s@@", _("Add comment")));
+ mBrowserBox->addRow("nuke", _("Nuke"));
+ mBrowserBox->addRow("move", _("Move"));
+ mBrowserBox->addRow("items", _("Show Items"));
+ mBrowserBox->addRow("undress", _("Undress"));
+ mBrowserBox->addRow("addcomment", _("Add comment"));
if (player_relations.getDefault() & PlayerRelation::TRADE)
{
@@ -274,18 +253,14 @@ void PopupMenu::showPopup(int x, int y, Being *being)
{
if (being->isShopEnabled())
{
- mBrowserBox->addRow(strprintf(
- "@@buy|%s@@", _("Buy")));
- mBrowserBox->addRow(strprintf(
- "@@sell|%s@@", _("Sell")));
+ mBrowserBox->addRow("buy", _("Buy"));
+ mBrowserBox->addRow("sell", _("Sell"));
}
}
else
{
- mBrowserBox->addRow(strprintf(
- "@@buy|%s@@", _("Buy (?)")));
- mBrowserBox->addRow(strprintf(
- "@@sell|%s@@", _("Sell (?)")));
+ mBrowserBox->addRow("buy", _("Buy (?)"));
+ mBrowserBox->addRow("sell", _("Sell (?)"));
}
}
}
@@ -294,26 +269,23 @@ void PopupMenu::showPopup(int x, int y, Being *being)
case ActorSprite::NPC:
// NPCs can be talked to (single option, candidate for removal
// unless more options would be added)
- mBrowserBox->addRow(strprintf("@@talk|%s@@", _("Talk")));
-
- mBrowserBox->addRow(strprintf("@@buy|%s@@", _("Buy")));
- mBrowserBox->addRow(strprintf("@@sell|%s@@", _("Sell")));
+ mBrowserBox->addRow("talk", _("Talk"));
+ mBrowserBox->addRow("buy", _("Buy"));
+ mBrowserBox->addRow("sell", _("Sell"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@move|%s@@", _("Move")));
- mBrowserBox->addRow(strprintf("@@addcomment|%s@@",
- _("Add comment")));
+ mBrowserBox->addRow("move", _("Move"));
+ mBrowserBox->addRow("addcomment", _("Add comment"));
break;
case ActorSprite::MONSTER:
{
// Monsters can be attacked
- mBrowserBox->addRow(strprintf("@@attack|%s@@", _("Attack")));
+ mBrowserBox->addRow("attack", _("Attack"));
if (player_node->isGM())
{
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf(
- "@@admin-kick|%s@@", _("Kick")));
+ mBrowserBox->addRow("admin-kick", _("Kick"));
}
if (config.getBoolValue("enableAttackFilter"))
@@ -323,19 +295,17 @@ void PopupMenu::showPopup(int x, int y, Being *being)
|| actorSpriteManager->isInIgnoreAttackList(name)
|| actorSpriteManager->isInPriorityAttackList(name))
{
- mBrowserBox->addRow(strprintf("@@remove attack|%s@@",
- _("Remove from attack list")));
+ mBrowserBox->addRow("remove attack",
+ _("Remove from attack list"));
}
else
{
- mBrowserBox->addRow(strprintf(
- "@@add attack priority|%s@@",
- _("Add to priority attack list")));
- mBrowserBox->addRow(strprintf(
- "@@add attack|%s@@", _("Add to attack list")));
- mBrowserBox->addRow(strprintf(
- "@@add attack ignore|%s@@",
- _("Add to ignore list")));
+ mBrowserBox->addRow("add attack priority",
+ _("Add to priority attack list"));
+ mBrowserBox->addRow("add attack",
+ _("Add to attack list"));
+ mBrowserBox->addRow("add attack ignore",
+ _("Add to ignore list"));
}
}
}
@@ -348,10 +318,10 @@ void PopupMenu::showPopup(int x, int y, Being *being)
/* Other beings aren't interesting... */
return;
}
- mBrowserBox->addRow(strprintf("@@name|%s@@", _("Add name to chat")));
+ mBrowserBox->addRow("name", _("Add name to chat"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -372,7 +342,7 @@ void PopupMenu::showPopup(int x, int y, std::vector<Being*> &beings)
}
}
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -390,42 +360,39 @@ void PopupMenu::showPlayerPopup(int x, int y, std::string nick)
mBrowserBox->addRow(name);
- mBrowserBox->addRow(strprintf("@@whisper|%s@@", _("Whisper")));
+ mBrowserBox->addRow("whisper", _("Whisper"));
mBrowserBox->addRow("##3---");
switch (player_relations.getRelation(name))
{
case PlayerRelation::NEUTRAL:
- mBrowserBox->addRow(strprintf("@@friend|%s@@", _("Be friend")));
- mBrowserBox->addRow(strprintf(
- "@@disregard|%s@@", _("Disregard")));
- mBrowserBox->addRow(strprintf("@@ignore|%s@@", _("Ignore")));
- mBrowserBox->addRow(strprintf("@@erase|%s@@", _("Erase")));
+ mBrowserBox->addRow("friend", _("Be friend"));
+ mBrowserBox->addRow("disregard", _("Disregard"));
+ mBrowserBox->addRow("ignore", _("Ignore"));
+ mBrowserBox->addRow("erase", _("Erase"));
break;
case PlayerRelation::FRIEND:
- mBrowserBox->addRow(strprintf("@@disregard|%s@@", _("Disregard")));
- mBrowserBox->addRow(strprintf("@@ignore|%s@@", _("Ignore")));
- mBrowserBox->addRow(strprintf("@@erase|%s@@", _("Erase")));
+ mBrowserBox->addRow("disregard", _("Disregard"));
+ mBrowserBox->addRow("ignore", _("Ignore"));
+ mBrowserBox->addRow("erase", _("Erase"));
break;
case PlayerRelation::DISREGARDED:
- mBrowserBox->addRow(strprintf("@@unignore|%s@@", _("Unignore")));
- mBrowserBox->addRow(strprintf(
- "@@ignore|%s@@", _("Completely ignore")));
- mBrowserBox->addRow(strprintf("@@erase|%s@@", _("Erase")));
+ mBrowserBox->addRow("unignore", _("Unignore"));
+ mBrowserBox->addRow("ignore", _("Completely ignore"));
+ mBrowserBox->addRow("erase", _("Erase"));
break;
case PlayerRelation::IGNORED:
- mBrowserBox->addRow(strprintf("@@unignore|%s@@", _("Unignore")));
- mBrowserBox->addRow(strprintf("@@erase|%s@@", _("Erase")));
+ mBrowserBox->addRow("unignore", _("Unignore"));
+ mBrowserBox->addRow("erase", _("Erase"));
break;
case PlayerRelation::ERASED:
- mBrowserBox->addRow(strprintf("@@unignore|%s@@", _("Unignore")));
- mBrowserBox->addRow(strprintf("@@disregard|%s@@", _("Disregard")));
- mBrowserBox->addRow(strprintf(
- "@@ignore|%s@@", _("Completely ignore")));
+ mBrowserBox->addRow("unignore", _("Unignore"));
+ mBrowserBox->addRow("disregard", _("Disregard"));
+ mBrowserBox->addRow("ignore", _("Completely ignore"));
break;
default:
@@ -433,9 +400,9 @@ void PopupMenu::showPlayerPopup(int x, int y, std::string nick)
}
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@follow|%s@@", _("Follow")));
- mBrowserBox->addRow(strprintf("@@imitation|%s@@", _("Imitation")));
- mBrowserBox->addRow(strprintf("@@addcomment|%s@@", _("Add comment")));
+ mBrowserBox->addRow("follow", _("Follow"));
+ mBrowserBox->addRow("imitation", _("Imitation"));
+ mBrowserBox->addRow("addcomment", _("Add comment"));
if (player_node->isInParty())
{
@@ -445,15 +412,11 @@ void PopupMenu::showPlayerPopup(int x, int y, std::string nick)
PartyMember *member = party->getMember(mNick);
if (member)
{
- mBrowserBox->addRow(strprintf(
- "@@kick party|%s@@", _("Kick from party")));
+ mBrowserBox->addRow("kick party", _("Kick from party"));
mBrowserBox->addRow("##3---");
PartyMember *o = party->getMember(player_node->getName());
if (o && member->getMap() == o->getMap())
- {
- mBrowserBox->addRow(strprintf(
- "@@move|%s@@", _("Move")));
- }
+ mBrowserBox->addRow("move", _("Move"));
}
}
}
@@ -466,8 +429,7 @@ void PopupMenu::showPlayerPopup(int x, int y, std::string nick)
if (guild2->getServerGuild() || (guildManager
&& guildManager->havePower()))
{
- mBrowserBox->addRow(strprintf(
- "@@guild-kick|%s@@", _("Kick from guild")));
+ mBrowserBox->addRow("guild-kick", _("Kick from guild"));
}
if (guild2->getServerGuild())
{
@@ -480,8 +442,7 @@ void PopupMenu::showPlayerPopup(int x, int y, std::string nick)
if (guild2->getServerGuild() || (guildManager
&& guildManager->havePower()))
{
- mBrowserBox->addRow(strprintf(
- "@@guild|%s@@", _("Invite to guild")));
+ mBrowserBox->addRow("guild", _("Invite to guild"));
}
}
}
@@ -489,17 +450,16 @@ void PopupMenu::showPlayerPopup(int x, int y, std::string nick)
mBrowserBox->addRow("##3---");
if (player_relations.getDefault() & PlayerRelation::TRADE)
{
- mBrowserBox->addRow(strprintf("@@buy|%s@@", _("Buy (?)")));
- mBrowserBox->addRow(strprintf("@@sell|%s@@", _("Sell (?)")));
+ mBrowserBox->addRow("buy", _("Buy (?)"));
+ mBrowserBox->addRow("sell", _("Sell (?)"));
}
- mBrowserBox->addRow(strprintf("@@name|%s@@", _("Add name to chat")));
+ mBrowserBox->addRow("name", _("Add name to chat"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
-
}
void PopupMenu::showPopup(int x, int y, FloorItem *floorItem)
@@ -519,11 +479,11 @@ void PopupMenu::showPopup(int x, int y, FloorItem *floorItem)
name = info.getName();
mBrowserBox->addRow(name);
- mBrowserBox->addRow(strprintf("@@pickup|%s@@", _("Pick up")));
- mBrowserBox->addRow(strprintf("@@chat|%s@@", _("Add to chat")));
+ mBrowserBox->addRow("pickup", _("Pick up"));
+ mBrowserBox->addRow("chat", _("Add to chat"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -538,16 +498,16 @@ void PopupMenu::showPopup(int x, int y, MapItem *mapItem)
mBrowserBox->clearRows();
mBrowserBox->addRow(_("Map Item"));
- mBrowserBox->addRow(strprintf("@@rename map|%s@@", _("Rename")));
- mBrowserBox->addRow(strprintf("@@remove map|%s@@", _("Remove")));
+ mBrowserBox->addRow("rename map", _("Rename"));
+ mBrowserBox->addRow("remove map", _("Remove"));
if (player_node && player_node->isGM())
{
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@warp map|%s@@", _("Warp")));
+ mBrowserBox->addRow("warp map", _("Warp"));
}
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -557,11 +517,10 @@ void PopupMenu::showOutfitsPopup(int x, int y)
mBrowserBox->clearRows();
mBrowserBox->addRow(_("Outfits"));
- mBrowserBox->addRow(strprintf(
- "@@load old outfits|%s@@", _("Load old outfits")));
+ mBrowserBox->addRow("load old outfits", _("Load old outfits"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -575,12 +534,11 @@ void PopupMenu::showSpellPopup(int x, int y, TextCommand *cmd)
mSpell = cmd;
mBrowserBox->addRow(_("Spells"));
- mBrowserBox->addRow(strprintf(
- "@@load old spells|%s@@", _("Load old spells")));
- mBrowserBox->addRow(strprintf("@@edit spell|%s@@", _("Edit spell")));
+ mBrowserBox->addRow("load old spells", _("Load old spells"));
+ mBrowserBox->addRow("edit spell", _("Edit spell"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -595,46 +553,28 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab)
mBrowserBox->clearRows();
if (tab->getType() == ChatTab::TAB_WHISPER)
- mBrowserBox->addRow(strprintf("@@chat close|%s@@", _("Close")));
+ mBrowserBox->addRow("chat close", _("Close"));
- mBrowserBox->addRow(strprintf("@@chat clear|%s@@", _("Clear")));
+ mBrowserBox->addRow("chat clear", _("Clear"));
mBrowserBox->addRow("##3---");
if (tab->getAllowHighlight())
- {
- mBrowserBox->addRow(strprintf("@@disable highlight|%s@@",
- _("Disable highlight")));
- }
+ mBrowserBox->addRow("disable highlight", _("Disable highlight"));
else
- {
- mBrowserBox->addRow(strprintf("@@enable highlight|%s@@",
- _("Enable highlight")));
- }
+ mBrowserBox->addRow("enable highlight", _("Enable highlight"));
if (tab->getRemoveNames())
- {
- mBrowserBox->addRow(strprintf("@@dont remove name|%s@@",
- _("Don't remove name")));
- }
+ mBrowserBox->addRow("dont remove name", _("Don't remove name"));
else
- {
- mBrowserBox->addRow(strprintf("@@remove name|%s@@",
- _("Remove name")));
- }
+ mBrowserBox->addRow("remove name", _("Remove name"));
if (tab->getNoAway())
- {
- mBrowserBox->addRow(strprintf("@@enable away|%s@@",
- _("Enable away")));
- }
+ mBrowserBox->addRow("enable away", _("Enable away"));
else
- {
- mBrowserBox->addRow(strprintf("@@disable away|%s@@",
- _("Disable away")));
- }
+ mBrowserBox->addRow("disable away", _("Disable away"));
mBrowserBox->addRow("##3---");
if (tab->getType() == ChatTab::TAB_PARTY)
{
- mBrowserBox->addRow(strprintf("@@leave party|%s@@", _("Leave")));
+ mBrowserBox->addRow("leave party", _("Leave"));
mBrowserBox->addRow("##3---");
}
@@ -652,55 +592,44 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab)
mNick = being->getName();
mType = being->getType();
- mBrowserBox->addRow(strprintf("@@trade|%s@@", _("Trade")));
- mBrowserBox->addRow(strprintf("@@attack|%s@@", _("Attack")));
+ mBrowserBox->addRow("trade", _("Trade"));
+ mBrowserBox->addRow("attack", _("Attack"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@heal|%s@@", _("Heal")));
+ mBrowserBox->addRow("heal", _("Heal"));
mBrowserBox->addRow("##3---");
switch (player_relations.getRelation(name))
{
case PlayerRelation::NEUTRAL:
- mBrowserBox->addRow(strprintf(
- "@@friend|%s@@", _("Be friend")));
- mBrowserBox->addRow(strprintf(
- "@@disregard|%s@@", _("Disregard")));
- mBrowserBox->addRow(strprintf(
- "@@ignore|%s@@", _("Ignore")));
- mBrowserBox->addRow(strprintf("@@erase|%s@@", _("Erase")));
+ mBrowserBox->addRow("friend", _("Be friend"));
+ mBrowserBox->addRow("disregard", _("Disregard"));
+ mBrowserBox->addRow("ignore", _("Ignore"));
+ mBrowserBox->addRow("erase", _("Erase"));
break;
case PlayerRelation::FRIEND:
- mBrowserBox->addRow(strprintf(
- "@@disregard|%s@@", _("Disregard")));
- mBrowserBox->addRow(strprintf(
- "@@ignore|%s@@", _("Ignore")));
- mBrowserBox->addRow(strprintf("@@erase|%s@@", _("Erase")));
+ mBrowserBox->addRow("disregard", _("Disregard"));
+ mBrowserBox->addRow("ignore", _("Ignore"));
+ mBrowserBox->addRow("erase", _("Erase"));
break;
case PlayerRelation::DISREGARDED:
- mBrowserBox->addRow(strprintf(
- "@@unignore|%s@@", _("Unignore")));
- mBrowserBox->addRow(strprintf(
- "@@ignore|%s@@", _("Completely ignore")));
- mBrowserBox->addRow(strprintf("@@erase|%s@@", _("Erase")));
+ mBrowserBox->addRow("unignore", _("Unignore"));
+ mBrowserBox->addRow("ignore", _("Completely ignore"));
+ mBrowserBox->addRow("erase", _("Erase"));
break;
case PlayerRelation::IGNORED:
- mBrowserBox->addRow(strprintf(
- "@@unignore|%s@@", _("Unignore")));
- mBrowserBox->addRow(strprintf("@@erase|%s@@", _("Erase")));
+ mBrowserBox->addRow("unignore", _("Unignore"));
+ mBrowserBox->addRow("erase", _("Erase"));
break;
case PlayerRelation::ERASED:
- mBrowserBox->addRow(strprintf(
- "@@unignore|%s@@", _("Unignore")));
- mBrowserBox->addRow(strprintf(
- "@@disregard|%s@@", _("Disregard")));
- mBrowserBox->addRow(strprintf(
- "@@ignore|%s@@", _("Completely ignore")));
+ mBrowserBox->addRow("unignore", _("Unignore"));
+ mBrowserBox->addRow("disregard", _("Disregard"));
+ mBrowserBox->addRow("ignore", _("Completely ignore"));
break;
default:
@@ -708,13 +637,12 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab)
}
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@follow|%s@@", _("Follow")));
- mBrowserBox->addRow(strprintf("@@imitation|%s@@", _("Imitation")));
- mBrowserBox->addRow(strprintf("@@move|%s@@", _("Move")));
- mBrowserBox->addRow(strprintf("@@items|%s@@", _("Show Items")));
- mBrowserBox->addRow(strprintf("@@undress|%s@@", _("Undress")));
- mBrowserBox->addRow(strprintf(
- "@@addcomment|%s@@", _("Add comment")));
+ mBrowserBox->addRow("follow", _("Follow"));
+ mBrowserBox->addRow("imitation", _("Imitation"));
+ mBrowserBox->addRow("move", _("Move"));
+ mBrowserBox->addRow("items", _("Show Items"));
+ mBrowserBox->addRow("undress", _("Undress"));
+ mBrowserBox->addRow("addcomment", _("Add comment"));
if (player_relations.getDefault() & PlayerRelation::TRADE)
{
@@ -723,17 +651,14 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab)
{
if (being->isShopEnabled())
{
- mBrowserBox->addRow(strprintf(
- "@@buy|%s@@", _("Buy")));
- mBrowserBox->addRow(strprintf(
- "@@sell|%s@@", _("Sell")));
+ mBrowserBox->addRow("buy", _("Buy"));
+ mBrowserBox->addRow("sell", _("Sell"));
}
}
else
{
- mBrowserBox->addRow(strprintf("@@buy|%s@@", _("Buy (?)")));
- mBrowserBox->addRow(strprintf(
- "@@sell|%s@@", _("Sell (?)")));
+ mBrowserBox->addRow("buy", _("Buy (?)"));
+ mBrowserBox->addRow("sell", _("Sell (?)"));
}
}
@@ -745,13 +670,12 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab)
{
if (!player_node->getParty()->isMember(wTab->getNick()))
{
- mBrowserBox->addRow(
- strprintf("@@party|%s@@", _("Invite to party")));
+ mBrowserBox->addRow("party", _("Invite to party"));
}
else
{
- mBrowserBox->addRow(strprintf(
- "@@kick party|%s@@", _("Kick from party")));
+ mBrowserBox->addRow("kick party",
+ _("Kick from party"));
}
mBrowserBox->addRow("##3---");
}
@@ -782,8 +706,7 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab)
if (guild2->getServerGuild() || (guildManager
&& guildManager->havePower()))
{
- mBrowserBox->addRow(strprintf(
- "@@guild|%s@@", _("Invite to guild")));
+ mBrowserBox->addRow("guild", _("Invite to guild"));
}
}
}
@@ -793,8 +716,8 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab)
mNick = name;
mType = Being::PLAYER;
- mBrowserBox->addRow(strprintf("@@follow|%s@@", _("Follow")));
- mBrowserBox->addRow(strprintf("@@imitation|%s@@", _("Imitation")));
+ mBrowserBox->addRow("follow", _("Follow"));
+ mBrowserBox->addRow("imitation", _("Imitation"));
if (player_node->isInParty())
{
@@ -803,16 +726,12 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab)
{
PartyMember *m = party->getMember(mNick);
if (m)
- {
- mBrowserBox->addRow(strprintf(
- "@@move|%s@@", _("Move")));
- }
+ mBrowserBox->addRow("move", _("Move"));
}
}
- mBrowserBox->addRow(strprintf("@@items|%s@@", _("Show Items")));
- mBrowserBox->addRow(strprintf("@@undress|%s@@", _("Undress")));
- mBrowserBox->addRow(strprintf(
- "@@addcomment|%s@@", _("Add comment")));
+ mBrowserBox->addRow("items", _("Show Items"));
+ mBrowserBox->addRow("undress", _("Undress"));
+ mBrowserBox->addRow("addcomment", _("Add comment"));
if (player_relations.getDefault() & PlayerRelation::TRADE)
{
@@ -821,23 +740,20 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab)
{
if (being->isShopEnabled())
{
- mBrowserBox->addRow(strprintf(
- "@@buy|%s@@", _("Buy")));
- mBrowserBox->addRow(strprintf(
- "@@sell|%s@@", _("Sell")));
+ mBrowserBox->addRow("buy", _("Buy"));
+ mBrowserBox->addRow("sell", _("Sell"));
}
}
else
{
- mBrowserBox->addRow(strprintf("@@buy|%s@@", _("Buy (?)")));
- mBrowserBox->addRow(strprintf(
- "@@sell|%s@@", _("Sell (?)")));
+ mBrowserBox->addRow("buy", _("Buy (?)"));
+ mBrowserBox->addRow("sell", _("Sell (?)"));
}
}
mBrowserBox->addRow("##3---");
}
}
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -861,7 +777,7 @@ void PopupMenu::showChangePos(int x, int y)
mBrowserBox->addRow(strprintf("@@guild-pos-%d|%s@@",
itr->first, itr->second.c_str()));
}
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -1722,36 +1638,25 @@ void PopupMenu::showPopup(Window *parent, int x, int y, Item *item,
{
if (tradeWindow && tradeWindow->isVisible())
{
- mBrowserBox->addRow(strprintf("@@addtrade|%s@@",
- _("Add to trade")));
+ mBrowserBox->addRow("addtrade", _("Add to trade"));
if (cnt > 1)
{
if (cnt > 10)
- {
- mBrowserBox->addRow(strprintf("@@addtrade 10|%s@@",
- _("Add to trade 10")));
- }
- mBrowserBox->addRow(strprintf("@@addtrade half|%s@@",
- _("Add to trade half")));
- mBrowserBox->addRow(strprintf("@@addtrade all|%s@@",
- _("Add to trade all")));
+ mBrowserBox->addRow("addtrade 10", _("Add to trade 10"));
+ mBrowserBox->addRow("addtrade half", _("Add to trade half"));
+ mBrowserBox->addRow("addtrade all", _("Add to trade all"));
}
mBrowserBox->addRow("##3---");
}
if (InventoryWindow::isStorageActive())
{
- mBrowserBox->addRow(strprintf("@@store|%s@@", _("Store")));
+ mBrowserBox->addRow("store", _("Store"));
if (cnt > 1)
{
if (cnt > 10)
- {
- mBrowserBox->addRow(strprintf("@@store 10|%s@@",
- _("Store 10")));
- }
- mBrowserBox->addRow(strprintf("@@store half|%s@@",
- _("Store half")));
- mBrowserBox->addRow(strprintf("@@store all|%s@@",
- _("Store all")));
+ mBrowserBox->addRow("store 10", _("Store 10"));
+ mBrowserBox->addRow("store half", _("Store half"));
+ mBrowserBox->addRow("store all", _("Store all"));
}
mBrowserBox->addRow("##3---");
}
@@ -1759,48 +1664,45 @@ void PopupMenu::showPopup(Window *parent, int x, int y, Item *item,
if (item->isEquipment())
{
if (item->isEquipped())
- mBrowserBox->addRow(strprintf("@@use|%s@@", _("Unequip")));
+ mBrowserBox->addRow("use", _("Unequip"));
else
- mBrowserBox->addRow(strprintf("@@use|%s@@", _("Equip")));
+ mBrowserBox->addRow("use", _("Equip"));
}
else
- mBrowserBox->addRow(strprintf("@@use|%s@@", _("Use")));
+ {
+ mBrowserBox->addRow("use", _("Use"));
+ }
if (cnt > 1)
{
- mBrowserBox->addRow(strprintf("@@drop|%s@@", _("Drop...")));
- mBrowserBox->addRow(strprintf("@@drop all|%s@@", _("Drop all")));
+ mBrowserBox->addRow("drop", _("Drop..."));
+ mBrowserBox->addRow("drop all", _("Drop all"));
}
else
{
- mBrowserBox->addRow(strprintf("@@drop|%s@@", _("Drop")));
+ mBrowserBox->addRow("drop", _("Drop"));
}
if (Net::getInventoryHandler()->canSplit(item))
- mBrowserBox->addRow(strprintf("@@split|%s@@", _("Split")));
+ mBrowserBox->addRow("split", _("Split"));
}
// Assume in storage for now
// TODO: make this whole system more flexible, if needed
else
{
- mBrowserBox->addRow(strprintf("@@retrieve|%s@@", _("Retrieve")));
+ mBrowserBox->addRow("retrieve", _("Retrieve"));
if (cnt > 1)
{
if (cnt > 10)
- {
- mBrowserBox->addRow(strprintf("@@retrieve 10|%s@@",
- _("Retrieve 10")));
- }
- mBrowserBox->addRow(strprintf("@@retrieve half|%s@@",
- _("Retrieve half")));
- mBrowserBox->addRow(strprintf("@@retrieve all|%s@@",
- _("Retrieve all")));
+ mBrowserBox->addRow("retrieve 10", _("Retrieve 10"));
+ mBrowserBox->addRow("retrieve half", _("Retrieve half"));
+ mBrowserBox->addRow("retrieve all", _("Retrieve all"));
}
}
- mBrowserBox->addRow(strprintf("@@chat|%s@@", _("Add to chat")));
+ mBrowserBox->addRow("chat", _("Add to chat"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -1823,12 +1725,12 @@ void PopupMenu::showItemPopup(int x, int y, int itemId, unsigned char color)
mItemColor = color;
mBrowserBox->clearRows();
- mBrowserBox->addRow(strprintf("@@use|%s@@", _("Use")));
+ mBrowserBox->addRow("use", _("Use"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@load old item shortcuts|%s@@",
- _("Load old item shortcuts")));
+ mBrowserBox->addRow("load old item shortcuts",
+ _("Load old item shortcuts"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -1854,37 +1756,37 @@ void PopupMenu::showItemPopup(int x, int y, Item *item)
if (item->isEquipment())
{
if (item->isEquipped())
- mBrowserBox->addRow(strprintf("@@use|%s@@", _("Unequip")));
+ mBrowserBox->addRow("use", _("Unequip"));
else
- mBrowserBox->addRow(strprintf("@@use|%s@@", _("Equip")));
+ mBrowserBox->addRow("use", _("Equip"));
}
else
{
- mBrowserBox->addRow(strprintf("@@use|%s@@", _("Use")));
+ mBrowserBox->addRow("use", _("Use"));
}
if (item->getQuantity() > 1)
{
- mBrowserBox->addRow(strprintf("@@drop|%s@@", _("Drop...")));
- mBrowserBox->addRow(strprintf("@@drop all|%s@@", _("Drop all")));
+ mBrowserBox->addRow("drop", _("Drop..."));
+ mBrowserBox->addRow("drop all", _("Drop all"));
}
else
{
- mBrowserBox->addRow(strprintf("@@drop|%s@@", _("Drop")));
+ mBrowserBox->addRow("drop", _("Drop"));
}
if (Net::getInventoryHandler()->canSplit(item))
- mBrowserBox->addRow(strprintf("@@split|%s@@", _("Split")));
+ mBrowserBox->addRow("split", _("Split"));
if (InventoryWindow::isStorageActive())
- mBrowserBox->addRow(strprintf("@@store|%s@@", _("Store")));
- mBrowserBox->addRow(strprintf("@@chat|%s@@", _("Add to chat")));
+ mBrowserBox->addRow("store", _("Store"));
+ mBrowserBox->addRow("chat", _("Add to chat"));
mBrowserBox->addRow("##3---");
}
- mBrowserBox->addRow(strprintf("@@load old item shortcuts|%s@@",
- _("Load old item shortcuts")));
+ mBrowserBox->addRow("load old item shortcuts",
+ _("Load old item shortcuts"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -1899,35 +1801,37 @@ void PopupMenu::showDropPopup(int x, int y, Item *item)
if (item->isEquipment())
{
if (item->isEquipped())
- mBrowserBox->addRow(strprintf("@@use|%s@@", _("Unequip")));
+ mBrowserBox->addRow("use", _("Unequip"));
else
- mBrowserBox->addRow(strprintf("@@use|%s@@", _("Equip")));
+ mBrowserBox->addRow("use", _("Equip"));
}
else
- mBrowserBox->addRow(strprintf("@@use|%s@@", _("Use")));
+ {
+ mBrowserBox->addRow("use", _("Use"));
+ }
if (item->getQuantity() > 1)
{
- mBrowserBox->addRow(strprintf("@@drop|%s@@", _("Drop...")));
- mBrowserBox->addRow(strprintf("@@drop all|%s@@", _("Drop all")));
+ mBrowserBox->addRow("drop", _("Drop..."));
+ mBrowserBox->addRow("drop all", _("Drop all"));
}
else
{
- mBrowserBox->addRow(strprintf("@@drop|%s@@", _("Drop")));
+ mBrowserBox->addRow("drop", _("Drop"));
}
if (Net::getInventoryHandler()->canSplit(item))
- mBrowserBox->addRow(strprintf("@@split|%s@@", _("Split")));
+ mBrowserBox->addRow("split", _("Split"));
if (InventoryWindow::isStorageActive())
- mBrowserBox->addRow(strprintf("@@store|%s@@", _("Store")));
- mBrowserBox->addRow(strprintf("@@chat|%s@@", _("Add to chat")));
+ mBrowserBox->addRow("store", _("Store"));
+ mBrowserBox->addRow("chat", _("Add to chat"));
mBrowserBox->addRow("##3---");
}
- mBrowserBox->addRow(strprintf("@@load old drop shortcuts|%s@@",
- _("Load old drop shortcuts")));
+ mBrowserBox->addRow("load old drop shortcuts",
+ _("Load old drop shortcuts"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -1962,7 +1866,7 @@ void PopupMenu::showPopup(int x, int y, Button *button)
}
}
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -1998,11 +1902,10 @@ void PopupMenu::showPopup(int x, int y, ProgressBar *b)
}
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@reset yellow|%s@@",
- _("Reset yellow bar")));
+ mBrowserBox->addRow("reset yellow", _("Reset yellow bar"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@bar to chat|%s@@", _("Copy to chat")));
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("bar to chat", _("Copy to chat"));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -2010,7 +1913,7 @@ void PopupMenu::showPopup(int x, int y, ProgressBar *b)
void PopupMenu::showAttackMonsterPopup(int x, int y, std::string name,
int type)
{
- if (!player_node)
+ if (!player_node || !actorSpriteManager)
return;
mNick = name;
@@ -2029,17 +1932,10 @@ void PopupMenu::showAttackMonsterPopup(int x, int y, std::string name,
int idx = actorSpriteManager->getAttackMobIndex(name);
int size = actorSpriteManager->getAttackMobsSize();
if (idx > 0)
- {
- mBrowserBox->addRow(strprintf(
- "@@attack moveup|%s@@", _("Move up")));
- }
+ mBrowserBox->addRow("attack moveup", _("Move up"));
if (idx + 1 < size)
- {
- mBrowserBox->addRow(strprintf(
- "@@attack movedown|%s@@", _("Move down")));
- }
- mBrowserBox->addRow(strprintf(
- "@@attack remove|%s@@", _("Remove")));
+ mBrowserBox->addRow("attack movedown", _("Move down"));
+ mBrowserBox->addRow("attack remove", _("Remove"));
break;
}
case MapItem::PRIORITY:
@@ -2047,29 +1943,21 @@ void PopupMenu::showAttackMonsterPopup(int x, int y, std::string name,
int idx = actorSpriteManager->getPriorityAttackMobIndex(name);
int size = actorSpriteManager->getPriorityAttackMobsSize();
if (idx > 0)
- {
- mBrowserBox->addRow(strprintf(
- "@@priority moveup|%s@@", _("Move up")));
- }
+ mBrowserBox->addRow("priority moveup", _("Move up"));
if (idx + 1 < size)
- {
- mBrowserBox->addRow(strprintf(
- "@@priority movedown|%s@@", _("Move down")));
- }
- mBrowserBox->addRow(strprintf(
- "@@attack remove|%s@@", _("Remove")));
+ mBrowserBox->addRow("priority movedown", _("Move down"));
+ mBrowserBox->addRow("attack remove", _("Remove"));
break;
}
case MapItem::IGNORE_:
- mBrowserBox->addRow(strprintf(
- "@@attack remove|%s@@", _("Remove")));
+ mBrowserBox->addRow("attack remove", _("Remove"));
break;
default:
break;
}
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
}
@@ -2086,10 +1974,10 @@ void PopupMenu::showUndressPopup(int x, int y, Being *being, Item *item)
mBrowserBox->clearRows();
- mBrowserBox->addRow(strprintf("@@undress item|%s@@", _("Undress")));
+ mBrowserBox->addRow("undress item", _("Undress"));
mBrowserBox->addRow("##3---");
- mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel")));
+ mBrowserBox->addRow("cancel", _("Cancel"));
showPopup(x, y);
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index c20eb4622..1419e213c 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -256,6 +256,11 @@ void BrowserBox::addRow(const std::string &row, bool atTop)
updateHeight();
}
+void BrowserBox::addRow(const std::string &cmd, char *text)
+{
+ addRow(strprintf("@@%s|%s@@", cmd.c_str(), text));
+}
+
void BrowserBox::addImage(const std::string &path)
{
if (!mEnableImages)
diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h
index cd69ce56f..e86f0288e 100644
--- a/src/gui/widgets/browserbox.h
+++ b/src/gui/widgets/browserbox.h
@@ -112,6 +112,11 @@ class BrowserBox : public gcn::Widget,
*/
void addRow(const std::string &row, bool atTop = false);
+ /**
+ * Adds a menu line to the browser.
+ */
+ void addRow(const std::string &cmd, char *text);
+
void addImage(const std::string &path);
/**