Skip to content

Commit

Permalink
Cryogenic Sleep Units (#24096)
Browse files Browse the repository at this point in the history
* Cryogenic sleep units

* pause map support

* no more body deletion

* Cryogenic Storage Units

* boowomp

* no more emag, no more dropping present people
  • Loading branch information
EmoGarbage404 authored Jan 15, 2024
1 parent 1fc3c41 commit 736b9dd
Show file tree
Hide file tree
Showing 38 changed files with 1,376 additions and 8 deletions.
56 changes: 56 additions & 0 deletions Content.Client/Bed/Cryostorage/CryostorageBoundUserInterface.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using Content.Shared.Bed.Cryostorage;
using JetBrains.Annotations;

namespace Content.Client.Bed.Cryostorage;

[UsedImplicitly]
public sealed class CryostorageBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private CryostorageMenu? _menu;

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

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

_menu = new();

_menu.OnClose += Close;

_menu.SlotRemoveButtonPressed += (ent, slot) =>
{
SendMessage(new CryostorageRemoveItemBuiMessage(ent, slot, CryostorageRemoveItemBuiMessage.RemovalType.Inventory));
};

_menu.HandRemoveButtonPressed += (ent, hand) =>
{
SendMessage(new CryostorageRemoveItemBuiMessage(ent, hand, CryostorageRemoveItemBuiMessage.RemovalType.Hand));
};

_menu.OpenCentered();
}

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

switch (state)
{
case CryostorageBuiState msg:
_menu?.UpdateState(msg);
break;
}
}

protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (!disposing)
return;
_menu?.Dispose();
}
}
21 changes: 21 additions & 0 deletions Content.Client/Bed/Cryostorage/CryostorageEntryControl.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<BoxContainer
xmlns="https://spacestation14.io"
xmlns:graphics="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
xmlns:xNamespace="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:style="clr-namespace:Content.Client.Stylesheets"
xmlns:customControls="clr-namespace:Content.Client.Administration.UI.CustomControls"
Orientation="Vertical"
HorizontalExpand="True"
Margin="0 0 0 5">
<PanelContainer>
<PanelContainer.PanelOverride>
<graphics:StyleBoxFlat BackgroundColor="{xNamespace:Static style:StyleNano.ButtonColorDisabled}" />
</PanelContainer.PanelOverride>
<Collapsible Orientation="Vertical" Name="Collapsible">
<CollapsibleHeading Name="Heading" MinHeight="35"/>
<CollapsibleBody Name="Body">
<BoxContainer Name="ItemsContainer" Orientation="Vertical" HorizontalExpand="True"/>
</CollapsibleBody>
</Collapsible>
</PanelContainer>
</BoxContainer>
46 changes: 46 additions & 0 deletions Content.Client/Bed/Cryostorage/CryostorageEntryControl.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using Content.Shared.Bed.Cryostorage;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;

namespace Content.Client.Bed.Cryostorage;

[GenerateTypedNameReferences]
public sealed partial class CryostorageEntryControl : BoxContainer
{
public event Action<string>? SlotRemoveButtonPressed;
public event Action<string>? HandRemoveButtonPressed;

public NetEntity Entity;
public bool LastOpenState;

public CryostorageEntryControl(CryostorageContainedPlayerData data)
{
RobustXamlLoader.Load(this);
Entity = data.PlayerEnt;
Update(data);
}

public void Update(CryostorageContainedPlayerData data)
{
LastOpenState = Collapsible.BodyVisible;
Heading.Title = data.PlayerName;
Body.Visible = data.ItemSlots.Count != 0 && data.HeldItems.Count != 0;

ItemsContainer.Children.Clear();
foreach (var (name, itemName) in data.ItemSlots)
{
var control = new CryostorageSlotControl(name, itemName);
control.Button.OnPressed += _ => SlotRemoveButtonPressed?.Invoke(name);
ItemsContainer.AddChild(control);
}

foreach (var (name, held) in data.HeldItems)
{
var control = new CryostorageSlotControl(Loc.GetString("cryostorage-ui-filler-hand"), held);
control.Button.OnPressed += _ => HandRemoveButtonPressed?.Invoke(name);
ItemsContainer.AddChild(control);
}
Collapsible.BodyVisible = LastOpenState;
}
}
33 changes: 33 additions & 0 deletions Content.Client/Bed/Cryostorage/CryostorageMenu.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<controls:FancyWindow
xmlns="https://spacestation14.io"
xmlns:graphics="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
xmlns:xNamespace="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:style="clr-namespace:Content.Client.Stylesheets"
Title="{Loc 'cryostorage-ui-window-title'}"
MinSize="350 350"
SetSize="450 400">
<BoxContainer
Orientation="Vertical"
VerticalExpand="True"
HorizontalExpand="True">
<PanelContainer
VerticalExpand="True"
HorizontalExpand="True"
Margin="15">
<PanelContainer.PanelOverride>
<graphics:StyleBoxFlat BackgroundColor="{xNamespace:Static style:StyleNano.PanelDark}" />
</PanelContainer.PanelOverride>
<ScrollContainer VerticalExpand="True" HorizontalExpand="True">
<Control>
<Label Text="{Loc 'cryostorage-ui-label-no-bodies'}" Name="EmptyLabel" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<BoxContainer Name="EntriesContainer"
Orientation="Vertical"
Margin="10"
VerticalExpand="True"
HorizontalExpand="True"/>
</Control>
</ScrollContainer>
</PanelContainer>
</BoxContainer>
</controls:FancyWindow>
54 changes: 54 additions & 0 deletions Content.Client/Bed/Cryostorage/CryostorageMenu.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using System.Linq;
using Content.Client.UserInterface.Controls;
using Content.Shared.Bed.Cryostorage;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Collections;
using Robust.Shared.Utility;

namespace Content.Client.Bed.Cryostorage;

[GenerateTypedNameReferences]
public sealed partial class CryostorageMenu : FancyWindow
{
public event Action<NetEntity, string>? SlotRemoveButtonPressed;
public event Action<NetEntity, string>? HandRemoveButtonPressed;

public CryostorageMenu()
{
RobustXamlLoader.Load(this);
}

public void UpdateState(CryostorageBuiState state)
{
var data = state.PlayerData;
var nonexistentEntries = new ValueList<CryostorageContainedPlayerData>(data);

var children = new ValueList<Control>(EntriesContainer.Children);
foreach (var control in children)
{
if (control is not CryostorageEntryControl entryControl)
continue;

if (data.Where(p => p.PlayerEnt == entryControl.Entity).FirstOrNull() is not { } datum)
{
EntriesContainer.Children.Remove(entryControl);
continue;
}

nonexistentEntries.Remove(datum);
entryControl.Update(datum);
}

foreach (var player in nonexistentEntries)
{
var control = new CryostorageEntryControl(player);
control.SlotRemoveButtonPressed += a => SlotRemoveButtonPressed?.Invoke(player.PlayerEnt, a);
control.HandRemoveButtonPressed += a => HandRemoveButtonPressed?.Invoke(player.PlayerEnt, a);
EntriesContainer.Children.Add(control);
}

EmptyLabel.Visible = data.Count == 0;
}
}
13 changes: 13 additions & 0 deletions Content.Client/Bed/Cryostorage/CryostorageSlotControl.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<BoxContainer
xmlns="https://spacestation14.io"
Orientation="Horizontal"
HorizontalExpand="True"
Margin="5">
<RichTextLabel Name="SlotLabel" HorizontalAlignment="Left"/>
<Control HorizontalExpand="True"/>
<BoxContainer Orientation="Horizontal"
HorizontalAlignment="Right">
<Label Name="ItemLabel" Margin="0 0 5 0"/>
<Button Name="Button" Access="Public" Text="{Loc 'cryostorage-ui-button-remove'}"></Button>
</BoxContainer>
</BoxContainer>
18 changes: 18 additions & 0 deletions Content.Client/Bed/Cryostorage/CryostorageSlotControl.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Content.Client.Message;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;

namespace Content.Client.Bed.Cryostorage;

[GenerateTypedNameReferences]
public sealed partial class CryostorageSlotControl : BoxContainer
{
public CryostorageSlotControl(string name, string itemName)
{
RobustXamlLoader.Load(this);

SlotLabel.SetMarkup(Loc.GetString("cryostorage-ui-label-slot-name", ("slot", name)));
ItemLabel.Text = itemName;
}
}
9 changes: 9 additions & 0 deletions Content.Client/Bed/Cryostorage/CryostorageSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Content.Shared.Bed.Cryostorage;

namespace Content.Client.Bed.Cryostorage;

/// <inheritdoc/>
public sealed class CryostorageSystem : SharedCryostorageSystem
{

}
Loading

0 comments on commit 736b9dd

Please sign in to comment.