SpineEventData.cpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /******************************************************************************
  2. * Spine Runtimes License Agreement
  3. * Last updated April 5, 2025. Replaces all prior versions.
  4. *
  5. * Copyright (c) 2013-2025, 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 "SpineEventData.h"
  30. #include "SpineCommon.h"
  31. void SpineEventData::_bind_methods() {
  32. ClassDB::bind_method(D_METHOD("get_event_name"), &SpineEventData::get_event_name);
  33. ClassDB::bind_method(D_METHOD("get_int_value"), &SpineEventData::get_int_value);
  34. ClassDB::bind_method(D_METHOD("set_int_value", "v"), &SpineEventData::set_int_value);
  35. ClassDB::bind_method(D_METHOD("get_float_value"), &SpineEventData::get_float_value);
  36. ClassDB::bind_method(D_METHOD("set_float_value", "v"), &SpineEventData::set_float_value);
  37. ClassDB::bind_method(D_METHOD("get_string_value"), &SpineEventData::get_string_value);
  38. ClassDB::bind_method(D_METHOD("set_string_value", "v"), &SpineEventData::set_string_value);
  39. ClassDB::bind_method(D_METHOD("get_audio_path"), &SpineEventData::get_audio_path);
  40. ClassDB::bind_method(D_METHOD("set_audio_path", "v"), &SpineEventData::set_audio_path);
  41. ClassDB::bind_method(D_METHOD("get_volume"), &SpineEventData::get_volume);
  42. ClassDB::bind_method(D_METHOD("set_volume", "v"), &SpineEventData::set_volume);
  43. ClassDB::bind_method(D_METHOD("get_balance"), &SpineEventData::get_balance);
  44. ClassDB::bind_method(D_METHOD("set_balance", "v"), &SpineEventData::set_balance);
  45. }
  46. String SpineEventData::get_event_name() {
  47. SPINE_CHECK(get_spine_object(), "")
  48. String name;
  49. name.parse_utf8(get_spine_object()->getName().buffer());
  50. return name;
  51. }
  52. int SpineEventData::get_int_value() {
  53. SPINE_CHECK(get_spine_object(), 0)
  54. return get_spine_object()->getIntValue();
  55. }
  56. void SpineEventData::set_int_value(int v) {
  57. SPINE_CHECK(get_spine_object(), )
  58. get_spine_object()->setIntValue(v);
  59. }
  60. float SpineEventData::get_float_value() {
  61. SPINE_CHECK(get_spine_object(), 0)
  62. return get_spine_object()->getFloatValue();
  63. }
  64. void SpineEventData::set_float_value(float v) {
  65. SPINE_CHECK(get_spine_object(), )
  66. get_spine_object()->setFloatValue(v);
  67. }
  68. String SpineEventData::get_string_value() {
  69. SPINE_CHECK(get_spine_object(), "")
  70. return get_spine_object()->getStringValue().buffer();
  71. }
  72. void SpineEventData::set_string_value(const String &v) {
  73. SPINE_CHECK(get_spine_object(), )
  74. get_spine_object()->setStringValue(spine::String(v.utf8()));
  75. }
  76. String SpineEventData::get_audio_path() {
  77. SPINE_CHECK(get_spine_object(), "")
  78. return get_spine_object()->getAudioPath().buffer();
  79. }
  80. void SpineEventData::set_audio_path(const String &v) {
  81. SPINE_CHECK(get_spine_object(), )
  82. get_spine_object()->setAudioPath(spine::String(v.utf8()));
  83. }
  84. float SpineEventData::get_volume() {
  85. SPINE_CHECK(get_spine_object(), 0)
  86. return get_spine_object()->getVolume();
  87. }
  88. void SpineEventData::set_volume(float v) {
  89. SPINE_CHECK(get_spine_object(), )
  90. get_spine_object()->setVolume(v);
  91. }
  92. float SpineEventData::get_balance() {
  93. SPINE_CHECK(get_spine_object(), 0)
  94. return get_spine_object()->getBalance();
  95. }
  96. void SpineEventData::set_balance(float v) {
  97. SPINE_CHECK(get_spine_object(), )
  98. get_spine_object()->setBalance(v);
  99. }