From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- Client/Assets/Scripts/XMainClient/RadioDlg.cs | 270 ++++++++++++++++++++++++++ 1 file changed, 270 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/RadioDlg.cs (limited to 'Client/Assets/Scripts/XMainClient/RadioDlg.cs') diff --git a/Client/Assets/Scripts/XMainClient/RadioDlg.cs b/Client/Assets/Scripts/XMainClient/RadioDlg.cs new file mode 100644 index 00000000..551d6604 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/RadioDlg.cs @@ -0,0 +1,270 @@ +using System; +using System.Collections.Generic; +using UILib; +using UnityEngine; +using XMainClient.UI; +using XMainClient.UI.UICommon; +using XUpdater; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class RadioDlg : DlgBase + { + private XRadioDocument radioDocument + { + get + { + return XDocuments.GetSpecificDocument(XRadioDocument.uuID); + } + } + + public override string fileName + { + get + { + return "Common/RadioDlg"; + } + } + + public override bool autoload + { + get + { + return true; + } + } + + public override bool isHideChat + { + get + { + return false; + } + } + + public override bool isMainUI + { + get + { + return true; + } + } + + public bool IsOpen + { + get + { + this.open_level = XSingleton.singleton.GetInt("RadioOpen"); + XPlayerAttributes xplayerData = XSingleton.singleton.XPlayerData; + return xplayerData != null && (ulong)xplayerData.Level >= (ulong)((long)this.open_level); + } + } + + private int open_level = 2; + + protected override void Init() + { + base.Init(); + this.open_level = XSingleton.singleton.GetInt("RadioOpen"); + } + + public override void RegisterEvent() + { + base.RegisterEvent(); + base.uiBehaviour.m_lblMicro.RegisterLabelClickEventHandler(new LabelClickEventHandler(this.OnMicroClick)); + base.uiBehaviour.m_btnRadio.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnRadioClick)); + } + + protected void SetPos() + { + XChatDocument specificDocument = XDocuments.GetSpecificDocument(XChatDocument.uuID); + bool flag = DlgBase.singleton.IsVisible(); + if (flag) + { + int type = 103; + ChatOpen.RowData yuyinRaw = specificDocument.GetYuyinRaw(type); + base.uiBehaviour.transform.localPosition = new Vector3((float)yuyinRaw.radioX, (float)yuyinRaw.radioY, 0f); + } + else + { + bool fakeShow = DlgBase.singleton.fakeShow; + if (fakeShow) + { + int type2 = 1; + ChatOpen.RowData yuyinRaw2 = specificDocument.GetYuyinRaw(type2); + base.uiBehaviour.transform.localPosition = new Vector3((float)yuyinRaw2.radioX, (float)yuyinRaw2.radioY, 0f); + } + } + } + + public void Show(bool show) + { + if (show) + { + XOptionsDocument specificDocument = XDocuments.GetSpecificDocument(XOptionsDocument.uuID); + bool flag = (DlgBase.singleton.fakeShow || DlgBase.singleton.IsVisible()) && specificDocument != null && specificDocument.GetValue(XOptionsDefine.OD_RADIO) == 1 && this.IsOpen; + if (flag) + { + this.SetVisible(true, true); + this.Refresh(this.radioDocument.roomState == XRadioDocument.BigRoomState.InRoom); + this.UpdateHostInfo(); + this.SetPos(); + } + else + { + this.SetVisible(false, true); + } + } + else + { + this.SetVisible(false, true); + } + } + + public void Process(bool open) + { + bool flag = XSingleton.singleton.CurrentStage != null && XSingleton.singleton.CurrentStage.Stage == EXStage.Hall; + if (flag) + { + this.Show(open); + bool flag2 = !open; + if (flag2) + { + this.QuitRoom(); + } + } + } + + public void Refresh(bool open) + { + bool flag = base.IsVisible(); + if (flag) + { + if (open) + { + bool flag2 = this.radioDocument.roomState == XRadioDocument.BigRoomState.InRoom; + if (flag2) + { + base.uiBehaviour.m_lblMicro.SetText(XStringDefineProxy.GetString("RADIO_HOST") + ": "); + base.uiBehaviour.m_sprPlay.SetSprite("icon_pause"); + } + } + else + { + bool flag3 = this.radioDocument.roomState == XRadioDocument.BigRoomState.OutRoom || this.radioDocument.roomState == XRadioDocument.BigRoomState.Processing; + if (flag3) + { + base.uiBehaviour.m_lblMicro.SetText(XStringDefineProxy.GetString("RADIO_LISTEN")); + base.uiBehaviour.m_sprPlay.SetSprite("icon_play"); + } + } + } + } + + public void JoinRoom() + { + bool isBroadcast = DlgBase.singleton.isBroadcast; + if (isBroadcast) + { + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("ERR_FM_FORBID2"), "fece00"); + } + else + { + bool flag = this.radioDocument.roomState == XRadioDocument.BigRoomState.OutRoom; + if (flag) + { + this.radioDocument.JoinBigRoom(); + } + } + } + + public void QuitRoom() + { + bool flag = this.radioDocument.roomState == XRadioDocument.BigRoomState.InRoom; + if (flag) + { + this.radioDocument.QuitBigRoom(); + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("FM_LEAVE_SUCCESS"), "fece00"); + this.Refresh(false); + } + } + + public void UpdateHostInfo() + { + bool flag = base.IsVisible() && this.radioDocument.roomState == XRadioDocument.BigRoomState.InRoom; + if (flag) + { + List hostlist = this.radioDocument.hostlist; + bool flag2 = hostlist.Count <= 0; + if (flag2) + { + base.uiBehaviour.m_lblMicro.SetText(XStringDefineProxy.GetString("ERR_FM_NOANCHOR_STRING")); + } + else + { + XSingleton.singleton.CleanStringCombine(); + XSingleton.singleton.AppendString(XStringDefineProxy.GetString("RADIO_HOST"), ": "); + for (int i = 0; i < hostlist.Count; i++) + { + XSingleton.singleton.AppendString(hostlist[i], " "); + } + base.uiBehaviour.m_lblMicro.SetText(XSingleton.singleton.GetString()); + } + } + } + + private bool OnRadioClick(IXUIButton sp) + { + bool flag = this.radioDocument.roomState == XRadioDocument.BigRoomState.InRoom; + if (flag) + { + this.QuitRoom(); + } + else + { + bool flag2 = this.radioDocument.roomState == XRadioDocument.BigRoomState.Processing; + if (flag2) + { + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("FM_CLICKTOOFAST"), "fece00"); + } + else + { + bool flag3 = this.radioDocument.roomState == XRadioDocument.BigRoomState.OutRoom; + if (flag3) + { + this.JoinRoom(); + } + } + } + return true; + } + + private void OnMicroClick(IXUILabel lbl) + { + bool isHost = this.radioDocument.isHost; + if (isHost) + { + bool flag = this.radioDocument.roomState == XRadioDocument.BigRoomState.InRoom; + if (flag) + { + bool openSpeak = XSingleton.singleton.XApolloManager.openSpeak; + XSingleton.singleton.XApolloManager.openSpeak = !openSpeak; + PtcC2M_HandleMicphone ptcC2M_HandleMicphone = new PtcC2M_HandleMicphone(); + bool openSpeak2 = XSingleton.singleton.XApolloManager.openSpeak; + if (openSpeak2) + { + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("FM_OPENMIC"), "fece00"); + ptcC2M_HandleMicphone.Data.param = true; + } + else + { + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("FM_CLOSEMIC"), "fece00"); + ptcC2M_HandleMicphone.Data.param = false; + } + XSingleton.singleton.Send(ptcC2M_HandleMicphone); + } + } + } + } +} -- cgit v1.1-26-g67d0