Skip to content

Commit

Permalink
Improve editor state persistence
Browse files Browse the repository at this point in the history
  • Loading branch information
Geometror committed May 11, 2023
1 parent 74c34ae commit dc46163
Show file tree
Hide file tree
Showing 20 changed files with 556 additions and 258 deletions.
3 changes: 3 additions & 0 deletions doc/classes/EditorSettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,9 @@
<member name="editors/polygon_editor/show_previous_outline" type="bool" setter="" getter="">
If [code]true[/code], displays the polygon's previous shape in the 2D polygon editors with an opaque gray outline. This outline is displayed while dragging a point until the left mouse button is released.
</member>
<member name="editors/shader_editor/behavior/files/restore_shaders_on_load" type="bool" setter="" getter="">
If [code]true[/code], reopens shader files that were open in the shader editor when the project was last closed.
</member>
<member name="editors/tiles_editor/display_grid" type="bool" setter="" getter="">
If [code]true[/code], displays a grid while the TileMap editor is active. See also [member editors/tiles_editor/grid_color].
</member>
Expand Down
20 changes: 18 additions & 2 deletions doc/classes/TreeItem.xml
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,19 @@
Returns the next sibling TreeItem in the tree or a null object if there is none.
</description>
</method>
<method name="get_next_in_tree">
<return type="TreeItem" />
<param index="0" name="wrap" type="bool" default="false" />
<description>
Returns the next TreeItem in the tree (in the context of a depth-first search) or a [code]null[/code] object if there is none.
If [param wrap] is enabled, the method will wrap around to the first element in the tree when called on the last element, otherwise it returns [code]null[/code].
</description>
</method>
<method name="get_next_visible">
<return type="TreeItem" />
<param index="0" name="wrap" type="bool" default="false" />
<description>
Returns the next visible sibling TreeItem in the tree or a null object if there is none.
Returns the next visible TreeItem in the tree (in the context of a depth-first search) or a [code]null[/code] object if there is none.
If [param wrap] is enabled, the method will wrap around to the first visible element in the tree when called on the last visible element, otherwise it returns [code]null[/code].
</description>
</method>
Expand All @@ -246,11 +254,19 @@
Returns the previous sibling TreeItem in the tree or a null object if there is none.
</description>
</method>
<method name="get_prev_in_tree">
<return type="TreeItem" />
<param index="0" name="wrap" type="bool" default="false" />
<description>
Returns the previous TreeItem in the tree (in the context of a depth-first search) or a [code]null[/code] object if there is none.
If [param wrap] is enabled, the method will wrap around to the last element in the tree when called on the first visible element, otherwise it returns [code]null[/code].
</description>
</method>
<method name="get_prev_visible">
<return type="TreeItem" />
<param index="0" name="wrap" type="bool" default="false" />
<description>
Returns the previous visible sibling TreeItem in the tree or a null object if there is none.
Returns the previous visible sibling TreeItem in the tree (in the context of a depth-first search) or a [code]null[/code] object if there is none.
If [param wrap] is enabled, the method will wrap around to the last visible element in the tree when called on the first visible element, otherwise it returns [code]null[/code].
</description>
</method>
Expand Down
8 changes: 8 additions & 0 deletions editor/debugger/script_editor_debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1704,6 +1704,14 @@ void ScriptEditorDebugger::remove_debugger_tab(Control *p_control) {
p_control->queue_free();
}

int ScriptEditorDebugger::get_current_debugger_tab() const {
return tabs->get_current_tab();
}

void ScriptEditorDebugger::switch_to_debugger(int p_debugger_tab_idx) {
tabs->set_current_tab(p_debugger_tab_idx);
}

void ScriptEditorDebugger::send_message(const String &p_message, const Array &p_args) {
_put_msg(p_message, p_args);
}
Expand Down
2 changes: 2 additions & 0 deletions editor/debugger/script_editor_debugger.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ class ScriptEditorDebugger : public MarginContainer {

void add_debugger_tab(Control *p_control);
void remove_debugger_tab(Control *p_control);
int get_current_debugger_tab() const;
void switch_to_debugger(int p_debugger_tab_idx);

void send_message(const String &p_message, const Array &p_args);
void toggle_profiler(const String &p_profiler, bool p_enable, const Array &p_data);
Expand Down
8 changes: 4 additions & 4 deletions editor/editor_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ void EditorData::get_editor_breakpoints(List<String> *p_breakpoints) {
}
}

Dictionary EditorData::get_editor_states() const {
Dictionary EditorData::get_editor_plugin_states() const {
Dictionary metadata;
for (int i = 0; i < editor_plugins.size(); i++) {
Dictionary state = editor_plugins[i]->get_state();
Expand All @@ -319,7 +319,7 @@ Dictionary EditorData::get_scene_editor_states(int p_idx) const {
return es.editor_states;
}

void EditorData::set_editor_states(const Dictionary &p_states) {
void EditorData::set_editor_plugin_states(const Dictionary &p_states) {
if (p_states.is_empty()) {
for (EditorPlugin *ep : editor_plugins) {
ep->clear();
Expand Down Expand Up @@ -891,7 +891,7 @@ void EditorData::save_edited_scene_state(EditorSelection *p_selection, EditorSel
es.selection = p_selection->get_full_selected_node_list();
es.history_current = p_history->current_elem_idx;
es.history_stored = p_history->history;
es.editor_states = get_editor_states();
es.editor_states = get_editor_plugin_states();
es.custom_state = p_custom;
}

Expand All @@ -907,7 +907,7 @@ Dictionary EditorData::restore_edited_scene_state(EditorSelection *p_selection,
for (Node *E : es.selection) {
p_selection->add_node(E);
}
set_editor_states(es.editor_states);
set_editor_plugin_states(es.editor_states);

return es.custom_state;
}
Expand Down
4 changes: 2 additions & 2 deletions editor/editor_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ class EditorData {
void copy_object_params(Object *p_object);
void paste_object_params(Object *p_object);

Dictionary get_editor_states() const;
Dictionary get_editor_plugin_states() const;
Dictionary get_scene_editor_states(int p_idx) const;
void set_editor_states(const Dictionary &p_states);
void set_editor_plugin_states(const Dictionary &p_states);
void get_editor_breakpoints(List<String> *p_breakpoints);
void clear_editor_states();
void save_editor_external_data();
Expand Down
Loading

0 comments on commit dc46163

Please sign in to comment.