summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/UI/XFlowerReplyView.cs
blob: 34f6c0832b804fab4cd52552c894c836eeac9ec8 (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
using System;
using UILib;
using UnityEngine;
using XMainClient.UI.UICommon;
using XUtliPoolLib;

namespace XMainClient.UI
{
	internal class XFlowerReplyView : DlgBase<XFlowerReplyView, XFlowerReplyBehavior>
	{
		public override string fileName
		{
			get
			{
				return "GameSystem/FlowerReply";
			}
		}

		public override int layer
		{
			get
			{
				return 100;
			}
		}

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

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

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

		public Action OnClosed;

		private XFlowerReplyDocument _Doc;

		private int _flowerID;

		private ulong _senderID;

		private string _senderName;

		private int _senderPower;

		private int _senderProfession;

		private int _senderVip;

		private int _sendCount;

		private Vector2 m_DragDistance = Vector2.zero;

		private bool m_CancelRecord = false;

		public void ShowView(int itemID, ulong senderID, string senderName, int senderPower, int senderProfession, int senderVip, int sendCount)
		{
			this._flowerID = itemID;
			this._senderID = senderID;
			this._senderName = senderName;
			this._senderPower = senderPower;
			this._senderProfession = senderProfession;
			this._senderVip = senderVip;
			this._sendCount = sendCount;
			this.SetVisibleWithAnimation(true, null);
		}

		protected override void Init()
		{
			this._Doc = XDocuments.GetSpecificDocument<XFlowerReplyDocument>(XFlowerReplyDocument.uuID);
			this._Doc.View = this;
		}

		protected override void OnShow()
		{
			base.OnShow();
			this.UpdateReplyBg();
			base.uiBehaviour.m_SpeakPanel.gameObject.SetActive(false);
			base.uiBehaviour.m_SenderName.SetText(this._senderName);
			base.uiBehaviour.m_SenderCount.SetText(this._sendCount.ToString());
			base.uiBehaviour.m_FlowerName.SetText(XSingleton<UiUtility>.singleton.ChooseProfString(XBagDocument.GetItemConf(this._flowerID).ItemName, 0u));
			base.uiBehaviour.m_ThxContent.SetText(this._Doc.GetThxContent(this._flowerID, this._sendCount));
		}

		private void UpdateReplyBg()
		{
			int num = this._flowerID - XFastEnumIntEqualityComparer<ItemEnum>.ToInt(ItemEnum.FLOWER_RED_ROSE);
			for (int i = 0; i < base.uiBehaviour.m_ReplayBgList.Count; i++)
			{
				base.uiBehaviour.m_ReplayBgList[i].SetActive(i == num);
			}
		}

		public override void RegisterEvent()
		{
			base.RegisterEvent();
			base.uiBehaviour.m_Close.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnCloseClicked));
			base.uiBehaviour.m_Voice.RegisterPressEventHandler(new ButtonPressEventHandler(this.OnVoicePressButton));
			base.uiBehaviour.m_Voice.RegisterDragEventHandler(new ButtonDragEventHandler(this.OnVoiceDragButton));
			base.uiBehaviour.m_QuickThx.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnReplyClicked));
		}

		private bool OnReplyClicked(IXUIButton button)
		{
			DlgBase<XChatView, XChatBehaviour>.singleton.ChatFriendId = this._senderID;
			ChatInfo chatInfo = new ChatInfo();
			chatInfo.mTime = DateTime.Now;
			chatInfo.isSelfSender = true;
			chatInfo.mReceiverName = this._senderName;
			chatInfo.mReceiverId = this._senderID;
			chatInfo.mReciverPowerPoint = (uint)this._senderPower;
			chatInfo.mRecieverProfession = (uint)this._senderProfession;
			chatInfo.mReceiverVip = (uint)this._senderVip;
			XChatDocument specificDocument = XDocuments.GetSpecificDocument<XChatDocument>(XChatDocument.uuID);
			specificDocument.AddChatinfo2FriendList(chatInfo);
			DlgBase<XChatView, XChatBehaviour>.singleton.SendChatContent(XStringDefineProxy.GetString("FLOWER_QUICK_THX"), ChatChannelType.Friends, true, null, false, 0UL, 0f, false, false);
			XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("INVITATION_SENT_NOTIFICATION"), "fece00");
			this.CloseDlg();
			return true;
		}

		private void CloseDlg()
		{
			this.SetVisibleWithAnimation(false, null);
		}

		protected override void OnHide()
		{
			base.OnHide();
			bool flag = this.OnClosed != null;
			if (flag)
			{
				this.OnClosed();
			}
		}

		private void OnCloseClicked(IXUISprite go)
		{
			this.CloseDlg();
		}

		private void OnVoicePressButton(IXUIButton button, bool state)
		{
			if (state)
			{
				this.m_DragDistance = Vector2.zero;
				bool useApollo = XChatDocument.UseApollo;
				if (useApollo)
				{
					XSingleton<XChatApolloMgr>.singleton.StartRecord(VoiceUsage.FLOWER_REPLY, null);
				}
				else
				{
					XSingleton<XChatIFlyMgr>.singleton.StartRecord(VoiceUsage.FLOWER_REPLY, null);
				}
			}
			else
			{
				DlgBase<XChatView, XChatBehaviour>.singleton.ChatFriendId = this._senderID;
				ChatInfo chatInfo = new ChatInfo();
				chatInfo.mTime = DateTime.Now;
				chatInfo.isSelfSender = true;
				chatInfo.mReceiverName = this._senderName;
				chatInfo.mReceiverId = this._senderID;
				chatInfo.mReciverPowerPoint = (uint)this._senderPower;
				chatInfo.mRecieverProfession = (uint)this._senderProfession;
				chatInfo.mReceiverVip = (uint)this._senderVip;
				XChatDocument specificDocument = XDocuments.GetSpecificDocument<XChatDocument>(XChatDocument.uuID);
				specificDocument.AddChatinfo2FriendList(chatInfo);
				XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("INVITATION_SENT_NOTIFICATION"), "fece00");
				bool useApollo2 = XChatDocument.UseApollo;
				if (useApollo2)
				{
					XSingleton<XChatApolloMgr>.singleton.StopRecord(this.m_CancelRecord);
				}
				else
				{
					XSingleton<XChatIFlyMgr>.singleton.StopRecord(this.m_CancelRecord);
				}
				bool flag = !this.m_CancelRecord;
				if (flag)
				{
					this.CloseDlg();
				}
			}
		}

		private void OnVoiceDragButton(IXUIButton button, Vector2 delta)
		{
			this.m_DragDistance += delta;
			bool flag = this.m_DragDistance.magnitude >= 100f;
			if (flag)
			{
				this.m_CancelRecord = true;
			}
			else
			{
				this.m_CancelRecord = false;
			}
		}
	}
}