]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/guiFormSpecMenu.h
make formspec textarea wordwrap
[dragonfireclient.git] / src / guiFormSpecMenu.h
index 84124afc3fa60272a1752855a3594725e3584539..6f7de158b505572018e379fd572d41ef1afcc976 100644 (file)
@@ -27,25 +27,37 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "inventory.h"
 #include "inventorymanager.h"
 #include "modalMenu.h"
+#include "guiTable.h"
 
 class IGameDef;
 class InventoryManager;
+class ISimpleTextureSource;
 
 typedef enum {
        f_Button,
-       f_ListBox,
+       f_Table,
        f_TabHeader,
        f_CheckBox,
        f_DropDown,
        f_Unknown
 } FormspecFieldType;
 
+typedef enum {
+       quit_mode_no,
+       quit_mode_accept,
+       quit_mode_cancel
+} FormspecQuitMode;
+
 struct TextDest
 {
        virtual ~TextDest() {};
        // This is deprecated I guess? -celeron55
        virtual void gotText(std::wstring text){}
        virtual void gotText(std::map<std::string, std::string> fields) = 0;
+       virtual void setFormName(std::string formname)
+       { m_formname = formname;};
+
+       std::string m_formname;
 };
 
 class IFormSource
@@ -137,7 +149,8 @@ class GUIFormSpecMenu : public GUIModalMenu
                FieldSpec()
                {
                }
-               FieldSpec(const std::wstring name, const std::wstring label, const std::wstring fdeflt, int id):
+               FieldSpec(const std::wstring &name, const std::wstring &label,
+                         const std::wstring &fdeflt, int id) :
                        fname(name),
                        flabel(label),
                        fdefault(fdeflt),
@@ -176,7 +189,8 @@ class GUIFormSpecMenu : public GUIModalMenu
                        gui::IGUIElement* parent, s32 id,
                        IMenuManager *menumgr,
                        InventoryManager *invmgr,
-                       IGameDef *gamedef
+                       IGameDef *gamedef,
+                       ISimpleTextureSource *tsrc
                        );
 
        ~GUIFormSpecMenu();
@@ -206,16 +220,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
        */
@@ -228,10 +239,16 @@ class GUIFormSpecMenu : public GUIModalMenu
        void updateSelectedItem();
        ItemStack verifySelectedItem();
 
-       void acceptInput(int evttype=-1);
+       void acceptInput(FormspecQuitMode quitmode);
+       bool preprocessEvent(const SEvent& event);
        bool OnEvent(const SEvent& event);
-       
-       int getListboxIndex(std::string listboxname);
+       bool doPause;
+       bool pausesGame() { return doPause; }
+
+       GUITable* getTable(std::wstring tablename);
+
+       static bool parseColor(const std::string &value,
+                       video::SColor &color, bool quiet);
 
 protected:
        v2s32 getBasePos() const
@@ -247,6 +264,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;
@@ -259,7 +277,7 @@ class GUIFormSpecMenu : public GUIModalMenu
        std::vector<ImageDrawSpec> m_itemimages;
        std::vector<BoxDrawSpec> m_boxes;
        std::vector<FieldSpec> m_fields;
-       std::vector<std::pair<FieldSpec,gui::IGUIListBox*> > m_listboxes;
+       std::vector<std::pair<FieldSpec,GUITable*> > m_tables;
        std::vector<std::pair<FieldSpec,gui::IGUICheckBox*> > m_checkboxes;
 
        ItemSpec *m_selected_item;
@@ -276,9 +294,16 @@ class GUIFormSpecMenu : public GUIModalMenu
        gui::IGUIStaticText *m_tooltip_element;
 
        bool m_allowclose;
-       bool m_use_gettext;
        bool m_lock;
        v2u32 m_lockscreensize;
+
+       bool m_bgfullscreen;
+       bool m_slotborder;
+       bool m_clipbackground;
+       video::SColor m_bgcolor;
+       video::SColor m_slotbg_n;
+       video::SColor m_slotbg_h;
+       video::SColor m_slotbordercolor;
 private:
        typedef struct {
                v2s32 size;
@@ -287,7 +312,11 @@ class GUIFormSpecMenu : public GUIModalMenu
                v2s32 basepos;
                int bp_set;
                v2u32 screensize;
-               std::map<std::wstring,int> listbox_selections;
+               std::wstring focused_fieldname;
+               GUITable::TableOptions table_options;
+               GUITable::TableColumns table_columns;
+               // used to restore table selection/scroll/treeview state
+               std::map<std::wstring,GUITable::DynamicData> table_dyndata;
        } parserData;
 
        typedef struct {
@@ -297,8 +326,6 @@ class GUIFormSpecMenu : public GUIModalMenu
                bool key_escape;
        } fs_key_pendig;
 
-       std::vector<video::ITexture *> m_Textures;
-
        fs_key_pendig current_keys_pending;
 
        void parseElement(parserData* data,std::string element);
@@ -310,20 +337,24 @@ class GUIFormSpecMenu : public GUIModalMenu
        void parseItemImage(parserData* data,std::string element);
        void parseButton(parserData* data,std::string element,std::string typ);
        void parseBackground(parserData* data,std::string element);
+       void parseTableOptions(parserData* data,std::string element);
+       void parseTableColumns(parserData* data,std::string element);
+       void parseTable(parserData* data,std::string element);
        void parseTextList(parserData* data,std::string element);
        void parseDropDown(parserData* data,std::string element);
        void parsePwdField(parserData* data,std::string element);
        void parseField(parserData* data,std::string element,std::string type);
        void parseSimpleField(parserData* data,std::vector<std::string> &parts);
-       void parseTextArea(parserData* data,std::vector<std::string>& parts,std::string type);
+       void parseTextArea(parserData* data,std::vector<std::string>& parts,
+                       std::string type);
        void parseLabel(parserData* data,std::string element);
        void parseVertLabel(parserData* data,std::string element);
        void parseImageButton(parserData* data,std::string element,std::string type);
        void parseItemImageButton(parserData* data,std::string element);
        void parseTabHeader(parserData* data,std::string element);
        void parseBox(parserData* data,std::string element);
-
-       bool parseColor(std::string color, irr::video::SColor& outcolor); 
+       void parseBackgroundColor(parserData* data,std::string element);
+       void parseListColors(parserData* data,std::string element);
 };
 
 class FormspecFormSource: public IFormSource