/// <summary> /// "Set" and returns the designdata /// this also sets up a research item for the design, /// and adds it to the factions designs. /// </summary> /// <returns></returns> public ComponentDesign CreateDesign(Entity factionEntity) { FactionInfoDB faction = factionEntity.GetDataBlob <FactionInfoDB>(); //set up the research FactionTechDB factionTech = factionEntity.GetDataBlob <FactionTechDB>(); TechSD tech = new TechSD(); tech.ID = Guid.NewGuid(); tech.Name = _design.Name + " Design Research"; tech.Description = "Research into building " + _design.Name; tech.MaxLevel = 1; tech.CostFormula = _design.ResearchCostValue.ToString(); _design.TechID = tech.ID; factionTech.MakeResearchable(tech); //add it to researchable techs EvalAll(); foreach (var designAttribute in ComponentDesignAttributes.Values) { if (designAttribute.AttributeType != null && designAttribute.IsEnabled) { if (designAttribute.AtbConstrArgs == null) { designAttribute.SetValue(); //force recalc. } object[] constructorArgs = designAttribute.AtbConstrArgs; try { dynamic attrbute = (IComponentDesignAttribute)Activator.CreateInstance(designAttribute.AttributeType, constructorArgs); _design.AttributesByType[attrbute.GetType()] = attrbute; } catch (MissingMethodException e) { string argTypes = ""; int i = 0; foreach (var arg in constructorArgs) { argTypes += arg.GetType() + ": " + constructorArgs[i].ToString() + ",\n"; i++; } string exstr = "The Attribute: " + designAttribute.AttributeType + " was found, but the arguments did not match any constructors.\nThe given arguments are:\n" + argTypes + "The full exception is as follows:\n" + e; throw new Exception(exstr); } } } faction.InternalComponentDesigns[_design.ID] = _design; faction.IndustryDesigns[_design.ID] = _design; return(_design); }
private void GatherAndUpdateData() { if (_selectedItemGuid == Guid.Empty) { return; } if (_updating) { return; } TechSD newTechSD = Data.TechData[_selectedItemGuid].StaticData; string newName = nameTextBox.Text; if (!string.IsNullOrWhiteSpace(newName)) { newTechSD.Name = newName; nameTextBox.BackColor = Color.White; } else { nameTextBox.BackColor = Color.Red; } string newDesc = descTextBox.Text; if (!string.IsNullOrWhiteSpace(newDesc)) { newTechSD.Description = newDesc; } newTechSD.Category = (ResearchCategories)categoryComboBox.SelectedItem; int newCost; if (Int32.TryParse(costTextBox.Text, out newCost) && newCost > 0) { newTechSD.CostFormula = newCost.ToString(); costTextBox.BackColor = Color.White; } else { costTextBox.BackColor = Color.Red; } List <DataHolder> requirements = requirementsListBox.Items.Cast <DataHolder>().ToList(); //newTechSD.Requirements = requirements.ConvertAll(entry => entry.Guid); Data.SaveToDataStore(newTechSD); }
private void newTechButton_Click(object sender, EventArgs e) { TechSD newTechSD = new TechSD() { Name = "New Tech", Description = "Description Here", ID = Guid.NewGuid(), CostFormula = "", Requirements = new JDictionary <Guid, int>() }; Data.SaveToDataStore(newTechSD); }
private void UpdateSelectedItem() { _updating = true; TechSD techSD; if (_selectedItemGuid == Guid.Empty) { techSD = new TechSD { Name = "Name", Description = "Description", ID = Guid.Empty, MaxLevel = 1, DataFormula = "1", Category = ResearchCategories.BiologyGenetics, Requirements = new JDictionary <Guid, int>(), CostFormula = "1000", } } ; else { techSD = Data.TechData[_selectedItemGuid].StaticData; } guidDataLabel.Text = techSD.ID.ToString(); nameTextBox.Text = techSD.Name; descTextBox.Text = techSD.Description; categoryComboBox.SelectedItem = techSD.Category; costTextBox.Text = techSD.CostFormula; requirementsListBox.BeginUpdate(); requirementsListBox.Items.Clear(); foreach (Guid requirementGuid in techSD.Requirements.Keys) { requirementsListBox.Items.Add(Data.TechData[requirementGuid]); } requirementsListBox.EndUpdate(); _updating = false; }
static void GuiHintTechSelection(ComponentDesignAttribute attribute) { if (compactmod) { ImGui.TextWrapped(attribute.Name + ": " + attribute.Description); ImGui.NewLine(); } else { ImGui.TextWrapped(attribute.Name + ":"); ImGui.SameLine(); ImGui.TextWrapped(attribute.Description); ImGui.NewLine(); } int i = 0; _techSDs = new TechSD[attribute.GuidDictionary.Count]; _techNames = new string[attribute.GuidDictionary.Count]; foreach (var kvp in attribute.GuidDictionary) { TechSD sd = StaticRefLib.StaticData.Techs[Guid.Parse((string)kvp.Key)]; _techSDs[i] = sd; _techNames[i] = sd.Name; i++; } ImGui.TextWrapped(attribute.Value.ToString()); if (ImGui.Combo("Select Tech", ref _techSelectedIndex, _techNames, _techNames.Length)) { attribute.SetValueFromGuidList(_techSDs[_techSelectedIndex].ID); } ImGui.NewLine(); }
public ComponentAbilityDesignVM(ComponentDesignVM designVM, ComponentDesignAbility designAbility, StaticDataStore staticData) { _designAbility = designAbility; _staticData = staticData; _parentDesignVM = designVM; switch (designAbility.GuiHint) { case GuiHint.GuiTechSelectionList: foreach (var kvp in designAbility.GuidDictionary) { TechSD sd = _staticData.Techs[Guid.Parse((string)kvp.Key)]; TechList.Add(sd, sd.Name); } TechList.SelectedIndex = 0; TechList.SelectionChangedEvent += TechList_SelectionChangedEvent; break; case GuiHint.GuiSelectionMaxMin: { minMaxSliderVM = new MinMaxSliderVM(); designAbility.SetMax(); designAbility.SetMin(); designAbility.SetValue(); designAbility.SetStep(); minMaxSliderVM.Name = Name; minMaxSliderVM.MaxValue = MaxValue; minMaxSliderVM.MinValue = MinValue; minMaxSliderVM.StepValue = StepValue; minMaxSliderVM.Value = Value; //.PreLoadedValue = Value; //hack due to eto bug. MinMaxSlider.Value = Value; minMaxSliderVM.PropertyChanged += MinMaxSlider_PropertyChanged; } break; } }
/// <summary> /// "Set" and returns the designdata /// this also sets up a research item for the design, /// and adds it to the factions designs. /// </summary> /// <returns></returns> public ComponentDesign CreateDesign(Entity factionEntity) { FactionInfoDB faction = factionEntity.GetDataBlob <FactionInfoDB>(); //set up the research FactionTechDB factionTech = factionEntity.GetDataBlob <FactionTechDB>(); TechSD tech = new TechSD(); tech.ID = Guid.NewGuid(); tech.Name = _design.Name + " Design Research"; tech.Description = "Research into building " + _design.Name; tech.MaxLevel = 1; tech.CostFormula = _design.ResearchCostValue.ToString(); _design.TechID = tech.ID; factionTech.MakeResearchable(tech); //add it to researchable techs SetAttributes(); faction.InternalComponentDesigns[_design.ID] = _design; faction.IndustryDesigns[_design.ID] = _design; return(_design); }
/// <summary> /// "Set" and returns the designdata /// this also sets up a research item for the design, /// and adds it to the factions designs. /// </summary> /// <returns></returns> public ComponentDesign CreateDesign(Entity factionEntity) { FactionInfoDB faction = factionEntity.GetDataBlob <FactionInfoDB>(); //set up the research FactionTechDB factionTech = factionEntity.GetDataBlob <FactionTechDB>(); TechSD tech = new TechSD(); tech.ID = Guid.NewGuid(); tech.Name = _design.Name + " Design Research"; tech.Description = "Research into building " + _design.Name; tech.MaxLevel = 1; tech.CostFormula = _design.ResearchCostValue.ToString(); _design.TechID = tech.ID; factionTech.MakeResearchable(tech); //add it to researchable techs EvalAll(); foreach (var designAttribute in ComponentDesignAttributes.Values) { if (designAttribute.DataBlobType != null) { if (designAttribute.DataBlobArgs == null) { designAttribute.SetValue(); //force recalc. } object[] constructorArgs = designAttribute.DataBlobArgs; dynamic attrbute = (IComponentDesignAttribute)Activator.CreateInstance(designAttribute.DataBlobType, constructorArgs); _design.AttributesByType.Add(attrbute.GetType(), attrbute); } } faction.InternalComponentDesigns.Add(_design.Guid, _design); return(_design); }
public ResearchTechControlVM(FactionTechDB factionTech, Guid techID) { _factionTech = factionTech; _techSD = factionTech.ResearchableTechs.Keys.First(k => k.ID == techID); }
public void TestTechSave() { Dictionary <Guid, TechSD> techs = new Dictionary <Guid, TechSD>(); TechSD enginePowerModMax = new TechSD(); enginePowerModMax.ID = new Guid("b8ef73c7-2ef0-445e-8461-1e0508958a0e"); enginePowerModMax.MaxLevel = 7; enginePowerModMax.DataFormula = "[Level] * 1.5"; enginePowerModMax.Name = "Maximum Engine Power Modifier"; enginePowerModMax.Description = ""; enginePowerModMax.Category = ResearchCategories.PowerAndPropulsion; enginePowerModMax.CostFormula = "[Level] * 1"; enginePowerModMax.Requirements = new Dictionary <Guid, int>(); techs.Add(enginePowerModMax.ID, enginePowerModMax); TechSD enginePowerModMin = new TechSD(); enginePowerModMin.ID = new Guid("08fa4c4b-0ddb-4b3a-9190-724d715694de"); enginePowerModMin.MaxLevel = 7; enginePowerModMin.DataFormula = "1.0 - [Level] * 0.05"; enginePowerModMin.Name = "Minimum Engine Power Modifier"; enginePowerModMin.Description = ""; enginePowerModMin.Category = ResearchCategories.PowerAndPropulsion; enginePowerModMin.CostFormula = "[Level] * 1"; enginePowerModMin.Requirements = new Dictionary <Guid, int>(); techs.Add(enginePowerModMin.ID, enginePowerModMin); TechSD fuelUsage = new TechSD(); fuelUsage.ID = new Guid("8557acb9-c764-44e7-8ee4-db2c2cebf0bc"); fuelUsage.MaxLevel = 12; fuelUsage.DataFormula = "1 - [Level] * 0.1"; fuelUsage.Name = "Fuel Consumption: 1 Litre per Engine Power Hour"; fuelUsage.Description = ""; fuelUsage.Category = ResearchCategories.PowerAndPropulsion; fuelUsage.CostFormula = "[Level] * 1"; fuelUsage.Requirements = new Dictionary <Guid, int>(); techs.Add(fuelUsage.ID, fuelUsage); TechSD EngineTech1 = new TechSD(); EngineTech1.ID = new Guid("35608fe6-0d65-4a5f-b452-78a3e5e6ce2c"); EngineTech1.MaxLevel = 1; EngineTech1.DataFormula = "0.2"; EngineTech1.Name = "Conventional Engine Technology"; EngineTech1.Description = ""; EngineTech1.Category = ResearchCategories.PowerAndPropulsion; EngineTech1.CostFormula = "[Level] * 500"; EngineTech1.Requirements = new Dictionary <Guid, int>(); techs.Add(EngineTech1.ID, EngineTech1); TechSD EngineTech2 = new TechSD(); EngineTech2.ID = new Guid("c827d369-3f16-43ef-b112-7d5bcafb74c7"); EngineTech2.MaxLevel = 1; EngineTech2.DataFormula = "5"; EngineTech2.Name = "Nuclear Thermal Engine Technology"; EngineTech2.Description = ""; EngineTech2.Category = ResearchCategories.PowerAndPropulsion; EngineTech2.CostFormula = "[Level] * 2500"; EngineTech2.Requirements = new Dictionary <Guid, int>(); EngineTech2.Requirements.Add(new Guid("35608fe6-0d65-4a5f-b452-78a3e5e6ce2c"), 1); techs.Add(EngineTech2.ID, EngineTech2); TechSD EngineTech3 = new TechSD(); EngineTech3.ID = new Guid("db6818f3-99e9-46c1-b903-f3af978c38b2"); EngineTech3.MaxLevel = 1; EngineTech3.DataFormula = "5"; EngineTech3.Name = "Nuclear Pulse Engine Technology"; EngineTech3.Description = ""; EngineTech3.Category = ResearchCategories.PowerAndPropulsion; EngineTech3.CostFormula = "[Level] * 5000"; EngineTech3.Requirements = new Dictionary <Guid, int>(); EngineTech3.Requirements.Add(new Guid("c827d369-3f16-43ef-b112-7d5bcafb74c7"), 1); techs.Add(EngineTech3.ID, EngineTech3); TechSD EngineTech4 = new TechSD(); EngineTech4.ID = new Guid("f3f10e56-9345-40cc-af42-342e7240355d"); EngineTech4.MaxLevel = 1; EngineTech4.DataFormula = "5"; EngineTech4.Name = "Ion Drive Technology"; EngineTech4.Description = ""; EngineTech4.Category = ResearchCategories.PowerAndPropulsion; EngineTech4.CostFormula = "[Level] * 10000";; EngineTech4.Requirements = new Dictionary <Guid, int>(); EngineTech4.Requirements.Add(new Guid("db6818f3-99e9-46c1-b903-f3af978c38b2"), 1); techs.Add(EngineTech4.ID, EngineTech4); StaticDataManager.ExportStaticData(techs, "TechnologyDataExportTest.json"); }
public ComponentDesigner(ComponentTemplateSD componentSD, FactionTechDB factionTech) { var staticData = StaticRefLib.StaticData; TypeName = componentSD.Name; Name = componentSD.Name; Description = componentSD.Description; _design.ID = Guid.NewGuid(); MassFormula = new ChainedExpression(componentSD.MassFormula, this, factionTech, staticData); VolumeFormula = new ChainedExpression(componentSD.VolumeFormula, this, factionTech, staticData); CrewFormula = new ChainedExpression(componentSD.CrewReqFormula, this, factionTech, staticData); HTKFormula = new ChainedExpression(componentSD.HTKFormula, this, factionTech, staticData); ResearchCostFormula = new ChainedExpression(componentSD.ResearchCostFormula, this, factionTech, staticData); BuildCostFormula = new ChainedExpression(componentSD.BuildPointCostFormula, this, factionTech, staticData); CreditCostFormula = new ChainedExpression(componentSD.CreditCostFormula, this, factionTech, staticData); ComponentMountType = componentSD.MountType; IndustryType = componentSD.IndustryTypeID; CargoTypeID = componentSD.CargoTypeID; _design.CargoTypeID = componentSD.CargoTypeID; if (componentSD.MountType.HasFlag(ComponentMountType.PlanetInstallation)) { _design.GuiHints = ConstructableGuiHints.CanBeInstalled; } Dictionary <Guid, ChainedExpression> resourceCostForulas = new Dictionary <Guid, ChainedExpression>(); //Dictionary<Guid, ChainedExpression> mineralCostFormulas = new Dictionary<Guid, ChainedExpression>(); //Dictionary<Guid, ChainedExpression> materalCostFormulas = new Dictionary<Guid, ChainedExpression>(); //Dictionary<Guid, ChainedExpression> componentCostForulas = new Dictionary<Guid, ChainedExpression>(); foreach (var kvp in componentSD.ResourceCostFormula) { /* * if (staticData.CargoGoods.IsMaterial(kvp.Key)) * { * materalCostFormulas.Add(kvp.Key, new ChainedExpression(kvp.Value, this, factionTech, staticData)); * } * else if (staticData.ComponentTemplates.ContainsKey(kvp.Key)) * { * componentCostForulas.Add(kvp.Key, new ChainedExpression(kvp.Value, this, factionTech, staticData)); * } * else if (staticData.CargoGoods.IsMineral(kvp.Key)) * { * mineralCostFormulas.Add(kvp.Key, new ChainedExpression(kvp.Value, this, factionTech, staticData)); * } * else //TODO: log don't crash. * throw new Exception("GUID object {" + kvp.Key + "} not found in materialCosting for " + this.TypeName + " This object needs to be either a mineral, material or component defined in the Data folder"); * */ if (staticData.CargoGoods.GetAny(kvp.Key) != null) { resourceCostForulas.Add(kvp.Key, new ChainedExpression(kvp.Value, this, factionTech)); } else //TODO: log don't crash. { throw new Exception("GUID object {" + kvp.Key + "} not found in resourceCosting for " + this.TypeName + " This object needs to be either a mineral, material or component defined in the Data folder"); } } ResourceCostFormulas = resourceCostForulas; //MineralCostFormulas = mineralCostFormulas; // MaterialCostFormulas = materalCostFormulas; //ComponentCostFormulas = componentCostForulas; foreach (ComponentTemplateAbilitySD abilitySD in componentSD.ComponentAbilitySDs) { ComponentDesignAttribute designAttribute = new ComponentDesignAttribute(this); if (abilitySD.Name == null) //TODO: Log this, and don't use this component instead of throwing. { throw new Exception("Bad Static Data. Ability name is null"); } designAttribute.Name = abilitySD.Name; designAttribute.Description = abilitySD.Description; designAttribute.GuiHint = abilitySD.GuiHint; if (abilitySD.AbilityFormula != null) { designAttribute.Formula = new ChainedExpression(abilitySD.AbilityFormula, designAttribute, factionTech, staticData); } if (abilitySD.GuidDictionary != null) { designAttribute.GuidDictionary = new Dictionary <object, ChainedExpression>(); if (designAttribute.GuiHint == GuiHint.GuiTechSelectionList) { foreach (var kvp in abilitySD.GuidDictionary) { if (factionTech.ResearchedTechs.ContainsKey(Guid.Parse(kvp.Key.ToString()))) { TechSD techSD = staticData.Techs[Guid.Parse(kvp.Key.ToString())]; designAttribute.GuidDictionary.Add(kvp.Key, new ChainedExpression(ResearchProcessor.DataFormula(factionTech, techSD).ToString(), designAttribute, factionTech, staticData)); } } } else { foreach (var kvp in abilitySD.GuidDictionary) { designAttribute.GuidDictionary.Add(kvp.Key, new ChainedExpression(kvp.Value, designAttribute, factionTech, staticData)); } } } if (designAttribute.GuiHint == GuiHint.GuiSelectionMaxMin) { designAttribute.MaxValueFormula = new ChainedExpression(abilitySD.MaxFormula, designAttribute, factionTech, staticData); designAttribute.MinValueFormula = new ChainedExpression(abilitySD.MinFormula, designAttribute, factionTech, staticData); designAttribute.StepValueFormula = new ChainedExpression(abilitySD.StepFormula, designAttribute, factionTech, staticData); } if (abilitySD.AbilityDataBlobType != null) { designAttribute.DataBlobType = Type.GetType(abilitySD.AbilityDataBlobType); } ComponentDesignAttributes.Add(designAttribute.Name, designAttribute); //TODO: get rid of this once json data is rewritten to use names instead of indexes ComponentDesignAttributeList.Add(designAttribute); } EvalAll(); }
internal override void Display() { if (IsActive && ImGui.Begin(_windowname, ref IsActive, _flags)) { GuiDesignUI(); //Part design GuiCostText(); //Print cost ImGui.End(); } void GuiDesignUI()//Creates all UI elements need for designing the Component { ImGui.Text("Component Specifications"); ImGui.SameLine(ImGui.GetWindowWidth() - 70); if (ImGui.Button("Compact")) { compactmod = !compactmod; } ImGui.NewLine(); if (_componentDesigner != null) //Make sure comp is selected { foreach (ComponentDesignAttribute attribute in _componentDesigner.ComponentDesignAttributes.Values) //For each property of the comp type { ImGui.PushID(attribute.Name); if (attribute.IsEnabled) { switch (attribute.GuiHint) //Either { case GuiHint.None: break; case GuiHint.GuiTechSelectionList: //Let the user pick a type from a list GuiHintTechSelection(attribute); break; case GuiHint.GuiSelectionMaxMin: //Set a value GuiHintMaxMin(attribute); break; case GuiHint.GuiTextDisplay: //Display a stat GuiHintText(attribute); break; case GuiHint.GuiEnumSelectionList: //Let the user pick a type from a hard coded list GuiHintEnumSelection(attribute); break; case GuiHint.GuiOrdnanceSelectionList: GuiHintOrdnanceSelection(attribute); break; default: throw new ArgumentOutOfRangeException(); } } ImGui.PopID(); } ImGui.Text("Name"); ImGui.InputText("", _nameInputBuffer, 32); if (ImGui.Button("Create Design")) { _componentDesigner.Name = ImGuiSDL2CSHelper.StringFromBytes(_nameInputBuffer); _componentDesigner.CreateDesign(_state.Faction); //we reset the designer here, so we don't end up trying to edit the precious design. var factionTech = _state.Faction.GetDataBlob <FactionTechDB>(); _componentDesigner = new ComponentDesigner(_designables[_designType], factionTech); } ImGui.NewLine(); } else//Tell the user they don't have a comp type selected { ImGui.NewLine(); ImGui.Text("No component type selected"); ImGui.NewLine(); } } void GuiCostText()//Prints a 2 col table with the costs of the part { //ImGui.BeginChild("Cost"); if (_componentDesigner != null)//If a part time is selected { ImGui.Columns(2); ImGui.BeginTabItem("Cost"); ImGui.Text("Mass"); ImGui.Text("Volume_km3"); ImGui.Text("Crew Requred"); ImGui.Text("Cost"); ImGui.Text("Research Cost"); ImGui.Text("Build Cost"); ImGui.Text("Resource Costs"); ImGui.NextColumn();//Add all the cost names to col 1 ImGui.Text(Stringify.Mass(_componentDesigner.MassValue)); ImGui.Text(Stringify.Volume(_componentDesigner.VolumeM3Value)); ImGui.Text(_componentDesigner.CrewReqValue.ToString()); ImGui.Text(_componentDesigner.CreditCostValue.ToString()); ImGui.Text(_componentDesigner.ResearchCostValue.ToString() + " RP"); ImGui.Text(_componentDesigner.IndustryPointCostsValue.ToString() + " BP"); ImGui.NextColumn();//Add all the price values to col 2 foreach (var kvp in _componentDesigner.ResourceCostValues) { var resource = StaticRefLib.StaticData.CargoGoods.GetAny(kvp.Key); if (resource == null) { resource = (ICargoable)_state.Faction.GetDataBlob <FactionInfoDB>().IndustryDesigns[kvp.Key]; } var xpos = ImGui.GetCursorPosX(); ImGui.SetCursorPosX(xpos + 12); ImGui.Text(resource.Name); ImGui.NextColumn(); ImGui.Text(kvp.Value.ToString()); ImGui.NextColumn(); } } //ImGui.EndChild(); } void GuiHintText(ComponentDesignAttribute attribute) { if (compactmod) { ImGui.TextWrapped(attribute.Name + ": " + attribute.Value.ToString() + " " + attribute.Unit); ImGui.NewLine(); } else { ImGui.TextWrapped(attribute.Name + ":"); ImGui.SameLine(); ImGui.TextWrapped(attribute.Value.ToString() + " " + attribute.Unit); ImGui.NewLine(); } } void GuiHintMaxMin(ComponentDesignAttribute attribute) { if (compactmod) { ImGui.TextWrapped(attribute.Name + ": " + attribute.Description); ImGui.NewLine(); } else { ImGui.TextWrapped(attribute.Name + ":"); ImGui.SameLine(); ImGui.TextWrapped(attribute.Description); ImGui.NewLine(); } attribute.SetMax(); attribute.SetMin(); attribute.SetValue(); attribute.SetStep(); var max = attribute.MaxValue; var min = attribute.MinValue; double val = attribute.Value; double step = attribute.StepValue; double fstep = step * 10; IntPtr valPtr; IntPtr maxPtr; IntPtr minPtr; IntPtr stepPtr; IntPtr fstepPtr; unsafe { valPtr = new IntPtr(&val); maxPtr = new IntPtr(&max); minPtr = new IntPtr(&min); stepPtr = new IntPtr(&step); fstepPtr = new IntPtr(&fstep); } //ImGui.DragScalar("##slider" + attribute.Name, ImGuiDataType.Double, valPtr, 1f, minPtr, maxPtr); if (compactmod) { } else { ImGui.PushItemWidth(-1); if (ImGui.SliderScalar("##scaler" + attribute.Name, ImGuiDataType.Double, valPtr, minPtr, maxPtr)) { attribute.SetValueFromInput(val); } } ImGui.PushItemWidth(-1); if (ImGui.InputScalar("##input" + attribute.Name, ImGuiDataType.Double, valPtr, stepPtr, fstepPtr)) { attribute.SetValueFromInput(val); } ImGui.NewLine(); } void GuiHintTechSelection(ComponentDesignAttribute attribute) { if (compactmod) { ImGui.TextWrapped(attribute.Name + ": " + attribute.Description); ImGui.NewLine(); } else { ImGui.TextWrapped(attribute.Name + ":"); ImGui.SameLine(); ImGui.TextWrapped(attribute.Description); ImGui.NewLine(); } int i = 0; _techSDs = new TechSD[attribute.GuidDictionary.Count]; _techNames = new string[attribute.GuidDictionary.Count]; foreach (var kvp in attribute.GuidDictionary) { TechSD sd = StaticRefLib.StaticData.Techs[Guid.Parse((string)kvp.Key)]; _techSDs[i] = sd; _techNames[i] = sd.Name; i++; } ImGui.TextWrapped(attribute.Value.ToString()); if (ImGui.Combo("Select Tech", ref _techSelectedIndex, _techNames, _techNames.Length)) { attribute.SetValueFromGuidList(_techSDs[_techSelectedIndex].ID); } ImGui.NewLine(); } void GuiHintEnumSelection(ComponentDesignAttribute attribute) { if (compactmod) { ImGui.TextWrapped(attribute.Name + ": " + attribute.Description); ImGui.NewLine(); } else { ImGui.TextWrapped(attribute.Name + ":"); ImGui.SameLine(); ImGui.TextWrapped(attribute.Description); ImGui.NewLine(); } int i = 0; //_techSDs = new TechSD[attribute.GuidDictionary.Count]; _listNames = Enum.GetNames(attribute.EnumType); ImGui.TextWrapped(attribute.Value.ToString()); if (ImGui.Combo("Select", ref attribute.ListSelection, _listNames, (int)attribute.MaxValue + 1)) { int enumVal = (int)Enum.Parse(attribute.EnumType, _listNames[attribute.ListSelection]); attribute.SetValueFromInput(enumVal); } ImGui.NewLine(); } void GuiHintOrdnanceSelection(ComponentDesignAttribute attribute) { var dict = _state.Faction.GetDataBlob <FactionInfoDB>().MissileDesigns; _listNames = new string[dict.Count]; OrdnanceDesign[] ordnances = new OrdnanceDesign[dict.Count]; int i = 0; foreach (var kvp in dict) { _listNames[i] = kvp.Value.Name; ordnances[i] = kvp.Value; } if (compactmod) { ImGui.TextWrapped(attribute.Name + ": " + attribute.Description); ImGui.NewLine(); } else { ImGui.TextWrapped(attribute.Name + ":"); ImGui.SameLine(); ImGui.TextWrapped(attribute.Description); ImGui.NewLine(); } ImGui.TextWrapped(attribute.Value.ToString()); if (ImGui.Combo("Select", ref attribute.ListSelection, _listNames, _listNames.Length)) { attribute.SetValueFromComponentList(ordnances[attribute.ListSelection].ID); } ImGui.NewLine(); } }