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
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
|
using System;
using UILib;
using UnityEngine;
using XUpdater;
using XUtliPoolLib;
namespace XMainClient.UI.UICommon
{
//c 界面逻辑控制器基类
public abstract class DlgBase<TDlgClass, TUIBehaviour> : IXUIDlg, IDlgHandlerMgr where TDlgClass : IXUIDlg, new() where TUIBehaviour : DlgBehaviourBase
{
public static TDlgClass singleton
{
get
{
bool flag = DlgBase<TDlgClass, TUIBehaviour>.s_instance == null;
if (flag)
{
object obj = DlgBase<TDlgClass, TUIBehaviour>.s_objLock;
lock (obj)
{
bool flag2 = DlgBase<TDlgClass, TUIBehaviour>.s_instance == null;
if (flag2)
{
DlgBase<TDlgClass, TUIBehaviour>.s_instance = Activator.CreateInstance<TDlgClass>();
}
}
}
return DlgBase<TDlgClass, TUIBehaviour>.s_instance;
}
}
public IXUIBehaviour uiBehaviourInterface
{
get
{
return this.m_uiBehaviour;
}
}
public TUIBehaviour uiBehaviour
{
get
{
return this.m_uiBehaviour;
}
}
public virtual string fileName
{
get
{
return "";
}
}
public string luaFileName
{
get
{
bool flag = this.fileName.Length > 1 && this.fileName.Contains("/");
string result;
if (flag)
{
result = this.fileName.Substring(this.fileName.LastIndexOf('/') + 1);
}
else
{
result = this.fileName;
}
return result;
}
}
public virtual int layer
{
get
{
return 2;
}
}
public virtual int group
{
get
{
return 0;
}
}
public virtual bool exclusive
{
get
{
return false;
}
}
public virtual bool autoload
{
get
{
return false;
}
}
public virtual bool isHideChat
{
get
{
return true;
}
}
public virtual bool hideMainMenu
{
get
{
return false;
}
}
public virtual bool pushstack
{
get
{
return false;
}
}
public virtual bool isMainUI
{
get
{
return false;
}
}
public virtual bool isHideTutorial
{
get
{
return false;
}
}
public virtual int sysid
{
get
{
return 0;
}
}
public virtual bool fullscreenui
{
get
{
return false;
}
}
public bool Prepared
{
get
{
return null != this.m_uiBehaviour;
}
}
public virtual bool isPopup
{
get
{
return false;
}
}
public virtual bool needOnTop
{
get
{
return false;
}
}
public DlgHandlerMgr HandlerMgr
{
get
{
return this.m_DlgHandlerMgr;
}
}
private LoadUIFinishedEventHandler _loadUICb = null;
protected int m_dummPool = -1;
private IXNGUICallback panelCB = null;
protected TUIBehaviour m_uiBehaviour = default(TUIBehaviour);
private static TDlgClass s_instance = default(TDlgClass);
private static object s_objLock = new object();
private bool m_bVisible = false;
protected bool m_bLoaded = false;
private float m_fDepthZ = 0f;
private bool m_bBindedReverse = false;
private Transform m_DlgController = null;
private bool m_bCacheVisible = false;
private DlgBase<TDlgClass, TUIBehaviour>.OnAnimationOver m_animationOver;
private IXUIDlg m_RelatedDlg;
private DlgHandlerMgr m_DlgHandlerMgr = new DlgHandlerMgr();
public delegate void OnAnimationOver();
public DlgBase()
{
this._loadUICb = new LoadUIFinishedEventHandler(this.OnLoadUIFinishedEventHandler);
}
public virtual void OnUpdate()
{
this.HandlerMgr.OnUpdate();
}
public virtual void OnPostUpdate()
{
}
public void SetVisiblePure(bool bVisible)
{
bool flag = !this.m_bLoaded && this.autoload;
if (flag)
{
this.Load();
}
else
{
bool flag2 = !this.m_bLoaded && !this.autoload;
if (flag2)
{
return;
}
}
this.uiBehaviour.SetVisible(bVisible);
this.m_bVisible = bVisible;
this.OnSetVisiblePure(bVisible);
bool flag3 = this.m_RelatedDlg != null;
if (flag3)
{
this.m_RelatedDlg.SetRelatedVisible(this.m_bVisible);
}
}
public virtual void SetVisible(bool bIsVisible, bool bEnableAuto = true)
{
bool bLoaded = this.m_bLoaded;
if (!bLoaded)
{
bool flag = this.autoload && bEnableAuto;
if (!flag)
{
return;
}
this.Load();
}
bool flag2 = bIsVisible && !this._CanShow();
if (!flag2)
{
bool prepared = this.Prepared;
if (prepared)
{
bool flag3 = this.m_bVisible != bIsVisible;
if (flag3)
{
this.uiBehaviour.SetVisible(bIsVisible);
this.m_bVisible = bIsVisible;
if (bIsVisible)
{
XSingleton<UIManager>.singleton.OnDlgShow(DlgBase<TDlgClass, TUIBehaviour>.s_instance);
ILuaEngine xluaEngine = XSingleton<XUpdater.XUpdater>.singleton.XLuaEngine;
bool flag4 = !xluaEngine.hotfixMgr.TryFixRefresh(HotfixMode.BEFORE, this.luaFileName, this.uiBehaviour.gameObject);
if (flag4)
{
this.OnShow();
xluaEngine.hotfixMgr.TryFixRefresh(HotfixMode.AFTER, this.luaFileName, this.uiBehaviour.gameObject);
}
bool flag5 = this.fullscreenui && XSingleton<XScene>.singleton.GameCamera != null && XSingleton<XScene>.singleton.GameCamera.UnityCamera != null;
if (flag5)
{
XSingleton<XScene>.singleton.GameCamera.UnityCamera.enabled = false;
}
}
else
{
this.OnHide();
XSingleton<UIManager>.singleton.OnDlgHide(DlgBase<TDlgClass, TUIBehaviour>.s_instance);
ILuaEngine xluaEngine2 = XSingleton<XUpdater.XUpdater>.singleton.XLuaEngine;
xluaEngine2.hotfixMgr.TryFixRefresh(HotfixMode.HIDE, this.luaFileName, this.uiBehaviour.gameObject);
bool flag6 = XSingleton<UIManager>.singleton.GetFullScreenUICount() == 0 && XSingleton<XScene>.singleton.GameCamera != null && XSingleton<XScene>.singleton.GameCamera.UnityCamera != null;
if (flag6)
{
XSingleton<XScene>.singleton.GameCamera.UnityCamera.enabled = true;
}
}
bool flag7 = this.m_RelatedDlg != null;
if (flag7)
{
this.m_RelatedDlg.SetVisible(this.m_bVisible, true);
}
}
}
}
}
public virtual void SetVisibleWithAnimation(bool bVisible, DlgBase<TDlgClass, TUIBehaviour>.OnAnimationOver AnimationOverDelegate)
{
bool flag = !this.m_bLoaded;
if (flag)
{
this.Load();
}
bool flag2 = bVisible && !this._CanShow();
if (!flag2)
{
int fullScreenUICount = XSingleton<UIManager>.singleton.GetFullScreenUICount();
bool flag3 = (bVisible && fullScreenUICount > 0) || (!bVisible && ((this.fullscreenui && fullScreenUICount > 1) || (!this.fullscreenui && fullScreenUICount > 0)));
if (flag3)
{
this.SetVisible(bVisible, true);
bool flag4 = AnimationOverDelegate != null;
if (flag4)
{
AnimationOverDelegate();
}
}
else
{
this.SetVisible(bVisible, true);
this.m_bCacheVisible = bVisible;
this.m_animationOver = AnimationOverDelegate;
bool flag5 = AnimationOverDelegate != null;
if (flag5)
{
AnimationOverDelegate();
}
}
}
}
protected void OnShowAnimationFinish(IXUITweenTool tween)
{
bool fullscreenui = this.fullscreenui;
if (fullscreenui)
{
XSingleton<XScene>.singleton.GameCamera.UnityCamera.enabled = false;
}
}
protected void OnCloseAnimationFinish(IXUITweenTool tween)
{
this.SetVisible(false, true);
bool flag = this.m_animationOver != null;
if (flag)
{
this.m_animationOver();
}
}
protected virtual void OnShow()
{
}
protected virtual void OnHide()
{
}
protected virtual void OnLoad()
{
}
protected virtual void OnUnload()
{
this.UnRegisterEvent();
}
public bool IsVisible()
{
bool bLoaded = this.m_bLoaded;
return bLoaded && this.uiBehaviour.IsVisible();
}
public void SetDepthZ(int nDepthZ)
{
this.m_fDepthZ = (float)(nDepthZ * 10);
bool prepared = this.Prepared;
if (prepared)
{
Vector3 localPosition = this.uiBehaviour.transform.localPosition;
localPosition.z = this.m_fDepthZ;
this.uiBehaviour.transform.localPosition = localPosition;
}
}
public virtual void Reset()
{
}
public virtual void StackRefresh()
{
bool flag = this.HandlerMgr != null;
if (flag)
{
this.HandlerMgr.StackRefresh();
}
}
public virtual void LeaveStackTop()
{
bool flag = this.HandlerMgr != null;
if (flag)
{
this.HandlerMgr.LeaveStackTop();
}
}
protected virtual void OnSetVisiblePure(bool bShow)
{
}
protected virtual void Init()
{
}
private void InnerInit()
{
this.m_uiBehaviour.Init();
Vector3 localPosition = this.uiBehaviour.transform.localPosition;
localPosition.z = this.m_fDepthZ;
this.uiBehaviour.transform.localPosition = localPosition;
this.m_DlgController = this.uiBehaviour.transform.Find("DlgController");
}
public void Load()
{
bool flag = !this.m_bLoaded;
if (flag)
{
this.m_bLoaded = true;
XSingleton<UIManager>.singleton.LoadUI(this.fileName, this._loadUICb);
XSingleton<UIManager>.singleton.AddDlg(DlgBase<TDlgClass, TUIBehaviour>.s_instance);
this.OnLoad();
}
}
public bool IsLoaded()
{
return this.m_bLoaded;
}
public void UnLoad(bool bTransfer = false)
{
bool bLoaded = this.m_bLoaded;
if (bLoaded)
{
if (bTransfer)
{
this.SetVisible(false, false);
}
else
{
ILuaEngine xluaEngine = XSingleton<XUpdater.XUpdater>.singleton.XLuaEngine;
xluaEngine.hotfixMgr.TryFixRefresh(HotfixMode.UNLOAD, this.luaFileName, this.uiBehaviour.gameObject);
this.OnUnload();
this.HandlerMgr.Unload();
XSingleton<UIManager>.singleton.RemoveDlg(DlgBase<TDlgClass, TUIBehaviour>.s_instance);
XSingleton<XResourceLoaderMgr>.singleton.UnSafeDestroy(this.uiBehaviour.gameObject, false, true);
this.m_uiBehaviour = default(TUIBehaviour);
this.m_uiBehaviour = default(TUIBehaviour);
this.m_bLoaded = false;
bool flag = !XSingleton<XGame>.singleton.switchScene;
if (flag)
{
bool flag2 = XSingleton<UIManager>.singleton.unloadUICount >= 10;
if (flag2)
{
Resources.UnloadUnusedAssets();
XSingleton<UIManager>.singleton.unloadUICount = 0;
}
else
{
XSingleton<UIManager>.singleton.unloadUICount++;
}
}
}
}
}
public void SetAlpha(float a)
{
IXUIPanel ixuipanel = this.uiBehaviour.gameObject.GetComponent("XUIPanel") as IXUIPanel;
bool flag = ixuipanel != null;
if (flag)
{
ixuipanel.SetAlpha(a);
}
}
public float GetAlpha()
{
IXUIPanel ixuipanel = this.uiBehaviour.gameObject.GetComponent("XUIPanel") as IXUIPanel;
bool flag = ixuipanel != null;
float result;
if (flag)
{
result = ixuipanel.GetAlpha();
}
else
{
result = 1f;
}
return result;
}
public void RegCallBack()
{
this.panelCB = (this.uiBehaviour.gameObject.GetComponent("NGUIAssetCallBack") as IXNGUICallback);
bool flag = this.panelCB != null;
if (flag)
{
this.panelCB.RegisterClickEventHandler(new IXNGUIClickEventHandler(this.OnXNGUIClick));
}
}
public virtual void OnXNGUIClick(GameObject obj, string path)
{
XSingleton<XDebug>.singleton.AddLog(obj.name, " ", path, null, null, null, XDebugColor.XDebug_None);
}
protected GameObject SetXUILable(string name, string content)
{
bool flag = this.uiBehaviour.transform == null;
GameObject result;
if (flag)
{
result = null;
}
else
{
bool flag2 = string.IsNullOrEmpty(content);
if (flag2)
{
content = string.Empty;
}
IXUILabel ixuilabel = this.uiBehaviour.transform.Find(name).GetComponent("XUILabel") as IXUILabel;
bool flag3 = ixuilabel == null;
if (flag3)
{
XSingleton<XDebug>.singleton.AddErrorLog("SetXUILable ", name, " ", content, null, null);
result = null;
}
else
{
ixuilabel.SetText(content);
result = ixuilabel.gameObject;
}
}
return result;
}
private void OnLoadUIFinishedEventHandler(string location)
{
Debug.Log("加载界面prfab: " + location);
//c 加载prefab
GameObject gameObject = XSingleton<XResourceLoaderMgr>.singleton.CreateFromPrefab("UI/" + location, true, false) as GameObject;
bool flag = null != gameObject;
if (flag)
{
gameObject.transform.parent = XSingleton<UIManager>.singleton.UIRoot;
gameObject.transform.localPosition = new Vector3(0f, 0f, 0f);
gameObject.transform.localScale = new Vector3(1f, 1f, 1f);
this.m_uiBehaviour = gameObject.AddComponent<TUIBehaviour>(); //c 这里给界面挂上对应的脚本
this.m_uiBehaviour.uiDlgInterface = this;
bool flag2 = !this.m_bBindedReverse;
if (flag2)
{
this.Init();
this.InnerInit();
this.RegisterEvent();
this.RegCallBack();
this.uiBehaviour.SetVisible(false);
this.m_bVisible = false;
}
}
}
public bool BindReverse(IXUIBehaviour iXUIBehaviour)
{
TUIBehaviour tuibehaviour = iXUIBehaviour as TUIBehaviour;
bool flag = null == tuibehaviour;
bool result;
if (flag)
{
result = false;
}
else
{
this.m_bLoaded = true;
this.m_uiBehaviour = tuibehaviour;
this.m_uiBehaviour.uiDlgInterface = this;
this.RegisterEvent();
this.InnerInit();
this.Init();
this.m_bBindedReverse = true;
result = true;
}
return result;
}
public virtual void RegisterEvent()
{
}
protected virtual void UnRegisterEvent()
{
}
public virtual void SetRelatedDlg(IXUIDlg dlg)
{
this.m_RelatedDlg = dlg;
}
protected virtual void OnRelatedShow()
{
}
protected virtual void OnRelatedHide()
{
}
public void SetRelatedVisible(bool bVisible)
{
bool bLoaded = this.m_bLoaded;
if (bLoaded)
{
this.SetVisiblePure(bVisible);
if (bVisible)
{
this.OnRelatedShow();
}
else
{
this.OnRelatedHide();
}
}
}
private bool _CanShow()
{
bool flag = this.isPopup && XSingleton<XTutorialMgr>.singleton.InTutorial;
bool result;
if (flag)
{
this.OnPopupBlocked();
result = false;
}
else
{
result = true;
}
return result;
}
protected virtual void OnPopupBlocked()
{
}
public virtual int[] GetTitanBarItems()
{
return null;
}
protected void Alloc3DAvatarPool(string user)
{
bool flag = this.m_dummPool < 0;
if (flag)
{
this.m_dummPool = XSingleton<X3DAvatarMgr>.singleton.AllocDummyPool(user, 1);
}
}
protected void Return3DAvatarPool()
{
XSingleton<X3DAvatarMgr>.singleton.ReturnDummyPool(this.m_dummPool);
this.m_dummPool = -1;
}
public static Transform FindChildRecursively(string childName)
{
TDlgClass singleton = DlgBase<TDlgClass, TUIBehaviour>.singleton;
TUIBehaviour tuibehaviour = singleton.uiBehaviourInterface as TUIBehaviour;
bool flag = !tuibehaviour.IsVisible();
Transform result;
if (flag)
{
result = null;
}
else
{
Transform transform = XSingleton<XCommon>.singleton.FindChildRecursively(tuibehaviour.transform, childName);
result = transform;
}
return result;
}
public static Vector3 GetChildWorldPos(string childName)
{
TDlgClass singleton = DlgBase<TDlgClass, TUIBehaviour>.singleton;
TUIBehaviour tuibehaviour = singleton.uiBehaviourInterface as TUIBehaviour;
bool flag = !tuibehaviour.IsVisible();
Vector3 result;
if (flag)
{
result = Vector3.zero;
}
else
{
Transform transform = XSingleton<XCommon>.singleton.FindChildRecursively(tuibehaviour.transform, childName);
bool flag2 = transform != null;
if (flag2)
{
result = transform.position;
}
else
{
result = Vector3.zero;
}
}
return result;
}
}
}
|