1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

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
This commit is contained in:
SmallJoker 2019-11-20 19:39:10 +01:00 committed by GitHub
parent 60bff1e6cb
commit b50a166bb0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 53 additions and 60 deletions

View file

@ -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<s32> 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<std::string> *v_pos);
v2s32 getRealCoordinateBasePos(const std::vector<std::string> &v_pos);
v2s32 getRealCoordinateGeometry(const std::vector<std::string> &v_geom);