@@ -11,52 +11,16 @@ namespace GitHub.Unity
11
11
[ Serializable ]
12
12
class SettingsView : Subview
13
13
{
14
- private const string EditorSettingsMissingTitle = "Missing editor settings" ;
15
- private const string EditorSettingsMissingMessage =
16
- "No valid editor settings found when looking in expected path '{0}'. Please save the project." ;
17
- private const string BadVCSSettingsTitle = "Update settings" ;
18
- private const string BadVCSSettingsMessage =
19
- "To use Git, you will need to set project Version Control Mode to either 'Visible Meta Files' or 'Hidden Meta Files'." ;
20
- private const string SelectEditorSettingsButton = "View settings" ;
21
- private const string NoActiveRepositoryTitle = "No repository found" ;
22
- private const string NoActiveRepositoryMessage = "Your current project is not currently in an active Git repository:" ;
23
- private const string TextSerialisationMessage =
24
- "For optimal Git use, it is recommended that you configure Unity to serialize assets using text serialization. Note that this may cause editor slowdowns for projects with very large datasets." ;
25
- private const string BinarySerialisationMessage = "This project is currently configured for binary serialization." ;
26
- private const string MixedSerialisationMessage = "This project is currently configured for mixed serialization." ;
27
- private const string IgnoreSerialisationIssuesSetting = "IgnoreSerializationIssues" ;
28
- private const string IgnoreSerialisationSettingsButton = "Ignore forever" ;
29
- private const string RefreshIssuesButton = "Refresh" ;
30
- private const string GitIgnoreExceptionWarning = "Exception when searching .gitignore files: {0}" ;
31
- private const string GitIgnoreIssueWarning = "{0}: {2}\n \n In line \" {1}\" " ;
32
- private const string GitIgnoreIssueNoLineWarning = "{0}: {1}" ;
33
- private const string GitInitBrowseTitle = "Pick desired repository root" ;
34
- private const string GitInitButton = "Set up Git" ;
35
- private const string InvalidInitDirectoryTitle = "Invalid repository root" ;
36
- private const string InvalidInitDirectoryMessage =
37
- "Your selected folder '{0}' is not a valid repository root for your current project." ;
38
- private const string InvalidInitDirectoryOK = "OK" ;
39
14
private const string GitInstallTitle = "Git installation" ;
40
- private const string GitInstallMissingMessage =
41
- "GitHub was unable to locate a valid Git install. Please specify install location or install git." ;
42
15
private const string GitInstallBrowseTitle = "Select git binary" ;
43
16
private const string GitInstallPickInvalidTitle = "Invalid Git install" ;
44
17
private const string GitInstallPickInvalidMessage = "The selected file is not a valid Git install. {0}" ;
45
18
private const string GitInstallPickInvalidOK = "OK" ;
46
19
private const string GitInstallFindButton = "Find install" ;
47
- private const string GitInstallURL = "http://desktop.github.com" ;
48
- private const string GitIgnoreRulesTitle = "gitignore rules" ;
49
- private const string GitIgnoreRulesEffect = "Effect" ;
50
- private const string GitIgnoreRulesFile = "File" ;
51
- private const string GitIgnoreRulesLine = "Line" ;
52
- private const string GitIgnoreRulesDescription = "Description" ;
53
- private const string NewGitIgnoreRuleButton = "New" ;
54
- private const string DeleteGitIgnoreRuleButton = "Delete" ;
55
20
private const string GitConfigTitle = "Git Configuration" ;
56
21
private const string GitConfigNameLabel = "Name" ;
57
22
private const string GitConfigEmailLabel = "Email" ;
58
23
private const string GitConfigUserSave = "Save User" ;
59
- private const string GitConfigUserSaved = "Saved" ;
60
24
private const string GitRepositoryTitle = "Repository Configuration" ;
61
25
private const string GitRepositoryRemoteLabel = "Remote" ;
62
26
private const string GitRepositorySave = "Save Repository" ;
@@ -240,14 +204,6 @@ private void MaybeUpdateData()
240
204
}
241
205
}
242
206
243
- private void ResetToDefaults ( )
244
- {
245
- gitName = Repository != null ? Repository . User . Name : String . Empty ;
246
- gitEmail = Repository != null ? Repository . User . Email : String . Empty ;
247
- repositoryRemoteName = DefaultRepositoryRemoteName ;
248
- repositoryRemoteUrl = string . Empty ;
249
- }
250
-
251
207
private void Repository_OnActiveRemoteChanged ( string remote )
252
208
{
253
209
remoteHasChanged = true ;
@@ -385,237 +341,6 @@ private bool ValidateGitInstall(string path)
385
341
return true ;
386
342
}
387
343
388
- private bool OnIssuesGUI ( )
389
- {
390
- IList < ProjectConfigurationIssue > projectConfigurationIssues ;
391
- if ( Utility . Issues != null )
392
- {
393
- projectConfigurationIssues = Utility . Issues ;
394
- }
395
- else
396
- {
397
- projectConfigurationIssues = new ProjectConfigurationIssue [ 0 ] ;
398
- }
399
-
400
- var settingsIssues = projectConfigurationIssues . Select ( i => i as ProjectSettingsIssue ) . FirstOrDefault ( i => i != null ) ;
401
-
402
- if ( settingsIssues != null )
403
- {
404
- if ( settingsIssues . WasCaught ( ProjectSettingsEvaluation . EditorSettingsMissing ) )
405
- {
406
- Styles . BeginInitialStateArea ( EditorSettingsMissingTitle ,
407
- String . Format ( EditorSettingsMissingMessage , EvaluateProjectConfigurationTask . EditorSettingsPath ) ) ;
408
- Styles . EndInitialStateArea ( ) ;
409
-
410
- return false ;
411
- }
412
- else if ( settingsIssues . WasCaught ( ProjectSettingsEvaluation . BadVCSSettings ) )
413
- {
414
- Styles . BeginInitialStateArea ( BadVCSSettingsTitle , BadVCSSettingsMessage ) ;
415
- {
416
- GUILayout . Space ( EditorGUIUtility . standardVerticalSpacing ) ;
417
-
418
- // Button to select editor settings - for remedying the bad setting
419
- if ( Styles . InitialStateActionButton ( SelectEditorSettingsButton ) )
420
- {
421
- Selection . activeObject = EvaluateProjectConfigurationTask . LoadEditorSettings ( ) ;
422
- }
423
- }
424
- Styles . EndInitialStateArea ( ) ;
425
-
426
- return false ;
427
- }
428
- }
429
-
430
- if ( ! Utility . GitFound )
431
- {
432
- Styles . BeginInitialStateArea ( GitInstallTitle , GitInstallMissingMessage ) ;
433
- {
434
- OnInstallPathGUI ( ) ;
435
- }
436
- Styles . EndInitialStateArea ( ) ;
437
-
438
- return false ;
439
- }
440
- else if ( ! Utility . ActiveRepository )
441
- {
442
- Styles . BeginInitialStateArea ( NoActiveRepositoryTitle , NoActiveRepositoryMessage ) ;
443
- {
444
- // Init directory path field
445
- Styles . PathField ( ref initDirectory , ( ) => EditorUtility . OpenFolderPanel ( GitInitBrowseTitle , initDirectory , "" ) ,
446
- ValidateInitDirectory ) ;
447
-
448
- GUILayout . Space ( EditorGUIUtility . standardVerticalSpacing ) ;
449
-
450
- // Git init, which starts the config flow
451
- if ( Styles . InitialStateActionButton ( GitInitButton ) )
452
- {
453
- if ( ValidateInitDirectory ( initDirectory ) )
454
- {
455
- Init ( ) ;
456
- }
457
- else
458
- {
459
- ResetInitDirectory ( ) ;
460
- }
461
- }
462
- }
463
- Styles . EndInitialStateArea ( ) ;
464
-
465
- return false ;
466
- }
467
-
468
- if ( settingsIssues != null && ! Manager . LocalSettings . Get ( IgnoreSerialisationIssuesSetting , "0" ) . Equals ( "1" ) )
469
- {
470
- var binary = settingsIssues . WasCaught ( ProjectSettingsEvaluation . BinarySerialization ) ;
471
- var mixed = settingsIssues . WasCaught ( ProjectSettingsEvaluation . MixedSerialization ) ;
472
-
473
- if ( binary || mixed )
474
- {
475
- GUILayout . Label ( TextSerialisationMessage , Styles . LongMessageStyle ) ;
476
- Styles . Warning ( binary ? BinarySerialisationMessage : MixedSerialisationMessage ) ;
477
-
478
- GUILayout . BeginHorizontal ( ) ;
479
- {
480
- if ( GUILayout . Button ( IgnoreSerialisationSettingsButton ) )
481
- {
482
- Manager . LocalSettings . Set ( IgnoreSerialisationIssuesSetting , "1" ) ;
483
- }
484
-
485
- GUILayout . FlexibleSpace ( ) ;
486
-
487
- if ( GUILayout . Button ( RefreshIssuesButton ) )
488
- {
489
- // TODO: Fix this
490
- }
491
-
492
- if ( GUILayout . Button ( SelectEditorSettingsButton ) )
493
- {
494
- Selection . activeObject = EvaluateProjectConfigurationTask . LoadEditorSettings ( ) ;
495
- }
496
- }
497
- GUILayout . EndHorizontal ( ) ;
498
- }
499
- }
500
-
501
- var gitIgnoreException = projectConfigurationIssues . Select ( i => i as GitIgnoreException ) . FirstOrDefault ( i => i != null ) ;
502
- if ( gitIgnoreException != null )
503
- {
504
- Styles . Warning ( String . Format ( GitIgnoreExceptionWarning , gitIgnoreException . Exception ) ) ;
505
- }
506
-
507
- foreach ( var issue in projectConfigurationIssues . Select ( i => i as GitIgnoreIssue ) . Where ( i => i != null ) )
508
- {
509
- if ( string . IsNullOrEmpty ( issue . Line ) )
510
- {
511
- Styles . Warning ( String . Format ( GitIgnoreIssueNoLineWarning , issue . File , issue . Description ) ) ;
512
- }
513
- else
514
- {
515
- Styles . Warning ( String . Format ( GitIgnoreIssueWarning , issue . File , issue . Line , issue . Description ) ) ;
516
- }
517
- }
518
-
519
- return true ;
520
- }
521
-
522
- private void OnGitIgnoreRulesGUI ( )
523
- {
524
- var gitignoreRulesWith = Position . width - Styles . GitIgnoreRulesTotalHorizontalMargin - Styles . GitIgnoreRulesSelectorWidth - 16f ;
525
- var effectWidth = gitignoreRulesWith * Styles . GitIgnoreRulesEffectRatio ;
526
- var fileWidth = gitignoreRulesWith * Styles . GitIgnoreRulesFileRatio ;
527
- var lineWidth = gitignoreRulesWith * Styles . GitIgnoreRulesLineRatio ;
528
-
529
- GUILayout . Label ( GitIgnoreRulesTitle , EditorStyles . boldLabel ) ;
530
- GUILayout . BeginVertical ( GUI . skin . box ) ;
531
- GUILayout . BeginHorizontal ( EditorStyles . toolbar ) ;
532
- {
533
- GUILayout . Space ( Styles . GitIgnoreRulesSelectorWidth ) ;
534
- TableCell ( GitIgnoreRulesEffect , effectWidth ) ;
535
- TableCell ( GitIgnoreRulesFile , fileWidth ) ;
536
- TableCell ( GitIgnoreRulesLine , lineWidth ) ;
537
- }
538
- GUILayout . EndHorizontal ( ) ;
539
-
540
- var count = GitIgnoreRule . Count ;
541
- for ( var index = 0 ; index < count ; ++ index )
542
- {
543
- GitIgnoreRule rule ;
544
- if ( GitIgnoreRule . TryLoad ( index , out rule ) )
545
- {
546
- GUILayout . BeginHorizontal ( ) ;
547
- {
548
- GUILayout . Space ( Styles . GitIgnoreRulesSelectorWidth ) ;
549
-
550
- if ( gitIgnoreRulesSelection == index && Event . current . type == EventType . Repaint )
551
- {
552
- var selectorRect = GUILayoutUtility . GetLastRect ( ) ;
553
- selectorRect . Set ( selectorRect . x , selectorRect . y + 2f , selectorRect . width - 2f , EditorGUIUtility . singleLineHeight ) ;
554
- EditorStyles . foldout . Draw ( selectorRect , false , false , false , false ) ;
555
- }
556
-
557
- TableCell ( rule . Effect . ToString ( ) , effectWidth ) ;
558
- // TODO: Tint if the regex is null
559
- TableCell ( rule . FileString , fileWidth ) ;
560
- TableCell ( rule . LineString , lineWidth ) ;
561
- }
562
- GUILayout . EndHorizontal ( ) ;
563
-
564
- if ( Event . current . type == EventType . MouseDown && GUILayoutUtility . GetLastRect ( ) . Contains ( Event . current . mousePosition ) )
565
- {
566
- newGitIgnoreRulesSelection = index ;
567
- Event . current . Use ( ) ;
568
- }
569
- }
570
- }
571
-
572
- GUILayout . BeginHorizontal ( ) ;
573
- {
574
- GUILayout . FlexibleSpace ( ) ;
575
- if ( GUILayout . Button ( NewGitIgnoreRuleButton , EditorStyles . miniButton ) )
576
- {
577
- GitIgnoreRule . New ( ) ;
578
- GUIUtility . hotControl = GUIUtility . keyboardControl = - 1 ;
579
- }
580
- }
581
- GUILayout . EndHorizontal ( ) ;
582
-
583
- GUILayout . Space ( EditorGUIUtility . standardVerticalSpacing ) ;
584
-
585
- // Selected gitignore rule edit
586
-
587
- GitIgnoreRule selectedRule ;
588
- if ( GitIgnoreRule . TryLoad ( gitIgnoreRulesSelection , out selectedRule ) )
589
- {
590
- GUILayout . BeginVertical ( GUI . skin . box ) ;
591
- {
592
- GUILayout . BeginHorizontal ( ) ;
593
- {
594
- GUILayout . FlexibleSpace ( ) ;
595
- if ( GUILayout . Button ( DeleteGitIgnoreRuleButton , EditorStyles . miniButton ) )
596
- {
597
- GitIgnoreRule . Delete ( gitIgnoreRulesSelection ) ;
598
- newGitIgnoreRulesSelection = gitIgnoreRulesSelection - 1 ;
599
- }
600
- }
601
- GUILayout . EndHorizontal ( ) ;
602
- EditorGUI . BeginChangeCheck ( ) ;
603
- var newEffect = ( GitIgnoreRuleEffect ) EditorGUILayout . EnumPopup ( GitIgnoreRulesEffect , selectedRule . Effect ) ;
604
- var newFile = EditorGUILayout . TextField ( GitIgnoreRulesFile , selectedRule . FileString ) ;
605
- var newLine = EditorGUILayout . TextField ( GitIgnoreRulesLine , selectedRule . LineString ) ;
606
- GUILayout . Label ( GitIgnoreRulesDescription ) ;
607
- var newDescription = EditorGUILayout . TextArea ( selectedRule . TriggerText , Styles . CommitDescriptionFieldStyle ) ;
608
- if ( EditorGUI . EndChangeCheck ( ) )
609
- {
610
- GitIgnoreRule . Save ( gitIgnoreRulesSelection , newEffect , newFile , newLine , newDescription ) ;
611
- // TODO: Fix this
612
- }
613
- }
614
- GUILayout . EndVertical ( ) ;
615
- }
616
- GUILayout . EndVertical ( ) ;
617
- }
618
-
619
344
private void OnGitLfsLocksGUI ( )
620
345
{
621
346
EditorGUI . BeginDisabledGroup ( isBusy || Repository == null ) ;
@@ -792,44 +517,5 @@ private void OnLoggingSettingsGui()
792
517
}
793
518
EditorGUI . EndDisabledGroup ( ) ;
794
519
}
795
-
796
- private void ResetInitDirectory ( )
797
- {
798
- initDirectory = Utility . UnityProjectPath ;
799
- GUIUtility . keyboardControl = GUIUtility . hotControl = 0 ;
800
- }
801
-
802
- private void ForceUnlockFile ( object obj )
803
- {
804
- var fileName = obj ;
805
-
806
- EditorUtility . DisplayDialog ( "Force unlock file?" ,
807
- "Are you sure you want to force unlock " + fileName + "? "
808
- + "This will notify the owner of the lock." ,
809
- "Unlock" ,
810
- "Cancel" ) ;
811
- }
812
-
813
- private void Init ( )
814
- {
815
- //Logger.Debug("TODO: Init '{0}'", initDirectory);
816
- }
817
-
818
- private static void TableCell ( string label , float width )
819
- {
820
- GUILayout . Label ( label , EditorStyles . miniLabel , GUILayout . Width ( width ) , GUILayout . MaxWidth ( width ) ) ;
821
- }
822
-
823
- private static bool ValidateInitDirectory ( string path )
824
- {
825
- if ( Utility . UnityProjectPath . IndexOf ( path ) != 0 )
826
- {
827
- EditorUtility . DisplayDialog ( InvalidInitDirectoryTitle , String . Format ( InvalidInitDirectoryMessage , path ) ,
828
- InvalidInitDirectoryOK ) ;
829
- return false ;
830
- }
831
-
832
- return true ;
833
- }
834
520
}
835
521
}
0 commit comments