You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-12 13:20:55 +00:00
Merge pull request #93713 from KoBeWi/scene_data_in_script_cache
Store script states for built-in scripts
This commit is contained in:
@@ -1291,6 +1291,16 @@ void _save_text_editor_theme_as(const String &p_file) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ScriptEditor::_script_exists(const String &p_path) const {
|
||||||
|
if (p_path.is_empty()) {
|
||||||
|
return false;
|
||||||
|
} else if (p_path.is_resource_file()) {
|
||||||
|
return FileAccess::exists(p_path);
|
||||||
|
} else {
|
||||||
|
return FileAccess::exists(p_path.get_slice("::", 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ScriptEditor::_file_dialog_action(const String &p_file) {
|
void ScriptEditor::_file_dialog_action(const String &p_file) {
|
||||||
switch (file_dialog_option) {
|
switch (file_dialog_option) {
|
||||||
case FILE_MENU_NEW_TEXTFILE: {
|
case FILE_MENU_NEW_TEXTFILE: {
|
||||||
@@ -3038,7 +3048,7 @@ void ScriptEditor::_save_editor_state(ScriptEditorBase *p_editor) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const String &path = p_editor->get_edited_resource()->get_path();
|
const String &path = p_editor->get_edited_resource()->get_path();
|
||||||
if (!path.is_resource_file()) {
|
if (path.is_empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3574,23 +3584,37 @@ void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) {
|
|||||||
ResourceLoader::get_recognized_extensions_for_type("Script", &extensions);
|
ResourceLoader::get_recognized_extensions_for_type("Script", &extensions);
|
||||||
ResourceLoader::get_recognized_extensions_for_type("JSON", &extensions);
|
ResourceLoader::get_recognized_extensions_for_type("JSON", &extensions);
|
||||||
|
|
||||||
for (int i = 0; i < scripts.size(); i++) {
|
for (const Variant &v : scripts) {
|
||||||
String path = scripts[i];
|
String path = v;
|
||||||
|
|
||||||
Dictionary script_info = scripts[i];
|
Dictionary script_info = v;
|
||||||
if (!script_info.is_empty()) {
|
if (!script_info.is_empty()) {
|
||||||
path = script_info["path"];
|
path = script_info["path"];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!FileAccess::exists(path)) {
|
if (!_script_exists(path)) {
|
||||||
if (script_editor_cache->has_section(path)) {
|
if (script_editor_cache->has_section(path)) {
|
||||||
script_editor_cache->erase_section(path);
|
script_editor_cache->erase_section(path);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
} else if (!path.is_resource_file() && !EditorNode::get_singleton()->is_scene_open(path.get_slice("::", 0))) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
loaded_scripts.insert(path);
|
loaded_scripts.insert(path);
|
||||||
|
|
||||||
if (extensions.find(path.get_extension())) {
|
bool is_script = false;
|
||||||
|
if (path.is_resource_file()) {
|
||||||
|
is_script = extensions.find(path.get_extension());
|
||||||
|
} else {
|
||||||
|
Ref<Script> scr = ResourceCache::get_ref(path);
|
||||||
|
if (scr.is_valid()) {
|
||||||
|
is_script = true;
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_script) {
|
||||||
Ref<Resource> scr = ResourceLoader::load(path);
|
Ref<Resource> scr = ResourceLoader::load(path);
|
||||||
if (scr.is_null()) {
|
if (scr.is_null()) {
|
||||||
continue;
|
continue;
|
||||||
@@ -3645,7 +3669,7 @@ void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!FileAccess::exists(E)) {
|
if (!_script_exists(E)) {
|
||||||
script_editor_cache->erase_section(E);
|
script_editor_cache->erase_section(E);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -3682,8 +3706,8 @@ void ScriptEditor::get_window_layout(Ref<ConfigFile> p_layout) {
|
|||||||
for (int i = 0; i < tab_container->get_tab_count(); i++) {
|
for (int i = 0; i < tab_container->get_tab_count(); i++) {
|
||||||
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i));
|
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i));
|
||||||
if (se) {
|
if (se) {
|
||||||
String path = se->get_edited_resource()->get_path();
|
const String path = se->get_edited_resource()->get_path();
|
||||||
if (!path.is_resource_file()) {
|
if (path.is_empty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -409,6 +409,7 @@ class ScriptEditor : public PanelContainer {
|
|||||||
void _resave_scripts(const String &p_str);
|
void _resave_scripts(const String &p_str);
|
||||||
|
|
||||||
bool _test_script_times_on_disk(Ref<Resource> p_for_script = Ref<Resource>());
|
bool _test_script_times_on_disk(Ref<Resource> p_for_script = Ref<Resource>());
|
||||||
|
bool _script_exists(const String &p_path) const;
|
||||||
|
|
||||||
void _add_recent_script(const String &p_path);
|
void _add_recent_script(const String &p_path);
|
||||||
void _update_recent_scripts();
|
void _update_recent_scripts();
|
||||||
|
|||||||
Reference in New Issue
Block a user