#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