From a1029be6540d55c114e9268e4f615441b27092d2 Mon Sep 17 00:00:00 2001
From: Thom <119594676+ItsMeThom@users.noreply.github.com>
Date: Tue, 29 Aug 2023 01:36:07 +0100
Subject: [PATCH] Changed Lathe UI to two-column layout so its easier to see
what materials are currently loaded (#19608)
---
.../Lathe/UI/LatheBoundUserInterface.cs | 35 +--
.../Lathe/UI/LatheMaterialEjector.xaml | 2 +-
.../Lathe/UI/LatheMaterialsEjectionMenu.xaml | 16 --
.../UI/LatheMaterialsEjectionMenu.xaml.cs | 74 ------
Content.Client/Lathe/UI/LatheMenu.xaml | 213 +++++++++++-------
Content.Client/Lathe/UI/LatheMenu.xaml.cs | 97 +++++---
Content.Client/Lathe/UI/LatheQueueMenu.xaml | 42 ----
.../Lathe/UI/LatheQueueMenu.xaml.cs | 57 -----
.../Locale/en-US/lathe/ui/lathe-menu.ftl | 6 +-
.../en-US/lathe/ui/lathe-queue-menu.ftl | 2 -
10 files changed, 215 insertions(+), 329 deletions(-)
delete mode 100644 Content.Client/Lathe/UI/LatheMaterialsEjectionMenu.xaml
delete mode 100644 Content.Client/Lathe/UI/LatheMaterialsEjectionMenu.xaml.cs
delete mode 100644 Content.Client/Lathe/UI/LatheQueueMenu.xaml
delete mode 100644 Content.Client/Lathe/UI/LatheQueueMenu.xaml.cs
delete mode 100644 Resources/Locale/en-US/lathe/ui/lathe-queue-menu.ftl
diff --git a/Content.Client/Lathe/UI/LatheBoundUserInterface.cs b/Content.Client/Lathe/UI/LatheBoundUserInterface.cs
index ab44d0f5a2f..69e41d18855 100644
--- a/Content.Client/Lathe/UI/LatheBoundUserInterface.cs
+++ b/Content.Client/Lathe/UI/LatheBoundUserInterface.cs
@@ -10,13 +10,6 @@ public sealed class LatheBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private LatheMenu? _menu;
-
- [ViewVariables]
- private LatheQueueMenu? _queueMenu;
-
- [ViewVariables]
- private LatheMaterialsEjectionMenu? _materialsEjectionMenu;
-
public LatheBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
@@ -26,26 +19,8 @@ protected override void Open()
base.Open();
_menu = new LatheMenu(this);
- _queueMenu = new LatheQueueMenu();
- _materialsEjectionMenu = new LatheMaterialsEjectionMenu();
-
_menu.OnClose += Close;
- _menu.OnQueueButtonPressed += _ =>
- {
- if (_queueMenu.IsOpen)
- _queueMenu.Close();
- else
- _queueMenu.OpenCenteredLeft();
- };
-
- _menu.OnMaterialsEjectionButtonPressed += _ =>
- {
- if (_materialsEjectionMenu.IsOpen)
- _materialsEjectionMenu.Close();
- else
- _materialsEjectionMenu.OpenCenteredRight();
- };
_menu.OnServerListButtonPressed += _ =>
{
@@ -57,7 +32,7 @@ protected override void Open()
SendMessage(new LatheQueueRecipeMessage(recipe, amount));
};
- _materialsEjectionMenu.OnEjectPressed += (material, sheetsToExtract) =>
+ _menu.OnEjectPressed += (material, sheetsToExtract) =>
{
SendMessage(new LatheEjectMaterialMessage(material, sheetsToExtract));
};
@@ -76,9 +51,8 @@ protected override void UpdateState(BoundUserInterfaceState state)
_menu.Recipes = msg.Recipes;
_menu?.PopulateRecipes(Owner);
_menu?.PopulateMaterials(Owner);
- _queueMenu?.PopulateList(msg.Queue);
- _queueMenu?.SetInfo(msg.CurrentlyProducing);
- _materialsEjectionMenu?.PopulateMaterials(Owner);
+ _menu?.PopulateQueueList(msg.Queue);
+ _menu?.SetQueueInfo(msg.CurrentlyProducing);
break;
}
}
@@ -89,8 +63,7 @@ protected override void Dispose(bool disposing)
if (!disposing)
return;
_menu?.Dispose();
- _queueMenu?.Dispose();
- _materialsEjectionMenu?.Dispose();
+ //thom _materialsEjectionMenu?.Dispose();
}
}
}
diff --git a/Content.Client/Lathe/UI/LatheMaterialEjector.xaml b/Content.Client/Lathe/UI/LatheMaterialEjector.xaml
index 713b49aa5c8..08c7da53020 100644
--- a/Content.Client/Lathe/UI/LatheMaterialEjector.xaml
+++ b/Content.Client/Lathe/UI/LatheMaterialEjector.xaml
@@ -14,7 +14,7 @@
Access="Public"
HorizontalExpand="True"
ClipText="True"
- Margin="0 4 0 0"/>
+ Margin="4 4 4 4"/>
diff --git a/Content.Client/Lathe/UI/LatheMaterialsEjectionMenu.xaml b/Content.Client/Lathe/UI/LatheMaterialsEjectionMenu.xaml
deleted file mode 100644
index be5eb1c7ef9..00000000000
--- a/Content.Client/Lathe/UI/LatheMaterialsEjectionMenu.xaml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
-
-
diff --git a/Content.Client/Lathe/UI/LatheMaterialsEjectionMenu.xaml.cs b/Content.Client/Lathe/UI/LatheMaterialsEjectionMenu.xaml.cs
deleted file mode 100644
index 4db470c1159..00000000000
--- a/Content.Client/Lathe/UI/LatheMaterialsEjectionMenu.xaml.cs
+++ /dev/null
@@ -1,74 +0,0 @@
-using Content.Shared.Materials;
-using Robust.Client.AutoGenerated;
-using Robust.Client.GameObjects;
-using Robust.Client.UserInterface.CustomControls;
-using Robust.Client.UserInterface.XAML;
-using Robust.Shared.Prototypes;
-using System.Linq;
-
-namespace Content.Client.Lathe.UI;
-
-[GenerateTypedNameReferences]
-public sealed partial class LatheMaterialsEjectionMenu : DefaultWindow
-{
- [Dependency] private readonly IEntityManager _entityManager = default!;
- [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
-
- private readonly SpriteSystem _spriteSystem;
-
- public event Action? OnEjectPressed;
-
- public LatheMaterialsEjectionMenu()
- {
- RobustXamlLoader.Load(this);
- IoCManager.InjectDependencies(this);
- _spriteSystem = _entityManager.EntitySysManager.GetEntitySystem();
- }
-
- public void PopulateMaterials(EntityUid lathe)
- {
- if (!_entityManager.TryGetComponent(lathe, out var materials))
- return;
-
- MaterialsList.DisposeAllChildren();
-
- foreach (var (materialId, volume) in materials.Storage)
- {
- if (volume <= 0)
- continue;
-
- if (!_prototypeManager.TryIndex(materialId, out MaterialPrototype? material))
- continue;
-
- var name = Loc.GetString(material.Name);
- int volumePerSheet = 0;
- int maxEjectableSheets = 0;
-
- if (material.StackEntity != null)
- {
- var proto = _prototypeManager.Index(material.StackEntity);
- name = proto.Name;
-
- if (proto.TryGetComponent(out var composition))
- {
- volumePerSheet = composition.MaterialComposition.FirstOrDefault(kvp => kvp.Key == materialId).Value;
- maxEjectableSheets = (int) MathF.Floor(volume / volumePerSheet);
- }
- }
-
- var row = new LatheMaterialEjector(materialId, OnEjectPressed, volumePerSheet, maxEjectableSheets)
- {
- Icon = { Texture = _spriteSystem.Frame0(material.Icon) },
- ProductName = { Text = name }
- };
-
- MaterialsList.AddChild(row);
- }
-
- if (MaterialsList.ChildCount == 0)
- {
- Close();
- }
- }
-}
-
diff --git a/Content.Client/Lathe/UI/LatheMenu.xaml b/Content.Client/Lathe/UI/LatheMenu.xaml
index a496fa9e50e..89ca6720970 100644
--- a/Content.Client/Lathe/UI/LatheMenu.xaml
+++ b/Content.Client/Lathe/UI/LatheMenu.xaml
@@ -2,91 +2,152 @@
xmlns="https://spacestation14.io"
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
Title="{Loc 'lathe-menu-title'}"
- MinSize="300 450"
- SetSize="350 475">
+ MinSize="550 450"
+ SetSize="750 500">
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
-
-
-
+
+
diff --git a/Content.Client/Lathe/UI/LatheMenu.xaml.cs b/Content.Client/Lathe/UI/LatheMenu.xaml.cs
index d8d0a8c0ab3..f4270ec3a66 100644
--- a/Content.Client/Lathe/UI/LatheMenu.xaml.cs
+++ b/Content.Client/Lathe/UI/LatheMenu.xaml.cs
@@ -6,6 +6,7 @@
using Content.Shared.Research.Prototypes;
using Robust.Client.AutoGenerated;
using Robust.Client.GameObjects;
+using Robust.Client.Graphics;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
@@ -21,11 +22,10 @@ public sealed partial class LatheMenu : DefaultWindow
private readonly SpriteSystem _spriteSystem;
private readonly LatheSystem _lathe;
- public event Action? OnQueueButtonPressed;
- public event Action? OnMaterialsEjectionButtonPressed;
+ // public event Action? OnMaterialsEjectionButtonPressed;
public event Action? OnServerListButtonPressed;
public event Action? RecipeQueueAction;
-
+ public event Action? OnEjectPressed;
public List Recipes = new();
public LatheMenu(LatheBoundUserInterface owner)
@@ -47,8 +47,7 @@ public LatheMenu(LatheBoundUserInterface owner)
PopulateRecipes(owner.Owner);
};
- QueueButton.OnPressed += a => OnQueueButtonPressed?.Invoke(a);
- MaterialsEjectionButton.OnPressed += a => OnMaterialsEjectionButtonPressed?.Invoke(a);
+ //MaterialsEjectionButton.OnPressed += a => OnMaterialsEjectionButtonPressed?.Invoke(a);
ServerListButton.OnPressed += a => OnServerListButtonPressed?.Invoke(a);
if (_entityManager.TryGetComponent(owner.Owner, out var latheComponent))
@@ -56,13 +55,6 @@ public LatheMenu(LatheBoundUserInterface owner)
if (!latheComponent.DynamicRecipes.Any())
{
ServerListButton.Visible = false;
- QueueButton.RemoveStyleClass(StyleBase.ButtonOpenRight);
- //QueueButton.AddStyleClass(StyleBase.ButtonSquare);
- }
-
- if (MaterialsEjectionButton != null && !latheComponent.CanEjectStoredMaterials)
- {
- MaterialsEjectionButton.Dispose();
}
}
}
@@ -72,37 +64,52 @@ public void PopulateMaterials(EntityUid lathe)
if (!_entityManager.TryGetComponent(lathe, out var materials))
return;
- Materials.Clear();
+ MaterialsList.DisposeAllChildren();
- foreach (var (id, amount) in materials.Storage)
+ foreach (var (materialId, volume) in materials.Storage)
{
- if (amount <= 0)
+ if (volume <= 0)
continue;
- if (!_prototypeManager.TryIndex(id, out MaterialPrototype? material))
+ if (!_prototypeManager.TryIndex(materialId, out MaterialPrototype? material))
continue;
var name = Loc.GetString(material.Name);
var mat = Loc.GetString("lathe-menu-material-display",
- ("material", name), ("amount", amount));
+ ("material", name), ("amount", volume));
+ int volumePerSheet = 0;
+ int maxEjectableSheets = 0;
- Materials.AddItem(mat, _spriteSystem.Frame0(material.Icon), false);
- }
+ if (material.StackEntity != null)
+ {
+ var proto = _prototypeManager.Index(material.StackEntity);
+ name = proto.Name;
+
+ if (proto.TryGetComponent(out var composition))
+ {
+ volumePerSheet = composition.MaterialComposition.FirstOrDefault(kvp => kvp.Key == materialId).Value;
+ maxEjectableSheets = (int) MathF.Floor(volume / volumePerSheet);
+ }
+ }
- if (MaterialsEjectionButton != null)
- {
- MaterialsEjectionButton.Disabled = Materials.Count == 0;
+ var row = new LatheMaterialEjector(materialId, OnEjectPressed, volumePerSheet, maxEjectableSheets)
+ {
+ Icon = { Texture = _spriteSystem.Frame0(material.Icon) },
+ ProductName = { Text = mat }
+ };
+
+ MaterialsList.AddChild(row);
}
- if (Materials.Count == 0)
+ if (MaterialsList.ChildCount == 0)
{
var noMaterialsMsg = Loc.GetString("lathe-menu-no-materials-message");
- Materials.AddItem(noMaterialsMsg, null, false);
+ var noItemRow = new Label();
+ noItemRow.Text = noMaterialsMsg;
+ noItemRow.Align = Label.AlignMode.Center;
+ MaterialsList.AddChild(noItemRow);
}
-
- PopulateRecipes(lathe);
}
-
///
/// Populates the list of all the recipes
///
@@ -167,4 +174,40 @@ public void PopulateRecipes(EntityUid lathe)
RecipeList.AddChild(control);
}
}
+
+ ///
+ /// Populates the build queue list with all queued items
+ ///
+ ///
+ public void PopulateQueueList(List queue)
+ {
+ QueueList.Clear();
+ var idx = 1;
+ foreach (var recipe in queue)
+ {
+ var icon = recipe.Icon == null
+ ? _spriteSystem.GetPrototypeIcon(recipe.Result).Default
+ : _spriteSystem.Frame0(recipe.Icon);
+ QueueList.AddItem($"{idx}. {recipe.Name}", icon);
+ idx++;
+ }
+ }
+
+ public void SetQueueInfo(LatheRecipePrototype? recipe)
+ {
+ if (recipe != null)
+ {
+ Icon.Texture = recipe.Icon == null
+ ? _spriteSystem.GetPrototypeIcon(recipe.Result).Default
+ : _spriteSystem.Frame0(recipe.Icon);
+ FabricatingActiveLabel.Text = "Fabricating...";
+ NameLabel.Text = $"{recipe.Name}";
+ }
+ else
+ {
+ Icon.Texture = Texture.Transparent;
+ FabricatingActiveLabel.Text = String.Empty;
+ NameLabel.Text = String.Empty;
+ }
+ }
}
diff --git a/Content.Client/Lathe/UI/LatheQueueMenu.xaml b/Content.Client/Lathe/UI/LatheQueueMenu.xaml
deleted file mode 100644
index a92a0a18a17..00000000000
--- a/Content.Client/Lathe/UI/LatheQueueMenu.xaml
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Content.Client/Lathe/UI/LatheQueueMenu.xaml.cs b/Content.Client/Lathe/UI/LatheQueueMenu.xaml.cs
deleted file mode 100644
index eaf03c2fffa..00000000000
--- a/Content.Client/Lathe/UI/LatheQueueMenu.xaml.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-using Content.Shared.Research.Prototypes;
-using Robust.Client.AutoGenerated;
-using Robust.Client.GameObjects;
-using Robust.Client.Graphics;
-using Robust.Client.UserInterface.CustomControls;
-using Robust.Client.UserInterface.XAML;
-
-namespace Content.Client.Lathe.UI
-{
- [GenerateTypedNameReferences]
- public sealed partial class LatheQueueMenu : DefaultWindow
- {
- [Dependency] private readonly IEntityManager _entityManager = default!;
- private readonly SpriteSystem _spriteSystem;
-
- public LatheQueueMenu()
- {
- RobustXamlLoader.Load(this);
- IoCManager.InjectDependencies(this);
- _spriteSystem = _entityManager.EntitySysManager.GetEntitySystem();
-
- SetInfo(null);
- }
-
- public void SetInfo(LatheRecipePrototype? recipe)
- {
- if (recipe != null)
- {
- Icon.Texture = recipe.Icon == null
- ? _spriteSystem.GetPrototypeIcon(recipe.Result).Default
- : _spriteSystem.Frame0(recipe.Icon);
- NameLabel.Text = recipe.Name;
- Description.Text = recipe.Description;
- }
- else
- {
- Icon.Texture = Texture.Transparent;
- NameLabel.Text = string.Empty;
- Description.Text = Loc.GetString("lathe-queue-menu-not-producing-text");
- }
- }
-
- public void PopulateList(List queue)
- {
- QueueList.Clear();
- var idx = 1;
- foreach (var recipe in queue)
- {
- var icon =recipe.Icon == null
- ? _spriteSystem.GetPrototypeIcon(recipe.Result).Default
- : _spriteSystem.Frame0(recipe.Icon);
- QueueList.AddItem($"{idx}. {recipe.Name}", icon);
- idx++;
- }
- }
- }
-}
diff --git a/Resources/Locale/en-US/lathe/ui/lathe-menu.ftl b/Resources/Locale/en-US/lathe/ui/lathe-menu.ftl
index e932b2805e7..be994e0c6dd 100644
--- a/Resources/Locale/en-US/lathe/ui/lathe-menu.ftl
+++ b/Resources/Locale/en-US/lathe/ui/lathe-menu.ftl
@@ -7,6 +7,6 @@ lathe-menu-search-filter = Filter
lathe-menu-amount = Amount:
lathe-menu-material-display = {$material} ({$amount} cm³)
lathe-menu-tooltip-display = {$amount} cm³ of {$material}
-lathe-menu-no-materials-message = No materials loaded
-lathe-menu-materials-ejection = Eject materials
-lathe-menu-materials-ejection-title = Eject materials
+lathe-menu-no-materials-message = No materials loaded.
+lathe-menu-materials-title = Materials
+lathe-menu-queue-title = Build Queue
diff --git a/Resources/Locale/en-US/lathe/ui/lathe-queue-menu.ftl b/Resources/Locale/en-US/lathe/ui/lathe-queue-menu.ftl
deleted file mode 100644
index 978d6dc1ad5..00000000000
--- a/Resources/Locale/en-US/lathe/ui/lathe-queue-menu.ftl
+++ /dev/null
@@ -1,2 +0,0 @@
-lathe-queue-menu-title = Lathe Queue
-lathe-queue-menu-not-producing-text = Not producing anything.