Files
tbd-station-14/Content.Client/Changelog/ChangelogButton.cs
Jezithyr 571dd4e6d5 Hud refactor (#7202)
Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>
Co-authored-by: Jezithyr <jmaster9999@gmail.com>
Co-authored-by: Jezithyr <Jezithyr@gmail.com>
Co-authored-by: Visne <39844191+Visne@users.noreply.github.com>
Co-authored-by: wrexbe <wrexbe@protonmail.com>
Co-authored-by: wrexbe <81056464+wrexbe@users.noreply.github.com>
2022-10-12 10:16:23 +02:00

49 lines
1.3 KiB
C#

using Content.Client.Stylesheets;
using Robust.Client.UserInterface.Controls;
namespace Content.Client.Changelog
{
public sealed class ChangelogButton : Button
{
[Dependency] private readonly ChangelogManager _changelogManager = default!;
public ChangelogButton()
{
IoCManager.InjectDependencies(this);
// So that measuring before opening returns a correct height,
// and the window has the correct size when opened.
Text = " ";
}
protected override void EnteredTree()
{
base.EnteredTree();
_changelogManager.NewChangelogEntriesChanged += UpdateStuff;
UpdateStuff();
}
protected override void ExitedTree()
{
base.ExitedTree();
_changelogManager.NewChangelogEntriesChanged -= UpdateStuff;
}
private void UpdateStuff()
{
if (_changelogManager.NewChangelogEntries)
{
Text = Loc.GetString("changelog-button-new-entries");
StyleClasses.Add(StyleBase.ButtonCaution);
}
else
{
Text = Loc.GetString("changelog-button");
StyleClasses.Remove(StyleBase.ButtonCaution);
}
}
}
}