summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/UI/LoadingDlg.cs
blob: c24822f0b249a1f0683ac5586639b606da3142dd (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
using System;
using System.Collections.Generic;
using UILib;
using XMainClient.UI.UICommon;
using XUtliPoolLib;

namespace XMainClient.UI
{
	internal class LoadingDlg : DlgBase<LoadingDlg, LoadingDlgBehaviour>
	{
		public override string fileName
		{
			get
			{
				return "Common/LoadingDlg";
			}
		}

		public override int layer
		{
			get
			{
				return 1;
			}
		}

		public override bool autoload
		{
			get
			{
				return true;
			}
		}

		public override bool needOnTop
		{
			get
			{
				return true;
			}
		}

		private string _pic = null;

		protected override void Init()
		{
			this.SetWaitForOthersTip("");
		}

		public void SetLoadingProgress(float f)
		{
			bool flag = !base.IsLoaded();
			if (!flag)
			{
				bool flag2 = this.m_uiBehaviour.m_LoadingProgress.IsVisible();
				if (flag2)
				{
					this.m_uiBehaviour.m_LoadingProgress.value = f;
					bool flag3 = XSingleton<XGame>.singleton.CurrentStage.Stage == EXStage.World && !XSingleton<XScene>.singleton.IsPVPScene && XSingleton<XGame>.singleton.SyncMode;
					if (flag3)
					{
						this.SetWaitForOthersTip((f == 1f) ? XStringDefineProxy.GetString("WAIT_FOR_OTHERS") : "");
					}
				}
			}
		}

		public void SetLoadingPrompt(List<string> otherPalyerName)
		{
			bool flag = !base.IsLoaded() || XSingleton<XGame>.singleton.CurrentStage.Stage != EXStage.World || !XSingleton<XGame>.singleton.SyncMode;
			if (!flag)
			{
				bool flag2 = otherPalyerName == null || otherPalyerName.Count == 0;
				if (flag2)
				{
					this.SetWaitForOthersTip(XStringDefineProxy.GetString("WAIT_FOR_OTHERS"));
				}
				else
				{
					string waitForOthersTip = string.Format(XSingleton<XStringTable>.singleton.GetString("WAIT_OTHER_PLAYER_PVE"), otherPalyerName.Count, otherPalyerName[0]);
					this.SetWaitForOthersTip(waitForOthersTip);
				}
			}
		}

		private void SetWaitForOthersTip(string tips)
		{
			base.uiBehaviour.m_WaitForOthersTip.SetText(tips);
			base.uiBehaviour.m_WaitForOthersTip.SetVisible(!string.IsNullOrEmpty(tips));
		}

		public void SetLoadingTip(string tip)
		{
			base.uiBehaviour.m_LoadingTips.SetText(tip);
		}

		public void SetLoadingPic(string pic)
		{
			this._pic = pic;
			bool flag = string.IsNullOrEmpty(pic);
			if (flag)
			{
				XSingleton<XDebug>.singleton.AddErrorLog("null laoding pic", null, null, null, null, null);
			}
			else
			{
				base.uiBehaviour.m_LoadingPic.SetTexturePath("atlas/UI/common/Pic/" + this._pic);
			}
			bool flag2 = base.uiBehaviour.m_Dog != null;
			if (flag2)
			{
				base.uiBehaviour.m_Dog.SetSprite("Animation");
			}
		}

		public void HideSelf(bool bFadeIn)
		{
			if (bFadeIn)
			{
				base.uiBehaviour.m_LoadingBg.gameObject.SetActive(false);
				base.uiBehaviour.m_Canvas.gameObject.SetActive(true);
				IXUITweenTool ixuitweenTool = base.uiBehaviour.m_Canvas.GetComponent("XUIPlayTween") as IXUITweenTool;
				ixuitweenTool.SetTweenEnabledWhenFinish(false);
				ixuitweenTool.SetTargetGameObject(base.uiBehaviour.m_Canvas.gameObject);
				ixuitweenTool.RegisterOnFinishEventHandler(new OnTweenFinishEventHandler(this.OnFinish));
				ixuitweenTool.PlayTween(true, -1f);
			}
			else
			{
				this.ReleaseTexture();
				this.SetVisible(false, true);
			}
		}

		protected void OnFinish(IXUITweenTool tween)
		{
			base.uiBehaviour.m_LoadingBg.gameObject.SetActive(true);
			base.uiBehaviour.m_Canvas.gameObject.SetActive(false);
			this.ReleaseTexture();
			this.SetVisible(false, true);
		}

		private void ReleaseTexture()
		{
			bool flag = base.uiBehaviour != null;
			if (flag)
			{
				bool flag2 = base.uiBehaviour.m_LoadingPic != null;
				if (flag2)
				{
					base.uiBehaviour.m_LoadingPic.SetTexturePath("");
				}
				bool flag3 = base.uiBehaviour.m_Dog != null;
				if (flag3)
				{
					base.uiBehaviour.m_Dog.SetSprite("", "", false);
				}
			}
		}
	}
}