summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/ReplaykitDlg.cs
blob: e00e54a7f1d58e88aa8ffe359350b2ee5b973063 (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
using System;
using System.Collections.Generic;
using MiniJSON;
using UILib;
using XMainClient.UI;
using XMainClient.UI.UICommon;
using XUpdater;
using XUtliPoolLib;

namespace XMainClient
{
	internal class ReplaykitDlg : DlgBase<ReplaykitDlg, ReplayBehaviour>
	{
		public override string fileName
		{
			get
			{
				return "Hall/ReplayDlg";
			}
		}

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

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

		public bool isPlaying = false;

		public bool isReadyPlaying = false;

		public static bool isCameraOpen = false;

		protected override void Init()
		{
			base.Init();
		}

		public override void RegisterEvent()
		{
			base.RegisterEvent();
			base.uiBehaviour.m_btn_camera.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnBtnCameraClick));
			base.uiBehaviour.m_btn_stop.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnStopClick));
			base.uiBehaviour.m_btn_mic.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnBtnMicClick));
			base.uiBehaviour.m_btn_switch.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnBtnSwitchClick));
		}

		public void CheckShow()
		{
			bool flag = this.isPlaying;
			if (flag)
			{
				this.SetVisible(true, true);
				this.Refresh();
			}
		}

		public void Show(bool show)
		{
			bool flag = DlgBase<BroadMiniDlg, BroadcastMiniBehaviour>.singleton.isBroadcast && show;
			if (flag)
			{
				XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("Replay_IsBroadcasting"), "fece00");
			}
			else
			{
				if (show)
				{
					this.SetVisible(true, true);
				}
				else
				{
					bool flag2 = base.IsLoaded();
					if (flag2)
					{
						this.SetVisible(false, true);
					}
				}
				if (show)
				{
					ReplaykitDlg.isCameraOpen = true;
					this.Refresh();
					this.OnBtnCameraClick(base.uiBehaviour.m_btn_camera);
				}
			}
		}

		private void Refresh()
		{
			base.uiBehaviour.m_spr_disable_camera.SetVisible(!ReplaykitDlg.isCameraOpen);
			bool flag = XSingleton<XUpdater.XUpdater>.singleton.XPlatform.CheckStatus("is_microphone_enabled", "");
			base.uiBehaviour.m_spr_disable_mic.SetVisible(!flag);
			XSingleton<XDebug>.singleton.AddLog("CAMERA: " + ReplaykitDlg.isCameraOpen.ToString(), " micro: " + flag.ToString(), null, null, null, null, XDebugColor.XDebug_None);
		}

		private bool OnBtnCameraClick(IXUIButton btn)
		{
			List<float> floatList = XSingleton<XGlobalConfig>.singleton.GetFloatList("ReplayPos");
			ReplaykitDlg.isCameraOpen = !ReplaykitDlg.isCameraOpen;
			base.uiBehaviour.m_spr_disable_camera.SetVisible(!ReplaykitDlg.isCameraOpen);
			bool flag = ReplaykitDlg.isCameraOpen;
			if (flag)
			{
				Dictionary<string, object> dictionary = new Dictionary<string, object>();
				dictionary["xPoint"] = floatList[0];
				dictionary["yPoint"] = floatList[1];
				dictionary["width"] = floatList[2];
				dictionary["height"] = floatList[3];
				string text = Json.Serialize(dictionary);
				XSingleton<XDebug>.singleton.AddLog("SetPortraitFrame paramStr = ", text, null, null, null, null, XDebugColor.XDebug_None);
				XSingleton<XUpdater.XUpdater>.singleton.XPlatform.SendGameExData("set_portrait_frame", text);
			}
			else
			{
				XSingleton<XDebug>.singleton.AddLog("remove_portrait_frame", null, null, null, null, null, XDebugColor.XDebug_None);
				XSingleton<XUpdater.XUpdater>.singleton.XPlatform.SendGameExData("remove_portrait_frame", "");
			}
			return true;
		}

		private bool OnBtnMicClick(IXUIButton btn)
		{
			bool flag = !XSingleton<XUpdater.XUpdater>.singleton.XPlatform.CheckStatus("is_microphone_enabled", "");
			Dictionary<string, object> dictionary = new Dictionary<string, object>();
			dictionary["enable"] = (flag ? "true" : "false");
			string text = Json.Serialize(dictionary);
			XSingleton<XDebug>.singleton.AddLog("SetPortraitFrame paramStr = ", text, null, null, null, null, XDebugColor.XDebug_None);
			base.uiBehaviour.m_spr_disable_mic.SetVisible(!flag);
			XSingleton<XUpdater.XUpdater>.singleton.XPlatform.SendGameExData("switch_microphone", text);
			return true;
		}

		public bool OnStopClick(IXUIButton btn)
		{
			this.Show(false);
			this.isReadyPlaying = false;
			this.isPlaying = false;
			XSingleton<XDebug>.singleton.AddLog("finish_broadcasting", null, null, null, null, null, XDebugColor.XDebug_None);
			XSingleton<XUpdater.XUpdater>.singleton.XPlatform.SendGameExData("finish_broadcasting", "");
			XSingleton<XUpdater.XUpdater>.singleton.XPlatform.SendGameExData("remove_portrait_frame", "");
			return true;
		}

		public void OpenRepaly()
		{
			XSingleton<XDebug>.singleton.AddLog("select_broadcast_service", null, null, null, null, null, XDebugColor.XDebug_None);
			XSingleton<XUpdater.XUpdater>.singleton.XPlatform.SendGameExData("select_broadcast_service", "");
			ReplaykitDlg.isCameraOpen = false;
			this.isReadyPlaying = true;
		}

		private bool OnBtnSwitchClick(IXUIButton btn)
		{
			XSingleton<XDebug>.singleton.AddLog("OnBtnSwitchClick", null, null, null, null, null, XDebugColor.XDebug_None);
			return true;
		}

		public void ResumeReplay()
		{
			bool flag = this.isPlaying;
			if (flag)
			{
				XSingleton<XDebug>.singleton.AddLog("resume_broadcasting", null, null, null, null, null, XDebugColor.XDebug_None);
				XSingleton<XUpdater.XUpdater>.singleton.XPlatform.SendGameExData("resume_broadcasting", "");
			}
		}
	}
}