@@ -55,7 +55,7 @@ void Start()
55
55
return ;
56
56
}
57
57
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 )
59
59
string [ ] args = Environment . GetCommandLineArgs ( ) ;
60
60
if ( args != null && args . Length > 2 )
61
61
{
@@ -67,6 +67,7 @@ void Start()
67
67
var projectPathArgument = args [ 2 ] ;
68
68
var version = GetProjectVersion ( projectPathArgument ) ;
69
69
70
+ // try launching it
70
71
LaunchProject ( projectPathArgument , version , true ) ;
71
72
72
73
SetStatus ( "Ready" ) ;
@@ -239,8 +240,7 @@ void UpdateRecentProjectsList()
239
240
//Console.WriteLine(key);
240
241
if ( key == null )
241
242
{
242
- // no recent list founded
243
- Console . WriteLine ( "No recent projects list founded" ) ;
243
+ SetStatus ( "No recent projects list founded" ) ;
244
244
return ;
245
245
}
246
246
@@ -297,7 +297,7 @@ void LaunchProject(string projectPath, string version, bool openProject = true)
297
297
var assetsFolder = Path . Combine ( projectPath , "Assets" ) ;
298
298
if ( Directory . Exists ( assetsFolder ) == false )
299
299
{
300
- // TODO could ask if want to create project
300
+ // TODO could ask if want to create project..
301
301
Directory . CreateDirectory ( assetsFolder ) ;
302
302
}
303
303
@@ -326,37 +326,8 @@ void LaunchProject(string projectPath, string version, bool openProject = true)
326
326
}
327
327
else // we dont have this version installed (or no version info available)
328
328
{
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 ) ;
360
331
}
361
332
}
362
333
else // given path doesnt exists, strange
@@ -429,7 +400,7 @@ void DownloadAndRun(string url)
429
400
else // not found
430
401
{
431
402
SetStatus ( "Error> Cannot find installer exe.. opening website instead" ) ;
432
- Process . Start ( url ) ;
403
+ Process . Start ( url + "#installer-exe-not-found" ) ;
433
404
}
434
405
}
435
406
@@ -440,7 +411,6 @@ void DownloadAndRun(string url)
440
411
/// <returns></returns>
441
412
string GetFileNameFromUrl ( string url )
442
413
{
443
- Console . WriteLine ( url ) ;
444
414
var uri = new Uri ( url ) ;
445
415
var filename = uri . Segments . Last ( ) ;
446
416
return filename ;
@@ -647,11 +617,7 @@ private void btnOpenReleasePage_Click(object sender, EventArgs e)
647
617
if ( selected > - 1 )
648
618
{
649
619
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 ) ;
655
621
}
656
622
}
657
623
@@ -802,7 +768,7 @@ private void btn_openFolder_Click(object sender, EventArgs e)
802
768
private void btnExplorePackageFolder_Click ( object sender , EventArgs e )
803
769
{
804
770
var selected = lstPackageFolders . SelectedIndex ;
805
- Console . WriteLine ( lstPackageFolders . Items [ selected ] . ToString ( ) ) ;
771
+ // Console.WriteLine(lstPackageFolders.Items[selected].ToString());
806
772
if ( selected > - 1 )
807
773
{
808
774
var path = lstPackageFolders . Items [ selected ] . ToString ( ) ;
@@ -848,14 +814,27 @@ private void btnUpgradeProject_Click(object sender, EventArgs e)
848
814
private void btnOpenLogFolder_Click ( object sender , EventArgs e )
849
815
{
850
816
var logfolder = Path . Combine ( Environment . GetFolderPath ( Environment . SpecialFolder . LocalApplicationData ) , "Unity" , "Editor" ) ;
851
- Console . WriteLine ( logfolder ) ;
817
+ // Console.WriteLine(logfolder);
852
818
if ( Directory . Exists ( logfolder ) == true )
853
819
{
854
820
LaunchExplorer ( logfolder ) ;
855
821
}
856
822
}
857
823
#endregion UI events
858
824
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
+ }
859
838
860
839
public static string FindNearestVersion ( string version , List < string > allAvailable )
861
840
{
@@ -880,13 +859,12 @@ private static string FindNearestVersionFromSimilarVersions(string version, IEnu
880
859
if ( ! stripped . ContainsKey ( comparableVersion ) )
881
860
{
882
861
stripped . Add ( comparableVersion , version ) ;
883
- //Console.WriteLine(comparableVersion + " : " + version);
884
862
}
885
863
886
864
var comparables = stripped . Keys . OrderBy ( x => x ) . ToList ( ) ;
887
865
var actualIndex = comparables . IndexOf ( comparableVersion ) ;
888
866
889
- if ( actualIndex < stripped . Count ) return stripped [ comparables [ actualIndex + 1 ] ] ;
867
+ if ( actualIndex < stripped . Count - 1 ) return stripped [ comparables [ actualIndex + 1 ] ] ;
890
868
return null ;
891
869
}
892
870
@@ -913,7 +891,6 @@ void UpgradeProject()
913
891
// you already have exact version, are you sure about upgrade?
914
892
}
915
893
}
916
-
917
894
DisplayUpgradeDialog ( currentVersion , projectPath , true ) ;
918
895
}
919
896
}
@@ -924,18 +901,38 @@ void DisplayUpgradeDialog(string currentVersion, string projectPath, bool launch
924
901
Form2 upgradeDialog = new Form2 ( ) ;
925
902
Form2 . currentVersion = currentVersion ;
926
903
927
- if ( upgradeDialog . ShowDialog ( this ) == DialogResult . OK )
904
+ // check what user selected
905
+ var results = upgradeDialog . ShowDialog ( this ) ;
906
+ switch ( results )
928
907
{
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 ;
937
935
}
938
-
939
936
upgradeDialog . Close ( ) ;
940
937
}
941
938
0 commit comments