summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/XQuickReplyDocument.cs
blob: 9a14a1f0cb1529689aa221d671cdcc3cd740584a (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
using System;
using System.Collections.Generic;
using KKSG;
using XMainClient.UI;
using XUtliPoolLib;

namespace XMainClient
{
	internal class XQuickReplyDocument : XDocComponent
	{
		public override uint ID
		{
			get
			{
				return XQuickReplyDocument.uuID;
			}
		}

		public QuickReplyDlg QuickReplyView { get; set; }

		public new static readonly uint uuID = XSingleton<XCommon>.singleton.XHash("QuickReplyDocument");

		public static XTableAsyncLoader AsyncLoader = new XTableAsyncLoader();

		private static QuickReplyTable _reader = new QuickReplyTable();

		private static Dictionary<int, List<QuickReplyTable.RowData>> _quickReplyTables = new Dictionary<int, List<QuickReplyTable.RowData>>();

		public static void Execute(OnLoadedCallback callBack = null)
		{
			XQuickReplyDocument.AsyncLoader.AddTask("Table/QuickReply", XQuickReplyDocument._reader, false);
			XQuickReplyDocument.AsyncLoader.Execute(callBack);
			XQuickReplyDocument._quickReplyTables.Clear();
		}

		public static void OnTableLoaded()
		{
			int i = 0;
			int num = XQuickReplyDocument._reader.Table.Length;
			while (i < num)
			{
				QuickReplyTable.RowData rowData = XQuickReplyDocument._reader.Table[i];
				List<QuickReplyTable.RowData> list;
				bool flag = !XQuickReplyDocument._quickReplyTables.TryGetValue(rowData.Type, out list);
				if (flag)
				{
					list = new List<QuickReplyTable.RowData>();
					XQuickReplyDocument._quickReplyTables.Add(rowData.Type, list);
				}
				list.Add(rowData);
				i++;
			}
		}

		public QuickReplyTable.RowData GetRowData(int id)
		{
			return XQuickReplyDocument._reader.GetByID(id);
		}

		public List<QuickReplyTable.RowData> GetQuickReplyList(int type)
		{
			List<QuickReplyTable.RowData> result = null;
			XQuickReplyDocument._quickReplyTables.TryGetValue(type, out result);
			return result;
		}

		public void GetThanksForBonus(ulong boundsID)
		{
			RpcC2G_ThanksForBonus rpcC2G_ThanksForBonus = new RpcC2G_ThanksForBonus();
			rpcC2G_ThanksForBonus.oArg.bonusID = (uint)boundsID;
			XSingleton<XClientNetwork>.singleton.Send(rpcC2G_ThanksForBonus);
		}

		public void OnThankForBonus(ThanksForBonusArg arg, ThanksForBonusRes res)
		{
			bool flag = res.errorcode > ErrorCode.ERR_SUCCESS;
			if (flag)
			{
				XSingleton<UiUtility>.singleton.ShowSystemTip(res.errorcode, "fece00");
			}
			else
			{
				XGuildRedPacketDocument specificDocument = XDocuments.GetSpecificDocument<XGuildRedPacketDocument>(XGuildRedPacketDocument.uuID);
				specificDocument.SetCanThank(false);
			}
		}

		public void GetAskForCheckInBonus()
		{
			RpcC2G_AskForCheckInBonus rpc = new RpcC2G_AskForCheckInBonus();
			XSingleton<XClientNetwork>.singleton.Send(rpc);
		}

		public void OnAskForCheckInBonus(AskForCheckInBonusArg arg, AskForCheckInBonusRes res)
		{
			bool flag = res.errorcode > ErrorCode.ERR_SUCCESS;
			if (flag)
			{
				XSingleton<UiUtility>.singleton.ShowSystemTip(res.errorcode, "fece00");
			}
			else
			{
				XGuildRedPacketDocument specificDocument = XDocuments.GetSpecificDocument<XGuildRedPacketDocument>(XGuildRedPacketDocument.uuID);
				specificDocument.GuildBonus.leftAskBonusTime = (double)XSingleton<XGlobalConfig>.singleton.GetInt("GuildBonusAskTimeSpan");
			}
		}

		protected override void OnReconnected(XReconnectedEventArgs arg)
		{
		}
	}
}