private MyToolTips GetListboxItemTooltip(MyGuiControlListbox listbox, int id) { MyInventoryItem item = m_itemsRepository.GetItem(id); MyToolTips toolTips = new MyToolTips(); toolTips.AddToolTip(item.MultiLineDescription, Color.White, 0.7f); // add price to tooltip if (m_tradeForMoney) { if (item.CanBeTraded) { StringBuilder sb = new StringBuilder(); if (listbox == m_shipInventoryListBox) { sb.Append(MyTextsWrapper.Get(MyTextsWrapperEnum.SellFor)); } else if (listbox == m_otherSideInventoryListBox) { sb.Append(MyTextsWrapper.Get(MyTextsWrapperEnum.BuyFor)); } sb.Append(GetPriceSB((decimal)GetTradeItemPrice(item))); toolTips.AddToolTip(sb, Color.Gold); } else { toolTips.AddToolTip(MyTextsWrapper.Get(MyTextsWrapperEnum.NotificationNonTradeableItem), Color.Red); } } return toolTips; }
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; }