188 lines
5.1 KiB
C#
188 lines
5.1 KiB
C#
|
using System;
|
|||
|
using Thousandto.Launcher.Form;
|
|||
|
using UnityEngine;
|
|||
|
|
|||
|
namespace Thousandto.Launcher.Form
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// 启动的主要窗体
|
|||
|
/// </summary>
|
|||
|
public class UILauncherMainForm : MonoBehaviour
|
|||
|
{
|
|||
|
|
|||
|
#region//静态方法的实例
|
|||
|
private static UILauncherMainForm _instance;
|
|||
|
public static UILauncherMainForm Instance
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _instance;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region//私有变量
|
|||
|
private UILoadingBasePanel _loadingPanel;
|
|||
|
private UIMessageBoxPanel _msgBoxPanel;
|
|||
|
private UIVersionPanel _verPanel;
|
|||
|
private UILanguagePanel _lanPanel;
|
|||
|
private UIFakeLoading _fakeLoading;
|
|||
|
private UIDownloading _downloading;
|
|||
|
private UIOtherPanel _otherPanel;
|
|||
|
private LoadStyleCode _loadStyle = LoadStyleCode.Fake;
|
|||
|
#endregion
|
|||
|
|
|||
|
#region//属性信息
|
|||
|
public bool IsInitliazed { get; private set; }
|
|||
|
|
|||
|
public UIFakeLoading FakeLoading
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _fakeLoading;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public UIDownloading Downloading
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _downloading;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 是否使用下载样式的进度
|
|||
|
/// </summary>
|
|||
|
public LoadStyleCode UseLoadStyle
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _loadStyle;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
if (_loadStyle != value)
|
|||
|
{
|
|||
|
_loadStyle = value;
|
|||
|
_downloading.Enabled = (_loadStyle != LoadStyleCode.Fake);
|
|||
|
_downloading.ShowDownloadStyle = (_loadStyle == LoadStyleCode.Download);
|
|||
|
_fakeLoading.Enabled = (_loadStyle == LoadStyleCode.Fake);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public UIVersionPanel VerPanel
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _verPanel;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public UILoadingBasePanel LoadingPanel
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return _loadingPanel;
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
//设置强制隐藏
|
|||
|
public void SetForceHide(bool value)
|
|||
|
{
|
|||
|
if (_loadingPanel != null)
|
|||
|
{
|
|||
|
_loadingPanel.IsForceHideBar = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void Initialize()
|
|||
|
{
|
|||
|
if (!IsInitliazed)
|
|||
|
{
|
|||
|
_loadingPanel = new UILoadingBasePanel();
|
|||
|
_loadingPanel.Initialize(this.transform.Find("LoadingPanel"));
|
|||
|
_loadingPanel.IsForceHideBar = !UnityEngine.Gonbest.MagicCube.AppPersistData.IsShowLoadingBar;
|
|||
|
|
|||
|
|
|||
|
_msgBoxPanel = new UIMessageBoxPanel();
|
|||
|
_msgBoxPanel.Initialize(this.transform.Find("MsgPanel"));
|
|||
|
|
|||
|
|
|||
|
_verPanel = new UIVersionPanel();
|
|||
|
_verPanel.Initialize(this.transform.Find("VersionPanel"));
|
|||
|
|
|||
|
|
|||
|
_lanPanel = new UILanguagePanel();
|
|||
|
_lanPanel.Initialize(this.transform.Find("LanguagePanel"));
|
|||
|
|
|||
|
_otherPanel = new UIOtherPanel();
|
|||
|
_otherPanel.Initialize(this.transform.Find("OtherPanel"));
|
|||
|
|
|||
|
|
|||
|
_fakeLoading = new UIFakeLoading(_loadingPanel);
|
|||
|
_downloading = new UIDownloading(_loadingPanel);
|
|||
|
IsInitliazed = true;
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
public void HideAll()
|
|||
|
{
|
|||
|
_loadingPanel.Hide();
|
|||
|
_msgBoxPanel.Hide();
|
|||
|
_verPanel.Hide();
|
|||
|
_lanPanel.Hide();
|
|||
|
_fakeLoading.Enabled = false;
|
|||
|
_downloading.Enabled = false;
|
|||
|
}
|
|||
|
|
|||
|
private void Awake()
|
|||
|
{
|
|||
|
DontDestroyOnLoad(gameObject);
|
|||
|
_instance = this;
|
|||
|
}
|
|||
|
|
|||
|
private void Update()
|
|||
|
{
|
|||
|
if (_fakeLoading != null) _fakeLoading.Update(Time.deltaTime);
|
|||
|
if (_downloading != null) _downloading.Update(Time.deltaTime);
|
|||
|
}
|
|||
|
|
|||
|
private void OnDestroy()
|
|||
|
{
|
|||
|
_instance = null;
|
|||
|
}
|
|||
|
|
|||
|
public void ShowMessage(string msg, string btn1Str, string btn2Str, Action<int> callBackAction = null)
|
|||
|
{
|
|||
|
_msgBoxPanel.SetData(msg, btn1Str, btn2Str, callBackAction);
|
|||
|
_msgBoxPanel.Show();
|
|||
|
}
|
|||
|
|
|||
|
public void ShowLanguage(string[] lans, Action<string> callBack)
|
|||
|
{
|
|||
|
_lanPanel.SetData(lans, callBack);
|
|||
|
_lanPanel.Show();
|
|||
|
}
|
|||
|
|
|||
|
public void ShowLauncher(int isloadStyle = 0)
|
|||
|
{
|
|||
|
_verPanel.SetData("-.-.-.-", "-.-.-.-");
|
|||
|
_verPanel.Show();
|
|||
|
_otherPanel.Show();
|
|||
|
_loadingPanel.Show();
|
|||
|
_loadingPanel.SetStepName("");
|
|||
|
_loadingPanel.SetProgress(0f);
|
|||
|
|
|||
|
_loadStyle = (LoadStyleCode)isloadStyle;
|
|||
|
_fakeLoading.Enabled = (_loadStyle == LoadStyleCode.Fake);
|
|||
|
_downloading.Enabled = (_loadStyle != LoadStyleCode.Fake);
|
|||
|
_downloading.ShowDownloadStyle = (_loadStyle == LoadStyleCode.Download);
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
}
|