diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-08-27 16:02:54 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-08-27 16:02:54 +0300 |
commit | fc2514926927b709dd59325e83b7da9fd10fa36e (patch) | |
tree | 97acbd471a5780177495f006e4e87ca94fe087a9 /src | |
parent | fda230f1a8a6399c2507c7e39cd714d8aefc712d (diff) | |
download | plus-fc2514926927b709dd59325e83b7da9fd10fa36e.tar.gz plus-fc2514926927b709dd59325e83b7da9fd10fa36e.tar.bz2 plus-fc2514926927b709dd59325e83b7da9fd10fa36e.tar.xz plus-fc2514926927b709dd59325e83b7da9fd10fa36e.zip |
Move chat command /createitems into actions.
Diffstat (limited to 'src')
-rw-r--r-- | src/actions/actions.cpp | 36 | ||||
-rw-r--r-- | src/actions/actions.h | 1 | ||||
-rw-r--r-- | src/commands.cpp | 32 | ||||
-rw-r--r-- | src/commands.h | 5 | ||||
-rw-r--r-- | src/input/inputaction.h | 1 | ||||
-rw-r--r-- | src/input/inputactionmap.h | 11 | ||||
-rw-r--r-- | src/input/pages/other.cpp | 6 |
7 files changed, 55 insertions, 37 deletions
diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp index 9198b474b..90429bc5b 100644 --- a/src/actions/actions.cpp +++ b/src/actions/actions.cpp @@ -46,6 +46,7 @@ #include "gui/popups/popupmenu.h" +#include "gui/windows/buydialog.h" #include "gui/windows/skilldialog.h" #include "gui/windows/socialwindow.h" #include "gui/windows/statuswindow.h" @@ -89,8 +90,11 @@ #include "listeners/updatestatuslistener.h" +#include "resources/iteminfo.h" #include "resources/resourcemanager.h" +#include "resources/db/itemdb.h" + #include "resources/map/map.h" #include "utils/chatutils.h" @@ -1037,4 +1041,36 @@ impHandler0(testSdlFont) } #endif +impHandler0(createItems) +{ + BuyDialog *const dialog = new BuyDialog(); + const ItemDB::ItemInfos &items = ItemDB::getItemInfos(); + FOR_EACH (ItemDB::ItemInfos::const_iterator, it, items) + { + const ItemInfo *const info = (*it).second; + const int id = info->getId(); + if (id <= 500) + continue; + + int colors = info->getColorsSize(); + if (colors >= 255) + colors = 254; + + if (!colors) + { + dialog->addItem(id, 1, 100, 0); + } + else + { + for (unsigned char f = 0; f < colors; f ++) + { + if (!info->getColor(f).empty()) + dialog->addItem(id, f, 100, 0); + } + } + } + dialog->sort(); + return true; +} + } // namespace Actions diff --git a/src/actions/actions.h b/src/actions/actions.h index f3c58da54..a288b7f86 100644 --- a/src/actions/actions.h +++ b/src/actions/actions.h @@ -83,6 +83,7 @@ namespace Actions #if defined USE_OPENGL && defined DEBUG_SDLFONT decHandler(testSdlFont); #endif + decHandler(createItems); } // namespace Actions #undef decHandler diff --git a/src/commands.cpp b/src/commands.cpp index fcc5eff26..960e35994 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -106,38 +106,6 @@ impHandler(hack) return true; } -impHandler0(createItems) -{ - BuyDialog *const dialog = new BuyDialog(); - const ItemDB::ItemInfos &items = ItemDB::getItemInfos(); - FOR_EACH (ItemDB::ItemInfos::const_iterator, it, items) - { - const ItemInfo *const info = (*it).second; - const int id = info->getId(); - if (id <= 500) - continue; - - int colors = info->getColorsSize(); - if (colors >= 255) - colors = 254; - - if (!colors) - { - dialog->addItem(id, 1, 100, 0); - } - else - { - for (unsigned char f = 0; f < colors; f ++) - { - if (!info->getColor(f).empty()) - dialog->addItem(id, f, 100, 0); - } - } - } - dialog->sort(); - return true; -} - impHandler(talkRaw) { Net::getChatHandler()->talkRaw(event.args); diff --git a/src/commands.h b/src/commands.h index d3a32d1c1..462323789 100644 --- a/src/commands.h +++ b/src/commands.h @@ -52,7 +52,6 @@ struct CommandInfo final namespace Commands { decHandler(hack); - decHandler(createItems); decHandler(talkRaw); decHandler(talkPet); decHandler(uploadConfig); @@ -66,8 +65,7 @@ namespace Commands enum { - COMMAND_CREATEITEMS = 0, - COMMAND_TALKRAW, + COMMAND_TALKRAW = 0, COMMAND_TALKPET, COMMAND_UPLOADCONFIG, COMMAND_UPLOADSERVERCONFIG, @@ -80,7 +78,6 @@ enum static const CommandInfo commands[] = { - {"createitems", &Commands::createItems, -1, false}, {"talkraw", &Commands::talkRaw, -1, true}, {"talkpet", &Commands::talkPet, -1, true}, {"uploadconfig", &Commands::uploadConfig, -1, false}, diff --git a/src/input/inputaction.h b/src/input/inputaction.h index dcd1e2552..ee8d44a95 100644 --- a/src/input/inputaction.h +++ b/src/input/inputaction.h @@ -415,6 +415,7 @@ namespace InputAction DISABLE_AWAY, ENABLE_AWAY, TEST_PARTICLE, + CREATE_ITEMS, TOTAL }; } // namespace InputAction diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h index 56853f0c8..9485d46d7 100644 --- a/src/input/inputactionmap.h +++ b/src/input/inputactionmap.h @@ -3512,7 +3512,16 @@ static const InputActionData inputActionData[InputAction::TOTAL] = { InputAction::NO_VALUE, 50, InputCondition::INGAME, "testparticle", - true} + true}, + {"keyCreateItems", + InputType::UNKNOWN, InputAction::NO_VALUE, + InputType::UNKNOWN, InputAction::NO_VALUE, + Input::GRP_DEFAULT, + &Actions::createItems, + InputAction::NO_VALUE, 50, + InputCondition::INGAME, + "createitems", + false} }; #endif // INPUT_INPUTACTIONMAP_H diff --git a/src/input/pages/other.cpp b/src/input/pages/other.cpp index aaa0067e0..a86d13860 100644 --- a/src/input/pages/other.cpp +++ b/src/input/pages/other.cpp @@ -275,6 +275,12 @@ SetupActionData setupActionDataOther[] = }, { // TRANSLATORS: input action name + N_("Crate items (for gms)"), + InputAction::CREATE_ITEMS, + "", + }, + { + // TRANSLATORS: input action name N_("Print configured directories in chat"), InputAction::DIRS, "", |