mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-02 16:38:41 +00:00
Formspecs: Introduce formspec_version to mods
This commit is contained in:
parent
b0baa698a4
commit
9acd36bf99
11 changed files with 54 additions and 10 deletions
|
@ -2167,6 +2167,9 @@ void GUIFormSpecMenu::parseElement(parserData* data, const std::string &element)
|
|||
if (element.empty())
|
||||
return;
|
||||
|
||||
if (parseVersionDirect(element))
|
||||
return;
|
||||
|
||||
std::vector<std::string> parts = split(element,'[');
|
||||
|
||||
// ugly workaround to keep compatibility
|
||||
|
@ -2503,7 +2506,7 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
|
|||
}
|
||||
|
||||
/* Copy of the "real_coordinates" element for after the form size. */
|
||||
mydata.real_coordinates = false;
|
||||
mydata.real_coordinates = m_formspec_version >= 2;
|
||||
for (; i < elements.size(); i++) {
|
||||
std::vector<std::string> parts = split(elements[i], '[');
|
||||
std::string name = trim(parts[0]);
|
||||
|
@ -2648,10 +2651,14 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
|
|||
if (enable_prepends) {
|
||||
// Backup the coordinates so that prepends can use the coordinates of choice.
|
||||
bool rc_backup = mydata.real_coordinates;
|
||||
bool version_backup = m_formspec_version;
|
||||
mydata.real_coordinates = false; // Old coordinates by default.
|
||||
|
||||
std::vector<std::string> prepend_elements = split(m_formspec_prepend, ']');
|
||||
for (const auto &element : prepend_elements)
|
||||
parseElement(&mydata, element);
|
||||
|
||||
m_formspec_version = version_backup;
|
||||
mydata.real_coordinates = rc_backup; // Restore coordinates
|
||||
}
|
||||
|
||||
|
|
|
@ -472,7 +472,7 @@ protected:
|
|||
private:
|
||||
IFormSource *m_form_src;
|
||||
TextDest *m_text_dst;
|
||||
u32 m_formspec_version = 0;
|
||||
u16 m_formspec_version = 1;
|
||||
std::string m_focused_element = "";
|
||||
JoystickController *m_joystick;
|
||||
|
||||
|
@ -591,7 +591,7 @@ public:
|
|||
|
||||
void setForm(const std::string &formspec)
|
||||
{
|
||||
m_formspec = FORMSPEC_VERSION_STRING + formspec;
|
||||
m_formspec = formspec;
|
||||
}
|
||||
|
||||
const std::string &getForm() const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue