Changed Lathe UI to two-column layout so its easier to see what materials are currently loaded (#19608)
This commit is contained in:
@@ -10,13 +10,6 @@ namespace Content.Client.Lathe.UI
|
|||||||
{
|
{
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
private LatheMenu? _menu;
|
private LatheMenu? _menu;
|
||||||
|
|
||||||
[ViewVariables]
|
|
||||||
private LatheQueueMenu? _queueMenu;
|
|
||||||
|
|
||||||
[ViewVariables]
|
|
||||||
private LatheMaterialsEjectionMenu? _materialsEjectionMenu;
|
|
||||||
|
|
||||||
public LatheBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
|
public LatheBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -26,26 +19,8 @@ namespace Content.Client.Lathe.UI
|
|||||||
base.Open();
|
base.Open();
|
||||||
|
|
||||||
_menu = new LatheMenu(this);
|
_menu = new LatheMenu(this);
|
||||||
_queueMenu = new LatheQueueMenu();
|
|
||||||
_materialsEjectionMenu = new LatheMaterialsEjectionMenu();
|
|
||||||
|
|
||||||
_menu.OnClose += Close;
|
_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 += _ =>
|
_menu.OnServerListButtonPressed += _ =>
|
||||||
{
|
{
|
||||||
@@ -57,7 +32,7 @@ namespace Content.Client.Lathe.UI
|
|||||||
SendMessage(new LatheQueueRecipeMessage(recipe, amount));
|
SendMessage(new LatheQueueRecipeMessage(recipe, amount));
|
||||||
};
|
};
|
||||||
|
|
||||||
_materialsEjectionMenu.OnEjectPressed += (material, sheetsToExtract) =>
|
_menu.OnEjectPressed += (material, sheetsToExtract) =>
|
||||||
{
|
{
|
||||||
SendMessage(new LatheEjectMaterialMessage(material, sheetsToExtract));
|
SendMessage(new LatheEjectMaterialMessage(material, sheetsToExtract));
|
||||||
};
|
};
|
||||||
@@ -76,9 +51,8 @@ namespace Content.Client.Lathe.UI
|
|||||||
_menu.Recipes = msg.Recipes;
|
_menu.Recipes = msg.Recipes;
|
||||||
_menu?.PopulateRecipes(Owner);
|
_menu?.PopulateRecipes(Owner);
|
||||||
_menu?.PopulateMaterials(Owner);
|
_menu?.PopulateMaterials(Owner);
|
||||||
_queueMenu?.PopulateList(msg.Queue);
|
_menu?.PopulateQueueList(msg.Queue);
|
||||||
_queueMenu?.SetInfo(msg.CurrentlyProducing);
|
_menu?.SetQueueInfo(msg.CurrentlyProducing);
|
||||||
_materialsEjectionMenu?.PopulateMaterials(Owner);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -89,8 +63,7 @@ namespace Content.Client.Lathe.UI
|
|||||||
if (!disposing)
|
if (!disposing)
|
||||||
return;
|
return;
|
||||||
_menu?.Dispose();
|
_menu?.Dispose();
|
||||||
_queueMenu?.Dispose();
|
//thom _materialsEjectionMenu?.Dispose();
|
||||||
_materialsEjectionMenu?.Dispose();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
Access="Public"
|
Access="Public"
|
||||||
HorizontalExpand="True"
|
HorizontalExpand="True"
|
||||||
ClipText="True"
|
ClipText="True"
|
||||||
Margin="0 4 0 0"/>
|
Margin="4 4 4 4"/>
|
||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
<!--Here go buttons which added in c#-->
|
<!--Here go buttons which added in c#-->
|
||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
<DefaultWindow
|
|
||||||
xmlns="https://spacestation14.io"
|
|
||||||
Title="{Loc 'lathe-menu-materials-ejection-title'}"
|
|
||||||
MinSize="300 100"
|
|
||||||
SetSize="350 475">
|
|
||||||
<ScrollContainer MinHeight="80">
|
|
||||||
<BoxContainer
|
|
||||||
Name="MaterialsList"
|
|
||||||
Orientation="Vertical"
|
|
||||||
SizeFlagsStretchRatio="8"
|
|
||||||
HorizontalExpand="True"
|
|
||||||
VerticalExpand="True">
|
|
||||||
<!-- Materials populated in C# file -->
|
|
||||||
</BoxContainer>
|
|
||||||
</ScrollContainer>
|
|
||||||
</DefaultWindow>
|
|
||||||
@@ -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<string, int>? OnEjectPressed;
|
|
||||||
|
|
||||||
public LatheMaterialsEjectionMenu()
|
|
||||||
{
|
|
||||||
RobustXamlLoader.Load(this);
|
|
||||||
IoCManager.InjectDependencies(this);
|
|
||||||
_spriteSystem = _entityManager.EntitySysManager.GetEntitySystem<SpriteSystem>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void PopulateMaterials(EntityUid lathe)
|
|
||||||
{
|
|
||||||
if (!_entityManager.TryGetComponent<MaterialStorageComponent>(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<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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -2,91 +2,152 @@
|
|||||||
xmlns="https://spacestation14.io"
|
xmlns="https://spacestation14.io"
|
||||||
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
|
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
|
||||||
Title="{Loc 'lathe-menu-title'}"
|
Title="{Loc 'lathe-menu-title'}"
|
||||||
MinSize="300 450"
|
MinSize="550 450"
|
||||||
SetSize="350 475">
|
SetSize="750 500">
|
||||||
<BoxContainer
|
<BoxContainer
|
||||||
Orientation="Vertical"
|
Orientation="Horizontal"
|
||||||
VerticalExpand="True"
|
VerticalExpand="True"
|
||||||
HorizontalExpand="True"
|
HorizontalExpand="True"
|
||||||
SeparationOverride="5">
|
SeparationOverride="5">
|
||||||
|
<!-- Left Col-->
|
||||||
<BoxContainer
|
<BoxContainer
|
||||||
Orientation="Horizontal"
|
VerticalExpand="True"
|
||||||
Align="End"
|
|
||||||
HorizontalExpand="True">
|
HorizontalExpand="True">
|
||||||
<Button
|
<BoxContainer
|
||||||
Name="QueueButton"
|
Orientation="Vertical"
|
||||||
Text="{Loc 'lathe-menu-queue'}"
|
VerticalExpand="True"
|
||||||
TextAlign="Center"
|
HorizontalExpand="True"
|
||||||
Mode="Press"
|
SeparationOverride="5">
|
||||||
StyleClasses="OpenRight">
|
<BoxContainer
|
||||||
</Button>
|
Orientation="Horizontal"
|
||||||
<Button
|
Align="End"
|
||||||
Name="ServerListButton"
|
HorizontalExpand="True">
|
||||||
Text="{Loc 'lathe-menu-server-list'}"
|
<Button
|
||||||
TextAlign="Center"
|
Name="ServerListButton"
|
||||||
Mode="Press"
|
Text="{Loc 'lathe-menu-server-list'}"
|
||||||
StyleClasses="OpenLeft">
|
TextAlign="Center"
|
||||||
</Button>
|
Mode="Press"
|
||||||
|
StyleClasses="OpenLeft">
|
||||||
|
</Button>
|
||||||
|
</BoxContainer>
|
||||||
|
<BoxContainer Orientation="Horizontal"
|
||||||
|
HorizontalExpand="True">
|
||||||
|
<LineEdit
|
||||||
|
Name="SearchBar"
|
||||||
|
PlaceHolder="{Loc 'lathe-menu-search-designs'}"
|
||||||
|
HorizontalExpand="True">
|
||||||
|
</LineEdit>
|
||||||
|
<Button
|
||||||
|
Name="FilterButton"
|
||||||
|
Text="{Loc 'lathe-menu-search-filter'}"
|
||||||
|
TextAlign="Center"
|
||||||
|
Margin="5 0 0 0"
|
||||||
|
Disabled="True"
|
||||||
|
StyleClasses="ButtonSquare">
|
||||||
|
</Button>
|
||||||
|
</BoxContainer>
|
||||||
|
<BoxContainer Orientation="Vertical"
|
||||||
|
MinHeight="225"
|
||||||
|
VerticalExpand="True"
|
||||||
|
HorizontalExpand="True"
|
||||||
|
SizeFlagsStretchRatio="4">
|
||||||
|
<PanelContainer VerticalExpand="True">
|
||||||
|
<PanelContainer.PanelOverride>
|
||||||
|
<gfx:StyleBoxFlat BackgroundColor="#1B1B1E" />
|
||||||
|
</PanelContainer.PanelOverride>
|
||||||
|
<ScrollContainer VerticalExpand="True" HScrollEnabled="False">
|
||||||
|
<BoxContainer
|
||||||
|
Name="RecipeList"
|
||||||
|
Orientation="Vertical"
|
||||||
|
HorizontalExpand="True"
|
||||||
|
VerticalExpand="True"
|
||||||
|
RectClipContent="True">
|
||||||
|
</BoxContainer>
|
||||||
|
</ScrollContainer>
|
||||||
|
</PanelContainer>
|
||||||
|
</BoxContainer>
|
||||||
|
<BoxContainer Orientation="Horizontal"
|
||||||
|
HorizontalExpand="True">
|
||||||
|
<Label Margin="8 0 8 0" Text="{Loc 'lathe-menu-amount'}" />
|
||||||
|
<LineEdit
|
||||||
|
Name="AmountLineEdit"
|
||||||
|
PlaceHolder="0"
|
||||||
|
Text="1"
|
||||||
|
HorizontalExpand="True" />
|
||||||
|
</BoxContainer>
|
||||||
|
</BoxContainer>
|
||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
<BoxContainer Orientation="Horizontal"
|
|
||||||
HorizontalExpand="True">
|
<!-- Right Col-->
|
||||||
<LineEdit
|
<BoxContainer
|
||||||
Name="SearchBar"
|
Orientation="Vertical"
|
||||||
PlaceHolder="{Loc 'lathe-menu-search-designs'}"
|
VerticalExpand="True"
|
||||||
HorizontalExpand="True">
|
HorizontalExpand="True"
|
||||||
</LineEdit>
|
SeparationOverride="5"
|
||||||
<Button
|
>
|
||||||
Name="FilterButton"
|
<BoxContainer Orientation="Vertical" MinHeight="225">
|
||||||
Text="{Loc 'lathe-menu-search-filter'}"
|
<Label Text="{Loc 'lathe-menu-queue-title'}" Margin="5 5 5 5" HorizontalAlignment="Center"/>
|
||||||
TextAlign="Center"
|
<BoxContainer
|
||||||
Margin="5 0 0 0"
|
Orientation="Horizontal"
|
||||||
Disabled="True"
|
HorizontalExpand="True"
|
||||||
StyleClasses="ButtonSquare">
|
SizeFlagsStretchRatio="2">
|
||||||
</Button>
|
<PanelContainer
|
||||||
</BoxContainer>
|
|
||||||
<BoxContainer Orientation="Vertical"
|
|
||||||
MinHeight="225"
|
|
||||||
VerticalExpand="True"
|
|
||||||
HorizontalExpand="True"
|
|
||||||
SizeFlagsStretchRatio="4">
|
|
||||||
<PanelContainer VerticalExpand="True">
|
|
||||||
<PanelContainer.PanelOverride>
|
|
||||||
<gfx:StyleBoxFlat BackgroundColor="#1B1B1E" />
|
|
||||||
</PanelContainer.PanelOverride>
|
|
||||||
<ScrollContainer VerticalExpand="True" HScrollEnabled="False">
|
|
||||||
<BoxContainer
|
|
||||||
Name="RecipeList"
|
|
||||||
Orientation="Vertical"
|
|
||||||
HorizontalExpand="True"
|
|
||||||
VerticalExpand="True"
|
VerticalExpand="True"
|
||||||
RectClipContent="True">
|
HorizontalExpand="True"
|
||||||
</BoxContainer>
|
SizeFlagsStretchRatio="3">
|
||||||
</ScrollContainer>
|
<PanelContainer.PanelOverride>
|
||||||
</PanelContainer>
|
<gfx:StyleBoxFlat BackgroundColor="#408040" />
|
||||||
</BoxContainer>
|
</PanelContainer.PanelOverride>
|
||||||
<BoxContainer Orientation="Horizontal"
|
<Label
|
||||||
HorizontalExpand="True">
|
Name="FabricatingActiveLabel"
|
||||||
<Label Margin="8 0 8 0" Text="{Loc 'lathe-menu-amount'}"/>
|
RectClipContent="False"
|
||||||
<LineEdit
|
HorizontalAlignment="Left"
|
||||||
Name="AmountLineEdit"
|
Margin="5 0 0 0">
|
||||||
PlaceHolder="0"
|
</Label>
|
||||||
Text="1"
|
<TextureRect
|
||||||
HorizontalExpand="True"/>
|
Name="Icon"
|
||||||
</BoxContainer>
|
HorizontalExpand="True"
|
||||||
<BoxContainer Orientation="Vertical" VerticalExpand="True" HorizontalExpand="True">
|
SizeFlagsStretchRatio="2"
|
||||||
<ItemList
|
Margin="100 0 0 0">
|
||||||
Name="Materials"
|
</TextureRect>
|
||||||
|
<Label
|
||||||
|
Name="NameLabel"
|
||||||
|
RectClipContent="True"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
Margin="130 0 0 0">
|
||||||
|
</Label>
|
||||||
|
</PanelContainer>
|
||||||
|
</BoxContainer>
|
||||||
|
<ItemList
|
||||||
|
Name="QueueList"
|
||||||
|
VerticalExpand="True"
|
||||||
|
SizeFlagsStretchRatio="3"
|
||||||
|
SelectMode="None">
|
||||||
|
</ItemList>
|
||||||
|
</BoxContainer>
|
||||||
|
<BoxContainer
|
||||||
|
VerticalExpand="True"
|
||||||
|
HorizontalExpand="True"
|
||||||
|
Orientation="Vertical"
|
||||||
|
MinHeight="225"
|
||||||
|
>
|
||||||
|
<Label Text="{Loc 'lathe-menu-materials-title'}" Margin="5 5 5 5" HorizontalAlignment="Center"/>
|
||||||
|
<BoxContainer
|
||||||
|
Orientation="Vertical"
|
||||||
|
VerticalExpand="True"
|
||||||
|
HorizontalExpand="True">
|
||||||
|
<BoxContainer
|
||||||
|
Name="MaterialsList"
|
||||||
|
Orientation="Vertical"
|
||||||
|
SizeFlagsStretchRatio="8"
|
||||||
|
HorizontalExpand="True"
|
||||||
VerticalExpand="True">
|
VerticalExpand="True">
|
||||||
</ItemList>
|
<!-- Materials populated in C# file -->
|
||||||
|
</BoxContainer>
|
||||||
|
</BoxContainer>
|
||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
<Button
|
</BoxContainer>
|
||||||
Name="MaterialsEjectionButton"
|
|
||||||
Text="{Loc 'lathe-menu-materials-ejection'}"
|
|
||||||
TextAlign="Center"
|
|
||||||
Mode="Press"
|
|
||||||
StyleClasses="OpenRight">
|
|
||||||
</Button>
|
|
||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
|
|
||||||
</DefaultWindow>
|
</DefaultWindow>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using Content.Shared.Materials;
|
|||||||
using Content.Shared.Research.Prototypes;
|
using Content.Shared.Research.Prototypes;
|
||||||
using Robust.Client.AutoGenerated;
|
using Robust.Client.AutoGenerated;
|
||||||
using Robust.Client.GameObjects;
|
using Robust.Client.GameObjects;
|
||||||
|
using Robust.Client.Graphics;
|
||||||
using Robust.Client.UserInterface.Controls;
|
using Robust.Client.UserInterface.Controls;
|
||||||
using Robust.Client.UserInterface.CustomControls;
|
using Robust.Client.UserInterface.CustomControls;
|
||||||
using Robust.Client.UserInterface.XAML;
|
using Robust.Client.UserInterface.XAML;
|
||||||
@@ -21,11 +22,10 @@ public sealed partial class LatheMenu : DefaultWindow
|
|||||||
private readonly SpriteSystem _spriteSystem;
|
private readonly SpriteSystem _spriteSystem;
|
||||||
private readonly LatheSystem _lathe;
|
private readonly LatheSystem _lathe;
|
||||||
|
|
||||||
public event Action<BaseButton.ButtonEventArgs>? OnQueueButtonPressed;
|
// public event Action<BaseButton.ButtonEventArgs>? OnMaterialsEjectionButtonPressed;
|
||||||
public event Action<BaseButton.ButtonEventArgs>? OnMaterialsEjectionButtonPressed;
|
|
||||||
public event Action<BaseButton.ButtonEventArgs>? OnServerListButtonPressed;
|
public event Action<BaseButton.ButtonEventArgs>? OnServerListButtonPressed;
|
||||||
public event Action<string, int>? RecipeQueueAction;
|
public event Action<string, int>? RecipeQueueAction;
|
||||||
|
public event Action<string, int>? OnEjectPressed;
|
||||||
public List<string> Recipes = new();
|
public List<string> Recipes = new();
|
||||||
|
|
||||||
public LatheMenu(LatheBoundUserInterface owner)
|
public LatheMenu(LatheBoundUserInterface owner)
|
||||||
@@ -47,8 +47,7 @@ public sealed partial class LatheMenu : DefaultWindow
|
|||||||
PopulateRecipes(owner.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);
|
ServerListButton.OnPressed += a => OnServerListButtonPressed?.Invoke(a);
|
||||||
|
|
||||||
if (_entityManager.TryGetComponent<LatheComponent>(owner.Owner, out var latheComponent))
|
if (_entityManager.TryGetComponent<LatheComponent>(owner.Owner, out var latheComponent))
|
||||||
@@ -56,13 +55,6 @@ public sealed partial class LatheMenu : DefaultWindow
|
|||||||
if (!latheComponent.DynamicRecipes.Any())
|
if (!latheComponent.DynamicRecipes.Any())
|
||||||
{
|
{
|
||||||
ServerListButton.Visible = false;
|
ServerListButton.Visible = false;
|
||||||
QueueButton.RemoveStyleClass(StyleBase.ButtonOpenRight);
|
|
||||||
//QueueButton.AddStyleClass(StyleBase.ButtonSquare);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (MaterialsEjectionButton != null && !latheComponent.CanEjectStoredMaterials)
|
|
||||||
{
|
|
||||||
MaterialsEjectionButton.Dispose();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -72,37 +64,52 @@ public sealed partial class LatheMenu : DefaultWindow
|
|||||||
if (!_entityManager.TryGetComponent<MaterialStorageComponent>(lathe, out var materials))
|
if (!_entityManager.TryGetComponent<MaterialStorageComponent>(lathe, out var materials))
|
||||||
return;
|
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;
|
continue;
|
||||||
|
|
||||||
if (!_prototypeManager.TryIndex(id, out MaterialPrototype? material))
|
if (!_prototypeManager.TryIndex(materialId, out MaterialPrototype? material))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var name = Loc.GetString(material.Name);
|
var name = Loc.GetString(material.Name);
|
||||||
var mat = Loc.GetString("lathe-menu-material-display",
|
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<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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var row = new LatheMaterialEjector(materialId, OnEjectPressed, volumePerSheet, maxEjectableSheets)
|
||||||
|
{
|
||||||
|
Icon = { Texture = _spriteSystem.Frame0(material.Icon) },
|
||||||
|
ProductName = { Text = mat }
|
||||||
|
};
|
||||||
|
|
||||||
|
MaterialsList.AddChild(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MaterialsEjectionButton != null)
|
if (MaterialsList.ChildCount == 0)
|
||||||
{
|
|
||||||
MaterialsEjectionButton.Disabled = Materials.Count == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Materials.Count == 0)
|
|
||||||
{
|
{
|
||||||
var noMaterialsMsg = Loc.GetString("lathe-menu-no-materials-message");
|
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Populates the list of all the recipes
|
/// Populates the list of all the recipes
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -167,4 +174,40 @@ public sealed partial class LatheMenu : DefaultWindow
|
|||||||
RecipeList.AddChild(control);
|
RecipeList.AddChild(control);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Populates the build queue list with all queued items
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="queue"></param>
|
||||||
|
public void PopulateQueueList(List<LatheRecipePrototype> 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
<DefaultWindow
|
|
||||||
xmlns="https://spacestation14.io"
|
|
||||||
Title="{Loc 'lathe-queue-menu-title'}"
|
|
||||||
MinSize="300 450"
|
|
||||||
SetSize="350 475">
|
|
||||||
<BoxContainer Orientation="Vertical">
|
|
||||||
<BoxContainer
|
|
||||||
Orientation="Horizontal"
|
|
||||||
HorizontalExpand="True"
|
|
||||||
SizeFlagsStretchRatio="2">
|
|
||||||
<TextureRect
|
|
||||||
Name="Icon"
|
|
||||||
HorizontalExpand="True"
|
|
||||||
SizeFlagsStretchRatio="2">
|
|
||||||
</TextureRect>
|
|
||||||
<BoxContainer
|
|
||||||
Orientation="Vertical"
|
|
||||||
VerticalExpand="True"
|
|
||||||
SizeFlagsStretchRatio="3">
|
|
||||||
<Label
|
|
||||||
Name="NameLabel"
|
|
||||||
RectClipContent="True"
|
|
||||||
Margin="36 0 0 0">
|
|
||||||
</Label>
|
|
||||||
<Label
|
|
||||||
Name="Description"
|
|
||||||
RectClipContent="True"
|
|
||||||
VerticalAlignment="Stretch"
|
|
||||||
VerticalExpand="True">
|
|
||||||
</Label>
|
|
||||||
</BoxContainer>
|
|
||||||
</BoxContainer>
|
|
||||||
<ItemList
|
|
||||||
Name="QueueList"
|
|
||||||
VerticalExpand="True"
|
|
||||||
SizeFlagsStretchRatio="3"
|
|
||||||
SelectMode="None">
|
|
||||||
</ItemList>
|
|
||||||
</BoxContainer>
|
|
||||||
</DefaultWindow>
|
|
||||||
|
|
||||||
|
|
||||||
@@ -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<SpriteSystem>();
|
|
||||||
|
|
||||||
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<LatheRecipePrototype> 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++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -7,6 +7,6 @@ lathe-menu-search-filter = Filter
|
|||||||
lathe-menu-amount = Amount:
|
lathe-menu-amount = Amount:
|
||||||
lathe-menu-material-display = {$material} ({$amount} cm³)
|
lathe-menu-material-display = {$material} ({$amount} cm³)
|
||||||
lathe-menu-tooltip-display = {$amount} cm³ of {$material}
|
lathe-menu-tooltip-display = {$amount} cm³ of {$material}
|
||||||
lathe-menu-no-materials-message = No materials loaded
|
lathe-menu-no-materials-message = No materials loaded.
|
||||||
lathe-menu-materials-ejection = Eject materials
|
lathe-menu-materials-title = Materials
|
||||||
lathe-menu-materials-ejection-title = Eject materials
|
lathe-menu-queue-title = Build Queue
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
lathe-queue-menu-title = Lathe Queue
|
|
||||||
lathe-queue-menu-not-producing-text = Not producing anything.
|
|
||||||
Reference in New Issue
Block a user