private MyGuiControlListboxItem CreateListboxItemAndAddToRepository(MyInventoryItem inventoryItem) { int inventoryItemKey = m_inventoryItemsRepository.AddItem(inventoryItem); StringBuilder description = null; if (inventoryItem.Icon == null) { description = inventoryItem.MultiLineDescription; } MyToolTips toolTips = new MyToolTips(); toolTips.AddToolTip(inventoryItem.MultiLineDescription, Color.White, 0.7f); MyGuiControlListboxItem listboxItem = new MyGuiControlListboxItem(inventoryItemKey, description, inventoryItem.Icon, toolTips, MyGuiConstants.LABEL_TEXT_SCALE); listboxItem.IconTexts = new MyIconTexts(); // add amount icon's text if (inventoryItem.Amount != 1f || inventoryItem.Amount != inventoryItem.MaxAmount) { StringBuilder amount = new StringBuilder(); amount.Append(inventoryItem.Amount.ToString()); MyGuiDrawAlignEnum align; Vector2 offset; if (inventoryItem.AmountTextAlign == MyInventoryAmountTextAlign.MiddleRight) { align = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER; offset = new Vector2(-0.004f, 0.0038f); } else if (inventoryItem.AmountTextAlign == MyInventoryAmountTextAlign.BottomRight) { align = MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM; offset = new Vector2(-0.004f, -0.0025f); } else { throw new MyMwcExceptionApplicationShouldNotGetHere(); } listboxItem.IconTexts[align] = new MyColoredText(amount, Color.White, Color.White, MyGuiManager.GetFontMinerWarsWhite(), 0.5f, offset); } return(listboxItem); }
private void GetBuildingRequirementsDescription(MyToolTips requirementsDescription, MyObjectToBuild objectToBuild) { StringBuilder meetRequirements = requirementsDescription.GetToolTips()[2].Text; StringBuilder notMeetRequirements = requirementsDescription.GetToolTips()[3].Text; meetRequirements.Clear(); notMeetRequirements.Clear(); foreach (IMyBuildingRequirement buildingRequirement in objectToBuild.BuildingSpecification.BuildingRequirements) { if (buildingRequirement.Check(MyEditor.Static.FoundationFactory)) { MyMwcUtils.AppendStringBuilder(meetRequirements, buildingRequirement.GetDescription()); meetRequirements.AppendLine(); } else { MyMwcUtils.AppendStringBuilder(notMeetRequirements, buildingRequirement.GetDescription()); notMeetRequirements.AppendLine(); } } requirementsDescription.RecalculateSize(); }