Exemple #1
0
        private Manager()
        {
#if !GROOT_ASSETBUNDLE_SIMULATION && UNITY_EDITOR
            SheetLiteDbNormal default_db   = new SheetLiteDbNormal(WeiqiApp.CONFIG_ROOT_PATH);
            SheetLiteDbNormal languages_db = new SheetLiteDbNormal(WeiqiApp.LANGUAGES_ROOT_PATH);
#else
            SheetLiteDbAssetBundle default_db   = new SheetLiteDbAssetBundle(WeiqiApp.CONFIG_ROOT_PATH);
            SheetLiteDbAssetBundle languages_db = new SheetLiteDbAssetBundle(WeiqiApp.LANGUAGES_ROOT_PATH);
#endif
            m_dbs.Add("data", default_db);
            SheetReader.BindDB(default_db);
            m_dbs.Add("language", languages_db);
        }
Exemple #2
0
 public static void LoadCsvConfig(string _name, Action <SheetReader> _action)
 {
     ResFramework.ResManager.Instance.LoadAsset(string.Format("Assets/Res/Config/{0}.txt", _name),
                                                (_data, _object) =>
     {
         Utility.SheetLite.SheetReader reader = new Utility.SheetLite.SheetReader();
         TextAsset text = _object as TextAsset;
         if (reader.OpenSheet(_name, text.bytes))
         {
             _action(reader);
         }
         if (_data != null)
         {
             _data.Unload();
         }
     }, false);
 }
Exemple #3
0
        private Boolean _loadLocaleFile(LanguageName _lang, String _file_name)
        {
            //StringBuilder string_builder = new StringBuilder( 128 );
            Utility.SheetLite.SheetReader reader = new Utility.SheetLite.SheetReader();

            if (!reader.OpenSheet("language", String.Format("{0}/{1}", _lang, _file_name)))
            {
                Log.Error("[Locale]语言包文件: {0} 加载失败!", _file_name);
                return(false);
            }
            for (Int32 i = 0; i < reader.Count; ++i)
            {
                SheetRow row = reader[i];
                String   key = row["Key"];

                String category = row["Category"];
                if (!String.IsNullOrEmpty(category))
                {
                    key = String.Format("{0}@{1}", category, key);
                }

                if (m_locale.ContainsKey(key))
                {
                    Utility.Log.Error("[Loclae]:语言包中包含重复键值:{0} {1}", _lang, key);
                    continue;
                }
                String value = row["Value"];

                // 颜色值转换
                //string_builder.Length = 0;
                //Int32 pos = 0;
                //while( pos < value.Length )
                //{
                //	if( '[' == value[pos] )
                //	{
                //		if( UnityEngine.UI.Text.ProcessColor( value, pos, string_builder, out pos ) )
                //			continue;
                //	}
                //	string_builder.Append( value[pos++] );
                //}

                //value = string_builder.ToString().Trim();
                m_locale.Add(key, value);
            }
            return(true);
        }
Exemple #4
0
 public static void LoadCsvConfigWithStructKey <Tkey, Tvalue>(string _name, Dictionary <Tkey, Tvalue> _dic) where Tkey : struct where Tvalue : new()
 {
     ResFramework.ResManager.Instance.LoadAsset(string.Format("Assets/Res/Config/{0}.txt", _name),
                                                (_data, _object) =>
     {
         Utility.SheetLite.SheetReader reader = new Utility.SheetLite.SheetReader();
         TextAsset text = _object as TextAsset;
         if (!reader.OpenSheet(_name, text.bytes))
         {
             return;
         }
         for (int i = 0; i < reader.Count; ++i)
         {
             SheetRow row     = reader[i];
             Type type        = typeof(Tvalue);
             Tkey new_key     = (Tkey)ConverFieldValue(reader.Sheet.GetKeyTypeString(0), row[0]);
             Tvalue new_value = new Tvalue();
             for (int j = 0; j < row.Count; ++j)
             {
                 if (string.IsNullOrEmpty(row[j]))
                 {
                     continue;
                 }
                 string key      = reader.Sheet.GetKeyString(j);
                 string key_type = reader.Sheet.GetKeyTypeString(j);
                 try
                 {
                     FieldInfo Property = type.GetField(key);
                     Property.SetValue(new_value, ConverFieldValue(key_type, row[j]));
                 }
                 catch (Exception e)
                 {
                     Debug.LogError(string.Format("表头 {0} 不是{1}类型 检查类 {2} 对应的配置 !!!{3}", key, key_type, type.Name, e.Message));
                 }
             }
             _dic.Add(new_key, new_value);
         }
         if (_data != null)
         {
             _data.Unload();
         }
     }, false);
 }
Exemple #5
0
    public override void Initialize()
    {
        Utility.SheetLite.SheetReader reader = new Utility.SheetLite.SheetReader();
        if (!reader.OpenSheet("global_config"))
        {
            return;
        }
        for (Int32 i = 0; i < reader.Count; ++i)
        {
            String  key;
            Variant value;
            if (!VariantPairSerializer.CreateFromSheetLite(reader[i], out key, out value))
            {
                Log.Error("È«¾ÖÅäÖöÁȡʧ°Ü!");
                return;
            }
            m_container.Add(key, value);
        }

        // LocalConfigSystem.Instacne.CreateXml();
    }