example.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*************************************************************************/
  2. /* example.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2021 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 EXAMPLE_CLASS_H
  31. #define EXAMPLE_CLASS_H
  32. // We don't need windows.h in this plugin but many others do and it throws up on itself all the time
  33. // So best to include it and make sure CI warns us when we use something Microsoft took for their own goals....
  34. #ifdef WIN32
  35. #include <windows.h>
  36. #endif
  37. #include <godot_cpp/classes/control.hpp>
  38. #include <godot_cpp/classes/global_constants.hpp>
  39. #include <godot_cpp/classes/viewport.hpp>
  40. #include <godot_cpp/core/binder_common.hpp>
  41. using namespace godot;
  42. class ExampleRef : public RefCounted {
  43. GDCLASS(ExampleRef, RefCounted);
  44. protected:
  45. static void _bind_methods() {}
  46. public:
  47. ExampleRef();
  48. ~ExampleRef();
  49. };
  50. class Example : public Control {
  51. GDCLASS(Example, Control);
  52. protected:
  53. static void _bind_methods();
  54. private:
  55. Vector2 custom_position;
  56. public:
  57. // Constants.
  58. enum Constants {
  59. FIRST,
  60. ANSWER_TO_EVERYTHING = 42,
  61. };
  62. enum {
  63. CONSTANT_WITHOUT_ENUM = 314,
  64. };
  65. Example();
  66. ~Example();
  67. // Functions.
  68. void simple_func();
  69. void simple_const_func() const;
  70. String return_something(const String &base);
  71. Viewport *return_something_const() const;
  72. ExampleRef *return_extended_ref() const;
  73. Ref<ExampleRef> extended_ref_checks(Ref<ExampleRef> p_ref) const;
  74. Variant varargs_func(const Variant **args, GDNativeInt arg_count, GDNativeCallError &error);
  75. void emit_custom_signal(const String &name, int value);
  76. Array test_array() const;
  77. // Property.
  78. void set_custom_position(const Vector2 &pos);
  79. Vector2 get_custom_position() const;
  80. // Virtual function override (no need to bind manually).
  81. virtual bool _has_point(const Vector2 &point) const override;
  82. };
  83. VARIANT_ENUM_CAST(Example, Constants);
  84. #endif // ! EXAMPLE_CLASS_H