From b50a166bb05c4ebe1bf757190f4045d57a0d5f20 Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Wed, 20 Nov 2019 19:39:10 +0100 Subject: Formspec: Fix priorities for version < 3 (#9121) * Formspec: Fix priorities for version < 3 1) Introduce 'priority' to 'FieldSpec' 2) Sort elements based on 'priority' 3) Assign 'name' to the Item Image Button's image to show tooltips again --- src/gui/guiFormSpecMenu.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/gui/guiFormSpecMenu.h') diff --git a/src/gui/guiFormSpecMenu.h b/src/gui/guiFormSpecMenu.h index f15bba35a..5be639fa5 100644 --- a/src/gui/guiFormSpecMenu.h +++ b/src/gui/guiFormSpecMenu.h @@ -143,24 +143,27 @@ class GUIFormSpecMenu : public GUIModalMenu FieldSpec() = default; FieldSpec(const std::string &name, const std::wstring &label, - const std::wstring &default_text, int id) : + const std::wstring &default_text, s32 id, int priority = 0) : fname(name), flabel(label), fdefault(unescape_enriched(translate_string(default_text))), fid(id), send(false), ftype(f_Unknown), - is_exit(false) + is_exit(false), + priority(priority) { } std::string fname; std::wstring flabel; std::wstring fdefault; - int fid; + s32 fid; bool send; FormspecFieldType ftype; bool is_exit; + // Draw priority for formspec version < 3 + int priority; core::rect rect; }; @@ -309,7 +312,7 @@ protected: } std::wstring getLabelByID(s32 id); std::string getNameByID(s32 id); - FormspecFieldType getTypeByID(s32 id); + const FieldSpec *getSpecByID(s32 id); v2s32 getElementBasePos(const std::vector *v_pos); v2s32 getRealCoordinateBasePos(const std::vector &v_pos); v2s32 getRealCoordinateGeometry(const std::vector &v_geom); -- cgit v1.2.3