diff --git a/Content.Client/VendingMachines/UI/VendingMachineMenu.xaml b/Content.Client/VendingMachines/UI/VendingMachineMenu.xaml
new file mode 100644
index 0000000000..c6021e85ad
--- /dev/null
+++ b/Content.Client/VendingMachines/UI/VendingMachineMenu.xaml
@@ -0,0 +1,6 @@
+
+
+
+
diff --git a/Content.Client/VendingMachines/UI/VendingMachineMenu.cs b/Content.Client/VendingMachines/UI/VendingMachineMenu.xaml.cs
similarity index 71%
rename from Content.Client/VendingMachines/UI/VendingMachineMenu.cs
rename to Content.Client/VendingMachines/UI/VendingMachineMenu.xaml.cs
index 201b17aff3..576200a063 100644
--- a/Content.Client/VendingMachines/UI/VendingMachineMenu.cs
+++ b/Content.Client/VendingMachines/UI/VendingMachineMenu.xaml.cs
@@ -1,65 +1,57 @@
+using System;
using System.Collections.Generic;
+using Robust.Client.AutoGenerated;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
+using Robust.Client.UserInterface.XAML;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
using static Content.Shared.VendingMachines.SharedVendingMachineComponent;
namespace Content.Client.VendingMachines.UI
{
- class VendingMachineMenu : SS14Window
+ [GenerateTypedNameReferences]
+ public partial class VendingMachineMenu : SS14Window
{
[Dependency] private readonly IResourceCache _resourceCache = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
- private readonly ItemList _items;
- private List _cachedInventory = new();
+ private VendingMachineBoundUserInterface Owner { get; }
- public VendingMachineBoundUserInterface Owner { get; }
+ private List _cachedInventory = new();
public VendingMachineMenu(VendingMachineBoundUserInterface owner)
{
- SetSize = (300, 450);
IoCManager.InjectDependencies(this);
+ RobustXamlLoader.Load(this);
Owner = owner;
-
- _items = new ItemList()
- {
- SizeFlagsStretchRatio = 8,
- VerticalExpand = true,
- };
- _items.OnItemSelected += ItemSelected;
-
- Contents.AddChild(_items);
+ VendingContents.OnItemSelected += ItemSelected;
}
public void Populate(List inventory)
{
- _items.Clear();
+ VendingContents.Clear();
_cachedInventory = inventory;
var longestEntry = "";
foreach (VendingMachineInventoryEntry entry in inventory)
{
var itemName = _prototypeManager.Index(entry.ID).Name;
if (itemName.Length > longestEntry.Length)
- {
longestEntry = itemName;
- }
Texture? icon = null;
if(_prototypeManager.TryIndex(entry.ID, out EntityPrototype? prototype))
- {
icon = SpriteComponent.GetPrototypeIcon(prototype, _resourceCache).Default;
- }
- _items.AddItem($"{itemName} ({entry.Amount} left)", icon);
+ VendingContents.AddItem($"{itemName} [{entry.Amount}]", icon);
}
- SetSize = ((longestEntry.Length + 8) * 12, _items.Count * 40 + 50);
+ SetSize = (Math.Clamp((longestEntry.Length + 2) * 12, 250, 300),
+ Math.Clamp(VendingContents.Count * 30, 150, 350));
}
public void ItemSelected(ItemList.ItemListSelectedEventArgs args)
diff --git a/Content.Client/VendingMachines/VendingMachineBoundUserInterface.cs b/Content.Client/VendingMachines/VendingMachineBoundUserInterface.cs
index 34f8080832..c2119c39f9 100644
--- a/Content.Client/VendingMachines/VendingMachineBoundUserInterface.cs
+++ b/Content.Client/VendingMachines/VendingMachineBoundUserInterface.cs
@@ -7,7 +7,7 @@ using static Content.Shared.VendingMachines.SharedVendingMachineComponent;
namespace Content.Client.VendingMachines
{
- class VendingMachineBoundUserInterface : BoundUserInterface
+ public class VendingMachineBoundUserInterface : BoundUserInterface
{
[ViewVariables] private VendingMachineMenu? _menu;