A game about forced loneliness, made by TACStudios
at master 138 lines 4.3 kB view raw
1using System.Threading.Tasks; 2 3using UnityEditor; 4using UnityEngine; 5 6using Codice.Client.Common.EventTracking; 7using Codice.CM.Common; 8using PlasticGui; 9using Unity.PlasticSCM.Editor.UI; 10 11namespace Unity.PlasticSCM.Editor.Views 12{ 13 internal class EnableSwitchAndShelveFeature : 14 SwitchAndShelve.IEnableSwitchAndShelveFeatureDialog 15 { 16 internal EnableSwitchAndShelveFeature(RepositorySpec repSpec, EditorWindow window) 17 { 18 mRepSpec = repSpec; 19 mWindow = window; 20 } 21 22 bool SwitchAndShelve.IEnableSwitchAndShelveFeatureDialog.Show() 23 { 24 bool result = false; 25 26 GUIActionRunner.RunGUIAction(() => 27 { 28 result = EnableSwitchAndShelveFeatureDialog.Show(mRepSpec, mWindow); 29 }); 30 31 return result; 32 } 33 34 readonly EditorWindow mWindow; 35 readonly RepositorySpec mRepSpec; 36 } 37 38 internal class EnableSwitchAndShelveFeatureDialog : PlasticDialog 39 { 40 protected override Rect DefaultRect 41 { 42 get 43 { 44 var baseRect = base.DefaultRect; 45 return new Rect(baseRect.x, baseRect.y, 600, 320); 46 } 47 } 48 49 internal static bool Show(RepositorySpec repSpec, EditorWindow window) 50 { 51 EnableSwitchAndShelveFeatureDialog dialog = CreateInstance<EnableSwitchAndShelveFeatureDialog>(); 52 dialog.mRepSpec = repSpec; 53 ResponseType dialogResult = dialog.RunModal(window); 54 return dialogResult == ResponseType.Ok; 55 } 56 57 protected override string GetTitle() 58 { 59 return PlasticLocalization.Name.EnableSwitchAndShelveTitle.GetString(); 60 } 61 62 protected override void OnModalGUI() 63 { 64 Title(PlasticLocalization.Name.EnableSwitchAndShelveTitle.GetString()); 65 66 Paragraph(PlasticLocalization.Name.EnableSwitchAndShelveMessage.GetString()); 67 68 using (new EditorGUILayout.HorizontalScope()) 69 { 70 EditorGUILayout.Space(20); 71 using (new EditorGUILayout.VerticalScope()) 72 { 73 Paragraph(string.Concat( 74 PlasticLocalization.Name.EnableSwitchAndShelveLeaveChangesTitle.GetString(), "\n", 75 PlasticLocalization.Name.EnableSwitchAndShelveLeaveChangesDescription.GetString())); 76 77 Paragraph(string.Concat( 78 PlasticLocalization.Name.EnableSwitchAndShelveBringChangesTitle.GetString(), "\n", 79 PlasticLocalization.Name.EnableSwitchAndShelveBringChangesDescription.GetString())); 80 } 81 82 GUILayout.FlexibleSpace(); 83 } 84 85 Paragraph(string.Concat( 86 PlasticLocalization.Name.EnableSwitchAndShelveQuestionStart.GetString(), "\n", 87 PlasticLocalization.Name.EnableSwitchAndShelveQuestionEnd.GetString())); 88 89 GUILayout.Space(20); 90 91 DoButtonsArea(); 92 } 93 94 void DoButtonsArea() 95 { 96 using (new EditorGUILayout.HorizontalScope()) 97 { 98 GUILayout.FlexibleSpace(); 99 100 if (Application.platform == RuntimePlatform.WindowsEditor) 101 { 102 DoYesButton(); 103 DoNoButton(); 104 return; 105 } 106 107 DoNoButton(); 108 DoYesButton(); 109 } 110 } 111 112 void DoYesButton() 113 { 114 if (!NormalButton(PlasticLocalization.Name.EnableSwitchAndShelveYesEnableItLowerCase.GetString())) 115 return; 116 117 TrackFeatureUseEvent.For( 118 mRepSpec, 119 TrackFeatureUseEvent.Features.SwitchAndShelve.EnableFeatureYes); 120 121 OkButtonAction(); 122 } 123 124 void DoNoButton() 125 { 126 if (!NormalButton(PlasticLocalization.Name.EnableSwitchAndShelveNotNow.GetString())) 127 return; 128 129 TrackFeatureUseEvent.For( 130 mRepSpec, 131 TrackFeatureUseEvent.Features.SwitchAndShelve.EnableFeatureNo); 132 133 CancelButtonAction(); 134 } 135 136 RepositorySpec mRepSpec; 137 } 138}