]> git.lizzy.rs Git - minetest.git/blobdiff - src/guiFormSpecMenu.h
Isolate irrlicht references and use a singleton (#6041)
[minetest.git] / src / guiFormSpecMenu.h
index 9eaf60ac6353794563390a08408e46527367054c..6d015e5c4530578ba846f807f502be6df709a991 100644 (file)
@@ -287,8 +287,7 @@ class GUIFormSpecMenu : public GUIModalMenu
        };
 
 public:
-       GUIFormSpecMenu(irr::IrrlichtDevice* dev,
-                       JoystickController *joystick,
+       GUIFormSpecMenu(JoystickController *joystick,
                        gui::IGUIElement* parent, s32 id,
                        IMenuManager *menumgr,
                        Client *client,
@@ -310,18 +309,14 @@ class GUIFormSpecMenu : public GUIModalMenu
        // form_src is deleted by this GUIFormSpecMenu
        void setFormSource(IFormSource *form_src)
        {
-               if (m_form_src != NULL) {
-                       delete m_form_src;
-               }
+               delete m_form_src;
                m_form_src = form_src;
        }
 
        // text_dst is deleted by this GUIFormSpecMenu
        void setTextDest(TextDest *text_dst)
        {
-               if (m_text_dst != NULL) {
-                       delete m_text_dst;
-               }
+               delete m_text_dst;
                m_text_dst = text_dst;
        }
 
@@ -382,7 +377,6 @@ class GUIFormSpecMenu : public GUIModalMenu
        v2s32 pos_offset;
        std::stack<v2s32> container_stack;
 
-       irr::IrrlichtDevice* m_device;
        InventoryManager *m_invmgr;
        ISimpleTextureSource *m_tsrc;
        Client *m_client;
@@ -390,14 +384,13 @@ class GUIFormSpecMenu : public GUIModalMenu
        std::string m_formspec_string;
        InventoryLocation m_current_inventory_location;
 
-
        std::vector<ListDrawSpec> m_inventorylists;
        std::vector<ListRingSpec> m_inventory_rings;
        std::vector<ImageDrawSpec> m_backgrounds;
        std::vector<ImageDrawSpec> m_images;
        std::vector<ImageDrawSpec> m_itemimages;
        std::vector<BoxDrawSpec> m_boxes;
-       UNORDERED_MAP<std::string, bool> field_close_on_enter;
+       std::unordered_map<std::string, bool> field_close_on_enter;
        std::vector<FieldSpec> m_fields;
        std::vector<StaticTextSpec> m_static_texts;
        std::vector<std::pair<FieldSpec,GUITable*> > m_tables;
@@ -406,9 +399,9 @@ class GUIFormSpecMenu : public GUIModalMenu
        std::vector<std::pair<FieldSpec,gui::IGUIScrollBar*> > m_scrollbars;
        std::vector<std::pair<FieldSpec, std::vector<std::string> > > m_dropdowns;
 
-       ItemSpec *m_selected_item;
-       u32 m_selected_amount;
-       bool m_selected_dragging;
+       ItemSpec *m_selected_item = nullptr;
+       u32 m_selected_amount = 0;
+       bool m_selected_dragging = false;
 
        // WARNING: BLACK MAGIC
        // Used to guess and keep up with some special things the server can do.
@@ -418,17 +411,16 @@ class GUIFormSpecMenu : public GUIModalMenu
 
        v2s32 m_pointer;
        v2s32 m_old_pointer;  // Mouse position after previous mouse event
-       gui::IGUIStaticText *m_tooltip_element;
+       gui::IGUIStaticText *m_tooltip_element = nullptr;
 
        u64 m_tooltip_show_delay;
-       u64 m_hovered_time;
-       s32 m_old_tooltip_id;
-       std::wstring m_old_tooltip;
+       u64 m_hovered_time = 0;
+       s32 m_old_tooltip_id = -1;
 
-       bool m_rmouse_auto_place;
+       bool m_rmouse_auto_place = false;
 
-       bool m_allowclose;
-       bool m_lock;
+       bool m_allowclose = true;
+       bool m_lock = false;
        v2u32 m_lockscreensize;
 
        bool m_bgfullscreen;
@@ -443,8 +435,8 @@ class GUIFormSpecMenu : public GUIModalMenu
 private:
        IFormSource        *m_form_src;
        TextDest           *m_text_dst;
-       unsigned int        m_formspec_version;
-       std::string         m_focused_element;
+       u32                 m_formspec_version = 0;
+       std::string         m_focused_element = "";
        JoystickController *m_joystick;
 
        typedef struct {
@@ -460,7 +452,7 @@ class GUIFormSpecMenu : public GUIModalMenu
                GUITable::TableOptions table_options;
                GUITable::TableColumns table_columns;
                // used to restore table selection/scroll/treeview state
-               UNORDERED_MAP<std::string, GUITable::DynamicData> table_dyndata;
+               std::unordered_map<std::string, GUITable::DynamicData> table_dyndata;
        } parserData;
 
        typedef struct {
@@ -471,7 +463,7 @@ class GUIFormSpecMenu : public GUIModalMenu
        } fs_key_pendig;
 
        fs_key_pendig current_keys_pending;
-       std::string current_field_enter_pending;
+       std::string current_field_enter_pending = "";
 
        void parseElement(parserData* data, const std::string &element);
 
@@ -535,7 +527,7 @@ class GUIFormSpecMenu : public GUIModalMenu
        clickpos m_doubleclickdetect[2];
 
        int m_btn_height;
-       gui::IGUIFont *m_font;
+       gui::IGUIFont *m_font = nullptr;
 
        std::wstring getLabelByID(s32 id);
        std::string getNameByID(s32 id);