Files
RobustToolbox/Robust.Client/UserInterface/Controls/CheckBox.cs
Acruid dadd7b4cc3 Remove Static Component NetIds (#1842)
* ComponentNames are not sent over the network when components are created.

* Removed ComponentStates array from EntityState, now the state is stored directly inside the CompChange struct.

* Remove the unnecessary NetID property from ComponentState.

* Remove Component.NetworkSynchronizeExistence.

* Change GetNetComponents to return both the component and the component NetId.

* Remove public usages of the Component.NetID property.

* Adds the NetIDAttribute that can be applied to components.

* Removed Component.NetID.

* Revert changes to GetComponentState and how prediction works.

* Adds component netID automatic generation.

* Modifies ClientConsoleHost so that commands can be called before Initialize().

* Completely remove static NetIds.

* Renamed NetIDAttribute to NetworkedComponentAttribute.

* Fixing unit tests.
2021-07-12 10:23:13 +02:00

71 lines
2.1 KiB
C#

using Robust.Shared.ViewVariables;
using static Robust.Client.UserInterface.Controls.Label;
namespace Robust.Client.UserInterface.Controls
{
/// <summary>
/// A type of toggleable button that also has a checkbox.
/// </summary>
public class CheckBox : ContainerButton
{
public const string StyleClassCheckBox = "checkBox";
public const string StyleClassCheckBoxChecked = "checkBoxChecked";
public Label Label { get; }
public TextureRect TextureRect { get; }
public CheckBox()
{
ToggleMode = true;
var hBox = new HBoxContainer
{
StyleClasses = { StyleClassCheckBox },
};
AddChild(hBox);
TextureRect = new TextureRect
{
StyleClasses = { StyleClassCheckBox },
};
hBox.AddChild(TextureRect);
Label = new Label();
hBox.AddChild(Label);
}
protected override void DrawModeChanged()
{
base.DrawModeChanged();
if (TextureRect != null)
{
if (Pressed)
TextureRect.AddStyleClass(StyleClassCheckBoxChecked);
else
TextureRect.RemoveStyleClass(StyleClassCheckBoxChecked);
}
}
/// <summary>
/// How to align the text inside the button.
/// </summary>
[ViewVariables]
public AlignMode TextAlign { get => Label.Align; set => Label.Align = value; }
/// <summary>
/// If true, the button will allow shrinking and clip text
/// to prevent the text from going outside the bounds of the button.
/// If false, the minimum size will always fit the contained text.
/// </summary>
[ViewVariables]
public bool ClipText { get => Label.ClipText; set => Label.ClipText = value; }
/// <summary>
/// The text displayed by the button.
/// </summary>
[ViewVariables]
public string? Text { get => Label.Text; set => Label.Text = value; }
}
}