public ServiceConfiguration() { TextAsset txt = Resources.Load("server_config") as TextAsset; INIReader reader = new INIReader(txt.text); foreach (INIReaderHeader header in reader.GetHeaders()) { if (header.Check("ServerConfig")) { foreach (INIReaderParameter parameter in header.parameters) { if (parameter.Check("maxclients")) { maxClients = parameter.GetInt(0); } else if (parameter.Check("login_server_port")) { loginServerPort = parameter.GetInt(0); } else if (parameter.Check("account_db_dir")) { accountDatabaseDir = parameter.GetString(0); } else if (parameter.Check("account_db_pass")) { accountDatabasePassword = parameter.GetString(0); } } } } }
public static int LoadAll(IndexArchStorage <T> outVal, string dirPath, string masterSection) { UnityEngine.Object[] assets = Resources.LoadAll(dirPath, typeof(TextAsset)); int loaded = outVal.Count; foreach (UnityEngine.Object e in assets) { TextAsset txtAsset = e as TextAsset; if (e == null) { continue; } INIReader reader = new INIReader(txtAsset.text); T archObj = null; foreach (INIReaderHeader h in reader.GetHeaders()) { if ((h.nickname.CompareTo(masterSection) == 0) && (archObj == null)) { archObj = new T(); archObj.ReadHeader(h); } else if ((h.nickname.CompareTo(masterSection) != 0) && (archObj != null)) { archObj.ReadHeader(h); } else if ((h.nickname.CompareTo(masterSection) == 0) && (archObj != null)) { // Store previous if (archObj.id != 0) { outVal.Add(archObj); } // Create new and read current section archObj = new T(); archObj.ReadHeader(h); } } if (archObj != null && archObj.id != 0) { outVal.Add(archObj); } } outVal.BuildIndexData(); return(outVal.Count - loaded); }
public static void Load(IndexArchStorage <T> outVal, string assetFile, string masterSection) { TextAsset txt = (TextAsset)Resources.Load(assetFile); if (txt == null) { Debug.Log("ArchLoader: failed to locate file - " + assetFile); return; } // now loop through all strings StringReader stringReader = new StringReader(txt.text); string currentLine; while ((currentLine = stringReader.ReadLine()) != null) { if (currentLine.StartsWith("//")) { continue; } if (currentLine.Length == 0) { continue; } // Load { TextAsset iniText = (TextAsset)Resources.Load(currentLine); if (iniText == null) { Debug.Log("ArchLoader: failed to locate listed file - " + currentLine); continue; } INIReader reader = new INIReader(iniText.text); T archObj = null; foreach (INIReaderHeader h in reader.GetHeaders()) { if ((h.nickname.CompareTo(masterSection) == 0) && (archObj == null)) { archObj = new T(); archObj.ReadHeader(h); } else if ((h.nickname.CompareTo(masterSection) != 0) && (archObj != null)) { archObj.ReadHeader(h); } else if ((h.nickname.CompareTo(masterSection) == 0) && (archObj != null)) { // Store previous outVal.Add(archObj); // Create new and read current section archObj = new T(); archObj.ReadHeader(h); } } if (archObj != null) { outVal.Add(archObj); } } } outVal.BuildIndexData(); }