Pipe painter (now with airlock painter) (#19031)

* Add a pipe painting function to the airlock painter

Signed-off-by: c4llv07e <kseandi@gmail.com>

* Rename engineer painter to omnipainter

Signed-off-by: c4llv07e <kseandi@gmail.com>

* review changes

Signed-off-by: c4llv07e <kseandi@gmail.com>

* fix migration duplicate

Signed-off-by: c4llv07e <kseandi@gmail.com>

---------

Signed-off-by: c4llv07e <kseandi@gmail.com>
This commit is contained in:
c4llv07e
2023-08-14 12:06:21 +00:00
committed by GitHub
parent 3b7a23bde4
commit d7eb3bfb44
36 changed files with 649 additions and 446 deletions

View File

@@ -1,54 +0,0 @@
using Content.Shared.AirlockPainter;
using Robust.Client.Graphics;
using Robust.Client.ResourceManagement;
using Robust.Shared.Utility;
using System.Linq;
using Robust.Shared.Serialization.TypeSerializers.Implementations;
namespace Content.Client.AirlockPainter
{
public sealed class AirlockPainterSystem : SharedAirlockPainterSystem
{
[Dependency] private readonly IResourceCache _resourceCache = default!;
public List<AirlockPainterEntry> Entries { get; private set; } = new();
public override void Initialize()
{
base.Initialize();
foreach (string style in Styles)
{
string? iconPath = Groups
.FindAll(x => x.StylePaths.ContainsKey(style))?
.MaxBy(x => x.IconPriority)?.StylePaths[style];
if (iconPath == null)
{
Entries.Add(new AirlockPainterEntry(style, null));
continue;
}
RSIResource doorRsi = _resourceCache.GetResource<RSIResource>(SpriteSpecifierSerializer.TextureRoot / new ResPath(iconPath));
if (!doorRsi.RSI.TryGetState("closed", out var icon))
{
Entries.Add(new AirlockPainterEntry(style, null));
continue;
}
Entries.Add(new AirlockPainterEntry(style, icon.Frame0));
}
}
}
public sealed class AirlockPainterEntry
{
public string Name;
public Texture? Icon;
public AirlockPainterEntry(string name, Texture? icon)
{
Name = name;
Icon = icon;
}
}
}

View File

@@ -1,53 +0,0 @@
using Content.Shared.AirlockPainter;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface.Controls;
namespace Content.Client.AirlockPainter.UI
{
public sealed class AirlockPainterBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private AirlockPainterWindow? _window;
[ViewVariables]
private AirlockPainterSystem? _painter;
public AirlockPainterBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void Open()
{
base.Open();
_window = new AirlockPainterWindow();
_painter = EntMan.System<AirlockPainterSystem>();
_window.OpenCentered();
_window.OnClose += Close;
_window.OnSpritePicked = OnSpritePicked;
}
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
if (_window == null)
return;
if (_painter == null)
return;
if (state is not AirlockPainterBoundUserInterfaceState stateCast)
return;
_window.Populate(_painter.Entries, stateCast.SelectedStyle);
}
private void OnSpritePicked(ItemList.ItemListSelectedEventArgs args)
{
SendMessage(new AirlockPainterSpritePickedMessage(args.ItemIndex));
}
}
}

View File

@@ -1,14 +0,0 @@
<DefaultWindow xmlns="https://spacestation14.io"
MinSize="300 300"
SetSize="300 500"
Title="{Loc 'airlock-painter-window-title'}">
<BoxContainer Orientation="Vertical" SeparationOverride="4" MinWidth="150">
<Label Name="SelectedSpriteLabel"
Text="{Loc 'airlock-painter-selected-style'}">
</Label>
<ItemList Name="SpriteList"
SizeFlagsStretchRatio="8"
VerticalExpand="True">
</ItemList>
</BoxContainer>
</DefaultWindow>

View File

@@ -1,39 +0,0 @@
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
namespace Content.Client.AirlockPainter.UI
{
[GenerateTypedNameReferences]
public sealed partial class AirlockPainterWindow : DefaultWindow
{
public Action<ItemList.ItemListSelectedEventArgs>? OnSpritePicked;
private List<AirlockPainterEntry> CurrentEntries = new List<AirlockPainterEntry>();
public AirlockPainterWindow()
{
RobustXamlLoader.Load(this);
}
public void Populate(List<AirlockPainterEntry> entries, int selected)
{
// Only clear if the entries change. Otherwise the list would "jump" after selecting an item
if (!CurrentEntries.Equals(entries))
{
CurrentEntries = entries;
SpriteList.Clear();
foreach (var entry in entries)
{
SpriteList.AddItem(entry.Name, entry.Icon);
}
}
// Disable event so we don't send a new event for pre-selected entry and end up in a loop
SpriteList.OnItemSelected -= OnSpritePicked;
SpriteList[selected].Selected = true;
SpriteList.OnItemSelected += OnSpritePicked;
}
}
}

View File

@@ -0,0 +1,53 @@
using Content.Shared.SprayPainter;
using Robust.Client.Graphics;
using Robust.Client.ResourceManagement;
using Robust.Shared.Serialization.TypeSerializers.Implementations;
using Robust.Shared.Utility;
using System.Linq;
namespace Content.Client.SprayPainter;
public sealed class SprayPainterSystem : SharedSprayPainterSystem
{
[Dependency] private readonly IResourceCache _resourceCache = default!;
public List<SprayPainterEntry> Entries { get; private set; } = new();
public override void Initialize()
{
base.Initialize();
foreach (string style in Styles)
{
string? iconPath = Groups
.FindAll(x => x.StylePaths.ContainsKey(style))?
.MaxBy(x => x.IconPriority)?.StylePaths[style];
if (iconPath == null)
{
Entries.Add(new SprayPainterEntry(style, null));
continue;
}
RSIResource doorRsi = _resourceCache.GetResource<RSIResource>(SpriteSpecifierSerializer.TextureRoot / new ResPath(iconPath));
if (!doorRsi.RSI.TryGetState("closed", out var icon))
{
Entries.Add(new SprayPainterEntry(style, null));
continue;
}
Entries.Add(new SprayPainterEntry(style, icon.Frame0));
}
}
}
public sealed class SprayPainterEntry
{
public string Name;
public Texture? Icon;
public SprayPainterEntry(string name, Texture? icon)
{
Name = name;
Icon = icon;
}
}

View File

@@ -0,0 +1,69 @@
using Content.Shared.SprayPainter;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface.Controls;
namespace Content.Client.SprayPainter.UI;
public sealed class SprayPainterBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private SprayPainterWindow? _window;
[ViewVariables]
private SprayPainterSystem? _painter;
public SprayPainterBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}
protected override void Open()
{
base.Open();
_window = new SprayPainterWindow();
_painter = EntMan.System<SprayPainterSystem>();
_window.OpenCentered();
_window.OnClose += Close;
_window.OnSpritePicked = OnSpritePicked;
_window.OnColorPicked = OnColorPicked;
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
_window?.Dispose();
}
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
if (_window == null)
return;
if (_painter == null)
return;
if (state is not SprayPainterBoundUserInterfaceState stateCast)
return;
_window.Populate(_painter.Entries,
stateCast.SelectedStyle,
stateCast.SelectedColorKey,
stateCast.Palette);
}
private void OnSpritePicked(ItemList.ItemListSelectedEventArgs args)
{
SendMessage(new SprayPainterSpritePickedMessage(args.ItemIndex));
}
private void OnColorPicked(ItemList.ItemListSelectedEventArgs args)
{
var key = _window?.IndexToColorKey(args.ItemIndex);
SendMessage(new SprayPainterColorPickedMessage(key));
}
}

View File

@@ -0,0 +1,34 @@
<DefaultWindow xmlns="https://spacestation14.io"
MinSize="500 300"
SetSize="500 500"
Title="{Loc 'spray-painter-window-title'}">
<BoxContainer Orientation="Horizontal"
HorizontalExpand="True"
VerticalExpand="True"
SeparationOverride="4"
MinWidth="450">
<BoxContainer Orientation="Vertical"
HorizontalExpand="True"
VerticalExpand="True"
SeparationOverride="4"
MinWidth="200">
<Label Name="SelectedSpriteLabel"
Text="{Loc 'spray-painter-selected-style'}">
</Label>
<ItemList Name="SpriteList"
SizeFlagsStretchRatio="8"
VerticalExpand="True"/>
</BoxContainer>
<BoxContainer Orientation="Vertical"
HorizontalExpand="True"
VerticalExpand="True"
SeparationOverride="4"
MinWidth="200">
<Label Name="SelectedColorLabel"
Text="{Loc 'spray-painter-selected-color'}"/>
<ItemList Name="ColorList"
SizeFlagsStretchRatio="8"
VerticalExpand="True"/>
</BoxContainer>
</BoxContainer>
</DefaultWindow>

View File

@@ -0,0 +1,96 @@
using Robust.Client.AutoGenerated;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Utility;
namespace Content.Client.SprayPainter.UI;
[GenerateTypedNameReferences]
public sealed partial class SprayPainterWindow : DefaultWindow
{
[Dependency] private readonly IEntitySystemManager _sysMan = default!;
private readonly SpriteSystem _spriteSystem;
public Action<ItemList.ItemListSelectedEventArgs>? OnSpritePicked;
public Action<ItemList.ItemListSelectedEventArgs>? OnColorPicked;
public Dictionary<string, int> ItemColorIndex = new();
private Dictionary<string, Color> currentPalette = new();
private const string colorLocKeyPrefix = "pipe-painter-color-";
private List<SprayPainterEntry> CurrentEntries = new List<SprayPainterEntry>();
private readonly SpriteSpecifier _colorEntryIconTexture = new SpriteSpecifier.Rsi(
new ResPath("Structures/Piping/Atmospherics/pipe.rsi"),
"pipeStraight");
public SprayPainterWindow()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
_spriteSystem = _sysMan.GetEntitySystem<SpriteSystem>();
}
private static string GetColorLocString(string? colorKey)
{
if (string.IsNullOrEmpty(colorKey))
return Loc.GetString("pipe-painter-no-color-selected");
var locKey = colorLocKeyPrefix + colorKey;
if (!Loc.TryGetString(locKey, out var locString))
locString = colorKey;
return locString;
}
public string? IndexToColorKey(int index)
{
return (string?) ColorList[index].Metadata;
}
public void Populate(List<SprayPainterEntry> entries, int selectedStyle, string? selectedColorKey, Dictionary<string, Color> palette)
{
// Only clear if the entries change. Otherwise the list would "jump" after selecting an item
if (!CurrentEntries.Equals(entries))
{
CurrentEntries = entries;
SpriteList.Clear();
foreach (var entry in entries)
{
SpriteList.AddItem(entry.Name, entry.Icon);
}
}
if (!currentPalette.Equals(palette))
{
currentPalette = palette;
ItemColorIndex.Clear();
ColorList.Clear();
foreach (var color in palette)
{
var locString = GetColorLocString(color.Key);
var item = ColorList.AddItem(locString, _spriteSystem.Frame0(_colorEntryIconTexture));
item.IconModulate = color.Value;
item.Metadata = color.Key;
ItemColorIndex.Add(color.Key, ColorList.IndexOf(item));
}
}
// Disable event so we don't send a new event for pre-selectedStyle entry and end up in a loop
if (selectedColorKey != null)
{
var index = ItemColorIndex[selectedColorKey];
ColorList.OnItemSelected -= OnColorPicked;
ColorList[index].Selected = true;
ColorList.OnItemSelected += OnColorPicked;
}
SpriteList.OnItemSelected -= OnSpritePicked;
SpriteList[selectedStyle].Selected = true;
SpriteList.OnItemSelected += OnSpritePicked;
}
}

View File

@@ -1,19 +0,0 @@
using Robust.Shared.Audio;
namespace Content.Server.AirlockPainter
{
[RegisterComponent]
public sealed class AirlockPainterComponent : Component
{
[DataField("spraySound")]
public SoundSpecifier SpraySound = new SoundPathSpecifier("/Audio/Effects/spray2.ogg");
[DataField("sprayTime")]
public float SprayTime = 3.0f;
[DataField("isSpraying")]
public bool IsSpraying = false;
public int Index = default!;
}
}

View File

@@ -1,118 +0,0 @@
using Content.Server.Administration.Logs;
using Content.Server.Popups;
using Content.Server.UserInterface;
using Content.Shared.AirlockPainter;
using Content.Shared.AirlockPainter.Prototypes;
using Content.Shared.DoAfter;
using Content.Shared.Database;
using Content.Shared.Doors.Components;
using Content.Shared.Interaction;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
namespace Content.Server.AirlockPainter
{
/// <summary>
/// A system for painting airlocks using airlock painter
/// </summary>
[UsedImplicitly]
public sealed class AirlockPainterSystem : SharedAirlockPainterSystem
{
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly UserInterfaceSystem _userInterfaceSystem = default!;
[Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<AirlockPainterComponent, AfterInteractEvent>(AfterInteractOn);
SubscribeLocalEvent<AirlockPainterComponent, ActivateInWorldEvent>(OnActivate);
SubscribeLocalEvent<AirlockPainterComponent, AirlockPainterSpritePickedMessage>(OnSpritePicked);
SubscribeLocalEvent<AirlockPainterComponent, AirlockPainterDoAfterEvent>(OnDoAfter);
}
private void OnDoAfter(EntityUid uid, AirlockPainterComponent component, AirlockPainterDoAfterEvent args)
{
component.IsSpraying = false;
if (args.Handled || args.Cancelled)
return;
if (args.Args.Target != null)
{
_audio.PlayPvs(component.SpraySound, uid);
_appearance.SetData(args.Args.Target.Value, DoorVisuals.BaseRSI, args.Sprite);
_adminLogger.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(args.Args.User):user} painted {ToPrettyString(args.Args.Target.Value):target}");
}
args.Handled = true;
}
private void OnActivate(EntityUid uid, AirlockPainterComponent component, ActivateInWorldEvent args)
{
if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
return;
DirtyUI(uid, component);
if (_userInterfaceSystem.TryGetUi(uid, AirlockPainterUiKey.Key, out var bui))
_userInterfaceSystem.OpenUi(bui, actor.PlayerSession);
args.Handled = true;
}
private void AfterInteractOn(EntityUid uid, AirlockPainterComponent component, AfterInteractEvent args)
{
if (component.IsSpraying || args.Target is not { Valid: true } target || !args.CanReach)
return;
if (!EntityManager.TryGetComponent<PaintableAirlockComponent>(target, out var airlock))
return;
if (!_prototypeManager.TryIndex<AirlockGroupPrototype>(airlock.Group, out var grp))
{
Log.Error("Group not defined: %s", airlock.Group);
return;
}
string style = Styles[component.Index];
if (!grp.StylePaths.TryGetValue(style, out var sprite))
{
string msg = Loc.GetString("airlock-painter-style-not-available");
_popupSystem.PopupEntity(msg, args.User, args.User);
return;
}
component.IsSpraying = true;
var doAfterEventArgs = new DoAfterArgs(args.User, component.SprayTime, new AirlockPainterDoAfterEvent(sprite), uid, target: target, used: uid)
{
BreakOnTargetMove = true,
BreakOnUserMove = true,
BreakOnDamage = true,
NeedHand = true,
};
_doAfterSystem.TryStartDoAfter(doAfterEventArgs);
// Log attempt
_adminLogger.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(args.User):user} is painting {ToPrettyString(uid):target} to '{style}' at {Transform(uid).Coordinates:targetlocation}");
}
private void OnSpritePicked(EntityUid uid, AirlockPainterComponent component, AirlockPainterSpritePickedMessage args)
{
component.Index = args.Index;
DirtyUI(uid, component);
}
private void DirtyUI(EntityUid uid,
AirlockPainterComponent? component = null)
{
if (!Resolve(uid, ref component))
return;
_userInterfaceSystem.TrySetUiState(uid, AirlockPainterUiKey.Key,
new AirlockPainterBoundUserInterfaceState(component.Index));
}
}
}

View File

@@ -0,0 +1,28 @@
using Robust.Shared.Audio;
namespace Content.Server.SprayPainter;
[RegisterComponent]
public sealed class SprayPainterComponent : Component
{
[DataField("spraySound")]
public SoundSpecifier SpraySound = new SoundPathSpecifier("/Audio/Effects/spray2.ogg");
[DataField("airlockSprayTime")]
public float AirlockSprayTime = 3.0f;
[DataField("pipeSprayTime")]
public float PipeSprayTime = 1.0f;
[DataField("isSpraying")]
public bool IsSpraying = false;
[ViewVariables(VVAccess.ReadWrite)]
public string? PickedColor;
[ViewVariables(VVAccess.ReadWrite)]
[DataField("colorPalette")]
public Dictionary<string, Color> ColorPalette = new();
public int Index = default!;
}

View File

@@ -0,0 +1,182 @@
using System.Linq;
using Content.Server.Administration.Logs;
using Content.Server.Atmos.Piping.Components;
using Content.Server.Atmos.Piping.EntitySystems;
using Content.Server.Popups;
using Content.Shared.Database;
using Content.Shared.DoAfter;
using Content.Shared.Doors.Components;
using Content.Shared.SprayPainter.Prototypes;
using Content.Shared.SprayPainter;
using Content.Shared.Interaction;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
namespace Content.Server.SprayPainter;
/// <summary>
/// A system for painting airlocks and pipes using enginner painter
/// </summary>
[UsedImplicitly]
public sealed class SprayPainterSystem : SharedSprayPainterSystem
{
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly UserInterfaceSystem _userInterfaceSystem = default!;
[Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly AtmosPipeColorSystem _pipeColorSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<SprayPainterComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<SprayPainterComponent, AfterInteractEvent>(AfterInteractOn);
SubscribeLocalEvent<SprayPainterComponent, ActivateInWorldEvent>(OnActivate);
SubscribeLocalEvent<SprayPainterComponent, SprayPainterSpritePickedMessage>(OnSpritePicked);
SubscribeLocalEvent<SprayPainterComponent, SprayPainterColorPickedMessage>(OnColorPicked);
SubscribeLocalEvent<SprayPainterComponent, SprayPainterDoAfterEvent>(OnDoAfter);
}
private void OnInit(EntityUid uid, SprayPainterComponent component, ComponentInit args)
{
if (component.ColorPalette.Count == 0)
return;
SetColor(uid, component, component.ColorPalette.First().Key);
}
private void OnDoAfter(EntityUid uid, SprayPainterComponent component, SprayPainterDoAfterEvent args)
{
component.IsSpraying = false;
if (args.Handled || args.Cancelled)
return;
if (args.Args.Target == null)
return;
EntityUid target = (EntityUid) args.Args.Target;
_audio.PlayPvs(component.SpraySound, uid);
if (TryComp<AtmosPipeColorComponent>(target, out var atmosPipeColorComp))
{
_pipeColorSystem.SetColor(target, atmosPipeColorComp, args.Color ?? Color.White);
} else { // Target is an airlock
if (args.Sprite != null)
{
_appearance.SetData(target, DoorVisuals.BaseRSI, args.Sprite);
_adminLogger.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(args.Args.User):user} painted {ToPrettyString(args.Args.Target.Value):target}");
}
}
args.Handled = true;
}
private void OnActivate(EntityUid uid, SprayPainterComponent component, ActivateInWorldEvent args)
{
if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor))
return;
DirtyUI(uid, component);
_userInterfaceSystem.TryOpen(uid, SprayPainterUiKey.Key, actor.PlayerSession);
args.Handled = true;
}
private void AfterInteractOn(EntityUid uid, SprayPainterComponent component, AfterInteractEvent args)
{
if (component.IsSpraying || args.Target is not { Valid: true } target || !args.CanReach)
return;
if (EntityManager.TryGetComponent<PaintableAirlockComponent>(target, out var airlock))
{
if (!_prototypeManager.TryIndex<AirlockGroupPrototype>(airlock.Group, out var grp))
{
Log.Error("Group not defined: %s", airlock.Group);
return;
}
string style = Styles[component.Index];
if (!grp.StylePaths.TryGetValue(style, out var sprite))
{
string msg = Loc.GetString("spray-painter-style-not-available");
_popupSystem.PopupEntity(msg, args.User, args.User);
return;
}
component.IsSpraying = true;
var doAfterEventArgs = new DoAfterArgs(args.User, component.AirlockSprayTime, new SprayPainterDoAfterEvent(sprite, null), uid, target: target, used: uid)
{
BreakOnTargetMove = true,
BreakOnUserMove = true,
BreakOnDamage = true,
NeedHand = true,
};
_doAfterSystem.TryStartDoAfter(doAfterEventArgs);
// Log attempt
_adminLogger.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(args.User):user} is painting {ToPrettyString(uid):target} to '{style}' at {Transform(uid).Coordinates:targetlocation}");
} else { // Painting pipes
if(component.PickedColor is null)
return;
if (!EntityManager.HasComponent<AtmosPipeColorComponent>(target))
return;
if(!component.ColorPalette.TryGetValue(component.PickedColor, out var color))
return;
var doAfterEventArgs = new DoAfterArgs(args.User, component.PipeSprayTime, new SprayPainterDoAfterEvent(null, color), uid, target, uid)
{
BreakOnTargetMove = true,
BreakOnUserMove = true,
BreakOnDamage = true,
CancelDuplicate = true,
DuplicateCondition = DuplicateConditions.SameTarget,
NeedHand = true,
};
_doAfterSystem.TryStartDoAfter(doAfterEventArgs);
}
}
private void OnColorPicked(EntityUid uid, SprayPainterComponent component, SprayPainterColorPickedMessage args)
{
SetColor(uid, component, args.Key);
}
private void OnSpritePicked(EntityUid uid, SprayPainterComponent component, SprayPainterSpritePickedMessage args)
{
component.Index = args.Index;
DirtyUI(uid, component);
}
private void SetColor(EntityUid uid, SprayPainterComponent component, string? paletteKey)
{
if (paletteKey == null)
return;
if (!component.ColorPalette.ContainsKey(paletteKey) || paletteKey == component.PickedColor)
return;
component.PickedColor = paletteKey;
DirtyUI(uid, component);
}
private void DirtyUI(EntityUid uid, SprayPainterComponent? component = null)
{
if (!Resolve(uid, ref component))
return;
_userInterfaceSystem.TrySetUiState(
uid,
SprayPainterUiKey.Key,
new SprayPainterBoundUserInterfaceState(
component.Index,
component.PickedColor,
component.ColorPalette));
}
}

View File

@@ -1,51 +0,0 @@
using Content.Shared.DoAfter;
using Robust.Shared.Serialization;
namespace Content.Shared.AirlockPainter
{
[Serializable, NetSerializable]
public enum AirlockPainterUiKey
{
Key,
}
[Serializable, NetSerializable]
public sealed class AirlockPainterSpritePickedMessage : BoundUserInterfaceMessage
{
public int Index { get; }
public AirlockPainterSpritePickedMessage(int index)
{
Index = index;
}
}
[Serializable, NetSerializable]
public sealed class AirlockPainterBoundUserInterfaceState : BoundUserInterfaceState
{
public int SelectedStyle { get; }
public AirlockPainterBoundUserInterfaceState(int selectedStyle)
{
SelectedStyle = selectedStyle;
}
}
[Serializable, NetSerializable]
public sealed class AirlockPainterDoAfterEvent : DoAfterEvent
{
[DataField("sprite", required: true)]
public readonly string Sprite = default!;
private AirlockPainterDoAfterEvent()
{
}
public AirlockPainterDoAfterEvent(string sprite)
{
Sprite = sprite;
}
public override DoAfterEvent Clone() => this;
}
}

View File

@@ -1,12 +0,0 @@
using Content.Shared.AirlockPainter.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Server.AirlockPainter
{
[RegisterComponent]
public sealed class PaintableAirlockComponent : Component
{
[DataField("group", customTypeSerializer:typeof(PrototypeIdSerializer<AirlockGroupPrototype>))]
public string Group = default!;
}
}

View File

@@ -1,20 +0,0 @@
using Robust.Shared.Prototypes;
namespace Content.Shared.AirlockPainter.Prototypes
{
[Prototype("AirlockGroup")]
public sealed class AirlockGroupPrototype : IPrototype
{
[IdDataField]
public string ID { get; } = default!;
[DataField("stylePaths")]
public Dictionary<string, string> StylePaths = default!;
// The priority determines, which sprite is used when showing
// the icon for a style in the airlock painter UI. The highest priority
// gets shown.
[DataField("iconPriority")]
public int IconPriority = 0;
}
}

View File

@@ -1,30 +0,0 @@
using System.Linq;
using Content.Shared.AirlockPainter.Prototypes;
using Robust.Shared.Prototypes;
namespace Content.Shared.AirlockPainter
{
public abstract class SharedAirlockPainterSystem : EntitySystem
{
[Dependency] protected readonly IPrototypeManager _prototypeManager = default!;
public List<string> Styles { get; private set; } = new();
public List<AirlockGroupPrototype> Groups { get; private set; } = new();
public override void Initialize()
{
base.Initialize();
SortedSet<string> styles = new();
foreach (AirlockGroupPrototype grp in _prototypeManager.EnumeratePrototypes<AirlockGroupPrototype>())
{
Groups.Add(grp);
foreach (string style in grp.StylePaths.Keys)
{
styles.Add(style);
}
}
Styles = styles.ToList();
}
}
}

View File

@@ -0,0 +1,11 @@
using Content.Shared.SprayPainter.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Server.SprayPainter;
[RegisterComponent]
public sealed class PaintableAirlockComponent : Component
{
[DataField("group", customTypeSerializer:typeof(PrototypeIdSerializer<AirlockGroupPrototype>))]
public string Group = default!;
}

View File

@@ -0,0 +1,19 @@
using Robust.Shared.Prototypes;
namespace Content.Shared.SprayPainter.Prototypes;
[Prototype("AirlockGroup")]
public sealed class AirlockGroupPrototype : IPrototype
{
[IdDataField]
public string ID { get; } = default!;
[DataField("stylePaths")]
public Dictionary<string, string> StylePaths = default!;
// The priority determines, which sprite is used when showing
// the icon for a style in the SprayPainter UI. The highest priority
// gets shown.
[DataField("iconPriority")]
public int IconPriority = 0;
}

View File

@@ -0,0 +1,29 @@
using System.Linq;
using Content.Shared.SprayPainter.Prototypes;
using Robust.Shared.Prototypes;
namespace Content.Shared.SprayPainter;
public abstract class SharedSprayPainterSystem : EntitySystem
{
[Dependency] protected readonly IPrototypeManager _prototypeManager = default!;
public List<string> Styles { get; private set; } = new();
public List<AirlockGroupPrototype> Groups { get; private set; } = new();
public override void Initialize()
{
base.Initialize();
SortedSet<string> styles = new();
foreach (AirlockGroupPrototype grp in _prototypeManager.EnumeratePrototypes<AirlockGroupPrototype>())
{
Groups.Add(grp);
foreach (string style in grp.StylePaths.Keys)
{
styles.Add(style);
}
}
Styles = styles.ToList();
}
}

View File

@@ -0,0 +1,69 @@
using Content.Shared.DoAfter;
using Robust.Shared.Serialization;
namespace Content.Shared.SprayPainter;
[Serializable, NetSerializable]
public enum SprayPainterUiKey
{
Key,
}
[Serializable, NetSerializable]
public sealed class SprayPainterSpritePickedMessage : BoundUserInterfaceMessage
{
public int Index { get; }
public SprayPainterSpritePickedMessage(int index)
{
Index = index;
}
}
[Serializable, NetSerializable]
public sealed class SprayPainterColorPickedMessage : BoundUserInterfaceMessage
{
public string? Key { get; }
public SprayPainterColorPickedMessage(string? key)
{
Key = key;
}
}
[Serializable, NetSerializable]
public sealed class SprayPainterBoundUserInterfaceState : BoundUserInterfaceState
{
public int SelectedStyle { get; }
public string? SelectedColorKey { get; }
public Dictionary<string, Color> Palette { get; }
public SprayPainterBoundUserInterfaceState(int selectedStyle, string? selectedColorKey, Dictionary<string, Color> palette)
{
SelectedStyle = selectedStyle;
SelectedColorKey = selectedColorKey;
Palette = palette;
}
}
[Serializable, NetSerializable]
public sealed class SprayPainterDoAfterEvent : DoAfterEvent
{
[DataField("sprite")]
public readonly string? Sprite = null;
[DataField("color")]
public readonly Color? Color = null;
private SprayPainterDoAfterEvent()
{
}
public SprayPainterDoAfterEvent(string? sprite, Color? color)
{
Sprite = sprite;
Color = color;
}
public override DoAfterEvent Clone() => this;
}

View File

@@ -1,3 +0,0 @@
airlock-painter-style-not-available = Cannot apply the selected style to this type of airlock
airlock-painter-window-title = Airlock painter
airlock-painter-selected-style = Selected style

View File

@@ -0,0 +1,14 @@
spray-painter-window-title = Spray painter
spray-painter-style-not-available = Cannot apply the selected style to this type of airlock
spray-painter-selected-style = Selected style:
spray-painter-selected-color = Selected color:
spray-painter-color-red = red
spray-painter-color-yellow = yellow
spray-painter-color-brown = brown
spray-painter-color-green = green
spray-painter-color-cyan = cyan
spray-painter-color-blue = blue
spray-painter-color-white = white
spray-painter-color-black = black

View File

@@ -11893,7 +11893,7 @@ entities:
- pos: -14.5,29.5 - pos: -14.5,29.5
parent: 1 parent: 1
type: Transform type: Transform
- proto: AirlockPainter - proto: SprayPainter
entities: entities:
- uid: 9885 - uid: 9885
components: components:

View File

@@ -19872,7 +19872,7 @@ entities:
- pos: 1.5,49.5 - pos: 1.5,49.5
parent: 13329 parent: 13329
type: Transform type: Transform
- proto: AirlockPainter - proto: SprayPainter
entities: entities:
- uid: 29081 - uid: 29081
components: components:

View File

@@ -13912,7 +13912,7 @@ entities:
- pos: -55.5,-29.5 - pos: -55.5,-29.5
parent: 82 parent: 82
type: Transform type: Transform
- proto: AirlockPainter - proto: SprayPainter
entities: entities:
- uid: 11279 - uid: 11279
components: components:

View File

@@ -37,7 +37,7 @@
prob: 0.3 prob: 0.3
- id: CableApcStack - id: CableApcStack
prob: 0.3 prob: 0.3
- id: AirlockPainter - id: SprayPainter
prob: 0.7 prob: 0.7
- type: entity - type: entity

View File

@@ -12,7 +12,7 @@
GasAnalyzer: 3 GasAnalyzer: 3
FlashlightLantern: 5 FlashlightLantern: 5
ClothingHandsGlovesColorYellowBudget: 3 ClothingHandsGlovesColorYellowBudget: 3
AirlockPainter: 3 SprayPainter: 3
# Some engineer forgot to take the multitool out the youtool when working on it, happens. # Some engineer forgot to take the multitool out the youtool when working on it, happens.
contrabandInventory: contrabandInventory:
Multitool: 1 Multitool: 1

View File

@@ -30,7 +30,7 @@
- Multitool - Multitool
- AppraisalTool - AppraisalTool
components: components:
- AirlockPainter - SprayPainter
- NetworkConfigurator - NetworkConfigurator
- RCD - RCD
- RCDAmmo - RCDAmmo
@@ -103,7 +103,7 @@
- Multitool - Multitool
- AppraisalTool - AppraisalTool
components: components:
- AirlockPainter - SprayPainter
- NetworkConfigurator - NetworkConfigurator
- RCD - RCD
- RCDAmmo - RCDAmmo

View File

@@ -161,7 +161,7 @@
- NetworkConfigurator - NetworkConfigurator
- trayScanner - trayScanner
- GasAnalyzer - GasAnalyzer
- AirlockPainter - SprayPainter
- AppraisalTool - AppraisalTool
- Flare - Flare
- HandheldGPSBasic - HandheldGPSBasic

View File

@@ -1,21 +0,0 @@
- type: entity
parent: BaseItem
id: AirlockPainter
name: airlock painter
description: An airlock painter for painting airlocks.
components:
- type: Sprite
sprite: Objects/Tools/airlock_painter.rsi
state: airlock_painter
- type: Item
sprite: Objects/Tools/airlock_painter.rsi
- type: UserInterface
interfaces:
- key: enum.AirlockPainterUiKey.Key
type: AirlockPainterBoundUserInterface
- type: AirlockPainter
whitelist:
tags:
- PaintableAirlock
- type: StaticPrice
price: 40

View File

@@ -0,0 +1,30 @@
- type: entity
parent: BaseItem
id: SprayPainter
name: Spray painter
description: A spray painter for painting airlocks and pipes.
components:
- type: Sprite
sprite: Objects/Tools/spray_painter.rsi
state: spray_painter
- type: Item
sprite: Objects/Tools/spray_painter.rsi
- type: UserInterface
interfaces:
- key: enum.SprayPainterUiKey.Key
type: SprayPainterBoundUserInterface
- type: SprayPainter
whitelist:
tags:
- PaintableAirlock
colorPalette:
red: '#FF1212FF'
yellow: '#B3A234FF'
brown: '#947507FF'
green: '#3AB334FF'
cyan: '#03FCD3FF'
blue: '#0335FCFF'
white: '#FFFFFFFF'
black: '#333333FF'
- type: StaticPrice
price: 40

View File

@@ -88,7 +88,7 @@
- Crowbar - Crowbar
- Multitool - Multitool
- NetworkConfigurator - NetworkConfigurator
- AirlockPainter - SprayPainter
- FlashlightLantern - FlashlightLantern
- CableStack - CableStack
- CableMVStack - CableMVStack

View File

@@ -143,8 +143,8 @@
Glass: 300 Glass: 300
- type: latheRecipe - type: latheRecipe
id: AirlockPainter id: SprayPainter
result: AirlockPainter result: SprayPainter
completetime: 2 completetime: 2
materials: materials:
Steel: 300 Steel: 300

View File

@@ -7,7 +7,7 @@
}, },
"states" : [ "states" : [
{ {
"name" : "airlock_painter" "name" : "spray_painter"
} }
], ],
"version" : 1 "version" : 1

View File

@@ -78,3 +78,6 @@ WindowTintedDirectional: WindowFrostedDirectional
# 2023-08-10 # 2023-08-10
SyringeSpaceacillin: null SyringeSpaceacillin: null
# 2023-08-13
AirlockPainter: SprayPainter