3 Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #ifndef GUIINVENTORYMENU_HEADER
22 #define GUIINVENTORYMENU_HEADER
24 #include "common_irrlicht.h"
25 #include "inventory.h"
27 #include "modalMenu.h"
30 class InventoryContext;
31 class InventoryManager;
33 void drawInventoryItem(video::IVideoDriver *driver,
35 InventoryItem *item, core::rect<s32> rect,
36 const core::rect<s32> *clip,
37 ITextureSource *tsrc);
39 class GUIInventoryMenu : public GUIModalMenu
47 ItemSpec(const std::string &a_inventoryname,
48 const std::string &a_listname,
51 inventoryname = a_inventoryname;
52 listname = a_listname;
60 std::string inventoryname;
70 ListDrawSpec(const std::string &a_inventoryname,
71 const std::string &a_listname,
72 v2s32 a_pos, v2s32 a_geom)
74 inventoryname = a_inventoryname;
75 listname = a_listname;
80 std::string inventoryname;
91 DrawSpec(const std::string &a_type,
92 const std::string &a_name,
93 const std::string &a_subname,
111 // See .cpp for format
112 static v2s16 makeDrawSpecArrayFromString(
113 core::array<GUIInventoryMenu::DrawSpec> &draw_spec,
114 const std::string &data,
115 const std::string ¤t_name);
117 GUIInventoryMenu(gui::IGUIEnvironment* env,
118 gui::IGUIElement* parent, s32 id,
119 IMenuManager *menumgr,
122 InventoryManager *invmgr,
127 void setDrawSpec(core::array<DrawSpec> &init_draw_spec)
129 m_init_draw_spec = init_draw_spec;
132 void removeChildren();
134 Remove and re-add (or reposition) stuff
136 void regenerateGui(v2u32 screensize);
138 ItemSpec getItemAtPos(v2s32 p) const;
139 void drawList(const ListDrawSpec &s, ITextureSource *tsrc);
142 bool OnEvent(const SEvent& event);
145 v2s32 getBasePos() const
147 return padding + AbsoluteRect.UpperLeftCorner;
156 InventoryContext *m_c;
157 InventoryManager *m_invmgr;
158 ITextureSource *m_tsrc;
160 core::array<DrawSpec> m_init_draw_spec;
161 core::array<ListDrawSpec> m_draw_spec;
163 ItemSpec *m_selected_item;