mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
[godot] Fix more handling of CJK in names, see #2788
This commit is contained in:
parent
88f69fb2a6
commit
56cd91047c
@ -47,7 +47,9 @@ void SpineAnimation::_bind_methods() {
|
||||
|
||||
String SpineAnimation::get_name() {
|
||||
SPINE_CHECK(get_spine_object(), "")
|
||||
return get_spine_object()->getName().buffer();
|
||||
String name;
|
||||
name.parse_utf8(get_spine_object()->getName().buffer());
|
||||
return name;
|
||||
}
|
||||
|
||||
float SpineAnimation::get_duration() {
|
||||
|
||||
@ -250,7 +250,9 @@ Ref<Animation> SpineAnimationTrack::create_animation(spine::Animation *animation
|
||||
|
||||
Ref<Animation> animation_ref;
|
||||
INSTANTIATE(animation_ref);
|
||||
animation_ref->set_name(String(animation->getName().buffer()) + (loop ? "" : "_looped"));
|
||||
String name;
|
||||
name.parse_utf8(animation.getName().buffer());
|
||||
animation_ref->set_name(name + (loop ? "" : "_looped"));
|
||||
#if VERSION_MAJOR > 3
|
||||
// animation_ref->set_loop(!loop);
|
||||
#else
|
||||
@ -260,7 +262,7 @@ Ref<Animation> SpineAnimationTrack::create_animation(spine::Animation *animation
|
||||
|
||||
animation_ref->add_track(Animation::TYPE_VALUE);
|
||||
animation_ref->track_set_path(0, NodePath(".:animation_name"));
|
||||
animation_ref->track_insert_key(0, 0, animation->getName().buffer());
|
||||
animation_ref->track_insert_key(0, 0, name);
|
||||
|
||||
animation_ref->add_track(Animation::TYPE_VALUE);
|
||||
animation_ref->track_set_path(1, NodePath(".:loop"));
|
||||
@ -298,7 +300,9 @@ void SpineAnimationTrack::update_animation_state(const Variant &variant_sprite)
|
||||
}
|
||||
auto current_entry = animation_state->getCurrent(track_index);
|
||||
bool should_set_mix = mix_duration >= 0;
|
||||
bool should_set_animation = !current_entry || (animation_name != current_entry->getAnimation()->getName().buffer() || current_entry->getLoop() != loop);
|
||||
String other_name;
|
||||
if (current_entry) other_name.parse_utf8(current_entry->getAnimation()->getName().buffer());
|
||||
bool should_set_animation = !current_entry || (animation_name != other_name || current_entry->getLoop() != loop);
|
||||
|
||||
if (should_set_animation) {
|
||||
if (!EMPTY(animation_name)) {
|
||||
@ -316,7 +320,7 @@ void SpineAnimationTrack::update_animation_state(const Variant &variant_sprite)
|
||||
|
||||
if (debug) print_line(String("Setting animation {0} with mix_duration {1} on track {2} on {3}").format(varray(animation_name, mix_duration, track_index, sprite->get_name())).utf8().ptr());
|
||||
} else {
|
||||
if (!current_entry || (String("<empty>") != current_entry->getAnimation()->getName().buffer())) {
|
||||
if (!current_entry || (String("<empty>") != other_name)) {
|
||||
auto entry = animation_state->setEmptyAnimation(track_index, should_set_mix ? mix_duration : 0);
|
||||
entry->setTrackEnd(FLT_MAX);
|
||||
if (debug) print_line(String("Setting empty animation with mix_duration {0} on track {1} on {2}").format(varray(mix_duration, track_index, sprite->get_name())).utf8().ptr());
|
||||
@ -423,7 +427,9 @@ void SpineAnimationTrack::update_animation_state(const Variant &variant_sprite)
|
||||
if (animation_player->is_playing()) {
|
||||
auto current_entry = animation_state->getCurrent(track_index);
|
||||
bool should_set_mix = mix_duration >= 0;
|
||||
bool should_set_animation = !current_entry || (animation_name != current_entry->getAnimation()->getName().buffer() || current_entry->getLoop() != loop) || animation_changed;
|
||||
String other_name;
|
||||
if (current_entry) other_name.parse_utf8(current_entry->getAnimation()->getName().buffer());
|
||||
bool should_set_animation = !current_entry || (animation_name != other_name || current_entry->getLoop() != loop) || animation_changed;
|
||||
animation_changed = false;
|
||||
|
||||
if (should_set_animation) {
|
||||
@ -442,7 +448,7 @@ void SpineAnimationTrack::update_animation_state(const Variant &variant_sprite)
|
||||
|
||||
if (debug) print_line(String("Setting animation {0} with mix_duration {1} on track {2} on {3}").format(varray(animation_name, mix_duration, track_index, sprite->get_name())).utf8().ptr());
|
||||
} else {
|
||||
if (!current_entry || (String("<empty>") != current_entry->getAnimation()->getName().buffer())) {
|
||||
if (!current_entry || (String("<empty>") != other_name)) {
|
||||
auto entry = animation_state->setEmptyAnimation(track_index, should_set_mix ? mix_duration : 0);
|
||||
entry->setTrackEnd(FLT_MAX);
|
||||
if (debug) print_line(String("Setting empty animation with mix_duration {0} on track {1} on {2}").format(varray(mix_duration, track_index, sprite->get_name())).utf8().ptr());
|
||||
|
||||
@ -41,7 +41,9 @@ SpineAttachment::~SpineAttachment() {
|
||||
|
||||
String SpineAttachment::get_attachment_name() {
|
||||
SPINE_CHECK(get_spine_object(), "")
|
||||
return get_spine_object()->getName().buffer();
|
||||
String name;
|
||||
name.parse_utf8(get_spine_object()->getName().buffer());
|
||||
return name;
|
||||
}
|
||||
|
||||
Ref<SpineAttachment> SpineAttachment::copy() {
|
||||
|
||||
@ -68,7 +68,9 @@ int SpineBoneData::get_index() {
|
||||
|
||||
String SpineBoneData::get_bone_name() {
|
||||
SPINE_CHECK(get_spine_object(), "")
|
||||
return get_spine_object()->getName().buffer();
|
||||
String name;
|
||||
name.parse_utf8(get_spine_object()->getName().buffer());
|
||||
return name;
|
||||
}
|
||||
|
||||
Ref<SpineBoneData> SpineBoneData::get_parent() {
|
||||
|
||||
@ -41,7 +41,9 @@ void SpineConstraintData::_bind_methods() {
|
||||
|
||||
String SpineConstraintData::get_constraint_name() {
|
||||
SPINE_CHECK(get_spine_object(), "")
|
||||
return get_spine_object()->getName().buffer();
|
||||
String name;
|
||||
name.parse_utf8(get_spine_object()->getName().buffer());
|
||||
return name;
|
||||
}
|
||||
|
||||
int SpineConstraintData::get_order() {
|
||||
|
||||
@ -48,7 +48,9 @@ void SpineEventData::_bind_methods() {
|
||||
|
||||
String SpineEventData::get_event_name() {
|
||||
SPINE_CHECK(get_spine_object(), "")
|
||||
return get_spine_object()->getName().buffer();
|
||||
String name;
|
||||
name.parse_utf8(get_spine_object()->getName().buffer());
|
||||
return name;
|
||||
}
|
||||
|
||||
int SpineEventData::get_int_value() {
|
||||
|
||||
@ -627,7 +627,9 @@ SpineSkeletonDataResource::find_physics_constraint(
|
||||
|
||||
String SpineSkeletonDataResource::get_skeleton_name() const {
|
||||
SPINE_CHECK(skeleton_data, "")
|
||||
return skeleton_data->getName().buffer();
|
||||
String name;
|
||||
name.parse_utf8(skeleton_data->getName().buffer());
|
||||
return name;
|
||||
}
|
||||
|
||||
Array SpineSkeletonDataResource::get_bones() const {
|
||||
|
||||
@ -123,7 +123,9 @@ Array SpineSkin::find_attachments_for_slot(int slot_index) {
|
||||
|
||||
String SpineSkin::get_name() {
|
||||
SPINE_CHECK(get_spine_object(), "")
|
||||
return get_spine_object()->getName().buffer();
|
||||
String name;
|
||||
name.parse_utf8(get_spine_object()->getName().buffer());
|
||||
return name;
|
||||
}
|
||||
|
||||
void SpineSkin::add_skin(Ref<SpineSkin> other) {
|
||||
|
||||
@ -53,7 +53,9 @@ int SpineSlotData::get_index() {
|
||||
|
||||
String SpineSlotData::get_name() {
|
||||
SPINE_CHECK(get_spine_object(), String(""))
|
||||
return get_spine_object()->getName().buffer();
|
||||
String name;
|
||||
name.parse_utf8(get_spine_object()->getName().buffer());
|
||||
return name;
|
||||
}
|
||||
|
||||
Ref<SpineBoneData> SpineSlotData::get_bone_data() {
|
||||
|
||||
@ -1223,7 +1223,9 @@ void SpineSprite::draw() {
|
||||
float inverse_zoom = 1 / get_viewport()->get_global_canvas_transform().get_scale().x * editor_scale;
|
||||
Vector<String> hover_text_lines;
|
||||
if (hovered_slot) {
|
||||
hover_text_lines.push_back(String("Slot: ") + hovered_slot->getData().getName().buffer());
|
||||
String name;
|
||||
name.parse_utf8(hovered_slot->getData().getName().buffer());
|
||||
hover_text_lines.push_back(String("Slot: ") + name);
|
||||
}
|
||||
|
||||
if (hovered_bone) {
|
||||
@ -1231,7 +1233,9 @@ void SpineSprite::draw() {
|
||||
debug_bones_thickness *= 1.1;
|
||||
draw_bone(hovered_bone, Color(debug_bones_color.r, debug_bones_color.g, debug_bones_color.b, 1));
|
||||
debug_bones_thickness = thickness;
|
||||
hover_text_lines.push_back(String("Bone: ") + hovered_bone->getData().getName().buffer());
|
||||
String name;
|
||||
name.parse_utf8(hovered_bone->getData().getName().buffer());
|
||||
hover_text_lines.push_back(String("Bone: ") + name);
|
||||
}
|
||||
|
||||
auto global_scale = get_global_scale();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user