mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[godot] Clean-up SpineSlot.
This commit is contained in:
parent
6ba8f3d67c
commit
3de051380a
@ -28,13 +28,12 @@
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include "SpineSlot.h"
|
#include "SpineSlot.h"
|
||||||
|
|
||||||
#include "SpineBone.h"
|
#include "SpineBone.h"
|
||||||
#include "SpineSkeleton.h"
|
#include "SpineSkeleton.h"
|
||||||
|
#include "SpineCommon.h"
|
||||||
|
|
||||||
void SpineSlot::_bind_methods() {
|
void SpineSlot::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("set_to_setup_pos"), &SpineSlot::set_to_setup_pos);
|
ClassDB::bind_method(D_METHOD("set_to_setup_pose"), &SpineSlot::set_to_setup_pose);
|
||||||
ClassDB::bind_method(D_METHOD("get_data"), &SpineSlot::get_data);
|
ClassDB::bind_method(D_METHOD("get_data"), &SpineSlot::get_data);
|
||||||
ClassDB::bind_method(D_METHOD("get_bone"), &SpineSlot::get_bone);
|
ClassDB::bind_method(D_METHOD("get_bone"), &SpineSlot::get_bone);
|
||||||
ClassDB::bind_method(D_METHOD("get_skeleton"), &SpineSlot::get_skeleton);
|
ClassDB::bind_method(D_METHOD("get_skeleton"), &SpineSlot::get_skeleton);
|
||||||
@ -49,93 +48,121 @@ void SpineSlot::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("set_attachment_state", "v"), &SpineSlot::set_attachment_state);
|
ClassDB::bind_method(D_METHOD("set_attachment_state", "v"), &SpineSlot::set_attachment_state);
|
||||||
ClassDB::bind_method(D_METHOD("get_deform"), &SpineSlot::get_deform);
|
ClassDB::bind_method(D_METHOD("get_deform"), &SpineSlot::get_deform);
|
||||||
ClassDB::bind_method(D_METHOD("set_deform", "v"), &SpineSlot::set_deform);
|
ClassDB::bind_method(D_METHOD("set_deform", "v"), &SpineSlot::set_deform);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_sequence_index"), &SpineSlot::get_sequence_index);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_sequence_index", "v"), &SpineSlot::set_sequence_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
SpineSlot::SpineSlot() : slot(NULL) {}
|
SpineSlot::SpineSlot() : slot(nullptr) {
|
||||||
SpineSlot::~SpineSlot() {}
|
}
|
||||||
|
|
||||||
void SpineSlot::set_to_setup_pos() {
|
void SpineSlot::set_to_setup_pose() {
|
||||||
|
SPINE_CHECK(slot,)
|
||||||
slot->setToSetupPose();
|
slot->setToSetupPose();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<SpineSlotData> SpineSlot::get_data() {
|
Ref<SpineSlotData> SpineSlot::get_data() {
|
||||||
auto &sd = slot->getData();
|
SPINE_CHECK(slot, nullptr)
|
||||||
Ref<SpineSlotData> gd_sd(memnew(SpineSlotData));
|
auto &slot_data = slot->getData();
|
||||||
gd_sd->set_spine_object(&sd);
|
Ref<SpineSlotData> slot_data_ref(memnew(SpineSlotData));
|
||||||
return gd_sd;
|
slot_data_ref->set_spine_object(&slot_data);
|
||||||
|
return slot_data_ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<SpineBone> SpineSlot::get_bone() {
|
Ref<SpineBone> SpineSlot::get_bone() {
|
||||||
auto &b = slot->getBone();
|
SPINE_CHECK(slot, nullptr)
|
||||||
Ref<SpineBone> gd_b(memnew(SpineBone));
|
auto &bone = slot->getBone();
|
||||||
gd_b->set_spine_object(&b);
|
Ref<SpineBone> bone_ref(memnew(SpineBone));
|
||||||
return gd_b;
|
bone_ref->set_spine_object(&bone);
|
||||||
|
return bone_ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<SpineSkeleton> SpineSlot::get_skeleton() {
|
Ref<SpineSkeleton> SpineSlot::get_skeleton() {
|
||||||
auto &s = slot->getSkeleton();
|
SPINE_CHECK(slot, nullptr)
|
||||||
Ref<SpineSkeleton> gd_s(memnew(SpineSkeleton));
|
auto &skeleton = slot->getSkeleton();
|
||||||
gd_s->set_spine_object(&s);
|
Ref<SpineSkeleton> skeleton_ref(memnew(SpineSkeleton));
|
||||||
return gd_s;
|
skeleton_ref->set_spine_object(&skeleton);
|
||||||
|
return skeleton_ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
Color SpineSlot::get_color() {
|
Color SpineSlot::get_color() {
|
||||||
auto &c = slot->getColor();
|
SPINE_CHECK(slot, Color(0, 0, 0, 0))
|
||||||
return Color(c.r, c.g, c.b, c.a);
|
auto &color = slot->getColor();
|
||||||
|
return Color(color.r, color.g, color.b, color.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineSlot::set_color(Color v) {
|
void SpineSlot::set_color(Color v) {
|
||||||
auto &c = slot->getColor();
|
SPINE_CHECK(slot,)
|
||||||
c.set(v.r, v.g, v.b, v.a);
|
auto &color = slot->getColor();
|
||||||
|
color.set(v.r, v.g, v.b, v.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
Color SpineSlot::get_dark_color() {
|
Color SpineSlot::get_dark_color() {
|
||||||
auto &c = slot->getDarkColor();
|
SPINE_CHECK(slot, Color(0, 0, 0, 0))
|
||||||
return Color(c.r, c.g, c.b, c.a);
|
auto &color = slot->getDarkColor();
|
||||||
|
return Color(color.r, color.g, color.b, color.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineSlot::set_dark_color(Color v) {
|
void SpineSlot::set_dark_color(Color v) {
|
||||||
auto &c = slot->getDarkColor();
|
SPINE_CHECK(slot,)
|
||||||
c.set(v.r, v.g, v.b, v.a);
|
auto &color = slot->getDarkColor();
|
||||||
|
color.set(v.r, v.g, v.b, v.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpineSlot::has_dark_color() {
|
bool SpineSlot::has_dark_color() {
|
||||||
|
SPINE_CHECK(slot, false)
|
||||||
return slot->hasDarkColor();
|
return slot->hasDarkColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<SpineAttachment> SpineSlot::get_attachment() {
|
Ref<SpineAttachment> SpineSlot::get_attachment() {
|
||||||
auto a = slot->getAttachment();
|
SPINE_CHECK(slot, nullptr)
|
||||||
if (a == NULL) return NULL;
|
auto attachment = slot->getAttachment();
|
||||||
Ref<SpineAttachment> gd_a(memnew(SpineAttachment));
|
if (!attachment) return nullptr;
|
||||||
gd_a->set_spine_object(a);
|
Ref<SpineAttachment> attachment_ref(memnew(SpineAttachment));
|
||||||
return gd_a;
|
attachment_ref->set_spine_object(attachment);
|
||||||
|
return attachment_ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineSlot::set_attachment(Ref<SpineAttachment> v) {
|
void SpineSlot::set_attachment(Ref<SpineAttachment> v) {
|
||||||
if (v.is_valid()) {
|
SPINE_CHECK(slot,)
|
||||||
slot->setAttachment(v->get_spine_object());
|
slot->setAttachment(v.is_valid() ? v->get_spine_object() : nullptr);
|
||||||
} else {
|
|
||||||
slot->setAttachment(NULL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int SpineSlot::get_attachment_state() {
|
int SpineSlot::get_attachment_state() {
|
||||||
|
SPINE_CHECK(slot, 0)
|
||||||
return slot->getAttachmentState();
|
return slot->getAttachmentState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpineSlot::set_attachment_state(int v) {
|
void SpineSlot::set_attachment_state(int v) {
|
||||||
|
SPINE_CHECK(slot,)
|
||||||
slot->setAttachmentState(v);
|
slot->setAttachmentState(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
Array SpineSlot::get_deform() {
|
Array SpineSlot::get_deform() {
|
||||||
auto &ds = slot->getDeform();
|
Array result;
|
||||||
Array gd_ds;
|
SPINE_CHECK(slot, result)
|
||||||
gd_ds.resize(ds.size());
|
auto &deform = slot->getDeform();
|
||||||
for (size_t i = 0; i < ds.size(); ++i) {
|
result.resize((int)deform.size());
|
||||||
gd_ds[i] = ds[i];
|
for (int i = 0; i < deform.size(); ++i) {
|
||||||
|
result[i] = deform[i];
|
||||||
}
|
}
|
||||||
return gd_ds;
|
return result;
|
||||||
}
|
}
|
||||||
void SpineSlot::set_deform(Array gd_ds) {
|
|
||||||
auto &ds = slot->getDeform();
|
void SpineSlot::set_deform(Array v) {
|
||||||
ds.setSize(gd_ds.size(), 0);
|
SPINE_CHECK(slot,)
|
||||||
for (size_t i = 0; i < gd_ds.size(); ++i) {
|
auto &deform = slot->getDeform();
|
||||||
ds[i] = gd_ds[i];
|
deform.setSize(v.size(), 0);
|
||||||
|
for (int i = 0; i < v.size(); ++i) {
|
||||||
|
deform[i] = v[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int SpineSlot::get_sequence_index() {
|
||||||
|
SPINE_CHECK(slot, 0)
|
||||||
|
return slot->getAttachmentState();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpineSlot::set_sequence_index(int v) {
|
||||||
|
SPINE_CHECK(slot,)
|
||||||
|
slot->setAttachmentState(v);
|
||||||
|
}
|
||||||
|
|||||||
@ -30,10 +30,6 @@
|
|||||||
#ifndef GODOT_SPINESLOT_H
|
#ifndef GODOT_SPINESLOT_H
|
||||||
#define GODOT_SPINESLOT_H
|
#define GODOT_SPINESLOT_H
|
||||||
|
|
||||||
#include "core/variant_parser.h"
|
|
||||||
|
|
||||||
#include <spine/spine.h>
|
|
||||||
|
|
||||||
#include "SpineSlotData.h"
|
#include "SpineSlotData.h"
|
||||||
#include "SpineAttachment.h"
|
#include "SpineAttachment.h"
|
||||||
|
|
||||||
@ -52,16 +48,11 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
SpineSlot();
|
SpineSlot();
|
||||||
~SpineSlot();
|
|
||||||
|
|
||||||
inline void set_spine_object(spine::Slot *s) {
|
void set_spine_object(spine::Slot *s) { slot = s; }
|
||||||
slot = s;
|
spine::Slot *get_spine_object() { return slot; }
|
||||||
}
|
|
||||||
inline spine::Slot *get_spine_object() {
|
|
||||||
return slot;
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_to_setup_pos();
|
void set_to_setup_pose();
|
||||||
|
|
||||||
Ref<SpineSlotData> get_data();
|
Ref<SpineSlotData> get_data();
|
||||||
|
|
||||||
@ -70,21 +61,30 @@ public:
|
|||||||
Ref<SpineSkeleton> get_skeleton();
|
Ref<SpineSkeleton> get_skeleton();
|
||||||
|
|
||||||
Color get_color();
|
Color get_color();
|
||||||
|
|
||||||
void set_color(Color v);
|
void set_color(Color v);
|
||||||
|
|
||||||
Color get_dark_color();
|
Color get_dark_color();
|
||||||
|
|
||||||
void set_dark_color(Color v);
|
void set_dark_color(Color v);
|
||||||
|
|
||||||
bool has_dark_color();
|
bool has_dark_color();
|
||||||
|
|
||||||
Ref<SpineAttachment> get_attachment();
|
Ref<SpineAttachment> get_attachment();
|
||||||
|
|
||||||
void set_attachment(Ref<SpineAttachment> v);
|
void set_attachment(Ref<SpineAttachment> v);
|
||||||
|
|
||||||
int get_attachment_state();
|
int get_attachment_state();
|
||||||
|
|
||||||
void set_attachment_state(int v);
|
void set_attachment_state(int v);
|
||||||
|
|
||||||
Array get_deform();
|
Array get_deform();
|
||||||
|
|
||||||
void set_deform(Array v);
|
void set_deform(Array v);
|
||||||
|
|
||||||
|
int get_sequence_index();
|
||||||
|
|
||||||
|
void set_sequence_index(int v);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif//GODOT_SPINESLOT_H
|
#endif//GODOT_SPINESLOT_H
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user