SpineSlotData.cpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /******************************************************************************
  2. * Spine Runtimes License Agreement
  3. * Last updated January 1, 2020. Replaces all prior versions.
  4. *
  5. * Copyright (c) 2013-2020, Esoteric Software LLC
  6. *
  7. * Integration of the Spine Runtimes into software or otherwise creating
  8. * derivative works of the Spine Runtimes is permitted under the terms and
  9. * conditions of Section 2 of the Spine Editor License Agreement:
  10. * http://esotericsoftware.com/spine-editor-license
  11. *
  12. * Otherwise, it is permitted to integrate the Spine Runtimes into software
  13. * or otherwise create derivative works of the Spine Runtimes (collectively,
  14. * "Products"), provided that each user of the Products must obtain their own
  15. * Spine Editor license and redistribution of the Products in any form must
  16. * include this license and copyright notice.
  17. *
  18. * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
  19. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  21. * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
  22. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
  24. * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
  25. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  27. * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. *****************************************************************************/
  29. #include "SpineSlotData.h"
  30. void SpineSlotData::_bind_methods() {
  31. ClassDB::bind_method(D_METHOD("get_index"), &SpineSlotData::get_index);
  32. ClassDB::bind_method(D_METHOD("get_slot_name"), &SpineSlotData::get_slot_name);
  33. ClassDB::bind_method(D_METHOD("get_bone_data"), &SpineSlotData::get_bone_data);
  34. ClassDB::bind_method(D_METHOD("get_color"), &SpineSlotData::get_color);
  35. ClassDB::bind_method(D_METHOD("get_dark_color"), &SpineSlotData::get_dark_color);
  36. ClassDB::bind_method(D_METHOD("has_dark_color"), &SpineSlotData::has_dark_color);
  37. ClassDB::bind_method(D_METHOD("set_has_dark_color", "v"), &SpineSlotData::set_has_dark_color);
  38. ClassDB::bind_method(D_METHOD("get_attachment_name"), &SpineSlotData::get_attachment_name);
  39. ClassDB::bind_method(D_METHOD("set_attachment_name", "v"), &SpineSlotData::set_attachment_name);
  40. ClassDB::bind_method(D_METHOD("get_blend_mode"), &SpineSlotData::get_blend_mode);
  41. ClassDB::bind_method(D_METHOD("set_blend_mode", "v"), &SpineSlotData::set_blend_mode);
  42. ClassDB::bind_method(D_METHOD("set_color", "v"), &SpineSlotData::set_color);
  43. ClassDB::bind_method(D_METHOD("set_dark_color", "v"), &SpineSlotData::set_dark_color);
  44. BIND_ENUM_CONSTANT(BLENDMODE_NORMAL);
  45. BIND_ENUM_CONSTANT(BLENDMODE_ADDITIVE);
  46. BIND_ENUM_CONSTANT(BLENDMODE_MULTIPLY);
  47. BIND_ENUM_CONSTANT(BLENDMODE_SCREEN);
  48. }
  49. SpineSlotData::SpineSlotData():slot_data(NULL) {}
  50. SpineSlotData::~SpineSlotData() {}
  51. #define S_T(x) (spine::String(x.utf8()))
  52. int SpineSlotData::get_index(){
  53. return slot_data->getIndex();
  54. }
  55. String SpineSlotData::get_slot_name(){
  56. return slot_data->getName().buffer();
  57. }
  58. Ref<SpineBoneData> SpineSlotData::get_bone_data(){
  59. auto &bd = slot_data->getBoneData();
  60. Ref<SpineBoneData> gd_bone_data(memnew(SpineBoneData));
  61. gd_bone_data->set_spine_object(&bd);
  62. return gd_bone_data;
  63. }
  64. Color SpineSlotData::get_color(){
  65. auto &c = slot_data->getColor();
  66. return Color(c.r, c.g, c.b, c.a);
  67. }
  68. void SpineSlotData::set_color(Color v){
  69. auto &c = slot_data->getColor();
  70. c.set(v.r, v.g, v.b, v.a);
  71. }
  72. Color SpineSlotData::get_dark_color(){
  73. auto &c = slot_data->getDarkColor();
  74. return Color(c.r, c.g, c.b, c.a);
  75. }
  76. void SpineSlotData::set_dark_color(Color v){
  77. auto &c = slot_data->getDarkColor();
  78. c.set(v.r, v.g, v.b, v.a);
  79. }
  80. bool SpineSlotData::has_dark_color(){
  81. return slot_data->hasDarkColor();
  82. }
  83. void SpineSlotData::set_has_dark_color(bool v){
  84. slot_data->setHasDarkColor(v);
  85. }
  86. String SpineSlotData::get_attachment_name(){
  87. return slot_data->getAttachmentName().buffer();
  88. }
  89. void SpineSlotData::set_attachment_name(const String &v){
  90. slot_data->setAttachmentName(S_T(v));
  91. }
  92. SpineSlotData::BlendMode SpineSlotData::get_blend_mode(){
  93. auto bm = (int) slot_data->getBlendMode();
  94. return (BlendMode) bm;
  95. }
  96. void SpineSlotData::set_blend_mode(BlendMode v){
  97. auto bm = (int) v;
  98. slot_data->setBlendMode((spine::BlendMode) bm);
  99. }
  100. #undef S_T