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
|
using System;
using System.Collections.Generic;
using UILib;
using UnityEngine;
using XMainClient.UI;
using XMainClient.UI.UICommon;
using XUpdater;
using XUtliPoolLib;
namespace XMainClient
{
public class XYuyinView : DlgHandlerBase
{
protected override string FileName
{
get
{
return "Common/YuyinDlg";
}
}
public GameObject m_pool;
public GameObject m_goCommon;
public GameObject m_goFriend;
public IXUIButton m_btnSetting;
public IXUIButton m_btnMusic;
public IXUIButton m_btnSpeak;
public GameObject m_objMusic;
public GameObject m_objSpeak;
public IXUIPanel m_panel;
public GameObject m_leftRoot;
public GameObject m_rightRoot;
public IXUITweenTool m_tween;
public XUIPool m_CommonPool = new XUIPool(XSingleton<XGameUI>.singleton.m_uiTool);
private bool m_CancelRecord = false;
private Vector2 m_DragDistance = Vector2.zero;
private int mType = 1;
private static bool hideRealEff = false;
public Vector3 farway = new Vector3(2000f, 2000f, 0f);
private bool cacheGuild = false;
private bool cacheTeam = false;
private List<Transform> m_trans = new List<Transform>();
private XChatDocument chatDoc;
private ChatOpen.RowData openRow;
public void ResetPool()
{
bool flag = this.m_CommonPool != null;
if (flag)
{
this.m_CommonPool.ReturnAll(false);
}
}
protected override void Init()
{
base.Init();
this.m_panel = (base.transform.GetComponent("XUIPanel") as IXUIPanel);
this.m_tween = (base.transform.GetComponent("XUIPlayTween") as IXUITweenTool);
this.m_leftRoot = base.transform.transform.Find("leftRoot").gameObject;
this.m_rightRoot = base.transform.transform.Find("rightRoot").gameObject;
this.m_pool = base.transform.Find("pool").gameObject;
this.m_goCommon = base.transform.Find("pool/1").gameObject;
this.m_btnSetting = (base.transform.Find("pool/3").GetComponent("XUIButton") as IXUIButton);
this.m_btnMusic = (base.transform.Find("pool/4/MUSIC").GetComponent("XUIButton") as IXUIButton);
this.m_btnSpeak = (base.transform.Find("pool/4/SPEAK").GetComponent("XUIButton") as IXUIButton);
this.m_objMusic = base.transform.Find("pool/4/MUSIC/close").gameObject;
this.m_objSpeak = base.transform.Find("pool/4/SPEAK/close").gameObject;
this.m_CommonPool.SetupPool(this.m_pool, this.m_goCommon, 2u, true);
}
public override void RegisterEvent()
{
base.RegisterEvent();
this.m_btnSetting.RegisterClickEventHandler(new ButtonClickEventHandler(this.OpenInputView));
this.m_btnMusic.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnMusicClick));
this.m_btnSpeak.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnSpeakClick));
}
public void Init(int depth)
{
this.m_panel.SetDepth(depth);
}
public override void OnUpdate()
{
bool flag = this.chatDoc != null;
if (flag)
{
bool flag2 = false;
XStage currentStage = XSingleton<XGame>.singleton.CurrentStage;
bool flag3 = currentStage != null && currentStage.Stage == EXStage.Hall;
if (flag3)
{
bool flag4 = this.chatDoc.CheckTeam() != this.cacheTeam;
if (flag4)
{
flag2 = true;
}
bool flag5 = this.chatDoc.CheckGuild() != this.cacheGuild;
if (flag5)
{
flag2 = true;
}
}
bool flag6 = flag2;
if (flag6)
{
this.Refresh(this.mType);
}
}
}
public void Show(bool active)
{
this.m_panel.gameObject.SetActive(active);
}
public void Show(YuyinIconType type, int depth = 1)
{
this.Show((int)type, depth);
}
public void Show(int type, int depth = 1)
{
this.mType = type;
this.Init(depth);
this.Refresh(type);
}
public void Refresh(YuyinIconType type)
{
this.Refresh((int)type);
}
public void Refresh(int type)
{
bool flag = this.chatDoc == null;
if (flag)
{
this.chatDoc = XDocuments.GetSpecificDocument<XChatDocument>(XChatDocument.uuID);
}
this.cacheGuild = this.chatDoc.CheckGuild();
this.cacheTeam = this.chatDoc.CheckTeam();
this.ResetPool();
this.m_trans.Clear();
this.openRow = this.chatDoc.GetYuyinRaw(type);
this.m_pool.transform.parent = ((this.openRow.pivot == 0) ? this.m_rightRoot.transform : this.m_leftRoot.transform);
this.m_pool.transform.localPosition = new Vector3((float)this.openRow.posX, (float)this.openRow.posY, 0f);
this.m_pool.transform.localScale = this.openRow.scale * Vector3.one;
this.m_panel.SetAlpha(this.openRow.alpha);
bool flag2 = this.openRow.real <= 0;
if (flag2)
{
List<int> list = this.chatDoc.SortCommonIcons(type);
int num = Mathf.Min(this.openRow.max, list.Count);
for (int i = 0; i < num; i++)
{
GameObject gameObject = this.m_CommonPool.FetchGameObject(false);
this.m_trans.Add(gameObject.transform);
string sprName = this.chatDoc.GetRawData((ChatChannelType)list[i]).sprName;
IXUISprite ixuisprite = gameObject.transform.Find("Name").GetComponent("XUISprite") as IXUISprite;
bool flag3 = ixuisprite != null;
if (flag3)
{
ixuisprite.SetSprite(sprName);
}
IXUIButton ixuibutton = gameObject.transform.GetComponent("XUIButton") as IXUIButton;
ixuibutton.ID = (ulong)((long)list[i]);
ixuibutton.RegisterPressEventHandler(new ButtonPressEventHandler(this.OnItemPress));
ixuibutton.RegisterDragEventHandler(new ButtonDragEventHandler(this.OnVoiceButtonDrag));
}
}
bool flag4 = this.openRow.fade == 1;
if (flag4)
{
this.m_trans.Add(this.m_btnSetting.gameObject.transform);
}
else
{
this.m_btnSetting.gameObject.transform.localPosition = this.farway;
}
bool flag5 = this.openRow.real > 0;
if (flag5)
{
this.m_trans.Add(this.m_btnMusic.gameObject.transform);
this.m_trans.Add(this.m_btnSpeak.gameObject.transform);
bool flag6 = !XYuyinView.hideRealEff;
if (flag6)
{
XYuyinView.hideRealEff = true;
}
else
{
this.HideVoiceEff(null);
}
}
else
{
this.m_btnSpeak.gameObject.transform.localPosition = this.farway;
this.m_btnMusic.gameObject.transform.localPosition = this.farway;
}
this.GridItems(type);
}
private void GridItems(int type)
{
bool flag = this.openRow == null;
if (!flag)
{
bool flag2 = this.openRow.pivot == 0;
int num = (this.openRow.real > 0) ? 70 : 55;
for (int i = 0; i < this.m_trans.Count; i++)
{
this.m_trans[i].localPosition = (flag2 ? new Vector3((float)(-(float)num * i), 0f, 0f) : new Vector3((float)(num * i), 0f, 0f));
}
}
}
public void OnItemPress(IXUIButton btn, bool isPressed)
{
GameObject gameObject = btn.gameObject.transform.Find("Effect").gameObject;
gameObject.SetActive(isPressed);
ulong id = btn.ID;
List<GameObject> list = ListPool<GameObject>.Get();
this.m_CommonPool.GetActiveList(list);
ListPool<GameObject>.Release(list);
DlgBase<XChatView, XChatBehaviour>.singleton.SetActiveChannel((ChatChannelType)btn.ID);
if (isPressed)
{
this.m_CancelRecord = false;
this.m_DragDistance = Vector2.zero;
bool useApollo = XChatDocument.UseApollo;
if (useApollo)
{
XSingleton<XChatApolloMgr>.singleton.StartRecord(VoiceUsage.CHAT, new EndRecordCallBack(this.ChatOver));
}
else
{
XSingleton<XChatIFlyMgr>.singleton.StartRecord(VoiceUsage.CHAT, new EndRecordCallBack(this.ChatOver));
}
}
else
{
bool useApollo2 = XChatDocument.UseApollo;
if (useApollo2)
{
XSingleton<XChatApolloMgr>.singleton.StopRecord(this.m_CancelRecord);
}
else
{
XSingleton<XChatIFlyMgr>.singleton.StopRecord(this.m_CancelRecord);
}
this.m_CancelRecord = false;
}
}
public void OnVoiceButtonDrag(IXUIButton sp, Vector2 delta)
{
this.m_DragDistance += delta;
this.m_CancelRecord = (this.m_DragDistance.magnitude >= 100f);
}
private void ChatOver()
{
}
private bool OpenInputView(IXUIButton btn)
{
DlgBase<XChatInputView, XChatInputBehaviour>.singleton.ShowChatInput(new ChatInputStringBack(this.SendInputMsg));
DlgBase<XChatInputView, XChatInputBehaviour>.singleton.SetInputType(ChatInputType.EMOTION);
return true;
}
public void SendInputMsg(string str)
{
bool flag = !XSingleton<UiUtility>.singleton.IsSystemExpress(str);
if (flag)
{
XSingleton<XDebug>.singleton.AddLog("input: ", str, null, null, null, null, XDebugColor.XDebug_None);
DlgBase<XChatView, XChatBehaviour>.singleton.SendChatContent(str, ChatChannelType.Spectate, true, null, false, 0UL, 0f, false, false);
}
}
private void HideVoiceEff(object o = null)
{
this.ShowVoiceEff(this.m_btnMusic, false);
this.ShowVoiceEff(this.m_btnSpeak, false);
}
public void ShowVoiceEff(IXUIButton btn, bool show)
{
bool flag = btn != null && btn.gameObject != null;
if (flag)
{
Transform transform = btn.gameObject.transform.Find("Effect");
bool flag2 = transform != null;
if (flag2)
{
transform.gameObject.SetActive(show);
}
}
}
public bool OnMusicClick(IXUIButton btn)
{
this.ShowVoiceEff(btn, false);
this.OnRealVoiceClick(0);
return true;
}
public void SetMusic(bool on)
{
XApolloDocument specificDocument = XDocuments.GetSpecificDocument<XApolloDocument>(XApolloDocument.uuID);
bool joinRoomSucc = specificDocument.JoinRoomSucc;
if (joinRoomSucc)
{
IApolloManager xapolloManager = XSingleton<XUpdater.XUpdater>.singleton.XApolloManager;
bool flag = xapolloManager.openMusic != on;
if (flag)
{
xapolloManager.openMusic = on;
this.m_objMusic.SetActive(!on);
specificDocument.PlayGameSound(!on);
}
}
else
{
XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("VOICE_APOLLO_FAIL"), "fece00");
}
}
public bool OnSpeakClick(IXUIButton btn)
{
this.ShowVoiceEff(btn, false);
this.OnRealVoiceClick(1);
return true;
}
public void SetSpeak(bool on)
{
XApolloDocument specificDocument = XDocuments.GetSpecificDocument<XApolloDocument>(XApolloDocument.uuID);
bool joinRoomSucc = specificDocument.JoinRoomSucc;
if (joinRoomSucc)
{
IApolloManager xapolloManager = XSingleton<XUpdater.XUpdater>.singleton.XApolloManager;
bool flag = xapolloManager.openSpeak != on;
if (flag)
{
xapolloManager.openSpeak = on;
this.m_objSpeak.SetActive(!on);
}
}
else
{
XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("VOICE_APOLLO_FAIL"), "fece00");
}
}
private void OnRealVoiceClick(int click)
{
IApolloManager xapolloManager = XSingleton<XUpdater.XUpdater>.singleton.XApolloManager;
int speak = xapolloManager.openSpeak ? 1 : 0;
int music = xapolloManager.openMusic ? 1 : 0;
XApolloDocument specificDocument = XDocuments.GetSpecificDocument<XApolloDocument>(XApolloDocument.uuID);
XChatDocument specificDocument2 = XDocuments.GetSpecificDocument<XChatDocument>(XChatDocument.uuID);
ChatApollo.RowData apollo = specificDocument2.GetApollo(speak, music, click);
bool flag = apollo != null;
if (flag)
{
bool isWaittingJoinRoom = specificDocument.IsWaittingJoinRoom;
if (isWaittingJoinRoom)
{
XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("CHAT_APOLLO_WAIT"), "fece00");
}
else
{
bool joinRoomSucc = specificDocument.JoinRoomSucc;
if (joinRoomSucc)
{
bool flag2 = !string.IsNullOrEmpty(apollo.note);
if (flag2)
{
XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString(apollo.note), "fece00");
}
bool flag3 = apollo.opens == 1;
bool flag4 = xapolloManager.openSpeak != flag3;
if (flag4)
{
xapolloManager.openSpeak = flag3;
}
bool flag5 = this.m_objSpeak.activeSelf == flag3;
if (flag5)
{
this.m_objSpeak.SetActive(!flag3);
}
bool flag6 = apollo.openm == 1;
bool flag7 = xapolloManager.openMusic != flag6;
if (flag7)
{
xapolloManager.openMusic = flag6;
}
bool flag8 = this.m_objMusic.activeSelf == flag6;
if (flag8)
{
this.m_objMusic.SetActive(!flag6);
}
specificDocument.PlayGameSound(!flag6);
}
else
{
bool flag9 = !string.IsNullOrEmpty(apollo.note2);
if (flag9)
{
XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString(apollo.note2), "fece00");
}
}
}
uint state = 0u;
bool joinRoomSucc2 = specificDocument.JoinRoomSucc;
if (joinRoomSucc2)
{
bool flag10 = xapolloManager.openMusic && xapolloManager.openSpeak;
if (flag10)
{
state = 2u;
}
else
{
bool flag11 = xapolloManager.openSpeak || xapolloManager.openMusic;
if (flag11)
{
state = 1u;
}
}
}
specificDocument.SendStateServer(state);
}
}
}
}
|