]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/guiInventoryMenu.h
drawing range updater update and myrand() (but not usage of it)
[dragonfireclient.git] / src / guiInventoryMenu.h
index b581a1166a7ea0e9c35b521a9295c57fa0820e92..82e7ee89d7a5305a8e92de87e047b9a39e18ac15 100644 (file)
@@ -23,65 +23,88 @@ 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,
                InventoryItem *item, core::rect<s32> rect,
                const core::rect<s32> *clip=0);
 
-class GUIInventorySlot: public gui::IGUIElement
+class GUIInventoryMenu : public GUIModalMenu
 {
-public:
-       GUIInventorySlot(gui::IGUIEnvironment* env,
-                       gui::IGUIElement* parent, s32 id, core::rect<s32> rect);
-       
-       void setItem(InventoryItem *item)
+       struct ItemSpec
        {
-               m_item = item;
-       }
-
-       void draw();
-
-       bool OnEvent(const SEvent& event);
-
-private:
-       InventoryItem *m_item;
-};
+               ItemSpec()
+               {
+                       i = -1;
+               }
+               ItemSpec(const std::string &a_name, s32 a_i)
+               {
+                       listname = a_name;
+                       i = a_i;
+               }
+               bool isValid() const
+               {
+                       return i != -1;
+               }
+
+               std::string listname;
+               s32 i;
+       };
+
+       struct ListDrawSpec
+       {
+               ListDrawSpec()
+               {
+               }
+               ListDrawSpec(const std::string &a_name, v2s32 a_pos, v2s32 a_geom)
+               {
+                       listname = a_name;
+                       pos = a_pos;
+                       geom = a_geom;
+               }
+
+               std::string listname;
+               v2s32 pos;
+               v2s32 geom;
+       };
 
-class GUIInventoryMenu : public gui::IGUIElement
-{
 public:
        GUIInventoryMenu(gui::IGUIEnvironment* env,
                        gui::IGUIElement* parent, s32 id,
-                       Inventory *inventory);
+                       Inventory *inventory,
+                       Queue<InventoryAction*> *actions,
+                       int *active_menu_count);
        ~GUIInventoryMenu();
 
+       void removeChildren();
        /*
                Remove and re-add (or reposition) stuff
        */
-       void resizeGui();
-
-       // Updates stuff from inventory to screen
-       // TODO: Remove, not used
-       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);
+       
+private:
+       v2s32 getBasePos() const
        {
-               setVisible(true);
-               Environment->setFocus(this);
+               return padding + AbsoluteRect.UpperLeftCorner;
        }
 
-       bool canTakeFocus(gui::IGUIElement *e)
-       {
-               return (e && (e == this || isMyChild(e)));
-       }
+       v2s32 padding;
+       v2s32 spacing;
+       v2s32 imgsize;
+
+       core::array<ListDrawSpec> m_draw_positions;
 
-       bool OnEvent(const SEvent& event);
-       
-private:
        Inventory *m_inventory;
-       v2u32 m_screensize_old;
+
+       ItemSpec *m_selected_item;
+       Queue<InventoryAction*> *m_actions;
 };
 
 #endif