private void ShowPlayerTradeItems() { var tradingWindow = GetTradingWindow(); if (tradingWindow == null || !tradingWindow.IsVisible) { return; } var tradingItems = GetItemsInTradingWindow(tradingWindow); var ourData = new ItemDisplay { Items = GetItemObjects(tradingItems.ourItems).OrderBy(item => item.Path), X = Settings.YourItemStartingLocationX, Y = Settings.YourItemStartingLocationY, TextSize = Settings.TextSize, TextColor = Settings.YourItemTextColor, BackgroundColor = Settings.YourItemBackgroundColor, BackgroundTransparency = Settings.YourItemBackgroundColor.Value.A, ImageSize = Settings.ImageSize, Spacing = Settings.Spacing, LeftAlignment = Settings.YourItemsImageLeftOrRight, Ascending = Settings.YourItemsAscending }; var theirData = new ItemDisplay { Items = GetItemObjects(tradingItems.theirItems).OrderBy(item => item.Path), X = Settings.TheirItemStartingLocationX, Y = Settings.TheirItemStartingLocationY, TextSize = Settings.TextSize, TextColor = Settings.TheirItemTextColor, BackgroundColor = Settings.TheirItemBackgroundColor, BackgroundTransparency = Settings.TheirItemBackgroundColor.Value.A, ImageSize = Settings.ImageSize, Spacing = Settings.Spacing, LeftAlignment = Settings.TheirItemsImageLeftOrRight, Ascending = Settings.TheirItemsAscending }; if (ourData.Items.Any()) { DrawCurrency(ourData); } if (theirData.Items.Any()) { DrawCurrency(theirData); } }
private void DrawCurrency(ItemDisplay data) { const string symbol = "-"; var counter = 0; var newColor = data.BackgroundColor; newColor.A = (byte)data.BackgroundTransparency; var maxCount = data.Items.Max(i => i.Amount); var background = new RectangleF(data.LeftAlignment ? data.X : data.X + data.ImageSize, data.Y, data.LeftAlignment ? +data.ImageSize + data.Spacing + 3 + Graphics.MeasureText(symbol + " " + maxCount, data.TextSize).X : -data.ImageSize - data.Spacing - 3 - Graphics.MeasureText(symbol + " " + maxCount, data.TextSize).X, data.Ascending ? -data.ImageSize * data.Items.Count() : data.ImageSize * data.Items.Count()); Graphics.DrawBox(background, newColor); foreach (var ourItem in data.Items) { counter++; var imageBox = new RectangleF(data.X, data.Ascending ? data.Y - counter * data.ImageSize : data.Y - data.ImageSize + counter * data.ImageSize, data.ImageSize, data.ImageSize); Graphics.DrawImageGui(ourItem.Path, imageBox, new RectangleF(0, 0, 1, 1)); Graphics.DrawText(data.LeftAlignment ? $"{symbol} {ourItem.Amount}" : $"{ourItem.Amount} {symbol}", new Vector2(data.LeftAlignment ? data.X + data.ImageSize + data.Spacing : data.X - data.Spacing, imageBox.Center.Y - data.TextSize / 2 - 3), data.TextColor, data.LeftAlignment ? FontAlign.Left : FontAlign.Right); } }