Exemplo n.º 1
0
        //バイナリ読み込み
        internal void Read(BinaryReader reader)
        {
            int version = reader.ReadInt32();

            if (version <= Version)
            {
                int count = reader.ReadInt32();
                for (int i = 0; i < count; i++)
                {
                    AdvParamData data = new AdvParamData();
                    AdvParamData src;
                    data.Read(reader, version);
                    if (Tbl.TryGetValue(data.Key, out src))
                    {
                        src.CopySaveData(data);
                    }
                    else
                    {
                        //セーブされていたが、パラメーター設定から消えているので読み込まない
                    }
                }
            }
            else
            {
                Debug.LogError(LanguageErrorMsg.LocalizeTextFormat(ErrorMsg.UnknownVersion, version));
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 値の代入を試みる
 /// </summary>
 bool CheckSetParameterSub(AdvParamData data, object parameter)
 {
     ///bool値のキャストは気をつける
     if (data.Type == AdvParamData.ParamType.Bool || parameter is bool)
     {
         if (data.Type != AdvParamData.ParamType.Bool || !(parameter is bool))
         {
             return(false);
         }
     }
     ///string値のキャストは気をつける
     if (parameter is string)
     {
         if (data.Type != AdvParamData.ParamType.String)
         {
             return(false);
         }
     }
     if (data.Type == AdvParamData.ParamType.String)
     {
         if (parameter is bool)
         {
             return(false);
         }
     }
     return(true);
 }
Exemplo n.º 3
0
 //通常のパラメーターを追加
 public void AddData(StringGrid grid)
 {
     foreach (StringGridRow row in grid.Rows)
     {
         if (row.RowIndex < grid.DataTopRow)
         {
             continue;
         }
         if (row.IsEmptyOrCommantOut)
         {
             continue;
         }
         AdvParamData data = new AdvParamData();
         if (!data.TryParse(row))
         {
             Debug.LogError(row.ToErrorString(" Parse Error"));
             continue;
         }
         else
         {
             if (Tbl.ContainsKey(data.Key))
             {
                 Debug.LogError(row.ToErrorString(data.Key + " is already contaisn"));
             }
             else
             {
                 Tbl.Add(data.Key, data);
             }
         }
     }
 }
Exemplo n.º 4
0
 public void Copy(AdvParamData src)
 {
     this.key             = src.Key;
     this.type            = src.type;
     this.parameterString = src.parameterString;
     ParseParameterString();
     this.fileType = src.fileType;
 }
Exemplo n.º 5
0
        //中身を全てコピー
        internal AdvParamStruct Clone()
        {
            AdvParamStruct clone = new AdvParamStruct();

            foreach (var item in Tbl)
            {
                AdvParamData param = new AdvParamData();
                param.Copy(item.Value);
                clone.Tbl.Add(item.Key, param);
            }
            return(clone);
        }
        internal AdvParamStruct Clone()
        {
            AdvParamStruct struct2 = new AdvParamStruct();

            foreach (KeyValuePair <string, AdvParamData> pair in this.Tbl)
            {
                AdvParamData data = new AdvParamData();
                data.Copy(pair.Value);
                struct2.Tbl.Add(pair.Key, data);
            }
            return(struct2);
        }
Exemplo n.º 7
0
        //構造体配列の値を表示
        void OnGuiStructArrayValues(string key, AdvParamStruct param)
        {
            GUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(key, paramHeight, paramWidth);
            foreach (var item in param.Tbl)
            {
                AdvParamData data    = item.Value;
                bool         isConst = data.SaveFileType == AdvParamData.FileType.Const;
                if (isConst && ignoreConst)
                {
                    continue;
                }
                EditorGUI.BeginDisabledGroup(isConst);
                switch (data.Type)
                {
                case AdvParamData.ParamType.Float:
                    float f = EditorGUILayout.FloatField((float)data.Parameter, paramHeight, paramWidth);
                    if (f != (float)data.Parameter)
                    {
                        data.Parameter = f;
                    }
                    break;

                case AdvParamData.ParamType.Int:
                    int i = EditorGUILayout.IntField((int)data.Parameter, paramHeight, paramWidth);
                    if (i != (int)data.Parameter)
                    {
                        data.Parameter = i;
                    }
                    break;

                case AdvParamData.ParamType.Bool:
                    bool b = EditorGUILayout.Toggle((bool)data.Parameter, paramHeight, paramWidth);
                    if (b != (bool)data.Parameter)
                    {
                        data.Parameter = b;
                    }
                    break;

                case AdvParamData.ParamType.String:
                    string s = EditorGUILayout.TextField((string)data.Parameter, paramHeight, paramWidth);
                    if (s != (string)data.Parameter)
                    {
                        data.Parameter = s;
                    }
                    break;
                }
                EditorGUI.EndDisabledGroup();
            }
            GUILayout.EndHorizontal();
        }
Exemplo n.º 8
0
        //構造体配列のヘッダ部分表示
        void DrawStructArrayHeader(AdvParamStruct advParamStruct)
        {
            GUILayout.BeginVertical();

            //名前
            GUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Label", paramHeight, paramWidth);
            foreach (var item in advParamStruct.Tbl)
            {
                AdvParamData data = item.Value;
                if (data.SaveFileType == AdvParamData.FileType.Const && ignoreConst)
                {
                    continue;
                }
                EditorGUILayout.LabelField(data.Key, paramHeight, paramWidth);
            }
            GUILayout.EndHorizontal();

            //型
            GUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Type", paramHeight, paramWidth);
            foreach (var item in advParamStruct.Tbl)
            {
                AdvParamData data = item.Value;
                if (data.SaveFileType == AdvParamData.FileType.Const && ignoreConst)
                {
                    continue;
                }
                EditorGUILayout.LabelField(data.Type.ToString(), paramHeight, paramWidth);
            }
            GUILayout.EndHorizontal();


            //ファイルタイプ
            GUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("FileType", paramHeight, paramWidth);
            foreach (var item in advParamStruct.Tbl)
            {
                AdvParamData data = item.Value;
                if (data.SaveFileType == AdvParamData.FileType.Const && ignoreConst)
                {
                    continue;
                }
                EditorGUILayout.LabelField(data.SaveFileType.ToString(), paramHeight, paramWidth);
            }
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
        }
Exemplo n.º 9
0
 public bool TryParse(AdvParamData src, string value)
 {
     this.key             = src.Key;
     this.type            = src.Type;
     this.fileType        = src.SaveFileType;
     this.parameterString = value;
     try
     {
         ParseParameterString();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemplo n.º 10
0
 public void CopySaveData(AdvParamData src)
 {
     if (this.key != src.Key)
     {
         Debug.LogError(src.key + "is diffent name of Saved param");
     }
     if (this.type != src.type)
     {
         Debug.LogError(src.type + "is diffent type of Saved param");
     }
     if (this.fileType != src.fileType)
     {
         Debug.LogError(src.fileType + "is diffent fileType of Saved param");
     }
     this.parameterString = src.parameterString;
     ParseParameterString();
 }
Exemplo n.º 11
0
        //ヘッダ情報と値一覧から初期化
        public AdvParamStruct(AdvParamStruct header, StringGridRow values)
        {
            int index = 1;

            foreach (var item in header.Tbl.Values)
            {
                string       value = index < values.Length ? values.Strings[index] : "";
                AdvParamData data  = new AdvParamData();
                if (!data.TryParse(item, value))
                {
                    Debug.LogError(values.ToErrorString(" Parse Error <b>" + value + "</b>"));
                    continue;
                }
                Tbl.Add(data.Key, data);
                ++index;
            }
        }
Exemplo n.º 12
0
        //通常パラメーターの表示
        void OnGuiParamData(AdvParamData data)
        {
            bool isConst = data.SaveFileType == AdvParamData.FileType.Const;

            if (isConst && ignoreConst)
            {
                return;
            }
            EditorGUI.BeginDisabledGroup(isConst);
            switch (data.Type)
            {
            case AdvParamData.ParamType.Float:
                float f = EditorGUILayout.FloatField(data.Key, (float)data.Parameter, paramHeight);
                if (f != (float)data.Parameter)
                {
                    data.Parameter = f;
                }
                break;

            case AdvParamData.ParamType.Int:
                int i = EditorGUILayout.IntField(data.Key, (int)data.Parameter, paramHeight);;
                if (i != (int)data.Parameter)
                {
                    data.Parameter = i;
                }
                break;

            case AdvParamData.ParamType.Bool:
                bool b = EditorGUILayout.Toggle(data.Key, (bool)data.Parameter, paramHeight);
                if (b != (bool)data.Parameter)
                {
                    data.Parameter = b;
                }
                break;

            case AdvParamData.ParamType.String:
                string s = EditorGUILayout.TextField(data.Key, (string)data.Parameter, paramHeight);
                if (s != (string)data.Parameter)
                {
                    data.Parameter = s;
                }
                break;
            }
            EditorGUI.EndDisabledGroup();
        }
Exemplo n.º 13
0
        //ヘッダ情報と値一覧から初期化
        public AdvParamStruct(AdvParamStruct header, StringGridRow values)
        {
            int index0 = 0;

            foreach (var keyValue in header.Tbl)
            {
                int          index = ToIndexCommentOuted(values.Grid.Rows[0], index0 + 1);
                string       value = (index < values.Strings.Length) ? values.Strings[index] : "";
                AdvParamData data  = new AdvParamData();
                if (!data.TryParse(keyValue.Value, value))
                {
                    Debug.LogError(values.ToErrorString(" Parse Error <b>" + value + "</b>" + "type = " + keyValue.Value.Type));
                    continue;
                }
                Tbl.Add(data.Key, data);
                ++index0;
            }
        }
Exemplo n.º 14
0
        //構造体配列の値を表示
        void OnGuiStructArrayValues(string key, AdvParamStruct param)
        {
            GUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(key, paramHeight, paramWidth);
            foreach (var item in param.Tbl)
            {
                AdvParamData data = item.Value;
                switch (data.Type)
                {
                case AdvParamData.ParamType.Float:
                    float f = EditorGUILayout.FloatField((float)data.Parameter, paramHeight, paramWidth);
                    if (f != (float)data.Parameter)
                    {
                        data.Parameter = f;
                    }
                    break;

                case AdvParamData.ParamType.Int:
                    int i = EditorGUILayout.IntField((int)data.Parameter, paramHeight, paramWidth);
                    if (i != (int)data.Parameter)
                    {
                        data.Parameter = i;
                    }
                    break;

                case AdvParamData.ParamType.Bool:
                    bool b = EditorGUILayout.Toggle((bool)data.Parameter, paramHeight, paramWidth);
                    if (b != (bool)data.Parameter)
                    {
                        data.Parameter = b;
                    }
                    break;

                case AdvParamData.ParamType.String:
                    string s = EditorGUILayout.TextField((string)data.Parameter, paramHeight, paramWidth);
                    if (s != (string)data.Parameter)
                    {
                        data.Parameter = s;
                    }
                    break;
                }
            }
            GUILayout.EndHorizontal();
        }
Exemplo n.º 15
0
 //構造体のヘッダ情報として初期化
 public AdvParamStruct(StringGridRow names, StringGridRow types, StringGridRow fileTypes)
 {
     for (int i = 1; i < names.Length; ++i)
     {
         string name = names.Strings[i];
         if (!name.StartsWith("//") && name.Length > 0)
         {
             AdvParamData data     = new AdvParamData();
             string       type     = (i < types.Length) ? types.Strings[i] : "";
             string       fileType = (i < fileTypes.Length) ? fileTypes.Strings[i] : "";
             if (!data.TryParse(name, type, fileType))
             {
                 Debug.LogError(string.Format("{0} Header [<b>{1}</b>]: ", names.Grid.Name, i));
                 continue;
             }
             Tbl.Add(data.Key, data);
         }
     }
 }
Exemplo n.º 16
0
 //構造体のヘッダ情報として初期化
 public AdvParamStruct(StringGridRow names, StringGridRow types, StringGridRow fileTypes)
 {
     if (names.Length != types.Length)
     {
         Debug.LogError(names.Grid.Name + " Contains Cell in Name or Type");
         return;
     }
     for (int i = 1; i < names.Length; ++i)
     {
         AdvParamData data     = new AdvParamData();
         string       fileType = (i < fileTypes.Length) ? fileTypes.Strings[i] : "";
         if (!data.TryParse(names.Strings[i], types.Strings[i], fileType))
         {
             Debug.LogError(string.Format("{0} Header [<b>{1}</b>]: ", names.Grid.Name, i));
             continue;
         }
         Tbl.Add(data.Key, data);
     }
 }
        public AdvParamStruct(AdvParamStruct header, StringGridRow values)
        {
            this.tbl = new Dictionary <string, AdvParamData>();
            int index = 1;

            foreach (KeyValuePair <string, AdvParamData> pair in header.Tbl)
            {
                if (!pair.Value.Key.StartsWith("//"))
                {
                    string       str  = (index >= values.Length) ? string.Empty : values.Strings[index];
                    AdvParamData data = new AdvParamData();
                    if (!data.TryParse(pair.Value, str))
                    {
                        Debug.LogError(values.ToErrorString(" Parse Error <b>" + str + "</b>"));
                        continue;
                    }
                    this.Tbl.Add(data.Key, data);
                }
                index++;
            }
        }
Exemplo n.º 18
0
        //通常パラメーターの表示
        void OnGuiParamData(AdvParamData data)
        {
            switch (data.Type)
            {
            case AdvParamData.ParamType.Float:
                float f = EditorGUILayout.FloatField(data.Key, (float)data.Parameter, paramHeight);
                if (f != (float)data.Parameter)
                {
                    data.Parameter = f;
                }
                break;

            case AdvParamData.ParamType.Int:
                int i = EditorGUILayout.IntField(data.Key, (int)data.Parameter, paramHeight);;
                if (i != (int)data.Parameter)
                {
                    data.Parameter = i;
                }
                break;

            case AdvParamData.ParamType.Bool:
                bool b = EditorGUILayout.Toggle(data.Key, (bool)data.Parameter, paramHeight);
                if (b != (bool)data.Parameter)
                {
                    data.Parameter = b;
                }
                break;

            case AdvParamData.ParamType.String:
                string s = EditorGUILayout.TextField(data.Key, (string)data.Parameter, paramHeight);
                if (s != (string)data.Parameter)
                {
                    data.Parameter = s;
                }
                break;
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// 値の代入を試みる
        /// </summary>
        bool CheckSetParameterSub(string key, object parameter, out AdvParamData data)
        {
            if (!TryGetParamData(key, out data))
            {
                return(false);
            }
            if (data.SaveFileType == AdvParamData.FileType.Const)
            {
                return(false);
            }

            ///bool値のキャストは気をつける
            if (data.Type == AdvParamData.ParamType.Bool || parameter is bool)
            {
                if (data.Type != AdvParamData.ParamType.Bool || !(parameter is bool))
                {
                    return(false);
                }
            }
            ///string値のキャストは気をつける
            if (parameter is string)
            {
                if (data.Type != AdvParamData.ParamType.String)
                {
                    return(false);
                }
            }
            if (data.Type == AdvParamData.ParamType.String)
            {
                if (parameter is bool)
                {
                    return(false);
                }
            }
            return(true);
        }
Exemplo n.º 20
0
        /// <summary>
        /// キーからパラメータを取得
        /// </summary>
        bool TryGetParamData(string key, out AdvParamData data)
        {
            data = null;
            string structName, indexKey, valueKey;

            if (!ParseKey(key, out structName, out indexKey, out valueKey))
            {
                AdvParamStruct def = GetDefault();
                if (def == null)
                {
                    return(false);
                }
                return(def.Tbl.TryGetValue(key, out data));
            }
            else
            {
                AdvParamStruct paramStruct;
                if (!TryGetParamTbl(structName, indexKey, out paramStruct))
                {
                    return(false);
                }
                return(paramStruct.Tbl.TryGetValue(valueKey, out data));
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// キーからパラメータを取得
        /// </summary>
        bool TryGetParamData(string key, out AdvParamData data)
        {
            data = null;
            string structName, indexKey, valueKey;

            if (!ParseKey(key, out structName, out indexKey, out valueKey))
            {
                return(GetDefault().Tbl.TryGetValue(key, out data));
            }
            else
            {
                if (!StructTbl.ContainsKey(structName))
                {
                    return(false);
                }

                if (!StructTbl[structName].Tbl.ContainsKey(indexKey))
                {
                    return(false);
                }

                return(StructTbl[structName].Tbl[indexKey].Tbl.TryGetValue(valueKey, out data));
            }
        }
 public AdvParamStruct(StringGridRow names, StringGridRow types, StringGridRow fileTypes)
 {
     this.tbl = new Dictionary <string, AdvParamData>();
     if (names.Length != types.Length)
     {
         Debug.LogError(names.Grid.Name + " Contains Cell in Name or Type");
     }
     else
     {
         for (int i = 1; i < names.Length; i++)
         {
             AdvParamData data     = new AdvParamData();
             string       fileType = (i >= fileTypes.Length) ? string.Empty : fileTypes.Strings[i];
             if (!data.TryParse(names.Strings[i], types.Strings[i], fileType))
             {
                 Debug.LogError(string.Format("{0} Header [<b>{1}</b>]: ", names.Grid.Name, i));
             }
             else
             {
                 this.Tbl.Add(data.Key, data);
             }
         }
     }
 }