Initial Commit
This commit is contained in:
commit
48a5e71e00
1136 changed files with 64347 additions and 0 deletions
93
addons/script_splitter/plugin.gd
Normal file
93
addons/script_splitter/plugin.gd
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
@tool
|
||||
extends EditorPlugin
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
# Script Splitter
|
||||
# https://github.com/CodeNameTwister/Script-Splitter
|
||||
#
|
||||
# Script Splitter addon for godot 4
|
||||
# author: "Twister"
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
|
||||
|
||||
const InputTool = preload("core/Input.gd")
|
||||
const TWISTER_script_splitter = preload("core/builder.gd")
|
||||
var builder : TWISTER_script_splitter = null
|
||||
var handler : InputTool = null
|
||||
|
||||
var tab_container : Node = null:
|
||||
get:
|
||||
if !is_instance_valid(tab_container):
|
||||
var script_editor: ScriptEditor = EditorInterface.get_script_editor()
|
||||
tab_container = find(script_editor, "*", "TabContainer")
|
||||
return tab_container
|
||||
var item_list : Node = null:
|
||||
get:
|
||||
if !is_instance_valid(item_list):
|
||||
var script_editor: ScriptEditor = EditorInterface.get_script_editor()
|
||||
item_list = find(script_editor, "*", "ItemList")
|
||||
return item_list
|
||||
|
||||
func find(root : Node, pattern : String, type : String) -> Node:
|
||||
var e : Array[Node] = root.find_children(pattern, type, true, false)
|
||||
if e.size() > 0:
|
||||
return e[0]
|
||||
return null
|
||||
|
||||
func _enter_tree() -> void:
|
||||
add_to_group(&"__SCRIPT_SPLITTER__")
|
||||
builder = TWISTER_script_splitter.new()
|
||||
handler = InputTool.new(self, builder)
|
||||
|
||||
func script_split() -> void:
|
||||
handler.get_honey_splitter().split()
|
||||
|
||||
func script_merge(value : Node = null) -> void:
|
||||
handler.get_honey_splitter().merge(value)
|
||||
|
||||
func _ready() -> void:
|
||||
set_process(false)
|
||||
set_process_input(false)
|
||||
for __ : int in range(5):
|
||||
await Engine.get_main_loop().process_frame
|
||||
if is_instance_valid(builder):
|
||||
builder.init_1(self, tab_container, item_list)
|
||||
if is_instance_valid(handler):
|
||||
handler.init_1()
|
||||
|
||||
builder.connect_callbacks(
|
||||
handler.add_column,
|
||||
handler.add_row,
|
||||
handler.remove_column,
|
||||
handler.remove_row,
|
||||
handler.left_tab_close,
|
||||
handler.right_tab_close,
|
||||
handler.others_tab_close
|
||||
)
|
||||
|
||||
func _save_external_data() -> void:
|
||||
builder.refresh_warnings()
|
||||
|
||||
func remove_from_control(control : Node) -> void:
|
||||
builder.reset_by_control(control)
|
||||
|
||||
func _exit_tree() -> void:
|
||||
remove_from_group(&"__SCRIPT_SPLITTER__")
|
||||
for x : Variant in [handler, builder]:
|
||||
if is_instance_valid(x) and x is Object:
|
||||
x.call(&"init_0")
|
||||
|
||||
func get_builder() -> Object:
|
||||
return builder
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
builder.update(delta)
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if handler.event(event):
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
func _io_call(id : StringName) -> void:
|
||||
builder.handle(id)
|
||||
|
||||
func move_item_container(container : TabContainer, from : int, to : int) -> void:
|
||||
builder.get_editor_manager().move_item_container(container, from, to)
|
||||
Loading…
Add table
Add a link
Reference in a new issue