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
|
using System;
using System.Collections.Generic;
using UILib;
using UnityEngine;
using XMainClient.UI.UICommon;
using XUtliPoolLib;
namespace XMainClient
{
internal class XTeamSmallChatHandler : DlgHandlerBase
{
private ChatChannelType CurrentChannel
{
get
{
return this.teamDoc.bInTeam ? ChatChannelType.Team : ChatChannelType.World;
}
}
private static int MSG_DISPLAY_COUNT = 3;
private XUIPool m_TextPool = new XUIPool(XSingleton<XGameUI>.singleton.m_uiTool);
private XUIPool m_AudioPool = new XUIPool(XSingleton<XGameUI>.singleton.m_uiTool);
private IXUIButton m_BtnVoice;
private GameObject m_SpeakInfo;
private List<XSmallChatInfo> m_ChatList = new List<XSmallChatInfo>();
private XChatDocument chatDoc;
private XTeamDocument teamDoc;
private Vector2 m_DragDistance = Vector2.zero;
private bool m_CancelRecord = false;
protected override void Init()
{
base.Init();
this.chatDoc = XDocuments.GetSpecificDocument<XChatDocument>(XChatDocument.uuID);
this.teamDoc = XDocuments.GetSpecificDocument<XTeamDocument>(XTeamDocument.uuID);
this.m_BtnVoice = (base.PanelObject.transform.Find("BtnVoice").GetComponent("XUIButton") as IXUIButton);
this.m_SpeakInfo = base.PanelObject.transform.Find("SpeakPanel/SpeakInfo").gameObject;
}
public override void RegisterEvent()
{
base.RegisterEvent();
this.m_BtnVoice.RegisterPressEventHandler(new ButtonPressEventHandler(this._OnVoiceBtn));
this.m_BtnVoice.RegisterDragEventHandler(new ButtonDragEventHandler(this._OnVoiceButtonDrag));
}
public override void OnUnload()
{
base.OnUnload();
}
protected override void OnShow()
{
base.OnShow();
this.m_SpeakInfo.SetActive(false);
}
private void _OnVoiceButtonDrag(IXUIButton sp, Vector2 delta)
{
this.m_DragDistance += delta;
bool flag = this.m_DragDistance.magnitude >= 100f;
if (flag)
{
this.m_CancelRecord = true;
}
else
{
this.m_CancelRecord = false;
}
}
private void _OnVoiceBtn(IXUIButton btn, bool state)
{
if (state)
{
this.m_DragDistance = Vector2.zero;
bool useApollo = XChatDocument.UseApollo;
if (useApollo)
{
XSingleton<XChatApolloMgr>.singleton.StartRecord(VoiceUsage.CHAT, null);
}
else
{
XSingleton<XChatIFlyMgr>.singleton.StartRecord(VoiceUsage.CHAT, null);
}
}
else
{
DlgBase<XChatView, XChatBehaviour>.singleton.SetActiveChannel(ChatChannelType.Team);
bool useApollo2 = XChatDocument.UseApollo;
if (useApollo2)
{
XSingleton<XChatApolloMgr>.singleton.StopRecord(this.m_CancelRecord);
}
else
{
XSingleton<XChatIFlyMgr>.singleton.StopRecord(this.m_CancelRecord);
}
}
}
private void _OnChatBgClicked(IXUISprite iSp)
{
DlgBase<XChatView, XChatBehaviour>.singleton.ShowChannel(this.CurrentChannel);
}
public void RefreshPage()
{
List<ChatInfo> chatInfoList = this.chatDoc.GetChatInfoList(this.CurrentChannel);
int num = (chatInfoList != null) ? Math.Min(chatInfoList.Count, XTeamSmallChatHandler.MSG_DISPLAY_COUNT) : 0;
int num2 = Math.Max(0, num - XTeamSmallChatHandler.MSG_DISPLAY_COUNT);
this.m_ChatList.Clear();
this.m_TextPool.FakeReturnAll();
this.m_AudioPool.FakeReturnAll();
for (int i = num2; i < num; i++)
{
this._SetChatInfo(chatInfoList[i]);
}
this.m_TextPool.ActualReturnAll(false);
this.m_AudioPool.ActualReturnAll(false);
this._SetAllChatInfoPosition();
}
public void OnGetChatInfo(ChatInfo newInfo)
{
bool flag = newInfo.mChannelId != this.CurrentChannel;
if (!flag)
{
this._SetChatInfo(newInfo);
this._SetAllChatInfoPosition();
}
}
private void _SetChatInfo(ChatInfo info)
{
XSmallChatInfo xsmallChatInfo = this._CreateSmallChatInfo();
xsmallChatInfo.info = info;
xsmallChatInfo.uiobject = (info.isAudioChat ? this.m_AudioPool.FetchGameObject(false) : this.m_TextPool.FetchGameObject(false));
this._SetChatUI(xsmallChatInfo.info, xsmallChatInfo.uiobject);
this.m_ChatList.Add(xsmallChatInfo);
}
private void _SetAllChatInfoPosition()
{
int num = 0;
for (int i = 0; i < this.m_ChatList.Count; i++)
{
GameObject uiobject = this.m_ChatList[i].uiobject;
IXUILabel ixuilabel = uiobject.transform.Find("content").GetComponent("XUILabel") as IXUILabel;
uiobject.transform.localPosition = new Vector3(0f, (float)(-(float)num));
num += (int)ixuilabel.GetPrintSize().y;
}
}
private XSmallChatInfo _CreateSmallChatInfo()
{
bool flag = this.m_ChatList.Count == XTeamSmallChatHandler.MSG_DISPLAY_COUNT;
XSmallChatInfo xsmallChatInfo;
if (flag)
{
xsmallChatInfo = this.m_ChatList[0];
for (int i = 0; i < this.m_ChatList.Count - 1; i++)
{
this.m_ChatList[i] = this.m_ChatList[i + 1];
}
this.m_ChatList.RemoveAt(this.m_ChatList.Count - 1);
}
else
{
xsmallChatInfo = new XSmallChatInfo();
}
bool flag2 = xsmallChatInfo.info != null && xsmallChatInfo.uiobject != null;
if (flag2)
{
bool isAudioChat = xsmallChatInfo.info.isAudioChat;
if (isAudioChat)
{
this.m_AudioPool.ReturnInstance(xsmallChatInfo.uiobject, false);
}
else
{
this.m_TextPool.ReturnInstance(xsmallChatInfo.uiobject, false);
}
}
return xsmallChatInfo;
}
private void _SetChatUI(ChatInfo info, GameObject go)
{
XChatSmallView.InitMiniChatUI(info, go);
}
}
}
|