]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/guiFormSpecMenu.h
Handle particle spawners in env and delete expired ids
[dragonfireclient.git] / src / guiFormSpecMenu.h
index 0677e87a690de54e43caacc879675125df8ec395..8774d306f95d0b7bd787e5ed5962a4f351c19162 100644 (file)
@@ -29,6 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "modalMenu.h"
 #include "guiTable.h"
 #include "network/networkprotocol.h"
+#include "util/string.h"
 
 class IGameDef;
 class InventoryManager;
@@ -139,53 +140,78 @@ class GUIFormSpecMenu : public GUIModalMenu
 
        struct ImageDrawSpec
        {
-               ImageDrawSpec()
+               ImageDrawSpec():
+                       parent_button(NULL)
                {
                }
                ImageDrawSpec(const std::string &a_name,
                                const std::string &a_item_name,
+                               gui::IGUIButton *a_parent_button,
                                const v2s32 &a_pos, const v2s32 &a_geom):
                        name(a_name),
-                       item_name (a_item_name),
+                       item_name(a_item_name),
+                       parent_button(a_parent_button),
                        pos(a_pos),
-                       geom(a_geom)
+                       geom(a_geom),
+                       scale(true)
                {
-                       scale = true;
                }
                ImageDrawSpec(const std::string &a_name,
+                               const std::string &a_item_name,
                                const v2s32 &a_pos, const v2s32 &a_geom):
                        name(a_name),
+                       item_name(a_item_name),
+                       parent_button(NULL),
                        pos(a_pos),
-                       geom(a_geom)
+                       geom(a_geom),
+                       scale(true)
+               {
+               }
+               ImageDrawSpec(const std::string &a_name,
+                               const v2s32 &a_pos, const v2s32 &a_geom):
+                       name(a_name),
+                       parent_button(NULL),
+                       pos(a_pos),
+                       geom(a_geom),
+                       scale(true)
                {
-                       scale = true;
                }
                ImageDrawSpec(const std::string &a_name,
                                const v2s32 &a_pos):
                        name(a_name),
-                       pos(a_pos)
+                       parent_button(NULL),
+                       pos(a_pos),
+                       scale(false)
                {
-                       scale = false;
                }
                std::string name;
                std::string item_name;
+               gui::IGUIButton *parent_button;
                v2s32 pos;
                v2s32 geom;
                bool scale;
        };
 
+       /* The responsibility of unescaping the strings has been shifted
+        * from the formspec parsing methods to the draw methods.
+        * There still are a few exceptions:
+        *  - Vertical label, because it modifies the string by inserting
+        *    '\n' between each character,
+        *  - Tab header, because it gives the string immediately to
+        *    Irrlicht and we can't unescape it later.
+        */
        struct FieldSpec
        {
                FieldSpec()
                {
                }
                FieldSpec(const std::string &name, const std::wstring &label,
-                               const std::wstring &fdeflt, int id) :
+                               const std::wstring &default_text, int id) :
                        fname(name),
-                       flabel(label),
-                       fdefault(fdeflt),
                        fid(id)
                {
+                       flabel = unescape_string(unescape_enriched(label));
+                       fdefault = unescape_string(unescape_enriched(default_text));
                        send = false;
                        ftype = f_Unknown;
                        is_exit = false;
@@ -218,28 +244,39 @@ class GUIFormSpecMenu : public GUIModalMenu
                }
                TooltipSpec(std::string a_tooltip, irr::video::SColor a_bgcolor,
                                irr::video::SColor a_color):
-                       tooltip(a_tooltip),
                        bgcolor(a_bgcolor),
                        color(a_color)
                {
+                       tooltip = unescape_string(unescape_enriched(utf8_to_wide(a_tooltip)));
                }
-               std::string tooltip;
+               std::wstring tooltip;
                irr::video::SColor bgcolor;
                irr::video::SColor color;
        };
 
        struct StaticTextSpec {
-               StaticTextSpec()
+               StaticTextSpec():
+                       parent_button(NULL)
                {
                }
                StaticTextSpec(const std::wstring &a_text,
                                const core::rect<s32> &a_rect):
-                       text(a_text),
-                       rect(a_rect)
+                       rect(a_rect),
+                       parent_button(NULL)
+               {
+                       text = unescape_string(unescape_enriched(a_text));
+               }
+               StaticTextSpec(const std::wstring &a_text,
+                               const core::rect<s32> &a_rect,
+                               gui::IGUIButton *a_parent_button):
+                       rect(a_rect),
+                       parent_button(a_parent_button)
                {
+                       text = unescape_string(unescape_enriched(a_text));
                }
                std::wstring text;
                core::rect<s32> rect;
+               gui::IGUIButton *parent_button;
        };
 
 public:
@@ -378,7 +415,7 @@ class GUIFormSpecMenu : public GUIModalMenu
        u32 m_tooltip_show_delay;
        s32 m_hovered_time;
        s32 m_old_tooltip_id;
-       std::string m_old_tooltip;
+       std::wstring m_old_tooltip;
 
        bool m_rmouse_auto_place;
 
@@ -401,7 +438,6 @@ class GUIFormSpecMenu : public GUIModalMenu
        TextDest         *m_text_dst;
        unsigned int      m_formspec_version;
        std::string       m_focused_element;
-       bool              m_selection_active;
 
        typedef struct {
                bool explicit_size;