|
@@ -1,115 +0,0 @@
|
|
-[gd_scene load_steps=2 format=3 uid="uid://c7m7hu5uvgbit"]
|
|
|
|
-
|
|
|
|
-[sub_resource type="GDScript" id="GDScript_d7xax"]
|
|
|
|
-script/source = "@tool
|
|
|
|
-extends Control
|
|
|
|
-
|
|
|
|
-var path: String
|
|
|
|
-var _config_path: String
|
|
|
|
-var _config := ConfigFile.new()
|
|
|
|
-var _task: Thread
|
|
|
|
-
|
|
|
|
-@export_file('*.rb')
|
|
|
|
-var _tool_file: String
|
|
|
|
-
|
|
|
|
-const _config_section := 'CONFIG'
|
|
|
|
-
|
|
|
|
-func _enter_tree() -> void:
|
|
|
|
- if path.is_empty():
|
|
|
|
- return
|
|
|
|
- _config_path = path.path_join('config-importer.ini')
|
|
|
|
- _config.load(_config_path)
|
|
|
|
- $config_path.text = _config.get_value(_config_section, 'config_path', '')
|
|
|
|
- $output_path.text = _config.get_value(_config_section, 'output_path', '')
|
|
|
|
- $generate_code_path.text = _config.get_value(_config_section, 'generate_code_path', '')
|
|
|
|
- $generate_text_path.text = _config.get_value(_config_section, 'generate_text_path', '')
|
|
|
|
- $generate_field_info.button_pressed = _config.get_value(_config_section, 'generate_field_info', true)
|
|
|
|
-
|
|
|
|
-func _exit_tree() -> void:
|
|
|
|
- if path.is_empty():
|
|
|
|
- return
|
|
|
|
- _config_save()
|
|
|
|
-
|
|
|
|
-func _config_save() -> void:
|
|
|
|
- _config.set_value(_config_section, 'config_path', $config_path.text)
|
|
|
|
- _config.set_value(_config_section, 'output_path', $output_path.text)
|
|
|
|
- _config.set_value(_config_section, 'generate_code_path', $generate_code_path.text)
|
|
|
|
- _config.set_value(_config_section, 'generate_text_path', $generate_text_path.text)
|
|
|
|
- _config.set_value(_config_section, 'generate_field_info', $generate_field_info.button_pressed)
|
|
|
|
- _config.save(_config_path)
|
|
|
|
-
|
|
|
|
-func _process(delta) -> void:
|
|
|
|
- if _task == null || !_task.is_alive():
|
|
|
|
- if _task != null && !_task.is_alive():
|
|
|
|
- _task.wait_to_finish()
|
|
|
|
- _task = null
|
|
|
|
- scale = Vector2.ONE
|
|
|
|
-
|
|
|
|
-func _setup_task(task:Callable) -> void:
|
|
|
|
- scale = Vector2.ZERO
|
|
|
|
- _task = Thread.new()
|
|
|
|
- _task.start(task)
|
|
|
|
-
|
|
|
|
-func _recreate_dir(full_path:String) -> void:
|
|
|
|
- if DirAccess.dir_exists_absolute(full_path):
|
|
|
|
- OS.move_to_trash(full_path)
|
|
|
|
- DirAccess.make_dir_recursive_absolute(full_path)
|
|
|
|
-
|
|
|
|
-func _on_import_perform_button_down() -> void:
|
|
|
|
- _setup_task(perform)
|
|
|
|
-
|
|
|
|
-func perform():
|
|
|
|
- var full_output_path := ProjectSettings.globalize_path($output_path.text)
|
|
|
|
- var full_gen_code_path := ProjectSettings.globalize_path($generate_code_path.text)
|
|
|
|
- var full_gen_text_path := ProjectSettings.globalize_path($generate_text_path.text)
|
|
|
|
- var params: PackedStringArray = [
|
|
|
|
- ProjectSettings.globalize_path(_tool_file),
|
|
|
|
- ProjectSettings.globalize_path($config_path.text),
|
|
|
|
- ProjectSettings.globalize_path($output_path.text),
|
|
|
|
- full_gen_code_path,
|
|
|
|
- full_gen_text_path,
|
|
|
|
- $generate_field_info.button_pressed
|
|
|
|
- ]
|
|
|
|
- for i in range(0, len(params)):
|
|
|
|
- params[i] = ('\"' + params[i] + '\"').strip_edges()
|
|
|
|
- _recreate_dir(full_output_path)
|
|
|
|
- _recreate_dir(full_gen_code_path)
|
|
|
|
- _recreate_dir(full_gen_text_path)
|
|
|
|
- OS.execute('ruby', params)
|
|
|
|
-"
|
|
|
|
-
|
|
|
|
-[node name="配置" type="VBoxContainer"]
|
|
|
|
-anchors_preset = 15
|
|
|
|
-anchor_right = 1.0
|
|
|
|
-anchor_bottom = 1.0
|
|
|
|
-grow_horizontal = 2
|
|
|
|
-grow_vertical = 2
|
|
|
|
-script = SubResource("GDScript_d7xax")
|
|
|
|
-_tool_file = "res://addons/godot-TBL-extension-base/editor/tools/config-importer.rb"
|
|
|
|
-
|
|
|
|
-[node name="config_path" type="LineEdit" parent="."]
|
|
|
|
-layout_mode = 2
|
|
|
|
-placeholder_text = "配置路径"
|
|
|
|
-
|
|
|
|
-[node name="output_path" type="LineEdit" parent="."]
|
|
|
|
-layout_mode = 2
|
|
|
|
-placeholder_text = "ini 生成路径"
|
|
|
|
-
|
|
|
|
-[node name="generate_code_path" type="LineEdit" parent="."]
|
|
|
|
-layout_mode = 2
|
|
|
|
-placeholder_text = "代码生成路径"
|
|
|
|
-
|
|
|
|
-[node name="generate_text_path" type="LineEdit" parent="."]
|
|
|
|
-layout_mode = 2
|
|
|
|
-placeholder_text = "文本表生成路径"
|
|
|
|
-
|
|
|
|
-[node name="generate_field_info" type="CheckBox" parent="."]
|
|
|
|
-layout_mode = 2
|
|
|
|
-button_pressed = true
|
|
|
|
-text = "生成所有字段注释"
|
|
|
|
-
|
|
|
|
-[node name="import_perform" type="Button" parent="."]
|
|
|
|
-layout_mode = 2
|
|
|
|
-text = "读取表格生成配置"
|
|
|
|
-
|
|
|
|
-[connection signal="button_down" from="import_perform" to="." method="_on_import_perform_button_down"]
|
|
|