config-importer.tscn 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. [gd_scene load_steps=2 format=3 uid="uid://c7m7hu5uvgbit"]
  2. [sub_resource type="GDScript" id="GDScript_d7xax"]
  3. script/source = "@tool
  4. extends Control
  5. var path: String
  6. var _config_path: String
  7. var _config := ConfigFile.new()
  8. const _config_section := 'CONFIG'
  9. func _enter_tree() -> void:
  10. _config_path = path.path_join('config-importer.ini')
  11. _config.load(_config_path)
  12. $config_path.text = _config.get_value(_config_section, 'config_path', '')
  13. func _exit_tree() -> void:
  14. _config_save()
  15. func _config_save() -> void:
  16. _config.set_value(_config_section, 'config_path', $config_path.text)
  17. _config.save(_config_path)
  18. func _on_import_perform_button_down() -> void:
  19. var dir_access := DirAccess.open($config_path.text)
  20. for config_type in dir_access.get_directories():
  21. var config_type_dir: String = $config_path.text.path_join(config_type)
  22. var config_dir_access := DirAccess.open(config_type_dir)
  23. for config_file in config_dir_access.get_files():
  24. if config_file.get_extension() != 'csv':
  25. continue
  26. var file_access := FileAccess.open(config_type_dir.path_join(config_file), FileAccess.READ)
  27. while !file_access.eof_reached():
  28. var line := file_access.get_csv_line()
  29. print(line)
  30. "
  31. [node name="配置" type="VBoxContainer"]
  32. anchors_preset = 15
  33. anchor_right = 1.0
  34. anchor_bottom = 1.0
  35. grow_horizontal = 2
  36. grow_vertical = 2
  37. script = SubResource("GDScript_d7xax")
  38. [node name="config_path" type="LineEdit" parent="."]
  39. layout_mode = 2
  40. placeholder_text = "配置路径"
  41. [node name="import_perform" type="Button" parent="."]
  42. layout_mode = 2
  43. text = "读取表格生成配置"
  44. [connection signal="button_down" from="import_perform" to="." method="_on_import_perform_button_down"]