Make use of new WritableDirProvider APIs to improve file sharing and simplify code.
This commit is contained in:
@@ -8,6 +8,7 @@ using Robust.Client.Graphics;
|
|||||||
using Robust.Client.Interfaces.ResourceManagement;
|
using Robust.Client.Interfaces.ResourceManagement;
|
||||||
using Robust.Shared.Interfaces.Configuration;
|
using Robust.Shared.Interfaces.Configuration;
|
||||||
using Robust.Shared.Interfaces.Log;
|
using Robust.Shared.Interfaces.Log;
|
||||||
|
using Robust.Shared.Interfaces.Resources;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Log;
|
using Robust.Shared.Log;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
@@ -59,16 +60,11 @@ namespace Content.Client.Parallax
|
|||||||
|
|
||||||
if (!debugParallax && _resourceCache.UserData.Exists(ParallaxConfigOld))
|
if (!debugParallax && _resourceCache.UserData.Exists(ParallaxConfigOld))
|
||||||
{
|
{
|
||||||
bool match;
|
var match = _resourceCache.UserData.ReadAllText(ParallaxConfigOld) == contents;
|
||||||
using (var data = _resourceCache.UserData.Open(ParallaxConfigOld, FileMode.Open))
|
|
||||||
using (var reader = new StreamReader(data, EncodingHelpers.UTF8))
|
|
||||||
{
|
|
||||||
match = reader.ReadToEnd() == contents;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (match)
|
if (match)
|
||||||
{
|
{
|
||||||
using (var stream = _resourceCache.UserData.Open(ParallaxPath, FileMode.Open))
|
using (var stream = _resourceCache.UserData.OpenRead(ParallaxPath))
|
||||||
{
|
{
|
||||||
ParallaxTexture = Texture.LoadFromPNGStream(stream, "Parallax");
|
ParallaxTexture = Texture.LoadFromPNGStream(stream, "Parallax");
|
||||||
}
|
}
|
||||||
@@ -95,7 +91,7 @@ namespace Content.Client.Parallax
|
|||||||
ParallaxTexture = Texture.LoadFromImage(image, "Parallax");
|
ParallaxTexture = Texture.LoadFromImage(image, "Parallax");
|
||||||
|
|
||||||
// Store it and CRC so further game starts don't need to regenerate it.
|
// Store it and CRC so further game starts don't need to regenerate it.
|
||||||
using (var stream = _resourceCache.UserData.Open(ParallaxPath, FileMode.Create))
|
using (var stream = _resourceCache.UserData.Create(ParallaxPath))
|
||||||
{
|
{
|
||||||
image.SaveAsPng(stream);
|
image.SaveAsPng(stream);
|
||||||
}
|
}
|
||||||
@@ -105,8 +101,7 @@ namespace Content.Client.Parallax
|
|||||||
var i = 0;
|
var i = 0;
|
||||||
foreach (var debugImage in debugImages)
|
foreach (var debugImage in debugImages)
|
||||||
{
|
{
|
||||||
using (var stream = _resourceCache.UserData.Open(new ResourcePath($"/parallax_debug_{i}.png"),
|
using (var stream = _resourceCache.UserData.Create(new ResourcePath($"/parallax_debug_{i}.png")))
|
||||||
FileMode.Create))
|
|
||||||
{
|
{
|
||||||
debugImage.SaveAsPng(stream);
|
debugImage.SaveAsPng(stream);
|
||||||
}
|
}
|
||||||
@@ -117,7 +112,7 @@ namespace Content.Client.Parallax
|
|||||||
|
|
||||||
image.Dispose();
|
image.Dispose();
|
||||||
|
|
||||||
using (var stream = _resourceCache.UserData.Open(ParallaxConfigOld, FileMode.Create))
|
using (var stream = _resourceCache.UserData.Create(ParallaxConfigOld))
|
||||||
using (var writer = new StreamWriter(stream, EncodingHelpers.UTF8))
|
using (var writer = new StreamWriter(stream, EncodingHelpers.UTF8))
|
||||||
{
|
{
|
||||||
writer.Write(contents);
|
writer.Write(contents);
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ namespace Content.Client
|
|||||||
}
|
}
|
||||||
|
|
||||||
await using var file =
|
await using var file =
|
||||||
_resourceManager.UserData.Open(BaseScreenshotPath / $"{filename}.png", FileMode.CreateNew);
|
_resourceManager.UserData.Open(BaseScreenshotPath / $"{filename}.png", FileMode.CreateNew, FileAccess.Read, FileShare.None);
|
||||||
|
|
||||||
await Task.Run(() =>
|
await Task.Run(() =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ namespace Content.Server.GameTicking.GamePresets
|
|||||||
for (var i = 0; i < numTraitors; i++)
|
for (var i = 0; i < numTraitors; i++)
|
||||||
{
|
{
|
||||||
IPlayerSession traitor;
|
IPlayerSession traitor;
|
||||||
if(prefList.Count() == 0)
|
if(prefList.Count == 0)
|
||||||
{
|
{
|
||||||
traitor = _random.PickAndTake(list);
|
traitor = _random.PickAndTake(list);
|
||||||
Logger.InfoS("preset", "Insufficient preferred traitors, picking at random.");
|
Logger.InfoS("preset", "Insufficient preferred traitors, picking at random.");
|
||||||
|
|||||||
Reference in New Issue
Block a user