diff --git a/League Sandbox Auto Setup/Form1.Designer.cs b/League Sandbox Auto Setup/Form1.Designer.cs index e13af3e..9853dd6 100644 --- a/League Sandbox Auto Setup/Form1.Designer.cs +++ b/League Sandbox Auto Setup/Form1.Designer.cs @@ -45,6 +45,8 @@ private void InitializeComponent() this.label12 = new System.Windows.Forms.Label(); this.installingTestboxLabel = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label(); + this.abortText = new System.Windows.Forms.Label(); + this.browseButton = new System.Windows.Forms.Button(); this.SuspendLayout(); // // label1 @@ -62,7 +64,7 @@ private void InitializeComponent() this.installDirectoryText.Name = "installDirectoryText"; this.installDirectoryText.Size = new System.Drawing.Size(213, 20); this.installDirectoryText.TabIndex = 1; - this.installDirectoryText.Text = "C:/LeagueSandbox"; + this.installDirectoryText.Text = "C:\\LeagueSandbox"; // // label2 // @@ -75,7 +77,7 @@ private void InitializeComponent() // // startButton // - this.startButton.Location = new System.Drawing.Point(197, 69); + this.startButton.Location = new System.Drawing.Point(446, 35); this.startButton.Name = "startButton"; this.startButton.Size = new System.Drawing.Size(75, 23); this.startButton.TabIndex = 3; @@ -191,11 +193,33 @@ private void InitializeComponent() this.label5.TabIndex = 14; this.label5.Text = "Installing LeagueUI(Testbox) Multiplayer Matchmaker"; // + // abortText + // + this.abortText.AutoSize = true; + this.abortText.ForeColor = System.Drawing.Color.Maroon; + this.abortText.Location = new System.Drawing.Point(46, 58); + this.abortText.Name = "abortText"; + this.abortText.Size = new System.Drawing.Size(292, 13); + this.abortText.TabIndex = 16; + this.abortText.Text = "Current operation will be aborted at the next task completion."; + // + // browseButton + // + this.browseButton.Location = new System.Drawing.Point(446, 9); + this.browseButton.Name = "browseButton"; + this.browseButton.Size = new System.Drawing.Size(75, 23); + this.browseButton.TabIndex = 17; + this.browseButton.Text = "Browse"; + this.browseButton.UseVisualStyleBackColor = true; + this.browseButton.Click += new System.EventHandler(this.BrowseButton_Click); + // // leagueSandboxAutoSetupForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(508, 258); + this.ClientSize = new System.Drawing.Size(542, 258); + this.Controls.Add(this.browseButton); + this.Controls.Add(this.abortText); this.Controls.Add(this.installingTestboxLabel); this.Controls.Add(this.label5); this.Controls.Add(this.finishProgressLabel); @@ -238,6 +262,8 @@ private void InitializeComponent() private System.Windows.Forms.Label label12; private System.Windows.Forms.Label installingTestboxLabel; private System.Windows.Forms.Label label5; + private System.Windows.Forms.Label abortText; + private System.Windows.Forms.Button browseButton; } } diff --git a/League Sandbox Auto Setup/Form1.cs b/League Sandbox Auto Setup/Form1.cs index 8dc7463..4960c12 100644 --- a/League Sandbox Auto Setup/Form1.cs +++ b/League Sandbox Auto Setup/Form1.cs @@ -18,6 +18,8 @@ namespace League_Sandbox_Auto_Setup public partial class leagueSandboxAutoSetupForm : Form { static string Client_Folder_Name = "League_Sandbox_Client"; + private bool _abortInitiated; + private bool _setupStarted; public leagueSandboxAutoSetupForm() { InitializeComponent(); @@ -27,13 +29,32 @@ public leagueSandboxAutoSetupForm() Environment.Exit(0); }; } + private void OnAbortSuccessfully() + { + _setupStarted = false; + _abortInitiated = false; + startButton.Enabled = true; + abortText.Visible = false; + } private void startButton_Click(object sender, EventArgs e) { - installDirectoryText.Enabled = false; - startButton.Enabled = false; - Directory.CreateDirectory(installDirectoryText.Text); - startCloningRepositories(); + if (!_setupStarted) + { + installDirectoryText.Enabled = false; + browseButton.Enabled = false; + startButton.Text = "Abort"; + Directory.CreateDirectory(installDirectoryText.Text); + startCloningRepositories(); + _setupStarted = true; + } + else + { + _abortInitiated = true; + abortText.Visible = true; + startButton.Text = "Start"; + startButton.Enabled = false; + } } private void startCloningRepositories() @@ -113,6 +134,12 @@ private void startCloningRepositories() private void startDownloadingClient() { + if (_abortInitiated) + { + OnAbortSuccessfully(); + return; + } + downloadingProgressLabel.Text = "--"; ProtocolProviderFactory.RegisterProtocolHandler("http", typeof(HttpProtocolProvider)); @@ -199,6 +226,12 @@ private void startUnzippingClient() } private void startSettingUpTestbox() { + if (_abortInitiated) + { + OnAbortSuccessfully(); + return; + } + String testboxLink = "http://gamemakersgarage.com/LeagueUI.7z"; String testboxLocation = Path.GetFullPath(Path.Combine(installDirectoryText.Text, "LeagueUI.7z")); if (File.Exists(testboxLocation)) @@ -262,11 +295,11 @@ private void startVisualStudioFirstRun() //Set up GameServer configs var gameServerFolder = Path.Combine(installDirectoryText.Text, "GameServer"); - var templatePath = Path.Combine(gameServerFolder, "GameServerApp\\Settings\\GameServerSettings.json.template"); - var newPath = Path.Combine(gameServerFolder, "GameServerApp\\Settings\\GameServerSettings.json"); + var templatePath = Path.Combine(gameServerFolder, "GameServerConsole\\Settings\\GameServerSettings.json.template"); + var newPath = Path.Combine(gameServerFolder, "GameServerConsole\\Settings\\GameServerSettings.json"); var templateString = File.ReadAllText(templatePath); - var configTemplatePath = Path.Combine(gameServerFolder, "GameServerApp\\Settings\\GameInfo.json.template"); - var configNewPath = Path.Combine(gameServerFolder, "GameServerApp\\Settings\\GameInfo.json"); + var configTemplatePath = Path.Combine(gameServerFolder, "GameServerConsole\\Settings\\GameInfo.json.template"); + var configNewPath = Path.Combine(gameServerFolder, "GameServerConsole\\Settings\\GameInfo.json"); if (File.Exists(newPath)) { File.Delete(newPath); @@ -340,5 +373,16 @@ private void startVisualStudioFirstRun() } }); } + + private void BrowseButton_Click(object sender, EventArgs e) + { + using (var selectPath = new FolderBrowserDialog()) + { + var result = selectPath.ShowDialog(); + + if (result == DialogResult.OK && !string.IsNullOrWhiteSpace(selectPath.SelectedPath)) + installDirectoryText.Text = selectPath.SelectedPath; + } + } } -} \ No newline at end of file +}