116 lines
3.3 KiB
C#
116 lines
3.3 KiB
C#
namespace FlowerPower
|
|
{
|
|
using System;
|
|
using FairyGUI;
|
|
using UnityEngine;
|
|
using System.Globalization;
|
|
|
|
public class PrivacyUI : BaseUI
|
|
{
|
|
private PrivacyUICtrl ctrl;
|
|
private PrivacyModel model;
|
|
private FGUI.PC_privacy.com_privacy ui;
|
|
|
|
private string content;
|
|
|
|
private bool isTerm;
|
|
|
|
public PrivacyUI(PrivacyUICtrl ctrl) : base(ctrl)
|
|
{
|
|
uiName = UIConst.PrivacyUI;
|
|
this.ctrl = ctrl;
|
|
}
|
|
|
|
protected override void SetUIInfo(UIInfo uiInfo)
|
|
{
|
|
uiInfo.packageName = "PC_privacy";
|
|
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.PC_privacy.com_privacy;
|
|
}
|
|
|
|
protected override void OnOpenBefore(object args)
|
|
{
|
|
if (args != null)
|
|
{
|
|
isTerm = (bool)args;
|
|
}
|
|
|
|
InitView();
|
|
}
|
|
|
|
protected override void OnOpen(object args)
|
|
{
|
|
ui?.FadeIn();
|
|
}
|
|
|
|
#endregion
|
|
|
|
private void InitView()
|
|
{
|
|
ui.title.text = isTerm ? "Terms of Service" : "Privacy Policy";
|
|
MarkdownTextManager.Instance.AddMarkdownToParentAsRichText(ui.text_list, isTerm ? "user" : "privacy",
|
|
new Color(0.4f, 0.22f, 0.11f), (b, state) =>
|
|
{
|
|
|
|
});
|
|
|
|
// LoadKit.Instance.LoadAsset<TextAsset>("TextAsset", isTerm ? "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.24f, 0.31f, 0.42f, 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;
|
|
}
|
|
}
|
|
} |