Browse Source

feat: config-importer.tscn

LanzaSchneider 1 năm trước cách đây
mục cha
commit
6c7afc8b9c
3 tập tin đã thay đổi với 60 bổ sung8 xóa
  1. 2 0
      editor/.gitignore
  2. 45 0
      editor/config-importer.tscn
  3. 13 8
      tblext.gd

+ 2 - 0
editor/.gitignore

@@ -0,0 +1,2 @@
+*.ini
+!.gitignore

+ 45 - 0
editor/config-importer.tscn

@@ -0,0 +1,45 @@
+[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():
+	print(_config_path)
+"
+
+[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"]

+ 13 - 8
tblext.gd

@@ -1,8 +1,13 @@
-@tool
-extends EditorPlugin
-
-func _enter_tree():
-	pass
-
-func _exit_tree():
-	pass
+@tool
+extends EditorPlugin
+
+func _enter_tree() -> void:
+	_setup_panel(preload('editor/config-importer.tscn'))
+
+func _setup_panel(prefab:PackedScene):
+	var panel := prefab.instantiate()
+	panel.set('path', prefab.resource_path.get_base_dir())
+	add_control_to_dock(EditorPlugin.DOCK_SLOT_LEFT_BR, panel)
+	tree_exiting.connect(func():
+		remove_control_from_docks(panel)
+		panel.queue_free())