A game about forced loneliness, made by TACStudios
at master 3.1 kB view raw
1using Codice.Client.Common; 2using PlasticGui; 3using Unity.PlasticSCM.Editor.Settings; 4 5namespace Unity.PlasticSCM.Editor.Views 6{ 7 internal class SelectNewCodeReviewBehavior 8 { 9 internal static NewCodeReviewBehavior For(string repServer) 10 { 11 if (PlasticGui.Plastic.API.IsCloud(repServer)) 12 return AskUserIfNeeded(); 13 14 return NewCodeReviewBehavior.CreateAndOpenInDesktop; 15 } 16 17 static NewCodeReviewBehavior AskUserIfNeeded() 18 { 19 NewCodeReviewBehavior choice = LoadPreferences(); 20 if (choice != NewCodeReviewBehavior.Ask) 21 return choice; 22 23 return AskUserForNewCodeReviewBehavior(); 24 } 25 26 static NewCodeReviewBehavior AskUserForNewCodeReviewBehavior() 27 { 28 MultiLinkLabelData dontAksMeAgainContent = 29 new MultiLinkLabelData( 30 PlasticLocalization.Name.DontAskMeAgainWithAction.GetString(), 31 PlasticLocalization.Name.OtherOptions.GetString(), 32 OpenPlasticProjectSettings.InOtherFoldout 33 ); 34 35 bool dontAskMeAgain; 36 GuiMessage.GuiMessageResponseButton response 37 = GuiMessage.Get().ShowQuestionWithCheckBox( 38 PlasticLocalization.Name.SelectNewCodeReviewBehaviorTitle.GetString(), 39 PlasticLocalization.Name.SelectNewCodeReviewBehaviorExplanation.GetString(), 40 PlasticLocalization.Name.OpenInDesktopApp.GetString(), 41 PlasticLocalization.Name.CancelButton.GetString(), 42 PlasticLocalization.Name.OpenInUnityCloud.GetString(), 43 dontAksMeAgainContent, 44 out dontAskMeAgain 45 ); 46 47 NewCodeReviewBehavior choice = GetNewCodeReviewBehavior(response); 48 49 if (dontAskMeAgain && choice != NewCodeReviewBehavior.Ask) 50 SavePreference(choice); 51 52 return choice; 53 } 54 55 static NewCodeReviewBehavior LoadPreferences() 56 { 57 return PlasticGuiConfig.Get().Configuration.NewCodeReviewBehavior; 58 } 59 60 static void SavePreference(NewCodeReviewBehavior choice) 61 { 62 PlasticGuiConfig plasticGuiConfig = PlasticGuiConfig.Get(); 63 plasticGuiConfig.Configuration.NewCodeReviewBehavior = choice; 64 plasticGuiConfig.Save(); 65 } 66 67 static NewCodeReviewBehavior GetNewCodeReviewBehavior( 68 GuiMessage.GuiMessageResponseButton response) 69 { 70 switch (response) 71 { 72 case GuiMessage.GuiMessageResponseButton.Positive: 73 return NewCodeReviewBehavior.CreateAndOpenInDesktop; 74 case GuiMessage.GuiMessageResponseButton.Negative: 75 return NewCodeReviewBehavior.RequestFromUnityCloud; 76 case GuiMessage.GuiMessageResponseButton.Neutral: 77 default: 78 return NewCodeReviewBehavior.Ask; 79 } 80 } 81 } 82}