A game about forced loneliness, made by TACStudios
at master 116 lines 3.6 kB view raw
1using System; 2using System.Collections.Generic; 3 4using Codice.Client.Common; 5using PlasticGui; 6using Unity.PlasticSCM.Editor.UI; 7using Unity.PlasticSCM.Editor.UI.StatusBar; 8 9using UnityEngine; 10 11namespace Unity.PlasticSCM.Editor.Views.PendingChanges 12{ 13 internal class PendingChangesStatusSuccessNotificationContent : INotificationContent 14 { 15 internal PendingChangesStatusSuccessNotificationContent( 16 CreatedChangesetData data, 17 Action openLink, 18 Action copyLink) 19 { 20 mCreatedChangesetData = data; 21 mOpenLinkAction = openLink; 22 mCopyAction = copyLink; 23 } 24 25 void INotificationContent.OnGUI() 26 { 27 if (mCreatedChangesetData.OperationType == CreatedChangesetData.Type.Checkin) 28 { 29 DrawCheckinSuccessMessage( 30 mCreatedChangesetData.CreatedChangesetId, 31 mOpenLinkAction, 32 mCopyAction); 33 return; 34 } 35 36 DrawShelveSuccessMessage( 37 mCreatedChangesetData.CreatedChangesetId, 38 mOpenLinkAction, 39 mCopyAction); 40 } 41 42 static void DrawCheckinSuccessMessage( 43 long changesetId, 44 Action openChangesetLink, 45 Action copyChangesetLink) 46 { 47 string text = string.Concat( 48 PlasticLocalization.Name.CheckinCompleted.GetString(), 49 " ", 50 "{0} " + PlasticLocalization.Name.CheckinChangesetWasCreatedPart.GetString()); 51 52 string linkText = 53 string.Format("{0} {1}", 54 PlasticLocalization.Name.Changeset.GetString(), 55 changesetId.ToString()); 56 57 DrawCreatedChangesetMessage( 58 text, 59 linkText, 60 openChangesetLink, 61 copyChangesetLink); 62 } 63 64 static void DrawShelveSuccessMessage( 65 long shelvesetId, 66 Action openShelveLink, 67 Action copyShelveLink) 68 { 69 string text = PlasticLocalization.Name.ShelveCreatedMessage.GetString() + "."; 70 string linkText = string.Format("{0} {1}", 71 PlasticLocalization.Name.Shelve.GetString().ToLower(), 72 Math.Abs(shelvesetId).ToString()); 73 74 DrawCreatedChangesetMessage( 75 text, 76 linkText, 77 openShelveLink, 78 copyShelveLink); 79 } 80 81 static void DrawCreatedChangesetMessage( 82 string text, 83 string linkText, 84 Action openLink, 85 Action copyLink) 86 { 87 GUILayout.BeginHorizontal(); 88 89 GUILayout.Space(2); 90 91 DrawTextBlockWithLink.ForMultiLinkLabel( 92 new MultiLinkLabelData( 93 text, 94 new List<string> { linkText }, 95 new List<Action> { openLink }), 96 UnityStyles.StatusBar.NotificationLabel); 97 98 GUILayout.Space(4); 99 100 if (GUILayout.Button( 101 new GUIContent( 102 Images.GetClipboardIcon(), 103 PlasticLocalization.Name.DiffLinkButtonTooltip.GetString()), 104 UnityStyles.StatusBar.CopyToClipboardButton)) 105 { 106 copyLink(); 107 } 108 109 GUILayout.EndHorizontal(); 110 } 111 112 readonly CreatedChangesetData mCreatedChangesetData; 113 readonly Action mOpenLinkAction; 114 readonly Action mCopyAction; 115 } 116}