diff --git a/Pulsar4X/Pulsar4X.Client/ModFileEditing/BluePrintsUI.cs b/Pulsar4X/Pulsar4X.Client/ModFileEditing/BluePrintsUI.cs index 9ad2985db..f18899663 100644 --- a/Pulsar4X/Pulsar4X.Client/ModFileEditing/BluePrintsUI.cs +++ b/Pulsar4X/Pulsar4X.Client/ModFileEditing/BluePrintsUI.cs @@ -22,12 +22,14 @@ public abstract class BluePrintsUI private protected string[] _cargoTypes; private protected string[] _techCatTypes; private protected string[] _techTypes; + private protected string[] _industryTypes; protected BluePrintsUI(ModDataStore modDataStore) { _modDataStore = modDataStore; _cargoTypes = modDataStore.CargoTypes.Keys.ToArray(); _techCatTypes = modDataStore.TechCategories.Keys.ToArray(); _techTypes = modDataStore.Techs.Keys.ToArray(); + _industryTypes = modDataStore.IndustryTypes.Keys.ToArray(); } public abstract void Display(); @@ -291,68 +293,88 @@ public void DisplayEditorWindow(int selectedIndex) ImGui.Columns(2); ImGui.SetColumnWidth(0, 100); ImGui.SetColumnWidth(1, 300); + + ImGui.Text("Name: "); ImGui.NextColumn(); - editStr = selectedItem.Name; if (TextEditWidget.Display("##name" + selectedItem.Name, ref editStr)) { selectedItem.Name = editStr; } - ImGui.NextColumn(); ImGui.Text("ComponentType: "); ImGui.NextColumn(); editStr = selectedItem.ComponentType; - if (TextEditWidget.Display("##ct" + selectedItem.ComponentType, ref editStr)) + if (TextEditWidget.Display("##cmpt" + selectedItem.ComponentType, ref editStr)) { selectedItem.Name = editStr; } - ImGui.NextColumn(); + ImGui.Text("CargoType: "); ImGui.NextColumn(); - editStr = selectedItem.CargoTypeID; - if (SelectFromListWiget.Display("##cgt" + selectedItem.CargoTypeID, _cargoTypes, ref editIndex)) + editIndex = Array.IndexOf(_cargoTypes, selectedItem.CargoTypeID); + if (SelectFromListWiget.Display("##cgot" + selectedItem.CargoTypeID, _cargoTypes, ref editIndex)) { selectedItem.Name = _cargoTypes[editIndex]; } - ImGui.NextColumn(); + + ImGui.Text("Fomula: "); + ImGui.NextColumn(); + var editDicf = selectedItem.Formulas; + if (DictEditWidget.Display("##fmula", ref editDicf)) + { + selectedItem.Formulas = editDicf; + } + ImGui.NextColumn(); + + ImGui.Text("ResourceCosts: "); ImGui.NextColumn(); var editDic = selectedItem.ResourceCost; - if (DictEditWidget.Display("##cgt", ref editDic)) + if (DictEditWidget.Display("##resc", ref editDic)) { selectedItem.ResourceCost = editDic; } + ImGui.NextColumn(); + + + ImGui.Text("IndustryType: "); + ImGui.NextColumn(); + editIndex = Array.IndexOf(_industryTypes, selectedItem.IndustryTypeID); + if (SelectFromListWiget.Display("##indt" + selectedItem.IndustryTypeID, _industryTypes, ref editIndex)) + { + selectedItem.IndustryTypeID = _industryTypes[editIndex]; + } + ImGui.NextColumn(); + + + ImGui.Text("MountType: "); + ImGui.NextColumn(); + string[] mountTypes = Enum.GetNames(typeof(ComponentMountType)); + editIndex = Array.IndexOf(_industryTypes, selectedItem.MountType); + if (SelectFromListWiget.Display("##mntt" + selectedItem.IndustryTypeID, mountTypes, ref editIndex)) + { + if(Enum.TryParse(typeof(ComponentMountType), mountTypes[editIndex], out var mtype)) + selectedItem.MountType = (ComponentMountType)mtype; + } ImGui.NextColumn(); + /* - ImGui.Text("ResourceCosts: "); - ImGui.SameLine(); - ImGui.Text(selected.ResourceCost.ToString()); - - ImGui.Text("IndustryType: "); - ImGui.SameLine(); - ImGui.Text(selected.IndustryTypeID); ImGui.Text("Attributes: "); ImGui.SameLine(); ImGui.Text(selected.Attributes.ToString()); - ImGui.Text("Formulas: "); - ImGui.SameLine(); - ImGui.Text(selected.Formulas.ToString()); - - ImGui.Text("MountType: "); - ImGui.SameLine(); - ImGui.Text(selected.MountType.ToString()); */ + ImGui.End(); } } } \ No newline at end of file diff --git a/Pulsar4X/Pulsar4X.Client/ModFileEditing/EditorWidgets.cs b/Pulsar4X/Pulsar4X.Client/ModFileEditing/EditorWidgets.cs index c6b16cf56..aac2abe4c 100644 --- a/Pulsar4X/Pulsar4X.Client/ModFileEditing/EditorWidgets.cs +++ b/Pulsar4X/Pulsar4X.Client/ModFileEditing/EditorWidgets.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Numerics; using ImGuiNET; using ImGuiSDL2CS; @@ -83,13 +84,13 @@ public static class DictEditWidget private static uint _buffSize = 128; private static byte[] _strInputBuffer = new byte[128]; private static int _techIndex = 0; - + private static int _addnum = -1; public static bool Display(string label, ref Dictionary> dict, string[] techs) { ImGui.BeginChild("##dic"); ImGui.Columns(2); bool isChanged = false; - int addnum = -1; + _addnum = -1; foreach (var kvp in dict) { _editInt = kvp.Key; @@ -133,14 +134,14 @@ public static bool Display(string label, ref Dictionary> dict, } else { - addnum = dict.Keys.Count; - while (dict.ContainsKey(addnum)) - addnum++; + _addnum = dict.Keys.Count; + while (dict.ContainsKey(_addnum)) + _addnum++; _editingID = null; } } - if(addnum > -1) //do this here so we don't add in the middle of foreach - dict.Add(addnum, new List()); + if(_addnum > -1) //do this here so we don't add in the middle of foreach + dict.Add(_addnum, new List()); ImGui.EndChild(); return isChanged; @@ -148,30 +149,31 @@ public static bool Display(string label, ref Dictionary> dict, public static bool Display(string label, ref Dictionary dict) { - ImGui.BeginChild("##dic"); + ImGui.BeginChild("##dic" + label, new Vector2(400,160), true); ImGui.Columns(2); bool isChanged = false; + _addnum = -1; foreach (var kvp in dict) { _editStr = kvp.Key; - if (TextEditWidget.Display(label + _editInt, ref _editStr)) + if (TextEditWidget.Display(label + kvp.Key + "k", ref _editStr)) { isChanged = true; if(!dict.ContainsKey(_editStr)) dict.Add(_editStr,kvp.Value); } ImGui.NextColumn(); - //values list - + + //values _editStr = kvp.Value; - if(TextEditWidget.Display(label+kvp.Value, ref _editStr)) + if(TextEditWidget.Display(label+kvp.Key + "v", ref _editStr)) { dict[kvp.Key] = _editStr; } - ImGui.NextColumn(); } - + ImGui.Columns(0); + ImGui.NewLine(); ImGui.EndChild(); return isChanged;