Formspec: Fallback to 'label' in readonly textarea[]
authorSmallJoker <mk939@ymail.com>
Fri, 13 Oct 2017 21:05:52 +0000 (23:05 +0200)
committerSmallJoker <mk939@ymail.com>
Fri, 13 Oct 2017 21:14:39 +0000 (23:14 +0200)
Guarantees backwards compatibility for this formspec element change

src/guiFormSpecMenu.cpp

index 2abb725786379e128e468f44596fc803b7e7a965..0482f59a47b2e1465dbd317145abf86ff798314c 100644 (file)
@@ -1119,18 +1119,21 @@ void GUIFormSpecMenu::parseTextArea(parserData* data, std::vector<std::string>&
 
        if (is_editable)
                spec.send = true;
-       
-               gui::IGUIEditBox *e;
+
+       gui::IGUIEditBox *e = nullptr;
+       const wchar_t *text = spec.fdefault.empty() ?
+               wlabel.c_str() : spec.fdefault.c_str();
+
 #if USE_FREETYPE && IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR < 9
        if (g_settings->getBool("freetype")) {
-               e = (gui::IGUIEditBox *) new gui::intlGUIEditBox(spec.fdefault.c_str(),
+               e = (gui::IGUIEditBox *) new gui::intlGUIEditBox(text,
                        true, Environment, this, spec.fid, rect, is_editable, true);
                e->drop();
        } else {
 #else
        {
 #endif
-               e = new GUIEditBoxWithScrollBar(spec.fdefault.c_str(), true,
+               e = new GUIEditBoxWithScrollBar(text, true,
                        Environment, this, spec.fid, rect, is_editable, true);
        }