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

Commit d835ca2

Browse files
committed
upgrade dialog for explorer projects also, fixed #13, more status updates, text changes
1 parent afeabff commit d835ca2

File tree

6 files changed

+172
-132
lines changed

6 files changed

+172
-132
lines changed

Diff for: UnityLauncher/Form1.Designer.cs

+47-49
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: UnityLauncher/Form1.cs

+54-57
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void Start()
5555
return;
5656
}
5757

58-
// check if received -projectPath argument (that means, should try open the project)
58+
// check if received -projectPath argument (that means opening from explorer / cmdline)
5959
string[] args = Environment.GetCommandLineArgs();
6060
if (args != null && args.Length > 2)
6161
{
@@ -67,6 +67,7 @@ void Start()
6767
var projectPathArgument = args[2];
6868
var version = GetProjectVersion(projectPathArgument);
6969

70+
// try launching it
7071
LaunchProject(projectPathArgument, version, true);
7172

7273
SetStatus("Ready");
@@ -239,8 +240,7 @@ void UpdateRecentProjectsList()
239240
//Console.WriteLine(key);
240241
if (key == null)
241242
{
242-
// no recent list founded
243-
Console.WriteLine("No recent projects list founded");
243+
SetStatus("No recent projects list founded");
244244
return;
245245
}
246246

@@ -297,7 +297,7 @@ void LaunchProject(string projectPath, string version, bool openProject = true)
297297
var assetsFolder = Path.Combine(projectPath, "Assets");
298298
if (Directory.Exists(assetsFolder) == false)
299299
{
300-
// TODO could ask if want to create project
300+
// TODO could ask if want to create project..
301301
Directory.CreateDirectory(assetsFolder);
302302
}
303303

@@ -326,37 +326,8 @@ void LaunchProject(string projectPath, string version, bool openProject = true)
326326
}
327327
else // we dont have this version installed (or no version info available)
328328
{
329-
if (string.IsNullOrEmpty(version) == true)
330-
{
331-
DisplayUpgradeDialog(version, projectPath);
332-
}
333-
else // offer to download or open web
334-
{
335-
SetStatus("Missing unity version: " + version);
336-
337-
var yesno = MessageBox.Show("Unity version " + version + " is not installed! Yes = Download, No = Open Webpage", "UnityLauncher", MessageBoxButtons.YesNoCancel);
338-
339-
string url = GetUnityReleaseURL(version);
340-
341-
// download file
342-
if (yesno == DialogResult.Yes)
343-
{
344-
Console.WriteLine("download unity: " + url);
345-
if (string.IsNullOrEmpty(url) == false)
346-
{
347-
DownloadAndRun(url);
348-
}
349-
}
350-
351-
// open page
352-
if (yesno == DialogResult.No)
353-
{
354-
if (string.IsNullOrEmpty(url) == false)
355-
{
356-
Process.Start(url);
357-
}
358-
}
359-
}
329+
SetStatus("Missing unity version: " + version);
330+
DisplayUpgradeDialog(version, projectPath);
360331
}
361332
}
362333
else // given path doesnt exists, strange
@@ -429,7 +400,7 @@ void DownloadAndRun(string url)
429400
else // not found
430401
{
431402
SetStatus("Error> Cannot find installer exe.. opening website instead");
432-
Process.Start(url);
403+
Process.Start(url + "#installer-exe-not-found");
433404
}
434405
}
435406

@@ -440,7 +411,6 @@ void DownloadAndRun(string url)
440411
/// <returns></returns>
441412
string GetFileNameFromUrl(string url)
442413
{
443-
Console.WriteLine(url);
444414
var uri = new Uri(url);
445415
var filename = uri.Segments.Last();
446416
return filename;
@@ -647,11 +617,7 @@ private void btnOpenReleasePage_Click(object sender, EventArgs e)
647617
if (selected > -1)
648618
{
649619
var version = gridUnityList.Rows[selected].Cells["_unityVersion"].Value.ToString();
650-
var url = GetUnityReleaseURL(version);
651-
if (string.IsNullOrEmpty(url) == false)
652-
{
653-
Process.Start(url);
654-
}
620+
OpenReleaseNotes(version);
655621
}
656622
}
657623

@@ -802,7 +768,7 @@ private void btn_openFolder_Click(object sender, EventArgs e)
802768
private void btnExplorePackageFolder_Click(object sender, EventArgs e)
803769
{
804770
var selected = lstPackageFolders.SelectedIndex;
805-
Console.WriteLine(lstPackageFolders.Items[selected].ToString());
771+
//Console.WriteLine(lstPackageFolders.Items[selected].ToString());
806772
if (selected > -1)
807773
{
808774
var path = lstPackageFolders.Items[selected].ToString();
@@ -848,14 +814,27 @@ private void btnUpgradeProject_Click(object sender, EventArgs e)
848814
private void btnOpenLogFolder_Click(object sender, EventArgs e)
849815
{
850816
var logfolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Unity", "Editor");
851-
Console.WriteLine(logfolder);
817+
//Console.WriteLine(logfolder);
852818
if (Directory.Exists(logfolder) == true)
853819
{
854820
LaunchExplorer(logfolder);
855821
}
856822
}
857823
#endregion UI events
858824

825+
void OpenReleaseNotes(string version)
826+
{
827+
SetStatus("Opening release notes for version " + version);
828+
var url = GetUnityReleaseURL(version);
829+
if (string.IsNullOrEmpty(url) == false)
830+
{
831+
Process.Start(url);
832+
}
833+
else
834+
{
835+
SetStatus("Failed opening Release Notes URL for version " + version);
836+
}
837+
}
859838

860839
public static string FindNearestVersion(string version, List<string> allAvailable)
861840
{
@@ -880,13 +859,12 @@ private static string FindNearestVersionFromSimilarVersions(string version, IEnu
880859
if (!stripped.ContainsKey(comparableVersion))
881860
{
882861
stripped.Add(comparableVersion, version);
883-
//Console.WriteLine(comparableVersion + " : " + version);
884862
}
885863

886864
var comparables = stripped.Keys.OrderBy(x => x).ToList();
887865
var actualIndex = comparables.IndexOf(comparableVersion);
888866

889-
if (actualIndex < stripped.Count) return stripped[comparables[actualIndex + 1]];
867+
if (actualIndex < stripped.Count - 1) return stripped[comparables[actualIndex + 1]];
890868
return null;
891869
}
892870

@@ -913,7 +891,6 @@ void UpgradeProject()
913891
// you already have exact version, are you sure about upgrade?
914892
}
915893
}
916-
917894
DisplayUpgradeDialog(currentVersion, projectPath, true);
918895
}
919896
}
@@ -924,18 +901,38 @@ void DisplayUpgradeDialog(string currentVersion, string projectPath, bool launch
924901
Form2 upgradeDialog = new Form2();
925902
Form2.currentVersion = currentVersion;
926903

927-
if (upgradeDialog.ShowDialog(this) == DialogResult.OK)
904+
// check what user selected
905+
var results = upgradeDialog.ShowDialog(this);
906+
switch (results)
928907
{
929-
// yes, upgrade
930-
SetStatus("Upgrading project to " + Form2.currentVersion);
931-
if (launchProject == true) LaunchProject(projectPath, Form2.currentVersion);
932-
}
933-
else
934-
{
935-
// cancelled
936-
SetStatus("Cancelled project upgrade");
908+
case DialogResult.Ignore: // view release notes page
909+
OpenReleaseNotes(currentVersion);
910+
// display window again for now..
911+
DisplayUpgradeDialog(currentVersion, projectPath, launchProject);
912+
break;
913+
case DialogResult.Cancel: // cancelled
914+
SetStatus("Cancelled project upgrade");
915+
break;
916+
case DialogResult.Retry: // download and install missing version
917+
SetStatus("Download and Install missing version " + currentVersion);
918+
string url = GetUnityReleaseURL(currentVersion);
919+
if (string.IsNullOrEmpty(url) == false)
920+
{
921+
DownloadAndRun(url);
922+
}
923+
else
924+
{
925+
SetStatus("Failed getting Unity Installer URL");
926+
}
927+
break;
928+
case DialogResult.Yes: // upgrade
929+
SetStatus("Upgrading project to " + Form2.currentVersion);
930+
if (launchProject == true) LaunchProject(projectPath, Form2.currentVersion);
931+
break;
932+
default:
933+
Console.WriteLine("Unknown DialogResult: " + results);
934+
break;
937935
}
938-
939936
upgradeDialog.Close();
940937
}
941938

0 commit comments

Comments
 (0)