Show materials as sheets, tweak lathe ui (#19709)
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Content.Client.Stylesheets;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Lathe;
|
||||
using Content.Shared.Materials;
|
||||
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;
|
||||
@@ -22,7 +21,6 @@ public sealed partial class LatheMenu : DefaultWindow
|
||||
private readonly SpriteSystem _spriteSystem;
|
||||
private readonly LatheSystem _lathe;
|
||||
|
||||
// public event Action<BaseButton.ButtonEventArgs>? OnMaterialsEjectionButtonPressed;
|
||||
public event Action<BaseButton.ButtonEventArgs>? OnServerListButtonPressed;
|
||||
public event Action<string, int>? RecipeQueueAction;
|
||||
public event Action<string, int>? OnEjectPressed;
|
||||
@@ -47,7 +45,6 @@ public sealed partial class LatheMenu : DefaultWindow
|
||||
PopulateRecipes(owner.Owner);
|
||||
};
|
||||
|
||||
//MaterialsEjectionButton.OnPressed += a => OnMaterialsEjectionButtonPressed?.Invoke(a);
|
||||
ServerListButton.OnPressed += a => OnServerListButtonPressed?.Invoke(a);
|
||||
|
||||
if (_entityManager.TryGetComponent<LatheComponent>(owner.Owner, out var latheComponent))
|
||||
@@ -76,19 +73,18 @@ public sealed partial class LatheMenu : DefaultWindow
|
||||
|
||||
var name = Loc.GetString(material.Name);
|
||||
var mat = Loc.GetString("lathe-menu-material-display",
|
||||
("material", name), ("amount", volume));
|
||||
int volumePerSheet = 0;
|
||||
int maxEjectableSheets = 0;
|
||||
("material", name), ("amount", volume / 100));
|
||||
var volumePerSheet = 0;
|
||||
var maxEjectableSheets = 0;
|
||||
|
||||
if (material.StackEntity != null)
|
||||
{
|
||||
var proto = _prototypeManager.Index<EntityPrototype>(material.StackEntity);
|
||||
name = proto.Name;
|
||||
|
||||
if (proto.TryGetComponent<PhysicalCompositionComponent>(out var composition))
|
||||
{
|
||||
volumePerSheet = composition.MaterialComposition.FirstOrDefault(kvp => kvp.Key == materialId).Value;
|
||||
maxEjectableSheets = (int) MathF.Floor(volume / volumePerSheet);
|
||||
maxEjectableSheets = (int) MathF.Floor((float) volume / volumePerSheet);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,7 +152,9 @@ public sealed partial class LatheMenu : DefaultWindow
|
||||
|
||||
var adjustedAmount = SharedLatheSystem.AdjustMaterial(amount, prototype.ApplyMaterialDiscount, component.MaterialUseMultiplier);
|
||||
|
||||
sb.Append(Loc.GetString("lathe-menu-tooltip-display", ("amount", adjustedAmount), ("material", Loc.GetString(proto.Name))));
|
||||
sb.Append(Loc.GetString("lathe-menu-tooltip-display",
|
||||
("amount", MathF.Round(adjustedAmount / 100f, 2)),
|
||||
("material", Loc.GetString(proto.Name))));
|
||||
}
|
||||
|
||||
var icon = prototype.Icon == null
|
||||
@@ -195,19 +193,12 @@ public sealed partial class LatheMenu : DefaultWindow
|
||||
|
||||
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;
|
||||
}
|
||||
FabricatingContainer.Visible = recipe != null;
|
||||
if (recipe == null)
|
||||
return;
|
||||
Icon.Texture = recipe.Icon == null
|
||||
? _spriteSystem.GetPrototypeIcon(recipe.Result).Default
|
||||
: _spriteSystem.Frame0(recipe.Icon);
|
||||
NameLabel.Text = $"{recipe.Name}";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user