private static void ReadConfigFile() { _configFile = GenericConfigFile.Load("config.ini"); if (_configFile == null) { Console.WriteLine("Could not read config.ini"); return; } if (!_configFile.TryGetFloat("volume", out _globalVolume)) { _globalVolume = 1.0f; Console.WriteLine("Could not read volume"); } }
public static GenericConfigFile Load(string path) { if (File.Exists(path)) { char[] split = { '=' }; GenericConfigFile file = new GenericConfigFile(); var lines = File.ReadAllLines(path); for (int i = 0; i < lines.Length; i++) { var curLine = lines[i].Trim(); var keyAndValue = curLine.Split(split); var key = keyAndValue[0].Trim(); var value = keyAndValue[1].Trim(); file.Add(key, value); } return(file); } return(null); }