Merge pull request #2 from space-wizards/master

pull from head
This commit is contained in:
moneyl
2019-05-08 16:18:02 -04:00
committed by GitHub
2 changed files with 8 additions and 4 deletions

View File

@@ -6,6 +6,7 @@ using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.Primitives;
using Robust.Client.Utility;
using Robust.Shared.Interfaces.Log;
using Robust.Shared.Log;
using Robust.Shared.Maths;
using Robust.Shared.Noise;
@@ -17,9 +18,9 @@ namespace Content.Client.Parallax
{
private readonly List<Layer> Layers = new List<Layer>();
public static Image<Rgba32> GenerateParallax(TomlTable config, Size size)
public static Image<Rgba32> GenerateParallax(TomlTable config, Size size, ISawmill sawmill)
{
Logger.DebugS("parallax", "Generating parallax!");
sawmill.Debug("Generating parallax!");
var generator = new ParallaxGenerator();
generator._loadConfig(config);
@@ -28,7 +29,7 @@ namespace Content.Client.Parallax
foreach (var layer in generator.Layers)
{
layer.Apply(image);
Logger.DebugS("parallax", "Layer {0} done!", count++);
sawmill.Debug("Layer {0} done!", count++);
}
return image;

View File

@@ -9,6 +9,7 @@ using SixLabors.ImageSharp;
using SixLabors.Primitives;
using Robust.Client.Graphics;
using Robust.Client.Interfaces.ResourceManagement;
using Robust.Shared.Interfaces.Log;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Utility;
@@ -19,6 +20,7 @@ namespace Content.Client.Parallax
{
#pragma warning disable 649
[Dependency] private readonly IResourceCache _resourceCache;
[Dependency] private readonly ILogManager _logManager;
#pragma warning restore 649
private static readonly ResourcePath ParallaxConfigPath = new ResourcePath("/parallax_config.toml");
@@ -77,8 +79,9 @@ namespace Content.Client.Parallax
configStream?.Dispose();
}
var sawmill = _logManager.GetSawmill("parallax");
// Generate the parallax in the thread pool.
var image = await Task.Run(() => ParallaxGenerator.GenerateParallax(table, new Size(1920, 1080)));
var image = await Task.Run(() => ParallaxGenerator.GenerateParallax(table, new Size(1920, 1080), sawmill));
// And load it in the main thread for safety reasons.
ParallaxTexture = Texture.LoadFromImage(image, "Parallax");