A game about forced loneliness, made by TACStudios
1using UnityEditor;
2using UnityEngine;
3
4using Codice.CM.Common;
5using PlasticGui;
6using PlasticGui.WorkspaceWindow;
7using PlasticGui.WorkspaceWindow.Topbar;
8using PlasticGui.WorkspaceWindow.Merge;
9using Unity.PlasticSCM.Editor.UI;
10using Unity.PlasticSCM.Editor.UI.StatusBar;
11
12namespace Unity.PlasticSCM.Editor.Developer
13{
14 internal class ShelvedChangesNotification :
15 StatusBar.IShelvedChangesNotification,
16 CheckShelvedChanges.IUpdateShelvedChangesNotification
17 {
18 internal ShelvedChangesNotification(
19 WorkspaceInfo wkInfo,
20 RepositorySpec repSpec,
21 ViewSwitcher viewSwitcher,
22 PlasticWindow plasticWindow)
23 {
24 mWkInfo = wkInfo;
25 mRepSpec = repSpec;
26 mViewSwitcher = viewSwitcher;
27 mPlasticWindow = plasticWindow;
28 }
29
30 bool StatusBar.IShelvedChangesNotification.HasNotification
31 {
32 get { return mHasNotification; }
33 }
34
35 void StatusBar.IShelvedChangesNotification.SetWorkspaceWindow(
36 WorkspaceWindow workspaceWindow)
37 {
38 mWorkspaceWindow = workspaceWindow;
39 }
40
41 void StatusBar.IShelvedChangesNotification.SetShelvedChangesUpdater(
42 IShelvedChangesUpdater shelvedChangesUpdater)
43 {
44 mShelvedChangesUpdater = shelvedChangesUpdater;
45 }
46
47 void StatusBar.IShelvedChangesNotification.OnGUI()
48 {
49 Texture2D icon = Images.GetInfoBellNotificationIcon();
50
51 StatusBar.DrawIcon(icon, UnityConstants.STATUS_BAR_ICON_SIZE - 2);
52
53 StatusBar.DrawNotification(
54 new GUIContentNotification(new GUIContent(
55 PlasticLocalization.Name.ShelvedChanges.GetString(),
56 PlasticLocalization.Name.ShelvedChangesExplanation.GetString())));
57
58 GenericMenu discardShelveDropdownMenu = new GenericMenu();
59 discardShelveDropdownMenu.AddItem(
60 new GUIContent(PlasticLocalization.Name.DiscardShelvedChanges.GetString()),
61 false,
62 () =>
63 {
64 ShelvedChangesNotificationPanelOperations.DiscardShelvedChanges(
65 mWkInfo,
66 mShelveInfo,
67 this,
68 mShelvedChangesUpdater,
69 mViewSwitcher,
70 mWorkspaceWindow);
71 });
72
73 DrawActionButtonWithMenu.For(
74 PlasticLocalization.Name.ViewButton.GetString(),
75 PlasticLocalization.Name.ViewShelvedChangesButtonExplanation.GetString(),
76 () =>
77 {
78 if (mShelveInfo == null || mViewSwitcher == null)
79 return;
80
81 ((IMergeViewLauncher)mViewSwitcher).MergeFrom(
82 mRepSpec,
83 mShelveInfo,
84 EnumMergeType.ChangesetCherryPick,
85 showDiscardChangesButton: true);
86 },
87 discardShelveDropdownMenu);
88 }
89
90 void CheckShelvedChanges.IUpdateShelvedChangesNotification.Hide(
91 WorkspaceInfo wkInfo)
92 {
93 if (!wkInfo.Equals(mWkInfo))
94 return;
95
96 mShelveInfo = null;
97
98 mHasNotification = false;
99
100 mPlasticWindow.Repaint();
101 }
102
103 void CheckShelvedChanges.IUpdateShelvedChangesNotification.Show(
104 WorkspaceInfo wkInfo,
105 RepositorySpec repSpec,
106 ChangesetInfo shelveInfo)
107 {
108 if (!wkInfo.Equals(mWkInfo))
109 return;
110
111 mShelveInfo = shelveInfo;
112
113 mHasNotification = true;
114
115 mPlasticWindow.Repaint();
116 }
117
118 bool mHasNotification;
119 ChangesetInfo mShelveInfo;
120
121 WorkspaceWindow mWorkspaceWindow;
122 IShelvedChangesUpdater mShelvedChangesUpdater;
123
124 readonly WorkspaceInfo mWkInfo;
125 readonly RepositorySpec mRepSpec;
126 readonly ViewSwitcher mViewSwitcher;
127 readonly PlasticWindow mPlasticWindow;
128 }
129}