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

namespace XMainClient
{
	internal class RadioDlg : DlgBase<RadioDlg, RadioBehaviour>
	{
		private XRadioDocument radioDocument
		{
			get
			{
				return XDocuments.GetSpecificDocument<XRadioDocument>(XRadioDocument.uuID);
			}
		}

		public override string fileName
		{
			get
			{
				return "Common/RadioDlg";
			}
		}

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

		public override bool isHideChat
		{
			get
			{
				return false;
			}
		}

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

		public bool IsOpen
		{
			get
			{
				this.open_level = XSingleton<XGlobalConfig>.singleton.GetInt("RadioOpen");
				XPlayerAttributes xplayerData = XSingleton<XAttributeMgr>.singleton.XPlayerData;
				return xplayerData != null && (ulong)xplayerData.Level >= (ulong)((long)this.open_level);
			}
		}

		private int open_level = 2;

		protected override void Init()
		{
			base.Init();
			this.open_level = XSingleton<XGlobalConfig>.singleton.GetInt("RadioOpen");
		}

		public override void RegisterEvent()
		{
			base.RegisterEvent();
			base.uiBehaviour.m_lblMicro.RegisterLabelClickEventHandler(new LabelClickEventHandler(this.OnMicroClick));
			base.uiBehaviour.m_btnRadio.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnRadioClick));
		}

		protected void SetPos()
		{
			XChatDocument specificDocument = XDocuments.GetSpecificDocument<XChatDocument>(XChatDocument.uuID);
			bool flag = DlgBase<SpectateSceneView, SpectateSceneBehaviour>.singleton.IsVisible();
			if (flag)
			{
				int type = 103;
				ChatOpen.RowData yuyinRaw = specificDocument.GetYuyinRaw(type);
				base.uiBehaviour.transform.localPosition = new Vector3((float)yuyinRaw.radioX, (float)yuyinRaw.radioY, 0f);
			}
			else
			{
				bool fakeShow = DlgBase<XMainInterface, XMainInterfaceBehaviour>.singleton.fakeShow;
				if (fakeShow)
				{
					int type2 = 1;
					ChatOpen.RowData yuyinRaw2 = specificDocument.GetYuyinRaw(type2);
					base.uiBehaviour.transform.localPosition = new Vector3((float)yuyinRaw2.radioX, (float)yuyinRaw2.radioY, 0f);
				}
			}
		}

		public void Show(bool show)
		{
			if (show)
			{
				XOptionsDocument specificDocument = XDocuments.GetSpecificDocument<XOptionsDocument>(XOptionsDocument.uuID);
				bool flag = (DlgBase<XMainInterface, XMainInterfaceBehaviour>.singleton.fakeShow || DlgBase<SpectateSceneView, SpectateSceneBehaviour>.singleton.IsVisible()) && specificDocument != null && specificDocument.GetValue(XOptionsDefine.OD_RADIO) == 1 && this.IsOpen;
				if (flag)
				{
					this.SetVisible(true, true);
					this.Refresh(this.radioDocument.roomState == XRadioDocument.BigRoomState.InRoom);
					this.UpdateHostInfo();
					this.SetPos();
				}
				else
				{
					this.SetVisible(false, true);
				}
			}
			else
			{
				this.SetVisible(false, true);
			}
		}

		public void Process(bool open)
		{
			bool flag = XSingleton<XGame>.singleton.CurrentStage != null && XSingleton<XGame>.singleton.CurrentStage.Stage == EXStage.Hall;
			if (flag)
			{
				this.Show(open);
				bool flag2 = !open;
				if (flag2)
				{
					this.QuitRoom();
				}
			}
		}

		public void Refresh(bool open)
		{
			bool flag = base.IsVisible();
			if (flag)
			{
				if (open)
				{
					bool flag2 = this.radioDocument.roomState == XRadioDocument.BigRoomState.InRoom;
					if (flag2)
					{
						base.uiBehaviour.m_lblMicro.SetText(XStringDefineProxy.GetString("RADIO_HOST") + ":  ");
						base.uiBehaviour.m_sprPlay.SetSprite("icon_pause");
					}
				}
				else
				{
					bool flag3 = this.radioDocument.roomState == XRadioDocument.BigRoomState.OutRoom || this.radioDocument.roomState == XRadioDocument.BigRoomState.Processing;
					if (flag3)
					{
						base.uiBehaviour.m_lblMicro.SetText(XStringDefineProxy.GetString("RADIO_LISTEN"));
						base.uiBehaviour.m_sprPlay.SetSprite("icon_play");
					}
				}
			}
		}

		public void JoinRoom()
		{
			bool isBroadcast = DlgBase<BroadMiniDlg, BroadcastMiniBehaviour>.singleton.isBroadcast;
			if (isBroadcast)
			{
				XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("ERR_FM_FORBID2"), "fece00");
			}
			else
			{
				bool flag = this.radioDocument.roomState == XRadioDocument.BigRoomState.OutRoom;
				if (flag)
				{
					this.radioDocument.JoinBigRoom();
				}
			}
		}

		public void QuitRoom()
		{
			bool flag = this.radioDocument.roomState == XRadioDocument.BigRoomState.InRoom;
			if (flag)
			{
				this.radioDocument.QuitBigRoom();
				XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("FM_LEAVE_SUCCESS"), "fece00");
				this.Refresh(false);
			}
		}

		public void UpdateHostInfo()
		{
			bool flag = base.IsVisible() && this.radioDocument.roomState == XRadioDocument.BigRoomState.InRoom;
			if (flag)
			{
				List<string> hostlist = this.radioDocument.hostlist;
				bool flag2 = hostlist.Count <= 0;
				if (flag2)
				{
					base.uiBehaviour.m_lblMicro.SetText(XStringDefineProxy.GetString("ERR_FM_NOANCHOR_STRING"));
				}
				else
				{
					XSingleton<XCommon>.singleton.CleanStringCombine();
					XSingleton<XCommon>.singleton.AppendString(XStringDefineProxy.GetString("RADIO_HOST"), ": ");
					for (int i = 0; i < hostlist.Count; i++)
					{
						XSingleton<XCommon>.singleton.AppendString(hostlist[i], " ");
					}
					base.uiBehaviour.m_lblMicro.SetText(XSingleton<XCommon>.singleton.GetString());
				}
			}
		}

		private bool OnRadioClick(IXUIButton sp)
		{
			bool flag = this.radioDocument.roomState == XRadioDocument.BigRoomState.InRoom;
			if (flag)
			{
				this.QuitRoom();
			}
			else
			{
				bool flag2 = this.radioDocument.roomState == XRadioDocument.BigRoomState.Processing;
				if (flag2)
				{
					XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("FM_CLICKTOOFAST"), "fece00");
				}
				else
				{
					bool flag3 = this.radioDocument.roomState == XRadioDocument.BigRoomState.OutRoom;
					if (flag3)
					{
						this.JoinRoom();
					}
				}
			}
			return true;
		}

		private void OnMicroClick(IXUILabel lbl)
		{
			bool isHost = this.radioDocument.isHost;
			if (isHost)
			{
				bool flag = this.radioDocument.roomState == XRadioDocument.BigRoomState.InRoom;
				if (flag)
				{
					bool openSpeak = XSingleton<XUpdater.XUpdater>.singleton.XApolloManager.openSpeak;
					XSingleton<XUpdater.XUpdater>.singleton.XApolloManager.openSpeak = !openSpeak;
					PtcC2M_HandleMicphone ptcC2M_HandleMicphone = new PtcC2M_HandleMicphone();
					bool openSpeak2 = XSingleton<XUpdater.XUpdater>.singleton.XApolloManager.openSpeak;
					if (openSpeak2)
					{
						XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("FM_OPENMIC"), "fece00");
						ptcC2M_HandleMicphone.Data.param = true;
					}
					else
					{
						XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("FM_CLOSEMIC"), "fece00");
						ptcC2M_HandleMicphone.Data.param = false;
					}
					XSingleton<XClientNetwork>.singleton.Send(ptcC2M_HandleMicphone);
				}
			}
		}
	}
}