* Work on cartridges * Work on PDA UI * Work on PDA UIs program list * Work on PDA UI borders * Add DeviceNetworkingComponent to the pda base prototype * Fix submodule version * Fix cartridge loader ui key * Fix pda menu xaml * Implement relaying ui messages * Finish implementing the notekeeper cartridge * Fix submodule version * Fix errors from merging master * Fix test failing * Implement setting preinstalled programs * Add some documentation to CartridgeLoaderSystem * Add more doc comments * Add localization to program names * Implement review suggestions * Fix background programs receiving events twice when active
109 lines
2.9 KiB
C#
109 lines
2.9 KiB
C#
using Robust.Client.AutoGenerated;
|
|
using Robust.Client.Graphics;
|
|
using Robust.Client.UserInterface.Controls;
|
|
using Robust.Client.UserInterface.XAML;
|
|
using Robust.Shared.Utility;
|
|
|
|
namespace Content.Client.PDA;
|
|
|
|
[GenerateTypedNameReferences]
|
|
public sealed partial class PDANavigationButton : ContainerButton
|
|
{
|
|
|
|
private bool _isCurrent;
|
|
private bool _isActive = true;
|
|
|
|
private Thickness _borderThickness = new(0, 0, 0, 2);
|
|
private Thickness _currentTabBorderThickness = new(2, 0, 2, 0);
|
|
|
|
private readonly StyleBoxFlat _styleBox = new()
|
|
{
|
|
BackgroundColor = Color.FromHex("#202023"),
|
|
BorderColor = Color.FromHex("#5a5a5a"),
|
|
BorderThickness = new Thickness(0, 0, 0, 2)
|
|
};
|
|
|
|
public string InactiveBgColor { get; set; } = "#202023";
|
|
public string ActiveBgColor { get; set; } = "#25252a";
|
|
public string InactiveFgColor { get; set; } = "#5a5a5a";
|
|
public string ActiveFgColor { get; set; } = "#FFFFFF";
|
|
|
|
public SpriteSpecifier? IconTexture
|
|
{
|
|
set
|
|
{
|
|
Icon.Visible = value != null;
|
|
Label.Visible = value == null;
|
|
|
|
if (value is not null)
|
|
Icon.SetFromSpriteSpecifier(value);
|
|
}
|
|
}
|
|
|
|
public Vector2 IconScale
|
|
{
|
|
get => Icon.DisplayRect.TextureScale;
|
|
set => Icon.DisplayRect.TextureScale = value;
|
|
}
|
|
|
|
public string? LabelText
|
|
{
|
|
get => Label.Text;
|
|
set => Label.Text = value;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sets the border thickness when the tab is not the currently active one
|
|
/// </summary>
|
|
public Thickness BorderThickness
|
|
{
|
|
get => _borderThickness;
|
|
set
|
|
{
|
|
_borderThickness = value;
|
|
_styleBox.BorderThickness = _isCurrent ? _currentTabBorderThickness : value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sets the border thickness when this tab is the currently active tab
|
|
/// </summary>
|
|
public Thickness CurrentTabBorderThickness
|
|
{
|
|
get => _currentTabBorderThickness;
|
|
set
|
|
{
|
|
_currentTabBorderThickness = value;
|
|
_styleBox.BorderThickness = _isCurrent ? value : _borderThickness;
|
|
}
|
|
}
|
|
|
|
public bool IsCurrent
|
|
{
|
|
get => _isCurrent;
|
|
set
|
|
{
|
|
_isCurrent = value;
|
|
_styleBox.BackgroundColor = Color.FromHex(value ? ActiveBgColor : InactiveBgColor);
|
|
_styleBox.BorderThickness = value ? CurrentTabBorderThickness : BorderThickness;
|
|
}
|
|
}
|
|
|
|
public bool IsActive
|
|
{
|
|
get => _isActive;
|
|
set
|
|
{
|
|
_isActive = value;
|
|
Icon.Modulate = Color.FromHex(value ? ActiveFgColor : InactiveFgColor);
|
|
Label.FontColorOverride = Color.FromHex(value ? ActiveFgColor : InactiveFgColor);
|
|
}
|
|
}
|
|
|
|
public PDANavigationButton()
|
|
{
|
|
RobustXamlLoader.Load(this);
|
|
Background.PanelOverride = _styleBox;
|
|
}
|
|
}
|