summaryrefslogtreecommitdiffstats
path: root/editor/plugins/font_config_plugin.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/plugins/font_config_plugin.cpp')
-rw-r--r--editor/plugins/font_config_plugin.cpp47
1 files changed, 39 insertions, 8 deletions
diff --git a/editor/plugins/font_config_plugin.cpp b/editor/plugins/font_config_plugin.cpp
index 15b268337f..e6ce63fe36 100644
--- a/editor/plugins/font_config_plugin.cpp
+++ b/editor/plugins/font_config_plugin.cpp
@@ -386,15 +386,8 @@ EditorPropertyFontMetaOverride::EditorPropertyFontMetaOverride(bool p_script) {
void EditorPropertyOTVariation::_property_changed(const String &p_property, const Variant &p_value, const String &p_name, bool p_changing) {
if (p_property.begins_with("keys")) {
Dictionary dict = object->get_dict();
- Dictionary defaults_dict = object->get_defaults();
int key = p_property.get_slice("/", 1).to_int();
dict[key] = (int)p_value;
- if (defaults_dict.has(key)) {
- Vector3i range = defaults_dict[key];
- if (range.z == (int)p_value) {
- dict.erase(key);
- }
- }
emit_changed(get_edited_property(), dict, "", true);
@@ -422,6 +415,14 @@ void EditorPropertyOTVariation::update_property() {
Dictionary supported = (fd.is_valid()) ? fd->get_supported_variation_list() : Dictionary();
+ for (int i = 0; i < supported.size(); i++) {
+ int name_tag = supported.get_key_at_index(i);
+ Vector3i range = supported.get_value_at_index(i);
+ if ((dict.has(name_tag) && dict[name_tag].get_type() == Variant::NIL) || !dict.has(name_tag)) {
+ dict[name_tag] = range.z;
+ }
+ }
+
edit->set_text(vformat(TTR("Variation Coordinates (%d)"), supported.size()));
bool unfolded = get_edited_object()->editor_is_section_unfolded(get_edited_property());
@@ -481,7 +482,21 @@ void EditorPropertyOTVariation::update_property() {
prop->set_object_and_property(object.ptr(), "keys/" + itos(name_tag));
String name = TS->tag_to_name(name_tag);
- prop->set_label(name.capitalize());
+ String name_cap;
+ {
+ String aux = name.replace("_", " ").strip_edges();
+ for (int j = 0; j < aux.get_slice_count(" "); j++) {
+ String slice = aux.get_slicec(' ', j);
+ if (slice.length() > 0) {
+ slice[0] = String::char_uppercase(slice[0]);
+ if (i > 0) {
+ name_cap += " ";
+ }
+ name_cap += slice;
+ }
+ }
+ }
+ prop->set_label(name_cap);
prop->set_tooltip_text(name);
prop->set_selectable(false);
@@ -935,6 +950,12 @@ void FontPreview::_notification(int p_what) {
font->draw_string(get_canvas_item(), Point2(0, font->get_height(font_size) + 2 * EDSCALE), TTR("Unable to preview font"), HORIZONTAL_ALIGNMENT_CENTER, get_size().x, font_size, text_color);
}
} break;
+
+ case NOTIFICATION_EXIT_TREE: {
+ if (prev_font.is_valid()) {
+ prev_font->disconnect_changed(callable_mp(this, &FontPreview::_preview_changed));
+ }
+ } break;
}
}
@@ -945,7 +966,17 @@ Size2 FontPreview::get_minimum_size() const {
}
void FontPreview::set_data(const Ref<Font> &p_f) {
+ if (prev_font.is_valid()) {
+ prev_font->disconnect_changed(callable_mp(this, &FontPreview::_preview_changed));
+ }
prev_font = p_f;
+ if (prev_font.is_valid()) {
+ prev_font->connect_changed(callable_mp(this, &FontPreview::_preview_changed));
+ }
+ queue_redraw();
+}
+
+void FontPreview::_preview_changed() {
queue_redraw();
}