summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-08-19 22:40:15 +0300
committerAndrei Karas <akaras@inbox.ru>2016-08-19 22:40:15 +0300
commitd8d06e4c4ff2b84fbe74c902ac4bf50d349dc018 (patch)
tree38a1580cb5d26865a8e8e6d2bd459d5ab10faf99 /src
parenta348d4a8882300fa308d210e860dd29a4b974622 (diff)
downloadmanaverse-d8d06e4c4ff2b84fbe74c902ac4bf50d349dc018.tar.gz
manaverse-d8d06e4c4ff2b84fbe74c902ac4bf50d349dc018.tar.bz2
manaverse-d8d06e4c4ff2b84fbe74c902ac4bf50d349dc018.tar.xz
manaverse-d8d06e4c4ff2b84fbe74c902ac4bf50d349dc018.zip
Add chat command for show/change share item drops in party.
Diffstat (limited to 'src')
-rw-r--r--src/actions/commands.cpp68
-rw-r--r--src/actions/commands.h1
-rw-r--r--src/dyetool/actions/commands.cpp1
-rw-r--r--src/enums/input/inputaction.h1
-rw-r--r--src/gui/widgets/tabs/chat/partytab.cpp51
-rw-r--r--src/input/inputactionmap.h6
6 files changed, 79 insertions, 49 deletions
diff --git a/src/actions/commands.cpp b/src/actions/commands.cpp
index f2acaea56..7ec1d8bf8 100644
--- a/src/actions/commands.cpp
+++ b/src/actions/commands.cpp
@@ -71,8 +71,8 @@
#include "resources/map/map.h"
+#include "utils/booleanoptions.h"
#include "utils/chatutils.h"
-#include "utils/gettext.h"
#include "utils/gmfunctions.h"
#include "utils/parameters.h"
#include "utils/process.h"
@@ -1690,4 +1690,70 @@ impHandler(setSkillOffsetY)
return false;
}
+impHandler(partyItemShare)
+{
+ if (!localPlayer)
+ return false;
+
+ if (localPlayer->isInParty() == false)
+ return true;
+
+ ChatTab *tab = event.tab;
+ if (tab == nullptr)
+ tab = localChatTab;
+ if (tab == nullptr)
+ return true;
+
+ const std::string args = event.args;
+ if (args.empty())
+ {
+ switch (partyHandler->getShareItems())
+ {
+ case PartyShare::YES:
+ // TRANSLATORS: chat message
+ tab->chatLog(_("Item sharing enabled."),
+ ChatMsgType::BY_SERVER);
+ return true;
+ case PartyShare::NO:
+ // TRANSLATORS: chat message
+ tab->chatLog(_("Item sharing disabled."),
+ ChatMsgType::BY_SERVER);
+ return true;
+ case PartyShare::NOT_POSSIBLE:
+ // TRANSLATORS: chat message
+ tab->chatLog(_("Item sharing not possible."),
+ ChatMsgType::BY_SERVER);
+ return true;
+ case PartyShare::UNKNOWN:
+ // TRANSLATORS: chat message
+ tab->chatLog(_("Item sharing unknown."),
+ ChatMsgType::BY_SERVER);
+ return true;
+ default:
+ break;
+ }
+ }
+
+ const signed char opt = parseBoolean(args);
+
+ switch (opt)
+ {
+ case 1:
+ partyHandler->setShareItems(
+ PartyShare::YES);
+ break;
+ case 0:
+ partyHandler->setShareItems(
+ PartyShare::NO);
+ break;
+ case -1:
+ tab->chatLog(strprintf(BOOLEAN_OPTIONS, "item"),
+ ChatMsgType::BY_SERVER);
+ break;
+ default:
+ break;
+ }
+ return true;
+}
+
} // namespace Actions
diff --git a/src/actions/commands.h b/src/actions/commands.h
index acc13af75..e0892f384 100644
--- a/src/actions/commands.h
+++ b/src/actions/commands.h
@@ -149,6 +149,7 @@ namespace Actions
decHandler(showSkillOffsetY);
decHandler(setSkillOffsetX);
decHandler(setSkillOffsetY);
+ decHandler(partyItemShare);
} // namespace Actions
#undef decHandler
diff --git a/src/dyetool/actions/commands.cpp b/src/dyetool/actions/commands.cpp
index 68331913d..210704fcd 100644
--- a/src/dyetool/actions/commands.cpp
+++ b/src/dyetool/actions/commands.cpp
@@ -149,5 +149,6 @@ impHandlerVoid(showSkillOffsetX)
impHandlerVoid(showSkillOffsetY)
impHandlerVoid(setSkillOffsetX)
impHandlerVoid(setSkillOffsetY)
+impHandlerVoid(partyItemShare)
} // namespace Actions
diff --git a/src/enums/input/inputaction.h b/src/enums/input/inputaction.h
index 4bf981256..d76c6f1bc 100644
--- a/src/enums/input/inputaction.h
+++ b/src/enums/input/inputaction.h
@@ -681,6 +681,7 @@ enumStart(InputAction)
SET_SKILL_OFFSET_Y,
LEAVE_GUILD,
GUILD_NOTICE,
+ PARTY_ITEM_SHARE,
TOTAL
}
enumEnd(InputAction);
diff --git a/src/gui/widgets/tabs/chat/partytab.cpp b/src/gui/widgets/tabs/chat/partytab.cpp
index 3786e916b..530b0eca8 100644
--- a/src/gui/widgets/tabs/chat/partytab.cpp
+++ b/src/gui/widgets/tabs/chat/partytab.cpp
@@ -84,54 +84,9 @@ bool PartyTab::handleCommand(const std::string &restrict type,
}
else if (type == "item")
{
- if (args.empty())
- {
- switch (partyHandler->getShareItems())
- {
- case PartyShare::YES:
- // TRANSLATORS: chat message
- chatLog(_("Item sharing enabled."),
- ChatMsgType::BY_SERVER);
- return true;
- case PartyShare::NO:
- // TRANSLATORS: chat message
- chatLog(_("Item sharing disabled."),
- ChatMsgType::BY_SERVER);
- return true;
- case PartyShare::NOT_POSSIBLE:
- // TRANSLATORS: chat message
- chatLog(_("Item sharing not possible."),
- ChatMsgType::BY_SERVER);
- return true;
- case PartyShare::UNKNOWN:
- // TRANSLATORS: chat message
- chatLog(_("Item sharing unknown."),
- ChatMsgType::BY_SERVER);
- return true;
- default:
- break;
- }
- }
-
- const signed char opt = parseBoolean(args);
-
- switch (opt)
- {
- case 1:
- partyHandler->setShareItems(
- PartyShare::YES);
- break;
- case 0:
- partyHandler->setShareItems(
- PartyShare::NO);
- break;
- case -1:
- chatLog(strprintf(BOOLEAN_OPTIONS, "item"),
- ChatMsgType::BY_SERVER);
- break;
- default:
- break;
- }
+ inputManager.executeChatCommand(InputAction::PARTY_ITEM_SHARE,
+ args,
+ this);
}
else if (type == "exp")
{
diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h
index 31c2240eb..99ff49779 100644
--- a/src/input/inputactionmap.h
+++ b/src/input/inputactionmap.h
@@ -5576,6 +5576,12 @@ static const InputActionData inputActionData
"notice|guildnotice",
UseArgs_true,
Protected_true},
+ {"keyPartyItemShare",
+ defaultAction(&Actions::partyItemShare),
+ InputCondition::INGAME,
+ "itemshare|shareitem",
+ UseArgs_true,
+ Protected_true},
};
#undef defaultAction