2020-01-31 19:34:47 +01:00
|
|
|
/*
|
2022-01-12 21:44:26 +01:00
|
|
|
Copyright (c) 2019-2022 Péter Magyar
|
2020-01-31 19:34:47 +01:00
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
|
|
copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2019-10-25 10:22:57 +02:00
|
|
|
#include "species_model_data.h"
|
|
|
|
|
2020-04-09 12:32:05 +02:00
|
|
|
#include "core/version.h"
|
|
|
|
|
2020-05-22 20:48:08 +02:00
|
|
|
#include "../../defines.h"
|
2020-06-12 15:13:31 +02:00
|
|
|
#include "../../singletons/ess.h"
|
2021-02-06 11:44:14 +01:00
|
|
|
|
|
|
|
#include "core/string/ustring.h"
|
2022-08-31 23:27:11 +02:00
|
|
|
|
2021-02-06 11:44:14 +01:00
|
|
|
|
2020-05-22 20:48:08 +02:00
|
|
|
|
2019-10-25 14:01:59 +02:00
|
|
|
int SpeciesModelData::get_id() {
|
|
|
|
return _id;
|
|
|
|
}
|
|
|
|
void SpeciesModelData::set_id(int value) {
|
|
|
|
_id = value;
|
|
|
|
}
|
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
int SpeciesModelData::get_bone_structure() const {
|
|
|
|
return _bone_structure;
|
|
|
|
}
|
|
|
|
void SpeciesModelData::set_bone_structure(const int value) {
|
|
|
|
_bone_structure = value;
|
|
|
|
}
|
|
|
|
|
2020-04-24 13:35:30 +02:00
|
|
|
Ref<PackedScene> SpeciesModelData::get_body() {
|
|
|
|
return _body;
|
2019-10-25 14:01:59 +02:00
|
|
|
}
|
2020-04-24 13:35:30 +02:00
|
|
|
void SpeciesModelData::set_body(Ref<PackedScene> value) {
|
|
|
|
_body = value;
|
2019-10-25 14:01:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//Entries
|
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
Ref<ModelVisualEntry> SpeciesModelData::get_visual(const int index) const {
|
|
|
|
ERR_FAIL_INDEX_V(index, _visuals.size(), Ref<ModelVisualEntry>());
|
2019-10-25 14:01:59 +02:00
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
return _visuals.get(index);
|
2019-10-25 14:01:59 +02:00
|
|
|
}
|
2020-06-12 15:13:31 +02:00
|
|
|
void SpeciesModelData::set_visual(const int index, const Ref<ModelVisualEntry> visual) {
|
|
|
|
ERR_FAIL_INDEX(index, _visuals.size());
|
2019-10-25 14:01:59 +02:00
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
_visuals.set(index, visual);
|
2019-10-25 14:01:59 +02:00
|
|
|
}
|
2020-06-12 15:13:31 +02:00
|
|
|
void SpeciesModelData::add_visual(const Ref<ModelVisualEntry> &visual) {
|
|
|
|
_visuals.push_back(visual);
|
2019-10-25 14:01:59 +02:00
|
|
|
}
|
2020-06-12 15:13:31 +02:00
|
|
|
void SpeciesModelData::remove_visual(const int index) {
|
|
|
|
ERR_FAIL_INDEX(index, _visuals.size());
|
2019-10-25 14:01:59 +02:00
|
|
|
|
2022-08-29 20:42:15 +02:00
|
|
|
_visuals.remove_at(index);
|
2019-10-25 14:01:59 +02:00
|
|
|
}
|
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
int SpeciesModelData::get_visual_count() const {
|
|
|
|
return _visuals.size();
|
2019-10-25 14:01:59 +02:00
|
|
|
}
|
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
Vector<Variant> SpeciesModelData::get_visuals() {
|
|
|
|
VARIANT_ARRAY_GET(_visuals);
|
|
|
|
}
|
|
|
|
void SpeciesModelData::set_visuals(const Vector<Variant> &visuals) {
|
|
|
|
VARIANT_ARRAY_SET(visuals, _visuals, ModelVisualEntry);
|
2019-10-25 14:01:59 +02:00
|
|
|
}
|
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
//Customizable Slots
|
|
|
|
String SpeciesModelData::get_customizable_slots_string() const {
|
|
|
|
return _customizable_slots_string;
|
|
|
|
}
|
|
|
|
void SpeciesModelData::set_customizable_slots_string(const String &value) {
|
|
|
|
_customizable_slots_string = value;
|
2019-10-25 14:01:59 +02:00
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
if (value == "") {
|
|
|
|
_customizable_slots.resize(0);
|
|
|
|
return;
|
2019-10-25 14:01:59 +02:00
|
|
|
}
|
2020-06-12 15:13:31 +02:00
|
|
|
|
|
|
|
_customizable_slots.resize(_customizable_slots_string.get_slice_count(","));
|
2019-10-25 14:01:59 +02:00
|
|
|
}
|
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
Ref<ModelVisualEntry> SpeciesModelData::get_customizable_slot_entry(const int slot_index, const int index) const {
|
|
|
|
ERR_FAIL_INDEX_V(slot_index, _customizable_slots.size(), Ref<ModelVisualEntry>());
|
|
|
|
ERR_FAIL_INDEX_V(index, _customizable_slots[slot_index].size(), Ref<ModelVisualEntry>());
|
2020-05-22 01:27:03 +02:00
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
return _customizable_slots[slot_index].get(index);
|
|
|
|
}
|
|
|
|
void SpeciesModelData::set_customizable_slot_entry(const int slot_index, const int index, const Ref<ModelVisualEntry> customizable_slot) {
|
|
|
|
ERR_FAIL_INDEX(slot_index, _customizable_slots.size());
|
|
|
|
ERR_FAIL_INDEX(index, _customizable_slots[slot_index].size());
|
2020-05-22 01:27:03 +02:00
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
_customizable_slots.write[slot_index].set(index, customizable_slot);
|
2020-05-22 01:27:03 +02:00
|
|
|
}
|
2020-06-12 15:13:31 +02:00
|
|
|
void SpeciesModelData::add_customizable_slot_entry(const int slot_index, const Ref<ModelVisualEntry> customizable_slot) {
|
|
|
|
ERR_FAIL_INDEX(slot_index, _customizable_slots.size());
|
2020-05-22 01:27:03 +02:00
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
_customizable_slots.write[slot_index].push_back(customizable_slot);
|
2020-05-22 01:27:03 +02:00
|
|
|
}
|
2020-06-12 15:13:31 +02:00
|
|
|
void SpeciesModelData::remove_customizable_slot_entry(const int slot_index, const int index) {
|
|
|
|
ERR_FAIL_INDEX(slot_index, _customizable_slots.size());
|
|
|
|
ERR_FAIL_INDEX(index, _customizable_slots.size());
|
|
|
|
|
2022-08-29 20:42:15 +02:00
|
|
|
_customizable_slots.write[slot_index].remove_at(index);
|
2020-05-22 01:27:03 +02:00
|
|
|
}
|
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
int SpeciesModelData::get_customizable_slot_count() const {
|
|
|
|
return _customizable_slots.size();
|
2020-05-22 01:27:03 +02:00
|
|
|
}
|
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
int SpeciesModelData::get_customizable_slot_entry_count(const int slot_index) const {
|
|
|
|
ERR_FAIL_INDEX_V(slot_index, _customizable_slots.size(), 0);
|
|
|
|
|
|
|
|
return _customizable_slots[slot_index].size();
|
2020-05-22 01:27:03 +02:00
|
|
|
}
|
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
Vector<Variant> SpeciesModelData::get_customizable_slot_entries(const int slot_index) const {
|
2020-05-22 01:27:03 +02:00
|
|
|
Vector<Variant> r;
|
2020-06-12 15:13:31 +02:00
|
|
|
|
|
|
|
ERR_FAIL_INDEX_V(slot_index, _customizable_slots.size(), r);
|
|
|
|
|
|
|
|
for (int i = 0; i < _customizable_slots[slot_index].size(); i++) {
|
2020-06-20 22:36:31 +02:00
|
|
|
#if GODOT4
|
|
|
|
r.push_back(_customizable_slots[slot_index][i]);
|
|
|
|
#else
|
2020-06-12 15:13:31 +02:00
|
|
|
r.push_back(_customizable_slots[slot_index][i].get_ref_ptr());
|
2020-06-20 22:36:31 +02:00
|
|
|
#endif
|
2020-05-22 01:27:03 +02:00
|
|
|
}
|
|
|
|
return r;
|
|
|
|
}
|
2020-06-12 15:13:31 +02:00
|
|
|
void SpeciesModelData::set_customizable_slot_entries(const int slot_index, const Vector<Variant> &customizable_slots) {
|
|
|
|
ERR_FAIL_INDEX(slot_index, _customizable_slots.size());
|
2020-05-22 01:27:03 +02:00
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
_customizable_slots.write[slot_index].clear();
|
|
|
|
for (int i = 0; i < customizable_slots.size(); i++) {
|
|
|
|
Ref<ModelVisualEntry> e = Ref<ModelVisualEntry>(customizable_slots[i]);
|
|
|
|
_customizable_slots.write[slot_index].push_back(e);
|
2020-05-22 01:27:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
//Color Customizable Slots
|
|
|
|
String SpeciesModelData::get_customizable_color_slots_string() const {
|
|
|
|
return _customizable_color_slots_string;
|
|
|
|
}
|
|
|
|
void SpeciesModelData::set_customizable_color_slots_string(const String &value) {
|
|
|
|
_customizable_color_slots_string = value;
|
2019-10-25 14:01:59 +02:00
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
if (value == "") {
|
|
|
|
_visuals.resize(0);
|
|
|
|
return;
|
|
|
|
}
|
2019-10-25 14:01:59 +02:00
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
_customizable_color_slots.resize(_customizable_color_slots_string.get_slice_count(","));
|
2019-10-25 14:01:59 +02:00
|
|
|
}
|
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
Color SpeciesModelData::get_color_customizable_slot_color(const int slot_index, const int index) const {
|
|
|
|
ERR_FAIL_INDEX_V(slot_index, _customizable_color_slots.size(), Color());
|
|
|
|
ERR_FAIL_INDEX_V(index, _customizable_color_slots.size(), Color());
|
2019-10-25 14:01:59 +02:00
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
return _customizable_color_slots[slot_index].colors.get(index);
|
2019-10-25 14:01:59 +02:00
|
|
|
}
|
2020-06-12 15:13:31 +02:00
|
|
|
void SpeciesModelData::set_color_customizable_slot_color(const int slot_index, const int index, const Color color_customizable_slot) {
|
|
|
|
ERR_FAIL_INDEX(slot_index, _customizable_color_slots.size());
|
|
|
|
ERR_FAIL_INDEX(index, _customizable_color_slots[slot_index].colors.size());
|
2019-10-25 14:01:59 +02:00
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
_customizable_color_slots.write[slot_index].colors.set(index, color_customizable_slot);
|
2019-10-25 14:01:59 +02:00
|
|
|
}
|
2020-06-12 15:13:31 +02:00
|
|
|
void SpeciesModelData::add_color_customizable_slot_color(const int slot_index, const Color color_customizable_slot) {
|
|
|
|
ERR_FAIL_INDEX(slot_index, _customizable_color_slots.size());
|
2019-10-25 14:01:59 +02:00
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
_customizable_color_slots.write[slot_index].colors.push_back(color_customizable_slot);
|
2019-10-25 14:01:59 +02:00
|
|
|
}
|
2020-06-12 15:13:31 +02:00
|
|
|
void SpeciesModelData::remove_color_customizable_slot_color(const int slot_index, const int index) {
|
|
|
|
ERR_FAIL_INDEX(slot_index, _customizable_color_slots.size());
|
|
|
|
ERR_FAIL_INDEX(index, _customizable_color_slots.size());
|
2019-10-25 14:01:59 +02:00
|
|
|
|
2022-08-29 20:42:15 +02:00
|
|
|
_customizable_color_slots.write[slot_index].colors.remove_at(index);
|
2019-10-25 14:01:59 +02:00
|
|
|
}
|
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
Vector<Color> SpeciesModelData::get_color_customizable_slot_colors(const int slot_index) const {
|
|
|
|
ERR_FAIL_INDEX_V(slot_index, _customizable_color_slots.size(), Vector<Color>());
|
2019-10-25 14:01:59 +02:00
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
return _customizable_color_slots[slot_index].colors;
|
2019-10-25 14:01:59 +02:00
|
|
|
}
|
2020-06-12 15:13:31 +02:00
|
|
|
void SpeciesModelData::set_color_customizable_slot_colors(const int slot_index, const Vector<Color> &colors) {
|
|
|
|
ERR_FAIL_INDEX(slot_index, _customizable_color_slots.size());
|
2019-10-25 14:01:59 +02:00
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
_customizable_color_slots.write[slot_index].colors = colors;
|
2019-10-25 14:01:59 +02:00
|
|
|
}
|
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
uint64_t SpeciesModelData::get_color_customizable_slot_bone_slot_mask(const int slot_index) const {
|
|
|
|
ERR_FAIL_INDEX_V(slot_index, _customizable_color_slots.size(), 0);
|
2019-10-25 14:01:59 +02:00
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
return _customizable_color_slots[slot_index].bone_slot_mask;
|
2019-10-25 14:01:59 +02:00
|
|
|
}
|
2020-06-12 15:13:31 +02:00
|
|
|
void SpeciesModelData::set_color_customizable_slot_bone_slot_mask(const int slot_index, const uint64_t value) {
|
|
|
|
ERR_FAIL_INDEX(slot_index, _customizable_color_slots.size());
|
2019-10-25 14:01:59 +02:00
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
_customizable_color_slots.write[slot_index].bone_slot_mask = value;
|
2019-10-25 14:01:59 +02:00
|
|
|
}
|
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
int SpeciesModelData::get_color_customizable_slot_texture_layer(const int slot_index) const {
|
|
|
|
ERR_FAIL_INDEX_V(slot_index, _customizable_color_slots.size(), 0);
|
2019-10-25 14:01:59 +02:00
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
return _customizable_color_slots[slot_index].texture_layer;
|
2019-10-25 14:01:59 +02:00
|
|
|
}
|
2020-06-12 15:13:31 +02:00
|
|
|
void SpeciesModelData::set_color_customizable_slot_texture_layer(const int slot_index, const int value) {
|
|
|
|
ERR_FAIL_INDEX(slot_index, _customizable_color_slots.size());
|
2019-10-25 14:01:59 +02:00
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
_customizable_color_slots.write[slot_index].texture_layer = value;
|
2019-10-25 14:01:59 +02:00
|
|
|
}
|
2020-06-12 15:13:31 +02:00
|
|
|
|
|
|
|
int SpeciesModelData::get_color_customizable_count() const {
|
|
|
|
return _customizable_color_slots.size();
|
2019-10-25 14:01:59 +02:00
|
|
|
}
|
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
int SpeciesModelData::get_color_customizable_slot_count(const int slot_index) const {
|
|
|
|
ERR_FAIL_INDEX_V(slot_index, _customizable_color_slots.size(), 0);
|
|
|
|
|
|
|
|
return _customizable_color_slots[slot_index].colors.size();
|
2019-10-25 14:01:59 +02:00
|
|
|
}
|
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
SpeciesModelData::SpeciesModelData() {
|
|
|
|
_id = 0;
|
|
|
|
_bone_structure = 0;
|
2019-10-25 14:01:59 +02:00
|
|
|
}
|
2020-06-12 15:13:31 +02:00
|
|
|
SpeciesModelData::~SpeciesModelData() {
|
|
|
|
_body.unref();
|
2019-10-25 14:01:59 +02:00
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
_visuals.clear();
|
|
|
|
|
|
|
|
for (int i = 0; i < _customizable_slots.size(); ++i) {
|
|
|
|
_customizable_slots.write[i].clear();
|
2019-10-25 14:01:59 +02:00
|
|
|
}
|
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
for (int i = 0; i < _customizable_color_slots.size(); ++i) {
|
|
|
|
_customizable_color_slots.write[i].colors.clear();
|
2019-10-25 14:01:59 +02:00
|
|
|
}
|
2020-06-12 15:13:31 +02:00
|
|
|
|
|
|
|
_customizable_slots.clear();
|
|
|
|
_customizable_color_slots.clear();
|
2019-10-25 14:01:59 +02:00
|
|
|
}
|
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
bool SpeciesModelData::_set(const StringName &p_name, const Variant &p_value) {
|
|
|
|
String name = p_name;
|
2019-10-25 14:01:59 +02:00
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
if (name.begins_with("customizable_slots")) {
|
|
|
|
int index = name.get_slicec('/', 1).get_slicec('_', 0).to_int();
|
2019-10-25 14:01:59 +02:00
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
if (_customizable_slots.size() <= index) {
|
|
|
|
_customizable_slots.resize(index + 1);
|
|
|
|
}
|
2019-10-25 14:01:59 +02:00
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
set_customizable_slot_entries(index, p_value);
|
2019-10-25 14:01:59 +02:00
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
return true;
|
|
|
|
} else if (name.begins_with("customizable_color_slots")) {
|
|
|
|
int index = name.get_slicec('/', 1).get_slicec('_', 0).to_int();
|
2019-10-25 14:01:59 +02:00
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
if (_customizable_color_slots.size() <= index) {
|
|
|
|
_customizable_color_slots.resize(index + 1);
|
|
|
|
}
|
2019-10-25 14:01:59 +02:00
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
String prop = name.get_slicec('/', 2);
|
|
|
|
|
|
|
|
if (prop == "texture_layer") {
|
|
|
|
_customizable_color_slots.write[index].texture_layer = p_value;
|
|
|
|
return true;
|
|
|
|
} else if (prop == "bone_slot_mask") {
|
|
|
|
_customizable_color_slots.write[index].bone_slot_mask = p_value;
|
|
|
|
return true;
|
|
|
|
} else if (prop == "colors") {
|
|
|
|
_customizable_color_slots.write[index].colors = p_value;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2019-10-25 14:01:59 +02:00
|
|
|
}
|
2020-06-12 15:13:31 +02:00
|
|
|
bool SpeciesModelData::_get(const StringName &p_name, Variant &r_ret) const {
|
|
|
|
String name = p_name;
|
2019-10-25 14:01:59 +02:00
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
if (name.begins_with("customizable_slots")) {
|
|
|
|
int index = name.get_slicec('/', 1).get_slicec('_', 0).to_int();
|
|
|
|
|
|
|
|
if (_customizable_slots.size() <= index) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
r_ret = get_customizable_slot_entries(index);
|
|
|
|
return true;
|
|
|
|
} else if (name.begins_with("customizable_color_slots")) {
|
|
|
|
int index = name.get_slicec('/', 1).get_slicec('_', 0).to_int();
|
|
|
|
|
|
|
|
if (_customizable_color_slots.size() <= index) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
String prop = name.get_slicec('/', 2);
|
|
|
|
|
|
|
|
if (prop == "texture_layer") {
|
|
|
|
r_ret = _customizable_color_slots[index].texture_layer;
|
|
|
|
return true;
|
|
|
|
} else if (prop == "bone_slot_mask") {
|
|
|
|
r_ret = _customizable_color_slots[index].bone_slot_mask;
|
|
|
|
return true;
|
|
|
|
} else if (prop == "colors") {
|
|
|
|
r_ret = _customizable_color_slots[index].colors;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2019-10-25 10:22:57 +02:00
|
|
|
}
|
2020-06-12 15:13:31 +02:00
|
|
|
void SpeciesModelData::_get_property_list(List<PropertyInfo> *p_list) const {
|
|
|
|
int count = _customizable_slots_string.get_slice_count(",");
|
|
|
|
|
|
|
|
for (int i = 0; i < count; ++i) {
|
|
|
|
p_list->push_back(PropertyInfo(Variant::ARRAY, "customizable_slots/" + itos(i) + "_" + _customizable_slots_string.get_slicec(',', i), PROPERTY_HINT_NONE, "17/17:ModelVisualEntry", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL, "ModelVisualEntry"));
|
|
|
|
}
|
2019-10-25 14:01:59 +02:00
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
count = _customizable_color_slots_string.get_slice_count(",");
|
|
|
|
|
|
|
|
for (int i = 0; i < count; ++i) {
|
|
|
|
p_list->push_back(PropertyInfo(Variant::INT, "customizable_color_slots/" + itos(i) + "_" + _customizable_color_slots_string.get_slicec(',', i) + "/texture_layer", PROPERTY_HINT_ENUM, ESS::get_singleton()->texture_layers_get(), PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED));
|
|
|
|
p_list->push_back(PropertyInfo(Variant::INT, "customizable_color_slots/" + itos(i) + "_" + _customizable_color_slots_string.get_slicec(',', i) + "/bone_slot_mask", PROPERTY_HINT_FLAGS, ESS::get_singleton()->skeletons_bones_index_get(_bone_structure), PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL));
|
|
|
|
p_list->push_back(PropertyInfo(Variant::ARRAY, "customizable_color_slots/" + itos(i) + "_" + _customizable_color_slots_string.get_slicec(',', i) + "/colors", PROPERTY_HINT_NONE, "17/17:Color", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL, "Color"));
|
2019-10-25 14:01:59 +02:00
|
|
|
}
|
2020-06-12 15:13:31 +02:00
|
|
|
}
|
|
|
|
void SpeciesModelData::_validate_property(PropertyInfo &property) const {
|
|
|
|
String prop = property.name;
|
2019-10-25 14:01:59 +02:00
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
if (prop == "bone_structure") {
|
|
|
|
property.hint_string = ESS::get_singleton()->entity_types_get();
|
|
|
|
}
|
2019-10-25 10:22:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void SpeciesModelData::_bind_methods() {
|
2019-10-25 14:01:59 +02:00
|
|
|
ClassDB::bind_method(D_METHOD("get_id"), &SpeciesModelData::get_id);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_id", "value"), &SpeciesModelData::set_id);
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "id"), "set_id", "get_id");
|
2019-10-25 10:22:57 +02:00
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
ClassDB::bind_method(D_METHOD("get_bone_structure"), &SpeciesModelData::get_bone_structure);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_bone_structure", "value"), &SpeciesModelData::set_bone_structure);
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "bone_structure", PROPERTY_HINT_ENUM, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), "set_bone_structure", "get_bone_structure");
|
|
|
|
|
2019-11-09 17:49:05 +01:00
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::STRING, "text_name"), "set_name", "get_name");
|
2019-10-25 14:01:59 +02:00
|
|
|
|
2020-04-24 13:35:30 +02:00
|
|
|
ClassDB::bind_method(D_METHOD("get_body"), &SpeciesModelData::get_body);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_body", "value"), &SpeciesModelData::set_body);
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "body", PROPERTY_HINT_RESOURCE_TYPE, "PackedScene"), "set_body", "get_body");
|
2019-10-25 14:01:59 +02:00
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
//Entries
|
|
|
|
ClassDB::bind_method(D_METHOD("get_visual", "index"), &SpeciesModelData::get_visual);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_visual", "index", "data"), &SpeciesModelData::set_visual);
|
|
|
|
ClassDB::bind_method(D_METHOD("add_visual", "visual"), &SpeciesModelData::add_visual);
|
|
|
|
ClassDB::bind_method(D_METHOD("remove_visual", "index"), &SpeciesModelData::remove_visual);
|
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("get_visual_count"), &SpeciesModelData::get_visual_count);
|
2020-05-22 01:27:03 +02:00
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
ClassDB::bind_method(D_METHOD("get_visuals"), &SpeciesModelData::get_visuals);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_visuals", "visuals"), &SpeciesModelData::set_visuals);
|
2020-05-22 01:27:03 +02:00
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
//Customizable Slots
|
|
|
|
ClassDB::bind_method(D_METHOD("get_customizable_slots_string"), &SpeciesModelData::get_customizable_slots_string);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_customizable_slots_string", "value"), &SpeciesModelData::set_customizable_slots_string);
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::STRING, "customizable_slots_string"), "set_customizable_slots_string", "get_customizable_slots_string");
|
2020-05-22 01:27:03 +02:00
|
|
|
|
2020-06-12 15:13:31 +02:00
|
|
|
ClassDB::bind_method(D_METHOD("get_customizable_slot_entry", "slot_index", "index"), &SpeciesModelData::get_customizable_slot_entry);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_customizable_slot_entry", "slot_index", "index", "data"), &SpeciesModelData::set_customizable_slot_entry);
|
|
|
|
ClassDB::bind_method(D_METHOD("add_customizable_slot_entry", "slot_index", "customizable_slot"), &SpeciesModelData::add_customizable_slot_entry);
|
|
|
|
ClassDB::bind_method(D_METHOD("remove_customizable_slot_entry", "slot_index", "index"), &SpeciesModelData::remove_customizable_slot_entry);
|
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("get_customizable_slot_count"), &SpeciesModelData::get_customizable_slot_count);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_customizable_slot_entry_count", "slot_index"), &SpeciesModelData::get_customizable_slot_entry_count);
|
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("get_customizable_slot_entries", "slot_index"), &SpeciesModelData::get_customizable_slot_entries);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_customizable_slot_entries", "slot_index", "customizable_slots"), &SpeciesModelData::set_customizable_slot_entries);
|
|
|
|
|
|
|
|
//Color Slots
|
|
|
|
ClassDB::bind_method(D_METHOD("get_customizable_color_slots_string"), &SpeciesModelData::get_customizable_color_slots_string);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_customizable_color_slots_string", "value"), &SpeciesModelData::set_customizable_color_slots_string);
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::STRING, "customizable_color_slots_string"), "set_customizable_color_slots_string", "get_customizable_color_slots_string");
|
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("get_color_customizable_slot_color", "slot_index", "index"), &SpeciesModelData::get_color_customizable_slot_color);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_color_customizable_slot_color", "slot_index", "index", "data"), &SpeciesModelData::set_color_customizable_slot_color);
|
|
|
|
ClassDB::bind_method(D_METHOD("add_color_customizable_slot_color", "slot_index", "color_customizable_slot"), &SpeciesModelData::add_color_customizable_slot_color);
|
|
|
|
ClassDB::bind_method(D_METHOD("remove_color_customizable_slot_color", "slot_index", "index"), &SpeciesModelData::remove_color_customizable_slot_color);
|
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("get_color_customizable_slot_colors", "slot_index"), &SpeciesModelData::get_color_customizable_slot_colors);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_color_customizable_slot_colors", "slot_index", "colors"), &SpeciesModelData::set_color_customizable_slot_colors);
|
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("get_color_customizable_slot_bone_slot_mask", "slot_index"), &SpeciesModelData::get_color_customizable_slot_bone_slot_mask);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_color_customizable_slot_bone_slot_mask", "slot_index", "value"), &SpeciesModelData::set_color_customizable_slot_bone_slot_mask);
|
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("get_color_customizable_slot_texture_layer", "slot_index"), &SpeciesModelData::get_color_customizable_slot_texture_layer);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_color_customizable_slot_texture_layer", "slot_index", "value"), &SpeciesModelData::set_color_customizable_slot_texture_layer);
|
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("get_color_customizable_count"), &SpeciesModelData::get_color_customizable_count);
|
|
|
|
ClassDB::bind_method(D_METHOD("get_color_customizable_slot_count", "slot_index"), &SpeciesModelData::get_color_customizable_slot_count);
|
2019-10-25 10:22:57 +02:00
|
|
|
}
|