129 lines
3.9 KiB
C#
129 lines
3.9 KiB
C#
using SGModule.MarkdownKit;
|
|
|
|
namespace LoveLegend
|
|
{
|
|
using System;
|
|
using FairyGUI;
|
|
using UnityEngine;
|
|
using System.Globalization;
|
|
|
|
public class PrivacyUI : BaseUI
|
|
{
|
|
private PrivacyUICtrl ctrl;
|
|
private PrivacyModel model;
|
|
private FGUI.ZM_Privacy_24.com_privacy ui;
|
|
|
|
private string content;
|
|
|
|
private int isTerm;
|
|
|
|
public PrivacyUI(PrivacyUICtrl ctrl) : base(ctrl)
|
|
{
|
|
uiName = UIConst.PrivacyUI;
|
|
this.ctrl = ctrl;
|
|
}
|
|
|
|
protected override void SetUIInfo(UIInfo uiInfo)
|
|
{
|
|
uiInfo.packageName = "ZM_Privacy_24";
|
|
uiInfo.assetName = "com_privacy";
|
|
uiInfo.layerType = UILayerType.Popup;
|
|
uiInfo.isNeedOpenAnim = true;
|
|
uiInfo.isNeedCloseAnim = true;
|
|
uiInfo.isNeedUIMask = true;
|
|
}
|
|
|
|
#region 生命周期
|
|
|
|
protected override void OnInit()
|
|
{
|
|
}
|
|
|
|
protected override void OnClose()
|
|
{
|
|
ui?.FadeOut();
|
|
}
|
|
|
|
protected override void OnBind()
|
|
{
|
|
ui = baseUI as FGUI.ZM_Privacy_24.com_privacy;
|
|
}
|
|
|
|
protected override void OnOpenBefore(object args)
|
|
{
|
|
|
|
if (args != null)
|
|
{
|
|
isTerm = (int)args;
|
|
|
|
}
|
|
|
|
InitView();
|
|
|
|
ui.show.selectedIndex = isTerm != 2 ? 0 : 1;
|
|
}
|
|
|
|
protected override void OnOpen(object args)
|
|
{
|
|
ui?.FadeIn();
|
|
}
|
|
|
|
#endregion
|
|
|
|
private void InitView()
|
|
{
|
|
bool BisTerm = isTerm < 2 && isTerm == 1 ;
|
|
string title = BisTerm ? Language.GetContent("terms_service") : Language.GetContent("privacy");
|
|
ui.title.text = isTerm == 2 ? "View Credits" : title;
|
|
|
|
var color = new Color(255 / 255f, 232 / 255f, 217 / 255f, 1f);
|
|
MarkdownKit.Instance.ShowAsRichText(ui.text_list, BisTerm ? "user" : "privacy", color, (success, state) => {
|
|
if (success) {
|
|
Debug.Log("内容加载成功!当前状态:" + state);
|
|
}
|
|
else {
|
|
Debug.LogError("内容加载失败!当前状态:" + state);
|
|
}
|
|
}, 44);
|
|
|
|
// LoadKit.Instance.LoadAsset<TextAsset>("TextAsset", BisTerm ? "Term" : "Privacy", (txt) =>
|
|
// {
|
|
// content = txt.text;
|
|
//
|
|
// var str = getstr(content, 16327);
|
|
//
|
|
// foreach (var t in str)
|
|
// {
|
|
// var aRichTextField = new GRichTextField();
|
|
// aRichTextField.SetSize(GRoot.inst.width, 100);
|
|
// aRichTextField.color = new Color(0.64f, 0.36f, 0.12f, 1f);
|
|
// // aRichTextField.strokeColor = Color.black;
|
|
// // aRichTextField.stroke = 1;
|
|
// aRichTextField.textFormat.size = 44;
|
|
// aRichTextField.autoSize = AutoSizeType.Height;
|
|
// aRichTextField.AddRelation(GRoot.inst, RelationType.Width);
|
|
// aRichTextField.text = t;
|
|
// ui.text_list.AddChild(aRichTextField);
|
|
// }
|
|
//
|
|
// ui.text_list.EnsureBoundsCorrect();
|
|
// });
|
|
|
|
ui.btn_close.SetClick(CtrlCloseUI);
|
|
}
|
|
|
|
public string[] getstr(string strs, int len)
|
|
{
|
|
double i = strs.Length;
|
|
var array = new string[int.Parse(Math.Ceiling(i / len).ToString(CultureInfo.InvariantCulture))];
|
|
for (var j = 0; j < array.Length; j++)
|
|
{
|
|
len = len <= strs.Length ? len : strs.Length;
|
|
array[j] = strs[..len];
|
|
strs = strs.Substring(len, strs.Length - len);
|
|
}
|
|
|
|
return array;
|
|
}
|
|
}
|
|
} |