diff --git a/Content.Client/Overlays/StencilOverlay.cs b/Content.Client/Overlays/StencilOverlay.cs index 14a86e5854..46745a0e62 100644 --- a/Content.Client/Overlays/StencilOverlay.cs +++ b/Content.Client/Overlays/StencilOverlay.cs @@ -1,7 +1,7 @@ using System.Numerics; using Content.Client.Parallax; using Content.Client.Weather; -using Content.Shared._CP14.DayCycle; +using Content.Shared._CP14.DayCycle.Components; using Content.Shared._CP14.WorldEdge; using Content.Shared.Salvage; using Content.Shared.Weather; diff --git a/Content.Client/_CP14/Overlays/StencilOverlay.CloudShadows.cs b/Content.Client/_CP14/Overlays/StencilOverlay.CloudShadows.cs index 13950801d3..1d37e65443 100644 --- a/Content.Client/_CP14/Overlays/StencilOverlay.CloudShadows.cs +++ b/Content.Client/_CP14/Overlays/StencilOverlay.CloudShadows.cs @@ -1,5 +1,5 @@ using System.Numerics; -using Content.Shared._CP14.DayCycle; +using Content.Shared._CP14.DayCycle.Components; using Robust.Client.Graphics; using Robust.Shared.Utility; @@ -53,7 +53,7 @@ public sealed partial class StencilOverlay worldHandle.UseShader(_protoManager.Index("StencilMask").Instance()); worldHandle.DrawTextureRect(_blep!.Texture, worldBounds); var curTime = _timing.RealTime; - var sprite = _sprite.GetFrame(new SpriteSpecifier.Texture(new ResPath(cloudComp.ParallaxPath)), curTime); + var sprite = _sprite.GetFrame(new SpriteSpecifier.Texture(cloudComp.ParallaxPath), curTime); // Draw the rain worldHandle.UseShader(_protoManager.Index("StencilDraw").Instance()); diff --git a/Content.Client/_CP14/Workbench/CP14WorkbenchBoundUserInterface.cs b/Content.Client/_CP14/Workbench/CP14WorkbenchBoundUserInterface.cs new file mode 100644 index 0000000000..1e17cbaa1a --- /dev/null +++ b/Content.Client/_CP14/Workbench/CP14WorkbenchBoundUserInterface.cs @@ -0,0 +1,34 @@ +using Content.Shared._CP14.Workbench; +using Robust.Client.UserInterface; + +namespace Content.Client._CP14.Workbench; + +public sealed class CP14WorkbenchBoundUserInterface : BoundUserInterface +{ + private CP14WorkbenchWindow? _window; + + public CP14WorkbenchBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) + { + } + + protected override void Open() + { + base.Open(); + + _window = this.CreateWindow(); + + _window.OnCraft += entry => SendMessage(new CP14WorkbenchUiCraftMessage(entry.ProtoId)); + } + + protected override void UpdateState(BoundUserInterfaceState state) + { + base.UpdateState(state); + + switch (state) + { + case CP14WorkbenchUiRecipesState recipesState: + _window?.UpdateRecipes(recipesState); + break; + } + } +} diff --git a/Content.Client/_CP14/Workbench/CP14WorkbenchRecipeControl.xaml b/Content.Client/_CP14/Workbench/CP14WorkbenchRecipeControl.xaml new file mode 100644 index 0000000000..fab7715ae6 --- /dev/null +++ b/Content.Client/_CP14/Workbench/CP14WorkbenchRecipeControl.xaml @@ -0,0 +1,10 @@ + + + + + diff --git a/Content.Client/_CP14/Workbench/CP14WorkbenchRecipeControl.xaml.cs b/Content.Client/_CP14/Workbench/CP14WorkbenchRecipeControl.xaml.cs new file mode 100644 index 0000000000..5d18ce3d7a --- /dev/null +++ b/Content.Client/_CP14/Workbench/CP14WorkbenchRecipeControl.xaml.cs @@ -0,0 +1,43 @@ +using Content.Shared.Stacks; +using Robust.Client.AutoGenerated; +using Robust.Client.GameObjects; +using Robust.Client.UserInterface; +using Robust.Client.UserInterface.XAML; +using Robust.Shared.Prototypes; + +namespace Content.Client._CP14.Workbench; + +[GenerateTypedNameReferences] +public sealed partial class CP14WorkbenchRecipeControl : Control +{ + [Dependency] private readonly IEntityManager _entity = default!; + + private readonly SpriteSystem _sprite; + + public CP14WorkbenchRecipeControl() + { + RobustXamlLoader.Load(this); + IoCManager.InjectDependencies(this); + + _sprite = _entity.System(); + } + + public CP14WorkbenchRecipeControl(EntityPrototype prototype, int count) : this() + { + var entityName = prototype.Name; + Name.Text = count <= 1 ? entityName : $"{entityName} x{count}"; + View.Texture = _sprite.GetPrototypeIcon(prototype).Default; + } + + public CP14WorkbenchRecipeControl(StackPrototype prototype, int count) : this() + { + var entityName = Loc.GetString(prototype.Name); + Name.Text = $"{entityName} x{count}"; + + var icon = prototype.Icon; + if (icon is null) + return; + + View.Texture = _sprite.Frame0(icon); + } +} diff --git a/Content.Client/_CP14/Workbench/CP14WorkbenchRequirementControl.xaml b/Content.Client/_CP14/Workbench/CP14WorkbenchRequirementControl.xaml new file mode 100644 index 0000000000..3efee3eace --- /dev/null +++ b/Content.Client/_CP14/Workbench/CP14WorkbenchRequirementControl.xaml @@ -0,0 +1,12 @@ + + + diff --git a/Content.Client/_CP14/Workbench/CP14WorkbenchRequirementControl.xaml.cs b/Content.Client/_CP14/Workbench/CP14WorkbenchRequirementControl.xaml.cs new file mode 100644 index 0000000000..b89a61afc3 --- /dev/null +++ b/Content.Client/_CP14/Workbench/CP14WorkbenchRequirementControl.xaml.cs @@ -0,0 +1,59 @@ +using Content.Shared._CP14.Workbench; +using Content.Shared._CP14.Workbench.Prototypes; +using Robust.Client.AutoGenerated; +using Robust.Client.GameObjects; +using Robust.Client.UserInterface; +using Robust.Client.UserInterface.XAML; +using Robust.Shared.Prototypes; + +namespace Content.Client._CP14.Workbench; + +[GenerateTypedNameReferences] +public sealed partial class CP14WorkbenchRequirementControl : Control +{ + [Dependency] private readonly IEntityManager _entity = default!; + [Dependency] private readonly IPrototypeManager _prototype = default!; + + public event Action? OnSelect; + + private readonly SpriteSystem _sprite; + + private readonly CP14WorkbenchRecipePrototype _recipePrototype; + private readonly bool _craftable; + + public CP14WorkbenchRequirementControl(CP14WorkbenchUiRecipesEntry entry) + { + RobustXamlLoader.Load(this); + IoCManager.InjectDependencies(this); + + _sprite = _entity.System(); + + _recipePrototype = _prototype.Index(entry.ProtoId); + _craftable = entry.Craftable; + + Button.OnPressed += _ => OnSelect?.Invoke(entry, _recipePrototype); + + UpdateColor(); + UpdateName(); + UpdateView(); + } + + private void UpdateColor() + { + if (_craftable) + return; + + Button.ModulateSelfOverride = Color.FromHex("#302622"); + } + + private void UpdateName() + { + var result = _prototype.Index(_recipePrototype.Result); + Name.Text = Loc.GetString(result.Name); + } + + private void UpdateView() + { + View.Texture = _sprite.GetPrototypeIcon(_recipePrototype.Result).Default; + } +} diff --git a/Content.Client/_CP14/Workbench/CP14WorkbenchWindow.xaml b/Content.Client/_CP14/Workbench/CP14WorkbenchWindow.xaml new file mode 100644 index 0000000000..86daf28101 --- /dev/null +++ b/Content.Client/_CP14/Workbench/CP14WorkbenchWindow.xaml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +