summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/animation/tween.cpp14
-rw-r--r--scene/resources/dynamic_font.cpp36
-rw-r--r--scene/resources/dynamic_font.h2
3 files changed, 44 insertions, 8 deletions
diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp
index 854db5fee2..bd4396d680 100644
--- a/scene/animation/tween.cpp
+++ b/scene/animation/tween.cpp
@@ -701,21 +701,21 @@ void Tween::_tween_process(float p_delta) {
}
// Are all of the tweens complete?
- bool all_finished = true;
+ int any_unfinished = 0;
// For each tween we wish to interpolate...
for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) {
// Get the data from it
InterpolateData &data = E->get();
- // Track if we hit one that isn't finished yet
- all_finished = all_finished && data.finish;
-
// Is the data not active or already finished? No need to go any further
if (!data.active || data.finish) {
continue;
}
+ // Track if we hit one that isn't finished yet
+ any_unfinished++;
+
// Get the target object for this interpolation
Object *object = ObjectDB::get_instance(data.id);
if (object == nullptr) {
@@ -802,17 +802,15 @@ void Tween::_tween_process(float p_delta) {
// If we are not repeating the tween, remove it
if (!repeat) {
call_deferred("_remove_by_uid", data.uid);
+ any_unfinished--;
}
- } else if (!repeat) {
- // Check whether all tweens are finished
- all_finished = all_finished && data.finish;
}
}
// One less update left to go
pending_update--;
// If all tweens are completed, we no longer need to be active
- if (all_finished) {
+ if (any_unfinished == 0) {
set_active(false);
emit_signal("tween_all_completed");
}
diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp
index 3d99556a10..99f87dd6ed 100644
--- a/scene/resources/dynamic_font.cpp
+++ b/scene/resources/dynamic_font.cpp
@@ -290,6 +290,21 @@ Size2 DynamicFontAtSize::get_char_size(CharType p_char, CharType p_next, const V
return ret;
}
+String DynamicFontAtSize::get_available_chars() const {
+ String chars;
+
+ FT_UInt gindex;
+ FT_ULong charcode = FT_Get_First_Char(face, &gindex);
+ while (gindex != 0) {
+ if (charcode != 0) {
+ chars += CharType(charcode);
+ }
+ charcode = FT_Get_Next_Char(face, charcode, &gindex);
+ }
+
+ return chars;
+}
+
float DynamicFontAtSize::draw_char(RID p_canvas_item, const Point2 &p_pos, CharType p_char, CharType p_next, const Color &p_modulate, const Vector<Ref<DynamicFontAtSize>> &p_fallbacks, bool p_advance_only, bool p_outline) const {
if (!valid) {
return 0;
@@ -849,6 +864,25 @@ Size2 DynamicFont::get_char_size(CharType p_char, CharType p_next) const {
return ret;
}
+String DynamicFont::get_available_chars() const {
+ if (!data_at_size.is_valid()) {
+ return "";
+ }
+
+ String chars = data_at_size->get_available_chars();
+
+ for (int i = 0; i < fallback_data_at_size.size(); i++) {
+ String fallback_chars = fallback_data_at_size[i]->get_available_chars();
+ for (int j = 0; j < fallback_chars.length(); j++) {
+ if (chars.find_char(fallback_chars[j]) == -1) {
+ chars += fallback_chars[j];
+ }
+ }
+ }
+
+ return chars;
+}
+
bool DynamicFont::is_distance_field_hint() const {
return false;
}
@@ -964,6 +998,8 @@ void DynamicFont::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_font_data", "data"), &DynamicFont::set_font_data);
ClassDB::bind_method(D_METHOD("get_font_data"), &DynamicFont::get_font_data);
+ ClassDB::bind_method(D_METHOD("get_available_chars"), &DynamicFont::get_available_chars);
+
ClassDB::bind_method(D_METHOD("set_size", "data"), &DynamicFont::set_size);
ClassDB::bind_method(D_METHOD("get_size"), &DynamicFont::get_size);
diff --git a/scene/resources/dynamic_font.h b/scene/resources/dynamic_font.h
index 0afad428b3..e8637e7e34 100644
--- a/scene/resources/dynamic_font.h
+++ b/scene/resources/dynamic_font.h
@@ -189,6 +189,7 @@ public:
float get_underline_thickness() const;
Size2 get_char_size(CharType p_char, CharType p_next, const Vector<Ref<DynamicFontAtSize>> &p_fallbacks) const;
+ String get_available_chars() const;
float draw_char(RID p_canvas_item, const Point2 &p_pos, CharType p_char, CharType p_next, const Color &p_modulate, const Vector<Ref<DynamicFontAtSize>> &p_fallbacks, bool p_advance_only = false, bool p_outline = false) const;
@@ -277,6 +278,7 @@ public:
virtual float get_underline_thickness() const override;
virtual Size2 get_char_size(CharType p_char, CharType p_next = 0) const override;
+ String get_available_chars() const;
virtual bool is_distance_field_hint() const override;