visual_script_builtin_funcs.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*************************************************************************/
  2. /* visual_script_builtin_funcs.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
  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. #ifndef VISUAL_SCRIPT_BUILTIN_FUNCS_H
  31. #define VISUAL_SCRIPT_BUILTIN_FUNCS_H
  32. #include "visual_script.h"
  33. class VisualScriptBuiltinFunc : public VisualScriptNode {
  34. GDCLASS(VisualScriptBuiltinFunc, VisualScriptNode)
  35. public:
  36. enum BuiltinFunc {
  37. MATH_SIN,
  38. MATH_COS,
  39. MATH_TAN,
  40. MATH_SINH,
  41. MATH_COSH,
  42. MATH_TANH,
  43. MATH_ASIN,
  44. MATH_ACOS,
  45. MATH_ATAN,
  46. MATH_ATAN2,
  47. MATH_SQRT,
  48. MATH_FMOD,
  49. MATH_FPOSMOD,
  50. MATH_FLOOR,
  51. MATH_CEIL,
  52. MATH_ROUND,
  53. MATH_ABS,
  54. MATH_SIGN,
  55. MATH_POW,
  56. MATH_LOG,
  57. MATH_EXP,
  58. MATH_ISNAN,
  59. MATH_ISINF,
  60. MATH_EASE,
  61. MATH_DECIMALS,
  62. MATH_STEPIFY,
  63. MATH_LERP,
  64. MATH_INVERSE_LERP,
  65. MATH_RANGE_LERP,
  66. MATH_DECTIME,
  67. MATH_RANDOMIZE,
  68. MATH_RAND,
  69. MATH_RANDF,
  70. MATH_RANDOM,
  71. MATH_SEED,
  72. MATH_RANDSEED,
  73. MATH_DEG2RAD,
  74. MATH_RAD2DEG,
  75. MATH_LINEAR2DB,
  76. MATH_DB2LINEAR,
  77. MATH_POLAR2CARTESIAN,
  78. MATH_CARTESIAN2POLAR,
  79. MATH_WRAP,
  80. MATH_WRAPF,
  81. LOGIC_MAX,
  82. LOGIC_MIN,
  83. LOGIC_CLAMP,
  84. LOGIC_NEAREST_PO2,
  85. OBJ_WEAKREF,
  86. FUNC_FUNCREF,
  87. TYPE_CONVERT,
  88. TYPE_OF,
  89. TYPE_EXISTS,
  90. TEXT_CHAR,
  91. TEXT_STR,
  92. TEXT_PRINT,
  93. TEXT_PRINTERR,
  94. TEXT_PRINTRAW,
  95. VAR_TO_STR,
  96. STR_TO_VAR,
  97. VAR_TO_BYTES,
  98. BYTES_TO_VAR,
  99. COLORN,
  100. FUNC_MAX
  101. };
  102. static int get_func_argument_count(BuiltinFunc p_func);
  103. static String get_func_name(BuiltinFunc p_func);
  104. static void exec_func(BuiltinFunc p_func, const Variant **p_inputs, Variant *r_return, Variant::CallError &r_error, String &r_error_str);
  105. static BuiltinFunc find_function(const String &p_string);
  106. private:
  107. static const char *func_name[FUNC_MAX];
  108. BuiltinFunc func;
  109. protected:
  110. static void _bind_methods();
  111. public:
  112. virtual int get_output_sequence_port_count() const;
  113. virtual bool has_input_sequence_port() const;
  114. virtual String get_output_sequence_port_text(int p_port) const;
  115. virtual int get_input_value_port_count() const;
  116. virtual int get_output_value_port_count() const;
  117. virtual PropertyInfo get_input_value_port_info(int p_idx) const;
  118. virtual PropertyInfo get_output_value_port_info(int p_idx) const;
  119. virtual String get_caption() const;
  120. //virtual String get_text() const;
  121. virtual String get_category() const { return "functions"; }
  122. void set_func(BuiltinFunc p_which);
  123. BuiltinFunc get_func();
  124. virtual VisualScriptNodeInstance *instance(VisualScriptInstance *p_instance);
  125. VisualScriptBuiltinFunc(VisualScriptBuiltinFunc::BuiltinFunc func);
  126. VisualScriptBuiltinFunc();
  127. };
  128. VARIANT_ENUM_CAST(VisualScriptBuiltinFunc::BuiltinFunc)
  129. void register_visual_script_builtin_func_node();
  130. #endif // VISUAL_SCRIPT_BUILTIN_FUNCS_H