Пример #1
0
        //構造体のパラメーターテーブルとしてデータ解析
        public void AddTbl(StringGrid grid)
        {
            if (grid.Rows.Count < 3)
            {
                Debug.LogError(grid.Name + " is not Param Sheet");
                return;
            }

            StringGridRow row0 = grid.Rows[0];
            StringGridRow row1 = grid.Rows[1];
            StringGridRow row2 = grid.Rows[2];

            AdvParamStruct header = new AdvParamStruct(row0, row1, row2);

            for (int i = 3; i < grid.Rows.Count; ++i)
            {
                StringGridRow row = grid.Rows[i];
                if (row.IsEmptyOrCommantOut)
                {
                    continue;
                }
                AdvParamStruct data = new AdvParamStruct(header, row);
                string         key  = row.Strings[0];
                if (Tbl.ContainsKey(key))
                {
                    row.ToErrorString(key + " is already contains ");
                }
                else
                {
                    Tbl.Add(key, data);
                }
            }
        }
Пример #2
0
 public void AddTbl(StringGrid grid)
 {
     if (grid.Rows.Count < 3)
     {
         Debug.LogError(grid.Name + " is not Param Sheet");
     }
     else
     {
         StringGridRow  names     = grid.Rows[0];
         StringGridRow  types     = grid.Rows[1];
         StringGridRow  fileTypes = grid.Rows[2];
         AdvParamStruct header    = new AdvParamStruct(names, types, fileTypes);
         for (int i = 3; i < grid.Rows.Count; i++)
         {
             StringGridRow values = grid.Rows[i];
             if (!values.IsEmptyOrCommantOut)
             {
                 AdvParamStruct struct3 = new AdvParamStruct(header, values);
                 string         key     = values.Strings[0];
                 if (this.Tbl.ContainsKey(key))
                 {
                     values.ToErrorString(key + " is already contains ");
                 }
                 else
                 {
                     this.Tbl.Add(key, struct3);
                 }
             }
         }
     }
 }
Пример #3
0
        public void AddSingle(StringGrid grid)
        {
            AdvParamStruct struct2;

            if (!this.Tbl.TryGetValue(string.Empty, out struct2))
            {
                struct2 = new AdvParamStruct();
                this.Tbl.Add(string.Empty, struct2);
            }
            struct2.AddData(grid);
        }
Пример #4
0
 //通常パラメーターの表示
 void OnGuiParamDefault(AdvParamStruct paramDefault)
 {
     {
         List <AdvParamData> list = paramDefault.GetFileTypeList(AdvParamData.FileType.Default);
         GetScrollViewCreateIfMissing("Default").OnGui(list.Count, (x) => OnGuiParamData(list[x]));
     }
     {
         List <AdvParamData> list = paramDefault.GetFileTypeList(AdvParamData.FileType.System);
         GetScrollViewCreateIfMissing("System").OnGui(list.Count, (x) => OnGuiParamData(list[x]));
     }
 }
        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);
        }
Пример #6
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);
        }
Пример #7
0
        //通常のパラメーターとしてデータ追加
        public void AddSingle(StringGrid grid)
        {
            const string   SingleKey = "";
            AdvParamStruct data;

            if (!Tbl.TryGetValue(SingleKey, out data))
            {
                data = new AdvParamStruct();
                Tbl.Add(SingleKey, data);
            }
            data.AddData(grid);
        }
Пример #8
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();
        }
Пример #9
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();
        }
Пример #10
0
        /// <summary>
        /// パラメータテーブルを取得
        /// </summary>
        public bool TryGetParamTbl(string structName, string indexKey, out AdvParamStruct paramStruct)
        {
            paramStruct = null;
            if (!StructTbl.ContainsKey(structName))
            {
                return(false);
            }

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

            paramStruct = StructTbl[structName].Tbl[indexKey];
            return(true);
        }
Пример #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;
            }
        }
 internal void InitDefaultNormal(AdvParamStruct src)
 {
     foreach (KeyValuePair <string, AdvParamData> pair in src.Tbl)
     {
         if (pair.Value.SaveFileType != AdvParamData.FileType.System)
         {
             AdvParamData data;
             if (this.Tbl.TryGetValue(pair.Key, out data))
             {
                 data.Copy(pair.Value);
             }
             else
             {
                 Debug.LogError("Param: " + pair.Key + "  is not found in default param");
             }
         }
     }
 }
Пример #13
0
 //通常パラメーターの表示
 void OnGuiParamDefault(AdvParamStruct paramDefault)
 {
     if (!CheckIgnoreGroup("Default"))
     {
         List <AdvParamData> list = paramDefault.GetFileTypeList(AdvParamData.FileType.Default);
         GetScrollViewCreateIfMissing("Default").OnGui(list.Count, (x) => OnGuiParamData(list[x]));
     }
     if (!CheckIgnoreGroup("System"))
     {
         List <AdvParamData> list = paramDefault.GetFileTypeList(AdvParamData.FileType.System);
         GetScrollViewCreateIfMissing("System").OnGui(list.Count, (x) => OnGuiParamData(list[x]));
     }
     if (!ignoreConst && !CheckIgnoreGroup("Const"))
     {
         List <AdvParamData> list = paramDefault.GetFileTypeList(AdvParamData.FileType.Const);
         GetScrollViewCreateIfMissing("Const").OnGui(list.Count, (x) => OnGuiParamData(list[x]));
     }
 }
Пример #14
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;
            }
        }
Пример #15
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();
        }
Пример #16
0
        /// <summary>
        /// システムデータ以外の値をデフォルト値で初期化
        /// </summary>
        internal void InitDefaultNormal(AdvParamStruct src)
        {
            foreach (var keyValue in src.Tbl)
            {
                if (keyValue.Value.SaveFileType == AdvParamData.FileType.System)
                {
                    continue;
                }

                AdvParamData data;
                if (Tbl.TryGetValue(keyValue.Key, out data))
                {
                    data.Copy(keyValue.Value);
                }
                else
                {
                    Debug.LogError("Param: " + keyValue.Key + "  is not found in default param");
                }
            }
        }
        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++;
            }
        }
Пример #18
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));
            }
        }