main cult
This commit is contained in:
9
Content.Client/_White/Cult/UI/Torch/TorchWindow.xaml
Normal file
9
Content.Client/_White/Cult/UI/Torch/TorchWindow.xaml
Normal file
@@ -0,0 +1,9 @@
|
||||
<DefaultWindow xmlns="https://spacestation14.io"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="{Loc 'cult-torch-window-title'}"
|
||||
MinWidth="300"
|
||||
MinHeight="400">
|
||||
<ScrollContainer HorizontalExpand="True" VerticalExpand="True">
|
||||
<BoxContainer Name="ItemsContainer" Orientation="Vertical"></BoxContainer>
|
||||
</ScrollContainer>
|
||||
</DefaultWindow>
|
||||
35
Content.Client/_White/Cult/UI/Torch/TorchWindow.xaml.cs
Normal file
35
Content.Client/_White/Cult/UI/Torch/TorchWindow.xaml.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Client._White.Cult.UI.Torch;
|
||||
|
||||
[GenerateTypedNameReferences]
|
||||
public partial class TorchWindow : DefaultWindow
|
||||
{
|
||||
public Action<string, string>? ItemSelected;
|
||||
|
||||
public TorchWindow()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
public void PopulateList(Dictionary<string, string> items)
|
||||
{
|
||||
ItemsContainer.RemoveAllChildren();
|
||||
|
||||
foreach (var item in items.Keys)
|
||||
{
|
||||
var button = new Button();
|
||||
var itemName = items[item];
|
||||
|
||||
button.Text = itemName;
|
||||
|
||||
button.OnPressed += _ => ItemSelected?.Invoke(item, items[item]);
|
||||
|
||||
ItemsContainer.AddChild(button);
|
||||
}
|
||||
}
|
||||
}
|
||||
47
Content.Client/_White/Cult/UI/Torch/TorchWindowBUI.cs
Normal file
47
Content.Client/_White/Cult/UI/Torch/TorchWindowBUI.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using System.Data;
|
||||
using Content.Shared.White.Cult.Items;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Client._White.Cult.UI.Torch;
|
||||
|
||||
public sealed class TorchWindowBUI : BoundUserInterface
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
|
||||
private TorchWindow? _window;
|
||||
|
||||
public TorchWindowBUI(EntityUid owner, Enum uiKey) : base(owner, uiKey)
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
}
|
||||
|
||||
protected override void Open()
|
||||
{
|
||||
base.Open();
|
||||
|
||||
_window = new();
|
||||
_window.OpenCentered();
|
||||
_window.OnClose += Close;
|
||||
|
||||
_window.ItemSelected += (uid, item) =>
|
||||
{
|
||||
var msg = new TorchWindowItemSelectedMessage(uid, item);
|
||||
SendMessage(msg);
|
||||
_window.Close();
|
||||
};
|
||||
|
||||
if (State != null)
|
||||
UpdateState(State);
|
||||
}
|
||||
|
||||
protected override void UpdateState(BoundUserInterfaceState state)
|
||||
{
|
||||
base.UpdateState(state);
|
||||
|
||||
if (state is TorchWindowBUIState newState)
|
||||
{
|
||||
_window?.PopulateList(newState.Items);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user