DrawSceneOperations.cs
3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
using System.Collections.Generic;
using UnityEngine;
using UnityEditor.VersionControl;
using UnityEditor;
using Codice.Client.Common;
using GluonGui;
using PlasticGui;
using PlasticGui.WorkspaceWindow;
using PlasticGui.WorkspaceWindow.Items;
using Unity.PlasticSCM.Editor.AssetUtils;
using Unity.PlasticSCM.Editor.UI;
using Unity.PlasticSCM.Editor.AssetMenu;
using GluonCheckoutOperation = GluonGui.WorkspaceWindow.Views.WorkspaceExplorer.Explorer.Operations.CheckoutOperation;
namespace Unity.PlasticSCM.Editor.SceneView
{
static class DrawSceneOperations
{
internal static void Enable()
{
if (sIsEnabled)
return;
sIsEnabled = true;
Provider.preCheckoutCallback += Provider_preCheckoutCallback;
}
internal static void Disable()
{
sIsEnabled = false;
Provider.preCheckoutCallback -= Provider_preCheckoutCallback;
}
internal static void Initialize(
WorkspaceWindow workspaceWindow,
ViewHost viewHost,
NewIncomingChangesUpdater incomingChangesUpdater,
bool isGluonMode)
{
if (!sIsEnabled)
Enable();
sWorkspaceWindow = workspaceWindow;
sViewHost = viewHost;
sNewIncomingChangesUpdater = incomingChangesUpdater;
sIsGluonMode = isGluonMode;
sGuiMessage = new UnityPlasticGuiMessage();
sProgressControls = new EditorProgressControls(sGuiMessage);
}
static bool Provider_preCheckoutCallback(
AssetList list,
ref string changesetID,
ref string changesetDescription)
{
if (!sIsEnabled)
return true;
if (!FindWorkspace.HasWorkspace(Application.dataPath))
{
Disable();
return true;
}
if (sWorkspaceWindow == null)
EditorWindow.GetWindow<PlasticWindow>();
List<string> selectedPaths = GetSelectedPaths.ForOperation(
list,
PlasticPlugin.AssetStatusCache,
AssetMenuOperations.Checkout);
if (sIsGluonMode)
{
GluonCheckoutOperation.Checkout(
sViewHost,
sProgressControls,
sGuiMessage,
selectedPaths.ToArray(),
false,
RefreshAsset.VersionControlCache);
return true;
}
CheckoutOperation.Checkout(
sWorkspaceWindow,
null,
sProgressControls,
selectedPaths,
sNewIncomingChangesUpdater,
RefreshAsset.VersionControlCache);
return true;
}
static bool sIsEnabled;
static bool sIsGluonMode;
static ViewHost sViewHost;
static GuiMessage.IGuiMessage sGuiMessage;
static EditorProgressControls sProgressControls;
static IWorkspaceWindow sWorkspaceWindow;
static NewIncomingChangesUpdater sNewIncomingChangesUpdater;
}
}