forked from space-wizards/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'SerbiaStrong-220:master' into UppMachineGun
- Loading branch information
Showing
172 changed files
with
3,009 additions
and
290 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
104
Content.Client/SS220/PdaIdPainter/PdaIdPainterBoundUserInterface.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
Content.Client/SS220/SmartGasMask/SmartGasMaskBoundUserInterface.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Oops, something went wrong.