SpineEvent.cpp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 "SpineEvent.h"
  30. void SpineEvent::_bind_methods() {
  31. ClassDB::bind_method(D_METHOD("get_data"), &SpineEvent::get_data);
  32. ClassDB::bind_method(D_METHOD("get_event_name"), &SpineEvent::get_event_name);
  33. ClassDB::bind_method(D_METHOD("get_time"), &SpineEvent::get_time);
  34. ClassDB::bind_method(D_METHOD("get_int_value"), &SpineEvent::get_int_value);
  35. ClassDB::bind_method(D_METHOD("set_int_value", "v"), &SpineEvent::set_int_value);
  36. ClassDB::bind_method(D_METHOD("get_float_value"), &SpineEvent::get_float_value);
  37. ClassDB::bind_method(D_METHOD("set_float_value", "v"), &SpineEvent::set_float_value);
  38. ClassDB::bind_method(D_METHOD("get_string_value"), &SpineEvent::get_string_value);
  39. ClassDB::bind_method(D_METHOD("set_string_value", "v"), &SpineEvent::set_string_value);
  40. ClassDB::bind_method(D_METHOD("get_volume"), &SpineEvent::get_volume);
  41. ClassDB::bind_method(D_METHOD("set_volume", "v"), &SpineEvent::set_volume);
  42. ClassDB::bind_method(D_METHOD("get_balance"), &SpineEvent::get_balance);
  43. ClassDB::bind_method(D_METHOD("set_balance", "v"), &SpineEvent::set_balance);
  44. //
  45. // BIND_ENUM_CONSTANT(EVENTTYPE_START);
  46. // BIND_ENUM_CONSTANT(EVENTTYPE_INTERRUPT);
  47. // BIND_ENUM_CONSTANT(EVENTTYPE_END);
  48. // BIND_ENUM_CONSTANT(EVENTTYPE_COMPLETE);
  49. // BIND_ENUM_CONSTANT(EVENTTYPE_DISPOSE);
  50. // BIND_ENUM_CONSTANT(EVENTTYPE_EVENT);
  51. }
  52. SpineEvent::SpineEvent():event(NULL) {}
  53. SpineEvent::~SpineEvent(){}
  54. Ref<SpineEventData> SpineEvent::get_data(){
  55. Ref<SpineEventData> event_data(memnew(SpineEventData));
  56. event_data->set_spine_object(&(event->getData()));
  57. return event_data;
  58. }
  59. String SpineEvent::get_event_name() {
  60. return event->getData().getName().buffer();
  61. }
  62. float SpineEvent::get_time(){
  63. return event->getTime();
  64. }
  65. int SpineEvent::get_int_value(){
  66. return event->getIntValue();
  67. }
  68. void SpineEvent::set_int_value(int v){
  69. event->setIntValue(v);
  70. }
  71. float SpineEvent::get_float_value(){
  72. return event->getFloatValue();
  73. }
  74. void SpineEvent::set_float_value(float v){
  75. event->setFloatValue(v);
  76. }
  77. String SpineEvent::get_string_value(){
  78. return event->getStringValue().buffer();
  79. }
  80. void SpineEvent::set_string_value(const String &v){
  81. event->setStringValue(spine::String(v.utf8()));
  82. }
  83. float SpineEvent::get_volume(){
  84. return event->getVolume();
  85. }
  86. void SpineEvent::set_volume(float v){
  87. event->setVolume(v);
  88. }
  89. float SpineEvent::get_balance(){
  90. return event->getBalance();
  91. }
  92. void SpineEvent::set_balance(float v){
  93. event->setBalance(v);
  94. }