Skip to content

Commit

Permalink
Added ability to add and remove datafiles to the list in ModInfo.
Browse files Browse the repository at this point in the history
  • Loading branch information
se5a committed Jun 24, 2024
1 parent 92c3507 commit 526124f
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions Pulsar4X/Pulsar4X.Client/ModFileEditing/ModInfoUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ public void Display(string label)
}
}
}


private static bool _showLoadFileDialogDatafiles = false;
public void DisplayEditorWindow(int selectedIndex)
{
if(!_isActive[selectedIndex])
Expand All @@ -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);
Expand Down Expand Up @@ -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();
}
}
Expand Down

0 comments on commit 526124f

Please sign in to comment.