m_form_src(fsrc),
m_text_dst(tdst),
m_ext_ptr(ext_ptr),
- m_font(dev->getGUIEnvironment()->getSkin()->getFont())
+ m_font(dev->getGUIEnvironment()->getSkin()->getFont()),
+ m_formspec_version(0)
{
current_keys_pending.key_down = false;
current_keys_pending.key_up = false;
{
std::vector<std::string> parts = split(element,',');
- if ((parts.size() == 2) || parts.size() == 3) {
+ if (((parts.size() == 2) || parts.size() == 3) ||
+ ((parts.size() > 3) && (m_formspec_version > FORMSPEC_API_VERSION)))
+ {
v2f invsize;
if (parts[1].find(';') != std::string::npos)
std::vector<std::string> parts = split(element,';');
- if ((parts.size() == 4) || (parts.size() == 5)) {
+ if (((parts.size() == 4) || (parts.size() == 5)) ||
+ ((parts.size() > 5) && (m_formspec_version > FORMSPEC_API_VERSION)))
+ {
std::string location = parts[0];
std::string listname = parts[1];
std::vector<std::string> v_pos = split(parts[2],',');
{
std::vector<std::string> parts = split(element,';');
- if ((parts.size() >= 3) || (parts.size() <= 4)) {
+ if (((parts.size() >= 3) || (parts.size() <= 4)) ||
+ ((parts.size() > 4) && (m_formspec_version > FORMSPEC_API_VERSION)))
+ {
std::vector<std::string> v_pos = split(parts[0],',');
std::string name = parts[1];
std::string label = parts[2];
{
std::vector<std::string> parts = split(element,';');
- if (parts.size() == 3) {
+ if ((parts.size() == 3) ||
+ ((parts.size() > 3) && (m_formspec_version > FORMSPEC_API_VERSION)))
+ {
std::vector<std::string> v_pos = split(parts[0],',');
std::vector<std::string> v_geom = split(parts[1],',');
std::string name = unescape_string(parts[2]);
{
std::vector<std::string> parts = split(element,';');
- if (parts.size() == 3) {
+ if ((parts.size() == 3) ||
+ ((parts.size() > 3) && (m_formspec_version > FORMSPEC_API_VERSION)))
+ {
std::vector<std::string> v_pos = split(parts[0],',');
std::vector<std::string> v_geom = split(parts[1],',');
std::string name = parts[2];
{
std::vector<std::string> parts = split(element,';');
- if (parts.size() == 4) {
+ if ((parts.size() == 4) ||
+ ((parts.size() > 4) && (m_formspec_version > FORMSPEC_API_VERSION)))
+ {
std::vector<std::string> v_pos = split(parts[0],',');
std::vector<std::string> v_geom = split(parts[1],',');
std::string name = parts[2];
{
std::vector<std::string> parts = split(element,';');
- if ((parts.size() == 3) || (parts.size() == 4)) {
+ if (((parts.size() == 3) || (parts.size() == 4)) ||
+ ((parts.size() > 4) && (m_formspec_version > FORMSPEC_API_VERSION)))
+ {
std::vector<std::string> v_pos = split(parts[0],',');
std::vector<std::string> v_geom = split(parts[1],',');
std::string name = unescape_string(parts[2]);
{
std::vector<std::string> parts = split(element,';');
- if ((parts.size() == 4) || (parts.size() == 5)) {
+ if (((parts.size() == 4) || (parts.size() == 5)) ||
+ ((parts.size() > 5) && (m_formspec_version > FORMSPEC_API_VERSION)))
+ {
std::vector<std::string> v_pos = split(parts[0],',');
std::vector<std::string> v_geom = split(parts[1],',');
std::string name = parts[2];
{
std::vector<std::string> parts = split(element,';');
- if ((parts.size() == 4) || (parts.size() == 5) || (parts.size() == 6)) {
+ if (((parts.size() == 4) || (parts.size() == 5) || (parts.size() == 6)) ||
+ ((parts.size() > 6) && (m_formspec_version > FORMSPEC_API_VERSION)))
+ {
std::vector<std::string> v_pos = split(parts[0],',');
std::vector<std::string> v_geom = split(parts[1],',');
std::string name = parts[2];
{
std::vector<std::string> parts = split(element,';');
- if (parts.size() == 5) {
+ if ((parts.size() == 5) ||
+ ((parts.size() > 5) && (m_formspec_version > FORMSPEC_API_VERSION)))
+ {
std::vector<std::string> v_pos = split(parts[0],',');
std::string name = parts[2];
std::vector<std::string> items = split(parts[3],',');
{
std::vector<std::string> parts = split(element,';');
- if (parts.size() == 4) {
+ if ((parts.size() == 4) ||
+ ((parts.size() > 4) && (m_formspec_version > FORMSPEC_API_VERSION)))
+ {
std::vector<std::string> v_pos = split(parts[0],',');
std::vector<std::string> v_geom = split(parts[1],',');
std::string name = parts[2];
return;
}
- if (parts.size() == 5) {
+ if ((parts.size() == 5) ||
+ ((parts.size() > 5) && (m_formspec_version > FORMSPEC_API_VERSION)))
+ {
parseTextArea(data,parts,type);
return;
}
{
std::vector<std::string> parts = split(element,';');
- if (parts.size() == 2) {
+ if ((parts.size() == 2) ||
+ ((parts.size() > 2) && (m_formspec_version > FORMSPEC_API_VERSION)))
+ {
std::vector<std::string> v_pos = split(parts[0],',');
std::string text = parts[1];
{
std::vector<std::string> parts = split(element,';');
- if (parts.size() == 2) {
+ if ((parts.size() == 2) ||
+ ((parts.size() > 2) && (m_formspec_version > FORMSPEC_API_VERSION)))
+ {
std::vector<std::string> v_pos = split(parts[0],',');
std::wstring text = narrow_to_wide(unescape_string(parts[1]));
{
std::vector<std::string> parts = split(element,';');
- if (((parts.size() >= 5) && (parts.size() <= 8)) && (parts.size() != 6)) {
+ if ((((parts.size() >= 5) && (parts.size() <= 8)) && (parts.size() != 6)) ||
+ ((parts.size() > 8) && (m_formspec_version > FORMSPEC_API_VERSION)))
+ {
std::vector<std::string> v_pos = split(parts[0],',');
std::vector<std::string> v_geom = split(parts[1],',');
std::string image_name = parts[2];
{
std::vector<std::string> parts = split(element,';');
- if ((parts.size() == 4) || (parts.size() == 6)) {
+ if (((parts.size() == 4) || (parts.size() == 6)) ||
+ ((parts.size() > 6) && (m_formspec_version > FORMSPEC_API_VERSION)))
+ {
std::vector<std::string> v_pos = split(parts[0],',');
std::string name = parts[1];
std::vector<std::string> buttons = split(parts[2],',');
std::vector<std::string> parts = split(element,';');
- if (parts.size() == 5) {
+ if ((parts.size() == 5) ||
+ ((parts.size() > 5) && (m_formspec_version > FORMSPEC_API_VERSION)))
+ {
std::vector<std::string> v_pos = split(parts[0],',');
std::vector<std::string> v_geom = split(parts[1],',');
std::string item_name = parts[2];
{
std::vector<std::string> parts = split(element,';');
- if (parts.size() == 3) {
+ if ((parts.size() == 3) ||
+ ((parts.size() > 3) && (m_formspec_version > FORMSPEC_API_VERSION)))
+ {
std::vector<std::string> v_pos = split(parts[0],',');
std::vector<std::string> v_geom = split(parts[1],',');
{
std::vector<std::string> parts = split(element,';');
- if ((parts.size() == 1) || (parts.size() == 2)) {
+ if (((parts.size() == 1) || (parts.size() == 2)) ||
+ ((parts.size() > 2) && (m_formspec_version > FORMSPEC_API_VERSION)))
+ {
parseColor(parts[0],m_bgcolor,false);
if (parts.size() == 2) {
{
std::vector<std::string> parts = split(element,';');
- if ((parts.size() == 2) || (parts.size() == 3) || (parts.size() == 5)) {
+ if (((parts.size() == 2) || (parts.size() == 3) || (parts.size() == 5)) ||
+ ((parts.size() > 5) && (m_formspec_version > FORMSPEC_API_VERSION)))
+ {
parseColor(parts[0], m_slotbg_n, false);
parseColor(parts[1], m_slotbg_h, false);
std::vector<std::string> parts = split(element,';');
if (parts.size() == 2) {
std::string name = parts[0];
- m_tooltips[narrow_to_wide(name.c_str())] = TooltipSpec (parts[1], m_default_tooltip_bgcolor, m_default_tooltip_color);
+ m_tooltips[narrow_to_wide(name.c_str())] = TooltipSpec (parts[1], m_default_tooltip_bgcolor, m_default_tooltip_color);
return;
} else if (parts.size() == 4) {
std::string name = parts[0];
video::SColor tmp_color1, tmp_color2;
- if ( parseColor(parts[2], tmp_color1, false) && parseColor(parts[3], tmp_color2, false) ) {
+ if ( parseColor(parts[2], tmp_color1, false) && parseColor(parts[3], tmp_color2, false) ) {
m_tooltips[narrow_to_wide(name.c_str())] = TooltipSpec (parts[1], tmp_color1, tmp_color2);
return;
}
errorstream<< "Invalid tooltip element(" << parts.size() << "): '" << element << "'" << std::endl;
}
-void GUIFormSpecMenu::parseElement(parserData* data,std::string element)
+bool GUIFormSpecMenu::parseVersionDirect(std::string data)
+{
+ //some prechecks
+ if (data == "")
+ return false;
+
+ std::vector<std::string> parts = split(data,'[');
+
+ if (parts.size() < 2) {
+ return false;
+ }
+
+ if (parts[0] != "formspec_version") {
+ return false;
+ }
+
+ if (is_number(parts[1])) {
+ m_formspec_version = mystoi(parts[1]);
+ return true;
+ }
+
+ return false;
+}
+
+void GUIFormSpecMenu::parseElement(parserData* data, std::string element)
{
//some prechecks
if (element == "")
m_tooltip_element->grab();
}
-
std::vector<std::string> elements = split(m_formspec_string,']');
- for (unsigned int i=0; i< elements.size(); i++) {
- parseElement(&mydata,elements[i]);
+ unsigned int i = 0;
+
+ /* try to read version from first element only */
+ if (elements.size() >= 1) {
+ if ( parseVersionDirect(elements[0]) ) {
+ i++;
+ }
+ }
+
+ for (; i< elements.size(); i++) {
+ parseElement(&mydata, elements[i]);
}
// If there's fields, add a Proceed button
m_tooltip_element->setVisible(true);
this->bringToFront(m_tooltip_element);
break;
- }
+ }
}
}
}
- skip_tooltip:
+ skip_tooltip:
/*
Draw dragged item stack
*/