mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-25 22:23:42 +08:00
[godot] Fixes for latest Godot master commits.
This commit is contained in:
parent
ce73d3c986
commit
b96db92250
@ -29,8 +29,11 @@
|
||||
|
||||
#include "SpineBoneNode.h"
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
#include "core/config/engine.h"
|
||||
#else
|
||||
#include "core/engine.h"
|
||||
#include "editor/editor_about.h"
|
||||
#endif
|
||||
|
||||
void SpineBoneNode::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_bone_mode"), &SpineBoneNode::set_bone_mode);
|
||||
@ -56,7 +59,7 @@ void SpineBoneNode::_notification(int what) {
|
||||
SpineSprite *sprite = find_parent_sprite();
|
||||
if (sprite) {
|
||||
#if VERSION_MAJOR > 3
|
||||
sprite->connect("world_transforms_changed", callable_mp(this, &SpineSlotNode::on_world_transforms_changed));
|
||||
sprite->connect("world_transforms_changed", callable_mp(this, &SpineBoneNode::on_world_transforms_changed));
|
||||
#else
|
||||
sprite->connect("world_transforms_changed", this, "_on_world_transforms_changed");
|
||||
#endif
|
||||
@ -71,7 +74,7 @@ void SpineBoneNode::_notification(int what) {
|
||||
_change_notify("scale");
|
||||
#endif
|
||||
} else {
|
||||
WARN_PRINT("SpineSlotNode parent is not a SpineSprite.");
|
||||
WARN_PRINT("SpineBoneNode parent is not a SpineSprite.");
|
||||
}
|
||||
NOTIFY_PROPERTY_LIST_CHANGED();
|
||||
break;
|
||||
@ -80,7 +83,7 @@ void SpineBoneNode::_notification(int what) {
|
||||
SpineSprite *sprite = find_parent_sprite();
|
||||
if (sprite) {
|
||||
#if VERSION_MAJOR > 3
|
||||
sprite->disconnect("world_transforms_changed", callable_mp(this, &SpineSlotNode::on_world_transforms_changed));
|
||||
sprite->disconnect("world_transforms_changed", callable_mp(this, &SpineBoneNode::on_world_transforms_changed));
|
||||
#else
|
||||
sprite->disconnect("world_transforms_changed", this, "_on_world_transforms_changed");
|
||||
#endif
|
||||
|
||||
@ -41,6 +41,9 @@
|
||||
#define NOTIFY_PROPERTY_LIST_CHANGED() notify_property_list_changed()
|
||||
#define VARIANT_FLOAT Variant::FLOAT
|
||||
#define PROPERTY_USAGE_NOEDITOR PROPERTY_USAGE_NO_EDITOR
|
||||
#define RES Ref<Resource>
|
||||
#define REF Ref<RefCounted>
|
||||
#define GEOMETRY2D Geometry2D
|
||||
#else
|
||||
#include "core/object.h"
|
||||
#include "core/reference.h"
|
||||
@ -51,6 +54,8 @@
|
||||
#define INSTANTIATE(x) (x).instance()
|
||||
#define NOTIFY_PROPERTY_LIST_CHANGED() property_list_changed_notify()
|
||||
#define VARIANT_FLOAT Variant::REAL
|
||||
#define GDREGISTER_CLASS(x) ClassDB::register_class<x>()
|
||||
#define GEOMETRY2D Geometry
|
||||
#endif
|
||||
|
||||
#define SPINE_CHECK(obj, ret) \
|
||||
|
||||
@ -33,9 +33,17 @@
|
||||
#include "SpineSkeleton.h"
|
||||
#include "SpineRendererObject.h"
|
||||
#include "SpineSlotNode.h"
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
#include "core/config/engine.h"
|
||||
#include "core/math/geometry_2d.h"
|
||||
#else
|
||||
#include "core/engine.h"
|
||||
#endif
|
||||
|
||||
#include "scene/gui/control.h"
|
||||
#include "scene/main/viewport.h"
|
||||
|
||||
#if TOOLS_ENABLED
|
||||
#include "editor/editor_plugin.h"
|
||||
#endif
|
||||
@ -461,14 +469,14 @@ static void add_triangles(MeshInstance2D *mesh_instance,
|
||||
Ref<Texture> texture,
|
||||
Ref<Texture> normal_map) {
|
||||
#if VERSION_MAJOR > 3
|
||||
RenderingServer::get_singleton()->canvas_item_add_triangle_array(mesh_ins->get_canvas_item(),
|
||||
RenderingServer::get_singleton()->canvas_item_add_triangle_array(mesh_instance->get_canvas_item(),
|
||||
indices,
|
||||
vertices,
|
||||
colors,
|
||||
uvs,
|
||||
Vector<int>(),
|
||||
Vector<float>(),
|
||||
tex.is_null() ? RID() : tex->get_rid(),
|
||||
texture.is_null() ? RID() : texture->get_rid(),
|
||||
-1);
|
||||
#else
|
||||
VisualServer::get_singleton()->canvas_item_add_triangle_array(mesh_instance->get_canvas_item(),
|
||||
@ -642,7 +650,7 @@ void SpineSprite::draw() {
|
||||
scratch_points.push_back(Vector2(vertices->buffer()[0], vertices->buffer()[1]));
|
||||
|
||||
Color color = debug_regions_color;
|
||||
if (Geometry::is_point_in_polygon(mouse_position, scratch_points)) {
|
||||
if (GEOMETRY2D::is_point_in_polygon(mouse_position, scratch_points)) {
|
||||
hovered_slot = slot;
|
||||
color = Color(1, 1, 1, 1);
|
||||
}
|
||||
@ -672,7 +680,7 @@ void SpineSprite::draw() {
|
||||
}
|
||||
|
||||
Color color = debug_meshes_color;
|
||||
if (Geometry::is_point_in_polygon(mouse_position, scratch_points)) {
|
||||
if (GEOMETRY2D::is_point_in_polygon(mouse_position, scratch_points)) {
|
||||
hovered_slot = slot;
|
||||
color = Color(1, 1, 1, 1);
|
||||
}
|
||||
@ -744,7 +752,7 @@ void SpineSprite::draw() {
|
||||
Transform2D bone_transform(Math::deg2rad(bone->getWorldRotationX()), Vector2(bone->getWorldX(), bone->getWorldY()));
|
||||
bone_transform.scale_basis(Vector2(bone->getWorldScaleX(), bone->getWorldScaleY()));
|
||||
auto mouse_local_position = bone_transform.affine_inverse().xform(mouse_position);
|
||||
if (Geometry::is_point_in_polygon(mouse_local_position, scratch_points)) {
|
||||
if (GEOMETRY2D::is_point_in_polygon(mouse_local_position, scratch_points)) {
|
||||
hovered_bone = bone;
|
||||
}
|
||||
}
|
||||
@ -753,7 +761,11 @@ void SpineSprite::draw() {
|
||||
#if TOOLS_ENABLED
|
||||
Ref<Font> default_font;
|
||||
auto control = memnew(Control);
|
||||
#if VERSION_MAJOR > 3
|
||||
default_font = control->get_theme_default_font();
|
||||
#else
|
||||
default_font = control->get_font("font", "Label");
|
||||
#endif
|
||||
memfree(control);
|
||||
|
||||
float editor_scale = EditorInterface::get_singleton()->get_editor_scale();
|
||||
@ -782,7 +794,11 @@ void SpineSprite::draw() {
|
||||
Rect2 background_rect(0, -default_font->get_height() - 5, rect_width + 20, line_height * hover_text_lines.size() + 10);
|
||||
if (hover_text_lines.size() > 0) draw_rect(background_rect, Color(0, 0, 0 ,0.8));
|
||||
for (int i = 0; i < hover_text_lines.size(); i++) {
|
||||
#if VERSION_MAJOR > 3
|
||||
draw_string(default_font, Vector2(10, 0 + i * default_font->get_height()), hover_text_lines[i], HORIZONTAL_ALIGNMENT_LEFT, -1, Font::DEFAULT_FONT_SIZE, Color (1, 1, 1, 1));
|
||||
#else
|
||||
draw_string(default_font, Vector2(10, 0 + i * default_font->get_height()), hover_text_lines[i], Color (1, 1, 1, 1));
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -51,6 +51,7 @@
|
||||
#include "SpineConstant.h"
|
||||
#include "SpineSlotNode.h"
|
||||
#include "SpineBoneNode.h"
|
||||
#include "spine/Bone.h"
|
||||
|
||||
static Ref<SpineAtlasResourceFormatLoader> atlas_loader;
|
||||
static Ref<SpineAtlasResourceFormatSaver> atlas_saver;
|
||||
@ -67,44 +68,48 @@ static void editor_init_callback() {
|
||||
|
||||
#endif
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
void initialize_spine_godot_module(ModuleInitializationLevel level) {
|
||||
#else
|
||||
void register_spine_godot_types() {
|
||||
#endif
|
||||
#ifdef TOOLS_ENABLED
|
||||
EditorNode::add_init_callback(editor_init_callback);
|
||||
ClassDB::register_class<SpineEditorPropertyAnimationMixes>();
|
||||
GDREGISTER_CLASS(SpineEditorPropertyAnimationMixes);
|
||||
#endif
|
||||
spine::Bone::setYDown(true);
|
||||
|
||||
ClassDB::register_class<SpineAtlasResource>();
|
||||
ClassDB::register_class<SpineSkeletonFileResource>();
|
||||
ClassDB::register_class<SpineSkeletonDataResource>();
|
||||
ClassDB::register_class<SpineAnimationMix>();
|
||||
ClassDB::register_class<SpineSprite>();
|
||||
ClassDB::register_class<SpineSkeleton>();
|
||||
ClassDB::register_class<SpineAnimationState>();
|
||||
ClassDB::register_class<SpineAnimation>();
|
||||
ClassDB::register_class<SpineEventData>();
|
||||
ClassDB::register_class<SpineTrackEntry>();
|
||||
ClassDB::register_class<SpineEvent>();
|
||||
ClassDB::register_class<SpineBoneData>();
|
||||
ClassDB::register_class<SpineSlotData>();
|
||||
ClassDB::register_class<SpineAttachment>();
|
||||
ClassDB::register_class<SpineSkinEntry>();
|
||||
ClassDB::register_class<SpineConstraintData>();
|
||||
ClassDB::register_class<SpineSkin>();
|
||||
ClassDB::register_class<SpineIkConstraintData>();
|
||||
ClassDB::register_class<SpineTransformConstraintData>();
|
||||
ClassDB::register_class<SpinePathConstraintData>();
|
||||
ClassDB::register_class<SpineBone>();
|
||||
ClassDB::register_class<SpineSlot>();
|
||||
ClassDB::register_class<SpineIkConstraint>();
|
||||
ClassDB::register_class<SpinePathConstraint>();
|
||||
ClassDB::register_class<SpineTransformConstraint>();
|
||||
ClassDB::register_class<SpineTimeline>();
|
||||
ClassDB::register_class<SpineConstant>();
|
||||
GDREGISTER_CLASS(SpineAtlasResource);
|
||||
GDREGISTER_CLASS(SpineSkeletonFileResource);
|
||||
GDREGISTER_CLASS(SpineSkeletonDataResource);
|
||||
GDREGISTER_CLASS(SpineAnimationMix);
|
||||
GDREGISTER_CLASS(SpineSprite);
|
||||
GDREGISTER_CLASS(SpineSkeleton);
|
||||
GDREGISTER_CLASS(SpineAnimationState);
|
||||
GDREGISTER_CLASS(SpineAnimation);
|
||||
GDREGISTER_CLASS(SpineEventData);
|
||||
GDREGISTER_CLASS(SpineTrackEntry);
|
||||
GDREGISTER_CLASS(SpineEvent);
|
||||
GDREGISTER_CLASS(SpineBoneData);
|
||||
GDREGISTER_CLASS(SpineSlotData);
|
||||
GDREGISTER_CLASS(SpineAttachment);
|
||||
GDREGISTER_CLASS(SpineSkinEntry);
|
||||
GDREGISTER_CLASS(SpineConstraintData);
|
||||
GDREGISTER_CLASS(SpineSkin);
|
||||
GDREGISTER_CLASS(SpineIkConstraintData);
|
||||
GDREGISTER_CLASS(SpineTransformConstraintData);
|
||||
GDREGISTER_CLASS(SpinePathConstraintData);
|
||||
GDREGISTER_CLASS(SpineBone);
|
||||
GDREGISTER_CLASS(SpineSlot);
|
||||
GDREGISTER_CLASS(SpineIkConstraint);
|
||||
GDREGISTER_CLASS(SpinePathConstraint);
|
||||
GDREGISTER_CLASS(SpineTransformConstraint);
|
||||
GDREGISTER_CLASS(SpineTimeline);
|
||||
GDREGISTER_CLASS(SpineConstant);
|
||||
|
||||
ClassDB::register_class<SpineSlotNode>();
|
||||
ClassDB::register_class<SpineBoneNode>();
|
||||
ClassDB::register_class<SpineAnimationTrack>();
|
||||
GDREGISTER_CLASS(SpineSlotNode);
|
||||
GDREGISTER_CLASS(SpineBoneNode);
|
||||
GDREGISTER_CLASS(SpineAnimationTrack);
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
atlas_loader.instantiate();
|
||||
@ -133,7 +138,11 @@ void register_spine_godot_types() {
|
||||
#endif
|
||||
}
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
void uninitialize_spine_godot_module(ModuleInitializationLevel level) {
|
||||
#else
|
||||
void unregister_spine_godot_types() {
|
||||
#endif
|
||||
ResourceLoader::remove_resource_format_loader(atlas_loader);
|
||||
atlas_loader.unref();
|
||||
|
||||
|
||||
@ -29,5 +29,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "SpineCommon.h"
|
||||
|
||||
#if VERSION_MAJOR > 3
|
||||
#include "modules/register_module_types.h"
|
||||
void initialize_spine_godot_module(ModuleInitializationLevel level);
|
||||
void uninitialize_spine_godot_module(ModuleInitializationLevel level);
|
||||
#else
|
||||
void register_spine_godot_types();
|
||||
void unregister_spine_godot_types();
|
||||
#endif
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user