mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-10-16 23:49:19 +02: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"
|
||||
};
|
||||
|
||||
private static MiniTextureIndex Build(int missRate)
|
||||
private static MiniTextureIndex Build(int? missRate)
|
||||
{
|
||||
var files = new InMemoryFileSystem();
|
||||
foreach (string name in Names)
|
||||
@@ -20,14 +20,14 @@ public class MiniTextureIndexTests
|
||||
files.WithFile(TestInstallation.At("textures", "mini", "other.bmp"), "bitmap");
|
||||
|
||||
var environment = new FakeEnvironment();
|
||||
if (missRate > 0)
|
||||
environment.With(MiniTextureIndex.MissRateVariable, missRate.ToString());
|
||||
if (missRate is { } rate)
|
||||
environment.With(MiniTextureIndex.MissRateVariable, rate.ToString());
|
||||
|
||||
return new MiniTextureIndex(files, new GamePaths(TestInstallation.Root), environment);
|
||||
}
|
||||
|
||||
[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);
|
||||
|
||||
@@ -35,6 +35,18 @@ public class MiniTextureIndexTests
|
||||
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]
|
||||
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";
|
||||
|
||||
/// <summary>
|
||||
/// Set to 1-100 to make that percentage of thumbnails behave as if the
|
||||
/// installation did not have their file - the vehicle then falls back to
|
||||
/// other.bmp exactly as one naming an unknown thumbnail would. For checking
|
||||
/// how a consist looks when some of its stock has no picture of its own.
|
||||
/// Off unless the variable is set.
|
||||
/// Set to 0-100 to override <see cref="DefaultMissRate"/>: the percentage of
|
||||
/// thumbnails that behave as if the installation did not have their file, so
|
||||
/// the vehicle falls back to other.bmp exactly as one naming an unknown
|
||||
/// thumbnail would. Set it to 0 to see the installation as it really is.
|
||||
/// </summary>
|
||||
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 IGamePaths _paths;
|
||||
private readonly int _missRate;
|
||||
@@ -93,7 +103,7 @@ public sealed class MiniTextureIndex : IMiniTextureIndex
|
||||
string? raw = environment?.GetVariable(MissRateVariable);
|
||||
return int.TryParse(raw, NumberStyles.Integer, CultureInfo.InvariantCulture, out int rate)
|
||||
? Math.Clamp(rate, 0, 100)
|
||||
: 0;
|
||||
: DefaultMissRate;
|
||||
}
|
||||
|
||||
private Dictionary<string, string> Index()
|
||||
|
||||
Reference in New Issue
Block a user