Sync launcher version with client version, display name of current resource being fetcehed in form title.

This commit is contained in:
UnknownShadow200 2015-04-08 06:49:24 +10:00
parent 97ad029205
commit 6d6067ec1c
4 changed files with 13 additions and 9 deletions

View File

@ -25,7 +25,7 @@ namespace Launcher {
protected HttpWebResponse MakeRequest( string uri, string referer, string data ) {
HttpWebRequest request = (HttpWebRequest)WebRequest.Create( uri );
request.UserAgent = "ClassicalSharp Launcher 0.1";
request.UserAgent = MainForm.AppName;
request.ReadWriteTimeout = 15 * 1000;
request.Timeout = 15 * 1000;
request.Referer = referer;

View File

@ -764,7 +764,7 @@ namespace Launcher
this.ClientSize = new System.Drawing.Size(432, 393);
this.Controls.Add(this.tabs);
this.Name = "MainForm";
this.Text = "ClassicalSharp Launcher";
this.Text = Launcher.MainForm.AppName;
this.ResizeEnd += new System.EventHandler(this.MainFormResizeEnd);
this.tabMinecraftNet.ResumeLayout(false);
this.tabMC.ResumeLayout(false);

View File

@ -13,6 +13,8 @@ namespace Launcher {
public partial class MainForm : Form {
public const string AppName = "ClassicalSharp Launcher 0.5";
public MainForm() {
InitializeComponent();
AdjustTabs();
@ -35,7 +37,8 @@ namespace Launcher {
"Some required resources weren't found. Would you like to download them now?", "Missing resources",
MessageBoxButtons.OKCancel );
if( result == DialogResult.OK ) {
fetcher.Run();
fetcher.Run( this );
Text = AppName;
}
}
}

View File

@ -11,17 +11,18 @@ namespace Launcher {
const string cloudsUri = "https://raw.githubusercontent.com/andrewphorn/ClassiCube-Client/master/src/main/resources/clouds.png";
const string charUri = "https://raw.githubusercontent.com/andrewphorn/ClassiCube-Client/master/src/main/resources/char.png";
public void Run() {
public void Run( MainForm form ) {
using( WebClient client = new WebClient() ) {
client.Proxy = null;
if( !DownloadData( terrainUri, client, "terrain.png" ) ) return;
if( !DownloadData( cloudsUri, client, "clouds.png" ) ) return;
if( !DownloadData( charUri, client, "char.png" ) ) return;
client.Proxy = null;
if( !DownloadData( terrainUri, client, "terrain.png", form ) ) return;
if( !DownloadData( cloudsUri, client, "clouds.png", form ) ) return;
if( !DownloadData( charUri, client, "char.png", form ) ) return;
}
}
static bool DownloadData( string uri, WebClient client, string output ) {
static bool DownloadData( string uri, WebClient client, string output, MainForm form ) {
if( File.Exists( output ) ) return true;
form.Text = MainForm.AppName + " - fetching " + output;
byte[] data = null;
try {