Skip to content

Commit b58e908

Browse files
Resolve Issue#6;Fix Document Search
1 parent 28eb17b commit b58e908

File tree

4 files changed

+104
-54
lines changed

4 files changed

+104
-54
lines changed

addons/script_spliter/context/flying_script.gd

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ var proxy : Control = null
1919
var replacer : Node = null
2020
var controller : Object = null
2121

22-
var _fps : int = 10
23-
2422
func set_base_control(node : Node) -> void:
2523
if _base_control:
2624
_base_control.queue_sort()

addons/script_spliter/core/builder.gd

Lines changed: 79 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,6 @@ func update_config() -> void:
201201
var gui : Node = x.get_control()
202202
if is_instance_valid(gui) and gui is Control:
203203
gui.modulate = Color.WHITE
204-
205-
for x : Mickeytools in _code_editors:
206-
x.update_focus_behaviour()
207204

208205
func _update_container() -> void:
209206
if !is_instance_valid(_main):
@@ -441,26 +438,36 @@ class Mickeytools extends Object:
441438

442439
func set_root(root : Node) -> void:
443440
_root = root
444-
445-
func _on_input(__ : InputEvent) -> void:
446-
if __ is InputEventMouseMotion:
447-
return
441+
442+
func _context_update(window : Window, control : Control) -> void:
443+
if is_instance_valid(window) and is_instance_valid(control) and is_instance_valid(_root):
444+
var root : Viewport= _root.get_viewport()
445+
var gvp : Vector2 = control.get_global_mouse_position()
446+
gvp.x += (window.size.x/ 4.0)
447+
gvp.y = min(gvp.y, root.size.y-window.size.y + 16.0)
448+
gvp.x = min(gvp.x, root.size.x-window.size.x + 16.0)
449+
450+
window.set_deferred(&"position", gvp)
451+
448452

449-
var tab : TabContainer = _root
450-
451-
var parent : Node = tab.get_parent()
452-
if parent and parent.has_method(&"show_splited_container"):
453-
parent.call(&"show_splited_container")
454453

455-
func update_focus_behaviour() -> void:
456-
if !is_instance_valid(_gui) or _gui.focus_mode == Control.FOCUS_NONE:
454+
func _on_input(input : InputEvent) -> void:
455+
if input is InputEventMouseMotion:
457456
return
458457

458+
if input is InputEventMouseButton:
459+
if input.pressed and input.button_index == 2:
460+
if _reference.get_child_count() > 1:
461+
var variant : Node = _reference.get_child(1)
462+
if variant is Window and _gui is Control:
463+
_context_update.call_deferred(variant, _gui)
464+
459465
if _helper.can_expand_same_focus():
460-
if !_gui.gui_input.is_connected(_on_input):
461-
_gui.gui_input.connect(_on_input)
462-
elif _gui.gui_input.is_connected(_on_input):
463-
_gui.gui_input.disconnect(_on_input)
466+
var tab : TabContainer = _root
467+
468+
var parent : Node = tab.get_parent()
469+
if parent and parent.has_method(&"show_splited_container"):
470+
parent.call(&"show_splited_container")
464471

465472
func set_reference(control : Node) -> void:
466473
if !is_instance_valid(control):
@@ -469,6 +476,8 @@ class Mickeytools extends Object:
469476
return
470477
elif is_instance_valid(_reference):
471478
reset()
479+
#if _reference is CanvasItem:
480+
#_gui.get_parent()
472481

473482
if is_instance_valid(_gui) and _gui.gui_input.is_connected(_on_input):
474483
_gui.gui_input.disconnect(_on_input)
@@ -479,7 +488,6 @@ class Mickeytools extends Object:
479488

480489
if control is ScriptEditorBase:
481490
_gui = control.get_base_editor()
482-
update_focus_behaviour()
483491

484492
if _gui is CodeEdit:
485493
var carets : PackedInt32Array = _gui.get_sorted_carets()
@@ -504,8 +512,18 @@ class Mickeytools extends Object:
504512
else:
505513
for x : Node in control.get_children():
506514
if x is RichTextLabel:
507-
_gui = x
508-
_control = x
515+
if _reference is CanvasItem:
516+
var canvas : VBoxContainer = VBoxContainer.new()
517+
canvas.size_flags_vertical = Control.SIZE_EXPAND_FILL
518+
canvas.size_flags_vertical = Control.SIZE_EXPAND_FILL
519+
if canvas.get_child_count() < 1:
520+
for n : Node in _reference.get_children():
521+
n.reparent(canvas)
522+
_gui = canvas
523+
_control = canvas
524+
else:
525+
_gui = x
526+
_control = x
509527
break
510528

511529
if _control == null:
@@ -518,21 +536,27 @@ class Mickeytools extends Object:
518536
if null != parent:
519537
_parent = parent
520538

521-
if null != _gui:
522-
if !_gui.focus_entered.is_connected(_i_like_coffe):
523-
_gui.focus_entered.connect(_i_like_coffe)
524-
525539
if is_instance_valid(_parent) and _control.get_parent() == _parent:
526540
_index = _control.get_index()
527541
_parent.remove_child(_control)
528542

529543
_root.add_child(_control)
530544

531545
if _gui:
532-
if !_gui.is_node_ready():
533-
await _gui.ready
534-
if is_instance_valid(_gui):
535-
focus.emit(self)
546+
var gui : Control = _gui
547+
548+
if gui.focus_mode != Control.FOCUS_NONE:
549+
if !gui.gui_input.is_connected(_on_input):
550+
gui.gui_input.connect(_on_input)
551+
552+
if gui is VBoxContainer:
553+
gui = gui.get_child(0)
554+
if !gui.focus_entered.is_connected(_i_like_coffe):
555+
gui.focus_entered.connect(_i_like_coffe)
556+
if !gui.is_node_ready():
557+
await gui.ready
558+
if is_instance_valid(gui):
559+
focus.emit(self)
536560

537561
func update() -> void:
538562
if is_instance_valid(_control) and is_instance_valid(_reference):
@@ -553,11 +577,23 @@ class Mickeytools extends Object:
553577
func reset(disconnect_signals : bool = true) -> void:
554578
if is_instance_valid(_gui):
555579
if disconnect_signals:
556-
if _gui.focus_entered.is_connected(_i_like_coffe):
557-
_gui.focus_entered.disconnect(_i_like_coffe)
558-
if _gui.gui_input.is_connected(_on_input):
559-
_gui.gui_input.disconnect(_on_input)
580+
var gui : Control = _gui
581+
if gui is VBoxContainer:
582+
gui = gui.get_child(0)
583+
if gui.focus_entered.is_connected(_i_like_coffe):
584+
gui.focus_entered.disconnect(_i_like_coffe)
585+
if gui.gui_input.is_connected(_on_input):
586+
gui.gui_input.disconnect(_on_input)
560587
_gui.modulate = Color.WHITE
588+
589+
if _gui is VBoxContainer:
590+
for x : Node in _gui.get_children():
591+
x.reparent(_reference)
592+
if _gui != _control:
593+
_gui.queue_free()
594+
_gui = null
595+
_control.queue_free()
596+
_control = null
561597

562598
if is_instance_valid(_control):
563599
if is_instance_valid(_parent):
@@ -693,6 +729,8 @@ func _set_focus(tool : Mickeytools, txt : String = "", items : PackedStringArray
693729
if wm and !wm.has_focus():
694730
wm.grab_focus()
695731
if !gui.has_focus():
732+
if gui is VBoxContainer:
733+
gui = gui.get_child(0)
696734
gui.grab_focus()
697735

698736
var item_list : ItemList = _item_list
@@ -1216,6 +1254,11 @@ func find_editor(node : Node) -> Control:
12161254
func can_remove_split(node : Node) -> bool:
12171255
if !is_instance_valid(_main):
12181256
return false
1257+
1258+
if node == null:
1259+
return _code_editors.size() > 1
1260+
1261+
12191262
if _code_editors.size() > 1:
12201263
if node is CodeEdit:
12211264
var main : bool = false
@@ -1244,6 +1287,9 @@ func can_add_split(_node : Node) -> bool:
12441287
if !is_instance_valid(_main):
12451288
return false
12461289

1290+
if _node == null:
1291+
return _code_editors.size() < _editor.get_child_count()
1292+
12471293
for o : int in _editor.get_child_count():
12481294
if get_item_text(o).begins_with(_POP_SCRIPT_PLACEHOLDER):
12491295
continue

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.4"
7+
version="0.2.4.1"
88
github="https://github.com/CodeNameTwister/Script-Spliter"
99
script="plugin.gd"

addons/script_spliter/plugin.gd

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -260,33 +260,39 @@ func _setup(input : int) -> void:
260260
func _can_add_split(path : PackedStringArray) -> bool:
261261
if !is_instance_valid(_builder):
262262
return false
263-
for x : String in path:
264-
if x.begins_with("res://"):
265-
var sc : ScriptEditor = EditorInterface.get_script_editor()
266-
return _builder.can_add_split(sc.get_current_editor().get_base_editor())
267-
else:
268-
var node : Node = get_node_or_null(x)
269-
if node:
270-
return _builder.can_add_split(node)
271-
else:
263+
if path.size() == 0:
264+
return _builder.can_add_split(null)
265+
else:
266+
for x : String in path:
267+
if x.begins_with("res://"):
272268
var sc : ScriptEditor = EditorInterface.get_script_editor()
273269
return _builder.can_add_split(sc.get_current_editor().get_base_editor())
270+
else:
271+
var node : Node = get_node_or_null(x)
272+
if node:
273+
return _builder.can_add_split(node)
274+
else:
275+
var sc : ScriptEditor = EditorInterface.get_script_editor()
276+
return _builder.can_add_split(sc.get_current_editor().get_base_editor())
274277
return false
275278

276279
func _can_remove_split(path : PackedStringArray) -> bool:
277280
if !is_instance_valid(_builder):
278281
return false
279-
for x : String in path:
280-
if x.begins_with("res://"):
281-
var sc : ScriptEditor = EditorInterface.get_script_editor()
282-
return _builder.can_remove_split(sc.get_current_editor().get_base_editor())
283-
else:
284-
var node : Node = get_node_or_null(x)
285-
if node:
286-
return _builder.can_remove_split(node)
287-
else:
282+
if path.size() == 0:
283+
return _builder.can_remove_split(null)
284+
else:
285+
for x : String in path:
286+
if x.begins_with("res://"):
288287
var sc : ScriptEditor = EditorInterface.get_script_editor()
289288
return _builder.can_remove_split(sc.get_current_editor().get_base_editor())
289+
else:
290+
var node : Node = get_node_or_null(x)
291+
if node:
292+
return _builder.can_remove_split(node)
293+
else:
294+
var sc : ScriptEditor = EditorInterface.get_script_editor()
295+
return _builder.can_remove_split(sc.get_current_editor().get_base_editor())
290296
return false
291297

292298
func _add_window_split(variant : Variant) -> void:

0 commit comments

Comments
 (0)