2014-02-10 02:10:30 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* animation_player_editor_plugin.h */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 14:16:55 +02:00
|
|
|
/* https://godotengine.org */
|
2014-02-10 02:10:30 +01:00
|
|
|
/*************************************************************************/
|
2020-01-01 11:16:22 +01:00
|
|
|
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
2014-02-10 02:10:30 +01:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
2018-01-05 00:50:27 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
#ifndef ANIMATION_PLAYER_EDITOR_PLUGIN_H
|
|
|
|
#define ANIMATION_PLAYER_EDITOR_PLUGIN_H
|
|
|
|
|
2017-03-05 14:21:25 +01:00
|
|
|
#include "editor/editor_node.h"
|
2017-03-05 16:44:50 +01:00
|
|
|
#include "editor/editor_plugin.h"
|
2014-02-10 02:10:30 +01:00
|
|
|
#include "scene/animation/animation_player.h"
|
|
|
|
#include "scene/gui/dialogs.h"
|
|
|
|
#include "scene/gui/slider.h"
|
|
|
|
#include "scene/gui/spin_box.h"
|
2017-03-05 16:44:50 +01:00
|
|
|
#include "scene/gui/texture_button.h"
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2018-06-07 17:46:14 +02:00
|
|
|
class AnimationTrackEditor;
|
2017-10-30 19:43:19 +01:00
|
|
|
class AnimationPlayerEditorPlugin;
|
2018-06-07 17:46:14 +02:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
class AnimationPlayerEditor : public VBoxContainer {
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
GDCLASS(AnimationPlayerEditor, VBoxContainer);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
EditorNode *editor;
|
2017-10-30 19:43:19 +01:00
|
|
|
AnimationPlayerEditorPlugin *plugin;
|
2014-02-10 02:10:30 +01:00
|
|
|
AnimationPlayer *player;
|
|
|
|
|
2015-05-25 06:46:45 +02:00
|
|
|
enum {
|
2018-06-07 17:46:14 +02:00
|
|
|
TOOL_NEW_ANIM,
|
|
|
|
TOOL_LOAD_ANIM,
|
|
|
|
TOOL_SAVE_ANIM,
|
|
|
|
TOOL_SAVE_AS_ANIM,
|
|
|
|
TOOL_DUPLICATE_ANIM,
|
|
|
|
TOOL_RENAME_ANIM,
|
|
|
|
TOOL_EDIT_TRANSITIONS,
|
|
|
|
TOOL_REMOVE_ANIM,
|
2015-05-25 06:46:45 +02:00
|
|
|
TOOL_COPY_ANIM,
|
|
|
|
TOOL_PASTE_ANIM,
|
|
|
|
TOOL_EDIT_RESOURCE
|
|
|
|
};
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-10-30 19:43:19 +01:00
|
|
|
enum {
|
|
|
|
ONION_SKINNING_ENABLE,
|
|
|
|
ONION_SKINNING_PAST,
|
|
|
|
ONION_SKINNING_FUTURE,
|
|
|
|
ONION_SKINNING_1_STEP,
|
|
|
|
ONION_SKINNING_2_STEPS,
|
|
|
|
ONION_SKINNING_3_STEPS,
|
|
|
|
ONION_SKINNING_LAST_STEPS_OPTION = ONION_SKINNING_3_STEPS,
|
|
|
|
ONION_SKINNING_DIFFERENCES_ONLY,
|
|
|
|
ONION_SKINNING_FORCE_WHITE_MODULATE,
|
|
|
|
ONION_SKINNING_INCLUDE_GIZMOS,
|
|
|
|
};
|
|
|
|
|
2015-10-19 21:40:24 +02:00
|
|
|
enum {
|
2018-06-07 17:46:14 +02:00
|
|
|
ANIM_OPEN,
|
2015-10-19 21:40:24 +02:00
|
|
|
ANIM_SAVE,
|
|
|
|
ANIM_SAVE_AS
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
RESOURCE_LOAD,
|
|
|
|
RESOURCE_SAVE
|
|
|
|
};
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
OptionButton *animation;
|
|
|
|
Button *stop;
|
|
|
|
Button *play;
|
2015-05-25 06:46:45 +02:00
|
|
|
Button *play_from;
|
|
|
|
Button *play_bw;
|
|
|
|
Button *play_bw_from;
|
2014-02-10 02:10:30 +01:00
|
|
|
Button *autoplay;
|
2018-06-07 17:46:14 +02:00
|
|
|
|
2015-05-25 06:46:45 +02:00
|
|
|
MenuButton *tool_anim;
|
2019-05-14 05:42:05 +02:00
|
|
|
ToolButton *onion_toggle;
|
2017-10-30 19:43:19 +01:00
|
|
|
MenuButton *onion_skinning;
|
2016-01-18 00:03:57 +01:00
|
|
|
ToolButton *pin;
|
2014-02-10 02:10:30 +01:00
|
|
|
SpinBox *frame;
|
|
|
|
LineEdit *scale;
|
|
|
|
LineEdit *name;
|
|
|
|
Label *name_title;
|
|
|
|
UndoRedo *undo_redo;
|
|
|
|
Ref<Texture> autoplay_icon;
|
|
|
|
bool last_active;
|
2019-10-01 18:38:03 +02:00
|
|
|
float timeline_position;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2015-06-06 14:44:38 +02:00
|
|
|
EditorFileDialog *file;
|
2015-10-19 21:40:24 +02:00
|
|
|
AcceptDialog *accept;
|
2017-03-05 16:44:50 +01:00
|
|
|
ConfirmationDialog *delete_dialog;
|
2015-10-19 21:40:24 +02:00
|
|
|
int current_option;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
struct BlendEditor {
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
AcceptDialog *dialog;
|
2014-02-10 02:10:30 +01:00
|
|
|
Tree *tree;
|
2016-05-07 18:27:52 +02:00
|
|
|
OptionButton *next;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
} blend_editor;
|
|
|
|
|
|
|
|
ConfirmationDialog *name_dialog;
|
|
|
|
ConfirmationDialog *error_dialog;
|
|
|
|
bool renaming;
|
|
|
|
|
|
|
|
bool updating;
|
|
|
|
bool updating_blends;
|
|
|
|
|
2018-06-07 17:46:14 +02:00
|
|
|
AnimationTrackEditor *track_editor;
|
2016-01-18 00:03:57 +01:00
|
|
|
|
2019-09-04 07:20:57 +02:00
|
|
|
// Onion skinning.
|
2017-10-30 19:43:19 +01:00
|
|
|
struct {
|
2019-09-04 07:20:57 +02:00
|
|
|
// Settings.
|
2017-10-30 19:43:19 +01:00
|
|
|
bool enabled;
|
|
|
|
bool past;
|
|
|
|
bool future;
|
|
|
|
int steps;
|
|
|
|
bool differences_only;
|
|
|
|
bool force_white_modulate;
|
|
|
|
bool include_gizmos;
|
|
|
|
|
|
|
|
int get_needed_capture_count() const {
|
2019-09-04 07:20:57 +02:00
|
|
|
// 'Differences only' needs a capture of the present.
|
2017-10-30 19:43:19 +01:00
|
|
|
return (past && future ? 2 * steps : steps) + (differences_only ? 1 : 0);
|
|
|
|
}
|
|
|
|
|
2019-09-04 07:20:57 +02:00
|
|
|
// Rendering.
|
2017-10-30 19:43:19 +01:00
|
|
|
int64_t last_frame;
|
|
|
|
int can_overlay;
|
|
|
|
Size2 capture_size;
|
|
|
|
Vector<RID> captures;
|
|
|
|
Vector<bool> captures_valid;
|
|
|
|
struct {
|
|
|
|
RID canvas;
|
|
|
|
RID canvas_item;
|
|
|
|
Ref<ShaderMaterial> material;
|
|
|
|
Ref<Shader> shader;
|
|
|
|
} capture;
|
|
|
|
} onion;
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void _select_anim_by_name(const String &p_anim);
|
2019-09-02 15:49:55 +02:00
|
|
|
double _get_editor_step() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
void _play_pressed();
|
2015-05-25 06:46:45 +02:00
|
|
|
void _play_from_pressed();
|
|
|
|
void _play_bw_pressed();
|
|
|
|
void _play_bw_from_pressed();
|
2014-02-10 02:10:30 +01:00
|
|
|
void _autoplay_pressed();
|
|
|
|
void _stop_pressed();
|
|
|
|
void _animation_selected(int p_which);
|
|
|
|
void _animation_new();
|
|
|
|
void _animation_rename();
|
|
|
|
void _animation_name_edited();
|
|
|
|
void _animation_load();
|
2015-10-19 21:40:24 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void _animation_save_in_path(const Ref<Resource> &p_resource, const String &p_path);
|
|
|
|
void _animation_save(const Ref<Resource> &p_resource);
|
|
|
|
void _animation_save_as(const Ref<Resource> &p_resource);
|
2015-10-19 21:40:24 +02:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
void _animation_remove();
|
2017-01-25 21:22:16 +01:00
|
|
|
void _animation_remove_confirmed();
|
2014-02-10 02:10:30 +01:00
|
|
|
void _animation_blend();
|
|
|
|
void _animation_edit();
|
|
|
|
void _animation_duplicate();
|
|
|
|
void _animation_resource_edit();
|
2017-03-05 16:44:50 +01:00
|
|
|
void _scale_changed(const String &p_scale);
|
2015-10-19 21:40:24 +02:00
|
|
|
void _dialog_action(String p_file);
|
2017-03-05 16:44:50 +01:00
|
|
|
void _seek_frame_changed(const String &p_frame);
|
|
|
|
void _seek_value_changed(float p_value, bool p_set = false);
|
2016-05-07 18:27:52 +02:00
|
|
|
void _blend_editor_next_changed(const int p_idx);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
void _list_changed();
|
|
|
|
void _update_animation();
|
|
|
|
void _update_player();
|
|
|
|
void _blend_edited();
|
|
|
|
|
|
|
|
void _animation_player_changed(Object *p_pl);
|
|
|
|
|
2016-06-19 06:43:02 +02:00
|
|
|
void _animation_key_editor_seek(float p_pos, bool p_drag);
|
2017-08-12 18:52:50 +02:00
|
|
|
void _animation_key_editor_anim_len_changed(float p_len);
|
2016-01-18 00:03:57 +01:00
|
|
|
|
2017-05-20 17:38:03 +02:00
|
|
|
void _unhandled_key_input(const Ref<InputEvent> &p_ev);
|
2015-05-25 06:46:45 +02:00
|
|
|
void _animation_tool_menu(int p_option);
|
2017-10-30 19:43:19 +01:00
|
|
|
void _onion_skinning_menu(int p_option);
|
|
|
|
|
|
|
|
void _editor_visibility_changed();
|
|
|
|
bool _are_onion_layers_valid();
|
|
|
|
void _allocate_onion_layers();
|
|
|
|
void _free_onion_layers();
|
|
|
|
void _prepare_onion_layers_1();
|
|
|
|
void _prepare_onion_layers_2();
|
|
|
|
void _start_onion_skinning();
|
|
|
|
void _stop_onion_skinning();
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2018-06-07 17:46:14 +02:00
|
|
|
void _pin_pressed();
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
AnimationPlayerEditor();
|
2017-10-30 19:43:19 +01:00
|
|
|
~AnimationPlayerEditor();
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
protected:
|
2014-02-10 02:10:30 +01:00
|
|
|
void _notification(int p_what);
|
|
|
|
void _node_removed(Node *p_node);
|
|
|
|
static void _bind_methods();
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
public:
|
2015-12-05 18:18:22 +01:00
|
|
|
AnimationPlayer *get_player() const;
|
|
|
|
static AnimationPlayerEditor *singleton;
|
|
|
|
|
2018-06-07 17:46:14 +02:00
|
|
|
bool is_pinned() const { return pin->is_pressed(); }
|
|
|
|
void unpin() { pin->set_pressed(false); }
|
|
|
|
AnimationTrackEditor *get_track_editor() { return track_editor; }
|
2015-08-30 03:59:25 +02:00
|
|
|
Dictionary get_state() const;
|
2017-03-05 16:44:50 +01:00
|
|
|
void set_state(const Dictionary &p_state);
|
2015-08-30 03:59:25 +02:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
void ensure_visibility();
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void set_undo_redo(UndoRedo *p_undo_redo) { undo_redo = p_undo_redo; }
|
2014-02-10 02:10:30 +01:00
|
|
|
void edit(AnimationPlayer *p_player);
|
2018-09-18 20:00:07 +02:00
|
|
|
void forward_canvas_force_draw_over_viewport(Control *p_overlay);
|
2017-10-30 19:43:19 +01:00
|
|
|
|
|
|
|
AnimationPlayerEditor(EditorNode *p_editor, AnimationPlayerEditorPlugin *p_plugin);
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class AnimationPlayerEditorPlugin : public EditorPlugin {
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
GDCLASS(AnimationPlayerEditorPlugin, EditorPlugin);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
AnimationPlayerEditor *anim_editor;
|
|
|
|
EditorNode *editor;
|
|
|
|
|
2017-10-30 19:43:19 +01:00
|
|
|
protected:
|
|
|
|
void _notification(int p_what);
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
public:
|
2015-08-30 03:59:25 +02:00
|
|
|
virtual Dictionary get_state() const { return anim_editor->get_state(); }
|
2017-03-05 16:44:50 +01:00
|
|
|
virtual void set_state(const Dictionary &p_state) { anim_editor->set_state(p_state); }
|
2015-08-30 03:59:25 +02:00
|
|
|
|
2016-05-19 00:08:12 +02:00
|
|
|
virtual String get_name() const { return "Anim"; }
|
2014-02-10 02:10:30 +01:00
|
|
|
bool has_main_screen() const { return false; }
|
2017-08-12 18:52:50 +02:00
|
|
|
virtual void edit(Object *p_object);
|
|
|
|
virtual bool handles(Object *p_object) const;
|
2014-02-10 02:10:30 +01:00
|
|
|
virtual void make_visible(bool p_visible);
|
|
|
|
|
2018-09-18 20:00:07 +02:00
|
|
|
virtual void forward_canvas_force_draw_over_viewport(Control *p_overlay) { anim_editor->forward_canvas_force_draw_over_viewport(p_overlay); }
|
2017-10-30 19:43:19 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
AnimationPlayerEditorPlugin(EditorNode *p_node);
|
|
|
|
~AnimationPlayerEditorPlugin();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ANIMATION_PLAYER_EDITOR_PLUGIN_H
|