Beispiel #1
0
        public bool AddAssetTypes(string fullFileName, List <AssetTypeInfo> listToFill, bool tolerateFailure = false)
        {
            bool succeeded = true;

            List <AssetTypeInfo> newTypes = new List <AssetTypeInfo>();

            try
            {
                CsvFileManager.CsvDeserializeList(typeof(AssetTypeInfo), fullFileName, newTypes);
            }
            catch (Exception e)
            {
                succeeded = false;

                if (tolerateFailure)
                {
#if GLUE
                    // let's report it:
                    PluginManager.ReceiveError("Error loading CSV: " + fullFileName + "\n" + e.ToString());
#endif
                }
                else
                {
                    throw e;
                }
            }
            if (succeeded)
            {
#if GLUE
                PluginManager.ReceiveOutput("Loading content types from " + fullFileName + " and found " + newTypes.Count + " types");
#endif
                listToFill.AddRange(newTypes);
            }
            return(succeeded);
        }
Beispiel #2
0
        public static void LoadAvaliableProjectFromCsv()
        {
            var fileName = "Content/EmptyTemplates.csv";

            var absoluteFile = FileManager.RelativeDirectory + fileName;

            if (!File.Exists(absoluteFile))
            {
                MessageBox.Show($"{Resources.LoadProjectTip1}{absoluteFile}{Resources.LoadProjectTip2}");
            }
            else
            {
                EmptyProjects.Clear();
                CsvFileManager.CsvDeserializeList(typeof(PlatformProjectInfo), fileName, EmptyProjects);
            }


            fileName = "Content/StarterProjects.csv";

            absoluteFile = FileManager.RelativeDirectory + fileName;

            if (!File.Exists(absoluteFile))
            {
                MessageBox.Show($"{Resources.LoadProjectTip3}{absoluteFile}{Resources.LoadProjectTip4}");
            }
            else
            {
                StarterProjects.Clear();
                CsvFileManager.CsvDeserializeList(typeof(PlatformProjectInfo), fileName, StarterProjects);
            }
        }
Beispiel #3
0
        public static void LoadAvailableProjectsFromCsv()
        {
            string fileName = "Content/EmptyTemplates.csv";

            string absoluteFile = FileManager.RelativeDirectory + fileName;

            if (!File.Exists(absoluteFile))
            {
                MessageBox.Show("The New Project Creator is missing a critical file called EmptyTemplates.csv.  Full path is\n\n" +
                                absoluteFile + "\n\nThis file is needed to get the list of available projects that the New Project Creator can create");
            }
            else
            {
                CsvFileManager.CsvDeserializeList(typeof(PlatformProjectInfo), fileName, emptyProjects);
            }

            fileName = "Content/StarterProjects.csv";

            absoluteFile = FileManager.RelativeDirectory + fileName;

            if (!File.Exists(absoluteFile))
            {
                MessageBox.Show("The New Project Creator is missing a critical file called StarterProjects.csv.  Full path is\n\n" +
                                absoluteFile + "\n\nThis file is needed to get the list of available projects that the New Project Creator can create");
            }
            else
            {
                CsvFileManager.CsvDeserializeList(typeof(PlatformProjectInfo), fileName, starterProjects);
            }
        }
Beispiel #4
0
        public void LoadExternalBuildToolsFromCsv(string csvFileName)
        {
            List <BuildToolAssociation> externals = new List <BuildToolAssociation>();

            CsvFileManager.CsvDeserializeList(typeof(BuildToolAssociation), csvFileName, externals);

            BuildToolAssociations.AddExternalRange(externals);
        }
Beispiel #5
0
        public static BuildToolAssociationList FromFileCsv(string fileName)
        {
            BuildToolAssociationList toReturn = new BuildToolAssociationList();

            CsvFileManager.CsvDeserializeList(typeof(BuildToolAssociation), fileName, toReturn.BuildToolList);

            return(toReturn);
        }
Beispiel #6
0
        public void Initialize(string contentTypesFileLocation, string startupPath)
        {
            mStartupPath           = startupPath;
            mCoreTypesFileLocation = contentTypesFileLocation;

            if (!File.Exists(contentTypesFileLocation))
            {
                throw new Exception("Could not find the file " + contentTypesFileLocation + " when trying to initialize the AvailableAssetTypes");
            }
            try
            {
                // We create a temporary
                // list to deserialize to
                // so that we can take the contents
                // and insert them at the front of the
                // list.  This makes the default implementations
                // show up first in the list so they can be found
                // first if searching by runtime type name.
                //List<AssetTypeInfo> tempList = new List<AssetTypeInfo>();
                // Update:  We now have a core asset types list
                CsvFileManager.CsvDeserializeList(typeof(AssetTypeInfo), contentTypesFileLocation, mCoreAssetTypes);
            }
            catch (Exception e)
            {
                string message = "Could not load the AssetTypes from\n" +
                                 contentTypesFileLocation + "\nThis probably means your ContentTypes.csv is corrupt (the file was found).  You should re-install Glue.";


                throw new Exception(message, e);
            }



            if (Directory.Exists(GlobalCustomContentTypesFolder))
            {
                List <string> extraCsvs = FileManager.GetAllFilesInDirectory(GlobalCustomContentTypesFolder, "csv", 0);

                foreach (string file in extraCsvs)
                {
                    try
                    {
                        AddAssetTypes(file);
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show("Failed to add additional asset types from file " + file + "\n\nError info:\n" + e);
                    }
                }
            }
        }
Beispiel #7
0
        void CustomInitialize()
        {
            if (StaticVariableEntity.FromGlobalCsv == null)
            {
                throw new Exception("Referencing a static entity's CSV variables is not working becaus the static variable is not properly set.  This variable is of a type defined in GlobalContent.");
            }

            // check if constants are made properly
            string in1 = SpreadsheetClass.FirstGuy;

            // to ignore warnings
            if (in1 != null)
            {
            }

            string in2 = SpreadsheetClass.GuyInFile2;

            if (in2 != null)
            {
            }

            if (GlobalCsvVariable.Name != "Name2")
            {
                throw new Exception("Variables using global CSVs in Screens are not getting their values set");
            }

            if (GlobalCsvVariableWithEvent.Name != "Name3")
            {
                throw new Exception("Variables with events using global CSVs in Screens are not getting their values set");
            }

            if (mHasCsvVariableEventBeenRaised == false)
            {
                throw new Exception("Events for CSV variables that are set in Glue are not raised");
            }

            if (new DataTypes.Spreadsheet().ListOfString == null)
            {
                throw new Exception("new instances of CSV objects should 'new' any lists");
            }

            // Check that the class with no associated CSV actually exists - we'll get a compile error if not:
            ClassWithNoAssociatedCsvs instance = new ClassWithNoAssociatedCsvs();

            var list = CsvFileManager.CsvDeserializeList(typeof(ManualCsvClass),
                                                         "Content/Screens/CsvScreen/CsvManuallyLoadedForPropertyTest.csv");

            ManualCsvClass entry = list[0] as ManualCsvClass;

            if (entry.StringList.Count == 0)
            {
                throw new NotImplementedException("CSVs that contain lists which are deserialized into properties are not set");
            }

            if (CsvUsingCustomDataFile["First"].StringListField.Count == 0)
            {
                throw new Exception("Primitive (string) lists as fields in custom data are not being deserialized properly");
            }

            if (CsvUsingCustomDataFile["First"].StringListProperty.Count == 0)
            {
                throw new Exception("Primitive (string) lists as properties in custom data are not being deserialized properly");
            }

            if (CsvUsingCustomDataFile["First"].ComplexCustomTypeListField.Count == 0)
            {
                throw new Exception("Complex type lists as fields in custom data are not being deserialized properly");
            }

            if (CsvUsingCustomDataFile["First"].ComplexCustomTypeListProperty.Count == 0)
            {
                throw new Exception("Complex type lists as properties in custom data are not being deserialized properly");
            }

            if (CsvUsingCustomDataFile["First"].ComplexCustomTypeListProperty[1].CustomEnumType != CustomDataTypes.CustomEnumType.Enum2)
            {
                throw new Exception("Enums in complex type property lists are not getting set.");
            }

            if (CsvUsingCustomDataFile["First"].StringProperty != "Test1")
            {
                throw new Exception("String properties are not being set correctly");
            }
        }