Exemplo n.º 1
0
 void OnFocus()
 {
     if (GDEItemManager.AllItems.Count.Equals(0) && GDEItemManager.AllSchemas.Count.Equals(0))
     {
         GDEItemManager.Load();
     }
 }
        protected override float CalculateGroupHeightsTotal()
        {
            float  totalHeight  = 0;
            float  schemaHeight = 0;
            string schema       = "";

            foreach (KeyValuePair <string, float> pair in groupHeights)
            {
                Dictionary <string, object> itemData;
                GDEItemManager.AllItems.TryGetValue(pair.Key, out itemData);
                if (ShouldFilter(pair.Key, itemData))
                {
                    continue;
                }

                //Check to see if this item's height has been updated
                //otherwise use the min height for the schema
                if (entryFoldoutState.Contains(pair.Key) && pair.Value.NearlyEqual(GDEConstants.LineHeight))
                {
                    schema = GDEItemManager.GetSchemaForItem(pair.Key);
                    groupHeightBySchema.TryGetValue(schema, out schemaHeight);
                    totalHeight += schemaHeight;
                }
                else
                {
                    totalHeight += pair.Value;
                }
            }

            return(totalHeight);
        }
Exemplo n.º 3
0
        void CreateSchema(string name, List <FieldInfo> fields)
        {
            string error;
            Dictionary <string, object> schemaData = new Dictionary <string, object>();

            GDEItemManager.AddSchema(name, schemaData, out error, true);

            foreach (FieldInfo field in fields)
            {
                if (field.skip)
                {
                    continue;
                }
                else if (field.type != BasicFieldType.Undefined)
                {
                    GDEItemManager.AddBasicFieldToSchema(field.type, name, schemaData, field.name, out error, field.isList,
                                                         field.is2DList, GDEItemManager.GetDefaultValueForType(field.type));
                }
                else
                {
                    GDEItemManager.AddCustomFieldToSchema(field.customType, name, schemaData, field.name, field.isList, field.is2DList, out error);
                }

                if (error != string.Empty)
                {
                    Debug.LogError(string.Format(GDEConstants.ErrorInSheet, name, error, field.cellID));
                }
            }
        }
        protected override bool Create(object data)
        {
            bool          result    = true;
            List <object> args      = data as List <object>;
            string        schemaKey = args[0] as string;
            string        itemName  = args[1] as string;

            Dictionary <string, object> schemaData = null;

            if (GDEItemManager.AllSchemas.TryGetValue(schemaKey, out schemaData))
            {
                Dictionary <string, object> itemData = schemaData.DeepCopy();
                itemData.Add(GDMConstants.SchemaKey, schemaKey);

                string error;
                if (GDEItemManager.AddItem(itemName, itemData, out error))
                {
                    SetFoldout(true, itemName);
                    SetNeedToSave(true);
                }
                else
                {
                    result = false;
                    EditorUtility.DisplayDialog(GDEConstants.ErrorCreatingItem, error, GDEConstants.OkLbl);
                }
            }
            else
            {
                result = false;
                EditorUtility.DisplayDialog(GDEConstants.ErrorLbl, GDEConstants.SchemaNotFound + ": " + schemaKey, GDEConstants.OkLbl);
            }

            return(result);
        }
Exemplo n.º 5
0
        static void AppendResetAllMethod(StringBuilder sb, string schemaKey, Dictionary <string, object> schemaData)
        {
            bool shouldAppendSpace = false;

            sb.Append("".PadLeft(GDECodeGenConstants.IndentLevel2));
            sb.Append(GDECodeGenConstants.ResetAllDeclaration);
            sb.Append("\n");

            // Reset all fields
            List <string> fields = GDEItemManager.SchemaFieldKeys(schemaKey, schemaData);

            foreach (string fieldName in fields)
            {
                if (shouldAppendSpace)
                {
                    sb.Append("\n");
                }

                sb.Append("".PadLeft(GDECodeGenConstants.IndentLevel3));
                sb.AppendFormat(GDECodeGenConstants.ResetToDefaultFormat, fieldName);
                shouldAppendSpace = true;
            }

            if (shouldAppendSpace)
            {
                sb.Append("\n");
            }

            // Call reset on any custom types
            for (int dimension = 0; dimension <= 2; dimension++)
            {
                fields = GDEItemManager.SchemaCustomFieldKeys(schemaKey, dimension);
                foreach (string fieldName in fields)
                {
                    if (shouldAppendSpace)
                    {
                        sb.Append("\n");
                    }

                    sb.Append("".PadLeft(GDECodeGenConstants.IndentLevel3));

                    if (dimension == 0)
                    {
                        sb.AppendFormat(GDECodeGenConstants.CustomResetAllFormat, fieldName);
                    }
                    else
                    {
                        sb.AppendFormat(GDECodeGenConstants.CustomResetAllFormat, fieldName);
                    }

                    shouldAppendSpace = true;
                }
            }

            sb.Append("\n");
            sb.Append("\n");

            sb.Append("".PadLeft(GDECodeGenConstants.IndentLevel3));
            sb.Append(GDECodeGenConstants.ResetAllEndMethod);
        }
Exemplo n.º 6
0
        public static void GenStaticKeysClass(Dictionary <string, Dictionary <string, object> > allSchemas)
        {
            Debug.Log(GDEConstants.GeneratingLbl + " " + GDECodeGenConstants.StaticKeysFilePath);
            StringBuilder sb = new StringBuilder();

            sb.Append(GDECodeGenConstants.AutoGenMsg);
            sb.Append("\n");
            sb.Append(GDECodeGenConstants.StaticKeyClassHeader);

            foreach (KeyValuePair <string, Dictionary <string, object> > pair in allSchemas)
            {
                string schema = pair.Key;

                List <string> items = GDEItemManager.GetItemsOfSchemaType(schema);
                foreach (string item in items)
                {
                    sb.Append("\n");
                    sb.Append("".PadLeft(GDECodeGenConstants.IndentLevel2));
                    sb.AppendFormat(GDECodeGenConstants.StaticKeyFormat, schema, item);
                }
            }

            sb.Append("\n");
            sb.Append("}".PadLeft(GDECodeGenConstants.IndentLevel1 + 1));
            sb.Append("\n");
            sb.Append("}");
            sb.Append("\n");

            File.WriteAllText(GDESettings.FullRootDir + Path.DirectorySeparatorChar + GDECodeGenConstants.StaticKeysFilePath, sb.ToString());

            Debug.Log(GDEConstants.DoneGeneratingLbl + " " + GDECodeGenConstants.StaticKeysFilePath);
        }
        private void RemoveField(string schemaKey, Dictionary <string, object> schemaData, string deletedFieldKey)
        {
            newListCountDict.Remove(string.Format(GDMConstants.MetaDataFormat, schemaKey, deletedFieldKey));
            GDEItemManager.RemoveFieldFromSchema(schemaKey, schemaData, deletedFieldKey);

            SetNeedToSave(true);
        }
Exemplo n.º 8
0
        public static void GenStaticKeysClass(Dictionary <string, Dictionary <string, object> > allSchemas)
        {
            string fileName = string.Format(GDECodeGenConstants.StaticItemKeysFileName, Path.GetFileNameWithoutExtension(GDESettings.Instance.DataFilePath));

            Debug.Log(GDEConstants.GeneratingLbl + " " + fileName);

            StringBuilder sb = new StringBuilder();

            sb.AppendFormat(GDECodeGenConstants.AutoGenMsg, GDESettings.Instance.DataFilePath);
            sb.Append("\n");
            sb.Append(GDECodeGenConstants.StaticItemKeyClassHeader);

            foreach (KeyValuePair <string, Dictionary <string, object> > pair in allSchemas)
            {
                string schema = pair.Key;

                List <string> items = GDEItemManager.GetItemsOfSchemaType(schema);
                foreach (string item in items)
                {
                    sb.Append("\n");
                    sb.Append("".PadLeft(GDECodeGenConstants.IndentLevel2));
                    sb.AppendFormat(GDECodeGenConstants.StaticItemKeyFormat, schema, item);
                }
            }

            sb.Append("\n");
            sb.Append("}".PadLeft(GDECodeGenConstants.IndentLevel1 + 1));
            sb.Append("\n");
            sb.Append("}");
            sb.Append("\n");

            WriteFile(sb, fileName);
        }
Exemplo n.º 9
0
        static void AppendUpdateCustomItemsMethod(StringBuilder sb, string schemaKey, Dictionary <string, object> schemaData)
        {
            sb.Append("".PadLeft(GDECodeGenConstants.IndentLevel2));
            sb.AppendFormat(GDECodeGenConstants.UpdateCustomItemsMethod, schemaKey);
            sb.Append("\n");

            bool shouldAppendSpace        = false;
            bool didAppendSpaceForSection = false;
            bool isFirstSection           = true;

            // Append the custom lists
            for (int dimension = 0; dimension <= 2; dimension++)
            {
                foreach (string fieldKey in GDEItemManager.SchemaCustomFieldKeys(schemaKey, dimension))
                {
                    if (shouldAppendSpace && !didAppendSpaceForSection && !isFirstSection)
                    {
                        sb.Append("\n");
                    }

                    AppendUpdateCustomItemVariable(sb, fieldKey, dimension);

                    shouldAppendSpace        = true;
                    isFirstSection           = false;
                    didAppendSpaceForSection = true;
                }
            }

            sb.Append("".PadLeft(GDECodeGenConstants.IndentLevel2));
            sb.Append(GDECodeGenConstants.UpdateCustomItemsEnd);
            sb.Append("\n");
        }
Exemplo n.º 10
0
        string Convert2DListToSheetFormat(BasicFieldType type, object value)
        {
            string result = string.Empty;

            if (GDEItemManager.IsUnityType(type))
            {
                var   pathList = new List <List <string> >();
                IList goList   = value as IList;
                foreach (var sublist in goList)
                {
                    IList list        = sublist as IList;
                    var   pathSubList = new List <string>();
                    foreach (var go in list)
                    {
                        pathSubList.Add(GDEItemManager.GetJsonRepresentation(go as UnityEngine.Object));
                    }
                    pathList.Add(pathSubList);
                }

                // Now convert the path 2d list to json
                result = Json.Serialize(pathList);
            }
            else
            {
                result = Json.Serialize(value);
            }

            return(result);
        }
Exemplo n.º 11
0
        static void AppendListVariable(StringBuilder sb, string type, string name, int dimension)
        {
            string formattedType = type;

            if (GDEItemManager.IsUnityType(type))
            {
                formattedType = "UnityObject";
            }
            else
            {
                formattedType = type.UppercaseFirst();
            }

            sb.Append("".PadLeft(GDECodeGenConstants.IndentLevel2));

            if (dimension == 1)
            {
                sb.AppendFormat(GDECodeGenConstants.OneDListVariableFormat, type, name, formattedType);
            }
            else
            {
                sb.AppendFormat(GDECodeGenConstants.TwoDListVariableFormat, type, name, formattedType + GDECodeGenConstants.TwoDListSuffix);
            }

            sb.Append("\n");
        }
Exemplo n.º 12
0
        public void ProcessSheet()
        {
            try
            {
                // Clear any data already loaded into the GDEItemManager
                GDEItemManager.ClearAll();
                GDEItemManager.Save();

                List <string> sheetNames = GetSheetNames();
                Dictionary <string, List <FieldInfo> > allFields    = new Dictionary <string, List <FieldInfo> >();
                Dictionary <string, ExcelRange>        allSheetData = new Dictionary <string, ExcelRange>();

                // Calculate Progressbar settings
                progressMessage = GDEConstants.ImportingScehemasLbl;
                processedItems  = 0;
                totalItems      = sheetNames.Count;

                // Create all the schemas first
                foreach (string name in sheetNames)
                {
                    if (OnUpdateProgress != null)
                    {
                        OnUpdateProgress(GDEConstants.ImportingGameDataLbl, progressMessage, processedItems / totalItems);
                    }

                    ExcelRange sheetRows = GetSheetData(name);
                    allSheetData.Add(name, sheetRows);

                    List <FieldInfo> fields = GetFields(name, sheetRows);
                    allFields.Add(name, fields);

                    CreateSchema(name, fields);

                    processedItems++;
                }

                // Calculate Progressbar settings
                progressMessage = GDEConstants.ImportingItemsLbl;
                processedItems  = 0;
                totalItems      = 0;

                // Then create all the items for each schema
                foreach (string name in sheetNames)
                {
                    ExcelRange       sheetRows = allSheetData[name];
                    List <FieldInfo> fields    = allFields[name];

                    CreateItems(name, fields, sheetRows);
                }

                GDEItemManager.Save();
            }
            catch (Exception ex)
            {
                Debug.LogError(ex);
            }
        }
Exemplo n.º 13
0
        public static void DoGenerateCustomExtensions()
        {
            GDEItemManager.Load();

            GDECodeGen.GenStaticKeysClass(GDEItemManager.AllSchemas);
            GDECodeGen.GenClasses(GDEItemManager.AllSchemas);

            AssetDatabase.Refresh();
        }
Exemplo n.º 14
0
        static void GDELoadData()
        {
            string assetPath = AssetDatabase.GetAssetPath(Selection.activeObject);
            string fullPath  = Path.GetFullPath(assetPath);

            GDESettings.Instance.DataFilePath = fullPath;
            GDESettings.Instance.Save();

            GDEItemManager.Load(true);
        }
Exemplo n.º 15
0
        static void AppendSaveToDictMethod(StringBuilder sb, string schemaKey, Dictionary <string, object> schemaData)
        {
            sb.Append("".PadLeft(GDECodeGenConstants.IndentLevel2));
            sb.AppendFormat(GDECodeGenConstants.SaveToDictMethod, schemaKey);
            sb.Append("\n");

            bool shouldAppendSpace        = false;
            bool didAppendSpaceForSection = false;
            bool isFirstSection           = true;

            // Append the basic types
            for (int dimension = 0; dimension <= 2; dimension++)
            {
                foreach (BasicFieldType fieldType in GDEItemManager.BasicFieldTypes)
                {
                    List <string> fieldKeys = GDEItemManager.SchemaFieldKeysOfType(schemaKey, fieldType.ToString(), dimension);

                    foreach (string fieldKey in fieldKeys)
                    {
                        if (shouldAppendSpace && !didAppendSpaceForSection && !isFirstSection)
                        {
                            sb.Append("\n");
                        }

                        AppendSaveToDictVariable(sb, fieldKey);
                        shouldAppendSpace        = true;
                        didAppendSpaceForSection = true;
                        isFirstSection           = false;
                    }
                }
                didAppendSpaceForSection = false;
            }

            // Append the custom lists
            for (int dimension = 0; dimension <= 2; dimension++)
            {
                foreach (string fieldKey in GDEItemManager.SchemaCustomFieldKeys(schemaKey, dimension))
                {
                    if (shouldAppendSpace && !didAppendSpaceForSection && !isFirstSection)
                    {
                        sb.Append("\n");
                    }

                    AppendSaveToDictVariable(sb, fieldKey);

                    shouldAppendSpace        = true;
                    isFirstSection           = false;
                    didAppendSpaceForSection = true;
                }
            }

            sb.Append("".PadLeft(GDECodeGenConstants.IndentLevel3));
            sb.Append(GDECodeGenConstants.SaveToDictEnd);
            sb.Append("\n");
        }
        protected override bool ShouldFilter(string schemaKey, Dictionary <string, object> schemaData)
        {
            bool schemaKeyMatch = schemaKey.ToLower().Contains(filterText.ToLower());
            bool fieldKeyMatch  = !GDEItemManager.ShouldFilterByField(schemaKey, filterText);

            // Return if the schema keys don't contain the filter text or
            // if the schema fields don't contain the filter text
            if (!schemaKeyMatch && !fieldKeyMatch)
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 17
0
        protected virtual void Load()
        {
            GDEItemManager.Load();

            entryFoldoutState.Clear();
            listFieldFoldoutState.Clear();
            currentFoldoutAllState = false;
            newListCountDict.Clear();
            filterText = "";
            groupHeights.Clear();
            groupHeightBySchema.Clear();
            editingFields.Clear();
            editFieldTextDict.Clear();
        }
Exemplo n.º 18
0
        public static void DoExport(bool newSheet = false)
        {
            GDESettings settings = GDESettings.Instance;

            if (!GDEItemManager.FileChangedOnDisk(GDEItemManager.DataFilePath, settings.ExportFileMD5))
            {
                Debug.Log("GDE Data hasn't changed, skipping export.");
                return;
            }

            if (settings.ExportType.Equals(ImportExportType.Local) &&
                !string.IsNullOrEmpty(settings.ExportedLocalSpreadsheetName))
            {
                // take the local languages dictionary
                // write it out to an excel file
                GDEExcelDataHelper excelHelper = new GDEExcelDataHelper(settings.ExportedLocalSpreadsheetName, true);
                excelHelper.ExportToSheet(GDEItemManager.ItemListBySchema);
                settings.ExportFileMD5 = File.ReadAllText(GDEItemManager.DataFilePath).Md5Sum();
            }
            else if (settings.ExportType.Equals(ImportExportType.Google) &&
                     !string.IsNullOrEmpty(settings.ExportedGoogleSpreadsheetPath) &&
                     GDEDriveHelper.Instance.HasAuthenticated())
            {
                GDEDriveHelper.Instance.GetSpreadsheetList();

                string tempSheetPath = FileUtil.GetUniqueTempPathInProject() + "exportnewgoog_" + settings.ExportedGoogleSpreadsheetPath + ".xlsx";

                GDEExcelDataHelper excelHelper = new GDEExcelDataHelper(tempSheetPath, true);
                excelHelper.ExportToSheet(GDEItemManager.ItemListBySchema);

                if (newSheet)
                {
                    GDEDriveHelper.Instance.UploadNewSheet(tempSheetPath, settings.ExportedGoogleSpreadsheetPath);
                    settings.ExportFileMD5 = File.ReadAllText(GDEItemManager.DataFilePath).Md5Sum();
                }
                else
                {
                    GDEDriveHelper.Instance.UploadToExistingSheet(settings.ExportedGoogleSpreadsheetPath, tempSheetPath);
                    settings.ExportFileMD5 = File.ReadAllText(GDEItemManager.DataFilePath).Md5Sum();
                }
            }
            else
            {
                var window = EditorWindow.GetWindow <GameDataEditor.GDEExportExcel>(true, GDEConstants.ExportSpreadsheetLbl);
                window.LoadSettings();
                window.Show();
            }
        }
Exemplo n.º 19
0
        List <FieldInfo> GetFieldInfoFromSchema(string schemaKey, Dictionary <string, object> schemaData)
        {
            List <FieldInfo> fieldInfos = new List <FieldInfo>();
            List <string>    fieldKeys  = GDEItemManager.SchemaFieldKeys(schemaKey, schemaData);

            foreach (var fieldKey in fieldKeys)
            {
                int listDimension;

                FieldInfo field = new FieldInfo();

                field.name = fieldKey;
                string isListKey = string.Format(GDMConstants.MetaDataFormat, GDMConstants.IsListPrefix, fieldKey);
                schemaData.TryGetInt(isListKey, out listDimension);

                // Set the list dimension
                if (listDimension == 0)
                {
                    field.isList   = false;
                    field.is2DList = false;
                }
                else if (listDimension == 1)
                {
                    field.isList   = true;
                    field.is2DList = false;
                }
                else
                {
                    field.isList   = false;
                    field.is2DList = true;
                }

                // Parse the field type
                string customType;
                field.type = ParseFieldType(fieldKey, schemaData, out customType);
                if (field.type.Equals(BasicFieldType.Undefined))
                {
                    field.isCustom   = true;
                    field.customType = customType;
                }

                fieldInfos.Add(field);
            }

            return(fieldInfos);
        }
Exemplo n.º 20
0
        static void AppendVariable(StringBuilder sb, string type, string name)
        {
            string formattedType = type;

            if (GDEItemManager.IsUnityType(type))
            {
                formattedType = "UnityObject";
            }
            else
            {
                formattedType = type.UppercaseFirst();
            }

            sb.Append("".PadLeft(GDECodeGenConstants.IndentLevel2));
            sb.AppendFormat(GDECodeGenConstants.VariableFormat, type, name, formattedType);
            sb.Append("\n");
        }
        private bool AddCustomField(string customType, string schemaKey, Dictionary <string, object> schemaData, string newFieldName, bool isList)
        {
            bool   result = true;
            string error;

            if (GDEItemManager.AddCustomFieldToSchema(customType, schemaKey, schemaData, newFieldName, isList, out error))
            {
                SetNeedToSave(true);
            }
            else
            {
                EditorUtility.DisplayDialog(GDEConstants.ErrorCreatingField, error, GDEConstants.OkLbl);
                result = false;
            }

            return(result);
        }
        private bool AddBasicField(BasicFieldType type, string schemaKey, Dictionary <string, object> schemaData, string newFieldName, bool isList)
        {
            bool   result       = true;
            object defaultValue = GDEItemManager.GetDefaultValueForType(type);
            string error;

            if (GDEItemManager.AddBasicFieldToSchema(type, schemaKey, schemaData, newFieldName, out error, isList, defaultValue))
            {
                SetNeedToSave(true);
            }
            else
            {
                EditorUtility.DisplayDialog(GDEConstants.ErrorCreatingField, error, GDEConstants.OkLbl);
                result = false;
            }

            return(result);
        }
        protected override void Remove(string key)
        {
            // Show a warning if we have items using this schema
            List <string> items        = GDEItemManager.GetItemsOfSchemaType(key);
            bool          shouldDelete = true;

            if (items != null && items.Count > 0)
            {
                string itemWord = items.Count == 1 ? "item" : "items";
                shouldDelete = EditorUtility.DisplayDialog(string.Format("{0} {1} will be deleted!", items.Count, itemWord), GDEConstants.SureDeleteSchema, GDEConstants.DeleteSchemaBtn, GDEConstants.CancelBtn);
            }

            if (shouldDelete)
            {
                GDEItemManager.RemoveSchema(key, true);
                SetNeedToSave(true);
            }
        }
Exemplo n.º 24
0
        List <List <T> > LoadUnityType2DList <T>(string jsonText) where T : UnityEngine.Object
        {
            var goList = new List <List <T> >();

            var paths = Json.Deserialize(jsonText) as IList;

            foreach (var sublist in paths)
            {
                var   goSubList = new List <T>();
                IList list      = sublist as IList;
                foreach (var path in list)
                {
                    goSubList.Add(GDEItemManager.GetTypeFromJson <T>(path.ToString()));
                }
                goList.Add(goSubList);
            }

            return(goList);
        }
        protected override bool Create(object data)
        {
            bool   result = true;
            string key    = data as string;
            string error;

            result = GDEItemManager.AddSchema(key, new Dictionary <string, object>(), out error);
            if (result)
            {
                SetNeedToSave(true);
                SetFoldout(true, key);
            }
            else
            {
                EditorUtility.DisplayDialog(GDEConstants.ErrorCreatingSchema, error, GDEConstants.OkLbl);
                result = false;
            }

            return(result);
        }
Exemplo n.º 26
0
        static void AppendLoadSavedListVariable(StringBuilder sb, string type, string name, int dimension)
        {
            string formattedType = type;

            if (GDEItemManager.IsUnityType(type))
            {
                formattedType = "UnityObject";
            }

            sb.Append("".PadLeft(GDECodeGenConstants.IndentLevel3));

            if (dimension == 1)
            {
                sb.AppendFormat(GDECodeGenConstants.LoadSavedVariableListFormat, formattedType, name);
            }
            else
            {
                sb.AppendFormat(GDECodeGenConstants.LoadSavedVariableListFormat, formattedType + GDECodeGenConstants.TwoDListSuffix, name);
            }

            sb.Append("\n");
        }
Exemplo n.º 27
0
        static void ProcessSheet(string path)
        {
            try
            {
                GDEExcelDataHelper excelDataHelper = new GDEExcelDataHelper(path);
                excelDataHelper.OnUpdateProgress += delegate(string title, string msg, float progress) {
                    EditorUtility.DisplayProgressBar(title, msg, progress);
                };

                excelDataHelper.ProcessSheet();

                GDEItemManager.ClearCaches();
            }
            catch (Exception ex)
            {
                Debug.LogError(ex);
            }
            finally
            {
                EditorUtility.ClearProgressBar();
            }
        }
        protected override bool ShouldFilter(string itemKey, Dictionary <string, object> itemData)
        {
            if (itemData == null)
            {
                return(true);
            }

            string schemaType = "<unknown>";
            object temp;

            if (itemData.TryGetValue(GDMConstants.SchemaKey, out temp))
            {
                schemaType = temp as string;
            }

            // Return if we don't match any of the filter types
            if (GDEItemManager.FilterSchemaKeyArray.IsValidIndex(filterSchemaIndex) &&
                !GDEItemManager.FilterSchemaKeyArray[filterSchemaIndex].Equals("_All") &&
                !schemaType.Equals(GDEItemManager.FilterSchemaKeyArray[filterSchemaIndex]))
            {
                return(true);
            }

            bool schemaKeyMatch = schemaType.ToLower().Contains(filterText.ToLower());
            bool fieldKeyMatch  = !GDEItemManager.ShouldFilterByField(schemaType, filterText);
            bool itemKeyMatch   = itemKey.ToLower().Contains(filterText.ToLower());

            // Return if the schema keys don't contain the filter text or
            // if the schema fields don't contain the filter text
            if (!schemaKeyMatch && !fieldKeyMatch && !itemKeyMatch)
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 29
0
        static void AppendResetVariableMethods(StringBuilder sb, string schemaKey, Dictionary <string, object> schemaData)
        {
            bool shouldAppendSpace        = false;
            bool didAppendSpaceForSection = false;
            bool isFirstSection           = true;

            string variableType;

            // Append all the single variables first
            foreach (BasicFieldType fieldType in GDEItemManager.BasicFieldTypes)
            {
                variableType = fieldType.ToString();
                List <string> fieldKeys = GDEItemManager.SchemaFieldKeysOfType(schemaKey, fieldType.ToString(), 0);
                foreach (string fieldKey in fieldKeys)
                {
                    if (shouldAppendSpace)
                    {
                        sb.Append("\n");
                    }

                    AppendResetVariableMethod(sb, fieldKey, variableType);
                    shouldAppendSpace = true;
                    isFirstSection    = false;
                }
            }

            // Append all list variables
            for (int dimension = 1; dimension <= 2; dimension++)
            {
                foreach (BasicFieldType fieldType in GDEItemManager.BasicFieldTypes)
                {
                    variableType = fieldType.ToString();
                    List <string> fieldKeys = GDEItemManager.SchemaFieldKeysOfType(schemaKey, variableType, dimension);
                    foreach (string fieldKey in fieldKeys)
                    {
                        if (shouldAppendSpace && !didAppendSpaceForSection && !isFirstSection)
                        {
                            sb.Append("\n");
                        }

                        AppendResetListVariableMethod(sb, fieldKey, variableType, dimension);
                        shouldAppendSpace        = true;
                        didAppendSpaceForSection = true;
                        isFirstSection           = false;
                    }
                }
                didAppendSpaceForSection = false;
            }

            // Append all custom variables
            for (int dimension = 0; dimension <= 2; dimension++)
            {
                List <string> fieldKeys = GDEItemManager.SchemaCustomFieldKeys(schemaKey, dimension);
                foreach (string fieldKey in fieldKeys)
                {
                    if (shouldAppendSpace && !didAppendSpaceForSection && !isFirstSection)
                    {
                        sb.Append("\n");
                    }

                    schemaData.TryGetString(string.Format(GDMConstants.MetaDataFormat, GDMConstants.TypePrefix, fieldKey), out variableType);
                    variableType = string.Format(GDECodeGenConstants.DataClassNameFormat, variableType);

                    AppendResetCustomVariableMethod(sb, fieldKey, variableType, dimension);
                    shouldAppendSpace        = true;
                    didAppendSpaceForSection = true;
                    isFirstSection           = false;
                }

                didAppendSpaceForSection = false;
            }
        }
Exemplo n.º 30
0
        static void AppendDeepCloneMethod(StringBuilder sb, string schemaKey, Dictionary <string, object> schemaData)
        {
            sb.Append("".PadLeft(GDECodeGenConstants.IndentLevel2));
            sb.AppendFormat(GDECodeGenConstants.DeepCloneMethodStart, schemaKey);
            sb.Append("\n");

            bool shouldAppendSpace        = false;
            bool didAppendSpaceForSection = false;
            bool isFirstSection           = true;

            string variableType;

            // Custom Types
            foreach (string fieldKey in GDEItemManager.SchemaCustomFieldKeys(schemaKey, 0))
            {
                if (shouldAppendSpace && !didAppendSpaceForSection && !isFirstSection)
                {
                    sb.Append("\n");
                }

                sb.Append("".PadLeft(GDECodeGenConstants.IndentLevel3));
                sb.AppendFormat(GDECodeGenConstants.CustomTypeDeepFormat, fieldKey);
                sb.Append("\n");

                shouldAppendSpace        = true;
                didAppendSpaceForSection = true;
                isFirstSection           = false;
            }
            didAppendSpaceForSection = false;

            // Custom List Types
            for (int dimension = 1; dimension <= 2; dimension++)
            {
                foreach (string fieldKey in GDEItemManager.SchemaCustomFieldKeys(schemaKey, dimension))
                {
                    if (shouldAppendSpace && !didAppendSpaceForSection && !isFirstSection)
                    {
                        sb.Append("\n");
                    }

                    schemaData.TryGetString(string.Format(GDMConstants.MetaDataFormat, GDMConstants.TypePrefix, fieldKey), out variableType);

                    sb.Append("".PadLeft(GDECodeGenConstants.IndentLevel3));

                    if (dimension == 1)
                    {
                        sb.AppendFormat(GDECodeGenConstants.CustomListTypeDeepCloneFormat, fieldKey, "GDE" + variableType + "Data");
                    }
                    else
                    {
                        sb.AppendFormat(GDECodeGenConstants.CustomTwoDListTypeDeepCloneFormat, fieldKey, "GDE" + variableType + "Data");
                    }
                    sb.Append("\n");

                    shouldAppendSpace        = true;
                    didAppendSpaceForSection = true;
                    isFirstSection           = false;
                }
                didAppendSpaceForSection = false;
            }

            sb.Append("".PadLeft(GDECodeGenConstants.IndentLevel3));
            sb.Append(GDECodeGenConstants.CloneMethodEnd);
            sb.Append("\n");
        }