Ejemplo n.º 1
0
        TreeNode AddFile(string path, RMMovieGroup movieGroup, bool pathCanBeTrimmed = false)
        {
            string ext = Path.GetExtension(path).ToLower();

            RMMovieFile movieFile = new RMMovieFile(movieGroup);

            if (pathCanBeTrimmed)
            {
                movieFile.Path = Helper.GetRelativePath(path, RootDirectory);
            }
            else
            {
                movieFile.Path = path;
                //movieFile.NonRelativePath = true;
            }

            if (ext == RMPConstants.MovieFileType.DOT_MP4)
            {
                movieFile.TypeOfFile = RMMovieFile.FileType.mp4;
            }
            else if (ext == RMPConstants.MovieFileType.DOT_WEBM)
            {
                movieFile.TypeOfFile = RMMovieFile.FileType.webm;
            }
            else
            {
                throw new InvalidMovieFileException(ExceptionMessages.General.FileExtInvalid(path), InvalidMovieFileException.WhichInvalid.InvalidType, movieGroup);
            }
            TreeNode             tNode = new TreeNode();
            frmPackAssetTNodeTag tag   = new frmPackAssetTNodeTag(tNode, movieFile, RootDirectory);

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

            if (movieGroup.Files == null)
            {
                movieGroup.Files = new List <RMMovieFile>();
            }
            movieGroup.Files.Add(movieFile);

            return(tNode);
        }
Ejemplo n.º 2
0
            public static RMMovieCollection RetrieveMovieCollection(string path, string rootPath, string _namespace, bool trimRootPath, out LogDataList log, RMPackage parent)
            {
                log = new LogDataList();


                RMMovieCollection newCollection = new RMMovieCollection(parent);

                log.WriteInformationLog(LoggerMessages.RMPackage.Info.RetrievedAutoData(parent.Name, path, RMCollectionType.Movies), _namespace);
                string[] files = null;
                try
                {
                    files = Directory.GetFiles(path);
                } catch (Exception ex)
                {
                    log.WriteErrorLog(LoggerMessages.RMPackage.Error.RetrieveAutoError(path, parent.Name, RMCollectionType.Movies), _namespace, ex);
                    return(null);
                }
                if (files == null || files.Length == 0)
                {
                    return(null);
                }

                for (int i = 0; i < files.Length; ++i)
                {
                    string originalFileName = Path.GetFileNameWithoutExtension(files[i]);
                    string nonLoweredPath   = files[i];
                    files[i] = files[i].ToLower();
                    string fileName      = originalFileName.ToLower();
                    string fileExtension = Path.GetExtension(files[i]);
                    if (fileExtension.Length < RMPConstants.MovieFileType.MP4.Length + 1)
                    {
                        continue;
                    }
                    fileExtension = fileExtension.Substring(1);

                    RMMovieFile.FileType typeOfFile = RMMovieFile.FileType.none;
                    typeOfFile = typeOfFile.ParseString(fileExtension);

                    if (typeOfFile == RMMovieFile.FileType.none || string.IsNullOrWhiteSpace(originalFileName))
                    {
                        continue;
                    }

                    RMMovieGroup rmv = newCollection.Groups.FindByInternalName(fileName);
                    if (rmv == null)
                    {
                        rmv              = new RMMovieGroup(newCollection);
                        rmv.Name         = originalFileName;
                        rmv.internalName = fileName;
                        newCollection.Groups.Add(rmv);
                    }
                    RMMovieFile rmf = new RMMovieFile(rmv);
                    if (trimRootPath)
                    {
                        rmf.Path = Helper.GetRelativePath(nonLoweredPath, rootPath);
                    }
                    else
                    {
                        rmf.Path = nonLoweredPath;
                    }
                    rmf.TypeOfFile = typeOfFile;
                    rmv.Files.Add(rmf);
                    log.WriteInformationLog(LoggerMessages.RMPackage.Info.RetrievedFile(parent.Name, nonLoweredPath, RMCollectionType.Movies), _namespace);
                }
                if (newCollection.Groups.Count == 0)
                {
                    return(null);
                }

                return(newCollection);
            }
Ejemplo n.º 3
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;
        }
Ejemplo n.º 4
0
        static void CopyMovieAsset(string toWhere, RMMovieGroup movieGroup, string _namespace, string rootDir = null)
        {
            if (movieGroup.Files == null)
            {
                return;
            }

            foreach (RMMovieFile movieFile in movieGroup.Files)
            {
                if (string.IsNullOrWhiteSpace(rootDir) && movieFile.NonRootedPath)
                {
                    try
                    {
                        throw new InvalidPathException(ExceptionMessages.PackUtil.MOVIE_FILE_PATH_REL, movieFile.Path);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteErrorLog(LoggerMessages.PackageMaker.Error.FILE_ALREADY_RELATIVE + movieFile.Path + ".", _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                        throw;
                    }
                }
                string typeOfFile;
                if (string.IsNullOrWhiteSpace(typeOfFile = movieFile.TypeOfFile.ToXMLString()))
                {
                    try
                    {
                        throw new InvalidMovieFileException(ExceptionMessages.RMPackage.MOVIE_TYPE_NOT_SET, InvalidMovieFileException.WhichInvalid.NoType, movieGroup);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteErrorLog(LoggerMessages.PackageMaker.Error.MOVIE_FILE_NO_TYPE, _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                        throw;
                    }
                }
                string newFileName = Path.GetFileNameWithoutExtension(movieFile.Path) + "." + typeOfFile;
                string newFile     = toWhere + "\\" + newFileName;
                if (string.IsNullOrWhiteSpace(movieFile.Path))
                {
                    try
                    {
                        throw new InvalidMovieFileException(ExceptionMessages.RMPackage.MOVIE_FILE_PATH_NULL, InvalidMovieFileException.WhichInvalid.NoPath, movieGroup);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteErrorLog(LoggerMessages.PackageMaker.Error.FILE_PATH_NOT_SET, _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                        throw;
                    }
                }

                Exception outEx;

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

                if (Helper.CopyFileSafely(originFile, newFile, true, _namespace, out outEx, new CopyFileLogMessages(copyFileFailed: LoggerMessages.PackageUtil.Error.CopyFileFailed)) != CopyFileResult.Success)
                {
                    throw outEx;
                }
            }
        }
Ejemplo n.º 5
0
        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));
            }
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        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);
        }
                static void InstallMovieFile(string toWhere, string rootDir, string fromDirectory, RMMovieGroup movie, string _namespace)
                {
                    if (movie.Files != null)
                    {
                        foreach (RMMovieFile file in movie.Files)
                        {
                            string typeOfFile;
                            if (string.IsNullOrWhiteSpace(typeOfFile = file.TypeOfFile.ToXMLString()))
                            {
                                try
                                {
                                    throw new InvalidMovieFileException(ExceptionMessages.RMPackage.MOVIE_TYPE_NOT_SET, InvalidMovieFileException.WhichInvalid.NoType, movie);
                                }
                                catch (Exception ex)
                                {
                                    Logger.WriteErrorLog(LoggerMessages.PackageManagement.Installer.Error.INVALID_MOVIE_FILE_TYPE, _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                                    throw;
                                }
                            }
                            string newFileName = Path.GetFileNameWithoutExtension(file.Path) + "." + typeOfFile;
                            string newFile     = toWhere + "\\" + newFileName;

                            if (string.IsNullOrWhiteSpace(file.Path))
                            {
                                try
                                {
                                    throw new InvalidMovieFileException(ExceptionMessages.RMPackage.MOVIE_FILE_PATH_NULL, InvalidMovieFileException.WhichInvalid.NoPath, movie);
                                }
                                catch (Exception ex)
                                {
                                    Logger.WriteErrorLog(LoggerMessages.PackageManagement.Installer.Error.INVALID_MOVIE_PATH_NULL, _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                                    throw;
                                }
                            }

                            string    oldFilePath = fromDirectory + "\\" + file.Path;
                            Exception outEx;
                            if (Helper.CopyFileSafely(oldFilePath, newFile, true, _namespace, out outEx, new CopyFileLogMessages(copyFileFailed: LoggerMessages.PackageManagement.Installer.Error.MovieUnableCopy)) != CopyFileResult.Success)
                            {
                                throw outEx;
                            }

                            file.Path = Helper.GetRelativePath(newFile, rootDir);
                            //file.InstallationStatus = RMPackObject.InstallStatus.Installed;
                        }
                    }
                }
Ejemplo n.º 9
0
 public InvalidMovieFileException(string message, WhichInvalid whichInvalid, RMMovieGroup parentMovie) : base(message)
 {
     TypeOfIssue = whichInvalid;
     ParentAudio = parentMovie;
 }