1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-14 09:05:19 +02:00

Reshape inventory menu code

This commit is contained in:
Perttu Ahola
2012-06-03 16:03:19 +03:00
parent e4bc76f55c
commit 7bf446f671
4 changed files with 79 additions and 181 deletions

View File

@@ -84,49 +84,20 @@ class GUIInventoryMenu : public GUIModalMenu
v2s32 geom;
};
public:
struct DrawSpec
{
DrawSpec()
{
}
DrawSpec(const std::string &a_type,
const InventoryLocation &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;
InventoryLocation name;
std::string subname;
v2s32 pos;
v2s32 geom;
};
// See .cpp for format
static v2s16 makeDrawSpecArrayFromString(
core::array<GUIInventoryMenu::DrawSpec> &draw_spec,
const std::string &data,
const InventoryLocation &current_location);
GUIInventoryMenu(gui::IGUIEnvironment* env,
gui::IGUIElement* parent, s32 id,
IMenuManager *menumgr,
v2s16 menu_size,
InventoryManager *invmgr,
IGameDef *gamedef
);
~GUIInventoryMenu();
void setDrawSpec(core::array<DrawSpec> &init_draw_spec)
void setFormSpec(const std::string &formspec_string,
InventoryLocation current_inventory_location)
{
m_init_draw_spec = init_draw_spec;
m_formspec_string = formspec_string;
m_current_inventory_location = current_inventory_location;
regenerateGui(m_screensize_old);
}
void removeChildren();
@@ -149,8 +120,6 @@ protected:
return padding + AbsoluteRect.UpperLeftCorner;
}
v2s16 m_menu_size;
v2s32 padding;
v2s32 spacing;
v2s32 imgsize;
@@ -158,7 +127,8 @@ protected:
InventoryManager *m_invmgr;
IGameDef *m_gamedef;
core::array<DrawSpec> m_init_draw_spec;
std::string m_formspec_string;
InventoryLocation m_current_inventory_location;
core::array<ListDrawSpec> m_draw_spec;
ItemSpec *m_selected_item;