2014-02-10 02:10:30 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* editor_data.h */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* http://www.godotengine.org */
|
|
|
|
/*************************************************************************/
|
2016-01-01 14:50:53 +01:00
|
|
|
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
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. */
|
|
|
|
/*************************************************************************/
|
|
|
|
#ifndef EDITOR_DATA_H
|
|
|
|
#define EDITOR_DATA_H
|
|
|
|
|
|
|
|
#include "tools/editor/editor_plugin.h"
|
|
|
|
#include "scene/resources/texture.h"
|
|
|
|
#include "list.h"
|
|
|
|
#include "undo_redo.h"
|
|
|
|
#include "pair.h"
|
|
|
|
|
|
|
|
class EditorHistory {
|
|
|
|
|
|
|
|
enum {
|
|
|
|
|
|
|
|
HISTORY_MAX=64
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Obj {
|
|
|
|
|
2015-08-25 05:08:45 +02:00
|
|
|
REF ref;
|
2014-02-10 02:10:30 +01:00
|
|
|
ObjectID object;
|
|
|
|
String property;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct History {
|
|
|
|
|
|
|
|
Vector<Obj> path;
|
|
|
|
int level;
|
|
|
|
};
|
2015-06-22 05:03:19 +02:00
|
|
|
friend class EditorData;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
Vector<History> history;
|
|
|
|
int current;
|
|
|
|
|
|
|
|
//Vector<EditorPlugin*> editor_plugins;
|
|
|
|
|
|
|
|
struct PropertyData {
|
|
|
|
|
|
|
|
String name;
|
|
|
|
Variant value;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void _cleanup_history();
|
|
|
|
|
|
|
|
void _add_object(ObjectID p_object,const String& p_property,int p_level_change);
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2015-09-01 05:49:47 +02:00
|
|
|
bool is_at_begining() const;
|
|
|
|
bool is_at_end() const;
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
void add_object(ObjectID p_object);
|
|
|
|
void add_object(ObjectID p_object,const String& p_subprop);
|
|
|
|
void add_object(ObjectID p_object,int p_relevel);
|
|
|
|
|
2015-09-01 05:49:47 +02:00
|
|
|
int get_history_len();
|
|
|
|
int get_history_pos();
|
|
|
|
ObjectID get_history_obj(int p_obj) const;
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
bool next();
|
|
|
|
bool previous();
|
|
|
|
ObjectID get_current();
|
|
|
|
|
|
|
|
int get_path_size() const;
|
|
|
|
ObjectID get_path_object(int p_index) const;
|
|
|
|
String get_path_property(int p_index) const;
|
|
|
|
|
|
|
|
void clear();
|
|
|
|
|
|
|
|
EditorHistory();
|
|
|
|
};
|
|
|
|
|
2015-06-22 05:03:19 +02:00
|
|
|
class EditorSelection;
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
class EditorData {
|
|
|
|
|
|
|
|
public:
|
|
|
|
struct CustomType {
|
|
|
|
|
|
|
|
String name;
|
|
|
|
Ref<Script> script;
|
|
|
|
Ref<Texture> icon;
|
|
|
|
};
|
|
|
|
private:
|
|
|
|
|
|
|
|
Vector<EditorPlugin*> editor_plugins;
|
|
|
|
|
|
|
|
struct PropertyData {
|
|
|
|
|
|
|
|
String name;
|
|
|
|
Variant value;
|
|
|
|
};
|
|
|
|
Map<String,Vector<CustomType> > custom_types;
|
|
|
|
|
|
|
|
List<PropertyData> clipboard;
|
|
|
|
UndoRedo undo_redo;
|
|
|
|
|
|
|
|
|
|
|
|
void _cleanup_history();
|
|
|
|
|
2015-06-22 05:03:19 +02:00
|
|
|
struct EditedScene {
|
|
|
|
Node* root;
|
|
|
|
Dictionary editor_states;
|
|
|
|
Ref<ResourceImportMetadata> medatata;
|
|
|
|
List<Node*> selection;
|
|
|
|
Vector<EditorHistory::History> history_stored;
|
|
|
|
int history_current;
|
|
|
|
Dictionary custom_state;
|
|
|
|
uint64_t version;
|
2015-08-02 17:29:37 +02:00
|
|
|
NodePath live_edit_root;
|
2015-06-22 05:03:19 +02:00
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
Vector<EditedScene> edited_scene;
|
|
|
|
int current_edited_scene;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2015-12-14 00:39:01 +01:00
|
|
|
bool _find_updated_instances(Node* p_root,Node *p_node,Set<String> &checked_paths);
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
public:
|
|
|
|
|
|
|
|
EditorPlugin* get_editor(Object *p_object);
|
|
|
|
EditorPlugin* get_subeditor(Object *p_object);
|
2016-03-30 01:02:53 +02:00
|
|
|
Vector<EditorPlugin*> get_subeditors(Object *p_object);
|
2014-02-10 02:10:30 +01:00
|
|
|
EditorPlugin* get_editor(String p_name);
|
|
|
|
|
|
|
|
void copy_object_params(Object *p_object);
|
|
|
|
void paste_object_params(Object *p_object);
|
|
|
|
|
|
|
|
Dictionary get_editor_states() const;
|
2016-07-08 18:36:57 +02:00
|
|
|
Dictionary get_scene_editor_states(int p_idx) const;
|
2014-02-10 02:10:30 +01:00
|
|
|
void set_editor_states(const Dictionary& p_states);
|
|
|
|
void get_editor_breakpoints(List<String> *p_breakpoints);
|
|
|
|
void clear_editor_states();
|
|
|
|
void save_editor_external_data();
|
|
|
|
void apply_changes_in_editors();
|
|
|
|
|
|
|
|
void add_editor_plugin(EditorPlugin *p_plugin);
|
|
|
|
void remove_editor_plugin(EditorPlugin *p_plugin);
|
|
|
|
|
2016-02-28 03:10:44 +01:00
|
|
|
int get_editor_plugin_count() const;
|
|
|
|
EditorPlugin *get_editor_plugin(int p_idx);
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
UndoRedo &get_undo_redo();
|
|
|
|
|
|
|
|
void save_editor_global_states();
|
|
|
|
void restore_editor_global_states();
|
|
|
|
|
|
|
|
void add_custom_type(const String& p_type, const String& p_inherits,const Ref<Script>& p_script,const Ref<Texture>& p_icon );
|
|
|
|
void remove_custom_type(const String& p_type);
|
|
|
|
const Map<String,Vector<CustomType> >& get_custom_types() const { return custom_types; }
|
|
|
|
|
2015-06-22 05:03:19 +02:00
|
|
|
|
|
|
|
int add_edited_scene(int p_at_pos);
|
|
|
|
void move_edited_scene_index(int p_idx,int p_to_idx);
|
|
|
|
void remove_scene(int p_idx);
|
|
|
|
void set_edited_scene(int p_idx);
|
|
|
|
void set_edited_scene_root(Node* p_root);
|
|
|
|
void set_edited_scene_import_metadata(Ref<ResourceImportMetadata> p_mdata);
|
2016-06-26 05:54:17 +02:00
|
|
|
Ref<ResourceImportMetadata> get_edited_scene_import_metadata(int p_idx = -1) const;
|
2015-06-22 05:03:19 +02:00
|
|
|
int get_edited_scene() const;
|
2016-06-26 05:54:17 +02:00
|
|
|
Node* get_edited_scene_root(int p_idx = -1);
|
2015-06-22 05:03:19 +02:00
|
|
|
int get_edited_scene_count() const;
|
|
|
|
String get_scene_title(int p_idx) const;
|
|
|
|
String get_scene_path(int p_idx) const;
|
2015-07-24 19:18:02 +02:00
|
|
|
String get_scene_type(int p_idx) const;
|
2015-07-26 15:44:10 +02:00
|
|
|
Ref<Script> get_scene_root_script(int p_idx) const;
|
2016-06-26 05:54:17 +02:00
|
|
|
void set_edited_scene_version(uint64_t version, int p_scene_idx = -1);
|
2015-06-22 05:03:19 +02:00
|
|
|
uint64_t get_edited_scene_version() const;
|
|
|
|
uint64_t get_scene_version(int p_idx) const;
|
|
|
|
void clear_edited_scenes();
|
2015-08-02 17:29:37 +02:00
|
|
|
void set_edited_scene_live_edit_root(const NodePath& p_root);
|
|
|
|
NodePath get_edited_scene_live_edit_root();
|
2015-12-14 00:39:01 +01:00
|
|
|
bool check_and_update_scene(int p_idx);
|
2016-01-23 22:28:30 +01:00
|
|
|
void move_edited_scene_to_index(int p_idx);
|
2015-06-22 05:03:19 +02:00
|
|
|
|
|
|
|
|
|
|
|
void set_plugin_window_layout(Ref<ConfigFile> p_layout);
|
|
|
|
void get_plugin_window_layout(Ref<ConfigFile> p_layout);
|
|
|
|
|
|
|
|
void save_edited_scene_state(EditorSelection *p_selection,EditorHistory *p_history,const Dictionary& p_custom);
|
|
|
|
Dictionary restore_edited_scene_state(EditorSelection *p_selection, EditorHistory *p_history);
|
2015-12-09 13:08:41 +01:00
|
|
|
void notify_edited_scene_changed();
|
2015-06-22 05:03:19 +02:00
|
|
|
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
EditorData();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class EditorSelection : public Object {
|
|
|
|
|
|
|
|
OBJ_TYPE(EditorSelection,Object);
|
|
|
|
public:
|
|
|
|
|
|
|
|
Map<Node*,Object*> selection;
|
|
|
|
|
|
|
|
bool changed;
|
|
|
|
bool nl_changed;
|
|
|
|
|
|
|
|
void _node_removed(Node *p_node);
|
|
|
|
|
|
|
|
List<Object*> editor_plugins;
|
|
|
|
List<Node*> selected_node_list;
|
|
|
|
|
|
|
|
void _update_nl();
|
2016-02-27 04:32:00 +01:00
|
|
|
Array _get_selected_nodes();
|
2014-02-10 02:10:30 +01:00
|
|
|
protected:
|
|
|
|
|
|
|
|
static void _bind_methods();
|
|
|
|
public:
|
|
|
|
|
|
|
|
void add_node(Node *p_node);
|
|
|
|
void remove_node(Node *p_node);
|
|
|
|
bool is_selected(Node *) const;
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
T* get_node_editor_data(Node *p_node) {
|
|
|
|
if (!selection.has(p_node))
|
|
|
|
return NULL;
|
|
|
|
Object *obj = selection[p_node];
|
|
|
|
if (!obj)
|
|
|
|
return NULL;
|
|
|
|
return obj->cast_to<T>();
|
|
|
|
}
|
|
|
|
|
|
|
|
void add_editor_plugin(Object *p_object);
|
|
|
|
|
|
|
|
void update();
|
|
|
|
void clear();
|
|
|
|
|
|
|
|
|
|
|
|
List<Node*>& get_selected_node_list();
|
|
|
|
Map<Node*,Object*>& get_selection() { return selection; }
|
|
|
|
|
|
|
|
|
|
|
|
EditorSelection();
|
|
|
|
~EditorSelection();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // EDITOR_DATA_H
|