Restores the palette picker in decals (#7635)

This commit is contained in:
Flipp Syder
2022-04-18 15:43:27 -07:00
committed by GitHub
parent ff05ec238e
commit afb999fb50
3 changed files with 42 additions and 6 deletions

View File

@@ -11,7 +11,10 @@
</GridContainer> </GridContainer>
</ScrollContainer> </ScrollContainer>
<ColorSelectorSliders Name="ColorPicker" IsAlphaVisible="True" /> <BoxContainer Orientation="Vertical">
<ColorSelectorSliders Name="ColorPicker" IsAlphaVisible="True" />
<Button Name="PickerOpen" Text="{Loc 'decal-placer-window-palette'}" />
</BoxContainer>
<CheckBox Name="EnableColor" Text="{Loc 'decal-placer-window-use-color'}" /> <CheckBox Name="EnableColor" Text="{Loc 'decal-placer-window-use-color'}" />
<CheckBox Name="EnableSnap" Text="{Loc 'decal-placer-window-enable-snap'}" /> <CheckBox Name="EnableSnap" Text="{Loc 'decal-placer-window-enable-snap'}" />
<CheckBox Name="EnableCleanable" Text="{Loc 'decal-placer-window-enable-cleanable'}" /> <CheckBox Name="EnableCleanable" Text="{Loc 'decal-placer-window-enable-cleanable'}" />

View File

@@ -1,4 +1,5 @@
using Content.Client.Stylesheets; using System.Linq;
using Content.Client.Stylesheets;
using Content.Shared.Decals; using Content.Shared.Decals;
using Robust.Client.AutoGenerated; using Robust.Client.AutoGenerated;
using Robust.Client.Graphics; using Robust.Client.Graphics;
@@ -19,6 +20,8 @@ public sealed partial class DecalPlacerWindow : DefaultWindow
public FloatSpinBox RotationSpinBox; public FloatSpinBox RotationSpinBox;
private PaletteColorPicker? _picker;
private Dictionary<string, Texture>? _decals; private Dictionary<string, Texture>? _decals;
private string? _selected; private string? _selected;
private Color _color = Color.White; private Color _color = Color.White;
@@ -44,12 +47,34 @@ public sealed partial class DecalPlacerWindow : DefaultWindow
SpinBoxContainer.AddChild(RotationSpinBox); SpinBoxContainer.AddChild(RotationSpinBox);
Search.OnTextChanged += _ => RefreshList(); Search.OnTextChanged += _ => RefreshList();
ColorPicker.OnColorChanged += color => ColorPicker.OnColorChanged += OnColorPicked;
PickerOpen.OnPressed += _ =>
{ {
_color = color; if (_picker is null)
UpdateDecalPlacementInfo(); {
RefreshList(); _picker = new PaletteColorPicker();
_picker.OpenToLeft();
_picker.PaletteList.OnItemSelected += args =>
{
var color = (args.ItemList.GetSelected().First().Metadata as Color?)!.Value;
ColorPicker.Color = color;
OnColorPicked(color);
};
}
else
{
if (_picker.IsOpen)
{
_picker.Close();
}
else
{
_picker.Open();
}
}
}; };
RotationSpinBox.OnValueChanged += args => RotationSpinBox.OnValueChanged += args =>
{ {
_rotation = args.Value; _rotation = args.Value;
@@ -77,6 +102,13 @@ public sealed partial class DecalPlacerWindow : DefaultWindow
Populate(); Populate();
} }
private void OnColorPicked(Color color)
{
_color = color;
UpdateDecalPlacementInfo();
RefreshList();
}
private void UpdateDecalPlacementInfo() private void UpdateDecalPlacementInfo()
{ {
if (_selected is null) if (_selected is null)

View File

@@ -4,4 +4,5 @@ decal-placer-window-rotation = Rotation
decal-placer-window-zindex = Draw Depth decal-placer-window-zindex = Draw Depth
decal-placer-window-enable-snap = Snap To Tile decal-placer-window-enable-snap = Snap To Tile
decal-placer-window-enable-cleanable = Cleanable decal-placer-window-enable-cleanable = Cleanable
decal-placer-window-palette = Palette
palette-color-picker-window-title = Palettes palette-color-picker-window-title = Palettes