summaryrefslogtreecommitdiffstats
path: root/editor/plugins/script_editor_plugin.cpp
diff options
context:
space:
mode:
authorbruvzg <7645683+bruvzg@users.noreply.github.com>2024-04-17 10:44:44 +0300
committerbruvzg <7645683+bruvzg@users.noreply.github.com>2024-08-28 10:29:01 +0300
commit07e986f728bea30787a2411a11d64c158e640015 (patch)
tree2672d40632a5164dff2dfdf522914e7364f79502 /editor/plugins/script_editor_plugin.cpp
parentdb24ed4eadf233f75cb1ebbf7552d396fb8b4b80 (diff)
downloadredot-engine-07e986f728bea30787a2411a11d64c158e640015.tar.gz
Allow adding custom export platforms using scripts / GDExtension.
Diffstat (limited to 'editor/plugins/script_editor_plugin.cpp')
-rw-r--r--editor/plugins/script_editor_plugin.cpp71
1 files changed, 57 insertions, 14 deletions
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 7a052ebc19..e6afe5cdc0 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -578,8 +578,8 @@ void ScriptEditor::_clear_breakpoints() {
script_editor_cache->get_sections(&cached_editors);
for (const String &E : cached_editors) {
Array breakpoints = _get_cached_breakpoints_for_script(E);
- for (int i = 0; i < breakpoints.size(); i++) {
- EditorDebuggerNode::get_singleton()->set_breakpoint(E, (int)breakpoints[i] + 1, false);
+ for (int breakpoint : breakpoints) {
+ EditorDebuggerNode::get_singleton()->set_breakpoint(E, (int)breakpoint + 1, false);
}
if (breakpoints.size() > 0) {
@@ -1820,6 +1820,48 @@ void ScriptEditor::notify_script_changed(const Ref<Script> &p_script) {
emit_signal(SNAME("editor_script_changed"), p_script);
}
+Vector<String> ScriptEditor::_get_breakpoints() {
+ Vector<String> ret;
+ HashSet<String> loaded_scripts;
+ for (int i = 0; i < tab_container->get_tab_count(); i++) {
+ ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_tab_control(i));
+ if (!se) {
+ continue;
+ }
+
+ Ref<Script> scr = se->get_edited_resource();
+ if (scr.is_null()) {
+ continue;
+ }
+
+ String base = scr->get_path();
+ loaded_scripts.insert(base);
+ if (base.is_empty() || base.begins_with("local://")) {
+ continue;
+ }
+
+ PackedInt32Array bpoints = se->get_breakpoints();
+ for (int32_t bpoint : bpoints) {
+ ret.push_back(base + ":" + itos((int)bpoint + 1));
+ }
+ }
+
+ // Load breakpoints that are in closed scripts.
+ List<String> cached_editors;
+ script_editor_cache->get_sections(&cached_editors);
+ for (const String &E : cached_editors) {
+ if (loaded_scripts.has(E)) {
+ continue;
+ }
+
+ Array breakpoints = _get_cached_breakpoints_for_script(E);
+ for (int breakpoint : breakpoints) {
+ ret.push_back(E + ":" + itos((int)breakpoint + 1));
+ }
+ }
+ return ret;
+}
+
void ScriptEditor::get_breakpoints(List<String> *p_breakpoints) {
HashSet<String> loaded_scripts;
for (int i = 0; i < tab_container->get_tab_count(); i++) {
@@ -1829,19 +1871,19 @@ void ScriptEditor::get_breakpoints(List<String> *p_breakpoints) {
}
Ref<Script> scr = se->get_edited_resource();
- if (scr == nullptr) {
+ if (scr.is_null()) {
continue;
}
String base = scr->get_path();
loaded_scripts.insert(base);
- if (base.begins_with("local://") || base.is_empty()) {
+ if (base.is_empty() || base.begins_with("local://")) {
continue;
}
PackedInt32Array bpoints = se->get_breakpoints();
- for (int j = 0; j < bpoints.size(); j++) {
- p_breakpoints->push_back(base + ":" + itos((int)bpoints[j] + 1));
+ for (int32_t bpoint : bpoints) {
+ p_breakpoints->push_back(base + ":" + itos((int)bpoint + 1));
}
}
@@ -1854,8 +1896,8 @@ void ScriptEditor::get_breakpoints(List<String> *p_breakpoints) {
}
Array breakpoints = _get_cached_breakpoints_for_script(E);
- for (int i = 0; i < breakpoints.size(); i++) {
- p_breakpoints->push_back(E + ":" + itos((int)breakpoints[i] + 1));
+ for (int breakpoint : breakpoints) {
+ p_breakpoints->push_back(E + ":" + itos((int)breakpoint + 1));
}
}
}
@@ -2944,8 +2986,8 @@ void ScriptEditor::_files_moved(const String &p_old_file, const String &p_new_fi
// If Script, update breakpoints with debugger.
Array breakpoints = _get_cached_breakpoints_for_script(p_new_file);
- for (int i = 0; i < breakpoints.size(); i++) {
- int line = (int)breakpoints[i] + 1;
+ for (int breakpoint : breakpoints) {
+ int line = (int)breakpoint + 1;
EditorDebuggerNode::get_singleton()->set_breakpoint(p_old_file, line, false);
if (!p_new_file.begins_with("local://") && ResourceLoader::exists(p_new_file, "Script")) {
EditorDebuggerNode::get_singleton()->set_breakpoint(p_new_file, line, true);
@@ -2969,8 +3011,8 @@ void ScriptEditor::_file_removed(const String &p_removed_file) {
// Check closed.
if (script_editor_cache->has_section(p_removed_file)) {
Array breakpoints = _get_cached_breakpoints_for_script(p_removed_file);
- for (int i = 0; i < breakpoints.size(); i++) {
- EditorDebuggerNode::get_singleton()->set_breakpoint(p_removed_file, (int)breakpoints[i] + 1, false);
+ for (int breakpoint : breakpoints) {
+ EditorDebuggerNode::get_singleton()->set_breakpoint(p_removed_file, (int)breakpoint + 1, false);
}
script_editor_cache->erase_section(p_removed_file);
}
@@ -3425,8 +3467,8 @@ void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) {
}
Array breakpoints = _get_cached_breakpoints_for_script(E);
- for (int i = 0; i < breakpoints.size(); i++) {
- EditorDebuggerNode::get_singleton()->set_breakpoint(E, (int)breakpoints[i] + 1, true);
+ for (int breakpoint : breakpoints) {
+ EditorDebuggerNode::get_singleton()->set_breakpoint(E, (int)breakpoint + 1, true);
}
}
@@ -3972,6 +4014,7 @@ void ScriptEditor::_bind_methods() {
ClassDB::bind_method("_help_tab_goto", &ScriptEditor::_help_tab_goto);
ClassDB::bind_method("get_current_editor", &ScriptEditor::_get_current_editor);
ClassDB::bind_method("get_open_script_editors", &ScriptEditor::_get_open_script_editors);
+ ClassDB::bind_method("get_breakpoints", &ScriptEditor::_get_breakpoints);
ClassDB::bind_method(D_METHOD("register_syntax_highlighter", "syntax_highlighter"), &ScriptEditor::register_syntax_highlighter);
ClassDB::bind_method(D_METHOD("unregister_syntax_highlighter", "syntax_highlighter"), &ScriptEditor::unregister_syntax_highlighter);