X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2FguiInventoryMenu.h;h=10fb7a4250dd11ff0403cd0b0eaff27547a882df;hb=0847e550f0b5484471e7c02d54ed35443824a86e;hp=8bfade4c4e9eeab14618ef3d8621d3fece778c04;hpb=4ec61b0ccdedecf54cd697d0b1cfa16aaf92bf82;p=dragonfireclient.git diff --git a/src/guiInventoryMenu.h b/src/guiInventoryMenu.h index 8bfade4c4..10fb7a425 100644 --- a/src/guiInventoryMenu.h +++ b/src/guiInventoryMenu.h @@ -23,65 +23,131 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "common_irrlicht.h" #include "inventory.h" +#include "utility.h" +#include "modalMenu.h" -void drawInventoryItem(gui::IGUIEnvironment* env, +void drawInventoryItem(video::IVideoDriver *driver, + gui::IGUIFont *font, InventoryItem *item, core::rect rect, - const core::rect *clip=0); + const core::rect *clip); -class GUIInventorySlot: public gui::IGUIElement +class GUIInventoryMenu : public GUIModalMenu { + struct ItemSpec + { + ItemSpec() + { + i = -1; + } + ItemSpec(const std::string &a_inventoryname, + const std::string &a_listname, + s32 a_i) + { + inventoryname = a_inventoryname; + listname = a_listname; + i = a_i; + } + bool isValid() const + { + return i != -1; + } + + std::string inventoryname; + std::string listname; + s32 i; + }; + + struct ListDrawSpec + { + ListDrawSpec() + { + } + ListDrawSpec(const std::string &a_inventoryname, + const std::string &a_listname, + v2s32 a_pos, v2s32 a_geom) + { + inventoryname = a_inventoryname; + listname = a_listname; + pos = a_pos; + geom = a_geom; + } + + std::string inventoryname; + std::string listname; + v2s32 pos; + v2s32 geom; + }; public: - GUIInventorySlot(gui::IGUIEnvironment* env, - gui::IGUIElement* parent, s32 id, core::rect rect); - - void setItem(InventoryItem *item) + struct DrawSpec { - m_item = item; - } - - void draw(); - - bool OnEvent(const SEvent& event); - -private: - InventoryItem *m_item; -}; + DrawSpec() + { + } + DrawSpec(const std::string &a_type, + const std::string &a_name, + const std::string &a_subname, + v2s32 a_pos, + v2s32 a_geom) + { + type = a_type; + name = a_name; + subname = a_subname; + pos = a_pos; + geom = a_geom; + } + + std::string type; + std::string name; + std::string subname; + v2s32 pos; + v2s32 geom; + }; -class GUIInventoryMenu : public gui::IGUIElement -{ -public: GUIInventoryMenu(gui::IGUIEnvironment* env, gui::IGUIElement* parent, s32 id, - Inventory *inventory); + IMenuManager *menumgr, + v2s16 menu_size, + InventoryContext *c, + InventoryManager *invmgr + ); ~GUIInventoryMenu(); + void setDrawSpec(core::array &init_draw_spec) + { + m_init_draw_spec = init_draw_spec; + } + + void removeChildren(); /* Remove and re-add (or reposition) stuff */ - void resizeGui(); - - // Updates stuff from inventory to screen - void update(); - - void draw(); + void regenerateGui(v2u32 screensize); + + ItemSpec getItemAtPos(v2s32 p) const; + void drawList(const ListDrawSpec &s); + void drawMenu(); - void launch() + bool OnEvent(const SEvent& event); + +protected: + v2s32 getBasePos() const { - setVisible(true); - Environment->setFocus(this); + return padding + AbsoluteRect.UpperLeftCorner; } - bool canTakeFocus(gui::IGUIElement *e) - { - return (e && (e == this || isMyChild(e))); - } + v2s16 m_menu_size; - bool OnEvent(const SEvent& event); + v2s32 padding; + v2s32 spacing; + v2s32 imgsize; -private: - Inventory *m_inventory; - core::array m_slots; - v2u32 m_screensize_old; + InventoryContext *m_c; + InventoryManager *m_invmgr; + + core::array m_init_draw_spec; + core::array m_draw_spec; + + ItemSpec *m_selected_item; }; #endif