Skip to content

Commit

Permalink
Merge branch 'SerbiaStrong-220:master' into UppMachineGun
Browse files Browse the repository at this point in the history
  • Loading branch information
anders0n9 authored Mar 6, 2025
2 parents 8b4e4db + 8c4b966 commit deb285d
Show file tree
Hide file tree
Showing 172 changed files with 3,009 additions and 290 deletions.
3 changes: 1 addition & 2 deletions Content.Client/PDA/PdaBoundUserInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ protected override void Open()

private void CreateMenu()
{
_menu = this.CreateWindow<PdaMenu>();
_menu.OpenCenteredLeft();
_menu = this.CreateWindowCenteredLeft<PdaMenu>();

_menu.FlashLightToggleButton.OnToggled += _ =>
{
Expand Down
50 changes: 50 additions & 0 deletions Content.Client/SS220/PdaIdPainter/PdaIdPainter.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<controls:FancyWindow xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
MinSize="500 300"
SetSize="500 500"
Title="{Loc 'pda-id-painter-window-title'}">
<BoxContainer Orientation="Horizontal"
HorizontalExpand="True"
VerticalExpand="True"
SeparationOverride="4"
MinWidth="450">
<BoxContainer Orientation="Vertical"
HorizontalExpand="True"
VerticalExpand="True"
SeparationOverride="4"
MinWidth="200">
<Button Name="InsertPdaButton"
Access="Public"
StyleClasses="OpenBoth"
Text="{Loc 'pda-id-painter-window-insert-pda-button'}"/>
<LineEdit Name="SearchPdaBar"
PlaceHolder="{Loc 'pda-id-painter-window-search-pda-bar'}"
HorizontalExpand="True" />
<Label Name="SelectedPdaLabel"
Text="{Loc 'pda-id-painter-window-select-pda-label'}">
</Label>
<ScrollContainer VerticalExpand="True">
<BoxContainer Name="PdaList" Orientation="Vertical"/>
</ScrollContainer>
</BoxContainer>
<BoxContainer Orientation="Vertical"
HorizontalExpand="True"
VerticalExpand="True"
SeparationOverride="4"
MinWidth="200">
<Button Name="InsertIdButton"
Access="Public"
StyleClasses="OpenBoth"
Text="{Loc 'pda-id-painter-window-insert-id-card-button'}"/>
<LineEdit Name="SearchIdBar"
PlaceHolder="{Loc 'pda-id-painter-window-search-id-card-bar'}"
HorizontalExpand="True" />
<Label Name="SelectedIdLabel"
Text="{Loc 'pda-id-painter-window-select-id-card-label'}"/>
<ScrollContainer VerticalExpand="True">
<BoxContainer Name="IdList" Orientation="Vertical"/>
</ScrollContainer>
</BoxContainer>
</BoxContainer>

</controls:FancyWindow>
112 changes: 112 additions & 0 deletions Content.Client/SS220/PdaIdPainter/PdaIdPainter.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
using System.Numerics;
using Content.Client.UserInterface.Controls;
using Content.Shared.Access.Components;
using Content.Shared.PDA;
using Content.Shared.Prototypes;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Prototypes;

namespace Content.Client.SS220.PdaIdPainter;

[GenerateTypedNameReferences]
public sealed partial class PdaIdPainter : FancyWindow
{
public Action<string>? OnPdaPicked;
public Action<string>? OnIdPicked;

public HashSet<EntityPrototype> PdaAndIds = [];

public PdaIdPainter()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
SearchPdaBar.OnTextChanged += OnSearchBarTextChanged;
SearchIdBar.OnTextChanged += OnSearchBarTextChanged;
}

private void OnSearchBarTextChanged(LineEdit.LineEditEventArgs args)
{
PopulateList(null, null);
}

private void PopulateList(EntProtoId? pdaDefaultProto, EntProtoId? idDefaultProto)
{
PdaList.RemoveAllChildren();
IdList.RemoveAllChildren();

var searchPdaTerm = SearchPdaBar.Text.ToLower();
var searchIdTerm = SearchIdBar.Text.ToLower();

var groupForId = new ButtonGroup();
var groupForPda = new ButtonGroup();

foreach (var entry in PdaAndIds)
{
if (entry.HasComponent<PdaComponent>() &&
(string.IsNullOrEmpty(searchPdaTerm) || entry.Name.Contains(searchPdaTerm as string, StringComparison.CurrentCultureIgnoreCase)))
{
var button = CreateButton(entry, groupForPda, pdaDefaultProto?.Id, OnPdaPicked);
PdaList.AddChild(button);
}

if (entry.HasComponent<IdCardComponent>() &&
(string.IsNullOrEmpty(searchIdTerm) || entry.Name.Contains(searchIdTerm as string, StringComparison.CurrentCultureIgnoreCase)))
{
var button = CreateButton(entry, groupForId, idDefaultProto?.Id, OnIdPicked);
IdList.AddChild(button);
}
}
}

private Button CreateButton(EntityPrototype entry, ButtonGroup group, string? defaultId, Action<string>? onPicked)
{
var button = new Button
{
HorizontalExpand = true,
Group = group,
StyleClasses = { "OpenBoth" },
ToggleMode = true,
Pressed = entry.ID == defaultId
};

var hbox = new BoxContainer
{
Orientation = BoxContainer.LayoutOrientation.Horizontal,
SeparationOverride = 10,
HorizontalExpand = true,
};

var iconTexture = new EntityPrototypeView
{
MinSize = new Vector2(32, 32),
MaxSize = new Vector2(32, 32),
};
iconTexture.SetPrototype(entry);

var labelForTexture = new Label
{
Text = entry.Name,
HorizontalExpand = true,
};

hbox.AddChild(iconTexture);
hbox.AddChild(labelForTexture);
button.AddChild(hbox);

button.OnPressed += _ =>
{
onPicked?.Invoke(entry.ID);
button.Pressed = true;
};

return button;
}

public void Populate(HashSet<EntityPrototype> entries, EntProtoId? pdaDefaultProto, EntProtoId? idDefaultProto)
{
PdaAndIds = entries;
PopulateList(pdaDefaultProto, idDefaultProto);
}
}
104 changes: 104 additions & 0 deletions Content.Client/SS220/PdaIdPainter/PdaIdPainterBoundUserInterface.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
using Content.Shared.Containers.ItemSlots;
using Content.Shared.SS220.PdaIdPainter;
using Robust.Client.UserInterface;
using Robust.Shared.Prototypes;

namespace Content.Client.SS220.PdaIdPainter;

public sealed partial class PdaIdPainterBoundUserInterface : BoundUserInterface
{
private PdaIdPainter? _window;

public PdaIdPainterBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}

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

if (_window == null)
return;

if (state is not PdaIdPainterBoundState args)
return;

var targetPda = EntMan.GetEntity(args.TargetPda);
var targetId = EntMan.GetEntity(args.TargetId);

_window.InsertIdButton.Text = args.TargetId.HasValue
? Loc.GetString("pda-id-painter-console-eject-button")
: Loc.GetString("pda-id-painter-console-insert-button");

_window.InsertPdaButton.Text = args.TargetPda.HasValue
? Loc.GetString("pda-id-painter-console-eject-button")
: Loc.GetString("pda-id-painter-console-insert-button");
UpdatePopulate(targetPda, targetId);
}

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

_window = this.CreateWindow<PdaIdPainter>();

_window.OnPdaPicked = OnPdaPicked;
_window.OnIdPicked = OnIdPicked;

if (EntMan.TryGetComponent(Owner, out PdaIdPainterComponent? comp))
{
UpdatePopulate(comp.PdaSlot.Item, comp.IdCardSlot.Item);
}

_window.InsertIdButton.OnPressed += _ => SendMessage(new ItemSlotButtonPressedEvent(PdaIdPainterComponent.IdPainterSlot));
_window.InsertPdaButton.OnPressed += _ => SendMessage(new ItemSlotButtonPressedEvent(PdaIdPainterComponent.PdaPainterSlot));
}

private void UpdatePopulate(EntityUid? targetPda, EntityUid? targetId)
{
EntProtoId? chosenPda = null;
EntProtoId? chosenId = null;

if (_window?.PdaAndIds == null)
return;

if (EntMan.TryGetComponent<PdaIdPainterTargetComponent>(targetId, out var idComp))
{
chosenId = idComp.NewProto;
}
else
{
if (EntMan.TryGetComponent(targetId, out MetaDataComponent? metaDataComponent) &&
metaDataComponent.EntityPrototype != null)
{
chosenId = metaDataComponent.EntityPrototype.ID;
}
}

if (EntMan.TryGetComponent<PdaIdPainterTargetComponent>(targetPda, out var pdaComp))
{
chosenPda = pdaComp.NewProto;
}
else
{
if (EntMan.TryGetComponent(targetPda, out MetaDataComponent? metaDataComponent) &&
metaDataComponent.EntityPrototype != null)
{
chosenPda = metaDataComponent.EntityPrototype.ID;
}
}

_window.Populate(EntMan.System<PdaIdPainterSystem>().PdaAndIdProtos, chosenPda, chosenId);
}

private void OnPdaPicked(string args)
{
SendMessage(new PdaIdPainterPickedPdaMessage(args));
}

private void OnIdPicked(string args)
{
SendMessage(new PdaIdPainterPickedIdMessage(args));
}

}
74 changes: 74 additions & 0 deletions Content.Client/SS220/PdaIdPainter/PdaIdPainterSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
using Content.Client.PDA;
using Content.Shared.SS220.PdaIdPainter;
using Robust.Client.GameObjects;
using Robust.Shared.Prototypes;

namespace Content.Client.SS220.PdaIdPainter;

public sealed class PdaIdPainterSystem : SharedPdaIdPainterSystem
{
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly IComponentFactory _factory = default!;

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

GetAllVariants();

SubscribeLocalEvent<PrototypesReloadedEventArgs>(OnProtoReloaded);
SubscribeLocalEvent<PdaIdPainterTargetComponent, AfterAutoHandleStateEvent>(HandleState);
}

private void HandleState(Entity<PdaIdPainterTargetComponent> ent, ref AfterAutoHandleStateEvent args)
{
UpdateVisuals(ent.Comp.NewProto, ent.Owner);
}

private void OnProtoReloaded(PrototypesReloadedEventArgs args)
{
if (args.WasModified<EntityPrototype>())
GetAllVariants();
}

private void GetAllVariants()
{
PdaAndIdProtos.Clear();

var prototypes = _proto.EnumeratePrototypes<EntityPrototype>();

foreach (var proto in prototypes)
{
if (!IsValidTarget(proto))
continue;

PdaAndIdProtos.Add(proto);
}
}

protected override void UpdateSprite(EntityUid uid, EntityPrototype proto)
{
base.UpdateSprite(uid, proto);

if (TryComp(uid, out SpriteComponent? sprite)
&& proto.TryGetComponent(out SpriteComponent? otherSprite, _factory))
{
sprite.CopyFrom(otherSprite);
}

if (TryComp(uid, out IconComponent? icon)
&& proto.TryGetComponent(out IconComponent? otherIcon, _factory))
{
icon.Icon = otherIcon.Icon;
}

if (!TryComp(uid, out PdaBorderColorComponent? borderColor)
|| !proto.TryGetComponent(out PdaBorderColorComponent? otherBorderColor, _factory))
return;

borderColor.BorderColor = otherBorderColor.BorderColor;
borderColor.AccentHColor = otherBorderColor.AccentHColor;
borderColor.AccentVColor = otherBorderColor.AccentVColor;

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt
using Content.Shared.SS220.SmartGasMask.Events;
using Content.Shared.SS220.SmartGasMask.Prototype;
using Robust.Client.UserInterface;
using Robust.Shared.Prototypes;

namespace Content.Client.SS220.SmartGasMask;

public sealed class SmartGasMaskBoundUserInterface : BoundUserInterface
{
private SmartGasMaskMenu? _smartGasMaskMenu;

public SmartGasMaskBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
IoCManager.InjectDependencies(this);
}

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

_smartGasMaskMenu = this.CreateWindow<SmartGasMaskMenu>();
_smartGasMaskMenu.SetEntity(Owner);
_smartGasMaskMenu.SendAlertSmartGasMaskRadioMessageAction += SendAlertSmartGasMaskRadioMessage;
}

private void SendAlertSmartGasMaskRadioMessage(ProtoId<AlertSmartGasMaskPrototype> protoId)
{
SendMessage(new SmartGasMaskMessage(protoId));
}
}
8 changes: 8 additions & 0 deletions Content.Client/SS220/SmartGasMask/SmartGasMaskMenu.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<ui:RadialMenu
xmlns:ui="clr-namespace:Content.Client.UserInterface.Controls"
CloseButtonStyleClass="RadialMenuCloseButton"
VerticalExpand="True"
HorizontalExpand="True">
<ui:RadialContainer Name="Main">
</ui:RadialContainer>
</ui:RadialMenu>
Loading

0 comments on commit deb285d

Please sign in to comment.