diff --git a/README.md b/README.md index a7a96cc..d4b68b0 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ +# Note: New Dark Theme WPF version is here : https://github.com/unitycoder/UnityLauncherPro + +### this old winforms version is no longer updated! + # UnityLauncher Handle all your Unity versions and Projects easily! diff --git a/UnityLauncher/Form1.Designer.cs b/UnityLauncher/Form1.Designer.cs index 7f38ec3..318d60b 100644 --- a/UnityLauncher/Form1.Designer.cs +++ b/UnityLauncher/Form1.Designer.cs @@ -32,6 +32,7 @@ private void InitializeComponent() System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabProjects = new System.Windows.Forms.TabPage(); + this.lblClearSearchField = new System.Windows.Forms.Label(); this.btnBrowseForProject = new System.Windows.Forms.Button(); this.btnRefreshProjectList = new System.Windows.Forms.Button(); this.tbSearchBar = new System.Windows.Forms.TextBox(); @@ -64,6 +65,7 @@ private void InitializeComponent() this.label3 = new System.Windows.Forms.Label(); this.lstPackageFolders = new System.Windows.Forms.ListBox(); this.tabUpdates = new System.Windows.Forms.TabPage(); + this.btnDownloadNewUnity = new System.Windows.Forms.Button(); this.tbSearchUpdates = new System.Windows.Forms.TextBox(); this.btnOpenUpdateWebsite = new System.Windows.Forms.Button(); this.btnFetchUnityVersions = new System.Windows.Forms.Button(); @@ -71,6 +73,7 @@ private void InitializeComponent() this._Date = new System.Windows.Forms.DataGridViewTextBoxColumn(); this._UnityUpdateVersion = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.tabSettings = new System.Windows.Forms.TabPage(); + this.btnPlayerLogFolder = new System.Windows.Forms.Button(); this.btnOpenLogcatCmd = new System.Windows.Forms.Button(); this.chkDarkSkin = new System.Windows.Forms.CheckBox(); this.btnCheckUpdates = new System.Windows.Forms.Button(); @@ -100,7 +103,6 @@ private void InitializeComponent() this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker(); - this.btnDownloadNewUnity = new System.Windows.Forms.Button(); this.tabControl1.SuspendLayout(); this.tabProjects.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.gridRecent)).BeginInit(); @@ -132,6 +134,7 @@ private void InitializeComponent() // // tabProjects // + this.tabProjects.Controls.Add(this.lblClearSearchField); this.tabProjects.Controls.Add(this.btnBrowseForProject); this.tabProjects.Controls.Add(this.btnRefreshProjectList); this.tabProjects.Controls.Add(this.tbSearchBar); @@ -147,6 +150,20 @@ private void InitializeComponent() this.tabProjects.Text = "Projects"; this.tabProjects.UseVisualStyleBackColor = true; // + // lblClearSearchField + // + this.lblClearSearchField.AutoSize = true; + this.lblClearSearchField.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblClearSearchField.ForeColor = System.Drawing.Color.DarkGray; + this.lblClearSearchField.Location = new System.Drawing.Point(448, 8); + this.lblClearSearchField.Name = "lblClearSearchField"; + this.lblClearSearchField.Size = new System.Drawing.Size(12, 13); + this.lblClearSearchField.TabIndex = 24; + this.lblClearSearchField.Text = "x"; + this.lblClearSearchField.Click += new System.EventHandler(this.lblClearSearchField_Click); + this.lblClearSearchField.MouseEnter += new System.EventHandler(this.lblClearSearchField_MouseEnter); + this.lblClearSearchField.MouseLeave += new System.EventHandler(this.lblClearSearchField_MouseLeave); + // // btnBrowseForProject // this.btnBrowseForProject.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); @@ -526,6 +543,19 @@ private void InitializeComponent() this.tabUpdates.Text = "Updates"; this.tabUpdates.UseVisualStyleBackColor = true; // + // btnDownloadNewUnity + // + this.btnDownloadNewUnity.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.btnDownloadNewUnity.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnDownloadNewUnity.Location = new System.Drawing.Point(3, 511); + this.btnDownloadNewUnity.Name = "btnDownloadNewUnity"; + this.btnDownloadNewUnity.Size = new System.Drawing.Size(239, 35); + this.btnDownloadNewUnity.TabIndex = 25; + this.btnDownloadNewUnity.Text = "Download in Browser"; + this.toolTip1.SetToolTip(this.btnDownloadNewUnity, "Open Release Page"); + this.btnDownloadNewUnity.UseVisualStyleBackColor = true; + this.btnDownloadNewUnity.Click += new System.EventHandler(this.btnDownloadNewUnity_Click); + // // tbSearchUpdates // this.tbSearchUpdates.Location = new System.Drawing.Point(3, 5); @@ -536,8 +566,7 @@ private void InitializeComponent() // // btnOpenUpdateWebsite // - this.btnOpenUpdateWebsite.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.btnOpenUpdateWebsite.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.btnOpenUpdateWebsite.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.btnOpenUpdateWebsite.Location = new System.Drawing.Point(248, 511); this.btnOpenUpdateWebsite.Name = "btnOpenUpdateWebsite"; @@ -609,6 +638,7 @@ private void InitializeComponent() // // tabSettings // + this.tabSettings.Controls.Add(this.btnPlayerLogFolder); this.tabSettings.Controls.Add(this.btnOpenLogcatCmd); this.tabSettings.Controls.Add(this.chkDarkSkin); this.tabSettings.Controls.Add(this.btnCheckUpdates); @@ -638,10 +668,21 @@ private void InitializeComponent() this.tabSettings.Text = "Settings"; this.tabSettings.UseVisualStyleBackColor = true; // + // btnPlayerLogFolder + // + this.btnPlayerLogFolder.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnPlayerLogFolder.Location = new System.Drawing.Point(328, 300); + this.btnPlayerLogFolder.Name = "btnPlayerLogFolder"; + this.btnPlayerLogFolder.Size = new System.Drawing.Size(119, 23); + this.btnPlayerLogFolder.TabIndex = 43; + this.btnPlayerLogFolder.Text = "Player.log Folder"; + this.btnPlayerLogFolder.UseVisualStyleBackColor = true; + this.btnPlayerLogFolder.Click += new System.EventHandler(this.btnPlayerLogFolder_Click); + // // btnOpenLogcatCmd // this.btnOpenLogcatCmd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.btnOpenLogcatCmd.Location = new System.Drawing.Point(453, 311); + this.btnOpenLogcatCmd.Location = new System.Drawing.Point(453, 271); this.btnOpenLogcatCmd.Name = "btnOpenLogcatCmd"; this.btnOpenLogcatCmd.Size = new System.Drawing.Size(119, 23); this.btnOpenLogcatCmd.TabIndex = 42; @@ -754,7 +795,7 @@ private void InitializeComponent() // btnOpenLogFolder // this.btnOpenLogFolder.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.btnOpenLogFolder.Location = new System.Drawing.Point(453, 273); + this.btnOpenLogFolder.Location = new System.Drawing.Point(328, 271); this.btnOpenLogFolder.Name = "btnOpenLogFolder"; this.btnOpenLogFolder.Size = new System.Drawing.Size(119, 23); this.btnOpenLogFolder.TabIndex = 32; @@ -916,12 +957,12 @@ private void InitializeComponent() // // statusStrip1 // + // this next line keeps disappearing : this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {this.toolStripStatusLabel1}); + this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolStripStatusLabel1 }); this.statusStrip1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.statusStrip1.AutoSize = false; this.statusStrip1.Dock = System.Windows.Forms.DockStyle.None; - this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripStatusLabel1}); this.statusStrip1.Location = new System.Drawing.Point(0, 590); this.statusStrip1.Name = "statusStrip1"; this.statusStrip1.Size = new System.Drawing.Size(579, 22); @@ -937,20 +978,6 @@ private void InitializeComponent() this.toolStripStatusLabel1.Text = "toolStripStatusLabel1"; this.toolStripStatusLabel1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // - // btnDownloadNewUnity - // - this.btnDownloadNewUnity.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.btnDownloadNewUnity.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnDownloadNewUnity.Location = new System.Drawing.Point(3, 511); - this.btnDownloadNewUnity.Name = "btnDownloadNewUnity"; - this.btnDownloadNewUnity.Size = new System.Drawing.Size(239, 35); - this.btnDownloadNewUnity.TabIndex = 25; - this.btnDownloadNewUnity.Text = "Download in Browser"; - this.toolTip1.SetToolTip(this.btnDownloadNewUnity, "Open Release Page"); - this.btnDownloadNewUnity.UseVisualStyleBackColor = true; - this.btnDownloadNewUnity.Click += new System.EventHandler(this.btnDownloadNewUnity_Click); - // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -1061,6 +1088,8 @@ private void InitializeComponent() private System.Windows.Forms.CheckBox chkDarkSkin; private System.Windows.Forms.Button btnOpenLogcatCmd; private System.Windows.Forms.Button btnDownloadNewUnity; + private System.Windows.Forms.Button btnPlayerLogFolder; + private System.Windows.Forms.Label lblClearSearchField; } } diff --git a/UnityLauncher/Form1.cs b/UnityLauncher/Form1.cs index 6d5ebfa..456283e 100644 --- a/UnityLauncher/Form1.cs +++ b/UnityLauncher/Form1.cs @@ -61,6 +61,8 @@ void Start() return; } + + // check if received -projectPath argument (that means opening from explorer / cmdline) string[] args = Environment.GetCommandLineArgs(); if (args != null && args.Length > 2) @@ -89,8 +91,17 @@ void Start() commandLineArguments += " " + args[i]; } - // try launching it - LaunchProject(projectPathArgument, version, openProject: true, commandLineArguments: commandLineArguments); + // check if force-update button is down + if ((Control.ModifierKeys & Keys.Shift) != 0) + { + DisplayUpgradeDialog(version, projectPathArgument, launchProject: true, commandLineArguments: commandLineArguments); + } + else + { + // try launching it + LaunchProject(projectPathArgument, version, openProject: true, commandLineArguments: commandLineArguments); + } + // quit after launch if enabled in settings if (Properties.Settings.Default.closeAfterExplorer == true) @@ -273,6 +284,7 @@ void FilterRecentProject(object sender, EventArgs e) { SetStatus("Filtering recent projects list ..."); string searchString = tbSearchBar.Text; + foreach (DataGridViewRow row in gridRecent.Rows) { if (row.Cells["_project"].Value.ToString().IndexOf(searchString, StringComparison.OrdinalIgnoreCase) > -1) @@ -284,6 +296,9 @@ void FilterRecentProject(object sender, EventArgs e) row.Visible = false; } } + + lblClearSearchField.Visible = tbSearchBar.Text.Length > 0; + } void FilterUnityUpdates(object sender, EventArgs e) @@ -531,30 +546,73 @@ bool CheckCrashBackupScene(string projectPath) // parse Unity installer exe from release page // thanks to https://github.com/softfruit - string GetDownloadUrlForUnityVersion(string version) + string ParseDownloadURLFromWebpage(string version) { string url = ""; using (WebClient client = new WebClient()) { - string htmlCode = client.DownloadString("https://unity3d.com/get-unity/download/archive"); - string[] lines = htmlCode.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None); - - for (int i = 0; i < lines.Length; i++) + // get correct page url + string website = "https://unity3d.com/get-unity/download/archive"; + if (Tools.VersionIsPatch(version)) website = "https://unity3d.com/unity/qa/patch-releases"; + if (Tools.VersionIsBeta(version)) website = "https://unity3d.com/unity/beta/" + version; + if (Tools.VersionIsAlpha(version)) website = "https://unity3d.com/unity/alpha/" + version; + + // download html + string sourceHTML = client.DownloadString(website); + string[] lines = sourceHTML.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None); + + // patch version download assistant finder + if (Tools.VersionIsPatch(version)) + { + for (int i = 0; i < lines.Length; i++) + { + if (lines[i].Contains("UnityDownloadAssistant-" + version + ".exe")) + { + int start = lines[i].IndexOf('"') + 1; + int end = lines[i].IndexOf('"', start); + url = lines[i].Substring(start, end - start); + break; + } + } + } + else if (Tools.VersionIsArchived(version)) { - if (lines[i].Contains("UnitySetup64-" + version)) + // archived version download assistant finder + for (int i = 0; i < lines.Length; i++) { - string line = lines[i - 1]; - int start = line.IndexOf('"') + 1; - int end = line.IndexOf('"', start); - url = @"https://unity3d.com" + line.Substring(start, end - start); - break; + // find line where full installer is (from archive page) + if (lines[i].Contains("UnitySetup64-" + version)) + { + // take previous line, which contains download assistant url + string line = lines[i - 1]; + int start = line.IndexOf('"') + 1; + int end = line.IndexOf('"', start); + url = @"https://unity3d.com" + line.Substring(start, end - start); + break; + } + } + } + else // alpha or beta version download assistant finder + { + for (int i = 0; i < lines.Length; i++) + { + if (lines[i].Contains("UnityDownloadAssistant.exe")) + { + int start = lines[i].IndexOf('"') + 1; + int end = lines[i].IndexOf('"', start); + url = lines[i].Substring(start, end - start) + "#version=" + version; + break; + } } } } + // didnt find installer if (string.IsNullOrEmpty(url)) + { SetStatus("Cannot find UnityDownloadAssistant.exe for this version."); + } return url; } @@ -565,7 +623,8 @@ string GetDownloadUrlForUnityVersion(string version) /// full url to installer void DownloadInBrowser(string url, string version) { - string exeURL = GetDownloadUrlForUnityVersion(version); + string exeURL = ParseDownloadURLFromWebpage(version); + if (string.IsNullOrEmpty(exeURL) == false) { SetStatus("Download installer in browser: " + exeURL); @@ -791,6 +850,7 @@ private void Form1_KeyPress(object sender, KeyPressEventArgs e) if (tabControl1.SelectedIndex == 0 && tbSearchBar.Text != "") { tbSearchBar.Text = ""; + lblClearSearchField.Visible = false; } else if (tabControl1.SelectedIndex == 3 && tbSearchUpdates.Text != "") { @@ -809,6 +869,7 @@ private void Form1_KeyPress(object sender, KeyPressEventArgs e) tbSearchBar.Focus(); tbSearchBar.Text += e.KeyChar; tbSearchBar.Select(tbSearchBar.Text.Length, 0); + lblClearSearchField.Visible = tbSearchBar.Text.Length > 0; } break; } @@ -1125,7 +1186,7 @@ void UpgradeProject() } } - void DisplayUpgradeDialog(string currentVersion, string projectPath, bool launchProject = true) + void DisplayUpgradeDialog(string currentVersion, string projectPath, bool launchProject = true, string commandLineArguments = "") { // display upgrade dialog (version selector) Form2 upgradeDialog = new Form2(); @@ -1138,7 +1199,7 @@ void DisplayUpgradeDialog(string currentVersion, string projectPath, bool launch case DialogResult.Ignore: // view release notes page Tools.OpenReleaseNotes(currentVersion); // display window again for now.. - DisplayUpgradeDialog(currentVersion, projectPath, launchProject); + DisplayUpgradeDialog(currentVersion, projectPath, launchProject, commandLineArguments); break; case DialogResult.Cancel: // cancelled SetStatus("Cancelled project upgrade"); @@ -1386,5 +1447,33 @@ private void btnDownloadNewUnity_Click(object sender, EventArgs e) } } + + // open LocalLow folder + private void btnPlayerLogFolder_Click(object sender, EventArgs e) + { + var logfolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "/../LocalLow"); + if (Directory.Exists(logfolder) == true) + { + if (Tools.LaunchExplorer(logfolder) == false) + { + SetStatus("Error> Directory not found: " + logfolder); + } + } + } + + private void lblClearSearchField_Click(object sender, EventArgs e) + { + tbSearchBar.Text = ""; + } + + private void lblClearSearchField_MouseEnter(object sender, EventArgs e) + { + ((Label)sender).ForeColor = Color.FromArgb(255, 0, 0, 0); + } + + private void lblClearSearchField_MouseLeave(object sender, EventArgs e) + { + ((Label)sender).ForeColor = Color.FromArgb(128, 128, 128, 128); + } } // class Form } // namespace \ No newline at end of file diff --git a/UnityLauncher/Form1.resx b/UnityLauncher/Form1.resx index f629e1d..83ebd0f 100644 --- a/UnityLauncher/Form1.resx +++ b/UnityLauncher/Form1.resx @@ -138,6 +138,36 @@ True + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + True @@ -156,6 +186,15 @@ True + + True + + + True + + + 14, 20 + 111, 20 diff --git a/UnityLauncher/Form2.Designer.cs b/UnityLauncher/Form2.Designer.cs index 6293ff1..5f5e19c 100644 --- a/UnityLauncher/Form2.Designer.cs +++ b/UnityLauncher/Form2.Designer.cs @@ -133,6 +133,7 @@ private void InitializeComponent() this.Name = "Form2"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Missing Exact Unity Version"; + this.TopMost = true; this.Load += new System.EventHandler(this.Form2_Load); this.ResumeLayout(false); this.PerformLayout(); diff --git a/UnityLauncher/Tools.cs b/UnityLauncher/Tools.cs index 0ac7e94..1dc5e63 100644 --- a/UnityLauncher/Tools.cs +++ b/UnityLauncher/Tools.cs @@ -178,9 +178,7 @@ public static bool OpenReleaseNotes(string version) public static string GetUnityReleaseURL(string version) { string url = ""; - - - if (version.Contains("f")) // archived + if (VersionIsArchived(version)) { // remove f# version = Regex.Replace(version, @"f.", "", RegexOptions.IgnoreCase); @@ -199,24 +197,47 @@ public static string GetUnityReleaseURL(string version) url = "https://unity3d.com/unity/" + whatsnew + "/" + padding + version; } else - if (version.Contains("p")) // patch version + if (VersionIsPatch(version)) { url = "https://unity3d.com/unity/qa/patch-releases/" + version; } else - if (version.Contains("b")) // beta version + if (VersionIsBeta(version)) { url = "https://unity3d.com/unity/beta/" + version; } else - if (version.Contains("a")) // alpha version + if (VersionIsAlpha(version)) { url = "https://unity3d.com/unity/alpha/" + version; } + Console.WriteLine(url); + return url; } + // if version contains *f* its archived version + public static bool VersionIsArchived(string version) + { + return version.Contains("f"); + } + + public static bool VersionIsPatch(string version) + { + return version.Contains("p"); + } + + public static bool VersionIsBeta(string version) + { + return version.Contains("b"); + } + + public static bool VersionIsAlpha(string version) + { + return version.Contains("a"); + } + /// /// uninstall context menu item from registry ///