-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
641 additions
and
242 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,17 @@ | ||
<DefaultWindow xmlns="https://spacestation14.io" | ||
Title="{Loc 'accept-cryo-window-title'}" | ||
MinSize="300 100" | ||
MaxSize="300 100"> | ||
<BoxContainer Orientation="Vertical"> | ||
<BoxContainer Orientation="Vertical"> | ||
<Label Text="{Loc accept-cryo-window-prompt-text-part}" /> | ||
<BoxContainer Orientation="Horizontal" Align="Center"> | ||
<Button Name="AcceptButton" | ||
Text="{Loc accept-cryo-window-accept-button}" /> | ||
<Control MinWidth="20" /> | ||
<Button Name="DenyButton" | ||
Text="{Loc accept-cryo-window-deny-button}" /> | ||
</BoxContainer> | ||
</BoxContainer> | ||
</BoxContainer> | ||
</DefaultWindow> |
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,29 @@ | ||
using Content.Shared._CD.CryoSleep; | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.UserInterface.CustomControls; | ||
using Robust.Client.UserInterface.XAML; | ||
|
||
namespace Content.Client._CD.CryoSleep; | ||
|
||
[GenerateTypedNameReferences] | ||
public sealed partial class AcceptCryoWindow : DefaultWindow | ||
{ | ||
public event Action<AcceptCryoUiButton>? OnChoice; | ||
|
||
public AcceptCryoWindow() | ||
{ | ||
RobustXamlLoader.Load(this); | ||
|
||
AcceptButton.OnPressed += _ => | ||
{ | ||
OnChoice?.Invoke(AcceptCryoUiButton.Accept); | ||
Close(); | ||
}; | ||
|
||
DenyButton.OnPressed += _ => | ||
{ | ||
OnChoice?.Invoke(AcceptCryoUiButton.Deny); | ||
Close(); | ||
}; | ||
} | ||
} |
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,49 @@ | ||
using Content.Shared._CD.CryoSleep; | ||
using Robust.Client.Player; | ||
|
||
namespace Content.Client._CD.CryoSleep; | ||
|
||
public sealed class LostAndFoundBoundUserInterface : BoundUserInterface | ||
{ | ||
[Dependency] private readonly IEntityManager _entManager = default!; | ||
[Dependency] private readonly IPlayerManager _playerManager = default!; | ||
|
||
private LostAndFoundWindow? _window; | ||
|
||
public LostAndFoundBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) | ||
{ | ||
_window = new LostAndFoundWindow(); | ||
_window.OnRetrieveItem += OnRetrieveItem; | ||
} | ||
|
||
private void OnRetrieveItem(string playerName, string slotName) | ||
{ | ||
if ( _playerManager.LocalEntity is not { } user) | ||
return; | ||
|
||
var netEntity = _entManager.GetNetEntity(user); | ||
SendMessage(new LostAndFoundRetrieveItemMessage(playerName, slotName, netEntity)); | ||
} | ||
|
||
protected override void UpdateState(BoundUserInterfaceState state) | ||
{ | ||
base.UpdateState(state); | ||
if (state is LostAndFoundBuiState msg) | ||
_window?.Populate(msg.StoredPlayers); | ||
} | ||
|
||
protected override void Open() | ||
{ | ||
base.Open(); | ||
_window?.OpenCentered(); | ||
} | ||
|
||
protected override void Dispose(bool disposing) | ||
{ | ||
base.Dispose(disposing); | ||
if (!disposing) | ||
return; | ||
_window?.Close(); | ||
_window = null; | ||
} | ||
} |
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,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 'lost-and-found-retrieve-button'}"></Button> | ||
</BoxContainer> | ||
</BoxContainer> |
22 changes: 22 additions & 0 deletions
22
Content.Client/_CD/CryoSleep/LostAndFoundItemControl.xaml.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,22 @@ | ||
using Content.Client.Message; | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface.XAML; | ||
|
||
namespace Content.Client._CD.CryoSleep; | ||
|
||
[GenerateTypedNameReferences] | ||
public sealed partial class LostAndFoundItemControl : BoxContainer | ||
{ | ||
public LostAndFoundItemControl(string slotName, string itemName) | ||
{ | ||
RobustXamlLoader.Load(this); | ||
|
||
// Replace spaces with underscores so that held items dont troll us | ||
var locKey = $"lost-and-found-slot-{slotName.ToLower().Replace(" ", "_")}"; | ||
var localizedSlot = Loc.GetString(locKey); | ||
|
||
SlotLabel.SetMarkup(localizedSlot); | ||
ItemLabel.Text = itemName; | ||
} | ||
} |
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,22 @@ | ||
<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" | ||
Orientation="Vertical" | ||
HorizontalExpand="True" | ||
Margin="0 0 0 5"> | ||
<PanelContainer> | ||
<PanelContainer.PanelOverride> | ||
<graphics:StyleBoxFlat BackgroundColor="{xNamespace:Static style:StyleNano.ButtonColorDisabled}" /> | ||
</PanelContainer.PanelOverride> | ||
<Collapsible Name="Collapsible"> | ||
<CollapsibleHeading Name="Heading" MinHeight="35"/> | ||
<CollapsibleBody Name="Body"> | ||
<BoxContainer Name="ItemsList" | ||
Orientation="Vertical" | ||
HorizontalExpand="True"/> | ||
</CollapsibleBody> | ||
</Collapsible> | ||
</PanelContainer> | ||
</BoxContainer> |
37 changes: 37 additions & 0 deletions
37
Content.Client/_CD/CryoSleep/LostAndFoundPlayerEntry.xaml.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,37 @@ | ||
using Content.Shared._CD.CryoSleep; | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface.XAML; | ||
|
||
namespace Content.Client._CD.CryoSleep; | ||
|
||
[GenerateTypedNameReferences] | ||
public sealed partial class LostAndFoundPlayerEntry : BoxContainer | ||
{ | ||
public event Action<string>? OnRetrieveItem; | ||
|
||
public LostAndFoundPlayerEntry(string playerName, List<LostItemData> items) | ||
{ | ||
RobustXamlLoader.Load(this); | ||
|
||
Heading.Title = playerName; | ||
UpdateItems(items); | ||
} | ||
|
||
public void UpdateItems(List<LostItemData> items) | ||
{ | ||
var wasVisible = Collapsible.BodyVisible; | ||
Body.Visible = items.Count != 0; | ||
|
||
ItemsList.RemoveAllChildren(); | ||
|
||
foreach (var item in items) | ||
{ | ||
var control = new LostAndFoundItemControl(item.SlotName, item.ItemName); | ||
control.Button.OnPressed += _ => OnRetrieveItem?.Invoke(item.SlotName); | ||
ItemsList.AddChild(control); | ||
} | ||
|
||
Collapsible.BodyVisible = wasVisible; | ||
} | ||
} |
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,34 @@ | ||
<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 'lost-and-found-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 'lost-and-found-no-items'}" Name="EmptyLabel" HorizontalAlignment="Center" | ||
VerticalAlignment="Center" /> | ||
<BoxContainer Name="PlayersContainer" | ||
Orientation="Vertical" | ||
Margin="10" | ||
VerticalExpand="True" | ||
HorizontalExpand="True" /> | ||
</Control> | ||
</ScrollContainer> | ||
</PanelContainer> | ||
</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,52 @@ | ||
using Content.Client.UserInterface.Controls; | ||
using Content.Shared._CD.CryoSleep; | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.UserInterface.XAML; | ||
|
||
namespace Content.Client._CD.CryoSleep; | ||
|
||
[GenerateTypedNameReferences] | ||
public sealed partial class LostAndFoundWindow : FancyWindow | ||
{ | ||
private readonly Dictionary<string, LostAndFoundPlayerEntry> _entries = new(); | ||
|
||
public event Action<string, string>? OnRetrieveItem; | ||
|
||
public LostAndFoundWindow() | ||
{ | ||
RobustXamlLoader.Load(this); | ||
Title = Loc.GetString("lost-and-found-title"); | ||
} | ||
|
||
public void Populate(Dictionary<string, List<LostItemData>> players) | ||
{ | ||
EmptyLabel.Visible = players.Count == 0; | ||
|
||
var toRemove = new HashSet<string>(_entries.Keys); | ||
|
||
foreach (var (playerName, items) in players) | ||
{ | ||
toRemove.Remove(playerName); | ||
|
||
if (_entries.TryGetValue(playerName, out var existing)) | ||
{ | ||
existing.UpdateItems(items); | ||
continue; | ||
} | ||
|
||
var entry = new LostAndFoundPlayerEntry(playerName, items); | ||
entry.OnRetrieveItem += (slot) => OnRetrieveItem?.Invoke(playerName, slot); | ||
_entries.Add(playerName, entry); | ||
PlayersContainer.AddChild(entry); | ||
} | ||
|
||
// Remove entries for players who no longer have items | ||
foreach (var playerName in toRemove) | ||
{ | ||
if (_entries.Remove(playerName, out var entry)) | ||
{ | ||
PlayersContainer.RemoveChild(entry); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.