summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/XGameUI.cs
blob: 58452c23ba0087b2140a41c0ea0ce477ef7a7ec2 (plain)
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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
using System;
using UILib;
using UnityEngine;
using XMainClient.UI;
using XMainClient.UI.Battle;
using XMainClient.UI.UICommon;
using XUtliPoolLib;

namespace XMainClient
{
	public class XGameUI : XSingleton<XGameUI>, IXGameUI, IXInterface
	{
		public int Base_UI_Width { get; set; }

		public int Base_UI_Height { get; set; }

		public bool Deprecated { get; set; }

		public GameObject DlgControllerTpl
		{
			get
			{
				return this._dlgControllerTpl;
			}
		}

		public GameObject[] buttonTpl
		{
			get
			{
				return this._buttonTpl;
			}
		}

		public GameObject[] spriteTpl
		{
			get
			{
				return this._spriteTpl;
			}
		}

		public IXUIPanel HpbarRoot
		{
			get
			{
				return this.m_objHpbarRoot;
			}
			set
			{
				this.m_objHpbarRoot = value;
			}
		}

		public IXUIPanel NpcHpbarRoot
		{
			get
			{
				return this.m_objNpcHpbarRoot;
			}
			set
			{
				this.m_objNpcHpbarRoot = value;
			}
		}

		public GameObject UIAudio
		{
			get
			{
				return this.m_uiAudio;
			}
		}

		public Transform UIRoot
		{
			get
			{
				return this.m_objUIRoot;
			}
			set
			{
				this.m_objUIRoot = value;
				this.m_uiTool = (this.m_objUIRoot.GetComponent("XUITool") as IXUITool);
				GameObject gameObject = this.m_objUIRoot.Find("GenericEventHandle").gameObject;
				this.m_uiAudio = this.m_objUIRoot.Find("uiplayaudio").gameObject;
				XSingleton<XAudioMgr>.singleton.StoreAudioSource(this.m_uiAudio);
				this.m_uiTool.SetUIGenericEventHandle(gameObject);
				XSingleton<UIManager>.singleton.UIRoot = this.m_objUIRoot;
			}
		}

		public Camera UICamera
		{
			get
			{
				return this.m_uiCamera;
			}
			set
			{
				this.m_uiCamera = value;
			}
		}

		private Transform m_objUIRoot = null;

		private IXUIPanel m_objHpbarRoot = null;

		private IXUIPanel m_objNpcHpbarRoot = null;

		private Camera m_uiCamera = null;

		public IXUITool m_uiTool = null;

		private IXUISprite m_overlay = null;

		private GameObject m_connect = null;

		private GameObject m_block = null;

		private GameObject m_uiAudio = null;

		public static int _far_far_away = 1000;

		public static Vector3 Far_Far_Away = new Vector3(10000f, 10000f, 0f);

		private GameObject[] _buttonTpl = new GameObject[3];

		private GameObject[] _spriteTpl = new GameObject[1];

		private GameObject _dlgControllerTpl = null;

		public override bool Init()
		{
			XSingleton<XDebug>.singleton.AddLog("XMainClient.XGameUI.Init --------------------------------", null, null, null, null, null, XDebugColor.XDebug_None);
			XSingleton<XInterfaceMgr>.singleton.AttachInterface<IXGameUI>(XSingleton<XCommon>.singleton.XHash("XGameUI"), this);
			XSingleton<XInterfaceMgr>.singleton.AttachInterface<IModalDlg>(XSingleton<XCommon>.singleton.XHash("IModalDlg"), DlgBase<ModalDlg, ModalDlgBehaviour>.singleton);
			XSingleton<XInterfaceMgr>.singleton.AttachInterface<IXNormalItemDrawer>(XSingleton<XCommon>.singleton.XHash("IXNormalItemDrawer"), XSingleton<XItemDrawerMgr>.singleton.normalItemDrawer);
			XSingleton<XInterfaceMgr>.singleton.AttachInterface<IGameSysMgr>(XSingleton<XCommon>.singleton.XHash("IGameSysMgr"), XSingleton<XGameSysMgr>.singleton);
			XSingleton<XInterfaceMgr>.singleton.AttachInterface<IUiUtility>(XSingleton<XCommon>.singleton.XHash("IUiUtility"), XSingleton<UiUtility>.singleton);
			XSingleton<XInterfaceMgr>.singleton.AttachInterface<ITssSdkSend>(XSingleton<XCommon>.singleton.XHash("ITssSdkSend"), XSingleton<XTssSdk>.singleton);
			XSingleton<XInterfaceMgr>.singleton.AttachInterface<IX3DAvatarMgr>(XSingleton<XCommon>.singleton.XHash("IX3DAvatarMgr"), XSingleton<X3DAvatarMgr>.singleton);
			XSingleton<XInterfaceMgr>.singleton.AttachInterface<ILuaExtion>(XSingleton<XCommon>.singleton.XHash("ILuaExtion"), XSingleton<XLuaExtion>.singleton);
			bool flag = this.UIRoot == null;
			if (flag)
			{
				this.UIRoot = (XSingleton<XResourceLoaderMgr>.singleton.CreateFromPrefab("UI/Common/work/UIRoot", false, true) as GameObject).transform;
				UnityEngine.Object.DontDestroyOnLoad(this.UIRoot);
			}
			bool flag2 = this.HpbarRoot == null;
			if (flag2)
			{
				GameObject gameObject = XSingleton<XResourceLoaderMgr>.singleton.CreateFromPrefab("UI/Common/work/HpbarRoot", false, true) as GameObject;
				bool flag3 = gameObject != null;
				if (flag3)
				{
					this.HpbarRoot = (gameObject.GetComponent("XUIPanel") as IXUIPanel);
					UnityEngine.Object.DontDestroyOnLoad(gameObject);
				}
			}
			bool flag4 = this.NpcHpbarRoot == null;
			if (flag4)
			{
				GameObject gameObject2 = XSingleton<XResourceLoaderMgr>.singleton.CreateFromPrefab("UI/Common/work/HpbarRoot", false, true) as GameObject;
				bool flag5 = gameObject2 != null;
				if (flag5)
				{
					gameObject2.name = "NpcHpbarRoot";
					this.NpcHpbarRoot = (gameObject2.GetComponent("XUIPanel") as IXUIPanel);
					UnityEngine.Object.DontDestroyOnLoad(gameObject2);
				}
			}
			for (int i = 0; i < 3; i++)
			{
				this._buttonTpl[i] = (XSingleton<XResourceLoaderMgr>.singleton.CreateFromPrefab("UI/Common/work/XButton" + (i + 1), false, true) as GameObject);
				this._buttonTpl[i].SetActive(false);
				UnityEngine.Object.DontDestroyOnLoad(this._buttonTpl[i]);
			}
			for (int j = 0; j < 1; j++)
			{
				this._spriteTpl[j] = (XSingleton<XResourceLoaderMgr>.singleton.CreateFromPrefab("UI/Common/work/XSprite" + (j + 1), false, true) as GameObject);
				this._spriteTpl[j].SetActive(false);
				UnityEngine.Object.DontDestroyOnLoad(this._spriteTpl[j]);
			}
			this._dlgControllerTpl = (XSingleton<XResourceLoaderMgr>.singleton.CreateFromPrefab("UI/Common/work/DlgAnimation", false, true) as GameObject);
			this._dlgControllerTpl.SetActive(false);
			UnityEngine.Object.DontDestroyOnLoad(this._dlgControllerTpl);
			return true;
		}

		public override void Uninit()
		{
		}

		public void GetOverlay()
		{
			bool flag = this.m_overlay == null;
			if (flag)
			{
				this.m_overlay = (this.m_objUIRoot.Find("fade_panel/fade_canvas").GetComponent("XUISprite") as IXUISprite);
				this.m_overlay.gameObject.SetActive(false);
			}
		}

		public float GetOverlayAlpha()
		{
			this.GetOverlay();
			return this.m_overlay.gameObject.activeSelf ? this.m_overlay.GetAlpha() : 0f;
		}

		public void SetOverlayAlpha(float alpha)
		{
			this.GetOverlay();
			bool flag = alpha > 0f;
			if (flag)
			{
				bool flag2 = !this.m_overlay.gameObject.activeSelf;
				if (flag2)
				{
					this.m_overlay.gameObject.SetActive(true);
				}
				this.m_overlay.SetAlpha(alpha);
			}
			else
			{
				this.m_overlay.gameObject.SetActive(false);
			}
		}

		private void ShowConnecting(bool bVisible)
		{
			bool flag = this.m_connect == null;
			if (flag)
			{
				this.m_connect = this.m_objUIRoot.Find("fade_panel/connecting").gameObject;
			}
			if (bVisible)
			{
				bool flag2 = !this.m_connect.activeSelf;
				if (flag2)
				{
					this.m_connect.SetActive(bVisible);
				}
			}
			else
			{
				bool activeSelf = this.m_connect.activeSelf;
				if (activeSelf)
				{
					this.m_connect.SetActive(bVisible);
				}
			}
		}

		public void ShowBlock(bool bVisible)
		{
			bool flag = this.m_block == null;
			if (flag)
			{
				this.m_block = this.m_objUIRoot.Find("block").gameObject;
			}
			if (bVisible)
			{
				bool flag2 = !this.m_block.activeSelf;
				if (flag2)
				{
					this.m_block.SetActive(bVisible);
				}
			}
			else
			{
				bool activeSelf = this.m_block.activeSelf;
				if (activeSelf)
				{
					this.m_block.SetActive(bVisible);
				}
			}
		}

		public void OnGenericClick()
		{
			bool flag = XSingleton<XGame>.singleton.CurrentStage != null;
			if (flag)
			{
				bool flag2 = !XSingleton<XTutorialMgr>.singleton.Exculsive;
				if (flag2)
				{
					bool flag3 = DlgBase<EquipTooltipDlg, EquipTooltipDlgBehaviour>.singleton.IsLoaded();
					if (flag3)
					{
						DlgBase<EquipTooltipDlg, EquipTooltipDlgBehaviour>.singleton.HideToolTip(false);
					}
					bool flag4 = DlgBase<ItemTooltipDlg, ItemTooltipDlgBehaviour>.singleton.IsLoaded();
					if (flag4)
					{
						DlgBase<ItemTooltipDlg, ItemTooltipDlgBehaviour>.singleton.HideToolTip(false);
					}
					bool flag5 = DlgBase<EmblemTooltipDlg, EmblemTooltipDlgBehaviour>.singleton.IsLoaded();
					if (flag5)
					{
						DlgBase<EmblemTooltipDlg, EmblemTooltipDlgBehaviour>.singleton.HideToolTip(false);
					}
					bool flag6 = DlgBase<JadeTooltipDlg, TooltipDlgBehaviour>.singleton.IsLoaded();
					if (flag6)
					{
						DlgBase<JadeTooltipDlg, TooltipDlgBehaviour>.singleton.HideToolTip(false);
					}
					bool flag7 = DlgBase<FashionTooltipDlg, FashionTooltipDlgBehaviour>.singleton.IsLoaded();
					if (flag7)
					{
						DlgBase<FashionTooltipDlg, FashionTooltipDlgBehaviour>.singleton.HideToolTip(false);
					}
					bool flag8 = DlgBase<ArtifactToolTipDlg, ArtifactTooltipDlgBehaviour>.singleton.IsLoaded();
					if (flag8)
					{
						DlgBase<ArtifactToolTipDlg, ArtifactTooltipDlgBehaviour>.singleton.HideToolTip(false);
					}
					bool flag9 = DlgBase<FashionHairToolTipDlg, FashionHairToolTipBehaviour>.singleton.IsLoaded();
					if (flag9)
					{
						DlgBase<FashionHairToolTipDlg, FashionHairToolTipBehaviour>.singleton.HideToolTip(false);
					}
					bool flag10 = DlgBase<FashionStorageFashionToolTipDlg, FashionTooltipDlgBehaviour>.singleton.IsLoaded();
					if (flag10)
					{
						DlgBase<FashionStorageFashionToolTipDlg, FashionTooltipDlgBehaviour>.singleton.HideToolTip(false);
					}
					bool flag11 = DlgBase<FashionStorageEquipToolTipDlg, ItemTooltipDlgBehaviour>.singleton.IsLoaded();
					if (flag11)
					{
						DlgBase<FashionStorageEquipToolTipDlg, ItemTooltipDlgBehaviour>.singleton.HideToolTip(false);
					}
					bool flag12 = DlgBase<FashionStorageFashionHairToolTipDlg, FashionHairToolTipBehaviour>.singleton.IsLoaded();
					if (flag12)
					{
						DlgBase<FashionStorageFashionHairToolTipDlg, FashionHairToolTipBehaviour>.singleton.HideToolTip(false);
					}
				}
				bool flag13 = XSingleton<XTutorialMgr>.singleton.Exculsive && XSingleton<XTutorialMgr>.singleton.ExculsiveOnGeneric;
				if (flag13)
				{
					bool flag14 = DlgBase<EquipTooltipDlg, EquipTooltipDlgBehaviour>.singleton.IsLoaded();
					if (flag14)
					{
						DlgBase<EquipTooltipDlg, EquipTooltipDlgBehaviour>.singleton.HideToolTip(false);
					}
					bool flag15 = DlgBase<ItemTooltipDlg, ItemTooltipDlgBehaviour>.singleton.IsLoaded();
					if (flag15)
					{
						DlgBase<ItemTooltipDlg, ItemTooltipDlgBehaviour>.singleton.HideToolTip(false);
					}
					bool flag16 = DlgBase<EmblemTooltipDlg, EmblemTooltipDlgBehaviour>.singleton.IsLoaded();
					if (flag16)
					{
						DlgBase<EmblemTooltipDlg, EmblemTooltipDlgBehaviour>.singleton.HideToolTip(false);
					}
					bool flag17 = DlgBase<JadeTooltipDlg, TooltipDlgBehaviour>.singleton.IsLoaded();
					if (flag17)
					{
						DlgBase<JadeTooltipDlg, TooltipDlgBehaviour>.singleton.HideToolTip(false);
					}
					bool flag18 = DlgBase<FashionTooltipDlg, FashionTooltipDlgBehaviour>.singleton.IsLoaded();
					if (flag18)
					{
						DlgBase<FashionTooltipDlg, FashionTooltipDlgBehaviour>.singleton.HideToolTip(false);
					}
					bool flag19 = DlgBase<ArtifactToolTipDlg, ArtifactTooltipDlgBehaviour>.singleton.IsLoaded();
					if (flag19)
					{
						DlgBase<ArtifactToolTipDlg, ArtifactTooltipDlgBehaviour>.singleton.HideToolTip(false);
					}
					bool flag20 = DlgBase<FashionHairToolTipDlg, FashionHairToolTipBehaviour>.singleton.IsLoaded();
					if (flag20)
					{
						DlgBase<FashionHairToolTipDlg, FashionHairToolTipBehaviour>.singleton.HideToolTip(false);
					}
					bool flag21 = DlgBase<FashionStorageFashionToolTipDlg, FashionTooltipDlgBehaviour>.singleton.IsLoaded();
					if (flag21)
					{
						DlgBase<FashionStorageFashionToolTipDlg, FashionTooltipDlgBehaviour>.singleton.HideToolTip(false);
					}
					bool flag22 = DlgBase<FashionStorageEquipToolTipDlg, ItemTooltipDlgBehaviour>.singleton.IsLoaded();
					if (flag22)
					{
						DlgBase<FashionStorageEquipToolTipDlg, ItemTooltipDlgBehaviour>.singleton.HideToolTip(false);
					}
					bool flag23 = DlgBase<FashionStorageFashionHairToolTipDlg, FashionHairToolTipBehaviour>.singleton.IsLoaded();
					if (flag23)
					{
						DlgBase<FashionStorageFashionHairToolTipDlg, FashionHairToolTipBehaviour>.singleton.HideToolTip(false);
					}
					XSingleton<XTutorialMgr>.singleton.OnTutorialClicked();
				}
			}
		}

		public void ShowCutSceneUI()
		{
			DlgBase<CutSceneUI, CutSceneUIBehaviour>.singleton.Load();
			DlgBase<CutSceneUI, CutSceneUIBehaviour>.singleton.SetVisible(true, true);
		}

		public void UpdateNetUI()
		{
			this.ShowConnecting(XSingleton<XLoginDocument>.singleton.FetchTokenDelay || XSingleton<XLoginDocument>.singleton.LoginDelay || XSingleton<XClientNetwork>.singleton.XConnect.OnConnectDelay || XSingleton<XClientNetwork>.singleton.XConnect.OnRpcDelay || XSingleton<XClientNetwork>.singleton.XConnect.OnReconnect);
		}

		internal void LoadLoginUI(EXStage eStage)
		{
			DlgBase<XLoginView, LoginWindowBehaviour>.singleton.Load();
			DlgBase<XLoginView, LoginWindowBehaviour>.singleton.SetVisible(true, true);
		}

		internal void UnloadLoginUI()
		{
			DlgBase<XLoginView, LoginWindowBehaviour>.singleton.UnLoad(false);
			DlgBase<CutSceneUI, CutSceneUIBehaviour>.singleton.UnLoad(false);
			DlgBase<ModalDlg, ModalDlgBehaviour>.singleton.UnLoad(false);
		}

		internal void LoadSelectCharUI(EXStage eStage)
		{
			DlgBase<XSelectCharView, SelectCharWindowBehaviour>.singleton.Load();
			DlgBase<XSelectCharView, SelectCharWindowBehaviour>.singleton.SetVisible(true, true);
		}

		internal void UnLoadSelectCharUI()
		{
			DlgBase<XSelectCharView, SelectCharWindowBehaviour>.singleton.UnLoad(false);
			DlgBase<XAnnouncementView, XAnnouncementBehaviour>.singleton.UnLoad(false);
			DlgBase<ModalDlg, ModalDlgBehaviour>.singleton.UnLoad(false);
		}

		internal void LoadWorldUI(EXStage eStage)
		{
			bool bSpectator = XSingleton<XScene>.singleton.bSpectator;
			if (bSpectator)
			{
				DlgBase<SpectateSceneView, SpectateSceneBehaviour>.singleton.Load();
			}
			else
			{
				DlgBase<BattleMain, BattleMainBehaviour>.singleton.Load();
			}
			DlgBase<XLevelRewardView, XLevelRewardBehaviour>.singleton.Load();
			DlgBase<CutSceneUI, CutSceneUIBehaviour>.singleton.Load();
			DlgBase<ReviveDlg, ReviveDlgBehaviour>.singleton.Load();
		}

		internal void UnloadWorldUI()
		{
			DlgBase<BattleMain, BattleMainBehaviour>.singleton.UnLoad(false);
			DlgBase<SpectateSceneView, SpectateSceneBehaviour>.singleton.UnLoad(false);
			DlgBase<ChallengeDlg, ChallengeDlgBehaviour>.singleton.UnLoad(false);
			DlgBase<BattleQTEDlg, BattleQTEDlgBehaviour>.singleton.UnLoad(false);
			DlgBase<BattleDramaDlg, BattleDramaDlgBehaviour>.singleton.UnLoad(false);
			DlgBase<XLevelRewardView, XLevelRewardBehaviour>.singleton.UnLoad(false);
			DlgBase<CutSceneUI, CutSceneUIBehaviour>.singleton.UnLoad(false);
			DlgBase<ReviveDlg, ReviveDlgBehaviour>.singleton.UnLoad(false);
			DlgBase<XPkLoadingView, XPkLoadingBehaviour>.singleton.UnLoad(false);
			DlgBase<XMultiPkLoadingView, XMultiPkLoadingBehaviour>.singleton.UnLoad(false);
			DlgBase<XTeamLeagueLoadingView, XTeamLeagueLoadingBehaviour>.singleton.UnLoad(false);
			DlgBase<NpcPopSpeekView, DlgBehaviourBase>.singleton.UnLoad(false);
			DlgBase<RollDlg, RollDlgBehaviour>.singleton.UnLoad(false);
		}

		internal void LoadHallUI(EXStage eStage)
		{
			DlgBase<XMainInterface, XMainInterfaceBehaviour>.singleton.Load();
		}

		internal void LoadConcreteUI(EXStage eStage)
		{
		}

		public void SetUIOptOption(bool globalMerge, bool selectMerge, bool lowDeviceMerge, bool refreshUI = true)
		{
			bool flag = this.m_uiTool != null;
			if (flag)
			{
				this.m_uiTool.SetUIOptOption(globalMerge, selectMerge, lowDeviceMerge);
			}
			if (refreshUI)
			{
				bool flag2 = this.m_objUIRoot != null;
				if (flag2)
				{
					this.m_objUIRoot.gameObject.SetActive(false);
					this.m_objUIRoot.gameObject.SetActive(true);
				}
				bool flag3 = this.m_objHpbarRoot != null;
				if (flag3)
				{
					this.m_objHpbarRoot.gameObject.SetActive(false);
					this.m_objHpbarRoot.gameObject.SetActive(true);
				}
				bool flag4 = this.m_objNpcHpbarRoot != null;
				if (flag4)
				{
					this.m_objNpcHpbarRoot.gameObject.SetActive(false);
					this.m_objNpcHpbarRoot.gameObject.SetActive(true);
				}
			}
		}
	}
}