Skip to content
This repository was archived by the owner on May 19, 2021. It is now read-only.

Commit 96b1a38

Browse files
committed
adjust statusbar texts fixes #37, compare version numbers, if difference is more than 0.1 then show update available fixes #38, clear folder list when loading settings fixes#39
1 parent a5731f8 commit 96b1a38

File tree

3 files changed

+24
-10
lines changed

3 files changed

+24
-10
lines changed

Diff for: UnityLauncher/Form1.cs

+14-8
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public partial class Form1 : Form
1919
public static Dictionary<string, string> unityList = new Dictionary<string, string>();
2020
const string contextRegRoot = "Software\\Classes\\Directory\\Background\\shell";
2121
const string launcherArgumentsFile = "LauncherArguments.txt";
22-
const string githubReleaseCheckURL = "https://api.github.com/repos/unitycoder/unitylauncher/releases/latest";
22+
const string githubReleaseAPICheckURL = "https://api.github.com/repos/unitycoder/unitylauncher/releases/latest";
2323
const string githubReleasesURL = "https://github.com/unitycoder/UnityLauncher/releases";
2424

2525
bool isDownloadUnityList = false;
@@ -135,6 +135,7 @@ void LoadSettings()
135135
gridRecent.Columns["_gitBranch"].Visible = chkShowGitBranchColumn.Checked;
136136

137137
// update installations folder listbox
138+
lstRootFolders.Items.Clear();
138139
lstRootFolders.Items.AddRange(Properties.Settings.Default.rootFolders.Cast<string>().ToArray());
139140
// update packages folder listbox
140141
lstPackageFolders.Items.AddRange(Properties.Settings.Default.packageFolders.Cast<string>().ToArray());
@@ -167,7 +168,7 @@ bool HaveExactVersionInstalled(string version)
167168

168169
void AddUnityInstallationRootFolder()
169170
{
170-
folderBrowserDialog1.Description = "Select root folder";
171+
folderBrowserDialog1.Description = "Select Unity installations root folder";
171172
var d = folderBrowserDialog1.ShowDialog();
172173
var newRoot = folderBrowserDialog1.SelectedPath;
173174

@@ -363,8 +364,14 @@ void LaunchProject(string projectPath, string version, bool openProject = true,
363364

364365
if (HaveExactVersionInstalled(version) == true)
365366
{
366-
//Console.WriteLine("Opening unity version " + version);
367-
SetStatus("Launching project in unity " + version);
367+
if (openProject == true)
368+
{
369+
SetStatus("Launching project in Unity " + version);
370+
}
371+
else
372+
{
373+
SetStatus("Launching Unity " + version);
374+
}
368375

369376
try
370377
{
@@ -527,7 +534,6 @@ void LaunchSelectedProject(bool openProject = true)
527534
var selected = gridRecent.CurrentCell.RowIndex;
528535
if (selected > -1)
529536
{
530-
SetStatus("Launching project..");
531537
var projectPath = gridRecent.Rows[selected].Cells["_path"].Value.ToString();
532538
var version = Tools.GetProjectVersion(projectPath);
533539
LaunchProject(projectPath, version, openProject);
@@ -1100,10 +1106,10 @@ string GetSelectedRowData(string key)
11001106

11011107
void CheckUpdates()
11021108
{
1103-
var result = Tools.CheckUpdates(githubReleaseCheckURL, previousGitRelease);
1109+
var result = Tools.CheckUpdates(githubReleaseAPICheckURL, previousGitRelease);
11041110
if (string.IsNullOrEmpty(result) == false)
11051111
{
1106-
SetStatus("Update available: " + result);
1112+
SetStatus("Update available: " + result + " - Previous release was:" + previousGitRelease);
11071113
DialogResult dialogResult = MessageBox.Show("Update " + result + " is available, open download page?", "UnityLauncher - Check Update", MessageBoxButtons.YesNo);
11081114
if (dialogResult == DialogResult.Yes) // open download page
11091115
{
@@ -1112,7 +1118,7 @@ void CheckUpdates()
11121118
}
11131119
else
11141120
{
1115-
SetStatus("No updates available..");
1121+
SetStatus("No updates available. Current release is " + previousGitRelease);
11161122
}
11171123
}
11181124
}

Diff for: UnityLauncher/PreviousVersion.txt

0 Bytes
Binary file not shown.

Diff for: UnityLauncher/Tools.cs

+10-2
Original file line numberDiff line numberDiff line change
@@ -325,11 +325,18 @@ public static bool LaunchExplorer(string folder)
325325
return result;
326326
}
327327

328+
/// <summary>
329+
///
330+
/// </summary>
331+
/// <param name="githubReleaseURL">api to check releases</param>
332+
/// <param name="previousGitRelease">embedded previous release version</param>
333+
/// <returns>null if no info available, otherwise returns current github release number</returns>
328334
public static string CheckUpdates(string githubReleaseURL, string previousGitRelease)
329335
{
330336
string result = null;
331337
using (WebClient client = new WebClient())
332338
{
339+
// fetch current release info
333340
client.Headers.Add("user-agent", "MuskBrowser");
334341
string json = client.DownloadString(githubReleaseURL);
335342
var arr = json.Split(new string[] { "\"tag_name\":" }, StringSplitOptions.None);
@@ -342,8 +349,9 @@ public static string CheckUpdates(string githubReleaseURL, string previousGitRel
342349
if (arr2.Length > 1)
343350
{
344351
var currentlyAvailableLatestReleaseTag = arr2[1];
345-
// compare with this build release version
346-
if (currentlyAvailableLatestReleaseTag != previousGitRelease)
352+
// compare online version with build in release version, return github version if different from embedded version
353+
if (Math.Abs(float.Parse(currentlyAvailableLatestReleaseTag)-float.Parse(previousGitRelease))>0.1f)
354+
// if (currentlyAvailableLatestReleaseTag != previousGitRelease)
347355
{
348356
result = currentlyAvailableLatestReleaseTag;
349357
Console.WriteLine("update available: [" + currentlyAvailableLatestReleaseTag + "] / [" + previousGitRelease + "]");

0 commit comments

Comments
 (0)