Refactoring: rename tools/editor/ to editor/

The other subfolders of tools/ had already been moved to either
editor/, misc/ or thirdparty/, so the hiding the editor code that
deep was no longer meaningful.

(Manual redo of 49c065d29c)
This commit is contained in:
Rémi Verschelde 2017-03-18 23:45:45 +01:00
parent 9d2c0f6c6e
commit 1b0e2b0c39
1880 changed files with 178275 additions and 178275 deletions

12
.gitignore vendored
View File

@ -15,12 +15,12 @@ core/method_bind_ext.inc
core/script_encryption_key.cpp
core/global_defaults.cpp
drivers/unix/os_unix_global_settings_path.cpp
tools/editor/register_exporters.cpp
tools/editor/doc_data_compressed.h
tools/editor/certs_compressed.h
tools/editor/editor_icons.cpp
tools/editor/translations.h
tools/editor/builtin_fonts.h
editor/register_exporters.cpp
editor/doc_data_compressed.h
editor/certs_compressed.h
editor/editor_icons.cpp
editor/translations.h
editor/builtin_fonts.h
.fscache
make.bat
log.txt

View File

@ -183,7 +183,7 @@ Help(opts.GenerateHelpText(env_base)) # generate help
# add default include paths
env_base.Append(CPPPATH=['#core', '#core/math', '#tools', '#drivers', '#'])
env_base.Append(CPPPATH=['#core', '#core/math', '#editor', '#drivers', '#'])
# configure ENV for platform
env_base.platform_exporters = platform_exporters
@ -359,7 +359,7 @@ if selected_platform in platform_list:
SConscript("core/SCsub")
SConscript("servers/SCsub")
SConscript("scene/SCsub")
SConscript("tools/editor/SCsub")
SConscript("editor/SCsub")
SConscript("drivers/SCsub")
SConscript("modules/SCsub")

185
editor/SCsub Normal file
View File

@ -0,0 +1,185 @@
#!/usr/bin/env python
Import('env')
env.editor_sources = []
def make_certs_header(target, source, env):
src = source[0].srcnode().abspath
dst = target[0].srcnode().abspath
f = open(src, "rb")
g = open(dst, "wb")
buf = f.read()
decomp_size = len(buf)
import zlib
buf = zlib.compress(buf)
g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
g.write("#ifndef _CERTS_RAW_H\n")
g.write("#define _CERTS_RAW_H\n")
g.write("static const int _certs_compressed_size=" + str(len(buf)) + ";\n")
g.write("static const int _certs_uncompressed_size=" + str(decomp_size) + ";\n")
g.write("static const unsigned char _certs_compressed[]={\n")
for i in range(len(buf)):
g.write(str(ord(buf[i])) + ",\n")
g.write("};\n")
g.write("#endif")
def make_doc_header(target, source, env):
src = source[0].srcnode().abspath
dst = target[0].srcnode().abspath
f = open(src, "rb")
g = open(dst, "wb")
buf = f.read()
decomp_size = len(buf)
import zlib
buf = zlib.compress(buf)
g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
g.write("#ifndef _DOC_DATA_RAW_H\n")
g.write("#define _DOC_DATA_RAW_H\n")
g.write("static const int _doc_data_compressed_size=" + str(len(buf)) + ";\n")
g.write("static const int _doc_data_uncompressed_size=" + str(decomp_size) + ";\n")
g.write("static const unsigned char _doc_data_compressed[]={\n")
for i in range(len(buf)):
g.write(str(ord(buf[i])) + ",\n")
g.write("};\n")
g.write("#endif")
def make_fonts_header(target, source, env):
dst = target[0].srcnode().abspath
g = open(dst, "wb")
g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
g.write("#ifndef _EDITOR_FONTS_H\n")
g.write("#define _EDITOR_FONTS_H\n")
# saving uncompressed, since freetype will reference from memory pointer
xl_names = []
for i in range(len(source)):
print("Appending font: " + source[i].srcnode().abspath)
f = open(source[i].srcnode().abspath, "rb")
buf = f.read()
import os.path
name = os.path.splitext(os.path.basename(source[i].srcnode().abspath))[0]
g.write("static const int _font_" + name + "_size=" + str(len(buf)) + ";\n")
g.write("static const unsigned char _font_" + name + "[]={\n")
for i in range(len(buf)):
g.write(str(ord(buf[i])) + ",\n")
g.write("};\n")
g.write("#endif")
def make_translations_header(target, source, env):
dst = target[0].srcnode().abspath
g = open(dst, "wb")
g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
g.write("#ifndef _EDITOR_TRANSLATIONS_H\n")
g.write("#define _EDITOR_TRANSLATIONS_H\n")
import zlib
import os.path
paths = [node.srcnode().abspath for node in source]
sorted_paths = sorted(paths, key=lambda path: os.path.splitext(os.path.basename(path))[0])
xl_names = []
for i in range(len(sorted_paths)):
print("Appending translation: " + sorted_paths[i])
f = open(sorted_paths[i], "rb")
buf = f.read()
decomp_size = len(buf)
buf = zlib.compress(buf)
name = os.path.splitext(os.path.basename(sorted_paths[i]))[0]
#g.write("static const int _translation_"+name+"_compressed_size="+str(len(buf))+";\n")
#g.write("static const int _translation_"+name+"_uncompressed_size="+str(decomp_size)+";\n")
g.write("static const unsigned char _translation_" + name + "_compressed[]={\n")
for i in range(len(buf)):
g.write(str(ord(buf[i])) + ",\n")
g.write("};\n")
xl_names.append([name, len(buf), str(decomp_size)])
g.write("struct EditorTranslationList {\n")
g.write("\tconst char* lang;\n")
g.write("\tint comp_size;\n")
g.write("\tint uncomp_size;\n")
g.write("\tconst unsigned char* data;\n")
g.write("};\n\n")
g.write("static EditorTranslationList _editor_translations[]={\n")
for x in xl_names:
g.write("\t{ \"" + x[0] + "\", " + str(x[1]) + ", " + str(x[2]) + ",_translation_" + x[0] + "_compressed},\n")
g.write("\t{NULL,0,0,NULL}\n")
g.write("};\n")
g.write("#endif")
if (env["tools"] == "yes"):
# Register exporters
reg_exporters_inc = '#include "register_exporters.h"\n'
reg_exporters = 'void register_exporters() {\n'
for e in env.platform_exporters:
env.editor_sources.append("#platform/" + e + "/export/export.cpp")
reg_exporters += '\tregister_' + e + '_exporter();\n'
reg_exporters_inc += '#include "platform/' + e + '/export/export.h"\n'
reg_exporters += '}\n'
f = open("register_exporters.cpp", "wb")
f.write(reg_exporters_inc)
f.write(reg_exporters)
f.close()
# API documentation
env.Depends("#editor/doc_data_compressed.h", "#doc/base/classes.xml")
env.Command("#editor/doc_data_compressed.h", "#doc/base/classes.xml", make_doc_header)
# Certificates
env.Depends("#editor/certs_compressed.h", "#thirdparty/certs/ca-certificates.crt")
env.Command("#editor/certs_compressed.h", "#thirdparty/certs/ca-certificates.crt", make_certs_header)
import glob
path = env.Dir('.').abspath
# Translations
tlist = glob.glob(path + "/translations/*.po")
print("translations: ", tlist)
env.Depends('#editor/translations.h', tlist)
env.Command('#editor/translations.h', tlist, make_translations_header)
# Fonts
flist = glob.glob(path + "/../thirdparty/fonts/*.ttf")
flist.append(glob.glob(path + "/../thirdparty/fonts/*.otf"))
print("fonts: ", flist)
env.Depends('#editor/builtin_fonts.h', flist)
env.Command('#editor/builtin_fonts.h', flist, make_fonts_header)
env.add_source_files(env.editor_sources, "*.cpp")
SConscript('collada/SCsub')
SConscript('doc/SCsub')
SConscript('fileserver/SCsub')
SConscript('icons/SCsub')
SConscript('io_plugins/SCsub')
SConscript('plugins/SCsub')
lib = env.Library("editor", env.editor_sources)
env.Prepend(LIBS=[lib])
Export('env')

4249
editor/animation_editor.cpp Normal file

File diff suppressed because it is too large Load Diff

83
editor/call_dialog.h Normal file
View File

@ -0,0 +1,83 @@
/*************************************************************************/
/* call_dialog.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 CALL_DIALOG_H
#define CALL_DIALOG_H
#include "scene/gui/popup.h"
#include "scene/gui/button.h"
#include "scene/gui/tree.h"
#include "scene/gui/label.h"
#include "scene/gui/line_edit.h"
#include "editor/property_editor.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
class CallDialogParams;
class CallDialog : public Popup {
OBJ_TYPE( CallDialog, Popup );
Label* method_label;
Tree *tree;
Button *call;
Button *cancel;
CallDialogParams *call_params;
PropertyEditor *property_editor;
Label *return_label;
LineEdit *return_value;
Object *object;
StringName selected;
Vector<MethodInfo> methods;
void _item_selected();
void _update_method_list();
void _call();
void _cancel();
protected:
static void _bind_methods();
void _notification(int p_what);
public:
void set_object(Object *p_object,StringName p_selected="");
CallDialog();
~CallDialog();
};
#endif

1285
editor/code_editor.cpp Normal file

File diff suppressed because it is too large Load Diff

249
editor/code_editor.h Normal file
View File

@ -0,0 +1,249 @@
/*************************************************************************/
/* code_editor.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 CODE_EDITOR_H
#define CODE_EDITOR_H
#include "editor/editor_plugin.h"
#include "scene/gui/text_edit.h"
#include "scene/gui/dialogs.h"
#include "scene/main/timer.h"
#include "scene/gui/tool_button.h"
#include "scene/gui/check_button.h"
#include "scene/gui/check_box.h"
#include "scene/gui/line_edit.h"
class GotoLineDialog : public ConfirmationDialog {
OBJ_TYPE(GotoLineDialog,ConfirmationDialog);
Label *line_label;
LineEdit *line;
TextEdit *text_editor;
virtual void ok_pressed();
public:
void popup_find_line(TextEdit *p_edit);
int get_line() const;
void set_text_editor(TextEdit *p_text_editor);
GotoLineDialog();
};
class FindReplaceBar : public HBoxContainer {
OBJ_TYPE(FindReplaceBar,HBoxContainer);
LineEdit *search_text;
ToolButton *find_prev;
ToolButton *find_next;
CheckBox *case_sensitive;
CheckBox *whole_words;
Label *error_label;
TextureButton *hide_button;
LineEdit *replace_text;
ToolButton *replace;
ToolButton *replace_all;
CheckBox *selection_only;
VBoxContainer *text_vbc;
HBoxContainer *replace_hbc;
HBoxContainer *replace_options_hbc;
TextEdit *text_edit;
int result_line;
int result_col;
bool replace_all_mode;
bool preserve_cursor;
void _get_search_from(int& r_line, int& r_col);
void _show_search();
void _hide_bar();
void _editor_text_changed();
void _search_options_changed(bool p_pressed);
void _search_text_changed(const String& p_text);
void _search_text_entered(const String& p_text);
protected:
void _notification(int p_what);
void _unhandled_input(const InputEvent &p_event);
bool _search(uint32_t p_flags, int p_from_line, int p_from_col);
void _replace();
void _replace_all();
static void _bind_methods();
public:
String get_search_text() const;
String get_replace_text() const;
bool is_case_sensitive() const;
bool is_whole_words() const;
bool is_selection_only() const;
void set_error(const String& p_label);
void set_text_edit(TextEdit *p_text_edit);
void popup_search();
void popup_replace();
bool search_current();
bool search_prev();
bool search_next();
FindReplaceBar();
};
class FindReplaceDialog : public ConfirmationDialog {
OBJ_TYPE(FindReplaceDialog,ConfirmationDialog);
LineEdit *search_text;
LineEdit *replace_text;
CheckButton *whole_words;
CheckButton *case_sensitive;
CheckButton *backwards;
CheckButton *prompt;
CheckButton *selection_only;
Button *skip;
Label *error_label;
MarginContainer *replace_mc;
Label *replace_label;
VBoxContainer *replace_vb;
void _search_text_entered(const String& p_text);
void _replace_text_entered(const String& p_text);
void _prompt_changed();
void _skip_pressed();
TextEdit *text_edit;
protected:
void _search_callback();
void _replace_skip_callback();
bool _search();
void _replace();
virtual void ok_pressed();
static void _bind_methods();
public:
String get_search_text() const;
String get_replace_text() const;
bool is_whole_words() const;
bool is_case_sensitive() const;
bool is_backwards() const;
bool is_replace_mode() const;
bool is_replace_all_mode() const;
bool is_replace_selection_only() const;
void set_replace_selection_only(bool p_enable);
void set_error(const String& p_error);
void popup_search();
void popup_replace();
void set_text_edit(TextEdit *p_text_edit);
void search_next();
FindReplaceDialog();
};
class CodeTextEditor : public VBoxContainer {
OBJ_TYPE(CodeTextEditor,VBoxContainer);
TextEdit *text_editor;
FindReplaceBar *find_replace_bar;
Label *line_nb;
Label *col_nb;
Label *info;
Timer *idle;
Timer *code_complete_timer;
bool enable_complete_timer;
Timer *font_resize_timer;
int font_resize_val;
Label *error;
void _on_settings_change();
void _update_font();
void _complete_request();
void _font_resize_timeout();
void _text_editor_input_event(const InputEvent& p_event);
void _zoom_in();
void _zoom_out();
void _reset_zoom();
protected:
void set_error(const String& p_error);
virtual void _load_theme_settings() {}
virtual void _validate_script()=0;
virtual void _code_complete_script(const String& p_code, List<String>* r_options) {};
void _text_changed_idle_timeout();
void _code_complete_timer_timeout();
void _text_changed();
void _line_col_changed();
void _notification(int);
static void _bind_methods();
public:
void update_editor_settings();
TextEdit *get_text_edit() { return text_editor; }
FindReplaceBar *get_find_replace_bar() { return find_replace_bar; }
virtual void apply_code() {}
CodeTextEditor();
};
#endif // CODE_EDITOR_H

134
editor/connections_dialog.h Normal file
View File

@ -0,0 +1,134 @@
/*************************************************************************/
/* connections_dialog.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 CONNECTIONS_DIALOG_H
#define CONNECTIONS_DIALOG_H
#include "scene/gui/popup.h"
#include "scene/gui/button.h"
#include "scene/gui/check_button.h"
#include "scene/gui/tree.h"
#include "scene/gui/dialogs.h"
#include "scene/gui/menu_button.h"
#include "scene/gui/line_edit.h"
#include "editor/scene_tree_editor.h"
#include "editor/property_editor.h"
#include "undo_redo.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
class ConnectDialogBinds;
class ConnectDialog : public ConfirmationDialog {
OBJ_TYPE( ConnectDialog, ConfirmationDialog );
ConfirmationDialog *error;
LineEdit *dst_path;
LineEdit *dst_method;
SceneTreeEditor *tree;
//MenuButton *dst_method_list;
OptionButton *type_list;
CheckButton *deferred;
CheckButton *oneshot;
CheckButton *make_callback;
PropertyEditor *bind_editor;
Node *node;
ConnectDialogBinds *cdbinds;
void ok_pressed();
void _cancel_pressed();
void _tree_node_selected();
void _dst_method_list_selected(int p_idx);
void _add_bind();
void _remove_bind();
protected:
void _notification(int p_what);
static void _bind_methods();
public:
bool get_make_callback() { return !make_callback->is_hidden() && make_callback->is_pressed(); }
NodePath get_dst_path() const;
StringName get_dst_method() const;
bool get_deferred() const;
bool get_oneshot() const;
Vector<Variant> get_binds() const;
void set_dst_method(const StringName& p_method);
void set_dst_node(Node* p_node);
// Button *get_ok() { return ok; }
// Button *get_cancel() { return cancel; }
void edit(Node *p_node);
ConnectDialog();
~ConnectDialog();
};
class ConnectionsDock : public VBoxContainer {
OBJ_TYPE( ConnectionsDock , VBoxContainer );
Button *connect_button;
EditorNode *editor;
Node *node;
Tree *tree;
ConfirmationDialog *remove_confirm;
ConnectDialog *connect_dialog;
void update_tree();
void _close();
void _connect();
void _something_selected();
void _something_activated();
UndoRedo *undo_redo;
protected:
void _connect_pressed();
void _notification(int p_what);
static void _bind_methods();
public:
void set_undoredo(UndoRedo *p_undo_redo) { undo_redo=p_undo_redo; }
void set_node(Node* p_node);
String get_selected_type();
ConnectionsDock(EditorNode *p_editor=NULL);
~ConnectionsDock();
};
#endif

270
editor/editor_data.h Normal file
View File

@ -0,0 +1,270 @@
/*************************************************************************/
/* editor_data.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* 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 "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 {
REF ref;
ObjectID object;
String property;
};
struct History {
Vector<Obj> path;
int level;
};
friend class EditorData;
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:
bool is_at_begining() const;
bool is_at_end() const;
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);
int get_history_len();
int get_history_pos();
ObjectID get_history_obj(int p_obj) const;
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();
};
class EditorSelection;
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();
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;
NodePath live_edit_root;
};
Vector<EditedScene> edited_scene;
int current_edited_scene;
bool _find_updated_instances(Node* p_root,Node *p_node,Set<String> &checked_paths);
public:
EditorPlugin* get_editor(Object *p_object);
EditorPlugin* get_subeditor(Object *p_object);
Vector<EditorPlugin*> get_subeditors(Object *p_object);
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;
Dictionary get_scene_editor_states(int p_idx) const;
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);
int get_editor_plugin_count() const;
EditorPlugin *get_editor_plugin(int p_idx);
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; }
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);
Ref<ResourceImportMetadata> get_edited_scene_import_metadata(int p_idx = -1) const;
int get_edited_scene() const;
Node* get_edited_scene_root(int p_idx = -1);
int get_edited_scene_count() const;
String get_scene_title(int p_idx) const;
String get_scene_path(int p_idx) const;
String get_scene_type(int p_idx) const;
Ref<Script> get_scene_root_script(int p_idx) const;
void set_edited_scene_version(uint64_t version, int p_scene_idx = -1);
uint64_t get_edited_scene_version() const;
uint64_t get_scene_version(int p_idx) const;
void clear_edited_scenes();
void set_edited_scene_live_edit_root(const NodePath& p_root);
NodePath get_edited_scene_live_edit_root();
bool check_and_update_scene(int p_idx);
void move_edited_scene_to_index(int p_idx);
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);
void notify_edited_scene_changed();
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();
Array _get_selected_nodes();
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

View File

@ -0,0 +1,275 @@
/*************************************************************************/
/* editor_dir_dialog.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* 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. */
/*************************************************************************/
#include "editor_dir_dialog.h"
#include "os/os.h"
#include "os/keyboard.h"
#include "editor/editor_settings.h"
#include "editor/editor_file_system.h"
void EditorDirDialog::_update_dir(TreeItem* p_item) {
updating=true;
p_item->clear_children();
DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
String cdir = p_item->get_metadata(0);
da->change_dir(cdir);
da->list_dir_begin();
String p=da->get_next();
List<String> dirs;
bool ishidden;
bool show_hidden = EditorSettings::get_singleton()->get("file_dialog/show_hidden_files");
while(p!="") {
ishidden = da->current_is_hidden();
if (show_hidden || !ishidden) {
if (da->current_is_dir() && !p.begins_with(".")) {
dirs.push_back(p);
}
}
p=da->get_next();
}
dirs.sort();
for(List<String>::Element *E=dirs.front();E;E=E->next()) {
TreeItem *ti = tree->create_item(p_item);
ti->set_text(0,E->get());
ti->set_icon(0,get_icon("Folder","EditorIcons"));
ti->set_collapsed(true);
}
memdelete(da);
updating=false;
}
void EditorDirDialog::reload() {
if (!is_visible()) {
must_reload=true;
return;
}
tree->clear();
TreeItem *root = tree->create_item();
root->set_metadata(0,"res://");
root->set_icon(0,get_icon("Folder","EditorIcons"));
root->set_text(0,"/");
_update_dir(root);
_item_collapsed(root);
must_reload=false;
}
void EditorDirDialog::_notification(int p_what) {
if (p_what==NOTIFICATION_ENTER_TREE) {
reload();
if (!tree->is_connected("item_collapsed",this,"_item_collapsed")) {
tree->connect("item_collapsed",this,"_item_collapsed",varray(),CONNECT_DEFERRED);
}
if (!EditorFileSystem::get_singleton()->is_connected("filesystem_changed",this,"reload")) {
EditorFileSystem::get_singleton()->connect("filesystem_changed",this,"reload");
}
}
if (p_what==NOTIFICATION_VISIBILITY_CHANGED) {
if (must_reload && is_visible()) {
reload();
}
}
}
void EditorDirDialog::_item_collapsed(Object* _p_item){
TreeItem *p_item=_p_item->cast_to<TreeItem>();
if (updating || p_item->is_collapsed())
return;
TreeItem *ci = p_item->get_children();
while(ci) {
String p =ci->get_metadata(0);
if (p=="") {
String pp = p_item->get_metadata(0);
ci->set_metadata(0,pp.plus_file(ci->get_text(0)));
_update_dir(ci);
}
ci=ci->get_next();
}
}
void EditorDirDialog::set_current_path(const String& p_path) {
reload();
String p = p_path;
if (p.begins_with("res://"))
p = p.replace_first("res://","");
Vector<String> dirs = p.split("/",false);
TreeItem *r=tree->get_root();
for(int i=0;i<dirs.size();i++) {
String d = dirs[i];
TreeItem *p = r->get_children();
while(p) {
if (p->get_text(0)==d)
break;
p=p->get_next();
}
ERR_FAIL_COND(!p);
String pp = p->get_metadata(0);
if (pp=="") {
p->set_metadata(0,String(r->get_metadata(0)).plus_file(d));
_update_dir(p);
}
updating=true;
p->set_collapsed(false);
updating=false;
_item_collapsed(p);
r=p;
}
r->select(0);
}
void EditorDirDialog::ok_pressed() {
TreeItem *ti=tree->get_selected();
if (!ti)
return;
String dir = ti->get_metadata(0);
emit_signal("dir_selected",dir);
hide();
}
void EditorDirDialog::_make_dir() {
TreeItem *ti=tree->get_selected();
if (!ti) {
mkdirerr->set_text("Please select a base directory first");
mkdirerr->popup_centered_minsize();
return;
}
makedialog->popup_centered_minsize(Size2(250,80));
makedirname->grab_focus();
}
void EditorDirDialog::_make_dir_confirm() {
TreeItem *ti=tree->get_selected();
if (!ti)
return;
String dir = ti->get_metadata(0);
DirAccess *d = DirAccess::open(dir);
ERR_FAIL_COND(!d);
Error err = d->make_dir(makedirname->get_text());
if (err!=OK) {
mkdirerr->popup_centered_minsize(Size2(250,80));
} else {
set_current_path(dir.plus_file(makedirname->get_text()));
}
makedirname->set_text(""); // reset label
}
void EditorDirDialog::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_item_collapsed"),&EditorDirDialog::_item_collapsed);
ObjectTypeDB::bind_method(_MD("_make_dir"),&EditorDirDialog::_make_dir);
ObjectTypeDB::bind_method(_MD("_make_dir_confirm"),&EditorDirDialog::_make_dir_confirm);
ObjectTypeDB::bind_method(_MD("reload"),&EditorDirDialog::reload);
ADD_SIGNAL(MethodInfo("dir_selected",PropertyInfo(Variant::STRING,"dir")));
}
EditorDirDialog::EditorDirDialog() {
updating=false;
set_title(TTR("Choose a Directory"));
set_hide_on_ok(false);
tree = memnew( Tree );
add_child(tree);
set_child_rect(tree);
tree->connect("item_activated",this,"_ok");
makedir = add_button(TTR("Create Folder"),OS::get_singleton()->get_swap_ok_cancel()?true:false,"makedir");
makedir->connect("pressed",this,"_make_dir");
makedialog = memnew( ConfirmationDialog );
makedialog->set_title(TTR("Create Folder"));
add_child(makedialog);
VBoxContainer *makevb= memnew( VBoxContainer );
makedialog->add_child(makevb);
makedialog->set_child_rect(makevb);
makedirname = memnew( LineEdit );
makevb->add_margin_child(TTR("Name:"),makedirname);
makedialog->register_text_enter(makedirname);
makedialog->connect("confirmed",this,"_make_dir_confirm");
mkdirerr = memnew( AcceptDialog );
mkdirerr->set_text(TTR("Could not create folder."));
add_child(mkdirerr);
get_ok()->set_text(TTR("Choose"));
must_reload=false;
}

View File

@ -0,0 +1,69 @@
#ifndef EDITOR_EXPORT_GODOT3_H
#define EDITOR_EXPORT_GODOT3_H
#include "scene/main/node.h"
#include "editor/editor_file_system.h"
#include "io/export_data.h"
class EditorExportGodot3 {
Map<String,int> pack_names;
HashMap<Variant,int,VariantHasher> pack_values;
int _pack_name(const String& p_name) {
if (pack_names.has(p_name)) {
return pack_names[p_name];
}
int idx = pack_names.size();
pack_names[p_name]=idx;
return idx;
}
int _pack_value(const Variant& p_value) {
if (pack_values.has(p_value)) {
return pack_values[p_value];
}
int idx = pack_values.size();
pack_values[p_value]=idx;
return idx;
}
Map<String,String> prop_rename_map;
Map<String,String> type_rename_map;
Map<String,String> signal_rename_map;
Map<String,String> resource_replace_map;
String _replace_resource(const String& p_res) {
if (resource_replace_map.has(p_res))
return resource_replace_map[p_res];
else
return p_res;
}
Error _get_property_as_text(const Variant& p_variant,String&p_string);
void _save_text(const String& p_path,ExportData &resource);
void _save_binary_property(const Variant& p_property,FileAccess *f);
void _save_binary(const String& p_path,ExportData &resource);
void _save_config(const String &p_path);
void _rename_properties(const String& p_type,List<ExportData::PropertyData> *p_props);
void _convert_resources(ExportData &resource);
void _unpack_packed_scene(ExportData &resource);
void _pack_packed_scene(ExportData &resource);
void _find_files(EditorFileSystemDirectory *p_dir, List<String> * r_files);
public:
Error export_godot3(const String& p_path);
EditorExportGodot3();
};
#endif // EDITOR_EXPORT_GODOT3_H

1785
editor/editor_help.cpp Normal file

File diff suppressed because it is too large Load Diff

222
editor/editor_help.h Normal file
View File

@ -0,0 +1,222 @@
/*************************************************************************/
/* editor_help.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* 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_HELP_H
#define EDITOR_HELP_H
#include "editor/editor_plugin.h"
#include "scene/gui/tab_container.h"
#include "scene/gui/text_edit.h"
#include "scene/gui/split_container.h"
#include "scene/gui/menu_button.h"
#include "scene/gui/rich_text_label.h"
#include "scene/gui/panel_container.h"
#include "scene/gui/tree.h"
#include "scene/main/timer.h"
#include "editor/code_editor.h"
#include "editor/doc/doc_data.h"
class EditorNode;
class EditorHelpSearch : public ConfirmationDialog {
OBJ_TYPE(EditorHelpSearch,ConfirmationDialog )
EditorNode *editor;
LineEdit *search_box;
Tree *search_options;
String base_type;
void _update_search();
void _sbox_input(const InputEvent& p_ie);
void _confirmed();
void _text_changed(const String& p_newtext);
protected:
void _notification(int p_what);
static void _bind_methods();
public:
void popup();
void popup(const String& p_term);
EditorHelpSearch();
};
class EditorHelpIndex : public ConfirmationDialog {
OBJ_TYPE( EditorHelpIndex, ConfirmationDialog );
LineEdit *search_box;
Tree *class_list;
HashMap<String,TreeItem*> tree_item_map;
void _tree_item_selected();
void _text_changed(const String& p_text);
void _sbox_input(const InputEvent& p_ie);
void _update_class_list();
void add_type(const String& p_type,HashMap<String,TreeItem*>& p_types,TreeItem *p_root);
protected:
void _notification(int p_what);
static void _bind_methods();
public:
void select_class(const String& p_class);
void popup();
EditorHelpIndex();
};
class EditorHelp : public VBoxContainer {
OBJ_TYPE( EditorHelp, VBoxContainer );
enum Page {
PAGE_CLASS_LIST,
PAGE_CLASS_DESC,
PAGE_CLASS_PREV,
PAGE_CLASS_NEXT,
PAGE_SEARCH,
CLASS_SEARCH,
};
bool select_locked;
String prev_search;
String edited_class;
EditorNode *editor;
Map<String,int> method_line;
Map<String,int> signal_line;
Map<String,int> property_line;
Map<String,int> theme_property_line;
Map<String,int> constant_line;
int description_line;
RichTextLabel *class_desc;
HSplitContainer *h_split;
static DocData *doc;
ConfirmationDialog *search_dialog;
LineEdit *search;
String base_path;
void _help_callback(const String& p_topic);
void _add_text(const String& p_text);
bool scroll_locked;
//void _button_pressed(int p_idx);
void _add_type(const String& p_type);
void _scroll_changed(double p_scroll);
void _class_list_select(const String& p_select);
void _class_desc_select(const String& p_select);
void _class_desc_input(const InputEvent& p_input);
Error _goto_desc(const String& p_class, int p_vscr=-1);
//void _update_history_buttons();
void _update_doc();
void _request_help(const String& p_string);
void _search(const String& p_str);
void _search_cbk();
void _unhandled_key_input(const InputEvent& p_ev);
protected:
void _notification(int p_what);
static void _bind_methods();
public:
static void generate_doc();
static DocData *get_doc_data() { return doc; }
void go_to_help(const String& p_help);
void go_to_class(const String& p_class,int p_scroll=0);
void popup_search();
void search_again();
String get_class_name();
void set_focused() { class_desc->grab_focus(); }
int get_scroll() const;
void set_scroll(int p_scroll);
EditorHelp();
~EditorHelp();
};
class EditorHelpBit : public Panel {
OBJ_TYPE( EditorHelpBit, Panel);
RichTextLabel *rich_text;
void _go_to_help(String p_what);
void _meta_clicked(String p_what);
protected:
static void _bind_methods();
void _notification(int p_what);
public:
void set_text(const String& p_text);
EditorHelpBit();
};
#endif // EDITOR_HELP_H

File diff suppressed because it is too large Load Diff

6758
editor/editor_node.cpp Normal file

File diff suppressed because it is too large Load Diff

797
editor/editor_node.h Normal file
View File

@ -0,0 +1,797 @@
/*************************************************************************/
/* editor_node.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* 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_NODE_H
#define EDITOR_NODE_H
#include "scene/gui/control.h"
#include "scene/gui/panel.h"
#include "scene/gui/tool_button.h"
#include "scene/gui/menu_button.h"
#include "scene/gui/tree.h"
#include "scene/gui/dialogs.h"
#include "scene/gui/separator.h"
#include "scene/gui/tab_container.h"
#include "scene/gui/panel_container.h"
#include "scene/gui/file_dialog.h"
#include "scene/gui/split_container.h"
#include "scene/gui/center_container.h"
#include "scene/gui/texture_progress.h"
#include "editor/filesystem_dock.h"
#include "editor/scene_tree_editor.h"
#include "editor/property_editor.h"
#include "editor/create_dialog.h"
#include "editor/call_dialog.h"
#include "editor/reparent_dialog.h"
#include "editor/connections_dialog.h"
#include "editor/node_dock.h"
#include "editor/settings_config_dialog.h"
#include "editor/groups_editor.h"
#include "editor/editor_data.h"
#include "editor/editor_path.h"
#include "editor/editor_run.h"
#include "editor/pane_drag.h"
#include "editor/script_create_dialog.h"
#include "editor/run_settings_dialog.h"
#include "editor/project_settings.h"
#include "editor/project_export.h"
#include "editor/editor_log.h"
#include "editor/scene_tree_dock.h"
#include "editor/resources_dock.h"
#include "editor/editor_run_script.h"
#include "editor/editor_run_native.h"
#include "scene/gui/tabs.h"
#include "editor/quick_open.h"
#include "editor/project_export.h"
#include "editor/editor_sub_scene.h"
#include "editor_import_export.h"
#include "editor_reimport_dialog.h"
#include "editor/editor_plugin.h"
#include "editor/editor_name_dialog.h"
#include "fileserver/editor_file_server.h"
#include "editor_resource_preview.h"
#include "editor_export_godot3.h"
#include "progress_dialog.h"
#include "editor_scale.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
typedef void (*EditorNodeInitCallback)();
class EditorPluginList;
class EditorNode : public Node {
OBJ_TYPE( EditorNode, Node );
public:
enum DockSlot {
DOCK_SLOT_LEFT_UL,
DOCK_SLOT_LEFT_BL,
DOCK_SLOT_LEFT_UR,
DOCK_SLOT_LEFT_BR,
DOCK_SLOT_RIGHT_UL,
DOCK_SLOT_RIGHT_BL,
DOCK_SLOT_RIGHT_UR,
DOCK_SLOT_RIGHT_BR,
DOCK_SLOT_MAX
};
private:
enum {
HISTORY_SIZE=64
};
enum MenuOptions {
FILE_NEW_SCENE,
FILE_NEW_INHERITED_SCENE,
FILE_OPEN_SCENE,
FILE_SAVE_SCENE,
FILE_SAVE_AS_SCENE,
FILE_SAVE_ALL_SCENES,
FILE_SAVE_BEFORE_RUN,
FILE_SAVE_AND_RUN,
FILE_IMPORT_SUBSCENE,
FILE_EXPORT_PROJECT,
FILE_EXPORT_MESH_LIBRARY,
FILE_EXPORT_TILESET,
FILE_SAVE_OPTIMIZED,
FILE_DUMP_STRINGS,
FILE_OPEN_RECENT,
FILE_OPEN_OLD_SCENE,
FILE_QUICK_OPEN_SCENE,
FILE_QUICK_OPEN_SCRIPT,
FILE_RUN_SCRIPT,
FILE_OPEN_PREV,
FILE_CLOSE,
FILE_QUIT,
FILE_EXTERNAL_OPEN_SCENE,
EDIT_UNDO,
EDIT_REDO,
EDIT_REVERT,
TOOLS_ORPHAN_RESOURCES,
TOOLS_EXPORT_GODOT3,
RESOURCE_NEW,
RESOURCE_LOAD,
RESOURCE_SAVE,
RESOURCE_SAVE_AS,
RESOURCE_UNREF,
RESOURCE_COPY,
RESOURCE_PASTE,
OBJECT_COPY_PARAMS,
OBJECT_PASTE_PARAMS,
OBJECT_UNIQUE_RESOURCES,
OBJECT_CALL_METHOD,
OBJECT_REQUEST_HELP,
RUN_PLAY,
RUN_STOP,
RUN_PLAY_SCENE,
RUN_PLAY_NATIVE,
RUN_PLAY_CUSTOM_SCENE,
RUN_SCENE_SETTINGS,
RUN_SETTINGS,
RUN_PROJECT_MANAGER,
RUN_FILE_SERVER,
//RUN_DEPLOY_DUMB_CLIENTS,
RUN_LIVE_DEBUG,
RUN_DEBUG_COLLISONS,
RUN_DEBUG_NAVIGATION,
RUN_DEPLOY_REMOTE_DEBUG,
RUN_RELOAD_SCRIPTS,
SETTINGS_UPDATE_ALWAYS,
SETTINGS_UPDATE_CHANGES,
SETTINGS_UPDATE_SPINNER_HIDE,
SETTINGS_EXPORT_PREFERENCES,
SETTINGS_PREFERENCES,
SETTINGS_OPTIMIZED_PRESETS,
SETTINGS_LAYOUT_SAVE,
SETTINGS_LAYOUT_DELETE,
SETTINGS_LAYOUT_DEFAULT,
SETTINGS_LOAD_EXPORT_TEMPLATES,
SETTINGS_PICK_MAIN_SCENE,
SETTINGS_HELP,
SETTINGS_ABOUT,
SOURCES_REIMPORT,
DEPENDENCY_LOAD_CHANGED_IMAGES,
DEPENDENCY_UPDATE_IMPORTED,
SCENE_TAB_CLOSE,
IMPORT_PLUGIN_BASE=100,
OBJECT_METHOD_BASE=500
};
//Node *edited_scene; //scene being edited
Viewport *scene_root; //root of the scene being edited
//Ref<ResourceImportMetadata> scene_import_metadata;
Control* scene_root_parent;
Control *gui_base;
VBoxContainer *main_vbox;
//split
HSplitContainer *left_l_hsplit;
VSplitContainer *left_l_vsplit;
HSplitContainer *left_r_hsplit;
VSplitContainer *left_r_vsplit;
HSplitContainer *main_hsplit;
HSplitContainer *right_hsplit;
VSplitContainer *right_l_vsplit;
VSplitContainer *right_r_vsplit;
VSplitContainer *center_split;
//main tabs
Tabs *scene_tabs;
int tab_closing;
bool exiting;
int old_split_ofs;
VSplitContainer *top_split;
HBoxContainer *bottom_hb;
Control *vp_base;
PaneDrag *pd;
//PaneDrag *pd_anim;
Panel *menu_panel;
//HSplitContainer *editor_hsplit;
//VSplitContainer *editor_vsplit;
CenterContainer *play_cc;
HBoxContainer *menu_hb;
Control *viewport;
MenuButton *file_menu;
MenuButton *import_menu;
MenuButton *tool_menu;
ToolButton *export_button;
ToolButton *prev_scene;
MenuButton *object_menu;
MenuButton *settings_menu;
ToolButton *play_button;
MenuButton *native_play_button;
ToolButton *pause_button;
ToolButton *stop_button;
ToolButton *run_settings_button;
ToolButton *play_scene_button;
ToolButton *play_custom_scene_button;
MenuButton *debug_button;
ToolButton *search_button;
TextureProgress *audio_vu;
//MenuButton *fileserver_menu;
RichTextLabel *load_errors;
AcceptDialog *load_error_dialog;
//Control *scene_root_base;
Ref<Theme> theme;
PopupMenu *recent_scenes;
Button *property_back;
Button *property_forward;
SceneTreeDock *scene_tree_dock;
//ResourcesDock *resources_dock;
PropertyEditor *property_editor;
NodeDock *node_dock;
VBoxContainer *prop_editor_vb;
FileSystemDock *filesystem_dock;
EditorRunNative *run_native;
HBoxContainer *search_bar;
LineEdit *search_box;
EditorExportGodot3 export_godot3;
FileDialog *export_godot3_dialog;
CreateDialog *create_dialog;
CallDialog *call_dialog;
ConfirmationDialog *confirmation;
ConfirmationDialog *import_confirmation;
ConfirmationDialog *open_recent_confirmation;
ConfirmationDialog *pick_main_scene;
AcceptDialog *accept;
AcceptDialog *about;
AcceptDialog *warning;
int overridden_default_layout;
Ref<ConfigFile> default_layout;
PopupMenu *editor_layouts;
EditorNameDialog *layout_dialog;
//OptimizedPresetsDialog *optimized_presets;
EditorSettingsDialog *settings_config_dialog;
RunSettingsDialog *run_settings_dialog;
ProjectSettings *project_settings;
EditorFileDialog *file;
FileDialog *file_templates;
FileDialog *file_export;
FileDialog *file_export_lib;
FileDialog *file_script;
CheckButton *file_export_lib_merge;
LineEdit *file_export_password;
String current_path;
MenuButton *update_menu;
ToolButton *sources_button;
//TabContainer *prop_pallete;
//TabContainer *top_pallete;
String defer_load_scene;
String defer_translatable;
String defer_optimize;
String defer_optimize_preset;
String defer_export;
String defer_export_platform;
bool defer_export_debug;
Node *_last_instanced_scene;
EditorPath *editor_path;
ToolButton *resource_new_button;
ToolButton *resource_load_button;
MenuButton *resource_save_button;
MenuButton *editor_history_menu;
EditorLog *log;
CenterContainer *tabs_center;
EditorQuickOpen *quick_open;
EditorQuickOpen *quick_run;
HBoxContainer *main_editor_button_vb;
Vector<ToolButton*> main_editor_buttons;
Vector<EditorPlugin*> editor_table;
EditorReImportDialog *reimport_dialog;
ProgressDialog *progress_dialog;
BackgroundProgress *progress_hb;
DependencyErrorDialog *dependency_error;
DependencyEditor *dependency_fixer;
OrphanResourcesDialog *orphan_resources;
TabContainer *dock_slot[DOCK_SLOT_MAX];
Rect2 dock_select_rect[DOCK_SLOT_MAX];
int dock_select_rect_over;
PopupPanel *dock_select_popoup;
Control *dock_select;
ToolButton *dock_tab_move_left;
ToolButton *dock_tab_move_right;
int dock_popup_selected;
Timer *dock_drag_timer;
bool docks_visible;
bool distraction_free_mode;
String _tmp_import_path;
EditorImportExport *editor_import_export;
Object *current;
bool _playing_edited;
String run_custom_filename;
bool reference_resource_mem;
bool save_external_resources_mem;
uint64_t saved_version;
uint64_t last_checked_version;
bool unsaved_cache;
String open_navigate;
bool changing_scene;
bool waiting_for_sources_changed;
uint32_t circle_step_msec;
uint64_t circle_step_frame;
int circle_step;
Vector<EditorPlugin*> editor_plugins;
EditorPlugin *editor_plugin_screen;
EditorPluginList *editor_plugins_over;
EditorHistory editor_history;
EditorData editor_data;
EditorRun editor_run;
EditorSelection *editor_selection;
ProjectExport *project_export;
ProjectExportDialog *project_export_settings;
EditorResourcePreview *resource_preview;
EditorFileServer *file_server;
struct BottomPanelItem {
String name;
Control *control;
ToolButton *button;
};
Vector<BottomPanelItem> bottom_panel_items;
PanelContainer *bottom_panel;
HBoxContainer *bottom_panel_hb;
VBoxContainer *bottom_panel_vb;
void _bottom_panel_switch(bool p_enable, int p_idx);
String external_file;
List<String> previous_scenes;
bool opening_prev;
void _dialog_action(String p_file);
void _edit_current();
void _dialog_display_file_error(String p_file,Error p_error);
int current_option;
//void _animation_visibility_toggle();
void _resource_created();
void _resource_selected(const RES& p_res,const String& p_property="");
void _menu_option(int p_option);
void _menu_confirm_current();
void _menu_option_confirm(int p_option,bool p_confirmed);
void _property_editor_forward();
void _property_editor_back();
void _select_history(int p_idx);
void _prepare_history();
void _fs_changed();
void _sources_changed(bool p_exist);
void _imported(Node *p_node);
void _node_renamed();
void _editor_select(int p_which);
void _set_scene_metadata(const String &p_file, int p_idx=-1);
void _get_scene_metadata(const String& p_file);
void _update_title();
void _update_scene_tabs();
void _close_messages();
void _show_messages();
void _vp_resized();
void _rebuild_import_menu();
void _save_scene(String p_file, int idx = -1);
void _instance_request(const Vector<String>& p_files);
void _property_keyed(const String& p_keyed, const Variant& p_value, bool p_advance);
void _transform_keyed(Object *sp,const String& p_sub,const Transform& p_key);
void _hide_top_editors();
void _display_top_editors(bool p_display);
void _set_top_editors(Vector<EditorPlugin*> p_editor_plugins_over);
void _set_editing_top_editors(Object * p_current_object);
void _quick_opened();
void _quick_run();
void _run(bool p_current=false, const String &p_custom="");
void _save_optimized();
void _import_action(const String& p_action);
void _import(const String &p_file);
void _add_to_recent_scenes(const String& p_scene);
void _update_recent_scenes();
void _open_recent_scene(int p_idx);
void _dropped_files(const Vector<String>& p_files,int p_screen);
//void _open_recent_scene_confirm();
String _recent_scene;
bool convert_old;
void _unhandled_input(const InputEvent& p_event);
static void _load_error_notify(void* p_ud,const String& p_text);
bool has_main_screen() const { return true; }
void _fetch_translatable_strings(const Object *p_object,Set<StringName>& strings);
bool _find_editing_changed_scene(Node *p_from);
String import_reload_fn;
Set<FileDialog*> file_dialogs;
Set<EditorFileDialog*> editor_file_dialogs;
Map<String,Ref<Texture> > icon_type_cache;
bool _initializing_addons;
Map<String,EditorPlugin*> plugin_addons;
static Ref<Texture> _file_dialog_get_icon(const String& p_path);
static void _file_dialog_register(FileDialog *p_dialog);
static void _file_dialog_unregister(FileDialog *p_dialog);
static void _editor_file_dialog_register(EditorFileDialog *p_dialog);
static void _editor_file_dialog_unregister(EditorFileDialog *p_dialog);
void _cleanup_scene();
void _remove_edited_scene();
void _remove_scene(int index);
bool _find_and_save_resource(RES p_res,Map<RES,bool>& processed,int32_t flags);
bool _find_and_save_edited_subresources(Object *obj,Map<RES,bool>& processed,int32_t flags);
void _save_edited_subresources(Node* scene,Map<RES,bool>& processed,int32_t flags);
void _find_node_types(Node* p_node, int&count_2d, int&count_3d);
void _save_scene_with_preview(String p_file);
Map<String,Set<String> > dependency_errors;
static void _dependency_error_report(void *ud,const String& p_path,const String& p_dep,const String& p_type) {
EditorNode*en=(EditorNode*)ud;
if (!en->dependency_errors.has(p_path))
en->dependency_errors[p_path]=Set<String>();
en->dependency_errors[p_path].insert(p_dep+"::"+p_type);
}
struct ExportDefer {
String platform;
String path;
bool debug;
String password;
} export_defer;
static EditorNode *singleton;
static Vector<EditorNodeInitCallback> _init_callbacks;
bool _find_scene_in_use(Node* p_node,const String& p_path) const;
void _dock_select_input(const InputEvent& p_input);
void _dock_move_left();
void _dock_move_right();
void _dock_select_draw();
void _dock_pre_popup(int p_which);
void _dock_split_dragged(int ofs);
void _dock_popup_exit();
void _scene_tab_changed(int p_tab);
void _scene_tab_closed(int p_tab);
void _scene_tab_script_edited(int p_tab);
Dictionary _get_main_scene_state();
void _set_main_scene_state(Dictionary p_state,Node* p_for_scene);
int _get_current_main_editor();
void _save_docks();
void _load_docks();
void _save_docks_to_config(Ref<ConfigFile> p_layout, const String& p_section);
void _load_docks_from_config(Ref<ConfigFile> p_layout, const String& p_section);
void _update_dock_slots_visibility();
void _update_top_menu_visibility();
void _update_layouts_menu();
void _layout_menu_option(int p_idx);
void _toggle_search_bar(bool p_pressed);
void _clear_search_box();
void _clear_undo_history();
void _update_addon_config();
void _export_godot3_path(const String& p_path);
static void _file_access_close_error_notify(const String& p_str);
protected:
void _notification(int p_what);
static void _bind_methods();
public:
enum EditorTable {
EDITOR_2D = 0,
EDITOR_3D,
EDITOR_SCRIPT
};
void set_visible_editor(EditorTable p_table) { _editor_select(p_table); }
static EditorNode* get_singleton() { return singleton; }
EditorPlugin *get_editor_plugin_screen() { return editor_plugin_screen; }
EditorPluginList *get_editor_plugins_over() { return editor_plugins_over; }
PropertyEditor *get_property_editor() { return property_editor; }
VBoxContainer *get_property_editor_vb() { return prop_editor_vb; }
static void add_editor_plugin(EditorPlugin *p_editor);
static void remove_editor_plugin(EditorPlugin *p_editor);
void new_inherited_scene() { _menu_option_confirm(FILE_NEW_INHERITED_SCENE,false); }
void set_docks_visible(bool p_show);
bool get_docks_visible() const;
void set_distraction_free_mode(bool p_enter);
bool get_distraction_free_mode() const;
void add_control_to_dock(DockSlot p_slot,Control* p_control);
void remove_control_from_dock(Control* p_control);
void add_editor_import_plugin(const Ref<EditorImportPlugin>& p_editor_import);
void remove_editor_import_plugin(const Ref<EditorImportPlugin>& p_editor_import);
void set_addon_plugin_enabled(const String& p_addon,bool p_enabled);
bool is_addon_plugin_enabled(const String &p_addon) const;
void edit_node(Node *p_node);
void edit_resource(const Ref<Resource>& p_resource);
void open_resource(const String& p_type="");
void save_resource_in_path(const Ref<Resource>& p_resource,const String& p_path);
void save_resource(const Ref<Resource>& p_resource);
void save_resource_as(const Ref<Resource>& p_resource, const String &p_at_path=String());
void merge_from_scene() { _menu_option_confirm(FILE_IMPORT_SUBSCENE,false); }
static bool has_unsaved_changes() { return singleton->unsaved_cache; }
static HBoxContainer *get_menu_hb() { return singleton->menu_hb; }
void push_item(Object *p_object,const String& p_property="");
void open_request(const String& p_path);
bool is_changing_scene() const;
static EditorLog *get_log() { return singleton->log; }
Control* get_viewport();
//void animation_editor_make_visible(bool p_visible);
//void hide_animation_player_editors();
//void animation_panel_make_visible(bool p_visible);
void set_edited_scene(Node *p_scene);
Node *get_edited_scene() { return editor_data.get_edited_scene_root(); }
Viewport *get_scene_root() { return scene_root; } //root of the scene being edited
Error save_optimized_copy(const String& p_scene,const String& p_preset);
void fix_dependencies(const String& p_for_file);
void clear_scene() { _cleanup_scene(); }
Error load_scene(const String& p_scene, bool p_ignore_broken_deps=false, bool p_set_inherited=false, bool p_clear_errors=true);
Error load_resource(const String& p_scene);
bool is_scene_open(const String& p_path);
void set_current_version(uint64_t p_version);
void set_current_scene(int p_idx);
static EditorData& get_editor_data() { return singleton->editor_data; }
EditorHistory * get_editor_history() { return &editor_history; }
static VSplitContainer *get_top_split() { return singleton->top_split; }
void request_instance_scene(const String &p_path);
void request_instance_scenes(const Vector<String>& p_files);
FileSystemDock *get_filesystem_dock();
SceneTreeDock *get_scene_tree_dock();
static UndoRedo* get_undo_redo() { return &singleton->editor_data.get_undo_redo(); }
EditorSelection *get_editor_selection() { return editor_selection; }
Error save_translatable_strings(const String& p_to_file);
void set_convert_old_scene(bool p_old) { convert_old=p_old; }
void notify_child_process_exited();
OS::ProcessID get_child_process_id() const { return editor_run.get_pid(); }
void stop_child_process();
Ref<Theme> get_editor_theme() const { return theme; }
void show_warning(const String& p_text,const String& p_title="Warning!");
Error export_platform(const String& p_platform, const String& p_path, bool p_debug,const String& p_password,bool p_quit_after=false);
static void register_editor_types();
static void unregister_editor_types();
Control *get_gui_base() { return gui_base; }
Control *get_theme_base() { return gui_base->get_parent_control(); }
static void add_io_error(const String& p_error);
static void progress_add_task(const String& p_task,const String& p_label, int p_steps);
static void progress_task_step(const String& p_task,const String& p_state, int p_step=-1,bool p_force_refresh=true);
static void progress_end_task(const String& p_task);
static void progress_add_task_bg(const String& p_task,const String& p_label, int p_steps);
static void progress_task_step_bg(const String& p_task,int p_step=-1);
static void progress_end_task_bg(const String& p_task);
void save_scene(String p_file) { _save_scene(p_file); }
bool is_scene_in_use(const String& p_path);
void scan_import_changes();
void save_layout();
void update_keying();
void reload_scene(const String& p_path);
bool is_exiting() const { return exiting; }
ToolButton *get_pause_button() { return pause_button; }
ToolButton* add_bottom_panel_item(String p_text,Control *p_item);
bool are_bottom_panels_hidden() const;
void make_bottom_panel_item_visible(Control *p_item);
void raise_bottom_panel_item(Control *p_item);
void hide_bottom_panel();
void remove_bottom_panel_item(Control *p_item);
Variant drag_resource(const Ref<Resource>& p_res,Control* p_from);
Variant drag_files(const Vector<String>& p_files,Control* p_from);
Variant drag_files_and_dirs(const Vector<String>& p_files,Control* p_from);
EditorNode();
~EditorNode();
void get_singleton(const char* arg1, bool arg2);
static void add_init_callback(EditorNodeInitCallback p_callback) { _init_callbacks.push_back(p_callback); }
};
struct EditorProgress {
String task;
void step(const String& p_state, int p_step=-1,bool p_force_refresh=true) { EditorNode::progress_task_step(task,p_state,p_step,p_force_refresh); }
EditorProgress(const String& p_task,const String& p_label,int p_amount) { EditorNode::progress_add_task(p_task,p_label,p_amount); task=p_task; }
~EditorProgress() { EditorNode::progress_end_task(task); }
};
class EditorPluginList : public Object {
private:
Vector<EditorPlugin*> plugins_list;
public:
void set_plugins_list(Vector<EditorPlugin*> p_plugins_list) {
plugins_list = p_plugins_list;
}
Vector<EditorPlugin*>& get_plugins_list() {
return plugins_list;
}
void make_visible(bool p_visible);
void edit(Object *p_object);
bool forward_input_event(const InputEvent& p_event);
bool forward_spatial_input_event(Camera* p_camera, const InputEvent& p_event);
void clear();
bool empty();
EditorPluginList();
~EditorPluginList();
} ;
struct EditorProgressBG {
String task;
void step(int p_step=-1) { EditorNode::progress_task_step_bg(task,p_step); }
EditorProgressBG(const String& p_task,const String& p_label,int p_amount) { EditorNode::progress_add_task_bg(p_task,p_label,p_amount); task=p_task; }
~EditorProgressBG() { EditorNode::progress_end_task_bg(task); }
};
#endif

392
editor/editor_plugin.cpp Normal file
View File

@ -0,0 +1,392 @@
/*************************************************************************/
/* editor_plugin.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* 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. */
/*************************************************************************/
#include "editor_plugin.h"
#include "scene/3d/camera.h"
#include "plugins/canvas_item_editor_plugin.h"
#include "plugins/spatial_editor_plugin.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
void EditorPlugin::add_custom_type(const String& p_type, const String& p_base,const Ref<Script>& p_script, const Ref<Texture>& p_icon) {
EditorNode::get_editor_data().add_custom_type(p_type,p_base,p_script,p_icon);
}
void EditorPlugin::remove_custom_type(const String& p_type){
EditorNode::get_editor_data().remove_custom_type(p_type);
}
ToolButton * EditorPlugin::add_control_to_bottom_panel(Control *p_control, const String &p_title) {
return EditorNode::get_singleton()->add_bottom_panel_item(p_title,p_control);
}
void EditorPlugin::add_control_to_dock(DockSlot p_slot,Control *p_control) {
ERR_FAIL_NULL(p_control);
EditorNode::get_singleton()->add_control_to_dock(EditorNode::DockSlot(p_slot),p_control);
}
void EditorPlugin::remove_control_from_docks(Control *p_control) {
ERR_FAIL_NULL(p_control);
EditorNode::get_singleton()->remove_control_from_dock(p_control);
}
void EditorPlugin::remove_control_from_bottom_panel(Control *p_control) {
ERR_FAIL_NULL(p_control);
EditorNode::get_singleton()->remove_bottom_panel_item(p_control);
}
Control * EditorPlugin::get_editor_viewport() {
return EditorNode::get_singleton()->get_viewport();
}
void EditorPlugin::edit_resource(const Ref<Resource>& p_resource){
EditorNode::get_singleton()->edit_resource(p_resource);
}
void EditorPlugin::add_control_to_container(CustomControlContainer p_location,Control *p_control) {
switch(p_location) {
case CONTAINER_TOOLBAR: {
EditorNode::get_menu_hb()->add_child(p_control);
} break;
case CONTAINER_SPATIAL_EDITOR_MENU: {
SpatialEditor::get_singleton()->add_control_to_menu_panel(p_control);
} break;
case CONTAINER_SPATIAL_EDITOR_SIDE: {
SpatialEditor::get_singleton()->get_palette_split()->add_child(p_control);
SpatialEditor::get_singleton()->get_palette_split()->move_child(p_control,0);
} break;
case CONTAINER_SPATIAL_EDITOR_BOTTOM: {
SpatialEditor::get_singleton()->get_shader_split()->add_child(p_control);
} break;
case CONTAINER_CANVAS_EDITOR_MENU: {
CanvasItemEditor::get_singleton()->add_control_to_menu_panel(p_control);
} break;
case CONTAINER_CANVAS_EDITOR_SIDE: {
CanvasItemEditor::get_singleton()->get_palette_split()->add_child(p_control);
CanvasItemEditor::get_singleton()->get_palette_split()->move_child(p_control,0);
} break;
case CONTAINER_CANVAS_EDITOR_BOTTOM: {
CanvasItemEditor::get_singleton()->get_bottom_split()->add_child(p_control);
} break;
case CONTAINER_PROPERTY_EDITOR_BOTTOM: {
EditorNode::get_singleton()->get_property_editor_vb()->add_child(p_control);
} break;
}
}
Ref<SpatialEditorGizmo> EditorPlugin::create_spatial_gizmo(Spatial* p_spatial) {
//??
if (get_script_instance() && get_script_instance()->has_method("create_spatial_gizmo")) {
return get_script_instance()->call("create_spatial_gizmo",p_spatial);
}
return Ref<SpatialEditorGizmo>();
}
bool EditorPlugin::forward_input_event(const InputEvent& p_event) {
if (get_script_instance() && get_script_instance()->has_method("forward_input_event")) {
return get_script_instance()->call("forward_input_event",p_event);
}
return false;
}
bool EditorPlugin::forward_spatial_input_event(Camera* p_camera,const InputEvent& p_event) {
if (get_script_instance() && get_script_instance()->has_method("forward_spatial_input_event")) {
return get_script_instance()->call("forward_spatial_input_event",p_camera,p_event);
}
return false;
}
String EditorPlugin::get_name() const {
if (get_script_instance() && get_script_instance()->has_method("get_name")) {
return get_script_instance()->call("get_name");
}
return String();
}
bool EditorPlugin::has_main_screen() const {
if (get_script_instance() && get_script_instance()->has_method("has_main_screen")) {
return get_script_instance()->call("has_main_screen");
}
return false;
}
void EditorPlugin::make_visible(bool p_visible) {
if (get_script_instance() && get_script_instance()->has_method("make_visible")) {
get_script_instance()->call("make_visible",p_visible);
}
}
void EditorPlugin::edit(Object *p_object) {
if (get_script_instance() && get_script_instance()->has_method("edit")) {
get_script_instance()->call("edit",p_object);
}
}
bool EditorPlugin::handles(Object *p_object) const {
if (get_script_instance() && get_script_instance()->has_method("handles")) {
return get_script_instance()->call("handles",p_object);
}
return false;
}
Dictionary EditorPlugin::get_state() const {
if (get_script_instance() && get_script_instance()->has_method("get_state")) {
return get_script_instance()->call("get_state");
}
return Dictionary();
}
void EditorPlugin::set_state(const Dictionary& p_state) {
if (get_script_instance() && get_script_instance()->has_method("set_state")) {
get_script_instance()->call("set_state",p_state);
}
}
void EditorPlugin::clear() {
if (get_script_instance() && get_script_instance()->has_method("clear")) {
get_script_instance()->call("clear");
}
}
// if editor references external resources/scenes, save them
void EditorPlugin::save_external_data() {
if (get_script_instance() && get_script_instance()->has_method("save_external_data")) {
get_script_instance()->call("save_external_data");
}
}
// if changes are pending in editor, apply them
void EditorPlugin::apply_changes() {
if (get_script_instance() && get_script_instance()->has_method("apply_changes")) {
get_script_instance()->call("apply_changes");
}
}
void EditorPlugin::get_breakpoints(List<String> *p_breakpoints) {
if (get_script_instance() && get_script_instance()->has_method("get_breakpoints")) {
StringArray arr = get_script_instance()->call("get_breakpoints");
for(int i=0;i<arr.size();i++)
p_breakpoints->push_back(arr[i]);
}
}
bool EditorPlugin::get_remove_list(List<Node*> *p_list) {
return false;
}
void EditorPlugin::restore_global_state() {}
void EditorPlugin::save_global_state() {}
void EditorPlugin::set_window_layout(Ref<ConfigFile> p_layout) {
if (get_script_instance() && get_script_instance()->has_method("set_window_layout")) {
get_script_instance()->call("set_window_layout", p_layout);
}
}
void EditorPlugin::get_window_layout(Ref<ConfigFile> p_layout){
if (get_script_instance() && get_script_instance()->has_method("get_window_layout")) {
get_script_instance()->call("get_window_layout", p_layout);
}
}
void EditorPlugin::queue_save_layout() const {
EditorNode::get_singleton()->save_layout();
}
EditorSelection* EditorPlugin::get_selection() {
return EditorNode::get_singleton()->get_editor_selection();
}
EditorSettings *EditorPlugin::get_editor_settings() {
return EditorSettings::get_singleton();
}
void EditorPlugin::add_import_plugin(const Ref<EditorImportPlugin>& p_editor_import) {
EditorNode::get_singleton()->add_editor_import_plugin(p_editor_import);
}
void EditorPlugin::remove_import_plugin(const Ref<EditorImportPlugin>& p_editor_import){
EditorNode::get_singleton()->remove_editor_import_plugin(p_editor_import);
}
void EditorPlugin::add_export_plugin(const Ref<EditorExportPlugin>& p_editor_export){
EditorImportExport::get_singleton()->add_export_plugin(p_editor_export);
}
void EditorPlugin::remove_export_plugin(const Ref<EditorExportPlugin>& p_editor_export){
EditorImportExport::get_singleton()->remove_export_plugin(p_editor_export);
}
Control *EditorPlugin::get_base_control() {
return EditorNode::get_singleton()->get_gui_base();
}
void EditorPlugin::_bind_methods() {
ObjectTypeDB::bind_method(_MD("add_control_to_container","container","control:Control"),&EditorPlugin::add_control_to_container);
ObjectTypeDB::bind_method(_MD("add_control_to_bottom_panel:ToolButton","control:Control","title"),&EditorPlugin::add_control_to_bottom_panel);
ObjectTypeDB::bind_method(_MD("add_control_to_dock","slot","control:Control"),&EditorPlugin::add_control_to_dock);
ObjectTypeDB::bind_method(_MD("remove_control_from_docks","control:Control"),&EditorPlugin::remove_control_from_docks);
ObjectTypeDB::bind_method(_MD("remove_control_from_bottom_panel","control:Control"),&EditorPlugin::remove_control_from_bottom_panel);
ObjectTypeDB::bind_method(_MD("add_custom_type","type","base","script:Script","icon:Texture"),&EditorPlugin::add_custom_type);
ObjectTypeDB::bind_method(_MD("remove_custom_type","type"),&EditorPlugin::remove_custom_type);
ObjectTypeDB::bind_method(_MD("get_editor_viewport:Control"), &EditorPlugin::get_editor_viewport);
ObjectTypeDB::bind_method(_MD("add_import_plugin","plugin:EditorImportPlugin"),&EditorPlugin::add_import_plugin);
ObjectTypeDB::bind_method(_MD("remove_import_plugin","plugin:EditorImportPlugin"),&EditorPlugin::remove_import_plugin);
ObjectTypeDB::bind_method(_MD("add_export_plugin","plugin:EditorExportPlugin"),&EditorPlugin::add_export_plugin);
ObjectTypeDB::bind_method(_MD("remove_export_plugin","plugin:EditorExportPlugin"),&EditorPlugin::remove_export_plugin);
ObjectTypeDB::bind_method(_MD("get_base_control:Control"),&EditorPlugin::get_base_control);
ObjectTypeDB::bind_method(_MD("get_undo_redo:UndoRedo"),&EditorPlugin::_get_undo_redo);
ObjectTypeDB::bind_method(_MD("get_selection:EditorSelection"),&EditorPlugin::get_selection);
ObjectTypeDB::bind_method(_MD("get_editor_settings:EditorSettings"),&EditorPlugin::get_editor_settings);
ObjectTypeDB::bind_method(_MD("queue_save_layout"),&EditorPlugin::queue_save_layout);
ObjectTypeDB::bind_method(_MD("edit_resource"),&EditorPlugin::edit_resource);
ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo(Variant::BOOL,"forward_input_event",PropertyInfo(Variant::INPUT_EVENT,"event")));
ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo(Variant::BOOL,"forward_spatial_input_event",PropertyInfo(Variant::OBJECT,"camera",PROPERTY_HINT_RESOURCE_TYPE,"Camera"),PropertyInfo(Variant::INPUT_EVENT,"event")));
MethodInfo gizmo = MethodInfo(Variant::OBJECT,"create_spatial_gizmo",PropertyInfo(Variant::OBJECT,"for_spatial:Spatial"));
gizmo.return_val.hint=PROPERTY_HINT_RESOURCE_TYPE;
gizmo.return_val.hint_string="EditorSpatialGizmo";
ObjectTypeDB::add_virtual_method(get_type_static(),gizmo);
ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo(Variant::STRING,"get_name"));
ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo(Variant::BOOL,"has_main_screen"));
ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo("make_visible",PropertyInfo(Variant::BOOL,"visible")));
ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo("edit",PropertyInfo(Variant::OBJECT,"object")));
ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo(Variant::BOOL,"handles",PropertyInfo(Variant::OBJECT,"object")));
ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo(Variant::DICTIONARY,"get_state"));
ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo("set_state",PropertyInfo(Variant::DICTIONARY,"state")));
ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo("clear"));
ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo("save_external_data"));
ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo("apply_changes"));
ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo(Variant::STRING_ARRAY,"get_breakpoints"));
ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo("set_window_layout",PropertyInfo(Variant::OBJECT,"layout",PROPERTY_HINT_RESOURCE_TYPE,"ConfigFile")));
ObjectTypeDB::add_virtual_method(get_type_static(),MethodInfo("get_window_layout",PropertyInfo(Variant::OBJECT,"layout",PROPERTY_HINT_RESOURCE_TYPE,"ConfigFile")));
BIND_CONSTANT( CONTAINER_TOOLBAR );
BIND_CONSTANT( CONTAINER_SPATIAL_EDITOR_MENU );
BIND_CONSTANT( CONTAINER_SPATIAL_EDITOR_SIDE );
BIND_CONSTANT( CONTAINER_SPATIAL_EDITOR_BOTTOM );
BIND_CONSTANT( CONTAINER_CANVAS_EDITOR_MENU );
BIND_CONSTANT( CONTAINER_CANVAS_EDITOR_SIDE );
BIND_CONSTANT( CONTAINER_PROPERTY_EDITOR_BOTTOM );
BIND_CONSTANT( DOCK_SLOT_LEFT_UL );
BIND_CONSTANT( DOCK_SLOT_LEFT_BL );
BIND_CONSTANT( DOCK_SLOT_LEFT_UR );
BIND_CONSTANT( DOCK_SLOT_LEFT_BR );
BIND_CONSTANT( DOCK_SLOT_RIGHT_UL );
BIND_CONSTANT( DOCK_SLOT_RIGHT_BL );
BIND_CONSTANT( DOCK_SLOT_RIGHT_UR );
BIND_CONSTANT( DOCK_SLOT_RIGHT_BR );
BIND_CONSTANT( DOCK_SLOT_MAX );
}
EditorPlugin::EditorPlugin()
{
undo_redo=NULL;
}
EditorPlugin::~EditorPlugin()
{
}
EditorPluginCreateFunc EditorPlugins::creation_funcs[MAX_CREATE_FUNCS];
int EditorPlugins::creation_func_count=0;

69
editor/editor_sub_scene.h Normal file
View File

@ -0,0 +1,69 @@
/*************************************************************************/
/* editor_sub_scene.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* 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_SUB_SCENE_H
#define EDITOR_SUB_SCENE_H
#include "scene/gui/dialogs.h"
#include "scene/gui/tree.h"
#include "editor/editor_file_dialog.h"
class EditorSubScene : public ConfirmationDialog {
OBJ_TYPE(EditorSubScene,ConfirmationDialog);
LineEdit *path;
Tree *tree;
Node *scene;
EditorFileDialog *file_dialog;
void _fill_tree(Node* p_node,TreeItem *p_parent);
void _reown(Node* p_node,List<Node*> *p_to_reown);
void ok_pressed();
protected:
void _notification(int p_what);
static void _bind_methods();
void _path_browse();
void _path_selected(const String& p_path);
void _path_changed(const String& p_path);
public:
void move(Node* p_new_parent, Node* p_new_owner);
void clear();
EditorSubScene();
};
#endif // EDITOR_SUB_SCENE_H

View File

Before

Width:  |  Height:  |  Size: 581 B

After

Width:  |  Height:  |  Size: 581 B

View File

Before

Width:  |  Height:  |  Size: 151 B

After

Width:  |  Height:  |  Size: 151 B

View File

Before

Width:  |  Height:  |  Size: 151 B

After

Width:  |  Height:  |  Size: 151 B

View File

Before

Width:  |  Height:  |  Size: 816 B

After

Width:  |  Height:  |  Size: 816 B

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Some files were not shown because too many files have changed in this diff Show More