Ejemplo n.º 1
0
        /// <summary>
        /// Reads a new setting from a file.
        /// </summary>
        /// <param name="filePath">Filepath of the settings file</param>
        /// <returns></returns>
        public static Settings Load(string filePath)
        {
            var settings = new Settings();

            if (File.Exists(filePath))
            {
                var     text = File.ReadAllText(filePath);
                IniData ini  = IniData.Deserialize(text);
                foreach (var section in ini.Content)
                {
                    var id = section.Key;
                    if (id == "General")
                    {
                        if (section.Value.ContainsKey("Language"))
                        {
                            LanguageManager.getInstance().Language = section.Value["Language"];
                        }
                    }
                    else if (id == "Keyboard")
                    {
                        settings.mappers[id] = KeyboardToXInputMapper.Parse(section.Value);
                    }
                    else
                    {
                        settings.mappers[id] = DirectToXInputMapper.Parse(section.Value);
                    }
                }
            }
            return(settings);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Reads a new setting from a file.
        /// </summary>
        /// <param name="filePath">Filepath of the settings file</param>
        /// <returns></returns>
        public static Settings Load(string filePath)
        {
            var settings = new Settings();

            if (File.Exists(filePath))
            {
                var     text = File.ReadAllText(filePath);
                IniData ini  = IniData.Deserialize(text);
                foreach (var section in ini.Content)
                {
                    var id = section.Key;
                    if (id == General)
                    {
                        if (section.Value.ContainsKey(LanguageKey))
                        {
                            LanguageManager.Instance.Language = section.Value[LanguageKey];
                        }
                        if (section.Value.ContainsKey(CloseToTrayKey))
                        {
                            settings.CloseToTray = section.Value[CloseToTrayKey] == "true";
                        }
                        if (section.Value.ContainsKey(ShowAllKey))
                        {
                            settings.ShowAll = section.Value[ShowAllKey] == "true";
                        }
                        if (section.Value.ContainsKey(HidGuardianEnabledKey))
                        {
                            settings.HidGuardianEnabled = section.Value[HidGuardianEnabledKey] == "true";
                        }
                    }
                    else if (id == KeyboardKey)
                    {
                        settings.mappers[id] = KeyboardToXInputMapper.Parse(section.Value);
                        logger.Debug("Mapper loaded for keyboard");
                    }
                    else
                    {
                        settings.mappers[id] = DirectToXInputMapper.Parse(section.Value);
                        logger.Debug("Mapper loaded for " + id);
                    }
                }
            }
            return(settings);
        }