From fc2514926927b709dd59325e83b7da9fd10fa36e Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 27 Aug 2014 16:02:54 +0300 Subject: Move chat command /createitems into actions. --- src/actions/actions.cpp | 36 ++++++++++++++++++++++++++++++++++++ src/actions/actions.h | 1 + 2 files changed, 37 insertions(+) (limited to 'src/actions') 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 -- cgit v1.2.3-70-g09d2