| | |
| | | //--------------------------------------------------------
|
| | | // [Author]: Fish
|
| | | // [ Date ]: Wednesday, February 13, 2019
|
| | | // [ Date ]: Thursday, February 14, 2019
|
| | | //--------------------------------------------------------
|
| | |
|
| | | using System.Collections.Generic;
|
| | |
| | | using System;
|
| | | using UnityEngine;
|
| | |
|
| | | [XLua.LuaCallCSharp]
|
| | | public partial class LoadingFunctionConfig
|
| | | {
|
| | |
|
| | | public readonly int ID;
|
| | | public readonly string Icon;
|
| | | public readonly int Level;
|
| | |
|
| | | public LoadingFunctionConfig()
|
| | | {
|
| | | }
|
| | |
|
| | | public LoadingFunctionConfig(string input)
|
| | | {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | static Dictionary<int, LoadingFunctionConfig> configs = new Dictionary<int, LoadingFunctionConfig>();
|
| | | public static LoadingFunctionConfig Get(int id)
|
| | | static Dictionary<string, LoadingFunctionConfig> configs = new Dictionary<string, LoadingFunctionConfig>();
|
| | | public static LoadingFunctionConfig Get(string id)
|
| | | {
|
| | | if (!inited)
|
| | | {
|
| | |
| | | return config;
|
| | | }
|
| | |
|
| | | public static bool Has(int id)
|
| | | public static LoadingFunctionConfig Get(int id)
|
| | | {
|
| | | return Get(id.ToString());
|
| | | }
|
| | |
|
| | | public static List<string> GetKeys()
|
| | | {
|
| | | var keys = new List<string>();
|
| | | keys.AddRange(configs.Keys);
|
| | | keys.AddRange(rawDatas.Keys);
|
| | | return keys;
|
| | | }
|
| | |
|
| | | public static List<LoadingFunctionConfig> GetValues()
|
| | | {
|
| | | var values = new List<LoadingFunctionConfig>();
|
| | | values.AddRange(configs.Values);
|
| | |
|
| | | var keys = new List<string>(rawDatas.Keys);
|
| | | foreach (var key in keys)
|
| | | {
|
| | | values.Add(Get(key));
|
| | | }
|
| | |
|
| | | return values;
|
| | | }
|
| | |
|
| | | public static bool Has(string id)
|
| | | {
|
| | | return configs.ContainsKey(id) || rawDatas.ContainsKey(id);
|
| | | }
|
| | |
|
| | | public static bool Has(int id)
|
| | | {
|
| | | return Has(id.ToString());
|
| | | }
|
| | |
|
| | | public static bool inited { get; private set; }
|
| | | protected static Dictionary<int, string> rawDatas = null;
|
| | | protected static Dictionary<string, string> rawDatas = new Dictionary<string, string>();
|
| | | public static void Init(bool sync=false)
|
| | | {
|
| | | inited = false;
|
| | |
| | | path = AssetVersionUtility.GetAssetFilePath("config/LoadingFunction.txt");
|
| | | }
|
| | |
|
| | | var tempConfig = new LoadingFunctionConfig();
|
| | | var preParse = tempConfig is IConfigPostProcess;
|
| | |
|
| | | if (sync)
|
| | | {
|
| | | var lines = File.ReadAllLines(path);
|
| | | rawDatas = new Dictionary<int, string>(lines.Length - 3);
|
| | | if (!preParse)
|
| | | {
|
| | | rawDatas = new Dictionary<string, string>(lines.Length - 3);
|
| | | }
|
| | | for (int i = 3; i < lines.Length; i++)
|
| | | {
|
| | | var line = lines[i];
|
| | | var index = line.IndexOf("\t");
|
| | | var idString = line.Substring(0, index);
|
| | | var id = int.Parse(idString);
|
| | | try |
| | | {
|
| | | var line = lines[i];
|
| | | var index = line.IndexOf("\t");
|
| | | if (index == -1)
|
| | | {
|
| | | continue;
|
| | | }
|
| | | var id = line.Substring(0, index);
|
| | |
|
| | | rawDatas[id] = line;
|
| | | if (preParse)
|
| | | {
|
| | | var config = new LoadingFunctionConfig(line);
|
| | | configs[id] = config;
|
| | | (config as IConfigPostProcess).OnConfigParseCompleted();
|
| | | }
|
| | | else
|
| | | {
|
| | | rawDatas[id] = line;
|
| | | }
|
| | | }
|
| | | catch (System.Exception ex)
|
| | | {
|
| | | Debug.LogError(ex);
|
| | | }
|
| | | }
|
| | | inited = true;
|
| | | }
|
| | |
| | | ThreadPool.QueueUserWorkItem((object _object) =>
|
| | | {
|
| | | var lines = File.ReadAllLines(path);
|
| | | rawDatas = new Dictionary<int, string>(lines.Length - 3);
|
| | | if (!preParse)
|
| | | {
|
| | | rawDatas = new Dictionary<string, string>(lines.Length - 3);
|
| | | }
|
| | | for (int i = 3; i < lines.Length; i++)
|
| | | {
|
| | | var line = lines[i];
|
| | | var index = line.IndexOf("\t");
|
| | | var idString = line.Substring(0, index);
|
| | | var id = int.Parse(idString);
|
| | | try |
| | | {
|
| | | var line = lines[i];
|
| | | var index = line.IndexOf("\t");
|
| | | if (index == -1)
|
| | | {
|
| | | continue;
|
| | | }
|
| | | var id = line.Substring(0, index);
|
| | |
|
| | | rawDatas[id] = line;
|
| | | if (preParse)
|
| | | {
|
| | | var config = new LoadingFunctionConfig(line);
|
| | | configs[id] = config;
|
| | | (config as IConfigPostProcess).OnConfigParseCompleted();
|
| | | }
|
| | | else
|
| | | {
|
| | | rawDatas[id] = line;
|
| | | }
|
| | | }
|
| | | catch (System.Exception ex)
|
| | | {
|
| | | Debug.LogError(ex);
|
| | | }
|
| | | }
|
| | |
|
| | | inited = true;
|