Add lathe material ejection (#19218)

This completes PilgrimViis' (now closed) PR 16398. It addresses issue 10896, by allowing materials to be ejected from most lathes (except the ore processor and sheet-meister 2000)

* - Refinements to the material ejection UI
- Made the lathe UI default to a slightly larger size
- Fixed an offset issue with the label of the item currently being printed in the build queue UI

* Allow the materiel reclamation UI to pop if there is material left in the lathe, but not enough to print any sheets

---------

Co-authored-by: Kevin Zheng <kevinz5000@gmail.com>
This commit is contained in:
chromiumboy
2023-08-17 12:22:01 -05:00
committed by GitHub
parent 89b3231de0
commit a39fa80d58
13 changed files with 288 additions and 10 deletions

View File

@@ -1,4 +1,4 @@
using System.Linq;
using System.Linq;
using System.Text;
using Content.Client.Stylesheets;
using Content.Shared.Lathe;
@@ -22,6 +22,7 @@ public sealed partial class LatheMenu : DefaultWindow
private readonly LatheSystem _lathe;
public event Action<BaseButton.ButtonEventArgs>? OnQueueButtonPressed;
public event Action<BaseButton.ButtonEventArgs>? OnMaterialsEjectionButtonPressed;
public event Action<BaseButton.ButtonEventArgs>? OnServerListButtonPressed;
public event Action<string, int>? RecipeQueueAction;
@@ -47,6 +48,7 @@ public sealed partial class LatheMenu : DefaultWindow
};
QueueButton.OnPressed += a => OnQueueButtonPressed?.Invoke(a);
MaterialsEjectionButton.OnPressed += a => OnMaterialsEjectionButtonPressed?.Invoke(a);
ServerListButton.OnPressed += a => OnServerListButtonPressed?.Invoke(a);
if (_entityManager.TryGetComponent<LatheComponent>(owner.Owner, out var latheComponent))
@@ -57,6 +59,11 @@ public sealed partial class LatheMenu : DefaultWindow
QueueButton.RemoveStyleClass(StyleBase.ButtonOpenRight);
//QueueButton.AddStyleClass(StyleBase.ButtonSquare);
}
if (MaterialsEjectionButton != null && !latheComponent.CanEjectStoredMaterials)
{
MaterialsEjectionButton.Dispose();
}
}
}
@@ -69,14 +76,24 @@ public sealed partial class LatheMenu : DefaultWindow
foreach (var (id, amount) in materials.Storage)
{
if (amount <= 0)
continue;
if (!_prototypeManager.TryIndex(id, out MaterialPrototype? material))
continue;
var name = Loc.GetString(material.Name);
var mat = Loc.GetString("lathe-menu-material-display",
("material", name), ("amount", amount));
Materials.AddItem(mat, _spriteSystem.Frame0(material.Icon), false);
}
if (MaterialsEjectionButton != null)
{
MaterialsEjectionButton.Disabled = Materials.Count == 0;
}
if (Materials.Count == 0)
{
var noMaterialsMsg = Loc.GetString("lathe-menu-no-materials-message");
@@ -132,9 +149,7 @@ public sealed partial class LatheMenu : DefaultWindow
var adjustedAmount = SharedLatheSystem.AdjustMaterial(amount, prototype.ApplyMaterialDiscount, component.MaterialUseMultiplier);
sb.Append(adjustedAmount);
sb.Append(' ');
sb.Append(Loc.GetString(proto.Name));
sb.Append(Loc.GetString("lathe-menu-tooltip-display", ("amount", adjustedAmount), ("material", Loc.GetString(proto.Name))));
}
var icon = prototype.Icon == null