diff options
Diffstat (limited to 'editor/doc_tools.cpp')
-rw-r--r-- | editor/doc_tools.cpp | 97 |
1 files changed, 54 insertions, 43 deletions
diff --git a/editor/doc_tools.cpp b/editor/doc_tools.cpp index c752d0d4fd..56a9d2c258 100644 --- a/editor/doc_tools.cpp +++ b/editor/doc_tools.cpp @@ -145,15 +145,15 @@ void DocTools::merge_from(const DocTools &p_data) { } for (int i = 0; i < c.theme_properties.size(); i++) { - DocData::PropertyDoc &p = c.theme_properties.write[i]; + DocData::ThemeItemDoc &ti = c.theme_properties.write[i]; for (int j = 0; j < cf.theme_properties.size(); j++) { - if (cf.theme_properties[j].name != p.name) { + if (cf.theme_properties[j].name != ti.name || cf.theme_properties[j].data_type != ti.data_type) { continue; } - const DocData::PropertyDoc &pf = cf.theme_properties[j]; + const DocData::ThemeItemDoc &pf = cf.theme_properties[j]; - p.description = pf.description; + ti.description = pf.description; break; } } @@ -464,60 +464,69 @@ void DocTools::generate(bool p_basic_types) { c.constants.push_back(constant); } - //theme stuff - + // Theme items. { List<StringName> l; - Theme::get_default()->get_constant_list(cname, &l); - for (const StringName &E : l) { - DocData::PropertyDoc pd; - pd.name = E; - pd.type = "int"; - pd.default_value = itos(Theme::get_default()->get_constant(E, cname)); - c.theme_properties.push_back(pd); - } - l.clear(); Theme::get_default()->get_color_list(cname, &l); for (const StringName &E : l) { - DocData::PropertyDoc pd; - pd.name = E; - pd.type = "Color"; - pd.default_value = Variant(Theme::get_default()->get_color(E, cname)).get_construct_string(); - c.theme_properties.push_back(pd); + DocData::ThemeItemDoc tid; + tid.name = E; + tid.type = "Color"; + tid.data_type = "color"; + tid.default_value = Variant(Theme::get_default()->get_color(E, cname)).get_construct_string(); + c.theme_properties.push_back(tid); } l.clear(); - Theme::get_default()->get_icon_list(cname, &l); + Theme::get_default()->get_constant_list(cname, &l); for (const StringName &E : l) { - DocData::PropertyDoc pd; - pd.name = E; - pd.type = "Texture2D"; - c.theme_properties.push_back(pd); + DocData::ThemeItemDoc tid; + tid.name = E; + tid.type = "int"; + tid.data_type = "constant"; + tid.default_value = itos(Theme::get_default()->get_constant(E, cname)); + c.theme_properties.push_back(tid); } + l.clear(); Theme::get_default()->get_font_list(cname, &l); for (const StringName &E : l) { - DocData::PropertyDoc pd; - pd.name = E; - pd.type = "Font"; - c.theme_properties.push_back(pd); + DocData::ThemeItemDoc tid; + tid.name = E; + tid.type = "Font"; + tid.data_type = "font"; + c.theme_properties.push_back(tid); } + l.clear(); Theme::get_default()->get_font_size_list(cname, &l); for (const StringName &E : l) { - DocData::PropertyDoc pd; - pd.name = E; - pd.type = "int"; - c.theme_properties.push_back(pd); + DocData::ThemeItemDoc tid; + tid.name = E; + tid.type = "int"; + tid.data_type = "font_size"; + c.theme_properties.push_back(tid); + } + + l.clear(); + Theme::get_default()->get_icon_list(cname, &l); + for (const StringName &E : l) { + DocData::ThemeItemDoc tid; + tid.name = E; + tid.type = "Texture2D"; + tid.data_type = "icon"; + c.theme_properties.push_back(tid); } + l.clear(); Theme::get_default()->get_stylebox_list(cname, &l); for (const StringName &E : l) { - DocData::PropertyDoc pd; - pd.name = E; - pd.type = "StyleBox"; - c.theme_properties.push_back(pd); + DocData::ThemeItemDoc tid; + tid.name = E; + tid.type = "StyleBox"; + tid.data_type = "style"; + c.theme_properties.push_back(tid); } } @@ -1069,12 +1078,14 @@ Error DocTools::_load(Ref<XMLParser> parser) { String name3 = parser->get_node_name(); if (name3 == "theme_item") { - DocData::PropertyDoc prop2; + DocData::ThemeItemDoc prop2; ERR_FAIL_COND_V(!parser->has_attribute("name"), ERR_FILE_CORRUPT); prop2.name = parser->get_attribute_value("name"); ERR_FAIL_COND_V(!parser->has_attribute("type"), ERR_FILE_CORRUPT); prop2.type = parser->get_attribute_value("type"); + ERR_FAIL_COND_V(!parser->has_attribute("data_type"), ERR_FILE_CORRUPT); + prop2.data_type = parser->get_attribute_value("data_type"); if (!parser->is_empty()) { parser->read(); if (parser->get_node_type() == XMLParser::NODE_TEXT) { @@ -1312,15 +1323,15 @@ Error DocTools::save_classes(const String &p_default_path, const Map<String, Str _write_string(f, 1, "<theme_items>"); for (int i = 0; i < c.theme_properties.size(); i++) { - const DocData::PropertyDoc &p = c.theme_properties[i]; + const DocData::ThemeItemDoc &ti = c.theme_properties[i]; - if (p.default_value != "") { - _write_string(f, 2, "<theme_item name=\"" + p.name + "\" type=\"" + p.type + "\" default=\"" + p.default_value.xml_escape(true) + "\">"); + if (ti.default_value != "") { + _write_string(f, 2, "<theme_item name=\"" + ti.name + "\" data_type=\"" + ti.data_type + "\" type=\"" + ti.type + "\" default=\"" + ti.default_value.xml_escape(true) + "\">"); } else { - _write_string(f, 2, "<theme_item name=\"" + p.name + "\" type=\"" + p.type + "\">"); + _write_string(f, 2, "<theme_item name=\"" + ti.name + "\" data_type=\"" + ti.data_type + "\" type=\"" + ti.type + "\">"); } - _write_string(f, 3, p.description.strip_edges().xml_escape()); + _write_string(f, 3, ti.description.strip_edges().xml_escape()); _write_string(f, 2, "</theme_item>"); } |