forked from hunterzonewu/unity-decompiled
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathASConfigWindow.cs
More file actions
338 lines (325 loc) · 13.1 KB
/
ASConfigWindow.cs
File metadata and controls
338 lines (325 loc) · 13.1 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
// Decompiled with JetBrains decompiler
// Type: UnityEditor.ASConfigWindow
// Assembly: UnityEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 01B28312-B6F5-4E06-90F6-BE297B711E41
// Assembly location: C:\Users\Blake\sandbox\unity\test-project\Library\UnityAssemblies\UnityEditor.dll
using System;
using System.Collections.Generic;
using UnityEditorInternal;
using UnityEngine;
namespace UnityEditor
{
[Serializable]
internal class ASConfigWindow
{
private ListViewState serversLv = new ListViewState(0);
private ListViewState projectsLv = new ListViewState(0);
private string serverAddress = string.Empty;
private string projectName = string.Empty;
private string userName = string.Empty;
private string password = string.Empty;
private string port = string.Empty;
private const int listLenghts = 20;
private static ASMainWindow.Constants constants;
private bool resetKeyboardControl;
private string[] projectsList;
private string[] serversList;
private PListConfig plc;
private ASMainWindow parentWin;
public ASConfigWindow(ASMainWindow parent)
{
this.parentWin = parent;
this.LoadConfig();
}
private void LoadConfig()
{
PListConfig plistConfig = new PListConfig("Library/ServerPreferences.plist");
this.serverAddress = plistConfig["Maint Server"];
this.userName = plistConfig["Maint UserName"];
this.port = plistConfig["Maint port number"];
this.projectName = plistConfig["Maint project name"];
this.password = ASEditorBackend.GetPassword(this.serverAddress, this.userName);
if (this.port != string.Empty && this.port != 10733.ToString())
{
ASConfigWindow asConfigWindow = this;
string str = asConfigWindow.serverAddress + ":" + this.port;
asConfigWindow.serverAddress = str;
}
this.serversList = InternalEditorUtility.GetEditorSettingsList("ASServer", 20);
this.serversLv.totalRows = this.serversList.Length;
if (!ArrayUtility.Contains<string>(this.serversList, this.serverAddress))
return;
this.serversLv.row = ArrayUtility.IndexOf<string>(this.serversList, this.serverAddress);
}
private void GetUserAndPassword()
{
string user = ASEditorBackend.GetUser(this.serverAddress);
if (user != string.Empty)
this.userName = user;
string password = ASEditorBackend.GetPassword(this.serverAddress, user);
if (!(password != string.Empty))
return;
this.password = password;
}
private void GetDefaultPListConfig()
{
this.plc = new PListConfig("Library/ServerPreferences.plist");
this.plc["Maint Server"] = string.Empty;
this.plc["Maint UserName"] = string.Empty;
this.plc["Maint database name"] = string.Empty;
this.plc["Maint port number"] = string.Empty;
this.plc["Maint project name"] = string.Empty;
this.plc["Maint Password"] = string.Empty;
if (this.plc["Maint settings type"] == string.Empty)
this.plc["Maint settings type"] = "manual";
if (this.plc["Maint Timeout"] == string.Empty)
this.plc["Maint Timeout"] = "5";
if (!(this.plc["Maint Connection Settings"] == string.Empty))
return;
this.plc["Maint Connection Settings"] = string.Empty;
}
private void DoShowProjects()
{
int result = 10733;
string server = this.serverAddress;
if (server.IndexOf(":") > 0)
{
int.TryParse(server.Substring(server.IndexOf(":") + 1), out result);
server = server.Substring(0, server.IndexOf(":"));
}
AssetServer.AdminSetCredentials(server, result, this.userName, this.password);
MaintDatabaseRecord[] maintDatabaseRecordArray = AssetServer.AdminRefreshDatabases();
if (maintDatabaseRecordArray != null)
{
this.projectsList = new string[maintDatabaseRecordArray.Length];
for (int index = 0; index < maintDatabaseRecordArray.Length; ++index)
this.projectsList[index] = maintDatabaseRecordArray[index].name;
this.projectsLv.totalRows = maintDatabaseRecordArray.Length;
this.GetDefaultPListConfig();
this.plc["Maint Server"] = server;
this.plc["Maint UserName"] = this.userName;
this.plc["Maint port number"] = this.port;
this.plc.Save();
ASEditorBackend.SetPassword(server, this.userName, this.password);
ASEditorBackend.AddUser(this.serverAddress, this.userName);
}
else
this.projectsLv.totalRows = 0;
}
private void ClearConfig()
{
if (!EditorUtility.DisplayDialog("Clear Configuration", "Are you sure you want to disconnect from Asset Server project and clear all configuration values?", "Clear", "Cancel"))
return;
this.plc = new PListConfig("Library/ServerPreferences.plist");
this.plc.Clear();
this.plc.Save();
this.LoadConfig();
this.projectsLv.totalRows = 0;
ASEditorBackend.InitializeMaintBinding();
this.resetKeyboardControl = true;
}
private void DoConnect()
{
AssetServer.RemoveMaintErrorsFromConsole();
int result = 10733;
string server = this.serverAddress;
if (server.IndexOf(":") > 0)
{
int.TryParse(server.Substring(server.IndexOf(":") + 1), out result);
server = server.Substring(0, server.IndexOf(":"));
}
this.port = result.ToString();
string databaseName = AssetServer.GetDatabaseName(server, this.userName, this.password, this.port, this.projectName);
this.GetDefaultPListConfig();
this.plc["Maint Server"] = server;
this.plc["Maint UserName"] = this.userName;
this.plc["Maint database name"] = databaseName;
this.plc["Maint port number"] = this.port;
this.plc["Maint project name"] = this.projectName;
this.plc.Save();
if (ArrayUtility.Contains<string>(this.serversList, this.serverAddress))
ArrayUtility.Remove<string>(ref this.serversList, this.serverAddress);
ArrayUtility.Insert<string>(ref this.serversList, 0, this.serverAddress);
ASEditorBackend.AddUser(this.serverAddress, this.userName);
ASEditorBackend.SetPassword(this.serverAddress, this.userName, this.password);
InternalEditorUtility.SaveEditorSettingsList("ASServer", this.serversList, 20);
if (databaseName != string.Empty)
{
ASEditorBackend.InitializeMaintBinding();
this.parentWin.Reinit();
GUIUtility.ExitGUI();
}
else
{
this.parentWin.NeedsSetup = true;
this.parentWin.Repaint();
}
}
private void ServersPopup()
{
if (this.serversList.Length <= 0)
return;
int index = EditorGUILayout.Popup(-1, this.serversList, ASConfigWindow.constants.dropDown, new GUILayoutOption[1]
{
GUILayout.MaxWidth(18f)
});
if (index < 0)
return;
GUIUtility.keyboardControl = 0;
GUIUtility.hotControl = 0;
this.resetKeyboardControl = true;
this.serverAddress = this.serversList[index];
this.parentWin.Repaint();
}
private void DoConfigGUI()
{
bool enabled1 = GUI.enabled;
bool changed1 = GUI.changed;
GUI.changed = false;
bool flag1 = false;
bool flag2 = false;
Event current = Event.current;
if (current.type == EventType.KeyDown)
{
bool flag3;
if (Application.platform == RuntimePlatform.OSXEditor)
{
flag3 = (int) current.character == 10 || (int) current.character == 3 || current.keyCode == KeyCode.Return || current.keyCode == KeyCode.KeypadEnter;
}
else
{
if (current.keyCode == KeyCode.Return || current.keyCode == KeyCode.KeypadEnter)
current.Use();
flag3 = (int) current.character == 10 || (int) current.character == 3;
}
if (flag3)
{
string ofFocusedControl = GUI.GetNameOfFocusedControl();
if (ofFocusedControl != null)
{
// ISSUE: reference to a compiler-generated field
if (ASConfigWindow.\u003C\u003Ef__switch\u0024map10 == null)
{
// ISSUE: reference to a compiler-generated field
ASConfigWindow.\u003C\u003Ef__switch\u0024map10 = new Dictionary<string, int>(2)
{
{
"password",
0
},
{
"project",
1
}
};
}
int num;
// ISSUE: reference to a compiler-generated field
if (ASConfigWindow.\u003C\u003Ef__switch\u0024map10.TryGetValue(ofFocusedControl, out num))
{
if (num != 0)
{
if (num == 1)
{
flag2 = true;
goto label_16;
}
}
else
{
flag1 = true;
goto label_16;
}
}
}
current.Use();
}
}
label_16:
GUILayout.BeginHorizontal();
this.serverAddress = EditorGUILayout.TextField("Server", this.serverAddress, new GUILayoutOption[0]);
this.ServersPopup();
GUILayout.EndHorizontal();
if (GUI.changed)
this.GetUserAndPassword();
GUI.changed |= changed1;
this.userName = EditorGUILayout.TextField("User Name", this.userName, new GUILayoutOption[0]);
GUI.SetNextControlName("password");
this.password = EditorGUILayout.PasswordField("Password", this.password, new GUILayoutOption[0]);
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUI.enabled = this.userName != string.Empty && this.password != string.Empty && this.serverAddress != string.Empty && enabled1;
if (GUILayout.Button("Show Projects", new GUILayoutOption[1]
{
GUILayout.MinWidth(100f)
}) || flag1 && GUI.enabled)
{
this.DoShowProjects();
this.projectName = string.Empty;
EditorGUI.FocusTextInControl("project");
}
bool enabled2 = GUI.enabled;
GUI.enabled = enabled1;
if (GUILayout.Button("Clear Configuration"))
this.ClearConfig();
GUI.enabled = enabled2;
GUILayout.EndHorizontal();
GUILayout.Space(5f);
bool changed2 = GUI.changed;
GUI.changed = false;
GUI.SetNextControlName("project");
this.projectName = EditorGUILayout.TextField("Project Name", this.projectName, new GUILayoutOption[0]);
GUI.changed |= changed2;
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUI.enabled = this.userName != string.Empty && this.password != string.Empty && (this.serverAddress != string.Empty && this.projectName != string.Empty) && enabled1;
if (GUILayout.Button("Connect", ASConfigWindow.constants.bigButton, new GUILayoutOption[1]
{
GUILayout.MinWidth(100f)
}) || flag2 && GUI.enabled)
this.DoConnect();
GUI.enabled = enabled1;
GUILayout.EndHorizontal();
}
private void DoProjectsGUI()
{
GUILayout.BeginVertical(ASConfigWindow.constants.groupBox, new GUILayoutOption[0]);
GUILayout.Label("Projects on Server", ASConfigWindow.constants.title, new GUILayoutOption[0]);
foreach (ListViewElement listViewElement in ListViewGUILayout.ListView(this.projectsLv, ASConfigWindow.constants.background))
{
if (listViewElement.row == this.projectsLv.row && Event.current.type == EventType.Repaint)
ASConfigWindow.constants.entrySelected.Draw(listViewElement.position, false, false, false, false);
GUILayout.Label(this.projectsList[listViewElement.row], ASConfigWindow.constants.element, new GUILayoutOption[0]);
}
if (this.projectsLv.selectionChanged)
this.projectName = this.projectsList[this.projectsLv.row];
GUILayout.EndVertical();
}
public bool DoGUI()
{
if (ASConfigWindow.constants == null)
ASConfigWindow.constants = new ASMainWindow.Constants();
if (this.resetKeyboardControl)
{
this.resetKeyboardControl = false;
GUIUtility.keyboardControl = 0;
}
GUILayout.BeginHorizontal();
GUILayout.BeginVertical(ASConfigWindow.constants.groupBox, new GUILayoutOption[0]);
GUILayout.Box("Server Connection", ASConfigWindow.constants.title, new GUILayoutOption[0]);
GUILayout.BeginVertical(ASConfigWindow.constants.contentBox, new GUILayoutOption[0]);
this.DoConfigGUI();
if (AssetServer.GetAssetServerError() != string.Empty)
{
GUILayout.Space(10f);
GUILayout.Label(AssetServer.GetAssetServerError(), ASConfigWindow.constants.errorLabel, new GUILayoutOption[0]);
GUILayout.Space(10f);
}
GUILayout.EndVertical();
GUILayout.EndVertical();
this.DoProjectsGUI();
GUILayout.EndHorizontal();
return true;
}
}
}