* fix #1428 * CodTenAlt review * fix map tests * real this time * fix #1429 * add wheat and cotton into victorian gardens trade faction * Update PostMapInitTest.cs
75 lines
2.1 KiB
C#
75 lines
2.1 KiB
C#
using System.Text;
|
|
using Content.Shared._CP14.Religion.Systems;
|
|
using Robust.Client.AutoGenerated;
|
|
using Robust.Client.UserInterface.Controls;
|
|
using Robust.Client.UserInterface.CustomControls;
|
|
using Robust.Client.UserInterface.XAML;
|
|
|
|
namespace Content.Client._CP14.Religion;
|
|
|
|
[GenerateTypedNameReferences]
|
|
public sealed partial class CP14ReligionEntityWindow : DefaultWindow
|
|
{
|
|
[Dependency] private readonly ILogManager _log = default!;
|
|
|
|
private ISawmill Sawmill { get; init; }
|
|
|
|
public event Action<NetEntity>? OnTeleportAttempt;
|
|
|
|
public CP14ReligionEntityWindow()
|
|
{
|
|
RobustXamlLoader.Load(this);
|
|
IoCManager.InjectDependencies(this);
|
|
|
|
Sawmill = _log.GetSawmill("cp14_religion_entity_window");
|
|
}
|
|
|
|
public void UpdateState(CP14ReligionEntityUiState state)
|
|
{
|
|
AltarsContainer.RemoveAllChildren();
|
|
FollowersContainer.RemoveAllChildren();
|
|
|
|
Altars.Visible = state.Altars.Count > 0;
|
|
Followers.Visible = state.Followers.Count > 0;
|
|
|
|
foreach (var (netId, name) in state.Altars)
|
|
{
|
|
var btn = new Button
|
|
{
|
|
Text = name,
|
|
HorizontalAlignment = HAlignment.Center
|
|
};
|
|
|
|
btn.OnPressed += _ =>
|
|
{
|
|
OnTeleportAttempt?.Invoke(netId);
|
|
};
|
|
AltarsContainer.AddChild(btn);
|
|
}
|
|
|
|
foreach (var (netId, name) in state.Followers)
|
|
{
|
|
var btn = new Button
|
|
{
|
|
Text = name,
|
|
HorizontalAlignment = HAlignment.Center
|
|
};
|
|
|
|
btn.OnPressed += _ =>
|
|
{
|
|
OnTeleportAttempt?.Invoke(netId);
|
|
};
|
|
FollowersContainer.AddChild(btn);
|
|
}
|
|
Status.Text = GetStatusText(state);
|
|
}
|
|
|
|
private string GetStatusText(CP14ReligionEntityUiState state)
|
|
{
|
|
var sb = new StringBuilder();
|
|
sb.Append(Loc.GetString("cp14-god-ui-follower-percentage", ("count", state.FollowerPercentage * 100)) + "\n");
|
|
sb.Append(Loc.GetString("cp14-god-ui-mana-percentage", ("count", state.ManaPercentage * 100)) + "\n");
|
|
return sb.ToString();
|
|
}
|
|
}
|