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
|
using System;
using System.Collections.Generic;
using KKSG;
using MiniJSON;
using UILib;
using UnityEngine;
using XMainClient.UI.UICommon;
using XUpdater;
using XUtliPoolLib;
namespace XMainClient.UI
{
internal class XFriendsRankHandler : DlgHandlerBase
{
public IXUIScrollView m_ScrollView;
public IXUIWrapContent m_WrapContent;
public Transform m_MyRank;
public Transform m_NoFriend;
public IXUIButton m_PkHelpBtn;
public IXUILabel m_PkHelpLabel;
private Dictionary<Transform, string> rankItemDict = new Dictionary<Transform, string>();
public Dictionary<Transform, IXUITexture> _WrapTextureList = new Dictionary<Transform, IXUITexture>();
private string m_noticeFriendOpenID;
protected override void Init()
{
base.Init();
this.m_ScrollView = (base.PanelObject.transform.Find("FriendsList").GetComponent("XUIScrollView") as IXUIScrollView);
this.m_WrapContent = (base.PanelObject.transform.Find("FriendsList/Friendname").GetComponent("XUIWrapContent") as IXUIWrapContent);
this.m_MyRank = base.PanelObject.transform.Find("Myname/Tpl");
this.m_MyRank.gameObject.SetActive(false);
this.m_NoFriend = base.PanelObject.transform.Find("NoFriend");
this.m_PkHelpBtn = (base.PanelObject.transform.Find("T3/Help").GetComponent("XUIButton") as IXUIButton);
this.m_PkHelpLabel = (base.PanelObject.transform.Find("T3/Content").GetComponent("XUILabel") as IXUILabel);
this.m_PkHelpLabel.gameObject.SetActive(false);
}
public override void RegisterEvent()
{
base.RegisterEvent();
this.m_WrapContent.RegisterItemUpdateEventHandler(new WrapItemUpdateEventHandler(this._RankWrapListUpdated));
this.m_PkHelpBtn.RegisterPressEventHandler(new ButtonPressEventHandler(this.OnHelpBtnPress));
}
private void OnHelpBtnPress(IXUIButton btn, bool state)
{
bool flag = this.m_PkHelpLabel.gameObject.activeInHierarchy != state;
if (flag)
{
this.m_PkHelpLabel.gameObject.SetActive(state);
}
}
protected override void OnShow()
{
base.OnShow();
this.m_WrapContent.InitContent();
this.RefreshRankList();
this.m_PkHelpLabel.SetText(XSingleton<UiUtility>.singleton.ReplaceReturn(XStringDefineProxy.GetString("FRIEND_PK")));
this.m_PkHelpBtn.SetVisible(XSingleton<XGameSysMgr>.singleton.IsSystemOpened(XSysDefine.XSys_Friends_Pk));
}
protected override void OnHide()
{
base.OnHide();
this.rankItemDict.Clear();
this.ClearPreTabTextures();
}
public void ClearPreTabTextures()
{
foreach (KeyValuePair<Transform, IXUITexture> keyValuePair in this._WrapTextureList)
{
IXUITexture value = keyValuePair.Value;
value.ID = 0UL;
value.SetRuntimeTex(null, true);
}
this._WrapTextureList.Clear();
}
public void RefreshRankList()
{
bool flag = !base.IsVisible();
if (!flag)
{
this.rankItemDict.Clear();
XFriendsDocument specificDocument = XDocuments.GetSpecificDocument<XFriendsDocument>(XFriendsDocument.uuID);
bool flag2 = specificDocument.PlatFriendsRankList != null;
if (flag2)
{
XSingleton<XDebug>.singleton.AddLog("FriendsRank RefreshRankList doc.PlatFriendsRankList != null", null, null, null, null, null, XDebugColor.XDebug_None);
this.m_WrapContent.SetContentCount(specificDocument.PlatFriendsRankList.Count, false);
}
bool flag3 = specificDocument.SelfPlatRankInfo != null;
if (flag3)
{
XSingleton<XDebug>.singleton.AddLog("FriendsRank RefreshRankList doc.SelfPlatRankInfo != null", null, null, null, null, null, XDebugColor.XDebug_None);
this.SetMyRankInfo(specificDocument.SelfPlatRankInfo);
}
this.m_MyRank.gameObject.SetActive(specificDocument.SelfPlatRankInfo != null);
this.m_NoFriend.gameObject.SetActive(specificDocument.PlatFriendsRankList == null || specificDocument.PlatFriendsRankList.Count == 0);
this.m_ScrollView.ResetPosition();
}
}
private string SimplifyString(string s)
{
s = this.RemoveEmoji(s);
int num = 8;
bool flag = s.Length > num;
string result;
if (flag)
{
int num2 = s.Length - num;
string text = s.Substring(0, num / 2);
text = XSingleton<XCommon>.singleton.StringCombine(text, "...", s.Substring(num / 2 + num2));
result = text;
}
else
{
result = s;
}
return result;
}
private string RemoveEmoji(string s)
{
char[] array = s.ToCharArray();
List<char> list = new List<char>();
int i = 0;
while (i < array.Length - 1)
{
char c = array[i];
int num = (int)c;
bool flag = num == 55356;
if (flag)
{
char c2 = array[i + 1];
i += 2;
}
else
{
bool flag2 = num == 55357;
if (flag2)
{
char c2 = array[i + 1];
i += 2;
}
else
{
list.Add(array[i]);
i++;
}
}
}
bool flag3 = i == array.Length - 1;
if (flag3)
{
list.Add(array[i]);
}
return new string(list.ToArray());
}
private void SetBaseRankInfo(Transform item, PlatFriendRankInfo2Client rankInfo, int index)
{
bool flag = rankInfo == null;
if (!flag)
{
this.SetRank(item.gameObject, rankInfo.rank - 1u);
IXUILabel ixuilabel = item.Find("Name").GetComponent("XUILabel") as IXUILabel;
ixuilabel.SetText(this.SimplifyString(rankInfo.platfriendBaseInfo.nickname));
IXUILabel ixuilabel2 = item.Find("Level").GetComponent("XUILabel") as IXUILabel;
ixuilabel2.SetText(string.Format("Lv.{0}", rankInfo.level));
IXUILabel ixuilabel3 = item.Find("Value").GetComponent("XUILabel") as IXUILabel;
ixuilabel3.SetText(rankInfo.maxAbility.ToString());
IXUILabel ixuilabel4 = item.Find("vip").GetComponent("XUILabel") as IXUILabel;
ixuilabel4.SetText(rankInfo.vipLevel.ToString());
ixuilabel4.SetVisible(false);
IXUISprite ixuisprite = item.Find("headboard").GetComponent("XUISprite") as IXUISprite;
ixuisprite.SetSprite(XSingleton<XProfessionSkillMgr>.singleton.GetProfHeadIcon2(rankInfo.profession));
IXUISprite spr = item.Find("headboard/AvatarFrame").GetComponent("XUISprite") as IXUISprite;
XSingleton<UiUtility>.singleton.ParseHeadIcon((rankInfo.pre == null) ? new List<uint>() : rankInfo.pre.setid, spr);
IXUITexture ixuitexture = item.Find("platHead").GetComponent("XUITexture") as IXUITexture;
string bigpic = rankInfo.platfriendBaseInfo.bigpic;
XSingleton<XUICacheImage>.singleton.Load((bigpic != "") ? bigpic : string.Empty, ixuitexture, DlgBase<XFriendsView, XFriendsBehaviour>.singleton.uiBehaviour);
IXUISprite ixuisprite2 = item.Find("onling").GetComponent("XUISprite") as IXUISprite;
string sprite = rankInfo.isOnline ? "l_online_01" : "l_online_02";
ixuisprite2.SetSprite(sprite);
this._WrapTextureList[item] = ixuitexture;
}
}
private void SetMyRankInfo(PlatFriendRankInfo2Client rankInfo)
{
this.SetBaseRankInfo(this.m_MyRank, rankInfo, 99999);
GameObject gameObject = this.m_MyRank.Find("OutOfRange").gameObject;
gameObject.SetActive(rankInfo.rank == XFlowerRankDocument.INVALID_RANK);
GameObject gameObject2 = this.m_MyRank.Find("platHead/QQVIP").gameObject;
GameObject gameObject3 = this.m_MyRank.Find("platHead/QQSVIP").gameObject;
XPlatformAbilityDocument specificDocument = XDocuments.GetSpecificDocument<XPlatformAbilityDocument>(XPlatformAbilityDocument.uuID);
bool flag = specificDocument.QQVipInfo == null;
if (flag)
{
gameObject2.SetActive(false);
gameObject3.SetActive(false);
}
else
{
gameObject3.SetActive(specificDocument.QQVipInfo.is_svip);
gameObject2.SetActive(!specificDocument.QQVipInfo.is_svip && specificDocument.QQVipInfo.is_vip);
}
IXUISprite ixuisprite = this.m_MyRank.Find("wxLaunch").GetComponent("XUISprite") as IXUISprite;
ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnClickWXGameCenterLaunchIcon));
ixuisprite.SetVisible(XSingleton<XLoginDocument>.singleton.GetLaunchTypeServerInfo() == StartUpType.StartUp_WX && XSingleton<XLoginDocument>.singleton.Channel == XAuthorizationChannel.XAuthorization_WeChat);
IXUISprite ixuisprite2 = this.m_MyRank.Find("qqLaunch").GetComponent("XUISprite") as IXUISprite;
ixuisprite2.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnClickQQGameCenterLaunchIcon));
ixuisprite2.SetVisible(XSingleton<XLoginDocument>.singleton.GetLaunchTypeServerInfo() == StartUpType.StartUp_QQ && XSingleton<XLoginDocument>.singleton.Channel == XAuthorizationChannel.XAuthorization_QQ);
}
private void _RankWrapListUpdated(Transform item, int index)
{
XFriendsDocument specificDocument = XDocuments.GetSpecificDocument<XFriendsDocument>(XFriendsDocument.uuID);
bool flag = index >= specificDocument.PlatFriendsRankList.Count;
if (!flag)
{
PlatFriendRankInfo2Client platFriendRankInfo2Client = specificDocument.PlatFriendsRankList[index];
bool flag2 = platFriendRankInfo2Client == null;
if (!flag2)
{
this.rankItemDict[item] = platFriendRankInfo2Client.platfriendBaseInfo.openid;
this.SetBaseRankInfo(item, platFriendRankInfo2Client, index);
IXUIButton ixuibutton = item.Find("BtnSend").GetComponent("XUIButton") as IXUIButton;
IXUILabel ixuilabel = item.Find("BtnSend/t").GetComponent("XUILabel") as IXUILabel;
ixuibutton.ID = (ulong)((long)index);
ixuibutton.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnSendBtnClicked));
ixuibutton.SetEnable(!platFriendRankInfo2Client.hasGiveGift, false);
ixuilabel.SetEnabled(!platFriendRankInfo2Client.hasGiveGift);
ixuibutton.SetVisible(platFriendRankInfo2Client.platfriendBaseInfo.openid != XSingleton<XLoginDocument>.singleton.OpenID);
IXUIButton ixuibutton2 = item.Find("BtnPk").GetComponent("XUIButton") as IXUIButton;
ixuibutton2.ID = (ulong)((long)index);
ixuibutton2.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnSendPkBtnClicked));
bool flag3 = XSingleton<XGameSysMgr>.singleton.IsSystemOpened(XSysDefine.XSys_Friends_Pk);
if (flag3)
{
ixuibutton2.SetVisible(platFriendRankInfo2Client.platfriendBaseInfo.openid != XSingleton<XLoginDocument>.singleton.OpenID);
}
else
{
ixuibutton2.SetVisible(false);
}
GameObject gameObject = item.Find("platHead/QQVIP").gameObject;
GameObject gameObject2 = item.Find("platHead/QQSVIP").gameObject;
QQVipType qqvipType;
bool flag4 = specificDocument.FriendsVipInfo.TryGetValue(platFriendRankInfo2Client.platfriendBaseInfo.openid, out qqvipType);
if (flag4)
{
gameObject2.SetActive(qqvipType == QQVipType.SVip);
gameObject.SetActive(qqvipType == QQVipType.Vip);
}
else
{
gameObject2.SetActive(false);
gameObject.SetActive(false);
}
IXUISprite ixuisprite = item.Find("wxLaunch").GetComponent("XUISprite") as IXUISprite;
ixuisprite.SetVisible(platFriendRankInfo2Client.startType == 3);
ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnClickWXGameCenterLaunchIcon));
IXUISprite ixuisprite2 = item.Find("qqLaunch").GetComponent("XUISprite") as IXUISprite;
ixuisprite2.SetVisible(platFriendRankInfo2Client.startType == 2);
ixuisprite2.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnClickQQGameCenterLaunchIcon));
}
}
}
private void OnClickWXGameCenterLaunchIcon(IXUISprite btn)
{
XSingleton<UiUtility>.singleton.ShowSystemTip(XSingleton<XStringTable>.singleton.GetString("FriendRankWXGameCenterTip"), "fece00");
}
private void OnClickQQGameCenterLaunchIcon(IXUISprite btn)
{
XSingleton<UiUtility>.singleton.ShowSystemTip(XSingleton<XStringTable>.singleton.GetString("FriendRankQQGameCenterTip"), "fece00");
}
private void SetRank(GameObject go, uint rankIndex)
{
IXUILabel ixuilabel = go.transform.Find("Rank").GetComponent("XUILabel") as IXUILabel;
IXUISprite ixuisprite = go.transform.Find("RankImage").GetComponent("XUISprite") as IXUISprite;
bool flag = rankIndex == XRankDocument.INVALID_RANK;
if (flag)
{
ixuilabel.SetVisible(false);
ixuisprite.SetVisible(false);
}
else
{
string[] array = new string[]
{
"N1",
"N2",
"N3"
};
bool flag2 = rankIndex < 3u;
if (flag2)
{
ixuisprite.SetSprite(array[(int)rankIndex]);
ixuisprite.SetVisible(true);
ixuilabel.SetVisible(false);
}
else
{
ixuisprite.SetVisible(false);
ixuilabel.SetText("No." + (rankIndex + 1u));
ixuilabel.SetVisible(true);
}
}
}
private bool OnSendBtnClicked(IXUIButton btn)
{
int num = (int)btn.ID;
XFriendsDocument specificDocument = XDocuments.GetSpecificDocument<XFriendsDocument>(XFriendsDocument.uuID);
bool flag = num >= specificDocument.PlatFriendsRankList.Count;
bool result;
if (flag)
{
result = false;
}
else
{
PlatFriendRankInfo2Client platFriendRankInfo2Client = specificDocument.PlatFriendsRankList[num];
bool flag2 = platFriendRankInfo2Client == null;
if (flag2)
{
result = false;
}
else
{
specificDocument.SendGift2PlatFriend(platFriendRankInfo2Client.platfriendBaseInfo.openid);
result = true;
}
}
return result;
}
private bool OnSendPkBtnClicked(IXUIButton btn)
{
int num = (int)btn.ID;
XFriendsDocument specificDocument = XDocuments.GetSpecificDocument<XFriendsDocument>(XFriendsDocument.uuID);
bool flag = num >= specificDocument.PlatFriendsRankList.Count;
bool result;
if (flag)
{
result = false;
}
else
{
PlatFriendRankInfo2Client platFriendRankInfo2Client = specificDocument.PlatFriendsRankList[num];
bool flag2 = platFriendRankInfo2Client == null;
if (flag2)
{
result = false;
}
else
{
specificDocument.SendPk2PlatFriend(platFriendRankInfo2Client.platfriendBaseInfo.openid);
result = true;
}
}
return result;
}
private void ShareToQQFriend(string openID)
{
Dictionary<string, object> dictionary = new Dictionary<string, object>();
dictionary["act"] = 1;
dictionary["openId"] = openID;
dictionary["title"] = XSingleton<XGlobalConfig>.singleton.GetValue("PlatFriendShareTitle");
dictionary["summary"] = XSingleton<XGlobalConfig>.singleton.GetValue("PlatFriendShareSummary");
dictionary["targetUrl"] = XSingleton<XGlobalConfig>.singleton.GetValue("PlatFriendShareTargetUrlQQ");
dictionary["imageUrl"] = XSingleton<XGlobalConfig>.singleton.GetValue("PlatFriendShareImageUrlQQ");
dictionary["previewText"] = XSingleton<XGlobalConfig>.singleton.GetValue("PlatFriendSharePreviewTextQQ");
dictionary["gameTag"] = "MSG_HEART_SEND";
string text = Json.Serialize(dictionary);
XSingleton<XDebug>.singleton.AddLog("ShareToQQFriend paramStr = " + text, null, null, null, null, null, XDebugColor.XDebug_None);
XSingleton<XUpdater.XUpdater>.singleton.XPlatform.SendExtDara("share_send_to_friend_qq", text);
}
private void ShareToWXFriend(string openID)
{
Dictionary<string, object> dictionary = new Dictionary<string, object>();
dictionary["openId"] = openID;
dictionary["title"] = XSingleton<XGlobalConfig>.singleton.GetValue("PlatFriendShareTitle");
dictionary["description"] = XSingleton<XGlobalConfig>.singleton.GetValue("PlatFriendShareSummary");
dictionary["thumbMediaId"] = "";
dictionary["mediaTagName"] = "MSG_HEART_SEND";
dictionary["messageExt"] = "ShareWithWeixin";
string text = Json.Serialize(dictionary);
XSingleton<XDebug>.singleton.AddLog("ShareToWXFriend paramStr = " + text, null, null, null, null, null, XDebugColor.XDebug_None);
XSingleton<XUpdater.XUpdater>.singleton.XPlatform.SendExtDara("share_send_to_friend_wx", text);
}
public void OnRefreshSendGiftState(PlatFriendRankInfo2Client info)
{
bool flag = !base.IsVisible();
if (!flag)
{
foreach (KeyValuePair<Transform, string> keyValuePair in this.rankItemDict)
{
bool flag2 = keyValuePair.Value == info.platfriendBaseInfo.openid;
if (flag2)
{
IXUIButton ixuibutton = keyValuePair.Key.Find("BtnSend").GetComponent("XUIButton") as IXUIButton;
ixuibutton.SetEnable(!info.hasGiveGift, false);
break;
}
}
}
}
public void NoticeFriend(string openID)
{
bool flag = !base.IsVisible();
if (!flag)
{
this.m_noticeFriendOpenID = openID;
string @string = XStringDefineProxy.GetString("FRIEND_SEND_PLAT_FRIEND_TIP");
string string2 = XStringDefineProxy.GetString("FRIEND_SEND_PLAT_FRIEND_OK");
string string3 = XStringDefineProxy.GetString("FRIEND_SEND_PLAT_FRIEND_CANCEL");
DlgBase<ModalDlg, ModalDlgBehaviour>.singleton.SetVisible(true, true);
DlgBase<ModalDlg, ModalDlgBehaviour>.singleton.SetSingleButtonMode(false);
DlgBase<ModalDlg, ModalDlgBehaviour>.singleton.SetLabelsWithSymbols(@string, string2, string3);
DlgBase<ModalDlg, ModalDlgBehaviour>.singleton.SetModalCallback(new ButtonClickEventHandler(this.CheckNoticeFriend), null);
}
}
private bool CheckNoticeFriend(IXUIButton btn)
{
DlgBase<ModalDlg, ModalDlgBehaviour>.singleton.SetVisible(false, true);
XAuthorizationChannel channel = XSingleton<XLoginDocument>.singleton.Channel;
string @string = XStringDefineProxy.GetString("FRIEND_SEND_PLAT_FRIEND_TIP");
bool flag = channel == XAuthorizationChannel.XAuthorization_QQ;
if (flag)
{
@string = XStringDefineProxy.GetString("FRIEND_SEND_PLAT_FRIEND_TIP_QQ");
}
else
{
bool flag2 = channel == XAuthorizationChannel.XAuthorization_WeChat;
if (flag2)
{
@string = XStringDefineProxy.GetString("FRIEND_SEND_PLAT_FRIEND_TIP_WX");
}
}
string string2 = XStringDefineProxy.GetString("FRIEND_SEND_PLAT_FRIEND_OK2");
string string3 = XStringDefineProxy.GetString("FRIEND_SEND_PLAT_FRIEND_CANCEL2");
DlgBase<ModalDlg, ModalDlgBehaviour>.singleton.SetVisible(true, true);
DlgBase<ModalDlg, ModalDlgBehaviour>.singleton.SetSingleButtonMode(false);
DlgBase<ModalDlg, ModalDlgBehaviour>.singleton.SetLabelsWithSymbols(@string, string2, string3);
DlgBase<ModalDlg, ModalDlgBehaviour>.singleton.SetModalCallback(new ButtonClickEventHandler(this.OnEnsureNoticeFriend), null);
return true;
}
private bool OnEnsureNoticeFriend(IXUIButton btn)
{
DlgBase<ModalDlg, ModalDlgBehaviour>.singleton.SetVisible(false, true);
bool flag = XSingleton<XLoginDocument>.singleton.Channel == XAuthorizationChannel.XAuthorization_QQ;
if (flag)
{
this.ShareToQQFriend(this.m_noticeFriendOpenID);
}
else
{
bool flag2 = XSingleton<XLoginDocument>.singleton.Channel == XAuthorizationChannel.XAuthorization_WeChat;
if (flag2)
{
this.ShareToWXFriend(this.m_noticeFriendOpenID);
}
}
return true;
}
}
}
|