diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-02-29 01:02:46 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-02-29 01:02:46 +0300 |
commit | 60100c4b30f779fe8f63758f9974891e98816340 (patch) | |
tree | a3a5ab8eb90c3f03937df95adcfcf68a7d3d1922 /src | |
parent | 54cdcc6cded841b2c5823a74f58e4f3b06f81622 (diff) | |
download | manaplus-60100c4b30f779fe8f63758f9974891e98816340.tar.gz manaplus-60100c4b30f779fe8f63758f9974891e98816340.tar.bz2 manaplus-60100c4b30f779fe8f63758f9974891e98816340.tar.xz manaplus-60100c4b30f779fe8f63758f9974891e98816340.zip |
Add chat command /gmpartyleader. Also add it to npc context menu.
Diffstat (limited to 'src')
-rw-r--r-- | src/actions/commands.cpp | 9 | ||||
-rw-r--r-- | src/actions/commands.h | 1 | ||||
-rw-r--r-- | src/dyetool/actions/commands.cpp | 1 | ||||
-rw-r--r-- | src/enums/input/inputaction.h | 1 | ||||
-rw-r--r-- | src/gui/popups/popupmenu.cpp | 20 | ||||
-rw-r--r-- | src/gui/popups/popupmenu.h | 4 | ||||
-rw-r--r-- | src/input/inputactionmap.h | 6 | ||||
-rw-r--r-- | src/net/adminhandler.h | 2 | ||||
-rw-r--r-- | src/net/eathena/adminhandler.cpp | 5 | ||||
-rw-r--r-- | src/net/eathena/adminhandler.h | 2 | ||||
-rw-r--r-- | src/net/tmwa/adminhandler.cpp | 4 | ||||
-rw-r--r-- | src/net/tmwa/adminhandler.h | 3 |
12 files changed, 52 insertions, 6 deletions
diff --git a/src/actions/commands.cpp b/src/actions/commands.cpp index 90ef67f04..bbde5c4a8 100644 --- a/src/actions/commands.cpp +++ b/src/actions/commands.cpp @@ -1509,4 +1509,13 @@ impHandler(commandNpcShow) return true; } +impHandler(commandChangePartyLeader) +{ + const std::string args = event.args; + if (args.empty()) + return false; + adminHandler->changePartyLeader(args); + return true; +} + } // namespace Actions diff --git a/src/actions/commands.h b/src/actions/commands.h index 35c03ce62..efc436c97 100644 --- a/src/actions/commands.h +++ b/src/actions/commands.h @@ -134,6 +134,7 @@ namespace Actions decHandler(commandNpcMove); decHandler(commandNpcHide); decHandler(commandNpcShow); + decHandler(commandChangePartyLeader); } // namespace Actions #undef decHandler diff --git a/src/dyetool/actions/commands.cpp b/src/dyetool/actions/commands.cpp index 4d44cb655..1f8fd5cbd 100644 --- a/src/dyetool/actions/commands.cpp +++ b/src/dyetool/actions/commands.cpp @@ -134,5 +134,6 @@ impHandlerVoid(commandUnjail) impHandlerVoid(commandNpcMove) impHandlerVoid(commandNpcHide) impHandlerVoid(commandNpcShow) +impHandlerVoid(commandChangePartyLeader) } // namespace Actions diff --git a/src/enums/input/inputaction.h b/src/enums/input/inputaction.h index 7a1fe53d7..63241a642 100644 --- a/src/enums/input/inputaction.h +++ b/src/enums/input/inputaction.h @@ -663,6 +663,7 @@ enumStart(InputAction) COMMAND_NPC_MOVE, COMMAND_NPC_HIDE, COMMAND_NPC_SHOW, + COMMAND_CHANGE_PARTY_LEADER, TOTAL } enumEnd(InputAction); diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp index 76e684766..49073811d 100644 --- a/src/gui/popups/popupmenu.cpp +++ b/src/gui/popups/popupmenu.cpp @@ -1351,7 +1351,7 @@ void PopupMenu::handleLink(const std::string &link, } else if (link == "gm" && !mName.empty()) { - showGMPopup(); + showGMPopup(mName); return; } else if (link == "mute" && !mName.empty()) @@ -2730,7 +2730,7 @@ void PopupMenu::showPlayerMenu() showPopup(getX(), getY()); } -void PopupMenu::showPlayerGMCommands() +void PopupMenu::showPlayerGMCommands(const std::string &name) { const bool legacy = Net::getNetworkType() == ServerType::TMWATHENA; if (!legacy) @@ -2756,6 +2756,18 @@ void PopupMenu::showPlayerGMCommands() mBrowserBox->addRow("/alive 'NAME'", _("Revive")); if (!legacy) { + if (localPlayer && localPlayer->isInParty()) + { + const Party *const party = localPlayer->getParty(); + if (party && party->isMember(name)) + { + mBrowserBox->addRow("/gmpartyleader 'NAME'", + // TRANSLATORS: popup menu item + // TRANSLATORS: give party leader status + _("Give party leader")); + } + } + // TRANSLATORS: popup menu item // TRANSLATORS: nuke player mBrowserBox->addRow("/nuke 'NAME'", _("Nuke")); @@ -2986,7 +2998,7 @@ void PopupMenu::showItemGMCommands() mBrowserBox->addRow("/whodrops 'ITEMID'", _("Who drops")); } -void PopupMenu::showGMPopup() +void PopupMenu::showGMPopup(const std::string &name) { mBrowserBox->clearRows(); // TRANSLATORS: popup menu header @@ -2996,7 +3008,7 @@ void PopupMenu::showGMPopup() switch (mType) { case ActorType::Player: - showPlayerGMCommands(); + showPlayerGMCommands(name); break; case ActorType::Npc: showNpcGMCommands(); diff --git a/src/gui/popups/popupmenu.h b/src/gui/popups/popupmenu.h index 9a22f6d5d..58ae77a88 100644 --- a/src/gui/popups/popupmenu.h +++ b/src/gui/popups/popupmenu.h @@ -223,9 +223,9 @@ class PopupMenu final : public Popup, public LinkHandler void addChat(const Being *const being); #endif - void showGMPopup(); + void showGMPopup(const std::string &name); - void showPlayerGMCommands(); + void showPlayerGMCommands(const std::string &name); void showNpcGMCommands(); diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h index ecc9a40ad..90fb66f8c 100644 --- a/src/input/inputactionmap.h +++ b/src/input/inputactionmap.h @@ -5467,6 +5467,12 @@ static const InputActionData inputActionData "npcshow|shownpc", UseArgs_true, Protected_true}, + {"keyCommandChangePartyLeader", + defaultAction(&Actions::commandChangePartyLeader), + InputCondition::INGAME, + "gmpartyleader|changepartyleader", + UseArgs_true, + Protected_true}, }; #undef defaultAction diff --git a/src/net/adminhandler.h b/src/net/adminhandler.h index f6fb0c562..da919e25c 100644 --- a/src/net/adminhandler.h +++ b/src/net/adminhandler.h @@ -170,6 +170,8 @@ class AdminHandler notfinal virtual void hideNpc(const std::string &name) const = 0; virtual void showNpc(const std::string &name) const = 0; + + virtual void changePartyLeader(const std::string &name) const = 0; }; } // namespace Net diff --git a/src/net/eathena/adminhandler.cpp b/src/net/eathena/adminhandler.cpp index dbe0e7731..07b99347e 100644 --- a/src/net/eathena/adminhandler.cpp +++ b/src/net/eathena/adminhandler.cpp @@ -347,4 +347,9 @@ void AdminHandler::showNpc(const std::string &name) const Gm::runCommand("shownpc", name); } +void AdminHandler::changePartyLeader(const std::string &name) const +{ + Gm::runCommand("changeleader", name); +} + } // namespace EAthena diff --git a/src/net/eathena/adminhandler.h b/src/net/eathena/adminhandler.h index b19cc39ee..756f60187 100644 --- a/src/net/eathena/adminhandler.h +++ b/src/net/eathena/adminhandler.h @@ -146,6 +146,8 @@ class AdminHandler final : public Ea::AdminHandler void showNpc(const std::string &name) const override final; + void changePartyLeader(const std::string &name) const override final; + protected: static std::string mStatsName; }; diff --git a/src/net/tmwa/adminhandler.cpp b/src/net/tmwa/adminhandler.cpp index 847339164..4ae9e5346 100644 --- a/src/net/tmwa/adminhandler.cpp +++ b/src/net/tmwa/adminhandler.cpp @@ -271,4 +271,8 @@ void AdminHandler::showNpc(const std::string &name A_UNUSED) const { } +void AdminHandler::changePartyLeader(const std::string &name A_UNUSED) const +{ +} + } // namespace TmwAthena diff --git a/src/net/tmwa/adminhandler.h b/src/net/tmwa/adminhandler.h index c3aa20ed1..069913ab8 100644 --- a/src/net/tmwa/adminhandler.h +++ b/src/net/tmwa/adminhandler.h @@ -158,6 +158,9 @@ class AdminHandler final : public Ea::AdminHandler void hideNpc(const std::string &name) const override final A_CONST; void showNpc(const std::string &name) const override final A_CONST; + + void changePartyLeader(const std::string &name) const override final + A_CONST; }; } // namespace TmwAthena |