Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feature of random loading screen support #211

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update feature of random loading screen support
  • Loading branch information
SadPencil committed Jan 4, 2021
commit 28a495fedbe5910fa8fad9943d6681bfe5c034ae
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)
SadPencil marked this conversation as resolved.
Show resolved Hide resolved
{
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;
}
SadPencil marked this conversation as resolved.
Show resolved Hide resolved

var roll = rand.Next();
if (roll % 2 == 0)
{
backgroundName = currentName;
}
}
if (backgroundMaximum > 0)
{
var rand = new System.Random();
var roll = rand.Next(backgroundMaximum + 1);
SadPencil marked this conversation as resolved.
Show resolved Hide resolved
backgroundName = GetBackgroundName(roll);
}

BackgroundTexture = AssetLoader.LoadTexture(backgroundName);
Expand Down