Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from DeltaV-Station:master #6

Merged
merged 16 commits into from
Oct 19, 2023
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Content.Shared.Kitchen.Components;

namespace Content.Client.Kitchen.Components
{
[RegisterComponent]
//Unnecessary item: [ComponentReference(typeof(SharedDeepFriedComponent))]
public sealed partial class DeepFriedComponent : SharedDeepFriedComponent
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Content.Shared.Kitchen.Components;

namespace Content.Client.Kitchen.Components
{
[RegisterComponent]
// Unnecessary line: [ComponentReference(typeof(SharedDeepFryerComponent))]
public sealed partial class DeepFryerComponent : SharedDeepFryerComponent
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using Robust.Client.GameObjects;
using Content.Shared.Kitchen.UI;

namespace Content.Client.Nyanotrasen.Kitchen.UI
{
public sealed class DeepFryerBoundUserInterface : BoundUserInterface
{
private DeepFryerWindow? _window;

private NetEntity[] _entities = default!;

public DeepFryerBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
base.Open();
_window = new DeepFryerWindow();
_window.OnClose += Close;
_window.ItemList.OnItemSelected += args =>
{
SendMessage(new DeepFryerRemoveItemMessage(_entities[args.ItemIndex]));
};
_window.InsertItem.OnPressed += _ =>
{
SendMessage(new DeepFryerInsertItemMessage());
};
_window.ScoopVat.OnPressed += _ =>
{
SendMessage(new DeepFryerScoopVatMessage());
};
_window.ClearSlag.OnPressed += args =>
{
SendMessage(new DeepFryerClearSlagMessage());
};
_window.RemoveAllItems.OnPressed += _ =>
{
SendMessage(new DeepFryerRemoveAllItemsMessage());
};
_window.OpenCentered();
}

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

if (_window == null)
return;

if (state is not DeepFryerBoundUserInterfaceState cast)
return;

_entities = cast.ContainedEntities;
_window.UpdateState(cast);
}

protected override void Dispose(bool disposing)
{
base.Dispose(disposing);

if (!disposing)
return;

_window?.Dispose();
}
}
}
67 changes: 67 additions & 0 deletions Content.Client/Nyanotrasen/Kitchen/UI/DeepFryerWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<DefaultWindow xmlns="https://spacestation14.io"
Title="{Loc 'deep-fryer-window-title'}"
MinSize="600 400"
>
<BoxContainer Orientation="Horizontal" VerticalExpand="True">
<BoxContainer
Orientation="Vertical"
HorizontalExpand="True"
>
<Label
Text="{Loc 'deep-fryer-label-baskets'}"
Align="Left"/>
<ItemList Name="ItemList"
Access="Public"
VerticalExpand="True"
HorizontalExpand="True"
SelectMode="Button">
</ItemList>
</BoxContainer>
<BoxContainer
Orientation="Vertical"
Margin="8 0"
MinSize="200 0"
>
<Label Text="{Loc 'deep-fryer-label-oil-level'}"/>
<ProgressBar Name="OilLevel"
HorizontalExpand="True"
MinValue="0"
MaxValue="1"
Page="0"
Value="1">
</ProgressBar>
<Label Text="{Loc 'deep-fryer-label-oil-purity'}"/>
<ProgressBar Name="OilPurity"
HorizontalExpand="True"
MinValue="0"
MaxValue="1"
Page="0"
Value="1">
</ProgressBar>
<Button Name="InsertItem"
Access="Public"
TextAlign="Center"
HorizontalExpand="True"
Text="{Loc 'deep-fryer-button-insert-item'}"
ToolTip="{Loc 'deep-fryer-button-insert-item-tooltip'}"/>
<Button Name="ScoopVat"
Access="Public"
TextAlign="Center"
HorizontalExpand="True"
Text="{Loc 'deep-fryer-button-scoop-vat'}"
ToolTip="{Loc 'deep-fryer-button-scoop-vat-tooltip'}"/>
<Button Name="ClearSlag"
Access="Public"
TextAlign="Center"
HorizontalExpand="True"
Text="{Loc 'deep-fryer-button-clear-slag'}"
ToolTip="{Loc 'deep-fryer-button-clear-slag-tooltip'}"/>
<Button Name="RemoveAllItems"
Access="Public"
TextAlign="Center"
HorizontalExpand="True"
Text="{Loc 'deep-fryer-button-remove-all-items'}"
ToolTip="{Loc 'deep-fryer-button-remove-all-items-tooltip'}"/>
</BoxContainer>
</BoxContainer>
</DefaultWindow>
71 changes: 71 additions & 0 deletions Content.Client/Nyanotrasen/Kitchen/UI/DeepFryerWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using Robust.Client.AutoGenerated;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Content.Shared.Kitchen.UI;

namespace Content.Client.Nyanotrasen.Kitchen.UI
{
[GenerateTypedNameReferences]
[Access(typeof(DeepFryerBoundUserInterface))]
public sealed partial class DeepFryerWindow : DefaultWindow
{
[Dependency] private readonly IEntityManager _entityManager = default!;

private static readonly Color WarningColor = Color.FromHsv(new Vector4(0.0f, 1.0f, 0.8f, 1.0f));

public DeepFryerWindow()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
}

public void UpdateState(DeepFryerBoundUserInterfaceState state)
{
OilLevel.Value = (float) state.OilLevel;
OilPurity.Value = (float) state.OilPurity;

if (state.OilPurity < state.FryingOilThreshold)
{
if (OilPurity.ForegroundStyleBoxOverride == null)
{
OilPurity.ForegroundStyleBoxOverride = new StyleBoxFlat();

var oilPurityStyle = (StyleBoxFlat) OilPurity.ForegroundStyleBoxOverride;
oilPurityStyle.BackgroundColor = WarningColor;
}
}
else
{
OilPurity.ForegroundStyleBoxOverride = null;
}

ItemList.Clear();

foreach (var netEntity in state.ContainedEntities)
{
var entity = _entityManager.GetEntity(netEntity);
if (_entityManager.Deleted(entity))
continue;

// Duplicated from MicrowaveBoundUserInterface.cs: keep an eye on that file for when it changes.
Texture? texture;
if (_entityManager.TryGetComponent(entity, out IconComponent? iconComponent))
{
texture = _entityManager.System<SpriteSystem>().GetIcon(iconComponent);
}
else if (_entityManager.TryGetComponent(entity, out SpriteComponent? spriteComponent))
{
texture = spriteComponent.Icon?.Default;
}
else
{
continue;
}

ItemList.AddItem(_entityManager.GetComponent<MetaDataComponent>(entity).EntityName, texture);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using System.Linq;
using Robust.Client.GameObjects;
using static Robust.Client.GameObjects.SpriteComponent;
using Content.Client.Kitchen.Components;
using Content.Shared.Clothing;
using Content.Shared.Hands;
using Content.Shared.Kitchen.Components;

namespace Content.Client.Kitchen.Visualizers
{
public sealed class DeepFriedVisualizerSystem : VisualizerSystem<DeepFriedComponent>
{
private readonly static string ShaderName = "Crispy";

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<DeepFriedComponent, HeldVisualsUpdatedEvent>(OnHeldVisualsUpdated);
SubscribeLocalEvent<DeepFriedComponent, EquipmentVisualsUpdatedEvent>(OnEquipmentVisualsUpdated);
}

protected override void OnAppearanceChange(EntityUid uid, DeepFriedComponent component, ref AppearanceChangeEvent args)
{
if (args.Sprite == null)
return;

if (!args.Component.TryGetData(DeepFriedVisuals.Fried, out bool isFried))
return;

for (var i = 0; i < args.Sprite.AllLayers.Count(); ++i)
args.Sprite.LayerSetShader(i, ShaderName);
}

private void OnHeldVisualsUpdated(EntityUid uid, DeepFriedComponent component, HeldVisualsUpdatedEvent args)
{
if (args.RevealedLayers.Count == 0)
{
return;
}

if (!TryComp(args.User, out SpriteComponent? sprite))
return;

foreach (var key in args.RevealedLayers)
{
if (!sprite.LayerMapTryGet(key, out var index) || sprite[index] is not Layer layer)
continue;

sprite.LayerSetShader(index, ShaderName);
}
}

private void OnEquipmentVisualsUpdated(EntityUid uid, DeepFriedComponent component, EquipmentVisualsUpdatedEvent args)
{
if (args.RevealedLayers.Count == 0)
{
return;
}

if (!TryComp(args.Equipee, out SpriteComponent? sprite))
return;

foreach (var key in args.RevealedLayers)
{
if (!sprite.LayerMapTryGet(key, out var index) || sprite[index] is not Layer layer)
continue;

sprite.LayerSetShader(index, ShaderName);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Robust.Client.GameObjects;
using Content.Client.Chemistry.Visualizers;
using Content.Client.Kitchen.Components;
using Content.Shared.Kitchen.Components;

namespace Content.Client.Kitchen.Visualizers
{
public sealed class DeepFryerVisualizerSystem : VisualizerSystem<DeepFryerComponent>
{
protected override void OnAppearanceChange(EntityUid uid, DeepFryerComponent component, ref AppearanceChangeEvent args)
{
if (!args.Component.TryGetData(DeepFryerVisuals.Bubbling, out bool isBubbling) ||
!TryComp<SolutionContainerVisualsComponent>(uid, out var scvComponent))
{
return;
}

scvComponent.FillBaseName = isBubbling ? "on-" : "off-";
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Diagnostics.CodeAnalysis;
using Content.Shared.CCVar;
using Content.Shared.Players.PlayTimeTracking;
using Content.Shared.Roles;
using Robust.Shared.Utility;

namespace Content.Client.Players.PlayTimeTracking;

public sealed partial class JobRequirementsManager
{
private bool _whitelisted = false;

private void RxWhitelist(MsgWhitelist message)
{
_whitelisted = message.Whitelisted;
}

public bool IsWhitelisted()
{
return _whitelisted;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace Content.Client.Players.PlayTimeTracking;

public sealed class JobRequirementsManager
public sealed partial class JobRequirementsManager
{
[Dependency] private readonly IBaseClient _client = default!;
[Dependency] private readonly IClientNetManager _net = default!;
Expand All @@ -37,6 +37,7 @@ public void Initialize()
// Yeah the client manager handles role bans and playtime but the server ones are separate DEAL.
_net.RegisterNetMessage<MsgRoleBans>(RxRoleBans);
_net.RegisterNetMessage<MsgPlayTime>(RxPlayTime);
_net.RegisterNetMessage<MsgWhitelist>(RxWhitelist);

_client.RunLevelChanged += ClientOnRunLevelChanged;
}
Expand Down Expand Up @@ -113,7 +114,7 @@ public bool CheckRoleTime(HashSet<JobRequirement>? requirements, [NotNullWhen(fa
var reasons = new List<string>();
foreach (var requirement in requirements)
{
if (JobRequirements.TryRequirementMet(requirement, _roles, out var jobReason, _entManager, _prototypes))
if (JobRequirements.TryRequirementMet(requirement, _roles, out var jobReason, _entManager, _prototypes, _whitelisted))
continue;

reasons.Add(jobReason.ToMarkup());
Expand Down
Loading