Skip to content

Commit 502201c

Browse files
0.2.4
1 parent 5494d07 commit 502201c

3 files changed

Lines changed: 109 additions & 10 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ differences with version 0.1:
5454
* Plugins Setting in Editor Settings. *(In the section Plugin, you can see with advance option enabled!)*
5555
* Pop Script: Make Floating Script in Separate Window using RMB context menu.
5656
* Refresh Warnings changes in all opened windows when project is saved *(Errors/Warning Script)*
57+
* Reopen recently closed/changed scripts when adding a split. (Suggestion: #5)
5758
>[!WARNING]
5859
>Experimental Refresh Warnings *(This option can be disabled on Editor Settings)*
5960

addons/script_spliter/core/builder.gd

Lines changed: 107 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ func _get_data_cfg() -> Array[Array]:
8686
,[&"plugin/script_spliter/editor/minimap_for_unfocus_window", &"_MINIMAP_4_UNFOCUS_WINDOW"]
8787
,[&"plugin/script_spliter/editor/out_focus_color_enabled", &"_OUT_FOCUS_COLORED"]
8888
,[&"plugin/script_spliter/editor/out_focus_color_value", &"_UNFOCUS_COLOR"]
89+
,[&"plugin/script_spliter/editor/split/reopen_last_closed_editor_on_add_split", &"_SHOULD_OPEN_CLOSED_EDITOR_SCRIPT"]
90+
,[&"plugin/script_spliter/editor/split/remember_last_used_editor_buffer_size", &"_LAST_USED_EDITOR_SIZE"]
8991

9092
,[&"plugin/script_spliter/line/size", &"_SEPARATOR_LINE_SIZE"]
9193
,[&"plugin/script_spliter/line/color", &"_SEPARATOR_LINE_COLOR"]
@@ -151,6 +153,36 @@ func init_1() -> void:
151153
#"hint_string": "Texture2D"
152154
#})
153155
#endregion
156+
157+
#region _FEATURE#5_
158+
var _SHOULD_OPEN_CLOSED_EDITOR_SCRIPT : bool = false
159+
var _LAST_USED_EDITOR_SIZE : int = 4
160+
161+
var _lifo_src : PackedStringArray = []
162+
163+
func add_last_script_used(src : String) -> void:
164+
if _LAST_USED_EDITOR_SIZE > 0:
165+
if src.is_empty():
166+
return
167+
168+
var x : int = _lifo_src.find(src)
169+
if x > -1:
170+
_lifo_src.remove_at(x)
171+
172+
_lifo_src.append(src)
173+
var total : int = maxi(_LAST_USED_EDITOR_SIZE, 0)
174+
while _lifo_src.size() > total:
175+
_lifo_src.remove_at(0)
176+
177+
func get_last_script_used() -> String:
178+
var size : int = _lifo_src.size()
179+
var result : String = ""
180+
if size > 0:
181+
size -= 1
182+
result = _lifo_src[size]
183+
_lifo_src.remove_at(size)
184+
return result
185+
#region
154186

155187
func update_config() -> void:
156188
var settings : EditorSettings = EditorInterface.get_editor_settings()
@@ -313,6 +345,13 @@ class Mickeytools extends Object:
313345
var _gui : Node = null
314346
var _index : int = 0
315347
var __placeholder : Node = null
348+
var _src : String = ""
349+
350+
func set_src(src : String) -> void:
351+
_src = src
352+
353+
func get_src() -> String:
354+
return _src
316355

317356
func get_title_name() -> String:
318357
if is_instance_valid(_reference):
@@ -545,6 +584,10 @@ class Mickeytools extends Object:
545584
_control = null
546585
_reference = null
547586
_index = 0
587+
588+
if is_instance_valid(_helper) and !_helper.is_queued_for_deletion():
589+
if _helper.add_last_script_used.is_valid():
590+
_helper.add_last_script_used(_src)
548591

549592
#func can_create(ref : Control) -> bool:
550593
#if !ref.has_meta("_tab_index"):
@@ -652,14 +695,28 @@ func _set_focus(tool : Mickeytools, txt : String = "", items : PackedStringArray
652695
if !gui.has_focus():
653696
gui.grab_focus()
654697

655-
if txt.length() > 0:
656-
for x : int in range(_item_list.item_count - 1, -1, -1):
657-
var _txt : String = _item_list.get_item_text(x)
658-
if !(_txt in items):
659-
_item_list.remove_item(x)
660-
_item_list.get_parent().get_child(0).set(&"text", txt)
661-
_item_list.queue_redraw()
662-
_focus_queue = false
698+
var item_list : ItemList = _item_list
699+
if is_instance_valid(item_list):
700+
_update_path()
701+
702+
if txt.length() > 0:
703+
for x : int in range(item_list.item_count - 1, -1, -1):
704+
var _txt : String = item_list.get_item_text(x)
705+
if !(_txt in items):
706+
item_list.remove_item(x)
707+
item_list.get_parent().get_child(0).set(&"text", txt)
708+
item_list.queue_redraw()
709+
710+
set_deferred(&"_focus_queue", false)
711+
712+
func _update_path() -> void:
713+
if _item_list.item_count == _editor.get_child_count():
714+
for x : Mickeytools in _code_editors:
715+
var ref : Control = x.get_reference()
716+
if is_instance_valid(ref):
717+
var index : int = ref.get_index()
718+
if index > -1 and _item_list.item_count > index:
719+
x.set_src(_item_list.get_item_tooltip(index))
663720

664721
func _on_focus(tool : Mickeytools) -> void:
665722
if _focus_queue:
@@ -682,6 +739,7 @@ func _out_it(node : Node, with_signals : bool = false) -> void:
682739
var has_tween : bool = is_instance_valid(_tweener)
683740
if has_tween and _code_editors.size() == 0:
684741
_tweener.clear()
742+
685743
for x : int in range(_code_editors.size() - 1, -1 , -1):
686744
var tool : Mickeytools = _code_editors[x]
687745
if is_instance_valid(tool):
@@ -829,12 +887,46 @@ func _get_container_edit() -> Control:
829887

830888
return rtab
831889

890+
func _create_by_last_used() -> void:
891+
if _lifo_src.size() > 0:
892+
var item_list : ItemList = _item_list
893+
if is_instance_valid(item_list):
894+
var unused : Array[Node] = []
895+
if _item_list.item_count == _editor.get_child_count():
896+
for x : Node in _main.get_children():
897+
if is_instance_valid(x):
898+
if x is TabContainer and x.get_child_count() == 0:
899+
unused.append(x)
900+
else:
901+
for y : Node in x.get_children():
902+
if y is TabContainer and y.get_child_count() == 0:
903+
unused.append(y)
904+
for u : Node in unused:
905+
var sc : String = get_last_script_used()
906+
var dirty : bool = false
907+
if sc.is_empty():
908+
continue
909+
910+
for x : int in _item_list.item_count:
911+
if _item_list.get_item_tooltip(x) == sc:
912+
create_code_editor(u, _editor.get_child(x))
913+
dirty = true
914+
break
915+
if !dirty and sc.begins_with("res://") and FileAccess.file_exists(sc):
916+
if _SHOULD_OPEN_CLOSED_EDITOR_SCRIPT:
917+
var res : Variant = ResourceLoader.load(sc)
918+
if res is Script:
919+
EditorInterface.edit_script(res)
920+
832921
func update() -> void:
833922
_clear()
834923
if _editor.get_child_count() > 0:
835924
var root : Node = _get_editor_root()
836925
if null != root and _editor.current_tab > -1:
837926
create_code_editor(root, _editor.get_current_tab_control())
927+
928+
_create_by_last_used()
929+
838930
for x : Node in _main.get_children():
839931
if is_instance_valid(x):
840932
if x is TabContainer and x.get_child_count() == 0:
@@ -1204,7 +1296,9 @@ func add_split(control : Node) -> void:
12041296
if null == current_unused:
12051297
current_unused = unused[0]
12061298

1207-
create_code_editor(root, current_unused)
1299+
_create_by_last_used()
1300+
if root.get_child_count() == 0:
1301+
create_code_editor(root, current_unused)
12081302

12091303
process_update_queue()
12101304

@@ -1238,6 +1332,10 @@ func update_build(columns : int, rows : int) -> void:
12381332
_main.add_child(broot)
12391333

12401334
var aviable : Node = get_aviable()
1335+
if aviable:
1336+
if _lifo_src.size() > 0:
1337+
_create_by_last_used()
1338+
aviable = get_aviable()
12411339
while aviable != null:
12421340
var unused : Array[Node] = _get_unused_editor_control()
12431341
if unused.size() == 0:

addons/script_spliter/plugin.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ name="Script Spliter"
44
description="Tool Addon for godot 4
55
Allow split script window."
66
author="Twister"
7-
version="0.2.3.4"
7+
version="0.2.4"
88
github="https://github.com/CodeNameTwister/Script-Spliter"
99
script="plugin.gd"

0 commit comments

Comments
 (0)