Rainbow crayon + color-selectable crayons (#7786)

This commit is contained in:
Flipp Syder
2022-04-28 05:23:45 -07:00
committed by GitHub
parent 4c9e45a480
commit 2325a7df94
9 changed files with 105 additions and 3 deletions

View File

@@ -40,6 +40,11 @@ namespace Content.Client.Crayon.UI
SendMessage(new CrayonSelectMessage(state));
}
public void SelectColor(string color)
{
SendMessage(new CrayonColorMessage(color));
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);

View File

@@ -3,6 +3,7 @@
MinSize="250 300"
SetSize="250 300">
<BoxContainer Orientation="Vertical">
<ColorSelectorSliders Name="ColorSelector" Visible="False" />
<LineEdit Name="Search" />
<ScrollContainer VerticalExpand="True">
<GridContainer Name="Grid" Columns="6">

View File

@@ -30,6 +30,16 @@ namespace Content.Client.Crayon.UI
Owner = owner;
Search.OnTextChanged += _ => RefreshList();
ColorSelector.OnColorChanged += SelectColor;
}
private void SelectColor(Color color)
{
_color = color;
Owner.SelectColor(color.ToHex());
RefreshList();
}
private void RefreshList()
@@ -86,7 +96,14 @@ namespace Content.Client.Crayon.UI
public void UpdateState(CrayonBoundUserInterfaceState state)
{
_selected = state.Selected;
ColorSelector.Visible = state.SelectableColor;
_color = state.Color;
if (ColorSelector.Visible)
{
ColorSelector.Color = state.Color;
}
RefreshList();
}