Optimize GetSplash

pull/32/head
Miepee 5 years ago
parent 33015b3990
commit 34c6a009fd

@ -7,7 +7,7 @@ namespace AM2RLauncher
/// <summary> /// <summary>
/// Class only for providing Splashes /// Class only for providing Splashes
/// </summary> /// </summary>
static class Splash public static class Splash
{ {
/// <summary> /// <summary>
/// Cross-Platform splash strings /// Cross-Platform splash strings
@ -72,22 +72,36 @@ namespace AM2RLauncher
"Did you find the penguin yet?" "Did you find the penguin yet?"
}; };
/// <summary>
/// Combined splash strings
/// </summary>
private static string[] combinedSplash = combineSplashes();
/// <summary> /// <summary>
/// Get a random splash string, according to the current OS. /// Get a random splash string, according to the current OS.
/// </summary> /// </summary>
/// <returns>The randomly chosen splash as a <see cref="string"/>.</returns> /// <returns>The randomly chosen splash as a <see cref="string"/>.</returns>
public static string GetSplash() public static string GetSplash()
{ {
string[] combinedSplash;
Random rng = new Random(); Random rng = new Random();
if (Platform.Instance.IsGtk)
combinedSplash = GeneralSplash.Concat(LinuxSplash).ToArray();
else
combinedSplash = GeneralSplash;
string splashString = combinedSplash[rng.Next(0, combinedSplash.Length)]; string splashString = combinedSplash[rng.Next(0, combinedSplash.Length)];
return splashString; return splashString;
} }
/// <summary>
/// Creates a string srray which is <see cref="GeneralSplash"/> concatonated with the splash array for the current OS
/// </summary>
/// <returns>A string array where <see cref="GeneralSplash"/> and the splash array for the current OS have been concatonated.</returns>
private static string[] combineSplashes()
{
string[] totalSplashes;
if (Platform.Instance.IsGtk)
totalSplashes = GeneralSplash.Concat(LinuxSplash).ToArray();
// else if (Platform.Instance.IsMac) combinedSplash = GeneralSplash.Concat(MacSplash).ToArray();
else
totalSplashes = GeneralSplash;
return totalSplashes;
}
} }
} }
Loading…
Cancel
Save