Esempio n. 1
0
        public void SetSettingFromLocal(bool isSet = true)
        {
            _localCache.Clear();
            string str = string.Empty;

            try
            {
                str = PlayerPrefs.GetString(LocalCacheKey, string.Empty);
            }
            catch (Exception e)
            {
                _logger.Error(e);
            }


            var sourceDic = SettingConfigUtil.CovertString(str);

            if (sourceDic == null)
            {
                return;
            }
            foreach (var pair in sourceDic)
            {
                if (isSet)
                {
                    SetSettingValue(pair.Key, pair.Value);
                }
                _localCache[pair.Key] = pair.Value;
            }
        }
Esempio n. 2
0
        public Dictionary <int, float> LoadLocalVideoSetting()
        {
            Dictionary <int, float> dict = new Dictionary <int, float>();
            string str = string.Empty;

            try
            {
                str = PlayerPrefs.GetString(LocalVideoCacheKey, string.Empty);
            }
            catch (Exception e)
            {
                _logger.Error(e);
            }

            var sourceDic = SettingConfigUtil.CovertString(str);

            if (sourceDic == null)
            {
                return(null);
            }
            foreach (var pair in sourceDic)
            {
                //SetSettingValue(pair.Key, pair.Value);
                dict.Add(pair.Key, float.Parse(pair.Value));
            }

            return(dict);
        }
Esempio n. 3
0
        public void SetSettingFromLocal(bool isSet = true)
        {
            _localCache.Clear();
            string str = string.Empty;

            try
            {
                str = PlayerPrefs.GetString(LocalCacheKey, string.Empty);
            }
            catch (Exception e)
            {
                _logger.Error(e);
            }


            var sourceDic = SettingConfigUtil.CovertString(str);

            // 应用一次所有设置项
            // 读取本地配置 替换默认配置 并应用
            var configDic = new Dictionary <int, string>();

            if (_configDic != null)
            {
                foreach (var item in _configDic)
                {
                    configDic[item.Key] = item.Value.value;
                }
            }

            if (sourceDic != null)
            {
                foreach (var item in sourceDic)
                {
                    configDic[item.Key] = item.Value;
                }
            }

            if (sourceDic == null || !sourceDic.ContainsKey((int)VideoSettingId.Quality))
            {
                haveQualityLevelCache = false;
            }

            ResolutionParamHelper.SetParamToSettingManager();

            if (UseBootParam)
            {
                ReplaceConfigOfResolutionAndScreenMode(configDic, _configDic);
            }

            if (isSet)
            {
                SetSetting(configDic);
            }

            foreach (var pair in configDic)
            {
                _localCache[pair.Key] = pair.Value;
            }
        }
Esempio n. 4
0
 public void SaveSettingToLocal()
 {
     try
     {
         string newStr = SettingConfigUtil.DictionaryToString(_localCache);
         PlayerPrefs.SetString(LocalCacheKey, newStr);
     }
     catch (Exception e)
     {
         _logger.Error(e);
     }
 }
 public void SaveLocalVideoSetting(Dictionary <int, float> list)
 {
     try
     {
         string newStr = SettingConfigUtil.DictionaryToString(list);
         PlayerPrefs.SetString(LocalVideoCacheKey, newStr);
     }
     catch (Exception e)
     {
         _logger.Error(e);
     }
 }
Esempio n. 6
0
        public override void ParseConfig(string xml)
        {
            var _config = XmlConfigParser <SettingConfig> .Load(xml);

            if (null == _config)
            {
                Logger.Error("invalid xml content");
                return;
            }

            _configDic = new Dictionary <int, SettingItem>();
            foreach (var item in _config.Items)
            {
                var settingItem = new SettingItem()
                {
                    Id           = item.Id,
                    Type         = item.Type,
                    ControlType  = item.ControlType,
                    Description  = item.Desription,
                    DefaultValue = item.DefaultValue,
                    Value        = item.DefaultValue,
                    Levels       = item.ComboxItemKeys
                };
                settingItem.SettingId = new List <Dictionary <int, string> >();
                if (item.SettingId != null)
                {
                    for (var i = 0; i < item.SettingId.Count; i++)
                    {
                        settingItem.SettingId.Add(SettingConfigUtil.CovertString(item.SettingId[i], ','));
                    }
                }
                settingItem.Additional = new List <List <string> >();
                if (item.Additional != null)
                {
                    for (var i = 0; i < item.Additional.Count; i++)
                    {
                        settingItem.Additional.Add(SettingConfigUtil.CovertAdditional(item.Additional[i], ','));
                    }
                }

                _configDic[settingItem.Id] = settingItem;
            }
        }