Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 17 additions & 18 deletions Content.Client/Lathe/UI/LatheMenu.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
<LineEdit
Name="SearchBar"
PlaceHolder="{Loc 'lathe-menu-search-designs'}"
HorizontalExpand="True">
</LineEdit>
HorizontalExpand="True" />
<OptionButton
Name="FilterOption"
MinWidth="100"
Expand All @@ -46,8 +45,7 @@
Orientation="Vertical"
HorizontalExpand="True"
VerticalExpand="True"
RectClipContent="True">
</BoxContainer>
RectClipContent="True" />
</ScrollContainer>
</PanelContainer>
</BoxContainer>
Expand Down Expand Up @@ -78,8 +76,7 @@
Name="ServerListButton"
Text="{Loc 'lathe-menu-server-list'}"
TextAlign="Center"
Mode="Press">
</Button>
Mode="Press" />
</BoxContainer>
<Label Text="{Loc 'lathe-menu-queue-title'}" Margin="5 5 5 5" HorizontalAlignment="Center"/>
<BoxContainer
Expand All @@ -98,17 +95,15 @@
RectClipContent="False"
HorizontalAlignment="Left"
Margin="5 0 0 0"
Text="{Loc 'lathe-menu-fabricating-message'}">
</Label>
Text="{Loc 'lathe-menu-fabricating-message'}" />
<BoxContainer Name="FabricatingDisplayContainer"
HorizontalAlignment="Left"
Margin="100 0 0 0"/>
<Label
Name="NameLabel"
RectClipContent="True"
HorizontalAlignment="Left"
Margin="130 0 0 0">
</Label>
Margin="130 0 0 0" />
</PanelContainer>
</BoxContainer>
<ScrollContainer VerticalExpand="True" HScrollEnabled="False">
Expand All @@ -117,21 +112,25 @@
Orientation="Vertical"
HorizontalExpand="True"
VerticalExpand="True"
RectClipContent="True">
</BoxContainer>
RectClipContent="True" />
</ScrollContainer>
</BoxContainer>
<BoxContainer
VerticalExpand="True"
HorizontalExpand="True"
Orientation="Vertical">
<Label Text="{Loc 'lathe-menu-materials-title'}" Margin="5 5 5 5" HorizontalAlignment="Center"/>
<BoxContainer
Orientation="Vertical"
VerticalExpand="True"
HorizontalExpand="True">
<ui:MaterialStorageControl Name="MaterialsList" SizeFlagsStretchRatio="8"/>
</BoxContainer>
<PanelContainer VerticalExpand="True">
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#1B1B1E" />
</PanelContainer.PanelOverride>
<BoxContainer
Orientation="Vertical"
VerticalExpand="True"
HorizontalExpand="True">
<ui:MaterialStorageControl Name="MaterialsList" SizeFlagsStretchRatio="8"/>
</BoxContainer>
</PanelContainer>
</BoxContainer>
</BoxContainer>

Expand Down
11 changes: 6 additions & 5 deletions Content.Client/Materials/MaterialStorageSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public sealed class MaterialStorageSystem : SharedMaterialStorageSystem
{
[Dependency] private readonly AppearanceSystem _appearance = default!;
[Dependency] private readonly TransformSystem _transform = default!;
[Dependency] private readonly SpriteSystem _sprite = default!;

public override void Initialize()
{
Expand All @@ -20,23 +21,23 @@ private void OnAppearanceChange(EntityUid uid, MaterialStorageComponent componen
if (args.Sprite == null)
return;

if (!args.Sprite.LayerMapTryGet(MaterialStorageVisualLayers.Inserting, out var layer))
if (!_sprite.LayerMapTryGet((uid, args.Sprite), MaterialStorageVisualLayers.Inserting, out var layer, false))
return;

if (!_appearance.TryGetData<bool>(uid, MaterialStorageVisuals.Inserting, out var inserting, args.Component))
return;

if (inserting && TryComp<InsertingMaterialStorageComponent>(uid, out var insertingComp))
{
args.Sprite.LayerSetAnimationTime(layer, 0f);
_sprite.LayerSetAnimationTime((uid, args.Sprite), layer, 0f);

args.Sprite.LayerSetVisible(layer, true);
_sprite.LayerSetVisible((uid, args.Sprite), layer, true);
if (insertingComp.MaterialColor != null)
args.Sprite.LayerSetColor(layer, insertingComp.MaterialColor.Value);
_sprite.LayerSetColor((uid, args.Sprite), layer, insertingComp.MaterialColor.Value);
}
else
{
args.Sprite.LayerSetVisible(layer, false);
_sprite.LayerSetVisible((uid, args.Sprite), layer, false);
}
}

Expand Down
35 changes: 35 additions & 0 deletions Content.Client/Materials/OreSilo/OreSiloBoundUserInterface.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using Content.Client.Materials.UI;
using Content.Shared.Materials.OreSilo;
using JetBrains.Annotations;
using Robust.Client.UserInterface;

namespace Content.Client.Materials.OreSilo;

[UsedImplicitly]
public sealed class OreSiloBoundUserInterface(EntityUid owner, Enum uiKey) : BoundUserInterface(owner, uiKey)
{
[ViewVariables]
private OreSiloMenu? _menu;

protected override void Open()
{
base.Open();

_menu = this.CreateWindow<OreSiloMenu>();
_menu.SetEntity(Owner);

_menu.OnClientEntryPressed += netEnt =>
{
SendPredictedMessage(new ToggleOreSiloClientMessage(netEnt));
};
}

protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);

if (state is not OreSiloBuiState msg)
return;
_menu?.Update(msg);
}
}
6 changes: 6 additions & 0 deletions Content.Client/Materials/OreSilo/OreSiloSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
using Content.Shared.Materials.OreSilo;

namespace Content.Client.Materials;

/// <inheritdoc/>
public sealed class OreSiloSystem : SharedOreSiloSystem;
7 changes: 5 additions & 2 deletions Content.Client/Materials/UI/MaterialStorageControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
SizeFlagsStretchRatio="8"
HorizontalExpand="True"
VerticalExpand="True">
<BoxContainer Name="MaterialList" Orientation="Vertical">
<Label Name="NoMatsLabel" Text="{Loc 'lathe-menu-no-materials-message'}" Align="Center"/>
<BoxContainer Orientation="Vertical" VerticalExpand="True">
<BoxContainer Name="MaterialList" Orientation="Vertical" VerticalExpand="True">
<Label Name="NoMatsLabel" Text="{Loc 'lathe-menu-no-materials-message'}" HorizontalAlignment="Center" VerticalAlignment="Center" VerticalExpand="True"/>
</BoxContainer>
<Label Name="SiloLinkedLabel" Text="{Loc 'lathe-menu-silo-linked-message'}" StyleClasses="LabelSubText" Visible="False" HorizontalAlignment="Center"/>
</BoxContainer>
</ScrollContainer>
11 changes: 9 additions & 2 deletions Content.Client/Materials/UI/MaterialStorageControl.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System.Linq;
using Content.Shared.Materials;
using Content.Shared.Materials.OreSilo;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;

namespace Content.Client.Materials.UI;
Expand All @@ -14,15 +16,18 @@ namespace Content.Client.Materials.UI;
public sealed partial class MaterialStorageControl : ScrollContainer
{
[Dependency] private readonly IEntityManager _entityManager = default!;
private readonly MaterialStorageSystem _materialStorage;

private EntityUid? _owner;

private Dictionary<string, int> _currentMaterials = new();
private Dictionary<ProtoId<MaterialPrototype>, int> _currentMaterials = new();

public MaterialStorageControl()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);

_materialStorage = _entityManager.System<MaterialStorageSystem>();
}

public void SetOwner(EntityUid owner)
Expand All @@ -44,7 +49,8 @@ protected override void FrameUpdate(FrameEventArgs args)
}

var canEject = materialStorage.CanEjectStoredMaterials;
var mats = materialStorage.Storage.Select(pair => (pair.Key.Id, pair.Value)).ToDictionary();
var mats = _materialStorage.GetStoredMaterials((_owner.Value, materialStorage));

if (_currentMaterials.Equals(mats))
return;

Expand Down Expand Up @@ -88,5 +94,6 @@ protected override void FrameUpdate(FrameEventArgs args)

_currentMaterials = mats;
NoMatsLabel.Visible = MaterialList.ChildCount == 1;
SiloLinkedLabel.Visible = _entityManager.TryGetComponent<OreSiloClientComponent>(_owner.Value, out var client) && client.Silo != null;
}
}
42 changes: 42 additions & 0 deletions Content.Client/Materials/UI/OreSiloMenu.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<controls:FancyWindow xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
xmlns:graphics="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
xmlns:ui="clr-namespace:Content.Client.Materials.UI"
Title="{Loc 'ore-silo-ui-title'}"
MinSize="400 260"
SetSize="400 460">
<BoxContainer Orientation="Vertical"
HorizontalExpand="True"
VerticalExpand="True"
Margin="10 10 10 10">
<BoxContainer VerticalExpand="True"
HorizontalExpand="True"
Orientation="Vertical"
SizeFlagsStretchRatio="3">
<Label Text="{Loc 'ore-silo-ui-label-clients'}" Margin="5 5 5 5" HorizontalAlignment="Center" StyleClasses="LabelKeyText"/>
<PanelContainer VerticalExpand="True">
<PanelContainer.PanelOverride>
<graphics:StyleBoxFlat BackgroundColor="#1B1B1E" />
</PanelContainer.PanelOverride>
<ItemList Name="ClientList" SelectMode="Button" VerticalExpand="True"/>
</PanelContainer>
</BoxContainer>
<BoxContainer VerticalExpand="True"
HorizontalExpand="True"
Orientation="Vertical"
SizeFlagsStretchRatio="2">
<Label Text="{Loc 'ore-silo-ui-label-mats'}" Margin="5 5 5 5" HorizontalAlignment="Center" StyleClasses="LabelKeyText"/>
<PanelContainer VerticalExpand="True">
<PanelContainer.PanelOverride>
<graphics:StyleBoxFlat BackgroundColor="#1B1B1E" />
</PanelContainer.PanelOverride>
<BoxContainer
Orientation="Vertical"
VerticalExpand="True"
HorizontalExpand="True">
<ui:MaterialStorageControl Name="Materials"/>
</BoxContainer>
</PanelContainer>
</BoxContainer>
</BoxContainer>
</controls:FancyWindow>
64 changes: 64 additions & 0 deletions Content.Client/Materials/UI/OreSiloMenu.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using System.Linq;
using Content.Client.UserInterface.Controls;
using Content.Shared.Materials.OreSilo;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;

namespace Content.Client.Materials.UI;

[GenerateTypedNameReferences]
public sealed partial class OreSiloMenu : FancyWindow
{
public event Action<NetEntity>? OnClientEntryPressed;

public OreSiloMenu()
{
RobustXamlLoader.Load(this);

ClientList.OnItemSelected += args =>
{
var item = ClientList[args.ItemIndex];
// a little bit of null suppression makes me feel great! :-)
OnClientEntryPressed?.Invoke((NetEntity) item.Metadata!);
};
}

public void SetEntity(EntityUid uid)
{
Materials.SetOwner(uid);
}

public void Update(OreSiloBuiState state)
{
var items = new List<ItemList.Item>();
var orderedClients = state.Clients.OrderBy(t => t.Item3).ThenBy(t => t.Item1.Id);
foreach (var (ent, _, _) in orderedClients)
{
items.Add(new ItemList.Item(ClientList)
{
Metadata = ent,
});
}

ClientList.SetItems(items,
(item1, item2) =>
{
var ent1 = (NetEntity) item1.Metadata!;
var ent2 = (NetEntity) item2.Metadata!;
return ent1.CompareTo(ent2);
});

var entTextDict = state.Clients.Select(t => (t.Item1, t.Item2)).ToDictionary();
using var enumerator = ClientList.GetEnumerator();
while (enumerator.MoveNext())
{
if (enumerator.Current.Metadata is not NetEntity ent)
continue;

if (entTextDict.TryGetValue(ent, out var text))
enumerator.Current.Text = text;
}
}
}

Loading
Loading