mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-13 09:35:23 -04:00
Add rain and snow to required resources list, add progress status to ResourceFetcher.
This commit is contained in:
parent
37137d6531
commit
e85d52ec22
@ -8,29 +8,32 @@ namespace Launcher {
|
|||||||
public class ResourceFetcher {
|
public class ResourceFetcher {
|
||||||
|
|
||||||
const string resUri = "https://raw.githubusercontent.com/andrewphorn/ClassiCube-Client/master/src/main/resources/";
|
const string resUri = "https://raw.githubusercontent.com/andrewphorn/ClassiCube-Client/master/src/main/resources/";
|
||||||
static readonly string[] coreList = { "char.png", "clouds.png", "terrain.png" };
|
static readonly string[] coreList = { "char.png", "clouds.png", "terrain.png", "rain.png", "snow.png" };
|
||||||
static readonly string[] mobsList = { "chicken.png", "creeper.png", "pig.png", "sheep.png",
|
static readonly string[] mobsList = { "chicken.png", "creeper.png", "pig.png", "sheep.png",
|
||||||
"sheep_fur.png", "skeleton.png", "spider.png", "zombie.png" };
|
"sheep_fur.png", "skeleton.png", "spider.png", "zombie.png" };
|
||||||
|
static int resourcesCount = coreList.Length + mobsList.Length;
|
||||||
|
|
||||||
public void Run( MainForm form ) {
|
public void Run( MainForm form ) {
|
||||||
using( WebClient client = new WebClient() ) {
|
using( WebClient client = new WebClient() ) {
|
||||||
client.Proxy = null;
|
client.Proxy = null;
|
||||||
if( DownloadResources( "", client, form, coreList ) ) {
|
int i = 0;
|
||||||
DownloadResources( "mob/", client, form, mobsList );
|
if( DownloadResources( "", client, form, ref i, coreList ) ) {
|
||||||
|
DownloadResources( "mob/", client, form, ref i, mobsList );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool DownloadResources( string prefix, WebClient client, MainForm form, params string[] resources ) {
|
static bool DownloadResources( string prefix, WebClient client, MainForm form, ref int i, params string[] resources ) {
|
||||||
foreach( string resource in resources ) {
|
foreach( string resource in resources ) {
|
||||||
if( !DownloadData( prefix + resource, client, resource, form ) ) return false;
|
if( !DownloadData( prefix + resource, client, resource, form, ref i ) ) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool DownloadData( string uri, WebClient client, string output, MainForm form ) {
|
static bool DownloadData( string uri, WebClient client, string output, MainForm form, ref int i ) {
|
||||||
|
i++;
|
||||||
if( File.Exists( output ) ) return true;
|
if( File.Exists( output ) ) return true;
|
||||||
form.Text = MainForm.AppName + " - fetching " + output;
|
form.Text = MainForm.AppName + " - fetching " + output + "(" + i + "/" + resourcesCount + ")";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
client.DownloadFile( resUri + uri, output );
|
client.DownloadFile( resUri + uri, output );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user