main cult

This commit is contained in:
EnefFlow
2024-01-27 15:19:52 +03:00
committed by Aviu00
parent 6310813ce6
commit 4fab8188f0
429 changed files with 12281 additions and 9 deletions

View File

@@ -0,0 +1,9 @@
<DefaultWindow xmlns="https://spacestation14.io"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="{Loc 'Choose'}"
MinWidth="300"
MinHeight="400">
<ScrollContainer HorizontalExpand="True" VerticalExpand="True">
<BoxContainer Name="ItemsContainer" Orientation="Vertical"></BoxContainer>
</ScrollContainer>
</DefaultWindow>

View File

@@ -0,0 +1,36 @@
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
namespace Content.Client._White.Cult.UI.SummonCultistList;
[GenerateTypedNameReferences]
public partial class SummonCultistListWindow : DefaultWindow
{
public Action<int, int>? ItemSelected;
public SummonCultistListWindow()
{
RobustXamlLoader.Load(this);
}
public void PopulateList(List<int> items, List<string> labels)
{
ItemsContainer.RemoveAllChildren();
var count = Math.Min(items.Count, labels.Count);
for (var i = 0; i < count; i++)
{
var item = items[i];
var button = new Button();
button.Text = labels[i];
button.OnPressed += _ => ItemSelected?.Invoke(item, items.IndexOf(item));
ItemsContainer.AddChild(button);
}
}
}

View File

@@ -0,0 +1,43 @@
using Content.Shared.White.Cult.UI;
using Robust.Client.GameObjects;
namespace Content.Client._White.Cult.UI.SummonCultistList;
public sealed class SummonCultistListWindowBUI : BoundUserInterface
{
private SummonCultistListWindow? _window;
public SummonCultistListWindowBUI(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 += (item, index) =>
{
var msg = new SummonCultistListWindowItemSelectedMessage(item, index);
SendMessage(msg);
_window.Close();
};
if (State != null)
UpdateState(State);
}
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
if (state is SummonCultistListWindowBUIState newState)
{
_window?.PopulateList(newState.Items, newState.Label);
}
}
}