aboutsummaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorSmallJoker <mk939@ymail.com>2019-09-10 21:18:42 +0200
committerSmallJoker <mk939@ymail.com>2019-09-14 19:43:08 +0200
commit9acd36bf9981cf9cb8e82785508d6eb7f010cc77 (patch)
tree6f0fae04efa009e8fd0a13dd0ab613c8010ae764 /src/gui
parentb0baa698a495cc990ce5d9c22763957f1138aed3 (diff)
downloadminetest-9acd36bf9981cf9cb8e82785508d6eb7f010cc77.tar.gz
minetest-9acd36bf9981cf9cb8e82785508d6eb7f010cc77.tar.bz2
minetest-9acd36bf9981cf9cb8e82785508d6eb7f010cc77.zip
Formspecs: Introduce formspec_version to mods
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/guiFormSpecMenu.cpp9
-rw-r--r--src/gui/guiFormSpecMenu.h4
2 files changed, 10 insertions, 3 deletions
diff --git a/src/gui/guiFormSpecMenu.cpp b/src/gui/guiFormSpecMenu.cpp
index e02abf018..f291b4e87 100644
--- a/src/gui/guiFormSpecMenu.cpp
+++ b/src/gui/guiFormSpecMenu.cpp
@@ -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
}
diff --git a/src/gui/guiFormSpecMenu.h b/src/gui/guiFormSpecMenu.h
index e4dc66151..46df0930c 100644
--- a/src/gui/guiFormSpecMenu.h
+++ b/src/gui/guiFormSpecMenu.h
@@ -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