TreeNode AddFile(string path, RMCharImageGroup charGroup, bool pathCanBeTrimmed = false)
        {
            RMCharImageFile charFile = new RMCharImageFile(charGroup);

            charFile.FileName  = Path.GetFileName(path);
            charFile.ImageType = RMCharImageFile.ImageTypes.Character;
            if (pathCanBeTrimmed)
            {
                charFile.Path = Helper.GetRelativePath(path, RootDirectory);
            }
            else
            {
                charFile.Path = path;
                //charFile.NonRelativePath = true;
            }

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

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

            if (charGroup.Files == null)
            {
                charGroup.Files = new List <RMCharImageFile>();
            }
            charGroup.Files.Add(charFile);

            return(tNode);
        }
Esempio n. 2
0
        public RMCharImageFile(XElement elementToParse, RMCharImageGroup parent)
        {
            Parent = parent;
            XAttribute typeAttr = elementToParse.Attribute(RMPConstants.ATTR_TYPE);

            if ((string)typeAttr == null)
            {
                throw new InvalidCharacterImageFileException(ExceptionMessages.RMPackage.CHAR_FILE_NO_TYPE, InvalidCharacterImageFileException.WhichInvalid.NoType, parent);
            }
            ImageType = ImageType.ParseString(typeAttr.Value);
            if (ImageType == ImageTypes.None)
            {
                throw new InvalidCharacterImageFileException(ExceptionMessages.RMPackage.CHAR_FILE_NO_TYPE, InvalidCharacterImageFileException.WhichInvalid.InvalidType, parent);
            }
            string path = elementToParse.Value;

            Path     = path;
            FileName = System.IO.Path.GetFileNameWithoutExtension(path);
            if (Parent.Parent.Parent.Installed)
            {
                typeAttr = elementToParse.Attribute(RMPConstants.ATTR_INSTALLED);
                if ((string)typeAttr != null)
                {
                    InstallationStatus = Pacman.Helper.GetInstallStatus(typeAttr.Value);
                }
            }
        }
Esempio n. 3
0
 public static void RetrieveSubCharacterImages(string path, string rootPath, string _namespace, bool trimRootPath, out LogDataList log, ref List <RMCharImageGroup> collection, RMCharImageFile.ImageTypes imageType, RMCharImageCollection parent)
 {
     log = new LogDataList();
     log.WriteInformationLog(LoggerMessages.RMPackage.Info.RetrievedAutoData(parent.Parent.Name, path, RMCollectionType.Characters), _namespace);
     string[] files = null;
     try
     {
         files = Directory.GetFiles(path, "*" + RMPConstants.GenFileNamePrefixANDSuffix.PNG);
     }
     catch (Exception ex)
     {
         log.WriteErrorLog(LoggerMessages.RMPackage.Error.RetrieveAutoError(path, parent.Parent.Name, RMCollectionType.Characters), _namespace, ex);
         return;
     }
     if (files == null || files.Length == 0)
     {
         return;
     }
     for (int i = 0; i < files.Length; ++i)
     {
         string realFileName = Path.GetFileNameWithoutExtension(files[i]);
         if (string.IsNullOrWhiteSpace(realFileName))
         {
             continue;
         }
         string nonLoweredPath = files[i];
         files[i] = files[i].ToLower();
         string           fileName = realFileName.ToLower();
         string           rootFileName;
         bool             atlas = IsAnAtlasPartFile(realFileName, out rootFileName);
         RMCharImageGroup parentNode;
         parentNode = collection.FindByInternalName((atlas) ? rootFileName.ToLower() : fileName);
         if (parentNode == null)
         {
             parentNode = new RMCharImageGroup(parent);
             parentNode.internalName = (atlas) ? rootFileName.ToLower() : fileName;
             parentNode.Name         = (atlas) ? rootFileName : realFileName;
             collection.Add(parentNode);
         }
         RMCharImageFile newFile = new RMCharImageFile(parentNode);
         newFile.FileName  = realFileName;
         newFile.ImageType = imageType;
         if (trimRootPath)
         {
             newFile.Path = Helper.GetRelativePath(nonLoweredPath, rootPath);
         }
         else
         {
             newFile.Path = nonLoweredPath;
         }
         parentNode.Files.Add(newFile);
         log.WriteInformationLog(LoggerMessages.RMPackage.Info.RetrievedFile(parent.Parent.Name, nonLoweredPath, RMCollectionType.Characters), _namespace);
     }
 }
Esempio n. 4
0
        public RMCharImageFile Clone(RMCharImageGroup parent)
        {
            RMCharImageFile clone = new RMCharImageFile(parent);

            clone.FileName           = FileName;
            clone.ImageType          = ImageType;
            clone.InstallationStatus = InstallationStatus;
            clone.InternalFileName   = InternalFileName;
            clone.Path  = Path;
            clone._path = _path;
            return(clone);
        }
        static void CopyCharacterAssetsGroup(string toWhere, RMCharImageGroup charGroup, string _namespace, string rootDir = null)
        {
            string pathToCharacterDir = toWhere + "\\";

            if (charGroup.Files == null)
            {
                return;
            }

            foreach (RMCharImageFile charFile in charGroup.Files)
            {
                if (string.IsNullOrWhiteSpace(rootDir) && charFile.NonRootedPath)
                {
                    try
                    {
                        throw new InvalidPathException(ExceptionMessages.PackUtil.CHAR_IMG_PATH_REL, charFile.Path);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteErrorLog(LoggerMessages.PackageMaker.Error.FILE_ALREADY_RELATIVE + charFile.Path + ".", _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                        throw;
                    }
                }

                string imageTypeToDirName = charFile.ImageType.ToDirectoryName();

                if (string.IsNullOrWhiteSpace(imageTypeToDirName))
                {
                    try
                    {
                        throw new InvalidCharacterFileException(ExceptionMessages.RMPackage.CHAR_FILE_NO_TYPE);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteErrorLog(LoggerMessages.PackageMaker.Error.CHAR_FILE_NO_TYPE, _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                        throw;
                    }
                }
                string dirPath = pathToCharacterDir + imageTypeToDirName;
                Helper.MakeDirIfNotExistCopy(dirPath, _namespace);

                if (string.IsNullOrWhiteSpace(charFile.Path))
                {
                    try
                    {
                        throw new InvalidCharacterFileException(ExceptionMessages.RMPackage.CHAR_FILE_PATH_NULL);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteErrorLog(LoggerMessages.PackageMaker.Error.FILE_PATH_NOT_SET, _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                        throw;
                    }
                }

                string copyTo = dirPath + "\\" + Path.GetFileName(charFile.Path);

                string originFile = charFile.Path;
                if (!string.IsNullOrWhiteSpace(rootDir))
                {
                    originFile = rootDir + "\\" + charFile.Path;
                }

                Exception outEx;
                if (Helper.CopyFileSafely(originFile, copyTo, true, _namespace, out outEx, new CopyFileLogMessages(copyFileFailed: LoggerMessages.PackageUtil.Error.CopyFileFailed)) != CopyFileResult.Success)
                {
                    throw outEx;
                }
            }
        }
                public static void InstallCharacterFile(string toWhere, string fromRootDirectory, RMCharImageGroup character, string _namespace)
                {
                    string pathToCharacterDir = toWhere + "\\";

                    if (character.Files != null)
                    {
                        foreach (RMCharImageFile imageFile in character.Files)
                        {
                            string imageTypeToDirName = imageFile.ImageType.ToDirectoryName();
                            if (string.IsNullOrWhiteSpace(imageTypeToDirName))
                            {
                                try
                                {
                                    throw new InvalidCharacterFileException(ExceptionMessages.RMPackage.CHAR_FILE_NO_TYPE);
                                }
                                catch (Exception ex)
                                {
                                    Logger.WriteErrorLog(LoggerMessages.PackageManagement.Installer.Error.UNABLE_INSTALL_CHAR_FILE_TYPE, _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                                    throw;
                                }
                            }
                            string dirPath = pathToCharacterDir + imageTypeToDirName;
                            Helper.MakeDirIfNotExistInstall(dirPath, _namespace);

                            if (string.IsNullOrWhiteSpace(imageFile.Path))
                            {
                                try
                                {
                                    throw new InvalidCharacterFileException(ExceptionMessages.RMPackage.CHAR_FILE_PATH_NULL);
                                }
                                catch (Exception ex)
                                {
                                    Logger.WriteErrorLog(LoggerMessages.PackageManagement.Installer.Error.UNABLE_INSTALL_CHAR_FILE_PATH, _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                                    throw;
                                }
                            }

                            string copyTo       = dirPath + "\\" + Path.GetFileName(imageFile.Path);
                            string originalFile = fromRootDirectory + "\\" + imageFile.Path;

                            Exception outEx;
                            if (Helper.CopyFileSafely(originalFile, copyTo, true, _namespace, out outEx, new CopyFileLogMessages(copyFileFailed: LoggerMessages.PackageManagement.Installer.Error.UnableInstallCharFileCopy)) != CopyFileResult.Success)
                            {
                                throw outEx;
                            }
                            imageFile.Path = Helper.GetRelativePath(copyTo, toWhere);
                            //imageFile.InstallationStatus = RMPackObject.InstallStatus.Installed;
                        }
                    }
                }
Esempio n. 7
0
        void SaveGroupInfo(TreeNode node)
        {
            string _namespace = MethodBase.GetCurrentMethod().ToLogFormatFullName();

            if (string.IsNullOrWhiteSpace(txtGroupName.Text))
            {
                Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.INVALID_GROUP_NAME, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (node.Tag == null)
            {
                Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.UNABLE_SAVE_GROUP_INFO, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                Logger.WriteErrorLog(LoggerMessages.GUI.frmPackageAssets.Error.UNABLE_SAVE_GROUP_INFO_NULL_TAG, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                return;
            }

            frmPackAssetTNodeTag tag = node.Tag as frmPackAssetTNodeTag;

            if (tag == null)
            {
                Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.UNABLE_SAVE_GROUP_INFO, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                Logger.WriteErrorLog(LoggerMessages.GUI.frmPackageAssets.Error.UNABLE_SAVE_GROUP_INFO_NULL_TAG, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                return;
            }

            if (tag.TagObjectType == frmPackAssetTNodeTag.TagType.AudioGroup)
            {
                RMAudioGroup audioGroup = tag.Object as RMAudioGroup;
                if (audioGroup == null)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.UNABLE_SAVE_GROUP_INFO, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(LoggerMessages.GUI.frmPackageAssets.Error.UNABLE_SAVE_GROUP_INFO_NULL_TAG, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                    return;
                }
                tag.Name         = txtGroupName.Text;
                audioGroup.Name  = txtGroupName.Text;
                node.Text        = tag.ToString();
                changesMadeGroup = false;
                return;
            }
            else if (tag.TagObjectType == frmPackAssetTNodeTag.TagType.CharacterGroup)
            {
                RMCharImageGroup characterGroup = tag.Object as RMCharImageGroup;
                if (characterGroup == null)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.UNABLE_SAVE_GROUP_INFO, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(LoggerMessages.GUI.frmPackageAssets.Error.UNABLE_SAVE_GROUP_INFO_NULL_TAG, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                    return;
                }
                tag.Name            = txtGroupName.Text;
                characterGroup.Name = txtGroupName.Text;
                node.Text           = tag.ToString();
                changesMadeGroup    = false;
                return;
            }
            else if (tag.TagObjectType == frmPackAssetTNodeTag.TagType.GeneratorPartGroup)
            {
                RMGenPart genGroup = tag.Object as RMGenPart;
                if (genGroup == null)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.UNABLE_SAVE_GROUP_INFO, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(LoggerMessages.GUI.frmPackageAssets.Error.UNABLE_SAVE_GROUP_INFO_NULL_TAG, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                    return;
                }
                tag.Name      = txtGroupName.Text;
                genGroup.Name = txtGroupName.Text;

                ObjectAndIntCollection objAndIntColl = comboGroupGender.SelectedItem as ObjectAndIntCollection;
                genGroup.Gender = (RMGenPart.eGender)objAndIntColl.IntegerCollection[0];

                objAndIntColl     = comboGroupType.SelectedItem as ObjectAndIntCollection;
                genGroup.PartType = (RMGenPart.GenPartType)objAndIntColl.IntegerCollection[0];

                node.Text        = tag.ToString();
                changesMadeGroup = false;
                return;
            }
            else if (tag.TagObjectType == frmPackAssetTNodeTag.TagType.MovieGroup)
            {
                RMMovieGroup movieGroup = tag.Object as RMMovieGroup;
                if (movieGroup == null)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.UNABLE_SAVE_GROUP_INFO, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(LoggerMessages.GUI.frmPackageAssets.Error.UNABLE_SAVE_GROUP_INFO_NULL_TAG, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                    return;
                }
                tag.Name         = txtGroupName.Text;
                movieGroup.Name  = txtGroupName.Text;
                node.Text        = tag.ToString();
                changesMadeGroup = false;
                return;
            }
            else if (tag.TagObjectType == frmPackAssetTNodeTag.TagType.TilesetGroup)
            {
                RMTilesetGroup tilesetGroup = tag.Object as RMTilesetGroup;
                if (tilesetGroup == null)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.UNABLE_SAVE_GROUP_INFO, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(LoggerMessages.GUI.frmPackageAssets.Error.UNABLE_SAVE_GROUP_INFO_NULL_TAG, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                    return;
                }
                tag.Name          = txtGroupName.Text;
                tilesetGroup.Name = txtGroupName.Text;
                node.Text         = tag.ToString();
                changesMadeGroup  = false;
                return;
            }
            Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.UNABLE_SAVE_GROUP_INFO, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
            Logger.WriteErrorLog(LoggerMessages.GUI.frmPackageAssets.Error.UNABLE_SAVE_GROUP_INFO_NULL_TAG, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
            return;
        }
Esempio n. 8
0
 public RMCharImageFile(RMCharImageGroup parent)
 {
     Parent = parent;
 }
        TreeNode AddFile(TreeNode selectedNode, string path, string _namespace, bool skipSanityChecks = false, bool pathCanBeTrimmed = false)
        {
            if (!skipSanityChecks)
            {
                if (string.IsNullOrWhiteSpace(path))
                {
                    throw new FileNotFoundException(ExceptionMessages.GUI.frmPackageAssets.FILE_PATH_NULL);
                }

                if (!File.Exists(path))
                {
                    throw new FileNotFoundException(ExceptionMessages.General.FileNotFound(path));
                }
                if (!string.IsNullOrWhiteSpace(RootDirectory) && path.ToLower().StartsWith(RootDirectory.ToLower()))
                {
                    pathCanBeTrimmed = true;
                }
            }



            frmPackAssetTNodeTag parentingTag = selectedNode.Tag as frmPackAssetTNodeTag;

            if (parentingTag == null)
            {
                throw new NullReferenceException(ExceptionMessages.GUI.frmPackageAssets.TAG_SEL_NODE_NULL);
            }

            if (parentingTag.TagObjectType == frmPackAssetTNodeTag.TagType.AudioGroup)
            {
                RMAudioGroup audioGroup = parentingTag.Object as RMAudioGroup;
                if (audioGroup == null)
                {
                    throw new NullReferenceException(ExceptionMessages.GUI.frmPackageAssets.ASSOC_OBJ_TAG_SEL_NODE_NULL);
                }
                TreeNode tNode = AddFile(path, audioGroup, pathCanBeTrimmed);
                parentingTag.AssociatedNode.Nodes.Add(tNode);
                return(tNode);
            }
            else if (parentingTag.TagObjectType == frmPackAssetTNodeTag.TagType.CharacterGroup)
            {
                RMCharImageGroup charNode = parentingTag.Object as RMCharImageGroup;
                if (charNode == null)
                {
                    throw new NullReferenceException(ExceptionMessages.GUI.frmPackageAssets.ASSOC_OBJ_TAG_SEL_NODE_NULL);
                }
                TreeNode tNode = AddFile(path, charNode, pathCanBeTrimmed);
                parentingTag.AssociatedNode.Nodes.Add(tNode);
                return(tNode);
            }
            else if (parentingTag.TagObjectType == frmPackAssetTNodeTag.TagType.Collection)
            {
                RMSingleFileCollection singleFileC = parentingTag.Object as RMSingleFileCollection;
                if (singleFileC == null)
                {
                    throw new NullReferenceException(ExceptionMessages.GUI.frmPackageAssets.ASSOC_OBJ_TAG_SEL_NODE_NULL);
                }
                TreeNode tNode = AddFile(path, singleFileC, pathCanBeTrimmed);
                parentingTag.AssociatedNode.Nodes.Add(tNode);

                if (!PackageOfCollections.Collections.Contains(singleFileC))
                {
                    PackageOfCollections.Collections.Add(singleFileC);
                }

                return(tNode);
            }
            else if (parentingTag.TagObjectType == frmPackAssetTNodeTag.TagType.GeneratorPartGroup)
            {
                RMGenPart genGroup = parentingTag.Object as RMGenPart;
                if (genGroup == null)
                {
                    throw new NullReferenceException(ExceptionMessages.GUI.frmPackageAssets.ASSOC_OBJ_TAG_SEL_NODE_NULL);
                }
                TreeNode tNode = AddFile(path, genGroup, pathCanBeTrimmed);
                parentingTag.AssociatedNode.Nodes.Add(tNode);
                return(tNode);
            }
            else if (parentingTag.TagObjectType == frmPackAssetTNodeTag.TagType.MovieGroup)
            {
                RMMovieGroup movieGroup = parentingTag.Object as RMMovieGroup;
                if (movieGroup == null)
                {
                    throw new NullReferenceException(ExceptionMessages.GUI.frmPackageAssets.ASSOC_OBJ_TAG_SEL_NODE_NULL);
                }
                TreeNode tNode = AddFile(path, movieGroup, pathCanBeTrimmed);
                parentingTag.AssociatedNode.Nodes.Add(tNode);
                return(tNode);
            }
            else if (parentingTag.TagObjectType == frmPackAssetTNodeTag.TagType.TilesetGroup)
            {
                RMTilesetGroup tilesetGroup = parentingTag.Object as RMTilesetGroup;
                if (tilesetGroup == null)
                {
                    throw new NullReferenceException(ExceptionMessages.GUI.frmPackageAssets.ASSOC_OBJ_TAG_SEL_NODE_NULL);
                }
                TreeNode tNode = AddFile(path, tilesetGroup, pathCanBeTrimmed);
                parentingTag.AssociatedNode.Nodes.Add(tNode);
                return(tNode);
            }
            else
            {
                TreeNode parentingNode = parentingTag.AssociatedNode.Parent;
                if (parentingNode == null)
                {
                    throw new NullReferenceException(ExceptionMessages.GUI.frmPackageAssets.PARENT_NODE_NULL);
                }
                return(AddFile(parentingNode, path, _namespace, true, pathCanBeTrimmed));
            }
        }
        TreeNode AddAssetGroup(frmAddAssetGroup formShown)
        {
            string _namespace = MethodBase.GetCurrentMethod().ToLogFormatFullName();

            if (formShown.DialogResult == DialogResult.Cancel)
            {
                return(null);
            }

            if (string.IsNullOrWhiteSpace(formShown.TypeName))
            {
                Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.ADD_NO_NAME_GROUP_ASSET, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }

            frmPackAssetTNodeTag collectionTag = tViewAssets.Nodes.FindNodeOfCollectionType(formShown.TypeToAdd);

            if (collectionTag == null)
            {
                RMCollection rmc = null;
                try
                {
                    rmc = formShown.TypeToAdd.ToNewCollection(PackageOfCollections);
                }
                catch (Exception ex)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.ADD_ASSET_GROUP_ERR_GENERAL, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_CREATE_COLLECTION, _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                    return(null);
                }
                if (PackageOfCollections.Collections == null)
                {
                    PackageOfCollections.Collections = new List <RMCollection>();
                }
                PackageOfCollections.Collections.Add(rmc);
                collectionTag = AddCollectionToTView(tViewAssets, rmc, RootDirectory);
            }

            if (formShown.TypeToAdd == RMCollectionType.BGM || formShown.TypeToAdd == RMCollectionType.BGS || formShown.TypeToAdd == RMCollectionType.ME || formShown.TypeToAdd == RMCollectionType.SE)
            {
                RMAudioCollection collectionObj = collectionTag.Object as RMAudioCollection;
                if (collectionObj == null)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.ADD_ASSET_GROUP_ERR_GENERAL, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_ADD_GROUP_INVALID_COLLECTION, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                    return(null);
                }
                RMAudioGroup audioGroup = new RMAudioGroup(collectionObj);
                audioGroup.Name = formShown.TypeName;
                TreeNode             tNode       = new TreeNode();
                frmPackAssetTNodeTag newGroupTag = new frmPackAssetTNodeTag(tNode, audioGroup, RootDirectory);
                tNode.Text = newGroupTag.ToString();
                tNode.Tag  = newGroupTag;
                collectionTag.AssociatedNode.Nodes.Add(tNode);

                if (collectionObj.Groups == null)
                {
                    collectionObj.Groups = new List <RMAudioGroup>();
                }
                collectionObj.Groups.Add(audioGroup);

                if (!PackageOfCollections.Collections.Contains(collectionObj))
                {
                    PackageOfCollections.Collections.Add(collectionObj);
                }

                return(tNode);
            }
            else if (formShown.TypeToAdd == RMCollectionType.Characters)
            {
                RMCharImageCollection collectionObj = collectionTag.Object as RMCharImageCollection;
                if (collectionObj == null)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.ADD_ASSET_GROUP_ERR_GENERAL, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_ADD_GROUP_INVALID_COLLECTION, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                    return(null);
                }
                RMCharImageGroup charImageGroup = new RMCharImageGroup(collectionObj);
                charImageGroup.Name = formShown.TypeName;
                TreeNode             tNode       = new TreeNode();
                frmPackAssetTNodeTag newGroupTag = new frmPackAssetTNodeTag(tNode, charImageGroup, RootDirectory);
                tNode.Text = newGroupTag.ToString();
                tNode.Tag  = newGroupTag;
                collectionTag.AssociatedNode.Nodes.Add(tNode);

                if (collectionObj.Groups == null)
                {
                    collectionObj.Groups = new List <RMCharImageGroup>();
                }
                collectionObj.Groups.Add(charImageGroup);

                if (!PackageOfCollections.Collections.Contains(collectionObj))
                {
                    PackageOfCollections.Collections.Add(collectionObj);
                }

                return(tNode);
            }
            else if (formShown.TypeToAdd == RMCollectionType.Tilesets)
            {
                RMTilesetCollection collectionObj = collectionTag.Object as RMTilesetCollection;
                if (collectionObj == null)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.ADD_ASSET_GROUP_ERR_GENERAL, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_ADD_GROUP_INVALID_COLLECTION, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                    return(null);
                }
                RMTilesetGroup tilesetGroup = new RMTilesetGroup(collectionObj);
                tilesetGroup.Name = formShown.TypeName;
                TreeNode             tNode       = new TreeNode();
                frmPackAssetTNodeTag newGroupTag = new frmPackAssetTNodeTag(tNode, tilesetGroup, RootDirectory);
                tNode.Text = newGroupTag.ToString();
                tNode.Tag  = newGroupTag;
                collectionTag.AssociatedNode.Nodes.Add(tNode);

                if (collectionObj.Groups == null)
                {
                    collectionObj.Groups = new List <RMTilesetGroup>();
                }
                collectionObj.Groups.Add(tilesetGroup);

                if (!PackageOfCollections.Collections.Contains(collectionObj))
                {
                    PackageOfCollections.Collections.Add(collectionObj);
                }

                return(tNode);
            }
            else if (formShown.TypeToAdd == RMCollectionType.Movies)
            {
                RMMovieCollection collectionObj = collectionTag.Object as RMMovieCollection;
                if (collectionObj == null)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.ADD_ASSET_GROUP_ERR_GENERAL, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_ADD_GROUP_INVALID_COLLECTION, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                    return(null);
                }
                RMMovieGroup movieGroup = new RMMovieGroup(collectionObj);
                movieGroup.Name = formShown.TypeName;
                TreeNode             tNode       = new TreeNode();
                frmPackAssetTNodeTag newGroupTag = new frmPackAssetTNodeTag(tNode, movieGroup, RootDirectory);
                tNode.Text = newGroupTag.ToString();
                tNode.Tag  = newGroupTag;
                collectionTag.AssociatedNode.Nodes.Add(tNode);

                if (collectionObj.Groups == null)
                {
                    collectionObj.Groups = new List <RMMovieGroup>();
                }
                collectionObj.Groups.Add(movieGroup);

                if (!PackageOfCollections.Collections.Contains(collectionObj))
                {
                    PackageOfCollections.Collections.Add(collectionObj);
                }

                return(tNode);
            }
            else if (formShown.TypeToAdd == RMCollectionType.Generator)
            {
                RMGeneratorCollection collectionObj = collectionTag.Object as RMGeneratorCollection;
                if (collectionObj == null)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.ADD_ASSET_GROUP_ERR_GENERAL, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_ADD_GROUP_INVALID_COLLECTION, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                    return(null);
                }
                RMGenPart genGroup = new RMGenPart(collectionObj);
                genGroup.Name     = formShown.TypeName;
                genGroup.PartType = formShown.GeneratorType;
                genGroup.Gender   = formShown.GeneratorGender;
                TreeNode             tNode       = new TreeNode();
                frmPackAssetTNodeTag newGroupTag = new frmPackAssetTNodeTag(tNode, genGroup, RootDirectory);
                tNode.Text = newGroupTag.ToString();
                tNode.Tag  = newGroupTag;
                collectionTag.AssociatedNode.Nodes.Add(tNode);

                if (collectionObj.Parts == null)
                {
                    collectionObj.Parts = new List <RMGenPart>();
                }
                collectionObj.Parts.Add(genGroup);

                if (!PackageOfCollections.Collections.Contains(collectionObj))
                {
                    PackageOfCollections.Collections.Add(collectionObj);
                }

                return(tNode);
            }
            return(null);
        }
        bool RemoveAssetGroup(TreeNode tNode)
        {
            string _namespace             = MethodBase.GetCurrentMethod().ToLogFormatFullName();
            frmPackAssetTNodeTag groupTag = tNode.Tag as frmPackAssetTNodeTag;

            if (groupTag == null)
            {
                Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_GROUP_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_GROUP_TAG_NULL, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                return(false);
            }

            if (tNode.Parent == null)
            {
                Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_GROUP_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_GROUP_PARENT_NULL, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                return(false);
            }

            frmPackAssetTNodeTag collTag = tNode.Parent.Tag as frmPackAssetTNodeTag;

            if (collTag == null)
            {
                Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_GROUP_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_GROUP_PARENT_NULL, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                return(false);
            }

            if (collTag.TagObjectType != frmPackAssetTNodeTag.TagType.Collection)
            {
                Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_GROUP_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_GROUP_PARENT_NULL, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                return(false);
            }


            if (groupTag.TagObjectType == frmPackAssetTNodeTag.TagType.AudioGroup)
            {
                if (collTag.CollectionType != RMCollectionType.BGM && collTag.CollectionType != RMCollectionType.BGS && collTag.CollectionType != RMCollectionType.SE && collTag.CollectionType != RMCollectionType.ME)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_GROUP_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_GROUP_INVALID_PARENT, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                    return(false);
                }
                RMAudioCollection audioCollection = collTag.Object as RMAudioCollection;
                if (audioCollection == null)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_GROUP_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_GROUP_INVALID_PARENT, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                    return(false);
                }
                RMAudioGroup audio = groupTag.Object as RMAudioGroup;
                if (audio == null)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_GROUP_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_GROUP_INVALID, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                    return(false);
                }
                tNode.Remove();
                audioCollection.Groups.Remove(audio);
                if (audioCollection.Groups.Count == 0)
                {
                    audioCollection.Parent.Collections.Remove(audioCollection);
                }
                return(true);
            }
            else if (groupTag.TagObjectType == frmPackAssetTNodeTag.TagType.CharacterGroup)
            {
                if (collTag.CollectionType != RMCollectionType.Characters)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_GROUP_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_GROUP_INVALID_PARENT, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                    return(false);
                }
                RMCharImageCollection charCollection = collTag.Object as RMCharImageCollection;
                if (charCollection == null)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_GROUP_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_GROUP_INVALID_PARENT, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                    return(false);
                }
                RMCharImageGroup charGroup = groupTag.Object as RMCharImageGroup;
                if (charGroup == null)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_GROUP_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_GROUP_INVALID, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                    return(false);
                }
                tNode.Remove();
                charCollection.Groups.Remove(charGroup);
                if (charCollection.Groups.Count == 0)
                {
                    charCollection.Parent.Collections.Remove(charCollection);
                }
                return(true);
            }
            else if (groupTag.TagObjectType == frmPackAssetTNodeTag.TagType.GeneratorPartGroup)
            {
                if (collTag.CollectionType != RMCollectionType.Generator)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_GROUP_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_GROUP_INVALID_PARENT, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                    return(false);
                }
                RMGeneratorCollection genCollection = collTag.Object as RMGeneratorCollection;
                if (genCollection == null)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_GROUP_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_GROUP_INVALID_PARENT, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                    return(false);
                }
                RMGenPart genGroup = groupTag.Object as RMGenPart;
                if (genGroup == null)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_GROUP_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_GROUP_INVALID, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                    return(false);
                }
                tNode.Remove();
                genCollection.Parts.Remove(genGroup);
                if (genCollection.Parts.Count == 0)
                {
                    genCollection.Parent.Collections.Remove(genCollection);
                }
                return(true);
            }
            else if (groupTag.TagObjectType == frmPackAssetTNodeTag.TagType.MovieGroup)
            {
                if (collTag.CollectionType != RMCollectionType.Movies)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_GROUP_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_GROUP_INVALID_PARENT, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                    return(false);
                }
                RMMovieCollection movieCollection = collTag.Object as RMMovieCollection;
                if (movieCollection == null)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_GROUP_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_GROUP_INVALID_PARENT, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                    return(false);
                }
                RMMovieGroup movieGroup = groupTag.Object as RMMovieGroup;
                if (movieGroup == null)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_GROUP_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_GROUP_INVALID, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                    return(false);
                }
                tNode.Remove();
                movieCollection.Groups.Remove(movieGroup);
                if (movieCollection.Groups.Count == 0)
                {
                    movieCollection.Parent.Collections.Remove(movieCollection);
                }
                return(true);
            }
            else if (groupTag.TagObjectType == frmPackAssetTNodeTag.TagType.TilesetGroup)
            {
                if (collTag.CollectionType != RMCollectionType.Tilesets)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_GROUP_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_GROUP_INVALID_PARENT, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                    return(false);
                }
                RMTilesetCollection tilesetCollection = collTag.Object as RMTilesetCollection;
                if (tilesetCollection == null)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_GROUP_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_GROUP_INVALID_PARENT, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                    return(false);
                }
                RMTilesetGroup tilesetGroup = groupTag.Object as RMTilesetGroup;
                if (tilesetGroup == null)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_GROUP_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_GROUP_INVALID, _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                    return(false);
                }
                tNode.Remove();
                tilesetCollection.Groups.Remove(tilesetGroup);
                if (tilesetCollection.Groups.Count == 0)
                {
                    tilesetCollection.Parent.Collections.Remove(tilesetCollection);
                }
                return(true);
            }

            return(false);
        }
Esempio n. 12
0
 public InvalidCharacterImageFileException(string message, WhichInvalid whichInvalid, RMCharImageGroup parent) : base(message)
 {
     TypeOfIssue = whichInvalid;
     Parent      = parent;
 }