feat: updated engine
This commit is contained in:
parent
cbe99774ff
commit
f4cf6b3999
6607 changed files with 910135 additions and 430025 deletions
|
|
@ -34,11 +34,15 @@
|
|||
#include "core/extension/gdextension_manager.h"
|
||||
#include "core/io/file_access.h"
|
||||
#include "core/io/resource_loader.h"
|
||||
#include "core/object/callable_mp.h"
|
||||
#include "core/object/class_db.h"
|
||||
#include "core/os/time.h"
|
||||
#include "editor/editor_node.h"
|
||||
#include "editor/editor_undo_redo_manager.h"
|
||||
#include "editor/inspector/editor_context_menu_plugin.h"
|
||||
#include "editor/inspector/multi_node_edit.h"
|
||||
#include "editor/plugins/editor_plugin.h"
|
||||
#include "scene/main/scene_tree.h"
|
||||
#include "scene/property_utils.h"
|
||||
#include "scene/resources/packed_scene.h"
|
||||
|
||||
|
|
@ -267,9 +271,9 @@ EditorPlugin *EditorData::get_handling_main_editor(Object *p_object) {
|
|||
|
||||
Vector<EditorPlugin *> EditorData::get_handling_sub_editors(Object *p_object) {
|
||||
Vector<EditorPlugin *> sub_plugins;
|
||||
for (int i = editor_plugins.size() - 1; i > -1; i--) {
|
||||
if (!editor_plugins[i]->has_main_screen() && editor_plugins[i]->handles(p_object)) {
|
||||
sub_plugins.push_back(editor_plugins[i]);
|
||||
for (EditorPlugin *plugin : editor_plugins) {
|
||||
if (!plugin->has_main_screen() && plugin->handles(p_object)) {
|
||||
sub_plugins.push_back(plugin);
|
||||
}
|
||||
}
|
||||
return sub_plugins;
|
||||
|
|
@ -324,8 +328,23 @@ Dictionary EditorData::get_editor_plugin_states() const {
|
|||
|
||||
Dictionary EditorData::get_scene_editor_states(int p_idx) const {
|
||||
ERR_FAIL_INDEX_V(p_idx, edited_scene.size(), Dictionary());
|
||||
EditedScene es = edited_scene[p_idx];
|
||||
return es.editor_states;
|
||||
return edited_scene[p_idx].editor_states;
|
||||
}
|
||||
|
||||
Dictionary EditorData::get_scene_editor_states_with_selection(int p_idx) const {
|
||||
ERR_FAIL_INDEX_V(p_idx, edited_scene.size(), Dictionary());
|
||||
const EditedScene &es = edited_scene[p_idx];
|
||||
Dictionary states = es.editor_states;
|
||||
|
||||
TypedArray<NodePath> selected_paths;
|
||||
Node *root = es.root;
|
||||
if (root) {
|
||||
for (Node *node : es.selection) {
|
||||
selected_paths.push_back(root->get_path_to(node));
|
||||
}
|
||||
states["$selected_nodes"] = selected_paths;
|
||||
}
|
||||
return states;
|
||||
}
|
||||
|
||||
void EditorData::set_editor_plugin_states(const Dictionary &p_states) {
|
||||
|
|
@ -337,19 +356,10 @@ void EditorData::set_editor_plugin_states(const Dictionary &p_states) {
|
|||
}
|
||||
|
||||
for (const KeyValue<Variant, Variant> &kv : p_states) {
|
||||
String name = kv.key;
|
||||
int idx = -1;
|
||||
for (int i = 0; i < editor_plugins.size(); i++) {
|
||||
if (editor_plugins[i]->get_plugin_name() == name) {
|
||||
idx = i;
|
||||
break;
|
||||
}
|
||||
EditorPlugin *plugin = get_editor_by_name(kv.key);
|
||||
if (plugin) {
|
||||
plugin->set_state(kv.value);
|
||||
}
|
||||
|
||||
if (idx == -1) {
|
||||
continue;
|
||||
}
|
||||
editor_plugins[idx]->set_state(kv.value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -372,6 +382,36 @@ void EditorData::notify_scene_saved(const String &p_path) {
|
|||
}
|
||||
}
|
||||
|
||||
void EditorData::load_editor_plugin_states_from_config(const Ref<ConfigFile> &p_config_file, int p_idx) {
|
||||
ERR_FAIL_INDEX(p_idx, edited_scene.size());
|
||||
EditedScene &es = edited_scene.write[p_idx];
|
||||
|
||||
const Vector<String> esl = p_config_file->get_section_keys("editor_states");
|
||||
|
||||
Dictionary states;
|
||||
for (const String &E : esl) {
|
||||
const Variant state = p_config_file->get_value("editor_states", E);
|
||||
if (state.get_type() != Variant::NIL) {
|
||||
states[E] = state;
|
||||
}
|
||||
}
|
||||
es.editor_states = states;
|
||||
|
||||
const Node *root = es.root;
|
||||
if (root && p_config_file->has_section_key("editor_states", "$selected_nodes")) {
|
||||
TypedArray<NodePath> node_paths = p_config_file->get_value("editor_states", "$selected_nodes");
|
||||
List<Node *> nodes;
|
||||
|
||||
for (const Variant &np : node_paths) {
|
||||
Node *node = root->get_node_or_null(np);
|
||||
if (node) {
|
||||
nodes.push_back(node);
|
||||
}
|
||||
}
|
||||
es.selection = nodes;
|
||||
}
|
||||
}
|
||||
|
||||
void EditorData::clear_editor_states() {
|
||||
for (int i = 0; i < editor_plugins.size(); i++) {
|
||||
editor_plugins[i]->clear();
|
||||
|
|
@ -617,6 +657,7 @@ int EditorData::add_edited_scene(int p_at_pos) {
|
|||
es.history_current = -1;
|
||||
es.live_edit_root = NodePath(String("/root"));
|
||||
es.history_id = last_created_scene++;
|
||||
es.time_opened = Time::get_singleton()->get_unix_time_from_system();
|
||||
|
||||
if (p_at_pos == edited_scene.size()) {
|
||||
edited_scene.push_back(es);
|
||||
|
|
@ -630,12 +671,6 @@ int EditorData::add_edited_scene(int p_at_pos) {
|
|||
return p_at_pos;
|
||||
}
|
||||
|
||||
void EditorData::move_edited_scene_index(int p_idx, int p_to_idx) {
|
||||
ERR_FAIL_INDEX(p_idx, edited_scene.size());
|
||||
ERR_FAIL_INDEX(p_to_idx, edited_scene.size());
|
||||
SWAP(edited_scene.write[p_idx], edited_scene.write[p_to_idx]);
|
||||
}
|
||||
|
||||
void EditorData::remove_scene(int p_idx) {
|
||||
ERR_FAIL_INDEX(p_idx, edited_scene.size());
|
||||
if (edited_scene[p_idx].root) {
|
||||
|
|
@ -666,6 +701,24 @@ void EditorData::remove_scene(int p_idx) {
|
|||
edited_scene.remove_at(p_idx);
|
||||
}
|
||||
|
||||
void EditorData::set_scene_root(int p_idx, Node *p_root) {
|
||||
ERR_FAIL_INDEX(p_idx, edited_scene.size());
|
||||
EditedScene &scene_info = edited_scene.write[p_idx];
|
||||
|
||||
scene_info.root = p_root;
|
||||
if (p_root) {
|
||||
if (p_root->is_instance()) {
|
||||
scene_info.path = p_root->get_scene_file_path();
|
||||
} else {
|
||||
p_root->set_scene_file_path(scene_info.path);
|
||||
}
|
||||
}
|
||||
|
||||
if (!scene_info.path.is_empty()) {
|
||||
scene_info.file_modified_time = FileAccess::get_modified_time(scene_info.path);
|
||||
}
|
||||
}
|
||||
|
||||
bool EditorData::_find_updated_instances(Node *p_root, Node *p_node, HashSet<String> &checked_paths) {
|
||||
Ref<SceneState> ss;
|
||||
|
||||
|
|
@ -757,6 +810,15 @@ bool EditorData::reload_scene_from_memory(int p_idx, bool p_mark_unsaved) {
|
|||
return true;
|
||||
}
|
||||
|
||||
void EditorData::move_scene_to_index(int p_idx, int p_to_idx) {
|
||||
ERR_FAIL_INDEX(p_idx, edited_scene.size());
|
||||
ERR_FAIL_INDEX(p_to_idx, edited_scene.size());
|
||||
|
||||
EditedScene es = edited_scene[p_idx];
|
||||
edited_scene.remove_at(p_idx);
|
||||
edited_scene.insert(p_to_idx, es);
|
||||
}
|
||||
|
||||
int EditorData::get_edited_scene() const {
|
||||
return current_edited_scene;
|
||||
}
|
||||
|
|
@ -787,19 +849,7 @@ Node *EditorData::get_edited_scene_root(int p_idx) {
|
|||
}
|
||||
|
||||
void EditorData::set_edited_scene_root(Node *p_root) {
|
||||
ERR_FAIL_INDEX(current_edited_scene, edited_scene.size());
|
||||
edited_scene.write[current_edited_scene].root = p_root;
|
||||
if (p_root) {
|
||||
if (p_root->is_instance()) {
|
||||
edited_scene.write[current_edited_scene].path = p_root->get_scene_file_path();
|
||||
} else {
|
||||
p_root->set_scene_file_path(edited_scene[current_edited_scene].path);
|
||||
}
|
||||
}
|
||||
|
||||
if (!edited_scene[current_edited_scene].path.is_empty()) {
|
||||
edited_scene.write[current_edited_scene].file_modified_time = FileAccess::get_modified_time(edited_scene[current_edited_scene].path);
|
||||
}
|
||||
set_scene_root(current_edited_scene, p_root);
|
||||
}
|
||||
|
||||
int EditorData::get_edited_scene_count() const {
|
||||
|
|
@ -816,6 +866,11 @@ Vector<EditorData::EditedScene> EditorData::get_edited_scenes() const {
|
|||
return out_edited_scenes_list;
|
||||
}
|
||||
|
||||
uint64_t EditorData::get_scene_time_opened(int p_idx) const {
|
||||
ERR_FAIL_INDEX_V(p_idx, edited_scene.size(), 0);
|
||||
return edited_scene[p_idx].time_opened;
|
||||
}
|
||||
|
||||
void EditorData::set_scene_modified_time(int p_idx, uint64_t p_time) {
|
||||
if (p_idx == -1) {
|
||||
p_idx = current_edited_scene;
|
||||
|
|
@ -842,9 +897,7 @@ void EditorData::move_edited_scene_to_index(int p_idx) {
|
|||
ERR_FAIL_INDEX(current_edited_scene, edited_scene.size());
|
||||
ERR_FAIL_INDEX(p_idx, edited_scene.size());
|
||||
|
||||
EditedScene es = edited_scene[current_edited_scene];
|
||||
edited_scene.remove_at(current_edited_scene);
|
||||
edited_scene.insert(p_idx, es);
|
||||
move_scene_to_index(current_edited_scene, p_idx);
|
||||
current_edited_scene = p_idx;
|
||||
}
|
||||
|
||||
|
|
@ -910,7 +963,7 @@ String EditorData::get_scene_path(int p_idx) const {
|
|||
ERR_FAIL_INDEX_V(p_idx, edited_scene.size(), String());
|
||||
|
||||
if (edited_scene[p_idx].root) {
|
||||
if (edited_scene[p_idx].root->get_scene_file_path().is_empty()) {
|
||||
if (edited_scene[p_idx].root->get_scene_file_path().is_empty() && !edited_scene[p_idx].path.is_empty()) {
|
||||
edited_scene[p_idx].root->set_scene_file_path(edited_scene[p_idx].path);
|
||||
} else {
|
||||
return edited_scene[p_idx].root->get_scene_file_path();
|
||||
|
|
@ -1322,16 +1375,20 @@ void EditorSelection::_update_node_list() {
|
|||
node_list_changed = false;
|
||||
}
|
||||
|
||||
void EditorSelection::update() {
|
||||
void EditorSelection::update(bool p_deferred) {
|
||||
_update_node_list();
|
||||
|
||||
if (!changed) {
|
||||
return;
|
||||
}
|
||||
changed = false;
|
||||
if (!emitted) {
|
||||
emitted = true;
|
||||
callable_mp(this, &EditorSelection::_emit_change).call_deferred();
|
||||
if (p_deferred) {
|
||||
if (!emitted) {
|
||||
emitted = true;
|
||||
callable_mp(this, &EditorSelection::_emit_change).call_deferred();
|
||||
}
|
||||
} else {
|
||||
_emit_change();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue