78 lines
2.1 KiB
C#
78 lines
2.1 KiB
C#
|
|
using System.Collections;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using UnityEngine;
|
||
|
|
using QFramework;
|
||
|
|
using System;
|
||
|
|
using QFramework.Example;
|
||
|
|
using System.Linq;
|
||
|
|
using TreeEditor;
|
||
|
|
public class TextWindowAction : IAction
|
||
|
|
{
|
||
|
|
public ulong ActionID { get; set; }
|
||
|
|
public bool Deinited { get; set; }
|
||
|
|
public bool Paused { get; set; }
|
||
|
|
public ActionStatus Status { get; set; }
|
||
|
|
|
||
|
|
private static readonly SimpleObjectPool<TextWindowAction> mPool =
|
||
|
|
new SimpleObjectPool<TextWindowAction>(() => new TextWindowAction(), null, 10);
|
||
|
|
string text = string.Empty;
|
||
|
|
Dictionary<string, string> datas;
|
||
|
|
public static TextWindowAction Allocate(string text, Dictionary<string, string> datas, System.Action onDelayFinish = null)
|
||
|
|
{
|
||
|
|
var retNode = mPool.Allocate();
|
||
|
|
retNode.ActionID = ActionKit.ID_GENERATOR++;
|
||
|
|
retNode.Deinited = false;
|
||
|
|
retNode.Reset();
|
||
|
|
retNode.text = text;
|
||
|
|
retNode.datas = datas;
|
||
|
|
return retNode;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
public void Deinit()
|
||
|
|
{
|
||
|
|
if (!Deinited)
|
||
|
|
{
|
||
|
|
Deinited = true;
|
||
|
|
mPool.Recycle(this);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public void OnExecute(float dt)
|
||
|
|
{
|
||
|
|
}
|
||
|
|
|
||
|
|
public void OnFinish()
|
||
|
|
{
|
||
|
|
}
|
||
|
|
|
||
|
|
public void OnStart()
|
||
|
|
{
|
||
|
|
UITextWindowData data = new UITextWindowData();
|
||
|
|
data.text = text;
|
||
|
|
data.audio = datas.ContainsKey("audio") ? datas["audio"] : string.Empty;
|
||
|
|
data.title = datas.ContainsKey("title") ? datas["title"] : string.Empty;
|
||
|
|
data.btns = datas.ContainsKey("btns") ? datas["btns"].Split(',').ToList() : null;
|
||
|
|
|
||
|
|
if (datas.ContainsKey("scrollSpeed"))
|
||
|
|
{
|
||
|
|
if (float.TryParse(datas["scrollSpeed"], out data.scrollSpeed) == false)
|
||
|
|
{
|
||
|
|
data.scrollSpeed = 25;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
data.position = datas.ContainsKey("position") ? datas["position"] : "";
|
||
|
|
|
||
|
|
|
||
|
|
UIKit.OpenPanelAsync<UITextWindow>(uiData: data, canvasLevel: UILevel.PopUI).ToAction().StartGlobal(() => this.Finish());
|
||
|
|
}
|
||
|
|
|
||
|
|
public void Reset()
|
||
|
|
{
|
||
|
|
Status = ActionStatus.NotStart;
|
||
|
|
Paused = false;
|
||
|
|
}
|
||
|
|
}
|