mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-09-29 23:57:29 +00:00
Upstream Merge (June / July) attempt 2 electric boogaloo (#4607)
* Fix the sensor monitoring console forcing a GC every 3 seconds (#38146) * Optimize sensor monitoring window graph drawing * Add shared static Vector2 pool for all GraphView instances * Address requested changes * remove lock * Update submodule to 264.0.0 (#38629) * Toy/Plushie Inhands and Wearables (#38514) * Fixed dependency injection and some other issues in a few places. * More issue fixes * patchfor broken NetworkConfiguratorLinkMenu (#38632) fix * Fix solutions flickering when transferring contents (#34838) * Use Solution clones when applying SolutionComponent states * Revert "Use Solution clones when applying SolutionComponent states" This reverts commit 013fd111cf92b22562e00f98a7aaa49bc4b4ed62. * Make Solution implement ICloneable and rename Clone method. * Copy CanReact value when cloning a Solution * Convert to IRobustCloneable * Fix typos in guidebook: Buisness → Business (#38636) * Fix typo in `MinorAntagonists.xml` Buisness → Business * Fix typo in `YourFirstCharacter.xml` Buisness → Business * Various Headphones Fixes and Tweaks (#38479) * sprites, wearables * neck * icon-on sprite * Cleanup prototype instantiation in `DamageTest` (#38639) Cleanup prototype instantiation in DamageTest * Cleanup prototype instantiation in `ExplosionSystem` (#38642) Cleanup prototype instantiation in ExplosionSystem * AddBodyPartCommand localization. (#38612) commit * fix ItemSlotsSystem debug assert (#38655) * Allow the Command & Super door remotes to use the access of their user. (Re-creation of PR due to changes to game balance) (#35536) * Added directional beacons (#38284) * Added directional beacons Signed-off-by: Nox38 <nebulousnox38@gmail.com> * Fixed names Signed-off-by: Nox38 <nebulousnox38@gmail.com> --------- Signed-off-by: Nox38 <nebulousnox38@gmail.com> * Power stat and nuke codes commands get some LEC love. (#38585) * commit * requested changes. * Dsay Dirty and Follow commands converted to LEC and localized. (#38666) * commit * whoopwhoopwhoop * Retro laser sprite fix (#38676) * Fixed everything except the icon Signed-off-by: Nox38 <nebulousnox38@gmail.com> * fixed icon Signed-off-by: Nox38 <nebulousnox38@gmail.com> --------- Signed-off-by: Nox38 <nebulousnox38@gmail.com> * fix water coolers (#38681) * Monochromacy typo fix (#38686) * fixes the typo * Fixed cloning looking for the trait, not the component, RE https://github.com/space-wizards/space-station-14/pull/38686#issuecomment-3025093504 * Apply suggestions from code review --------- Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> * Validate `CloningSettingsPrototype`s (#38688) * Validate CloningSettingsPrototypes * Update Content.IntegrationTests/Tests/Cloning/CloningSettingsPrototypeTest.cs Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> * Check EventComponents too --------- Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> * Add test of objective-related console commands (#36400) * Add test of objective add/list/remove commands * Not sure why we're validating test prototypes, but sure * We don't need a map * Improvements and fixups for New Status Effect API (#38660) * Predict healing and bloodstream (#38690) * initial commit * reapply 38126 * fix rootable * someone missed an important minus sign here * try this * fix * fix * reenable crit hits * cleanup * fix status time dirtying * fix * camelCase * Healing and bloodstream prediction fixes. * Resolving Wizard casting recall on nuke disk making it impossible to disarm (#38661) * Resolving Wizard Recall on Nuke disk making it impossible to disarm - Adding a DisarmBomb case to nuke status update loop - Changing a few methods and parameters to properly follow formatting standards - Updating some names to follow camelCase * Updating missed tag * Reverting DataField change Should prevent this preventative bugfix being a breaking change. * Switch HSV to the default colorspace for character customization (#38434) * Made HSV default for character editor * Adds/fixes comments to HSV defaulting * Added dropbox fix, potentially cursed * Revert "Added dropbox fix, potentially cursed" This reverts commit a709883366fbee813e839742125e70844672af29. --------- Co-authored-by: TrixxedHeart <46364955+TrixxedBit@users.noreply.github.com> * Fix: Don't deploy foldables when clicking on items inside containers (#38709) * Fix * Apply suggestions from code review --------- Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> * Pressure Relief Valve (#36708) * initial system (this math is probably WRONG) * General code cleanup and OnExamined support (holy moly this code sucks) * UICode and related events foundation TODO: - Actually write the XAML UI and the underlying system - Un-shitcode the entire thing - Actually test everything... * Working UI code TODO: Make predicted, as this certainly isn't predicted. Even though I said it was. It isn't. * Remove one TODO for unshitcoding the examine code * Add reminder yea * Make predicted (defenitely isn't) (also defenitely isn't a copypaste from pressure pump code) * It's predicted! TODO: - Give it snazzy predicted visuals! - Have a different field for pressure entry, lest it gets bulldozed every UI update. * Improve gas pressure relief valve UI TODO: Reminder to reduce amount of dirties using deltafields * Implement DirtyField prediction * Entity<T> cleanup A lot of Entity<T> conversions and lukewarm cleanup. Also got caught copy pasting code in 4K UHD but it's not like you couldn't tell. * More cleanup and comments * Remove TODO comment on bulldozing window title * """refactoring""" - Move appearance out of shared and finally fix it. Pointless to predict appearance in this instance. - More Entity<T> conversions because I like them. - Move UI creation handling over entirely to the ActivatableUI system. - Fix a hardcoded locale string (why????). * Add visuals * Revert debugging variable replacememt yea * Revert skissue * Remove unused using directives and remove TODO * Localize, cleanup, document * Fix adminlogging discrepancy * Add ability to construct, add guidebook entry * Clear up comment * Add guidebook tooltip to valve * Convert GasPressureReliefValveBoundUserInterface declaration into primary constructor * Adds more input handling and adds autofill on open * Un-deepfry input validator shitcode Genuinely what was I smoking * improve visuals logic * Refactor again - Update math to the correct implementation - Moved code that could be re-used in the future into a helper method under AtmosphereSystem.Gases.cs * I'm sorry but I hate warnings * Remove unused using directive in AtmosphereSystem.Gases.cs * Review and cleanup * Lukewarm UI glossup * Maintainer for the upstream project btw * Remove redundant state sets and messy logic * Unduplicate valve updater code * Redo UI (im sorry Slarti) * run tests * Test refactored UI messaging * Second round of UI improvements - God please find a way to improve this system. Feels bad. * Update loop implementation * Further predict UI * Clear up SetToCurrentThreshold * cleanup * Update to master + pipe layers and bug fixes want to run tests * fixes * Deploy rename pipebomb * Documentation and requested changes * Rename the method that wiggled away * Undo rounding changes * Fix comment * Rename and cleanup * Apply suggestions from code review --------- Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> * Fix TextLinkTag (#32203) * Adjust uplink buy button to be under item icon (#38596) * Adjusted uplink buy button to be under item icon * Put the discount subtext under the icon * Indent fixes, added margin --------- Co-authored-by: TrixxedHeart <46364955+TrixxedBit@users.noreply.github.com> * Scurrets - Audio Improvements (#38482) * Scurret audio tuning * Add new sfx * Update sneezing sfx * YAML support * Rename a folder * make telesci wreck easier (#37569) rel * Validate `ShaderPrototype` IDs (#38728) * Convert all shader prototype string literals to protoids in overlays * Convert more shader prototype literal strings to protoids * Convert ValidatePrototypeId to ProtoId * Later * [BUGFIX] Fixed revenant malfunction ability not working properly only MediBots and Stasis bed (#38664) * fixed * clean up * orks fix smart * review fix 1 * more requested changes * less cursed * more descriptive description * better wording * Tiny Tiny Cleanup of the EyeClosingSystem. (#38734) Update EyeClosingSystem.cs * Fix human skin tone distribution (#38701) * fix: Use PredictedQueueDel for gib spell (#38729) * fix: don't default to uncharged sprite state for cells (#38730) * Fix Hristov description - remove inaccurate technical specs (#38746) - Removes inaccurate 'armor piercing 14.5mm shells' reference - Replaces it with a more funny description, matching the style of the other snipers and guns - Keeps ammunition type '.60 anti-materiel ammo' specification - Fixes issue #38590 Co-authored-by: Arthur Fiorese de Andrade <aandrade@cmcxs.gov.br> * feat: allow mopping evaporating puddles (#38743) * Validate remaining `ProtoId` strings (#38747) Validate remaining ProtoId strings * Validate `ProtoId`s in tests (#38745) * Convert string literals to protoids in Content.Tests * Convert string literals to protoids or consts in Content.IntegrationTests * Fix linter failures Tricksy static using misled me * Cleanup warning in StomachSystem (#38748) you did not see this * Vox scars (#38592) * Added vox scars n'stuff, renamed vox_tattoos.ftl to just vox.ftl * Revert "Added vox scars n'stuff, renamed vox_tattoos.ftl to just vox.ftl" This reverts commit c73da55ba3b39ddf93b493aecd85604c54dd8a15. * locale key fix * Changed top surgery scar names to be more generalized * Adjusted face scars * Formatting fixes --------- Co-authored-by: TrixxedHeart <46364955+TrixxedBit@users.noreply.github.com> * UnlockNode command to LEC. (#38751) * commit * Update UnlockNodeCommand.cs * commit * move command locale to its own file. * Update Content.Server/Xenoarchaeology/Artifact/UnlockNodeCommand.cs --------- Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> * Typofixes for figurine dialogue (#38737) * Typofixes for figurine dialogue * Forgot two * Janitor Tool: Wire Brush (#38667) * Wow! It's -brush- * spacing. * Update Resources/Prototypes/Entities/Objects/Specific/Janitorial/janitor.yml Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> * Update Resources/Prototypes/Entities/Objects/Specific/Janitorial/janitor.yml Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> * fixed changes --------- Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> * Minor escape menu UX improvements (#38650) * fix: spellbooks can have infinite charges (#38376) * fix: spellbooks can have infinite charges * refactor: indicate infinite spellbook charges with null Not sure if I like this much better...
This commit is contained in:
co-authored by
TrixxedHeart
slarticodefast
parent
88a11aea06
commit
29e55b9464
@@ -13,6 +13,7 @@ public sealed class CommandLineArguments
|
||||
public string OutputPath { get; set; } = DirectoryExtensions.MapImages().FullName;
|
||||
public bool ArgumentsAreFileNames { get; set; } = false;
|
||||
public bool ShowMarkers { get; set; } = false;
|
||||
public bool OutputParallax { get; set; } = false;
|
||||
|
||||
public static bool TryParse(IReadOnlyList<string> args, [NotNullWhen(true)] out CommandLineArguments? parsed)
|
||||
{
|
||||
@@ -70,7 +71,17 @@ public sealed class CommandLineArguments
|
||||
PrintHelp();
|
||||
return false;
|
||||
|
||||
case "--parallax":
|
||||
parsed.OutputParallax = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (argument.StartsWith('-'))
|
||||
{
|
||||
Console.WriteLine($"Unknown argument: {argument}");
|
||||
return false;
|
||||
}
|
||||
|
||||
parsed.Maps.Add(argument);
|
||||
break;
|
||||
}
|
||||
@@ -95,7 +106,6 @@ Options:
|
||||
Defaults to: png
|
||||
--viewer
|
||||
Causes the map renderer to create the map.json files required for use with the map viewer.
|
||||
Also puts the maps in the required directory structure.
|
||||
-o / --output <output path>
|
||||
Changes the path the rendered maps will get saved to.
|
||||
Defaults to Resources/MapImages
|
||||
@@ -104,6 +114,8 @@ Options:
|
||||
Example: Content.MapRenderer -f /Maps/box.yml /Maps/bagel.yml
|
||||
-m / --markers
|
||||
Show hidden markers on map render. Defaults to false.
|
||||
--parallax
|
||||
Output images and data used for map viewer parallax.
|
||||
-h / --help
|
||||
Displays this help text");
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using Robust.Shared.Maths;
|
||||
using System.Text.Json.Serialization;
|
||||
using Robust.Shared.ContentPack;
|
||||
using Robust.Shared.Utility;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
|
||||
namespace Content.MapRenderer;
|
||||
@@ -43,31 +45,31 @@ public sealed class LayerGroup
|
||||
public GroupSource Source { get; set; } = new();
|
||||
public List<Layer> Layers { get; set; } = new();
|
||||
|
||||
public static LayerGroup DefaultParallax()
|
||||
public static LayerGroup DefaultParallax(IResourceManager resourceManager, ParallaxOutput output)
|
||||
{
|
||||
return new LayerGroup
|
||||
{
|
||||
Scale = new Position(0.1f, 0.1f),
|
||||
Source = new GroupSource
|
||||
{
|
||||
Url = "https://i.imgur.com/3YO8KRd.png",
|
||||
Extent = new Extent(6000, 4000)
|
||||
Url = output.ReferenceResourceFile(resourceManager, new ResPath("/Textures/Parallaxes/layer1.png")),
|
||||
Extent = new Extent(6000, 4000),
|
||||
},
|
||||
Layers = new List<Layer>
|
||||
{
|
||||
new()
|
||||
{
|
||||
Url = "https://i.imgur.com/IannmmK.png"
|
||||
Url = output.ReferenceResourceFile(resourceManager, new ResPath("/Textures/Parallaxes/layer1.png")),
|
||||
},
|
||||
new()
|
||||
{
|
||||
Url = "https://i.imgur.com/T3W6JsE.png",
|
||||
Url = output.ReferenceResourceFile(resourceManager, new ResPath("/Textures/Parallaxes/layer2.png")),
|
||||
Composition = "lighter",
|
||||
ParallaxScale = new Position(0.2f, 0.2f)
|
||||
},
|
||||
new()
|
||||
{
|
||||
Url = "https://i.imgur.com/T3W6JsE.png",
|
||||
Url = output.ReferenceResourceFile(resourceManager, new ResPath("/Textures/Parallaxes/layer3.png")),
|
||||
Composition = "lighter",
|
||||
ParallaxScale = new Position(0.3f, 0.3f)
|
||||
}
|
||||
@@ -91,9 +93,13 @@ public sealed class Layer
|
||||
|
||||
public readonly struct Extent
|
||||
{
|
||||
[JsonInclude]
|
||||
public readonly float X1;
|
||||
[JsonInclude]
|
||||
public readonly float Y1;
|
||||
[JsonInclude]
|
||||
public readonly float X2;
|
||||
[JsonInclude]
|
||||
public readonly float Y2;
|
||||
|
||||
public Extent()
|
||||
@@ -123,7 +129,9 @@ public readonly struct Extent
|
||||
|
||||
public readonly struct Position
|
||||
{
|
||||
[JsonInclude]
|
||||
public readonly float X;
|
||||
[JsonInclude]
|
||||
public readonly float Y;
|
||||
|
||||
public Position(float x, float y)
|
||||
|
||||
@@ -1,149 +1,158 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Client.Markers;
|
||||
using Content.IntegrationTests;
|
||||
using Content.IntegrationTests.Pair;
|
||||
using Content.Server.GameTicking;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.ContentPack;
|
||||
using Robust.Shared.EntitySerialization;
|
||||
using Robust.Shared.EntitySerialization.Systems;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Components;
|
||||
using Robust.Shared.Map.Events;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
using SixLabors.ImageSharp.Processing;
|
||||
|
||||
namespace Content.MapRenderer.Painters
|
||||
{
|
||||
public sealed class MapPainter
|
||||
public sealed class MapPainter : IAsyncDisposable
|
||||
{
|
||||
public static async IAsyncEnumerable<RenderedGridImage<Rgba32>> Paint(string map,
|
||||
bool mapIsFilename = false,
|
||||
bool showMarkers = false)
|
||||
{
|
||||
var stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
private readonly RenderMap _map;
|
||||
private readonly ITestContextLike _testContextLike;
|
||||
|
||||
await using var pair = await PoolManager.GetServerClient(new PoolSettings
|
||||
private TestPair? _pair;
|
||||
private Entity<MapGridComponent>[] _grids = [];
|
||||
|
||||
public MapPainter(RenderMap map, ITestContextLike testContextLike)
|
||||
{
|
||||
_map = map;
|
||||
_testContextLike = testContextLike;
|
||||
}
|
||||
|
||||
public async Task Initialize()
|
||||
{
|
||||
var stopwatch = RStopwatch.StartNew();
|
||||
|
||||
var poolSettings = new PoolSettings
|
||||
{
|
||||
DummyTicker = false,
|
||||
Connected = true,
|
||||
Destructive = true,
|
||||
Fresh = true,
|
||||
// Seriously whoever made MapPainter use GameMapPrototype I wish you step on a lego one time.
|
||||
Map = mapIsFilename ? "Empty" : map,
|
||||
});
|
||||
|
||||
var server = pair.Server;
|
||||
var client = pair.Client;
|
||||
Map = _map is RenderMapPrototype prototype ? prototype.Prototype : PoolManager.TestMap,
|
||||
};
|
||||
_pair = await PoolManager.GetServerClient(poolSettings, _testContextLike);
|
||||
|
||||
Console.WriteLine($"Loaded client and server in {(int)stopwatch.Elapsed.TotalMilliseconds} ms");
|
||||
|
||||
stopwatch.Restart();
|
||||
|
||||
var cEntityManager = client.ResolveDependency<IClientEntityManager>();
|
||||
var cPlayerManager = client.ResolveDependency<Robust.Client.Player.IPlayerManager>();
|
||||
|
||||
await client.WaitPost(() =>
|
||||
if (_map is RenderMapFile mapFile)
|
||||
{
|
||||
if (cEntityManager.TryGetComponent(cPlayerManager.LocalEntity, out SpriteComponent? sprite))
|
||||
using var stream = File.OpenRead(mapFile.FileName);
|
||||
|
||||
await _pair.Server.WaitPost(() =>
|
||||
{
|
||||
cEntityManager.System<SpriteSystem>().SetVisible((cPlayerManager.LocalEntity.Value, sprite), false);
|
||||
var loadOptions = new MapLoadOptions
|
||||
{
|
||||
// Accept loading both maps and grids without caring about what the input file truly is.
|
||||
DeserializationOptions =
|
||||
{
|
||||
LogOrphanedGrids = false,
|
||||
},
|
||||
};
|
||||
|
||||
if (!_pair.Server.System<MapLoaderSystem>().TryLoadGeneric(stream, mapFile.FileName, out var loadResult, loadOptions))
|
||||
throw new IOException($"File {mapFile.FileName} could not be read");
|
||||
|
||||
_grids = loadResult.Grids.ToArray();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public async Task SetupView(bool showMarkers)
|
||||
{
|
||||
if (_pair == null)
|
||||
throw new InvalidOperationException("Instance not initialized!");
|
||||
|
||||
await _pair.Client.WaitPost(() =>
|
||||
{
|
||||
if (_pair.Client.EntMan.TryGetComponent(_pair.Client.PlayerMan.LocalEntity, out SpriteComponent? sprite))
|
||||
{
|
||||
_pair.Client.System<SpriteSystem>()
|
||||
.SetVisible((_pair.Client.PlayerMan.LocalEntity.Value, sprite), false);
|
||||
}
|
||||
});
|
||||
|
||||
if (showMarkers)
|
||||
await pair.WaitClientCommand("showmarkers");
|
||||
{
|
||||
await _pair.Client.WaitPost(() =>
|
||||
{
|
||||
_pair.Client.System<MarkerSystem>().MarkersVisible = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<MapViewerData> GenerateMapViewerData(ParallaxOutput? parallaxOutput)
|
||||
{
|
||||
if (_pair == null)
|
||||
throw new InvalidOperationException("Instance not initialized!");
|
||||
|
||||
var mapShort = _map.ShortName;
|
||||
|
||||
string fullName;
|
||||
if (_map is RenderMapPrototype prototype)
|
||||
{
|
||||
fullName = _pair.Server.ProtoMan.Index(prototype.Prototype).MapName;
|
||||
}
|
||||
else
|
||||
{
|
||||
fullName = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(mapShort);
|
||||
}
|
||||
|
||||
var mapViewerData = new MapViewerData
|
||||
{
|
||||
Id = mapShort,
|
||||
Name = fullName,
|
||||
};
|
||||
|
||||
if (parallaxOutput != null)
|
||||
{
|
||||
await _pair.Client.WaitPost(() =>
|
||||
{
|
||||
var res = _pair.Client.InstanceDependencyCollection.Resolve<IResourceManager>();
|
||||
mapViewerData.ParallaxLayers.Add(LayerGroup.DefaultParallax(res, parallaxOutput));
|
||||
});
|
||||
}
|
||||
|
||||
return mapViewerData;
|
||||
}
|
||||
|
||||
public async IAsyncEnumerable<RenderedGridImage<Rgba32>> Paint()
|
||||
{
|
||||
if (_pair == null)
|
||||
throw new InvalidOperationException("Instance not initialized!");
|
||||
|
||||
var client = _pair.Client;
|
||||
var server = _pair.Server;
|
||||
|
||||
var sEntityManager = server.ResolveDependency<IServerEntityManager>();
|
||||
var sPlayerManager = server.ResolveDependency<IPlayerManager>();
|
||||
|
||||
var entityManager = server.ResolveDependency<IEntityManager>();
|
||||
var mapLoader = entityManager.System<MapLoaderSystem>();
|
||||
var mapSys = entityManager.System<SharedMapSystem>();
|
||||
var deps = server.ResolveDependency<IEntitySystemManager>().DependencyCollection;
|
||||
|
||||
Entity<MapGridComponent>[] grids = [];
|
||||
|
||||
if (mapIsFilename)
|
||||
{
|
||||
var resPath = new ResPath(map);
|
||||
|
||||
if (!mapLoader.TryReadFile(resPath, out var data))
|
||||
throw new IOException($"File {map} could not be read");
|
||||
|
||||
var ev = new BeforeEntityReadEvent();
|
||||
server.EntMan.EventBus.RaiseEvent(EventSource.Local, ev);
|
||||
|
||||
var deserializer = new EntityDeserializer(deps,
|
||||
data,
|
||||
DeserializationOptions.Default,
|
||||
ev.RenamedPrototypes,
|
||||
ev.DeletedPrototypes);
|
||||
|
||||
if (!deserializer.TryProcessData())
|
||||
{
|
||||
throw new IOException($"Failed to process entity data in {map}");
|
||||
}
|
||||
|
||||
if (deserializer.Result.Category == FileCategory.Unknown && deserializer.Result.Version < 7)
|
||||
{
|
||||
var mapCount = 0;
|
||||
var gridCount = 0;
|
||||
foreach (var (entId, ent) in deserializer.YamlEntities)
|
||||
{
|
||||
if (ent.Components != null && ent.Components.ContainsKey("MapGrid"))
|
||||
{
|
||||
gridCount++;
|
||||
}
|
||||
if (ent.Components != null && ent.Components.ContainsKey("Map"))
|
||||
{
|
||||
mapCount++;
|
||||
}
|
||||
}
|
||||
if (mapCount == 1)
|
||||
deserializer.Result.Category = FileCategory.Map;
|
||||
else if (mapCount == 0 && gridCount == 1)
|
||||
deserializer.Result.Category = FileCategory.Grid;
|
||||
}
|
||||
|
||||
switch (deserializer.Result.Category)
|
||||
{
|
||||
case FileCategory.Map:
|
||||
await server.WaitPost(() =>
|
||||
{
|
||||
if (mapLoader.TryLoadMap(resPath, out _, out var loadedGrids))
|
||||
{
|
||||
grids = loadedGrids.ToArray();
|
||||
}
|
||||
});
|
||||
break;
|
||||
|
||||
case FileCategory.Grid:
|
||||
await server.WaitPost(() =>
|
||||
{
|
||||
if (mapLoader.TryLoadGrid(resPath, out _, out var loadedGrids))
|
||||
{
|
||||
grids = [(Entity<MapGridComponent>)loadedGrids];
|
||||
}
|
||||
});
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new IOException($"Unknown category {deserializer.Result.Category}");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
await pair.RunTicksSync(10);
|
||||
await _pair.RunTicksSync(10);
|
||||
await Task.WhenAll(client.WaitIdleAsync(), server.WaitIdleAsync());
|
||||
|
||||
var sMapManager = server.ResolveDependency<IMapManager>();
|
||||
@@ -162,23 +171,23 @@ namespace Content.MapRenderer.Painters
|
||||
sEntityManager.DeleteEntity(playerEntity.Value);
|
||||
}
|
||||
|
||||
if (!mapIsFilename)
|
||||
if (_map is RenderMapPrototype)
|
||||
{
|
||||
var mapId = sEntityManager.System<GameTicker>().DefaultMap;
|
||||
grids = sMapManager.GetAllGrids(mapId).ToArray();
|
||||
_grids = sMapManager.GetAllGrids(mapId).ToArray();
|
||||
}
|
||||
|
||||
foreach (var (uid, _) in grids)
|
||||
foreach (var (uid, _) in _grids)
|
||||
{
|
||||
var gridXform = xformQuery.GetComponent(uid);
|
||||
xformSystem.SetWorldRotation(gridXform, Angle.Zero);
|
||||
}
|
||||
});
|
||||
|
||||
await pair.RunTicksSync(10);
|
||||
await _pair.RunTicksSync(10);
|
||||
await Task.WhenAll(client.WaitIdleAsync(), server.WaitIdleAsync());
|
||||
|
||||
foreach (var (uid, grid) in grids)
|
||||
foreach (var (uid, grid) in _grids)
|
||||
{
|
||||
var tiles = mapSys.GetAllTiles(uid, grid).ToList();
|
||||
if (tiles.Count == 0)
|
||||
@@ -219,16 +228,20 @@ namespace Content.MapRenderer.Painters
|
||||
|
||||
yield return renderedImage;
|
||||
}
|
||||
}
|
||||
|
||||
// We don't care if it fails as we have already saved the images.
|
||||
try
|
||||
{
|
||||
await pair.CleanReturnAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
public async Task CleanReturnAsync()
|
||||
{
|
||||
if (_pair == null)
|
||||
throw new InvalidOperationException("Instance not initialized!");
|
||||
|
||||
await _pair.CleanReturnAsync();
|
||||
}
|
||||
|
||||
public async ValueTask DisposeAsync()
|
||||
{
|
||||
if (_pair != null)
|
||||
await _pair.DisposeAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Robust.Shared.ContentPack;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.MapRenderer;
|
||||
|
||||
/// <summary>
|
||||
/// Helper class for collecting the files used for parallax output
|
||||
/// </summary>
|
||||
public sealed class ParallaxOutput
|
||||
{
|
||||
public const string OutputDirectory = "_parallax";
|
||||
|
||||
public readonly HashSet<ResPath> FilesToCopy = [];
|
||||
|
||||
private readonly string _outputPath;
|
||||
|
||||
/// <summary>
|
||||
/// Helper class for collecting the files used for parallax output
|
||||
/// </summary>
|
||||
public ParallaxOutput(string outputPath)
|
||||
{
|
||||
_outputPath = outputPath;
|
||||
Directory.CreateDirectory(Path.Combine(_outputPath, OutputDirectory));
|
||||
}
|
||||
|
||||
public string ReferenceResourceFile(IResourceManager resourceManager, ResPath path)
|
||||
{
|
||||
var fileName = Path.Combine(OutputDirectory, path.Filename);
|
||||
if (FilesToCopy.Add(path))
|
||||
{
|
||||
using var file = resourceManager.ContentFileRead(path);
|
||||
using var target = File.Create(Path.Combine(_outputPath, fileName));
|
||||
|
||||
file.CopyTo(target);
|
||||
}
|
||||
|
||||
return fileName;
|
||||
}
|
||||
}
|
||||
+105
-27
@@ -3,12 +3,11 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using Content.IntegrationTests;
|
||||
using Content.MapRenderer.Painters;
|
||||
using Content.Server.Maps;
|
||||
using Newtonsoft.Json;
|
||||
using Robust.Shared.Prototypes;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.Formats.Webp;
|
||||
@@ -21,20 +20,19 @@ namespace Content.MapRenderer
|
||||
private static readonly Func<string, string> ChosenMapIdNotIntMessage = id => $"The chosen id is not a valid integer: {id}";
|
||||
private static readonly Func<int, string> NoMapFoundWithIdMessage = id => $"No map found with chosen id: {id}";
|
||||
|
||||
private static readonly MapPainter MapPainter = new();
|
||||
|
||||
internal static async Task Main(string[] args)
|
||||
{
|
||||
|
||||
if (!CommandLineArguments.TryParse(args, out var arguments))
|
||||
return;
|
||||
|
||||
var testContext = new ExternalTestContext("Content.MapRenderer", Console.Out);
|
||||
|
||||
PoolManager.Startup();
|
||||
if (arguments.Maps.Count == 0)
|
||||
{
|
||||
Console.WriteLine("Didn't specify any maps to paint! Loading the map list...");
|
||||
|
||||
await using var pair = await PoolManager.GetServerClient();
|
||||
await using var pair = await PoolManager.GetServerClient(testContext: testContext);
|
||||
var mapIds = pair.Server
|
||||
.ResolveDependency<IPrototypeManager>()
|
||||
.EnumeratePrototypes<GameMapPrototype>()
|
||||
@@ -104,45 +102,118 @@ namespace Content.MapRenderer
|
||||
Console.WriteLine($"Selected maps: {string.Join(", ", selectedMapPrototypes)}");
|
||||
}
|
||||
|
||||
var maps = new List<RenderMap>();
|
||||
|
||||
if (arguments.ArgumentsAreFileNames)
|
||||
{
|
||||
Console.WriteLine("Retrieving maps by file names...");
|
||||
|
||||
//
|
||||
// Handle legacy command line processing:
|
||||
// Ideally, people pass file names that are relative to the process working directory.
|
||||
// i.e. regular command-line behavior.
|
||||
//
|
||||
// However, the map renderer was originally written to only handle gameMap prototypes,
|
||||
// so it would actually go through the list of prototypes and match file name arguments
|
||||
// via a *very* coarse check.
|
||||
//
|
||||
// So if we have any input filenames that don't exist... we run the old behavior.
|
||||
// Yes by the way this means a typo means spinning up an entire integration pool pair
|
||||
// before the map renderer can report a proper failure.
|
||||
//
|
||||
// Note that this legacy processing is very important! The map server currently relies on it,
|
||||
// because it wants to work with file names, but we *need* to resolve the input to a prototype
|
||||
// to properly export viewer JSON data.
|
||||
//
|
||||
|
||||
var lookupPrototypeFiles = new List<string>();
|
||||
|
||||
foreach (var map in arguments.Maps)
|
||||
{
|
||||
if (File.Exists(map))
|
||||
{
|
||||
maps.Add(new RenderMapFile { FileName = map });
|
||||
}
|
||||
else
|
||||
{
|
||||
lookupPrototypeFiles.Add(map);
|
||||
}
|
||||
}
|
||||
|
||||
if (lookupPrototypeFiles.Count > 0)
|
||||
{
|
||||
Console.Write($"Following map files did not exist on disk directly, searching through prototypes: {string.Join(", ", lookupPrototypeFiles)}");
|
||||
|
||||
await using var pair = await PoolManager.GetServerClient();
|
||||
var mapPrototypes = pair.Server
|
||||
.ResolveDependency<IPrototypeManager>()
|
||||
.EnumeratePrototypes<GameMapPrototype>()
|
||||
.ToArray();
|
||||
|
||||
foreach (var toFind in lookupPrototypeFiles)
|
||||
{
|
||||
foreach (var mapPrototype in mapPrototypes)
|
||||
{
|
||||
if (mapPrototype.MapPath.Filename == toFind)
|
||||
{
|
||||
maps.Add(new RenderMapPrototype { Prototype = mapPrototype, });
|
||||
Console.WriteLine($"Found matching map prototype: {mapPrototype.MapName}");
|
||||
goto found;
|
||||
}
|
||||
}
|
||||
|
||||
await Console.Error.WriteLineAsync($"Found no map prototype for file '{toFind}'!");
|
||||
|
||||
found: ;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var map in arguments.Maps)
|
||||
{
|
||||
maps.Add(new RenderMapPrototype { Prototype = map });
|
||||
}
|
||||
}
|
||||
|
||||
await Run(arguments);
|
||||
await Run(arguments, maps, testContext);
|
||||
PoolManager.Shutdown();
|
||||
}
|
||||
|
||||
private static async Task Run(CommandLineArguments arguments)
|
||||
private static async Task Run(
|
||||
CommandLineArguments arguments,
|
||||
List<RenderMap> toRender,
|
||||
ExternalTestContext testContext)
|
||||
{
|
||||
Console.WriteLine($"Creating images for {arguments.Maps.Count} maps");
|
||||
Console.WriteLine($"Creating images for {toRender.Count} maps");
|
||||
|
||||
var parallaxOutput = arguments.OutputParallax ? new ParallaxOutput(arguments.OutputPath) : null;
|
||||
|
||||
var mapNames = new List<string>();
|
||||
foreach (var map in arguments.Maps)
|
||||
foreach (var map in toRender)
|
||||
{
|
||||
Console.WriteLine($"Painting map {map}");
|
||||
|
||||
var mapViewerData = new MapViewerData
|
||||
{
|
||||
Id = map,
|
||||
Name = Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(map)
|
||||
};
|
||||
await using var painter = new MapPainter(map, testContext);
|
||||
await painter.Initialize();
|
||||
await painter.SetupView(showMarkers: arguments.ShowMarkers);
|
||||
|
||||
mapViewerData.ParallaxLayers.Add(LayerGroup.DefaultParallax());
|
||||
var directory = Path.Combine(arguments.OutputPath, Path.GetFileNameWithoutExtension(map));
|
||||
var mapViewerData = await painter.GenerateMapViewerData(parallaxOutput);
|
||||
|
||||
var mapShort = map.ShortName;
|
||||
var directory = Path.Combine(arguments.OutputPath, mapShort);
|
||||
|
||||
mapNames.Add(mapShort);
|
||||
|
||||
var i = 0;
|
||||
try
|
||||
{
|
||||
await foreach (var renderedGrid in MapPainter.Paint(map,
|
||||
arguments.ArgumentsAreFileNames,
|
||||
arguments.ShowMarkers))
|
||||
await foreach (var renderedGrid in painter.Paint())
|
||||
{
|
||||
var grid = renderedGrid.Image;
|
||||
Directory.CreateDirectory(directory);
|
||||
|
||||
var fileName = Path.GetFileNameWithoutExtension(map);
|
||||
var savePath = $"{directory}{Path.DirectorySeparatorChar}{fileName}-{i}.{arguments.Format}";
|
||||
var savePath = $"{directory}{Path.DirectorySeparatorChar}{mapShort}-{i}.{arguments.Format}";
|
||||
|
||||
Console.WriteLine($"Writing grid of size {grid.Width}x{grid.Height} to {savePath}");
|
||||
|
||||
@@ -167,9 +238,7 @@ namespace Content.MapRenderer
|
||||
|
||||
grid.Dispose();
|
||||
|
||||
mapViewerData.Grids.Add(new GridLayer(renderedGrid, Path.Combine(map, Path.GetFileName(savePath))));
|
||||
|
||||
mapNames.Add(fileName);
|
||||
mapViewerData.Grids.Add(new GridLayer(renderedGrid, Path.Combine(mapShort, Path.GetFileName(savePath))));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
@@ -182,8 +251,17 @@ namespace Content.MapRenderer
|
||||
|
||||
if (arguments.ExportViewerJson)
|
||||
{
|
||||
var json = JsonConvert.SerializeObject(mapViewerData);
|
||||
await File.WriteAllTextAsync(Path.Combine(arguments.OutputPath, map, "map.json"), json);
|
||||
var json = JsonSerializer.Serialize(mapViewerData);
|
||||
await File.WriteAllTextAsync(Path.Combine(directory, "map.json"), json);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
await painter.CleanReturnAsync();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine($"Exception while shutting down painter: {e}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
using System.IO;
|
||||
using Content.Server.Maps;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.MapRenderer;
|
||||
|
||||
/// <summary>
|
||||
/// A single target map that the map renderer should render.
|
||||
/// </summary>
|
||||
/// <seealso cref="RenderMapPrototype"/>
|
||||
/// <seealso cref="RenderMapFile"/>
|
||||
public abstract class RenderMap
|
||||
{
|
||||
/// <summary>
|
||||
/// Short identifier of the map that should be unique-ish. Used in file names and other important stuff.
|
||||
/// </summary>
|
||||
public abstract string ShortName { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Specifies a map prototype that the map renderer should render.
|
||||
/// </summary>
|
||||
public sealed class RenderMapPrototype : RenderMap
|
||||
{
|
||||
/// <summary>
|
||||
/// The ID of the prototype to render.
|
||||
/// </summary>
|
||||
public required ProtoId<GameMapPrototype> Prototype;
|
||||
|
||||
public override string ShortName => Prototype;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{nameof(RenderMapPrototype)}({Prototype})";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Specifies a map file on disk that the map renderer should render.
|
||||
/// </summary>
|
||||
public sealed class RenderMapFile : RenderMap
|
||||
{
|
||||
/// <summary>
|
||||
/// The path to the file that should be rendered. This is an OS disk path, *not* a <see cref="ResPath"/>.
|
||||
/// </summary>
|
||||
public required string FileName;
|
||||
|
||||
public override string ShortName => Path.GetFileNameWithoutExtension(FileName);
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{nameof(RenderMapFile)}({FileName})";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user