| 1 | /**************************************************************************/ |
| 2 | /* skeleton_modification_2d.h */ |
| 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 | |
| 31 | #ifndef SKELETON_MODIFICATION_2D_H |
| 32 | #define SKELETON_MODIFICATION_2D_H |
| 33 | |
| 34 | #include "scene/2d/skeleton_2d.h" |
| 35 | #include "scene/resources/skeleton_modification_stack_2d.h" |
| 36 | |
| 37 | /////////////////////////////////////// |
| 38 | // SkeletonModification2D |
| 39 | /////////////////////////////////////// |
| 40 | |
| 41 | class SkeletonModificationStack2D; |
| 42 | class Bone2D; |
| 43 | |
| 44 | class SkeletonModification2D : public Resource { |
| 45 | GDCLASS(SkeletonModification2D, Resource); |
| 46 | friend class Skeleton2D; |
| 47 | friend class Bone2D; |
| 48 | |
| 49 | protected: |
| 50 | static void _bind_methods(); |
| 51 | |
| 52 | SkeletonModificationStack2D *stack = nullptr; |
| 53 | int execution_mode = 0; // 0 = process |
| 54 | |
| 55 | bool enabled = true; |
| 56 | bool is_setup = false; |
| 57 | |
| 58 | bool _print_execution_error(bool p_condition, String p_message); |
| 59 | |
| 60 | GDVIRTUAL1(_execute, double) |
| 61 | GDVIRTUAL1(_setup_modification, Ref<SkeletonModificationStack2D>) |
| 62 | GDVIRTUAL0(_draw_editor_gizmo) |
| 63 | |
| 64 | public: |
| 65 | virtual void _execute(float _delta); |
| 66 | virtual void _setup_modification(SkeletonModificationStack2D *p_stack); |
| 67 | virtual void _draw_editor_gizmo(); |
| 68 | |
| 69 | bool editor_draw_gizmo = false; |
| 70 | void set_editor_draw_gizmo(bool p_draw_gizmo); |
| 71 | bool get_editor_draw_gizmo() const; |
| 72 | |
| 73 | void set_enabled(bool p_enabled); |
| 74 | bool get_enabled(); |
| 75 | |
| 76 | Ref<SkeletonModificationStack2D> get_modification_stack(); |
| 77 | void set_is_setup(bool p_setup); |
| 78 | bool get_is_setup() const; |
| 79 | |
| 80 | void set_execution_mode(int p_mode); |
| 81 | int get_execution_mode() const; |
| 82 | |
| 83 | float clamp_angle(float p_angle, float p_min_bound, float p_max_bound, bool p_invert_clamp = false); |
| 84 | void editor_draw_angle_constraints(Bone2D *p_operation_bone, float p_min_bound, float p_max_bound, bool p_constraint_enabled, bool p_constraint_in_localspace, bool p_constraint_inverted); |
| 85 | |
| 86 | SkeletonModification2D(); |
| 87 | }; |
| 88 | |
| 89 | #endif // SKELETON_MODIFICATION_2D_H |
| 90 | |