]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/guiFormSpecMenu.h
Made unknown nodes stop falling nodes properly and shorten lines
[dragonfireclient.git] / src / guiFormSpecMenu.h
index 60d170fda10fd2ed821799ce977d1b9854ddcd98..c244e458f08105141e2fa3f6a85cf3acf5dad119 100644 (file)
@@ -30,6 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 class IGameDef;
 class InventoryManager;
+class ISimpleTextureSource;
 
 typedef enum {
        f_Button,
@@ -57,13 +58,6 @@ class IFormSource
        virtual std::string resolveText(std::string str){ return str; }
 };
 
-void drawItemStack(video::IVideoDriver *driver,
-               gui::IGUIFont *font,
-               const ItemStack &item,
-               const core::rect<s32> &rect,
-               const core::rect<s32> *clip,
-               IGameDef *gamedef);
-
 class GUIFormSpecMenu : public GUIModalMenu
 {
        struct ItemSpec
@@ -183,7 +177,8 @@ class GUIFormSpecMenu : public GUIModalMenu
                        gui::IGUIElement* parent, s32 id,
                        IMenuManager *menumgr,
                        InventoryManager *invmgr,
-                       IGameDef *gamedef
+                       IGameDef *gamedef,
+                       ISimpleTextureSource *tsrc
                        );
 
        ~GUIFormSpecMenu();
@@ -213,16 +208,13 @@ class GUIFormSpecMenu : public GUIModalMenu
                m_allowclose = value;
        }
 
-       void useGettext(bool value) {
-               m_use_gettext = true;
-       }
-
        void lockSize(bool lock,v2u32 basescreensize=v2u32(0,0)) {
                m_lock = lock;
                m_lockscreensize = basescreensize;
        }
 
        void removeChildren();
+       void setInitialFocus();
        /*
                Remove and re-add (or reposition) stuff
        */
@@ -235,9 +227,10 @@ class GUIFormSpecMenu : public GUIModalMenu
        void updateSelectedItem();
        ItemStack verifySelectedItem();
 
-       void acceptInput(int evttype=-1);
+       void acceptInput();
+       bool preprocessEvent(const SEvent& event);
        bool OnEvent(const SEvent& event);
-       
+
        int getListboxIndex(std::string listboxname);
 
 protected:
@@ -254,6 +247,7 @@ class GUIFormSpecMenu : public GUIModalMenu
        irr::IrrlichtDevice* m_device;
        InventoryManager *m_invmgr;
        IGameDef *m_gamedef;
+       ISimpleTextureSource *m_tsrc;
 
        std::string m_formspec_string;
        InventoryLocation m_current_inventory_location;
@@ -279,11 +273,16 @@ class GUIFormSpecMenu : public GUIModalMenu
        ItemStack m_selected_content_guess;
        InventoryLocation m_selected_content_guess_inventory;
 
+       // WARNING: BLACK IRRLICHT MAGIC, see checkListboxClick()
+       std::wstring m_listbox_click_fname;
+       int m_listbox_click_index;
+       u32 m_listbox_click_time;
+       bool m_listbox_doubleclick;
+
        v2s32 m_pointer;
        gui::IGUIStaticText *m_tooltip_element;
 
        bool m_allowclose;
-       bool m_use_gettext;
        bool m_lock;
        v2u32 m_lockscreensize;
 private:
@@ -294,10 +293,25 @@ class GUIFormSpecMenu : public GUIModalMenu
                v2s32 basepos;
                int bp_set;
                v2u32 screensize;
+               std::wstring focused_fieldname;
                std::map<std::wstring,int> listbox_selections;
+               std::map<std::wstring,int> listbox_scroll;
        } parserData;
 
-       std::vector<video::ITexture *> m_Textures;
+       typedef struct {
+               bool key_up;
+               bool key_down;
+               bool key_enter;
+               bool key_escape;
+       } fs_key_pendig;
+
+       fs_key_pendig current_keys_pending;
+
+       // Determine whether listbox click was double click
+       // (Using some black Irrlicht magic)
+       bool checkListboxClick(std::wstring wlistboxname, int eventtype);
+
+       gui::IGUIScrollBar* getListboxScrollbar(gui::IGUIListBox *listbox);
 
        void parseElement(parserData* data,std::string element);
 
@@ -321,7 +335,7 @@ class GUIFormSpecMenu : public GUIModalMenu
        void parseTabHeader(parserData* data,std::string element);
        void parseBox(parserData* data,std::string element);
 
-       bool parseColor(std::string color, irr::video::SColor& outcolor);
+       bool parseColor(std::string color, irr::video::SColor& outcolor); 
 };
 
 class FormspecFormSource: public IFormSource