rich_text_effect.cpp 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /**************************************************************************/
  2. /* rich_text_effect.cpp */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #include "rich_text_effect.h"
  31. #include "core/object/script_language.h"
  32. CharFXTransform::CharFXTransform() {
  33. }
  34. CharFXTransform::~CharFXTransform() {
  35. environment.clear();
  36. }
  37. void RichTextEffect::_bind_methods(){
  38. GDVIRTUAL_BIND(_process_custom_fx, "char_fx")
  39. }
  40. Variant RichTextEffect::get_bbcode() const {
  41. Variant r;
  42. if (get_script_instance()) {
  43. if (!get_script_instance()->get("bbcode", r)) {
  44. String path = get_script_instance()->get_script()->get_path();
  45. r = path.get_file().get_basename();
  46. }
  47. }
  48. return r;
  49. }
  50. bool RichTextEffect::_process_effect_impl(Ref<CharFXTransform> p_cfx) {
  51. bool return_value = false;
  52. GDVIRTUAL_CALL(_process_custom_fx, p_cfx, return_value);
  53. return return_value;
  54. }
  55. RichTextEffect::RichTextEffect() {
  56. }
  57. void CharFXTransform::_bind_methods() {
  58. ClassDB::bind_method(D_METHOD("get_transform"), &CharFXTransform::get_transform);
  59. ClassDB::bind_method(D_METHOD("set_transform", "transform"), &CharFXTransform::set_transform);
  60. ClassDB::bind_method(D_METHOD("get_range"), &CharFXTransform::get_range);
  61. ClassDB::bind_method(D_METHOD("set_range", "range"), &CharFXTransform::set_range);
  62. ClassDB::bind_method(D_METHOD("get_elapsed_time"), &CharFXTransform::get_elapsed_time);
  63. ClassDB::bind_method(D_METHOD("set_elapsed_time", "time"), &CharFXTransform::set_elapsed_time);
  64. ClassDB::bind_method(D_METHOD("is_visible"), &CharFXTransform::is_visible);
  65. ClassDB::bind_method(D_METHOD("set_visibility", "visibility"), &CharFXTransform::set_visibility);
  66. ClassDB::bind_method(D_METHOD("is_outline"), &CharFXTransform::is_outline);
  67. ClassDB::bind_method(D_METHOD("set_outline", "outline"), &CharFXTransform::set_outline);
  68. ClassDB::bind_method(D_METHOD("get_offset"), &CharFXTransform::get_offset);
  69. ClassDB::bind_method(D_METHOD("set_offset", "offset"), &CharFXTransform::set_offset);
  70. ClassDB::bind_method(D_METHOD("get_color"), &CharFXTransform::get_color);
  71. ClassDB::bind_method(D_METHOD("set_color", "color"), &CharFXTransform::set_color);
  72. ClassDB::bind_method(D_METHOD("get_environment"), &CharFXTransform::get_environment);
  73. ClassDB::bind_method(D_METHOD("set_environment", "environment"), &CharFXTransform::set_environment);
  74. ClassDB::bind_method(D_METHOD("get_glyph_index"), &CharFXTransform::get_glyph_index);
  75. ClassDB::bind_method(D_METHOD("set_glyph_index", "glyph_index"), &CharFXTransform::set_glyph_index);
  76. ClassDB::bind_method(D_METHOD("get_relative_index"), &CharFXTransform::get_relative_index);
  77. ClassDB::bind_method(D_METHOD("set_relative_index", "relative_index"), &CharFXTransform::set_relative_index);
  78. ClassDB::bind_method(D_METHOD("get_glyph_count"), &CharFXTransform::get_glyph_count);
  79. ClassDB::bind_method(D_METHOD("set_glyph_count", "glyph_count"), &CharFXTransform::set_glyph_count);
  80. ClassDB::bind_method(D_METHOD("get_glyph_flags"), &CharFXTransform::get_glyph_flags);
  81. ClassDB::bind_method(D_METHOD("set_glyph_flags", "glyph_flags"), &CharFXTransform::set_glyph_flags);
  82. ClassDB::bind_method(D_METHOD("get_font"), &CharFXTransform::get_font);
  83. ClassDB::bind_method(D_METHOD("set_font", "font"), &CharFXTransform::set_font);
  84. ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "transform"), "set_transform", "get_transform");
  85. ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "range"), "set_range", "get_range");
  86. ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "elapsed_time"), "set_elapsed_time", "get_elapsed_time");
  87. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "visible"), "set_visibility", "is_visible");
  88. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "outline"), "set_outline", "is_outline");
  89. ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "offset"), "set_offset", "get_offset");
  90. ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_color", "get_color");
  91. ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "env"), "set_environment", "get_environment");
  92. ADD_PROPERTY(PropertyInfo(Variant::INT, "glyph_index"), "set_glyph_index", "get_glyph_index");
  93. ADD_PROPERTY(PropertyInfo(Variant::INT, "glyph_count"), "set_glyph_count", "get_glyph_count");
  94. ADD_PROPERTY(PropertyInfo(Variant::INT, "glyph_flags"), "set_glyph_flags", "get_glyph_flags");
  95. ADD_PROPERTY(PropertyInfo(Variant::INT, "relative_index"), "set_relative_index", "get_relative_index");
  96. ADD_PROPERTY(PropertyInfo(Variant::RID, "font"), "set_font", "get_font");
  97. }