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/XUtliPoolLib/XStringTable.cs | 116 +++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 Client/Assets/Scripts/XUtliPoolLib/XStringTable.cs (limited to 'Client/Assets/Scripts/XUtliPoolLib/XStringTable.cs') diff --git a/Client/Assets/Scripts/XUtliPoolLib/XStringTable.cs b/Client/Assets/Scripts/XUtliPoolLib/XStringTable.cs new file mode 100644 index 00000000..c7e2fc39 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/XStringTable.cs @@ -0,0 +1,116 @@ +using System; +using UnityEngine; +using XUpdater; + +namespace XUtliPoolLib +{ + public class XStringTable : XSingleton + { + private XTableAsyncLoader _async_loader = null; + + private StringTable _reader = new StringTable(); + + private bool _inited = false; + + public bool ReInit(TextAsset ta) + { + this.Uninit(); + bool flag = XSingleton.singleton.ReadFile(ta, this._reader); + bool result; + if (flag) + { + this._inited = true; + result = true; + } + else + { + result = false; + } + return result; + } + + public bool SyncInit() + { + bool inited = this._inited; + bool result; + if (inited) + { + result = true; + } + else + { + this._inited = XSingleton.singleton.ReadFile("Table/StringTable", this._reader); + bool inited2 = this._inited; + if (inited2) + { + } + result = this._inited; + } + return result; + } + + public override bool Init() + { + bool inited = this._inited; + bool result; + if (inited) + { + result = true; + } + else + { + bool flag = this._async_loader == null; + if (flag) + { + this._async_loader = new XTableAsyncLoader(); + this._async_loader.AddTask("Table/StringTable", this._reader, false); + this._async_loader.Execute(null); + } + this._inited = this._async_loader.IsDone; + result = this._inited; + } + return result; + } + + public override void Uninit() + { + this._inited = false; + this._async_loader = null; + } + + public bool StringTableUpdated() + { + return XSingleton.singleton.ContainRes(XSingleton.singleton.XHash("Table/StringTable")); + } + + public string GetString(string key) + { + string text = ""; + bool data = this.GetData(key, out text); + string result; + if (data) + { + result = text; + } + else + { + bool flag = key != "UNKNOWN_TARGET"; + if (flag) + { + result = this.GetString("UNKNOWN_TARGET") + " " + key; + } + else + { + result = "UNKNOWN_TARGET not found in StringTable"; + } + } + return result; + } + + public bool GetData(string key, out string value) + { + uint key2 = XSingleton.singleton.XHash(key); + return this._reader.Table.TryGetValue(key2, out value); + } + } +} -- cgit v1.1-26-g67d0