Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Content.Client/Decals/DecalPlacementSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public sealed partial class DecalPlacementSystem : EntitySystem
private bool _placing;
private bool _erasing;

public bool IsActive => _active; // Forge-Change

public (DecalPrototype? Decal, bool Snap, Angle Angle, Color Color) GetActiveDecal()
{
return _active && _decalId != null ?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private void EnsureWindow()
ReloadPrototypes();
}

private void CloseWindow()
public void CloseWindow() // Forge-Change
{
if (_window == null || _window.Disposed)
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Content.Client.Markers;
using Content.Client.Sandbox;
using Content.Client.SubFloor;
using Content.Client._Forge.WallPaint.UI;
using Content.Client.UserInterface.Controls;
using Content.Client.UserInterface.Systems.DecalPlacer;
using Content.Client.UserInterface.Systems.Sandbox.Windows;
Expand Down Expand Up @@ -46,6 +47,7 @@ public sealed partial class SandboxUIController : UIController, IOnStateChanged<
private EntitySpawningUIController EntitySpawningController => UIManager.GetUIController<EntitySpawningUIController>();
private TileSpawningUIController TileSpawningController => UIManager.GetUIController<TileSpawningUIController>();
private DecalPlacerUIController DecalPlacerController => UIManager.GetUIController<DecalPlacerUIController>();
private WallPaintUIController WallPaintController => UIManager.GetUIController<WallPaintUIController>();

private MenuButton? SandboxButton => UIManager.GetActiveUIWidgetOrNull<MenuBar.Widgets.GameTopMenuBar>()?.SandboxButton;

Expand All @@ -61,6 +63,7 @@ public void OnStateEntered(GameplayState state)
{
if (!_admin.CanAdminPlace())
return;
WallPaintController.CloseWindow(); // Forge-Change
EntitySpawningController.ToggleWindow();
}));
_input.SetInputCommand(ContentKeyFunctions.OpenSandboxWindow,
Expand All @@ -70,13 +73,15 @@ public void OnStateEntered(GameplayState state)
{
if (!_admin.CanAdminPlace())
return;
WallPaintController.CloseWindow(); // Forge-Change
TileSpawningController.ToggleWindow();
}));
_input.SetInputCommand(ContentKeyFunctions.OpenDecalSpawnWindow,
InputCmdHandler.FromDelegate(_ =>
{
if (!_admin.CanAdminPlace())
return;
WallPaintController.CloseWindow(); // Forge-Change
DecalPlacerController.ToggleWindow();
}));

Expand Down Expand Up @@ -140,9 +145,28 @@ private void EnsureWindow()
_console.ExecuteCommand($"rmcomp {pnent.Id} StationAiOverlay");
};
_window.RespawnButton.OnPressed += _ => _sandbox.Respawn();
_window.SpawnTilesButton.OnPressed += _ => TileSpawningController.ToggleWindow();
_window.SpawnEntitiesButton.OnPressed += _ => EntitySpawningController.ToggleWindow();
_window.SpawnDecalsButton.OnPressed += _ => DecalPlacerController.ToggleWindow();
_window.SpawnTilesButton.OnPressed += _ => // Forge-Change
{
WallPaintController.CloseWindow();
TileSpawningController.ToggleWindow();
};
_window.SpawnEntitiesButton.OnPressed += _ => // Forge-Change
{
WallPaintController.CloseWindow();
EntitySpawningController.ToggleWindow();
};
_window.SpawnDecalsButton.OnPressed += _ => // Forge-Change
{
WallPaintController.CloseWindow();
DecalPlacerController.ToggleWindow();
};
_window.PaintWallsButton.OnPressed += _ => // Forge-Change
{
EntitySpawningController.CloseWindow();
TileSpawningController.CloseWindow();
DecalPlacerController.CloseWindow();
WallPaintController.ToggleWindow();
};
_window.GiveFullAccessButton.OnPressed += _ => _sandbox.GiveAdminAccess();
_window.GiveAghostButton.OnPressed += _ => _sandbox.GiveAGhost();
_window.ToggleLightButton.OnToggled += _ => _sandbox.ToggleLight();
Expand Down Expand Up @@ -197,6 +221,7 @@ private void CloseAll()
_window?.Close();
EntitySpawningController.CloseWindow();
TileSpawningController.CloseWindow();
WallPaintController.CloseWindow();
}

private bool Copy(ICommonSession? session, EntityCoordinates coords, EntityUid uid)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<Button Name="SpawnTilesButton" Access="Public" Text="{Loc sandbox-window-spawn-tiles-button}"/>
<Button Name="SpawnEntitiesButton" Access="Public" Text="{Loc sandbox-window-spawn-entities-button}"/>
<Button Name="SpawnDecalsButton" Access="Public" Text="{Loc sandbox-window-spawn-decals-button}"/>
<!-- Forge-Change -->
<Button Name="PaintWallsButton" Access="Public" Text="{Loc sandbox-window-paint-walls-button}"/>

<Label Text="{Loc sandbox-window-visibility-label}"/>
<Button Name="ToggleLightButton" Access="Public" Text="{Loc sandbox-window-toggle-lights-button}" ToggleMode="True"/>
Expand Down
71 changes: 71 additions & 0 deletions Content.Client/_Forge/WallPaint/UI/WallPaintUIController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using Content.Client.Gameplay;
using Content.Client.Sandbox;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.Controllers;

namespace Content.Client._Forge.WallPaint.UI;

public sealed partial class WallPaintUIController : UIController, IOnStateExited<GameplayState>, IOnSystemChanged<SandboxSystem>
{
[Dependency] private readonly IEntitySystemManager _systems = default!;
[UISystemDependency] private readonly SandboxSystem _sandbox = default!;

private WallPaintWindow? _window;

public void ToggleWindow()
{
EnsureWindow();

if (_window!.IsOpen)
_window.Close();
else if (_sandbox.SandboxAllowed)
_window.Open();
}

public void OnStateExited(GameplayState state)
{
DeactivatePaint();

if (_window == null)
return;

_window.Dispose();
_window = null;
}

public void OnSystemLoaded(SandboxSystem system)
{
_sandbox.SandboxDisabled += CloseWindow;
}

public void OnSystemUnloaded(SandboxSystem system)
{
_sandbox.SandboxDisabled -= CloseWindow;
DeactivatePaint();
}

private void EnsureWindow()
{
if (_window is { Disposed: false })
return;

DeactivatePaint();
_window = UIManager.CreateWindow<WallPaintWindow>();
LayoutContainer.SetAnchorPreset(_window, LayoutContainer.LayoutPreset.CenterLeft);
}

public void CloseWindow()
{
if (_window == null || _window.Disposed)
return;

_window.Close();
}

private void DeactivatePaint()
{
if (_systems.TryGetEntitySystem<WallPaintPlacementSystem>(out var wallPaint))
wallPaint.Deactivate();
}
}
9 changes: 9 additions & 0 deletions Content.Client/_Forge/WallPaint/UI/WallPaintWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<DefaultWindow xmlns="https://spacestation14.io"
Title="{Loc 'wall-paint-window-title'}"
MinSize="250 230"
SetSize="250 230">
<BoxContainer Orientation="Vertical" SeparationOverride="4">
<ColorSelectorSliders Name="ColorPicker" IsAlphaVisible="True" />
<CheckBox Name="ErasePaint" Text="{Loc 'wall-paint-window-erase'}" />
</BoxContainer>
</DefaultWindow>
56 changes: 56 additions & 0 deletions Content.Client/_Forge/WallPaint/UI/WallPaintWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using Content.Shared._Forge.WallPaint;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Maths;

namespace Content.Client._Forge.WallPaint.UI;

[GenerateTypedNameReferences]
public sealed partial class WallPaintWindow : DefaultWindow
{
[Dependency] private IEntityManager _entity = default!;

private WallPaintPlacementSystem _wallPaint = default!;

public WallPaintWindow()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);

_wallPaint = _entity.System<WallPaintPlacementSystem>();
ColorPicker.SelectorType = ColorSelectorSliders.ColorSelectorType.Hsv;
ColorPicker.Color = _wallPaint.Color;
ErasePaint.Pressed = _wallPaint.Erase;

ColorPicker.OnColorChanged += color =>
{
var clamped = WallPaintColor.Clamp(color);
if (!MathHelper.CloseToPercent(color, clamped))
ColorPicker.Color = clamped;

_wallPaint.SetColor(clamped);
};

ErasePaint.OnToggled += args => _wallPaint.SetErase(args.Pressed);
}

protected override void Opened()
{
base.Opened();
_wallPaint.SetActive(true);
}

public override void Close()
{
base.Close();
_wallPaint.Deactivate();
}

protected override void Dispose(bool disposing)
{
_wallPaint.Deactivate();
base.Dispose(disposing);
}
}
Loading
Loading