Skip to content

Commit 54d5bd2

Browse files
DrSmugleafmetalgearslothPJB3005
authored
Add mapping editor (space-wizards#23427)
* Add mapping editor (space-wizards#757) * Remove mapping actions, never again * Cleanup actions system * Jarvis, remove all references to CM14 * Fix InventoryUIController crashing when an InventoryGui is not found * Rename mapping1 to mapping * Clean up context calls * Add doc comments * Add delegate for hiding decals in the mapping screen * Jarvis mission failed * a * Add test * Fix not flushing save stream in mapping manager * change * Fix verbs * fixes * localise --------- Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com> Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
1 parent 6e8f8d7 commit 54d5bd2

37 files changed

+2024
-47
lines changed

‎Content.Client/Actions/ActionsSystem.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ public void LoadActionAssignments(string path, bool userData)
293293
continue;
294294

295295
var action = _serialization.Read<BaseActionComponent>(actionNode, notNullableOverride: true);
296-
var actionId = Spawn(null);
296+
var actionId = Spawn();
297297
AddComp(actionId, action);
298298
AddActionDirect(user, actionId);
299299

‎Content.Client/Commands/ActionsCommands.cs‎

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using Content.Client.Actions;
12
using Content.Client.Actions;
23
using Content.Client.Mapping;
34
using Content.Shared.Administration;
@@ -61,27 +62,3 @@ public override void Execute(IConsoleShell shell, string argStr, string[] args)
6162
}
6263
}
6364
}
64-
65-
[AnyCommand]
66-
public sealed class LoadMappingActionsCommand : LocalizedCommands
67-
{
68-
[Dependency] private readonly IEntitySystemManager _entitySystemManager = default!;
69-
70-
public const string CommandName = "loadmapacts";
71-
72-
public override string Command => CommandName;
73-
74-
public override string Help => LocalizationManager.GetString($"cmd-{Command}-help", ("command", Command));
75-
76-
public override void Execute(IConsoleShell shell, string argStr, string[] args)
77-
{
78-
try
79-
{
80-
_entitySystemManager.GetEntitySystem<MappingSystem>().LoadMappingActions();
81-
}
82-
catch
83-
{
84-
shell.WriteError(LocalizationManager.GetString($"cmd-{Command}-error"));
85-
}
86-
}
87-
}

‎Content.Client/Commands/MappingClientSideSetupCommand.cs‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
using Content.Client.Mapping;
12
using Content.Client.Markers;
23
using JetBrains.Annotations;
34
using Robust.Client.Graphics;
5+
using Robust.Client.State;
46
using Robust.Shared.Console;
57

68
namespace Content.Client.Commands;
@@ -10,6 +12,7 @@ internal sealed class MappingClientSideSetupCommand : LocalizedCommands
1012
{
1113
[Dependency] private readonly IEntitySystemManager _entitySystemManager = default!;
1214
[Dependency] private readonly ILightManager _lightManager = default!;
15+
[Dependency] private readonly IStateManager _stateManager = default!;
1316

1417
public override string Command => "mappingclientsidesetup";
1518

@@ -21,8 +24,8 @@ public override void Execute(IConsoleShell shell, string argStr, string[] args)
2124
{
2225
_entitySystemManager.GetEntitySystem<MarkerSystem>().MarkersVisible = true;
2326
_lightManager.Enabled = false;
24-
shell.ExecuteCommand(ShowSubFloorForever.CommandName);
25-
shell.ExecuteCommand(LoadMappingActionsCommand.CommandName);
27+
shell.ExecuteCommand("showsubfloorforever");
28+
_stateManager.RequestStateChange<MappingState>();
2629
}
2730
}
2831
}

‎Content.Client/ContextMenu/UI/ContextMenuUIController.cs‎

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Threading;
33
using Content.Client.CombatMode;
44
using Content.Client.Gameplay;
5+
using Content.Client.Mapping;
56
using Robust.Client.UserInterface;
67
using Robust.Client.UserInterface.Controllers;
78
using Timer = Robust.Shared.Timing.Timer;
@@ -16,7 +17,7 @@ namespace Content.Client.ContextMenu.UI
1617
/// <remarks>
1718
/// This largely involves setting up timers to open and close sub-menus when hovering over other menu elements.
1819
/// </remarks>
19-
public sealed class ContextMenuUIController : UIController, IOnStateEntered<GameplayState>, IOnStateExited<GameplayState>, IOnSystemChanged<CombatModeSystem>
20+
public sealed class ContextMenuUIController : UIController, IOnStateEntered<GameplayState>, IOnStateExited<GameplayState>, IOnSystemChanged<CombatModeSystem>, IOnStateEntered<MappingState>, IOnStateExited<MappingState>
2021
{
2122
public static readonly TimeSpan HoverDelay = TimeSpan.FromSeconds(0.2);
2223

@@ -42,18 +43,51 @@ public sealed class ContextMenuUIController : UIController, IOnStateEntered<Game
4243
public Action<ContextMenuElement>? OnSubMenuOpened;
4344
public Action<ContextMenuElement, GUIBoundKeyEventArgs>? OnContextKeyEvent;
4445

46+
private bool _setup;
47+
4548
public void OnStateEntered(GameplayState state)
4649
{
50+
Setup();
51+
}
52+
53+
public void OnStateExited(GameplayState state)
54+
{
55+
Shutdown();
56+
}
57+
58+
public void OnStateEntered(MappingState state)
59+
{
60+
Setup();
61+
}
62+
63+
public void OnStateExited(MappingState state)
64+
{
65+
Shutdown();
66+
}
67+
68+
public void Setup()
69+
{
70+
if (_setup)
71+
return;
72+
73+
_setup = true;
74+
4775
RootMenu = new(this, null);
4876
RootMenu.OnPopupHide += Close;
4977
Menus.Push(RootMenu);
5078
}
5179

52-
public void OnStateExited(GameplayState state)
80+
public void Shutdown()
5381
{
82+
if (!_setup)
83+
return;
84+
85+
_setup = false;
86+
5487
Close();
5588
RootMenu.OnPopupHide -= Close;
5689
RootMenu.Dispose();
90+
RootMenu = default!;
5791
}
5892

5993
/// <summary>

‎Content.Client/Decals/Overlays/DecalPlacementOverlay.cs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using Robust.Client.Input;
55
using Robust.Shared.Enums;
66
using Robust.Shared.Map;
7+
using Robust.Shared.Prototypes;
78

89
namespace Content.Client.Decals.Overlays;
910

@@ -16,14 +17,15 @@ public sealed class DecalPlacementOverlay : Overlay
1617
private readonly SharedTransformSystem _transform;
1718
private readonly SpriteSystem _sprite;
1819

19-
public override OverlaySpace Space => OverlaySpace.WorldSpace;
20+
public override OverlaySpace Space => OverlaySpace.WorldSpaceEntities;
2021

2122
public DecalPlacementOverlay(DecalPlacementSystem placement, SharedTransformSystem transform, SpriteSystem sprite)
2223
{
2324
IoCManager.InjectDependencies(this);
2425
_placement = placement;
2526
_transform = transform;
2627
_sprite = sprite;
28+
ZIndex = 1000;
2729
}
2830

2931
protected override void Draw(in OverlayDrawArgs args)
@@ -55,7 +57,7 @@ protected override void Draw(in OverlayDrawArgs args)
5557

5658
if (snap)
5759
{
58-
localPos = (Vector2) localPos.Floored() + grid.TileSizeHalfVector;
60+
localPos = localPos.Floored() + grid.TileSizeHalfVector;
5961
}
6062

6163
// Nothing uses snap cardinals so probably don't need preview?

‎Content.Client/IoC/ClientContentIoC.cs‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@
44
using Content.Client.Clickable;
55
using Content.Client.DebugMon;
66
using Content.Client.Eui;
7+
using Content.Client.Fullscreen;
78
using Content.Client.GhostKick;
9+
using Content.Client.Guidebook;
810
using Content.Client.Launcher;
11+
using Content.Client.Mapping;
912
using Content.Client.Parallax.Managers;
1013
using Content.Client.Players.PlayTimeTracking;
14+
using Content.Client.Replay;
1115
using Content.Client.Screenshot;
12-
using Content.Client.Fullscreen;
1316
using Content.Client.Stylesheets;
1417
using Content.Client.Viewport;
1518
using Content.Client.Voting;
1619
using Content.Shared.Administration.Logs;
17-
using Content.Client.Guidebook;
1820
using Content.Client.Lobby;
19-
using Content.Client.Replay;
2021
using Content.Shared.Administration.Managers;
2122
using Content.Shared.Players.PlayTimeTracking;
2223

23-
2424
namespace Content.Client.IoC
2525
{
2626
internal static class ClientContentIoC
@@ -49,6 +49,7 @@ public static void Register()
4949
collection.Register<DocumentParsingManager>();
5050
collection.Register<ContentReplayPlaybackManager, ContentReplayPlaybackManager>();
5151
collection.Register<ISharedPlaytimeManager, JobRequirementsManager>();
52+
collection.Register<MappingManager>();
5253
collection.Register<DebugMonitorManager>();
5354
}
5455
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<mapping:MappingActionsButton
2+
xmlns="https://spacestation14.io"
3+
xmlns:mapping="clr-namespace:Content.Client.Mapping"
4+
StyleClasses="ButtonSquare" ToggleMode="True" SetSize="32 32" Margin="0 0 5 0"
5+
TooltipDelay="0">
6+
<TextureRect Name="Texture" Access="Public" Stretch="Scale" SetSize="16 16"
7+
HorizontalAlignment="Center" VerticalAlignment="Center" />
8+
</mapping:MappingActionsButton>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using Robust.Client.AutoGenerated;
2+
using Robust.Client.UserInterface.Controls;
3+
using Robust.Client.UserInterface.XAML;
4+
5+
namespace Content.Client.Mapping;
6+
7+
[GenerateTypedNameReferences]
8+
public sealed partial class MappingActionsButton : Button
9+
{
10+
public MappingActionsButton()
11+
{
12+
RobustXamlLoader.Load(this);
13+
}
14+
}
15+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<mapping:MappingDoNotMeasure
2+
xmlns="https://spacestation14.io"
3+
xmlns:mapping="clr-namespace:Content.Client.Mapping">
4+
</mapping:MappingDoNotMeasure>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System.Numerics;
2+
using Robust.Client.AutoGenerated;
3+
using Robust.Client.UserInterface;
4+
using Robust.Client.UserInterface.XAML;
5+
6+
namespace Content.Client.Mapping;
7+
8+
[GenerateTypedNameReferences]
9+
public sealed partial class MappingDoNotMeasure : Control
10+
{
11+
public MappingDoNotMeasure()
12+
{
13+
RobustXamlLoader.Load(this);
14+
}
15+
16+
protected override Vector2 MeasureOverride(Vector2 availableSize)
17+
{
18+
return Vector2.Zero;
19+
}
20+
}
21+

0 commit comments

Comments
 (0)