mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-11-03 21:02:06 +01:00
Temporarily make half the thumbnails act as missing
This commit is contained in:
@@ -12,7 +12,7 @@ public class MiniTextureIndexTests
|
|||||||
"406r", "424z", "621z", "z1kd", "gags", "eaos", "falns", "uacs", "sgs", "kbs"
|
"406r", "424z", "621z", "z1kd", "gags", "eaos", "falns", "uacs", "sgs", "kbs"
|
||||||
};
|
};
|
||||||
|
|
||||||
private static MiniTextureIndex Build(int missRate)
|
private static MiniTextureIndex Build(int? missRate)
|
||||||
{
|
{
|
||||||
var files = new InMemoryFileSystem();
|
var files = new InMemoryFileSystem();
|
||||||
foreach (string name in Names)
|
foreach (string name in Names)
|
||||||
@@ -20,14 +20,14 @@ public class MiniTextureIndexTests
|
|||||||
files.WithFile(TestInstallation.At("textures", "mini", "other.bmp"), "bitmap");
|
files.WithFile(TestInstallation.At("textures", "mini", "other.bmp"), "bitmap");
|
||||||
|
|
||||||
var environment = new FakeEnvironment();
|
var environment = new FakeEnvironment();
|
||||||
if (missRate > 0)
|
if (missRate is { } rate)
|
||||||
environment.With(MiniTextureIndex.MissRateVariable, missRate.ToString());
|
environment.With(MiniTextureIndex.MissRateVariable, rate.ToString());
|
||||||
|
|
||||||
return new MiniTextureIndex(files, new GamePaths(TestInstallation.Root), environment);
|
return new MiniTextureIndex(files, new GamePaths(TestInstallation.Root), environment);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void Without_the_debug_variable_every_thumbnail_loads()
|
public void Setting_the_variable_to_zero_shows_the_installation_as_it_is()
|
||||||
{
|
{
|
||||||
var index = Build(missRate: 0);
|
var index = Build(missRate: 0);
|
||||||
|
|
||||||
@@ -35,6 +35,18 @@ public class MiniTextureIndexTests
|
|||||||
Assert.All(Names, name => Assert.True(index.Has(name)));
|
Assert.All(Names, name => Assert.True(index.Has(name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void The_temporary_default_still_hides_half_the_thumbnails()
|
||||||
|
{
|
||||||
|
// Guards the testing default in MiniTextureIndex.DefaultMissRate. When
|
||||||
|
// that goes back to 0 for release, this test is what says so - change it
|
||||||
|
// together with the constant, do not delete it quietly.
|
||||||
|
var index = Build(missRate: null);
|
||||||
|
|
||||||
|
Assert.Equal(50, index.SimulatedMissRate);
|
||||||
|
Assert.Contains(Names, name => !index.Has(name));
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void The_debug_variable_hides_roughly_the_share_it_names()
|
public void The_debug_variable_hides_roughly_the_share_it_names()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,14 +20,24 @@ public sealed class MiniTextureIndex : IMiniTextureIndex
|
|||||||
private const string FallbackName = "other";
|
private const string FallbackName = "other";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set to 1-100 to make that percentage of thumbnails behave as if the
|
/// Set to 0-100 to override <see cref="DefaultMissRate"/>: the percentage of
|
||||||
/// installation did not have their file - the vehicle then falls back to
|
/// thumbnails that behave as if the installation did not have their file, so
|
||||||
/// other.bmp exactly as one naming an unknown thumbnail would. For checking
|
/// the vehicle falls back to other.bmp exactly as one naming an unknown
|
||||||
/// how a consist looks when some of its stock has no picture of its own.
|
/// thumbnail would. Set it to 0 to see the installation as it really is.
|
||||||
/// Off unless the variable is set.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string MissRateVariable = "STARTER_DEBUG_MISSING_MINI";
|
public const string MissRateVariable = "STARTER_DEBUG_MISSING_MINI";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// TEMPORARY, FOR TESTING THE MISSING-THUMBNAIL DRAWING. Half the vehicles in
|
||||||
|
/// every consist will show the other.bmp stand-in instead of their own
|
||||||
|
/// picture, whether or not the installation is complete.
|
||||||
|
///
|
||||||
|
/// Set this back to 0 before release - it is the whole of the switch, and
|
||||||
|
/// MiniTextureIndexTests.The_temporary_default_still_hides_half_the_thumbnails
|
||||||
|
/// fails the moment it changes, so nothing ships it by accident.
|
||||||
|
/// </summary>
|
||||||
|
private const int DefaultMissRate = 50;
|
||||||
|
|
||||||
private readonly IFileSystem _files;
|
private readonly IFileSystem _files;
|
||||||
private readonly IGamePaths _paths;
|
private readonly IGamePaths _paths;
|
||||||
private readonly int _missRate;
|
private readonly int _missRate;
|
||||||
@@ -93,7 +103,7 @@ public sealed class MiniTextureIndex : IMiniTextureIndex
|
|||||||
string? raw = environment?.GetVariable(MissRateVariable);
|
string? raw = environment?.GetVariable(MissRateVariable);
|
||||||
return int.TryParse(raw, NumberStyles.Integer, CultureInfo.InvariantCulture, out int rate)
|
return int.TryParse(raw, NumberStyles.Integer, CultureInfo.InvariantCulture, out int rate)
|
||||||
? Math.Clamp(rate, 0, 100)
|
? Math.Clamp(rate, 0, 100)
|
||||||
: 0;
|
: DefaultMissRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Dictionary<string, string> Index()
|
private Dictionary<string, string> Index()
|
||||||
|
|||||||
Reference in New Issue
Block a user