protected bool GetConditionToNext(SingleData data)
        {
            //对旧项目做兼容
            if (!data.ContainsKey(c_ConditionToNextKey) &&
                !data.data.m_defaultValue.ContainsKey(c_ConditionToNextKey))
            {
                return(false);
            }

            return(data.GetBool(c_ConditionToNextKey));
        }
        protected bool GetGuideClosePoint(SingleData data)
        {
            //对旧项目做兼容
            if (!data.ContainsKey(c_guideClosePoint) &&
                !data.data.m_defaultValue.ContainsKey(c_guideClosePoint))
            {
                return(false);
            }


            return(data.GetBool(c_guideClosePoint));
        }
    void ResetDataField(DataTable data, string key, FieldType type, string enumType)
    {
        string newContent = new SingleField(type, null, enumType).m_content;

        for (int i = 0; i < data.TableIDs.Count; i++)
        {
            SingleData tmp = data[data.TableIDs[i]];

            if (tmp.ContainsKey(key))
            {
                tmp[key] = newContent;
            }
        }

        data.SetDefault(key, newContent);
    }
Exemple #4
0
    static void ResetDataField(DataTable data, string key, FieldType type, string enumType, object defaultValue)
    {
        string newContent = DataConfigUtils.ObjectValue2TableString(defaultValue);

        for (int i = 0; i < data.TableIDs.Count; i++)
        {
            SingleData tmp = data[data.TableIDs[i]];

            if (tmp.ContainsKey(key))
            {
                tmp[key] = newContent;
            }
        }

        if (data.m_defaultValue.ContainsKey(key))
        {
            data.m_defaultValue[key] = newContent;
        }
        else
        {
            data.m_defaultValue.Add(key, newContent);
        }
    }
    SingleData EditorDataGUI(DataTable table, SingleData data)
    {
        try
        {
            List <string> keys = table.TableKeys;
            for (int i = 0; i < keys.Count; i++)
            {
                string    keyTmp = keys[i];
                FieldType type   = table.GetFieldType(keyTmp);

                if (i != 0)
                {
                    bool cancelDefault = false;
                    EditorGUILayout.BeginHorizontal();

                    if (data.ContainsKey(keyTmp))
                    {
                        EditorGUILayout.LabelField("[" + keyTmp + "]");

                        if (GUILayout.Button("使用默认值"))
                        {
                            data.Remove(keyTmp);
                            EditorGUILayout.EndHorizontal();

                            continue;
                        }
                    }
                    else
                    {
                        EditorGUILayout.LabelField("[" + keyTmp + "] (默认值)");
                        if (GUILayout.Button("取消默认值"))
                        {
                            cancelDefault = true;
                        }
                    }

                    EditorGUILayout.EndHorizontal();

                    //EditorGUI.indentLevel++;
                    EditorGUI.indentLevel++;

                    //非默认值情况
                    if (data.ContainsKey(keyTmp))
                    {
                        EditorGUILayout.LabelField("字段名", keyTmp);
                        EditorGUILayout.LabelField("注释", table.GetNote(keyTmp));

                        string newContent = EditorUtilGUI.FieldGUI_TypeValue(type, data[keyTmp], table.GetEnumType(keyTmp));

                        if (newContent != data[keyTmp])
                        {
                            data[keyTmp] = newContent;
                        }
                    }
                    //如果是默认值则走这里
                    else
                    {
                        EditorGUILayout.LabelField("字段名", keyTmp);
                        EditorGUILayout.LabelField("注释", table.GetNote(keyTmp));
                        string newContent = "";

                        if (table.m_defaultValue.ContainsKey(keyTmp))
                        {
                            newContent = new SingleField(type, table.GetDefault(keyTmp), table.GetEnumType(keyTmp)).m_content;
                        }
                        else
                        {
                            newContent = new SingleField(type, null, table.GetEnumType(keyTmp)).m_content;
                        }

                        if (type != FieldType.Enum)
                        {
                            EditorGUILayout.LabelField("字段类型", type.ToString());
                        }
                        else
                        {
                            EditorGUILayout.LabelField("字段类型", type.ToString() + "/" + table.GetEnumType(keyTmp));
                        }

                        EditorGUILayout.LabelField("(默认)字段内容", new SingleField(type, newContent, table.GetEnumType(keyTmp)).GetShowString());

                        if (cancelDefault)
                        {
                            data.Add(keyTmp, newContent);
                        }
                    }

                    EditorGUI.indentLevel--;
                    //EditorGUI.indentLevel--;
                }

                EditorGUILayout.Space();
            }
        }
        catch (Exception e)
        {
            EditorGUILayout.TextArea(e.ToString(), EditorGUIStyleData.s_ErrorMessageLabel);
        }

        return(data);
    }
    SingleData EditorDataGUI(DataTable table, SingleData data)
    {
        List <string> keys = table.TableKeys;

        for (int i = 0; i < keys.Count; i++)
        {
            string    keyTmp = keys[i];
            FieldType type   = table.GetFieldType(keyTmp);

            if (i != 0)
            {
                if (data.ContainsKey(keyTmp))
                {
                    EditorGUILayout.BeginHorizontal();

                    EditorGUILayout.LabelField("字段名", keyTmp);

                    if (GUILayout.Button("使用默认值"))
                    {
                        data.Remove(keyTmp);
                        EditorGUILayout.EndHorizontal();

                        continue;
                    }

                    EditorGUILayout.EndHorizontal();

                    string newContent = EditorUtilGUI.FieldGUI_TypeValue(type, data[keyTmp]);

                    if (newContent != data[keyTmp])
                    {
                        data[keyTmp] = newContent;
                    }
                }
                else
                {
                    bool cancelDefault = false;

                    EditorGUILayout.BeginHorizontal();

                    EditorGUILayout.LabelField("字段名", keyTmp);

                    if (GUILayout.Button("取消默认值"))
                    {
                        cancelDefault = true;
                    }

                    EditorGUILayout.EndHorizontal();

                    string newContent = "";

                    if (table.m_defaultValue.ContainsKey(keyTmp))
                    {
                        newContent = new SingleField(type, table.GetDefault(keyTmp)).m_content;
                    }
                    else
                    {
                        newContent = new SingleField(type, null).m_content;
                    }

                    EditorGUILayout.LabelField("字段类型", type.ToString());
                    EditorGUILayout.LabelField("(默认值)字段内容", new SingleField(type, newContent).GetShowString());

                    if (cancelDefault)
                    {
                        data.Add(keyTmp, newContent);
                    }
                }
            }

            EditorGUILayout.Space();
        }

        return(data);
    }
    SingleData EditorDataGUI(DataTable table, SingleData data)
    {
        try
        {
            List<string> keys = table.TableKeys;
            for (int i = 0; i < keys.Count; i++)
            {
                string keyTmp = keys[i];
                FieldType type = table.GetFieldType(keyTmp);

                if (i != 0)
                {
                    bool cancelDefault = false;
                    EditorGUILayout.BeginHorizontal();

                    if (data.ContainsKey(keyTmp))
                    {
                        EditorGUILayout.LabelField("[" + keyTmp + "]");

                        if (GUILayout.Button("使用默认值"))
                        {
                            data.Remove(keyTmp);
                            EditorGUILayout.EndHorizontal();

                            continue;
                        }
                    }
                    else
                    {
                        EditorGUILayout.LabelField("[" + keyTmp + "] (默认值)");
                        if (GUILayout.Button("取消默认值"))
                        {
                            cancelDefault = true;
                        }
                    }

                    EditorGUILayout.EndHorizontal();

                    //EditorGUI.indentLevel++;
                    EditorGUI.indentLevel++;

                    //非默认值情况
                    if (data.ContainsKey(keyTmp))
                    {
                        EditorGUILayout.LabelField("字段名", keyTmp);
                        EditorGUILayout.LabelField("注释", table.GetNote(keyTmp));

                        string newContent = EditorUtilGUI.FieldGUI_TypeValue(type, data[keyTmp], table.GetEnumType(keyTmp));

                        if (newContent != data[keyTmp])
                        {
                            data[keyTmp] = newContent;
                        }
                    }
                    //如果是默认值则走这里
                    else
                    {
                        EditorGUILayout.LabelField("字段名", keyTmp);
                        EditorGUILayout.LabelField("注释", table.GetNote(keyTmp));
                        string newContent = "";

                        if (table.m_defaultValue.ContainsKey(keyTmp))
                        {
                            newContent = new SingleField(type, table.GetDefault(keyTmp), table.GetEnumType(keyTmp)).m_content;
                        }
                        else
                        {
                            newContent = new SingleField(type, null, table.GetEnumType(keyTmp)).m_content;
                        }

                        if (type != FieldType.Enum)
                        {
                            EditorGUILayout.LabelField("字段类型", type.ToString());
                        }
                        else
                        {
                            EditorGUILayout.LabelField("字段类型", type.ToString() + "/" + table.GetEnumType(keyTmp));
                        }

                        EditorGUILayout.LabelField("(默认)字段内容", new SingleField(type, newContent, table.GetEnumType(keyTmp)).GetShowString());

                        if (cancelDefault)
                        {
                            data.Add(keyTmp, newContent);
                        }
                    }

                    EditorGUI.indentLevel--;
                    //EditorGUI.indentLevel--;
                }

                EditorGUILayout.Space();
            }
        }
        catch(Exception e)
        {
            EditorGUILayout.TextArea(e.ToString(),EditorGUIStyleData.s_ErrorMessageLabel);
        }

        return data;
    }
Exemple #8
0
    /// <summary>
    /// 绘制每个数据格子
    /// </summary>
    /// <param name="startPos"></param>
    private void DrawGridItem(Vector2 startPos)
    {
        helpBoxStyle.fontSize = nowButtonFontSize;
        float tempHeight = 0;

        for (int i = 0; i < heightItemList.Count; i++)
        {
            float h        = heightItemList[i];
            float tempWith = 0;


            for (int j = 0; j < withItemList.Count; j++)
            {
                float w = withItemList[j];

                Vector2 size = new Vector2(w, h);
                Vector2 pos  = startPos + new Vector2(tempWith, tempHeight);

                object value   = null;
                string showStr = "";

                string    field          = m_currentData.TableKeys[j];
                FieldType fieldValueType = GetFieldType(j, field);
                string    enumType       = GetEnumType(fieldValueType, field);

                string defaultValue = GetDefaultValue(fieldValueType, enumType, field);


                if (i == 0)
                {
                    GUI.color = Color.yellow;

                    showStr = EditorDrawGUIUtil.GetFormatName(field, DataConfigUtils.ConfigFieldValueType2Type(fieldValueType, enumType), "red");
                }
                else if (i == 1)
                {
                    GUI.color = Color.cyan;

                    showStr = GetDescription(field);
                }
                else if (i == 2)
                {
                    GUI.color = Color.green;

                    showStr = defaultValue;
                }
                else
                {
                    SingleData data = m_currentData[m_currentData.TableIDs[i - 3]];

                    bool isDefault = false;
                    if (data.ContainsKey(field) && data[field] != defaultValue)
                    {
                        DataFieldAssetType fieldAssetType = GetDataFieldAssetType(field);
                        if (fieldAssetType == DataFieldAssetType.LocalizedLanguage)
                        {
                            string k = data[field];
                            if (LanguageManager.HaveKey(k))
                            {
                                showStr = LanguageManager.GetContentByKey(k);
                            }
                            else
                            {
                                showStr = k;
                            }
                        }
                        else
                        {
                            showStr = data[field];
                        }
                    }
                    else
                    {
                        showStr   = defaultValue;
                        isDefault = true;
                    }
                    if (!string.IsNullOrEmpty(searchValue))
                    {
                        showStr = ShowContainsChar(showStr, searchValue);
                    }

                    if (isDefault)
                    {
                        showStr = "<color=green>" + showStr + "</color>";
                    }
                }

                if (i == 1 || i == 2)
                {
                    GUI.Button(new Rect(pos, size), showStr, helpBoxStyle);
                }
                else
                {
                    if (selectColumnIndexs.Contains(j))
                    {
                        GUI.color = Color.magenta;
                    }
                    if (selectRowIndexs.Contains(i))
                    {
                        GUI.color = Color.cyan;
                    }
                    if (GUI.Button(new Rect(pos, size), showStr, helpBoxStyle))
                    {
                        modifiIndex = new Vector2Int(i - 2, j);
                        if (i == 0)
                        {
                            TableConfigFieldInfo f = new TableConfigFieldInfo();
                            f.fieldName      = field;
                            f.description    = m_currentData.m_noteValue.ContainsKey(field) ? m_currentData.m_noteValue[field] : "";
                            f.fieldValueType = fieldValueType;
                            f.defultValue    = DataConfigUtils.TableString2ObjectValue(defaultValue, fieldValueType, enumType);
                            f.enumType       = enumType;
                            f.fieldAssetType = GetDataFieldAssetType(field);
                            value            = f;
                        }
                        else
                        {
                            SingleData data = m_currentData[m_currentData.TableIDs[i - 3]];

                            if (data.ContainsKey(field))
                            {
                                defaultValue = data[field];
                            }
                            value = DataConfigUtils.TableString2ObjectValue(defaultValue, fieldValueType, enumType);
                        }
                        GeneralDataModificationWindow.OpenWindow(this, "修改数据", value, DrawModifiValueGUI, CheckModifiValueCallBack, ModificationCompleteCallBack);
                    }
                }

                GUI.color = Color.white;
                tempWith += w;
            }

            tempHeight += h;
        }
        helpBoxStyle.fontSize = oldButtonFontSize;
    }