12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- [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()
- const _config_section := 'CONFIG'
- func _enter_tree() -> void:
- _config_path = path.path_join('config-importer.ini')
- _config.load(_config_path)
- $config_path.text = _config.get_value(_config_section, 'config_path', '')
- func _exit_tree() -> void:
- _config_save()
- func _config_save() -> void:
- _config.set_value(_config_section, 'config_path', $config_path.text)
- _config.save(_config_path)
- func _on_import_perform_button_down() -> void:
- var dir_access := DirAccess.open($config_path.text)
- for config_type in dir_access.get_directories():
- var config_type_dir: String = $config_path.text.path_join(config_type)
- var config_dir_access := DirAccess.open(config_type_dir)
- for config_file in config_dir_access.get_files():
- if config_file.get_extension() != 'csv':
- continue
- var file_access := FileAccess.open(config_type_dir.path_join(config_file), FileAccess.READ)
- while !file_access.eof_reached():
- var line := file_access.get_csv_line()
- print(line)
- "
- [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")
- [node name="config_path" type="LineEdit" parent="."]
- layout_mode = 2
- placeholder_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"]
|