From 526124f64d7fa9078a1621d5ed5cf5c2160f4df6 Mon Sep 17 00:00:00 2001 From: se5a Date: Mon, 24 Jun 2024 18:45:14 +1200 Subject: [PATCH] Added ability to add and remove datafiles to the list in ModInfo. --- .../ModFileEditing/ModInfoUI.cs | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/Pulsar4X/Pulsar4X.Client/ModFileEditing/ModInfoUI.cs b/Pulsar4X/Pulsar4X.Client/ModFileEditing/ModInfoUI.cs index 585e28a9e..cb59821d7 100644 --- a/Pulsar4X/Pulsar4X.Client/ModFileEditing/ModInfoUI.cs +++ b/Pulsar4X/Pulsar4X.Client/ModFileEditing/ModInfoUI.cs @@ -111,7 +111,8 @@ public void Display(string label) } } } - + + private static bool _showLoadFileDialogDatafiles = false; public void DisplayEditorWindow(int selectedIndex) { if(!_isActive[selectedIndex]) @@ -122,6 +123,8 @@ public void DisplayEditorWindow(int selectedIndex) string version = selectedItem.Version; string modDir = selectedItem.ModDirectory; string nameSpace = selectedItem.Namespace; + int removeDatafileIndex = -1; + if (ImGui.Begin("Tech Category Editor: " + name, ref _isActive[selectedIndex])) { ImGui.Columns(2); @@ -171,11 +174,31 @@ public void DisplayEditorWindow(int selectedIndex) ImGui.NextColumn(); ImGui.Text("DataFiles: "); ImGui.NextColumn(); + int datafileIndex = 0; foreach (var dataFile in selectedItem.DataFiles) { ImGui.Text(dataFile); + ImGui.SameLine(); + if (ImGui.SmallButton("X##datafileRemove" + datafileIndex)) + { + removeDatafileIndex = datafileIndex; + } + + datafileIndex++; + } + if (ImGui.Button("Add Datafile")) + { + _showLoadFileDialogDatafiles = true; + } + if (removeDatafileIndex > -1) + { + selectedItem.DataFiles.RemoveAt(removeDatafileIndex); + } + + if (_showLoadFileDialogDatafiles && (FileDialog.DisplayLoad(ref _fileDialogPath, ref _fileName, ref _showLoadFileDialogDatafiles))) + { + selectedItem.DataFiles.Add(_fileName); } - //selectedItem.DataFiles ImGui.End(); } }