Add mapping editor (#23427)

* Add mapping editor (#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>
This commit is contained in:
DrSmugleaf
2024-08-03 20:31:45 -07:00
committed by GitHub
parent 6e8f8d706a
commit 54d5bd266c
37 changed files with 2024 additions and 47 deletions

View File

@@ -1,10 +1,11 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Array;
using Robust.Shared.Utility;
namespace Content.Shared.Decals
{
[Prototype("decal")]
public sealed partial class DecalPrototype : IPrototype
public sealed partial class DecalPrototype : IPrototype, IInheritingPrototype
{
[IdDataField] public string ID { get; } = null!;
[DataField("sprite")] public SpriteSpecifier Sprite { get; private set; } = SpriteSpecifier.Invalid;
@@ -33,5 +34,13 @@ namespace Content.Shared.Decals
/// </summary>
[DataField]
public bool DefaultSnap = true;
[ParentDataField(typeof(AbstractPrototypeIdArraySerializer<DecalPrototype>))]
public string[]? Parents { get; }
[NeverPushInheritance]
[AbstractDataField]
public bool Abstract { get; }
}
}

View File

@@ -104,5 +104,14 @@ namespace Content.Shared.Input
public static readonly BoundKeyFunction EditorCopyObject = "EditorCopyObject";
public static readonly BoundKeyFunction EditorFlipObject = "EditorFlipObject";
public static readonly BoundKeyFunction InspectEntity = "InspectEntity";
public static readonly BoundKeyFunction MappingUnselect = "MappingUnselect";
public static readonly BoundKeyFunction SaveMap = "SaveMap";
public static readonly BoundKeyFunction MappingEnablePick = "MappingEnablePick";
public static readonly BoundKeyFunction MappingEnableDelete = "MappingEnableDelete";
public static readonly BoundKeyFunction MappingPick = "MappingPick";
public static readonly BoundKeyFunction MappingRemoveDecal = "MappingRemoveDecal";
public static readonly BoundKeyFunction MappingCancelEraseDecal = "MappingCancelEraseDecal";
public static readonly BoundKeyFunction MappingOpenContextMenu = "MappingOpenContextMenu";
}
}

View File

@@ -0,0 +1,46 @@
using System.IO;
using Lidgren.Network;
using Robust.Shared.Network;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;
namespace Content.Shared.Mapping;
public sealed class MappingMapDataMessage : NetMessage
{
public override MsgGroups MsgGroup => MsgGroups.Command;
public override NetDeliveryMethod DeliveryMethod => NetDeliveryMethod.ReliableUnordered;
public ZStdCompressionContext Context = default!;
public string Yml = default!;
public override void ReadFromBuffer(NetIncomingMessage buffer, IRobustSerializer serializer)
{
MsgSize = buffer.LengthBytes;
var uncompressedLength = buffer.ReadVariableInt32();
var compressedLength = buffer.ReadVariableInt32();
var stream = new MemoryStream(compressedLength);
buffer.ReadAlignedMemory(stream, compressedLength);
using var decompress = new ZStdDecompressStream(stream);
using var decompressed = new MemoryStream(uncompressedLength);
decompress.CopyTo(decompressed, uncompressedLength);
decompressed.Position = 0;
serializer.DeserializeDirect(decompressed, out Yml);
}
public override void WriteToBuffer(NetOutgoingMessage buffer, IRobustSerializer serializer)
{
var stream = new MemoryStream();
serializer.SerializeDirect(stream, Yml);
buffer.WriteVariableInt32((int) stream.Length);
stream.Position = 0;
var buf = new byte[ZStd.CompressBound((int) stream.Length)];
var length = Context.Compress2(buf, stream.AsSpan());
buffer.WriteVariableInt32(length);
buffer.Write(buf.AsSpan(0, length));
}
}

View File

@@ -0,0 +1,19 @@
using Lidgren.Network;
using Robust.Shared.Network;
using Robust.Shared.Serialization;
namespace Content.Shared.Mapping;
public sealed class MappingSaveMapErrorMessage : NetMessage
{
public override MsgGroups MsgGroup => MsgGroups.Command;
public override NetDeliveryMethod DeliveryMethod => NetDeliveryMethod.ReliableUnordered;
public override void ReadFromBuffer(NetIncomingMessage buffer, IRobustSerializer serializer)
{
}
public override void WriteToBuffer(NetOutgoingMessage buffer, IRobustSerializer serializer)
{
}
}

View File

@@ -0,0 +1,19 @@
using Lidgren.Network;
using Robust.Shared.Network;
using Robust.Shared.Serialization;
namespace Content.Shared.Mapping;
public sealed class MappingSaveMapMessage : NetMessage
{
public override MsgGroups MsgGroup => MsgGroups.Command;
public override NetDeliveryMethod DeliveryMethod => NetDeliveryMethod.ReliableUnordered;
public override void ReadFromBuffer(NetIncomingMessage buffer, IRobustSerializer serializer)
{
}
public override void WriteToBuffer(NetOutgoingMessage buffer, IRobustSerializer serializer)
{
}
}