public void Display() { var width = ImGui.GetWindowWidth() * 0.5f; ImGui.BeginChild(_entityState.Name, new System.Numerics.Vector2(240, 200), true, ImGuiWindowFlags.AlwaysAutoResize); foreach (var typeStore in _stores) { CargoTypeSD stype = _staticData.CargoTypes[typeStore.Key]; var freeVolume = typeStore.Value.FreeVolume; var maxVolume = typeStore.Value.MaxVolume; var storedVolume = maxVolume - freeVolume; string headerText = stype.Name + " " + Stringify.Volume(freeVolume) + " / " + Stringify.Volume(maxVolume) + " free"; ImGui.PushID(_entityState.Entity.Guid.ToString()); if (ImGui.CollapsingHeader(headerText, ImGuiTreeNodeFlags.CollapsingHeader)) { ImGui.Columns(3); ImGui.Text("Item"); ImGui.NextColumn(); ImGui.Text("Count"); ImGui.NextColumn(); ImGui.Text("Total Mass"); ImGui.NextColumn(); ImGui.Separator(); foreach (var cargoType in typeStore.Value.CurrentStoreInUnits) { ICargoable ctype = typeStore.Value.Cargoables[cargoType.Key]; var cname = ctype.Name; var volumeStored = cargoType.Value; var volumePerItem = ctype.VolumePerUnit; var massStored = cargoType.Value * ctype.MassPerUnit; var itemsStored = typeStore.Value.CurrentStoreInUnits[ctype.ID]; if (ImGui.Selectable(cname)) { } ImGui.NextColumn(); ImGui.Text(Stringify.Number(itemsStored)); ImGui.NextColumn(); ImGui.Text(Stringify.Mass(massStored)); ImGui.SetTooltip(Stringify.Volume(volumeStored)); ImGui.NextColumn(); } ImGui.Columns(1); } } ImGui.EndChild(); }
static void GuiCostText(ComponentDesigner componentDesigner) //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(); }
//displays selected entity info internal override void Display() { ImGui.SetNextWindowSize(new Vector2(264, 325), ImGuiCond.Once); if (ImGui.Begin("Currently selected", _flags)) { if (_uiState.LastClickedEntity != null && _uiState.StarSystemStates.ContainsKey(_uiState.SelectedStarSysGuid)) { EntityState _SelectedEntityState = _uiState.LastClickedEntity; if (_selectedEntity == null || _selectedEntity != _SelectedEntityState.Entity) { _selectedEntity = _SelectedEntityState.Entity; _componentInstances = ComponentsDisplay.CreateNewInstanceArray(_selectedEntity); } if (_uiState.PrimaryEntity != null) { //ImGui.Text("Primary: " + _uiState.PrimaryEntity.Name); } else { //ImGui.Text("(Select primary...)"); } if (_selectedEntity.HasDataBlob <MassVolumeDB>()) { ImGui.Text("Volume: " + Stringify.Volume(_selectedEntity.GetDataBlob <MassVolumeDB>().Volume_m3)); } ImGui.Text("Subject: " + _SelectedEntityState.Name); //ImGui.Text(""+_uiState.LastClickedEntity.); //gets all children and parent nodes, displays their names and makes them clickable to navigate towards them. if (_selectedEntity.HasDataBlob <PositionDB>()) { ImGui.Text("Parent entity: "); var _parentEntity = _selectedEntity.GetDataBlob <PositionDB>().Parent; bool _hasParentEntity = false; SystemState _StarSystemState = _uiState.StarSystemStates[_uiState.SelectedStarSysGuid]; Dictionary <Guid, EntityState> _NamedEntityStates = _StarSystemState.EntityStatesWithNames; if (_parentEntity != null) { //checks if parent exists in the selected star system and has a name //notice that parent can be any bodyType(ex. asteroid, comet, planet etc), unlike childrenEntities, which are more selectively displayed... if (_NamedEntityStates.ContainsKey(_parentEntity.Guid)) { var tempEntityState = _NamedEntityStates[_parentEntity.Guid]; _hasParentEntity = true; if (ImGui.SmallButton(tempEntityState.Name)) { //if(ImGui.SmallButton(parentEntity.GetDataBlob<NameDB>().GetName(_uiState.Faction.ID))){ _uiState.EntityClicked(_parentEntity.Guid, _uiState.SelectedStarSysGuid, MouseButtons.Primary); //} } } } if (!_hasParentEntity) { ImGui.Text("(...No parent entity)"); } bool hasChildrenEntities = false; ImGui.Text("Children entities: "); foreach (var childEntity in _selectedEntity.GetDataBlob <PositionDB>().Children) { //checks if child exists in the seclted star system and has name if (_NamedEntityStates.ContainsKey(childEntity.Guid)) { var tempEntityState = _NamedEntityStates[childEntity.Guid]; //only show child entities that arent comets or asteroids if the lastClickedEntity(parent entity) isnt either, if LastClickedEntity(parent entity) is either, then show them always if (_SelectedEntityState.IsSmallBody() && !tempEntityState.IsSmallBody()) { hasChildrenEntities = true; if (ImGui.SmallButton(tempEntityState.Name)) { _uiState.EntityClicked(childEntity.Guid, _uiState.SelectedStarSysGuid, MouseButtons.Primary); } } } } if (!hasChildrenEntities) { ImGui.Text("(...No children entities)"); } if (_selectedEntity.HasDataBlob <ComponentInstancesDB>()) { ComponentsDisplay.Display(_componentInstances); ImGui.NewLine(); } } } else { ImGui.Text("(select subject...)"); } if (ImGui.Button("see all small bodies")) { SmallBodyEntityInfoPanel.GetInstance().SetActive(); } ImGui.End(); } }
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(); } }
public void Display() { ImGui.BeginChild(_entityState.Name, new System.Numerics.Vector2(260, 200), true); ImGui.Text(_entityState.Name); ImGui.Text("Transfer Rate: " + _volStorageDB.TransferRateInKgHr); ImGui.Text("At DeltaV < " + Stringify.Velocity(_volStorageDB.TransferRangeDv_mps)); foreach (var typeStore in _stores) { CargoTypeSD stype = _staticData.CargoTypes[typeStore.Key]; var freeVolume = typeStore.Value.FreeVolume; var maxVolume = typeStore.Value.MaxVolume; var storedVolume = maxVolume - freeVolume; string headerText = stype.Name + " " + Stringify.Volume(freeVolume) + " / " + Stringify.Volume(maxVolume) + " free"; ImGui.PushID(_entityState.Entity.Guid.ToString()); if (ImGui.CollapsingHeader(headerText, ImGuiTreeNodeFlags.CollapsingHeader)) { ImGui.Columns(3); ImGui.Text("Item"); ImGui.NextColumn(); ImGui.Text("Count"); ImGui.NextColumn(); ImGui.Text("Total Mass"); ImGui.NextColumn(); ImGui.Separator(); foreach (var cargoItemKvp in typeStore.Value.CurrentStoreInUnits.ToArray()) { ICargoable cargoItem = _stores[typeStore.Key].Cargoables[cargoItemKvp.Key]; if (cargoItem == null) { FactionInfoDB factionInfoDB; //factionInfoDB. } var cname = cargoItem.Name; var unitsStored = cargoItemKvp.Value; var volumePerItem = cargoItem.VolumePerUnit; var volumeStored = _volStorageDB.GetVolumeStored(cargoItem); var massStored = _volStorageDB.GetMassStored(cargoItem); bool isSelected = selectedCargo == cargoItem; if (ImGui.Selectable(cname, isSelected)) { selectedCargo = cargoItem; CargoItemSelectedEvent.Invoke(this); } ImGui.NextColumn(); ImGui.Text(Stringify.Number(unitsStored)); if (_cargoToMove.ContainsKey(cargoItem)) { var unitsMoving = _cargoToMove[cargoItem]; string text = Stringify.Number(unitsMoving); ImGui.SameLine(); float blue = 0f; if (_cargoToMoveDatablob.ContainsKey(cargoItem)) { if (_cargoToMoveDatablob[cargoItem] != 0) { blue = 0.25f; } } if (_cargoToMoveOrders.ContainsKey(cargoItem)) { if (_cargoToMoveOrders[cargoItem] != 0) { blue = 0.5f; } } if (_cargoToMoveUI.ContainsKey(cargoItem)) { if (_cargoToMoveUI[cargoItem] != 0) { blue = 0.75f; } } if (unitsMoving > 0) { ImGui.TextColored(new Vector4(0.5f, 1, blue, 1), text); } else { ImGui.TextColored(new Vector4(1f, 0.5f, blue, 1), text); } } ImGui.NextColumn(); ImGui.Text(Stringify.Mass(massStored)); ImGui.NextColumn(); } ImGui.Columns(1); } } ImGui.EndChild(); }