mirror of
https://github.com/godotengine/godot.git
synced 2025-11-09 10:01:15 +00:00
Add unsaved status for script and shader editors
This commit is contained in:
parent
6dc5dc3479
commit
000471ee56
4 changed files with 49 additions and 0 deletions
|
|
@ -2435,6 +2435,18 @@ bool ScriptEditor::edit(const Ref<Resource> &p_resource, int p_line, int p_col,
|
|||
return true;
|
||||
}
|
||||
|
||||
PackedStringArray ScriptEditor::get_unsaved_scripts() const {
|
||||
PackedStringArray unsaved_list;
|
||||
|
||||
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->is_unsaved()) {
|
||||
unsaved_list.append(se->get_name());
|
||||
}
|
||||
}
|
||||
return unsaved_list;
|
||||
}
|
||||
|
||||
void ScriptEditor::save_current_script() {
|
||||
ScriptEditorBase *current = _get_current_editor();
|
||||
if (!current || _test_script_times_on_disk()) {
|
||||
|
|
@ -4207,6 +4219,24 @@ void ScriptEditorPlugin::selected_notify() {
|
|||
_focus_another_editor();
|
||||
}
|
||||
|
||||
String ScriptEditorPlugin::get_unsaved_status() const {
|
||||
const PackedStringArray unsaved_scripts = script_editor->get_unsaved_scripts();
|
||||
if (unsaved_scripts.is_empty()) {
|
||||
return String();
|
||||
}
|
||||
|
||||
PackedStringArray message;
|
||||
message.resize(unsaved_scripts.size() + 1);
|
||||
message.write[0] = "Save changes to the following script(s) before quitting?";
|
||||
|
||||
int i = 1;
|
||||
for (const String &E : unsaved_scripts) {
|
||||
message.write[i] = E.trim_suffix("(*)");
|
||||
i++;
|
||||
}
|
||||
return String("\n").join(message);
|
||||
}
|
||||
|
||||
void ScriptEditorPlugin::save_external_data() {
|
||||
script_editor->save_all_scripts();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue