ToolDefManager serialization
[oweals/minetest.git] / src / guiInventoryMenu.cpp
index bf955a43ed55154d88887c0b48673d2dfc42ff15..4ed9c857cf16e6199891b1b23d50d16fba4d1d8b 100644 (file)
@@ -22,17 +22,24 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "constants.h"
 #include "keycode.h"
 #include "strfnd.h"
+#include <IGUICheckBox.h>
+#include <IGUIEditBox.h>
+#include <IGUIButton.h>
+#include <IGUIStaticText.h>
+#include <IGUIFont.h>
+#include "log.h"
 
 void drawInventoryItem(video::IVideoDriver *driver,
                gui::IGUIFont *font,
                InventoryItem *item, core::rect<s32> rect,
-               const core::rect<s32> *clip)
+               const core::rect<s32> *clip,
+               ITextureSource *tsrc)
 {
        if(item == NULL)
                return;
        
        video::ITexture *texture = NULL;
-       texture = item->getImage();
+       texture = item->getImage(tsrc);
 
        if(texture != NULL)
        {
@@ -83,12 +90,14 @@ GUIInventoryMenu::GUIInventoryMenu(gui::IGUIEnvironment* env,
                IMenuManager *menumgr,
                v2s16 menu_size,
                InventoryContext *c,
-               InventoryManager *invmgr
+               InventoryManager *invmgr,
+               ITextureSource *tsrc
                ):
        GUIModalMenu(env, parent, id, menumgr),
        m_menu_size(menu_size),
        m_c(c),
-       m_invmgr(invmgr)
+       m_invmgr(invmgr),
+       m_tsrc(tsrc)
 {
        m_selected_item = NULL;
 }
@@ -212,7 +221,7 @@ GUIInventoryMenu::ItemSpec GUIInventoryMenu::getItemAtPos(v2s32 p) const
        return ItemSpec("", "", -1);
 }
 
-void GUIInventoryMenu::drawList(const ListDrawSpec &s)
+void GUIInventoryMenu::drawList(const ListDrawSpec &s, ITextureSource *tsrc)
 {
        video::IVideoDriver* driver = Environment->getVideoDriver();
 
@@ -263,7 +272,7 @@ void GUIInventoryMenu::drawList(const ListDrawSpec &s)
                if(item)
                {
                        drawInventoryItem(driver, font, item,
-                                       rect, &AbsoluteClippingRect);
+                                       rect, &AbsoluteClippingRect, tsrc);
                }
 
        }
@@ -286,7 +295,7 @@ void GUIInventoryMenu::drawMenu()
        for(u32 i=0; i<m_draw_spec.size(); i++)
        {
                ListDrawSpec &s = m_draw_spec[i];
-               drawList(s);
+               drawList(s, m_tsrc);
        }
 
        /*
@@ -321,11 +330,11 @@ bool GUIInventoryMenu::OnEvent(const SEvent& event)
                if(amount >= 0)
                {
                        v2s32 p(event.MouseInput.X, event.MouseInput.Y);
-                       //dstream<<"Mouse down at p=("<<p.X<<","<<p.Y<<")"<<std::endl;
+                       //infostream<<"Mouse down at p=("<<p.X<<","<<p.Y<<")"<<std::endl;
                        ItemSpec s = getItemAtPos(p);
                        if(s.isValid())
                        {
-                               dstream<<"Mouse down on "<<s.inventoryname
+                               infostream<<"Mouse down on "<<s.inventoryname
                                                <<"/"<<s.listname<<" "<<s.i<<std::endl;
                                if(m_selected_item)
                                {
@@ -340,15 +349,15 @@ bool GUIInventoryMenu::OnEvent(const SEvent& event)
                                        InventoryList *list_to =
                                                        inv_to->getList(s.listname);
                                        if(list_from == NULL)
-                                               dstream<<"from list doesn't exist"<<std::endl;
+                                               infostream<<"from list doesn't exist"<<std::endl;
                                        if(list_to == NULL)
-                                               dstream<<"to list doesn't exist"<<std::endl;
+                                               infostream<<"to list doesn't exist"<<std::endl;
                                        // Indicates whether source slot completely empties
                                        bool source_empties = false;
                                        if(list_from && list_to
                                                        && list_from->getItem(m_selected_item->i) != NULL)
                                        {
-                                               dstream<<"Handing IACTION_MOVE to manager"<<std::endl;
+                                               infostream<<"Handing IACTION_MOVE to manager"<<std::endl;
                                                IMoveAction *a = new IMoveAction();
                                                a->count = amount;
                                                a->from_inv = m_selected_item->inventoryname;
@@ -403,7 +412,7 @@ bool GUIInventoryMenu::OnEvent(const SEvent& event)
                {
                        if(!canTakeFocus(event.GUIEvent.Element))
                        {
-                               dstream<<"GUIInventoryMenu: Not allowing focus change."
+                               infostream<<"GUIInventoryMenu: Not allowing focus change."
                                                <<std::endl;
                                // Returning true disables focus change
                                return true;
@@ -469,7 +478,7 @@ v2s16 GUIInventoryMenu::makeDrawSpecArrayFromString(
        while(f.atend() == false)
        {
                std::string type = trim(f.next("["));
-               //dstream<<"type="<<type<<std::endl;
+               //infostream<<"type="<<type<<std::endl;
                if(type == "list")
                {
                        std::string name = f.next(";");
@@ -480,7 +489,7 @@ v2s16 GUIInventoryMenu::makeDrawSpecArrayFromString(
                        s32 pos_y = stoi(f.next(";"));
                        s32 geom_x = stoi(f.next(","));
                        s32 geom_y = stoi(f.next(";"));
-                       dstream<<"list name="<<name<<", subname="<<subname
+                       infostream<<"list name="<<name<<", subname="<<subname
                                        <<", pos=("<<pos_x<<","<<pos_y<<")"
                                        <<", geom=("<<geom_x<<","<<geom_y<<")"
                                        <<std::endl;
@@ -493,14 +502,14 @@ v2s16 GUIInventoryMenu::makeDrawSpecArrayFromString(
                {
                        invsize.X = stoi(f.next(","));
                        invsize.Y = stoi(f.next(";"));
-                       dstream<<"invsize ("<<invsize.X<<","<<invsize.Y<<")"<<std::endl;
+                       infostream<<"invsize ("<<invsize.X<<","<<invsize.Y<<")"<<std::endl;
                        f.next("]");
                }
                else
                {
                        // Ignore others
                        std::string ts = f.next("]");
-                       dstream<<"Unknown DrawSpec: type="<<type<<", data=\""<<ts<<"\""
+                       infostream<<"Unknown DrawSpec: type="<<type<<", data=\""<<ts<<"\""
                                        <<std::endl;
                }
        }