Skip to content

Commit

Permalink
Update feature of random loading screen support
Browse files Browse the repository at this point in the history
  • Loading branch information
SadPencil committed Jan 4, 2021
1 parent aac69b5 commit 28a495f
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions DXMainClient/DXGUI/Generic/LoadingScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,32 @@ public override void Initialize()
ClientRectangle = new Rectangle(0, 0, 800, 600);
Name = "LoadingScreen";

string backgroundName = "loadingscreen.png";
string GetBackgroundName(int id)
{
if (id == 0)
return "loadingscreen.png";
else
return "loadingscreen" + id.ToString(System.Globalization.CultureInfo.InvariantCulture) + ".png";
}

var rand = new System.Random();
for (int i = 0; ; i++)
string backgroundName = GetBackgroundName(0);

// Randomly select a background picture if there are more than one pictures.
int backgroundMaximum = 0;
for (int i = 1; ; i++)
{
string currentName = "loadingscreen" + i.ToString(System.Globalization.CultureInfo.InvariantCulture) + ".png";
string currentName = GetBackgroundName(i);
if (!AssetLoader.AssetExists(currentName))
{
backgroundMaximum = i - 1;
break;
}

var roll = rand.Next();
if (roll % 2 == 0)
{
backgroundName = currentName;
}
}
if (backgroundMaximum > 0)
{
var rand = new System.Random();
var roll = rand.Next(backgroundMaximum + 1);
backgroundName = GetBackgroundName(roll);
}

BackgroundTexture = AssetLoader.LoadTexture(backgroundName);
Expand Down

0 comments on commit 28a495f

Please sign in to comment.