示例#1
0
            static RMGenFile CreateGenFileFromTempGenFileName(TempGenFileNameParsed parsedFileName, RMGenFile.GenFileType typeOfFile, string path)
            {
                RMGenFile newGenFile = new RMGenFile();

                newGenFile.BaseOrder = parsedFileName.BaseOrder;
                newGenFile.Colour    = parsedFileName.Colour;
                newGenFile.FileType  = typeOfFile;
                newGenFile.Order     = parsedFileName.Order;
                newGenFile.Path      = path;
                return(newGenFile);
            }
示例#2
0
            static RMGenPart CreateNewPart(TempGenFileNameParsed parsedFileName, RMGenPart.eGender gender, RMGeneratorCollection parent, int countToAppend)
            {
                RMGenPart tempPart = new RMGenPart();

                tempPart.Gender     = gender;
                tempPart.Name       = parsedFileName.Part.ToParsableXMLString() + "_" + countToAppend;
                tempPart.implicitID = parsedFileName.Position;
                tempPart.Parent     = parent;
                tempPart.PartType   = parsedFileName.Part;
                return(tempPart);
            }
示例#3
0
 static RMGenFile.GenFileType GetProperFileType(TempGenFileNameParsed parsedFileName, RMGenFile.GenFileType mainType)
 {
     if (mainType == RMGenFile.GenFileType.Face)
     {
         return(RMGenFile.GenFileType.Face);
     }
     else if (mainType == RMGenFile.GenFileType.None)
     {
         return(RMGenFile.GenFileType.None);
     }
     else if (mainType == RMGenFile.GenFileType.Var)
     {
         return(RMGenFile.GenFileType.Var);
     }
     else if (mainType == RMGenFile.GenFileType.SV)
     {
         if (parsedFileName.IsAcFile)
         {
             return(RMGenFile.GenFileType.SV_C);
         }
         else
         {
             return(RMGenFile.GenFileType.SV);
         }
     }
     else if (mainType == RMGenFile.GenFileType.TV)
     {
         if (parsedFileName.IsAcFile)
         {
             return(RMGenFile.GenFileType.TV_C);
         }
         else
         {
             return(RMGenFile.GenFileType.TV);
         }
     }
     else if (mainType == RMGenFile.GenFileType.TVD)
     {
         if (parsedFileName.IsAcFile)
         {
             return(RMGenFile.GenFileType.TVD_C);
         }
         else
         {
             return(RMGenFile.GenFileType.TVD);
         }
     }
     return(RMGenFile.GenFileType.None);
 }
示例#4
0
 static void VerifyFile(TempGenFileNameParsed whichFile, string path, RMGenFile.FileNameInfo requires = RMGenFile.FileNameInfo.Type | RMGenFile.FileNameInfo.Position)
 {
     if (requires.HasFlag(RMGenFile.FileNameInfo.Type) && whichFile.Part == RMGenPart.GenPartType.None)
     {
         throw new ImplicitInvalidGeneratorPartException(ExceptionMessages.RMPackage.GEN_FILE_NO_TYPE, ImplicitInvalidGeneratorPartException.WhichInvalid.Type, path);
     }
     else if (requires.HasFlag(RMGenFile.FileNameInfo.BaseOrder) && whichFile.BaseOrder == 0)
     {
         throw new ImplicitInvalidGeneratorPartException(ExceptionMessages.RMPackage.GEN_FILE_NO_HIGH_ORDER, ImplicitInvalidGeneratorPartException.WhichInvalid.BaseOrder, path);
     }
     else if (requires.HasFlag(RMGenFile.FileNameInfo.Colour) && whichFile.Colour == 0)
     {
         throw new ImplicitInvalidGeneratorPartException(ExceptionMessages.RMPackage.GEN_FILE_NO_COLOUR, ImplicitInvalidGeneratorPartException.WhichInvalid.Colour, path);
     }
     else if (requires.HasFlag(RMGenFile.FileNameInfo.Order) && whichFile.Order == 0)
     {
         throw new ImplicitInvalidGeneratorPartException(ExceptionMessages.RMPackage.GEN_FILE_NO_LOW_ORDER, ImplicitInvalidGeneratorPartException.WhichInvalid.Order, path);
     }
     else if (requires.HasFlag(RMGenFile.FileNameInfo.Position) && whichFile.Position < 0)
     {
         throw new ImplicitInvalidGeneratorPartException(ExceptionMessages.RMPackage.GEN_FILE_NO_POS, ImplicitInvalidGeneratorPartException.WhichInvalid.Position, path);
     }
 }
示例#5
0
            static void RetrieveGeneratorPartOnGender(string path, string rootPath, string _namespace, bool trimRootPath, out LogDataList log, ref List <RMGenPart> partsCollection, RMGenFile.GenFileType whichFilePart, RMGenPart.eGender whichGender, RMGeneratorCollection parent)
            {
                log = new LogDataList();
                log.WriteInformationLog(LoggerMessages.RMPackage.Info.RetrievedAutoData(parent.Parent.Name, path, RMCollectionType.Generator), _namespace);
                string[] listOfFiles = null;
                try
                {
                    listOfFiles = Directory.GetFiles(path, "*" + RMPConstants.GenFileNamePrefixANDSuffix.PNG);
                }
                catch (Exception ex)
                {
                    log.WriteErrorLog(LoggerMessages.RMPackage.Error.RetrieveAutoError(path, parent.Parent.Name, RMCollectionType.Generator), _namespace, ex);
                    return;
                }
                if (listOfFiles == null || listOfFiles.Length == 0)
                {
                    return;
                }
                string prefix;

                switch (whichFilePart)
                {
                case RMGenFile.GenFileType.Face:
                    prefix = RMPConstants.GenFileNamePrefixANDSuffix.FACE_LOWER + RMPConstants.GenFileNamePrefixANDSuffix.SEPARATOR;
                    break;

                case RMGenFile.GenFileType.SV:
                    prefix = RMPConstants.GenFileNamePrefixANDSuffix.SV_LOWER + RMPConstants.GenFileNamePrefixANDSuffix.SEPARATOR;
                    break;

                case RMGenFile.GenFileType.TV:
                    prefix = RMPConstants.GenFileNamePrefixANDSuffix.TV_LOWER + RMPConstants.GenFileNamePrefixANDSuffix.SEPARATOR;
                    break;

                case RMGenFile.GenFileType.TVD:
                    prefix = RMPConstants.GenFileNamePrefixANDSuffix.TVD_LOWER + RMPConstants.GenFileNamePrefixANDSuffix.SEPARATOR;
                    break;

                case RMGenFile.GenFileType.Var:
                    prefix = RMPConstants.GenFileNamePrefixANDSuffix.VARIATION + RMPConstants.GenFileNamePrefixANDSuffix.SEPARATOR;
                    break;

                default:
                    return;
                }
                for (int i = 0; i < listOfFiles.Length; ++i)
                {
                    string nonLoweredPath = listOfFiles[i];
                    listOfFiles[i] = listOfFiles[i].ToLower();
                    string fileName = Path.GetFileName(listOfFiles[i]);


                    if (fileName.Length > prefix.Length && fileName.StartsWith(prefix))
                    {
                        TempGenFileNameParsed tgfnm = null;
                        try
                        {
                            tgfnm = new TempGenFileNameParsed(fileName, prefix.Length);
                            VerifyFile(tgfnm, listOfFiles[i]);
                        }
                        catch (Exception ex)
                        {
                            log.WriteErrorLog(LoggerMessages.RMPackage.Error.InvalidGenFile(nonLoweredPath), _namespace, ex);
                            continue;
                        }
                        RMGenPart tempPart = partsCollection.GetPartByInternalPosition(tgfnm.Part, whichGender, tgfnm.Position);

                        RMGenFile newGenFile;

                        string pathToSave = (trimRootPath) ? Helper.GetRelativePath(nonLoweredPath, rootPath) : nonLoweredPath;

                        newGenFile = CreateGenFileFromTempGenFileName(tgfnm, GetProperFileType(tgfnm, whichFilePart), pathToSave);
                        if (tempPart == null)
                        {
                            tempPart = CreateNewPart(tgfnm, whichGender, parent, (partsCollection.CountPartOfType(tgfnm.Part, whichGender) + 1));
                            partsCollection.Add(tempPart);
                        }

                        newGenFile.Parent = tempPart;
                        tempPart.Files.Add(newGenFile);
                        log.WriteInformationLog(LoggerMessages.RMPackage.Info.RetrievedFile(parent.Parent.Name, nonLoweredPath, RMCollectionType.Generator), _namespace);
                    }
                }
            }
        TreeNode AddFile(string path, RMGenPart genGroup, bool pathCanBeTrimmed = false)
        {
            RMGenFile genFile = new RMGenFile(genGroup);

            if (pathCanBeTrimmed)
            {
                genFile.Path = Helper.GetRelativePath(path, RootDirectory);
            }
            else
            {
                genFile.Path = path;
                //genFile.NonRelativePath = true;
            }
            string fileName = Path.GetFileName(path).ToLower();
            int    startPos;

            genFile.FileType = TempGenFileNameParsed.RetrieveType(fileName, out startPos);
            if (genFile.FileType == RMGenFile.GenFileType.None)
            {
                genFile.BaseOrder = 0;
                genFile.Colour    = 0;
                genFile.FileType  = RMGenFile.GenFileType.Face;
                genFile.Order     = 0;
            }
            else
            {
                try
                {
                    TempGenFileNameParsed genFileNameParsed = new TempGenFileNameParsed(fileName, startPos);
                    genFile.BaseOrder = genFileNameParsed.BaseOrder;
                    genFile.Colour    = genFileNameParsed.Colour;
                    genFile.Order     = genFileNameParsed.Order;
                    if (genFileNameParsed.IsAcFile)
                    {
                        switch (genFile.FileType)
                        {
                        case RMGenFile.GenFileType.SV:
                            genFile.FileType = RMGenFile.GenFileType.SV_C;
                            break;

                        case RMGenFile.GenFileType.TV:
                            genFile.FileType = RMGenFile.GenFileType.TV_C;
                            break;

                        case RMGenFile.GenFileType.TVD:
                            genFile.FileType = RMGenFile.GenFileType.TVD_C;
                            break;
                        }
                    }
                }
                catch
                {
                    genFile.BaseOrder = 0;
                    genFile.Colour    = 0;
                    genFile.Order     = 0;
                }
            }

            TreeNode             tNode = new TreeNode();
            frmPackAssetTNodeTag tag   = new frmPackAssetTNodeTag(tNode, genFile, RootDirectory);

            tNode.Text = tag.ToString();
            tNode.Tag  = tag;

            if (genGroup.Files == null)
            {
                genGroup.Files = new List <RMGenFile>();
            }
            genGroup.Files.Add(genFile);

            return(tNode);
        }