forked from MattRix/UnityDecompiled
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWindowRevert.cs
More file actions
103 lines (103 loc) · 3.04 KB
/
Copy pathWindowRevert.cs
File metadata and controls
103 lines (103 loc) · 3.04 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
using System;
using UnityEditorInternal.VersionControl;
using UnityEngine;
namespace UnityEditor.VersionControl
{
internal class WindowRevert : EditorWindow
{
private ListControl revertList = new ListControl();
private AssetList assetList = new AssetList();
public void OnEnable()
{
base.position = new Rect(100f, 100f, 700f, 230f);
base.minSize = new Vector2(700f, 230f);
this.revertList.ReadOnly = true;
}
public static void Open(ChangeSet change)
{
Task task = Provider.ChangeSetStatus(change);
task.Wait();
WindowRevert.GetWindow().DoOpen(task.assetList);
}
public static void Open(AssetList assets)
{
Task task = Provider.Status(assets);
task.Wait();
AssetList revert = task.assetList.Filter(true, new Asset.States[]
{
Asset.States.CheckedOutLocal,
Asset.States.DeletedLocal,
Asset.States.AddedLocal,
Asset.States.Missing
});
WindowRevert.GetWindow().DoOpen(revert);
}
private static WindowRevert GetWindow()
{
return EditorWindow.GetWindow<WindowRevert>(true, "Version Control Revert");
}
private void DoOpen(AssetList revert)
{
this.assetList = revert;
this.RefreshList();
}
private void RefreshList()
{
this.revertList.Clear();
foreach (Asset current in this.assetList)
{
this.revertList.Add(null, current.prettyPath, current);
}
if (this.assetList.Count == 0)
{
ChangeSet changeSet = new ChangeSet("no files to revert");
ListItem listItem = this.revertList.Add(null, changeSet.description, changeSet);
listItem.Dummy = true;
}
this.revertList.Refresh();
base.Repaint();
}
private void OnGUI()
{
GUILayout.Label("Revert Files", EditorStyles.boldLabel, new GUILayoutOption[0]);
GUILayout.FlexibleSpace();
Rect screenRect = new Rect(6f, 40f, base.position.width - 12f, base.position.height - 82f);
GUILayout.BeginArea(screenRect);
GUILayout.Box(string.Empty, new GUILayoutOption[]
{
GUILayout.ExpandWidth(true),
GUILayout.ExpandHeight(true)
});
GUILayout.EndArea();
this.revertList.OnGUI(new Rect(screenRect.x + 2f, screenRect.y + 2f, screenRect.width - 4f, screenRect.height - 4f), true);
GUILayout.FlexibleSpace();
GUILayout.BeginHorizontal(new GUILayoutOption[0]);
GUILayout.FlexibleSpace();
if (GUILayout.Button("Cancel", new GUILayoutOption[0]))
{
base.Close();
}
if (this.assetList.Count > 0 && GUILayout.Button("Revert", new GUILayoutOption[0]))
{
foreach (Asset current in this.assetList)
{
if (current.path == EditorApplication.currentScene)
{
if (!EditorUtility.DisplayDialog("Revert open scene?", "You are about to revert your currently open scene:\n\n" + EditorApplication.currentScene + "\n\nContinuing will remove all unsaved changes.", "Continue", "Cancel"))
{
base.Close();
return;
}
break;
}
}
Provider.Revert(this.assetList, RevertMode.Normal).Wait();
WindowPending.UpdateAllWindows();
AssetDatabase.Refresh();
base.Close();
}
GUILayout.EndHorizontal();
GUILayout.Space(12f);
}
}
}