Borgs (#18136)
* Laws * positronic brain and PAI rewrite * MMI * MMI pt. 2 * borg brain transfer * Roleban support, Borg job (WIP), the end of mind shenaniganry * battery drain, item slot cleanup, alerts * visuals * fix this pt1 * fix this pt2 * Modules, Lingering Stacks, Better borg flashlight * Start on UI, fix battery alerts, expand activation/deactivation, low movement speed on no power. * sprotes * no zombie borgs * oh fuck yeah i love a good relay * charger * fix the tiniest of sprite issues * adjustable names * a functional UI???? * foobar * more modules * this shit for some reason * upstream * genericize selectable borg modules * upstream again * holy fucking shit * i love christ * proper construction * da job * AA borgs * and boom more shit * admin logs * laws redux * ok just do this rq * oh boy that looks like modules * oh shit research * testos passo * so much shit holy fuck * fuckit we SHIP * last minute snags * should've gotten me on a better day
This commit is contained in:
66
Content.Client/Silicons/Borgs/BorgBoundUserInterface.cs
Normal file
66
Content.Client/Silicons/Borgs/BorgBoundUserInterface.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using Content.Shared.Silicons.Borgs;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
|
||||
namespace Content.Client.Silicons.Borgs;
|
||||
|
||||
[UsedImplicitly]
|
||||
public sealed class BorgBoundUserInterface : BoundUserInterface
|
||||
{
|
||||
[ViewVariables]
|
||||
private BorgMenu? _menu;
|
||||
|
||||
public BorgBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Open()
|
||||
{
|
||||
base.Open();
|
||||
|
||||
var owner = Owner;
|
||||
|
||||
_menu = new BorgMenu(owner);
|
||||
|
||||
_menu.BrainButtonPressed += () =>
|
||||
{
|
||||
SendMessage(new BorgEjectBrainBuiMessage());
|
||||
};
|
||||
|
||||
_menu.EjectBatteryButtonPressed += () =>
|
||||
{
|
||||
SendMessage(new BorgEjectBatteryBuiMessage());
|
||||
};
|
||||
|
||||
_menu.NameChanged += name =>
|
||||
{
|
||||
SendMessage(new BorgSetNameBuiMessage(name));
|
||||
};
|
||||
|
||||
_menu.RemoveModuleButtonPressed += module =>
|
||||
{
|
||||
SendMessage(new BorgRemoveModuleBuiMessage(module));
|
||||
};
|
||||
|
||||
_menu.OnClose += Close;
|
||||
|
||||
_menu.OpenCentered();
|
||||
}
|
||||
|
||||
protected override void UpdateState(BoundUserInterfaceState state)
|
||||
{
|
||||
base.UpdateState(state);
|
||||
|
||||
if (state is not BorgBuiState msg)
|
||||
return;
|
||||
_menu?.UpdateState(msg);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
if (!disposing)
|
||||
return;
|
||||
_menu?.Dispose();
|
||||
}
|
||||
}
|
||||
58
Content.Client/Silicons/Borgs/BorgMenu.xaml
Normal file
58
Content.Client/Silicons/Borgs/BorgMenu.xaml
Normal file
@@ -0,0 +1,58 @@
|
||||
<controls:FancyWindow xmlns="https://spacestation14.io"
|
||||
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
|
||||
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
|
||||
xmlns:customControls="clr-namespace:Content.Client.Administration.UI.CustomControls"
|
||||
Title="{Loc 'borg-ui-menu-title'}"
|
||||
MinSize="600 350"
|
||||
SetSize="650 450">
|
||||
<BoxContainer Orientation="Horizontal"
|
||||
HorizontalExpand="True"
|
||||
VerticalExpand="True">
|
||||
<BoxContainer Orientation="Vertical" VerticalExpand="True" HorizontalExpand="True" Margin="15 10 15 15">
|
||||
<BoxContainer Orientation="Horizontal">
|
||||
<ProgressBar Name="ChargeBar" Access="Public" HorizontalExpand="True" MinValue="0" MaxValue="1">
|
||||
<Label Name="ChargeLabel" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="5 0 0 0"/>
|
||||
</ProgressBar>
|
||||
<Control MinWidth="5"/>
|
||||
<Button Name="EjectBatteryButton" Text="{Loc 'borg-ui-remove-battery'}" StyleClasses="OpenLeft"/>
|
||||
</BoxContainer>
|
||||
<customControls:HSeparator Margin="0 10 0 10"/>
|
||||
<PanelContainer VerticalExpand="True">
|
||||
<PanelContainer.PanelOverride>
|
||||
<gfx:StyleBoxFlat BackgroundColor="#1B1B1E"/>
|
||||
</PanelContainer.PanelOverride>
|
||||
<BoxContainer HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<SpriteView Name="BorgSprite" Scale="5 5"/>
|
||||
</BoxContainer>
|
||||
</PanelContainer>
|
||||
<customControls:HSeparator Margin="0 10 0 10"/>
|
||||
<BoxContainer Orientation="Horizontal">
|
||||
<LineEdit Name="NameLineEdit" HorizontalExpand="True"/>
|
||||
<Label Name="NameIdentifierLabel" Margin="10 0 0 0"/>
|
||||
</BoxContainer>
|
||||
<Control MinHeight="10"/>
|
||||
<Button HorizontalExpand="True" Name="BrainButton" ToggleMode="False" Margin="0" MinHeight="40" StyleClasses="OpenLeft">
|
||||
<SpriteView Name="BrainView" HorizontalAlignment="Left" VerticalAlignment="Center"/>
|
||||
</Button>
|
||||
</BoxContainer>
|
||||
<customControls:VSeparator/>
|
||||
<BoxContainer Orientation="Vertical" VerticalExpand="True" HorizontalExpand="True" Margin="15 10 15 15">
|
||||
<Label Text="{Loc 'borg-ui-modules-label'}" Margin="0 0 0 5"/>
|
||||
<PanelContainer VerticalExpand="True">
|
||||
<PanelContainer.PanelOverride>
|
||||
<gfx:StyleBoxFlat BackgroundColor="#1B1B1E"/>
|
||||
</PanelContainer.PanelOverride>
|
||||
<BoxContainer VerticalExpand="True" Orientation="Vertical">
|
||||
<ScrollContainer HScrollEnabled="False" HorizontalExpand="True" VerticalExpand="True">
|
||||
<BoxContainer Orientation="Vertical" HorizontalExpand="True" VerticalExpand="True" Name="ModuleContainer" RectClipContent="True"/>
|
||||
</ScrollContainer>
|
||||
<Label Name="ModuleCounter"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Bottom"
|
||||
StyleClasses="WindowFooterText"
|
||||
Margin="5"/>
|
||||
</BoxContainer>
|
||||
</PanelContainer>
|
||||
</BoxContainer>
|
||||
</BoxContainer>
|
||||
</controls:FancyWindow>
|
||||
165
Content.Client/Silicons/Borgs/BorgMenu.xaml.cs
Normal file
165
Content.Client/Silicons/Borgs/BorgMenu.xaml.cs
Normal file
@@ -0,0 +1,165 @@
|
||||
using Content.Client.Stylesheets;
|
||||
using Content.Client.UserInterface.Controls;
|
||||
using Content.Shared.NameIdentifier;
|
||||
using Content.Shared.Preferences;
|
||||
using Content.Shared.Silicons.Borgs;
|
||||
using Content.Shared.Silicons.Borgs.Components;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Client.Silicons.Borgs;
|
||||
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class BorgMenu : FancyWindow
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entity = default!;
|
||||
|
||||
public Action? BrainButtonPressed;
|
||||
public Action? EjectBatteryButtonPressed;
|
||||
public Action<string>? NameChanged;
|
||||
public Action<EntityUid>? RemoveModuleButtonPressed;
|
||||
|
||||
private readonly BorgChassisComponent? _chassis;
|
||||
public readonly EntityUid Entity;
|
||||
public float AccumulatedTime;
|
||||
private string _lastValidName;
|
||||
|
||||
public BorgMenu(EntityUid entity)
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
Entity = entity;
|
||||
|
||||
if (_entity.TryGetComponent<BorgChassisComponent>(Entity, out var chassis))
|
||||
_chassis = chassis;
|
||||
|
||||
BorgSprite.SetEntity(entity);
|
||||
ChargeBar.MaxValue = 1f;
|
||||
ChargeBar.Value = 1f;
|
||||
|
||||
if (_entity.TryGetComponent<NameIdentifierComponent>(Entity, out var nameIdentifierComponent))
|
||||
{
|
||||
NameIdentifierLabel.Visible = true;
|
||||
NameIdentifierLabel.Text = nameIdentifierComponent.FullIdentifier;
|
||||
|
||||
var fullName = _entity.GetComponent<MetaDataComponent>(Entity).EntityName;
|
||||
var name = fullName.Substring(0, fullName.Length - nameIdentifierComponent.FullIdentifier.Length - 1);
|
||||
NameLineEdit.Text = name;
|
||||
}
|
||||
else
|
||||
{
|
||||
NameIdentifierLabel.Visible = false;
|
||||
NameLineEdit.Text = _entity.GetComponent<MetaDataComponent>(Entity).EntityName;
|
||||
}
|
||||
|
||||
_lastValidName = NameLineEdit.Text;
|
||||
|
||||
EjectBatteryButton.OnPressed += _ => EjectBatteryButtonPressed?.Invoke();
|
||||
BrainButton.OnPressed += _ => BrainButtonPressed?.Invoke();
|
||||
|
||||
NameLineEdit.OnTextChanged += OnNameChanged;
|
||||
NameLineEdit.OnTextEntered += OnNameEntered;
|
||||
NameLineEdit.OnFocusExit += OnNameFocusExit;
|
||||
|
||||
UpdateBrainButton();
|
||||
}
|
||||
|
||||
protected override void FrameUpdate(FrameEventArgs args)
|
||||
{
|
||||
base.FrameUpdate(args);
|
||||
|
||||
AccumulatedTime += args.DeltaSeconds;
|
||||
BorgSprite.OverrideDirection = (Direction) ((int) AccumulatedTime % 4 * 2);
|
||||
}
|
||||
|
||||
public void UpdateState(BorgBuiState state)
|
||||
{
|
||||
EjectBatteryButton.Disabled = !state.HasBattery;
|
||||
ChargeBar.Value = state.ChargePercent;
|
||||
ChargeLabel.Text = Loc.GetString("borg-ui-charge-label",
|
||||
("charge", (int) MathF.Round(state.ChargePercent * 100)));
|
||||
|
||||
UpdateBrainButton();
|
||||
UpdateModulePanel();
|
||||
}
|
||||
|
||||
private void UpdateBrainButton()
|
||||
{
|
||||
if (_chassis?.BrainEntity is { } brain)
|
||||
{
|
||||
BrainButton.Text = _entity.GetComponent<MetaDataComponent>(brain).EntityName;
|
||||
BrainView.Visible = true;
|
||||
BrainView.SetEntity(brain);
|
||||
BrainButton.Disabled = false;
|
||||
BrainButton.AddStyleClass(StyleBase.ButtonOpenLeft);
|
||||
}
|
||||
else
|
||||
{
|
||||
BrainButton.Text = Loc.GetString("borg-ui-no-brain");
|
||||
BrainButton.Disabled = true;
|
||||
BrainView.Visible = false;
|
||||
BrainButton.RemoveStyleClass(StyleBase.ButtonOpenLeft);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateModulePanel()
|
||||
{
|
||||
if (_chassis == null)
|
||||
return;
|
||||
|
||||
ModuleCounter.Text = Loc.GetString("borg-ui-module-counter",
|
||||
("actual", _chassis.ModuleCount),
|
||||
("max", _chassis.MaxModules));
|
||||
|
||||
ModuleContainer.Children.Clear();
|
||||
foreach (var module in _chassis.ModuleContainer.ContainedEntities)
|
||||
{
|
||||
var control = new BorgModuleControl(module, _entity);
|
||||
control.RemoveButtonPressed += () =>
|
||||
{
|
||||
RemoveModuleButtonPressed?.Invoke(module);
|
||||
};
|
||||
ModuleContainer.AddChild(control);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnNameChanged(LineEdit.LineEditEventArgs obj)
|
||||
{
|
||||
if (obj.Text.Length == 0 ||
|
||||
string.IsNullOrWhiteSpace(obj.Text) ||
|
||||
string.IsNullOrEmpty(obj.Text))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj.Text.Length > HumanoidCharacterProfile.MaxNameLength)
|
||||
{
|
||||
obj.Control.Text = obj.Text.Substring(0, HumanoidCharacterProfile.MaxNameLength);
|
||||
}
|
||||
|
||||
_lastValidName = obj.Control.Text;
|
||||
obj.Control.Text = _lastValidName;
|
||||
}
|
||||
|
||||
private void OnNameEntered(LineEdit.LineEditEventArgs obj)
|
||||
{
|
||||
NameChanged?.Invoke(_lastValidName);
|
||||
}
|
||||
|
||||
private void OnNameFocusExit(LineEdit.LineEditEventArgs obj)
|
||||
{
|
||||
if (obj.Text.Length > HumanoidCharacterProfile.MaxNameLength ||
|
||||
obj.Text.Length == 0 ||
|
||||
string.IsNullOrWhiteSpace(obj.Text) ||
|
||||
string.IsNullOrEmpty(obj.Text))
|
||||
{
|
||||
obj.Control.Text = _lastValidName.Trim();
|
||||
}
|
||||
|
||||
NameChanged?.Invoke(_lastValidName);
|
||||
}
|
||||
}
|
||||
|
||||
12
Content.Client/Silicons/Borgs/BorgModuleControl.xaml
Normal file
12
Content.Client/Silicons/Borgs/BorgModuleControl.xaml
Normal file
@@ -0,0 +1,12 @@
|
||||
<PanelContainer xmlns="https://spacestation14.io"
|
||||
HorizontalExpand="True"
|
||||
StyleClasses="PanelBackgroundLight"
|
||||
Margin="5 5 5 0">
|
||||
<BoxContainer Orientation="Horizontal" HorizontalExpand="True" Margin="5 5 0 5">
|
||||
<SpriteView Name="ModuleView" Margin="0 0 5 0"/>
|
||||
<BoxContainer RectClipContent="True" HorizontalExpand="True">
|
||||
<Label Name="ModuleName" HorizontalExpand="True" HorizontalAlignment="Center"/>
|
||||
</BoxContainer>
|
||||
<TextureButton Name="RemoveButton" VerticalAlignment="Top" HorizontalAlignment="Right" Scale="0.5 0.5"/>
|
||||
</BoxContainer>
|
||||
</PanelContainer>
|
||||
25
Content.Client/Silicons/Borgs/BorgModuleControl.xaml.cs
Normal file
25
Content.Client/Silicons/Borgs/BorgModuleControl.xaml.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
|
||||
namespace Content.Client.Silicons.Borgs;
|
||||
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class BorgModuleControl : PanelContainer
|
||||
{
|
||||
public Action? RemoveButtonPressed;
|
||||
|
||||
public BorgModuleControl(EntityUid entity, IEntityManager entityManager)
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
|
||||
ModuleView.SetEntity(entity);
|
||||
ModuleName.Text = entityManager.GetComponent<MetaDataComponent>(entity).EntityName;
|
||||
RemoveButton.TexturePath = "/Textures/Interface/Nano/cross.svg.png";
|
||||
RemoveButton.OnPressed += _ =>
|
||||
{
|
||||
RemoveButtonPressed?.Invoke();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
85
Content.Client/Silicons/Borgs/BorgSystem.cs
Normal file
85
Content.Client/Silicons/Borgs/BorgSystem.cs
Normal file
@@ -0,0 +1,85 @@
|
||||
using Content.Shared.Silicons.Borgs;
|
||||
using Content.Shared.Silicons.Borgs.Components;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.Containers;
|
||||
|
||||
namespace Content.Client.Silicons.Borgs;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public sealed class BorgSystem : SharedBorgSystem
|
||||
{
|
||||
[Dependency] private readonly AppearanceSystem _appearance = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<BorgChassisComponent, AppearanceChangeEvent>(OnBorgAppearanceChanged);
|
||||
SubscribeLocalEvent<MMIComponent, AppearanceChangeEvent>(OnMMIAppearanceChanged);
|
||||
}
|
||||
|
||||
private void OnBorgAppearanceChanged(EntityUid uid, BorgChassisComponent component, ref AppearanceChangeEvent args)
|
||||
{
|
||||
if (args.Sprite == null)
|
||||
return;
|
||||
UpdateBorgAppearnce(uid, component, args.Component, args.Sprite);
|
||||
}
|
||||
|
||||
protected override void OnInserted(EntityUid uid, BorgChassisComponent component, EntInsertedIntoContainerMessage args)
|
||||
{
|
||||
if (!component.Initialized)
|
||||
return;
|
||||
|
||||
base.OnInserted(uid, component, args);
|
||||
UpdateBorgAppearnce(uid, component);
|
||||
}
|
||||
|
||||
protected override void OnRemoved(EntityUid uid, BorgChassisComponent component, EntRemovedFromContainerMessage args)
|
||||
{
|
||||
if (!component.Initialized)
|
||||
return;
|
||||
|
||||
base.OnRemoved(uid, component, args);
|
||||
UpdateBorgAppearnce(uid, component);
|
||||
}
|
||||
|
||||
private void UpdateBorgAppearnce(EntityUid uid,
|
||||
BorgChassisComponent? component = null,
|
||||
AppearanceComponent? appearance = null,
|
||||
SpriteComponent? sprite = null)
|
||||
{
|
||||
if (!Resolve(uid, ref component, ref appearance, ref sprite))
|
||||
return;
|
||||
|
||||
if (!_appearance.TryGetData<bool>(uid, BorgVisuals.HasPlayer, out var hasPlayer, appearance))
|
||||
hasPlayer = false;
|
||||
|
||||
sprite.LayerSetVisible(BorgVisualLayers.Light, component.BrainEntity != null || hasPlayer);
|
||||
sprite.LayerSetState(BorgVisualLayers.Light, hasPlayer ? component.HasMindState : component.NoMindState);
|
||||
}
|
||||
|
||||
private void OnMMIAppearanceChanged(EntityUid uid, MMIComponent component, ref AppearanceChangeEvent args)
|
||||
{
|
||||
if (args.Sprite == null)
|
||||
return;
|
||||
var sprite = args.Sprite;
|
||||
|
||||
if (!_appearance.TryGetData(uid, MMIVisuals.BrainPresent, out bool brain))
|
||||
brain = false;
|
||||
if (!_appearance.TryGetData(uid, MMIVisuals.HasMind, out bool hasMind))
|
||||
hasMind = false;
|
||||
|
||||
sprite.LayerSetVisible(MMIVisualLayers.Brain, brain);
|
||||
if (!brain)
|
||||
{
|
||||
sprite.LayerSetState(MMIVisualLayers.Base, component.NoBrainState);
|
||||
}
|
||||
else
|
||||
{
|
||||
var state = hasMind
|
||||
? component.HasMindState
|
||||
: component.NoMindState;
|
||||
sprite.LayerSetState(MMIVisualLayers.Base, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
9
Content.Client/Silicons/Laws/SiliconLawSystem.cs
Normal file
9
Content.Client/Silicons/Laws/SiliconLawSystem.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using Content.Shared.Silicons.Laws;
|
||||
|
||||
namespace Content.Client.Silicons.Laws;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public sealed class SiliconLawSystem : SharedSiliconLawSystem
|
||||
{
|
||||
|
||||
}
|
||||
18
Content.Client/Silicons/Laws/Ui/LawDisplay.xaml
Normal file
18
Content.Client/Silicons/Laws/Ui/LawDisplay.xaml
Normal file
@@ -0,0 +1,18 @@
|
||||
<Control xmlns="https://spacestation14.io"
|
||||
xmlns:customControls="clr-namespace:Content.Client.Administration.UI.CustomControls"
|
||||
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
|
||||
Margin="0 0 0 10">
|
||||
<PanelContainer VerticalExpand="True">
|
||||
<PanelContainer.PanelOverride>
|
||||
<gfx:StyleBoxFlat BackgroundColor="#25252a"/>
|
||||
</PanelContainer.PanelOverride>
|
||||
<BoxContainer Orientation="Vertical"
|
||||
HorizontalExpand="True"
|
||||
VerticalExpand="True"
|
||||
Margin="5 5 5 5">
|
||||
<Label Name="LawNumberLabel" StyleClasses="StatusFieldTitle"/>
|
||||
<customControls:HSeparator Margin="0 5 0 5"/>
|
||||
<RichTextLabel Name="LawLabel"/>
|
||||
</BoxContainer>
|
||||
</PanelContainer>
|
||||
</Control>
|
||||
21
Content.Client/Silicons/Laws/Ui/LawDisplay.xaml.cs
Normal file
21
Content.Client/Silicons/Laws/Ui/LawDisplay.xaml.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using Content.Shared.Silicons.Laws;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
|
||||
namespace Content.Client.Silicons.Laws.Ui;
|
||||
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class LawDisplay : Control
|
||||
{
|
||||
public LawDisplay(SiliconLaw prototype)
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
|
||||
var identifier = prototype.LawIdentifierOverride ?? $"{prototype.Order}";
|
||||
|
||||
LawNumberLabel.Text = Loc.GetString("laws-ui-law-header", ("id", identifier));
|
||||
LawLabel.SetMessage(Loc.GetString(prototype.LawString));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
using Content.Shared.Silicons.Laws.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
|
||||
namespace Content.Client.Silicons.Laws.Ui;
|
||||
|
||||
[UsedImplicitly]
|
||||
public sealed class SiliconLawBoundUserInterface : BoundUserInterface
|
||||
{
|
||||
[ViewVariables]
|
||||
private SiliconLawMenu? _menu;
|
||||
|
||||
public SiliconLawBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void Open()
|
||||
{
|
||||
base.Open();
|
||||
|
||||
_menu = new();
|
||||
|
||||
_menu.OnClose += Close;
|
||||
_menu.OpenCentered();
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
if (!disposing)
|
||||
return;
|
||||
_menu?.Close();
|
||||
}
|
||||
|
||||
protected override void UpdateState(BoundUserInterfaceState state)
|
||||
{
|
||||
base.UpdateState(state);
|
||||
|
||||
if (state is not SiliconLawBuiState msg)
|
||||
return;
|
||||
|
||||
_menu?.Update(msg);
|
||||
}
|
||||
}
|
||||
27
Content.Client/Silicons/Laws/Ui/SiliconLawMenu.xaml
Normal file
27
Content.Client/Silicons/Laws/Ui/SiliconLawMenu.xaml
Normal file
@@ -0,0 +1,27 @@
|
||||
<controls:FancyWindow xmlns="https://spacestation14.io"
|
||||
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
|
||||
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
|
||||
Title="{Loc 'laws-ui-menu-title'}"
|
||||
MinSize="200 100"
|
||||
SetSize="450 385">
|
||||
<BoxContainer Orientation="Vertical"
|
||||
HorizontalExpand="True"
|
||||
VerticalExpand="True">
|
||||
<PanelContainer VerticalExpand="True" Margin="10 10 10 10">
|
||||
<PanelContainer.PanelOverride>
|
||||
<gfx:StyleBoxFlat BackgroundColor="#1B1B1E"/>
|
||||
</PanelContainer.PanelOverride>
|
||||
<ScrollContainer
|
||||
HScrollEnabled="False"
|
||||
HorizontalExpand="True"
|
||||
VerticalExpand="True">
|
||||
<BoxContainer
|
||||
Name="LawDisplayContainer"
|
||||
Orientation="Vertical"
|
||||
VerticalExpand="True"
|
||||
Margin="10 10 10 0">
|
||||
</BoxContainer>
|
||||
</ScrollContainer>
|
||||
</PanelContainer>
|
||||
</BoxContainer>
|
||||
</controls:FancyWindow>
|
||||
31
Content.Client/Silicons/Laws/Ui/SiliconLawMenu.xaml.cs
Normal file
31
Content.Client/Silicons/Laws/Ui/SiliconLawMenu.xaml.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using Content.Client.UserInterface.Controls;
|
||||
using Content.Shared.Silicons.Laws.Components;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Client.Silicons.Laws.Ui;
|
||||
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class SiliconLawMenu : FancyWindow
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototype = default!;
|
||||
|
||||
public SiliconLawMenu()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
IoCManager.InjectDependencies(this);
|
||||
}
|
||||
|
||||
public void Update(SiliconLawBuiState state)
|
||||
{
|
||||
state.Laws.Sort();
|
||||
foreach (var law in state.Laws)
|
||||
{
|
||||
var control = new LawDisplay(law);
|
||||
|
||||
LawDisplayContainer.AddChild(control);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user