internal static RMGenPart GetLowestPartByInternalPosition(this IEnumerable <RMGenPart> listOfPart, RMGenPart.GenPartType partType, RMGenPart.eGender gender) { if (listOfPart == null) { return(null); } RMGenPart retVal = null; foreach (RMGenPart part in listOfPart) { if (part.PartType == partType && part.Gender == gender) { if (retVal == null) { retVal = part; } else if (part.implicitID < retVal.implicitID) { retVal = part; } } } return(retVal); }
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); }
static void CopyGeneratorPart(string toWhere, RMGenPart genGroup, string _namespace, string rootDir = null) { if (genGroup == null) { return; } foreach (RMGenFile genFile in genGroup.Files) { if (string.IsNullOrWhiteSpace(rootDir) && genFile.NonRootedPath) { try { throw new InvalidPathException(ExceptionMessages.PackUtil.GEN_FILE_PATH_REL, genFile.Path); } catch (Exception ex) { Logger.WriteErrorLog(LoggerMessages.PackageMaker.Error.FILE_ALREADY_RELATIVE + genFile.Path + ".", _namespace, ex, BasicDebugLogger.DebugErrorType.Error); throw; } } string dirContainerFile = genFile.FileType.GetContainingDirectoryName(); string dirContainerGender = genGroup.Gender.GetContainingDirectoryName(); if (string.IsNullOrWhiteSpace(dirContainerFile)) { try { throw new InvalidGeneratorPartFileException(ExceptionMessages.RMPackage.GEN_FILE_NO_TYPE, InvalidGeneratorPartFileException.WhichInvalid.NoType, genGroup); } catch (Exception ex) { Logger.WriteErrorLog(LoggerMessages.PackageMaker.Error.GEN_FILE_NO_TYPE, _namespace, ex, BasicDebugLogger.DebugErrorType.Error); throw; } } if (string.IsNullOrWhiteSpace(dirContainerGender)) { try { throw new InvalidGeneratorPartFileException(ExceptionMessages.RMPackage.GEN_FILE_NO_GENDER, InvalidGeneratorPartFileException.WhichInvalid.NoGender, genGroup); } catch (Exception ex) { Logger.WriteErrorLog(LoggerMessages.PackageMaker.Error.GEN_FILE_NO_GENDER, _namespace, ex, BasicDebugLogger.DebugErrorType.Error); throw; } } string subPath = toWhere + "\\" + dirContainerFile + "\\" + dirContainerGender; CopyGeneratorFile(subPath, genFile, _namespace, rootDir); } }
static void PerformRenumberOnPart(RMGeneratorCollection collection, RMGenPart.eGender gender, RMGenPart.GenPartType partType, ref List <ComparedPath> comparedPaths, string rootPath, string _namespace) { int floorPositionValue = Precision.GetPositionFloorOfPart(gender, partType); RMGenPart nextLowestGenPart = collection.Parts.GetPartByInternalPosition(partType, gender, floorPositionValue); if (nextLowestGenPart == null) { nextLowestGenPart = collection.Parts.GetLowestPartByInternalPosition(partType, gender); if (nextLowestGenPart == null) { return; } nextLowestGenPart.implicitID = floorPositionValue; PerformRenumberOnPartsFile(nextLowestGenPart, ref comparedPaths, rootPath, _namespace); } RMGenPart prevLowestGenPart; while (true) { prevLowestGenPart = nextLowestGenPart; collection.Parts.Remove(nextLowestGenPart); nextLowestGenPart = collection.Parts.GetLowestPartByInternalPosition(partType, gender); if (nextLowestGenPart == null) { break; } if ((nextLowestGenPart.implicitID - prevLowestGenPart.implicitID) > 1) { if (Precision.ShouldSkipPosition(gender, partType, prevLowestGenPart.implicitID + 1)) { int nextPosition = Precision.GetNextIntPosition(gender, partType, prevLowestGenPart.implicitID); if (nextPosition == nextLowestGenPart.implicitID) { continue; } } nextLowestGenPart.implicitID = Precision.GetNextIntPosition(gender, partType, prevLowestGenPart.implicitID); PerformRenumberOnPartsFile(nextLowestGenPart, ref comparedPaths, rootPath, _namespace); } } }
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; }
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); }
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); }
void LoadAssetInfo(frmPackAssetTNodeTag tag) { string _namespace = MethodBase.GetCurrentMethod().ToLogFormatFullName(); bool groupTypeSet = false; bool genderSet = false; bool type1Set = false; bool type2Set = false; bool type3Set = false; bool type4Set = false; if (tag.TagObjectType == frmPackAssetTNodeTag.TagType.AudioGroup || tag.TagObjectType == frmPackAssetTNodeTag.TagType.CharacterGroup || tag.TagObjectType == frmPackAssetTNodeTag.TagType.TilesetGroup || tag.TagObjectType == frmPackAssetTNodeTag.TagType.MovieGroup) { if (string.IsNullOrWhiteSpace(tag.Name)) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.CORRUPTED_MAIN, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(LoggerMessages.GUI.frmPackageAssets.Error.FAILED_LOAD_NAME, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return; } txtGroupName.Text = tag.Name; } else if (tag.TagObjectType == frmPackAssetTNodeTag.TagType.Collection) { ObjectAndIntCollection obj = comboGroupType.Items.FindObjectAndIntItemWithInt(0, (int)tag.CollectionType); if (obj == null) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.CORRUPTED_MAIN, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(LoggerMessages.GUI.frmPackageAssets.Error.FAILED_CORRUPTED_DATA, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return; } comboGroupType.SelectedItem = obj; groupTypeSet = true; } else if (tag.TagObjectType == frmPackAssetTNodeTag.TagType.GeneratorPartGroup) { if (string.IsNullOrWhiteSpace(tag.Name)) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.CORRUPTED_MAIN, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(LoggerMessages.GUI.frmPackageAssets.Error.FAILED_LOAD_NAME, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return; } txtGroupName.Text = tag.Name; RMGenPart genPart = tag.Object as RMGenPart; if (genPart == null) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.CORRUPTED_MAIN, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(LoggerMessages.GUI.frmPackageAssets.Error.FAILED_CORRUPTED_DATA, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return; } ObjectAndIntCollection obj = comboGroupType.Items.FindObjectAndIntItemWithInt(0, (int)genPart.PartType); if (obj == null) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.CORRUPTED_MAIN, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(LoggerMessages.GUI.frmPackageAssets.Error.FAILED_CORRUPTED_DATA, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return; } comboGroupType.SelectedItem = obj; groupTypeSet = true; obj = comboGroupGender.Items.FindObjectAndIntItemWithInt(0, (int)genPart.Gender); if (obj == null) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.CORRUPTED_MAIN, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(LoggerMessages.GUI.frmPackageAssets.Error.FAILED_CORRUPTED_DATA, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return; } comboGroupGender.SelectedItem = obj; genderSet = true; } else if (tag.TagObjectType == frmPackAssetTNodeTag.TagType.RMAudioFile) { if (string.IsNullOrWhiteSpace(tag.FullPath)) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.CORRUPTED_MAIN, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(LoggerMessages.GUI.frmPackageAssets.Error.FAILED_PATH_INVALID, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return; } if (string.IsNullOrWhiteSpace(NonVisibleRootDir)) { FileToOpenPath = tag.FullPath; } else { FileToOpenPath = NonVisibleRootDir + "\\" + tag.FullPath; } if (File.Exists(FileToOpenPath)) { txtFilePath.Text = tag.FullPath; } else { btnFileOpen.Enabled = false; txtFilePath.Text = "(Missing!) " + tag.FullPath; } RMAudioFile audioFile = tag.Object as RMAudioFile; if (audioFile == null) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.CORRUPTED_MAIN, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(LoggerMessages.GUI.frmPackageAssets.Error.FAILED_CORRUPTED_DATA, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return; } ObjectAndIntCollection obj = comboFileType1.Items.FindObjectAndIntItemWithInt(0, (int)audioFile.TypeOfFile); if (obj == null) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.CORRUPTED_MAIN, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(LoggerMessages.GUI.frmPackageAssets.Error.FAILED_CORRUPTED_DATA, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return; } comboFileType1.SelectedItem = obj; type1Set = true; //Be wary of this. Set this to false if error occurs. } else if (tag.TagObjectType == frmPackAssetTNodeTag.TagType.RMCharImageFile) { if (string.IsNullOrWhiteSpace(tag.FullPath)) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.CORRUPTED_MAIN, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(LoggerMessages.GUI.frmPackageAssets.Error.FAILED_PATH_INVALID, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return; } if (string.IsNullOrWhiteSpace(NonVisibleRootDir)) { FileToOpenPath = tag.FullPath; } else { FileToOpenPath = NonVisibleRootDir + "\\" + tag.FullPath; } if (File.Exists(FileToOpenPath)) { txtFilePath.Text = tag.FullPath; } else { btnFileOpen.Enabled = false; txtFilePath.Text = "(Missing!) " + tag.FullPath; } RMCharImageFile charImageFile = tag.Object as RMCharImageFile; if (charImageFile == null) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.CORRUPTED_MAIN, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(LoggerMessages.GUI.frmPackageAssets.Error.FAILED_CORRUPTED_DATA, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return; } ObjectAndIntCollection obj = comboFileType1.Items.FindObjectAndIntItemWithInt(0, (int)charImageFile.ImageType); if (obj == null) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.CORRUPTED_MAIN, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(LoggerMessages.GUI.frmPackageAssets.Error.FAILED_CORRUPTED_DATA, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return; } comboFileType1.SelectedItem = obj; type1Set = true; //Be wary of this. Set this to false if error occurs. } else if (tag.TagObjectType == frmPackAssetTNodeTag.TagType.RMGenFile) { if (string.IsNullOrWhiteSpace(tag.FullPath)) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.CORRUPTED_MAIN, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(LoggerMessages.GUI.frmPackageAssets.Error.FAILED_PATH_INVALID, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return; } if (string.IsNullOrWhiteSpace(NonVisibleRootDir)) { FileToOpenPath = tag.FullPath; } else { FileToOpenPath = NonVisibleRootDir + "\\" + tag.FullPath; } if (File.Exists(FileToOpenPath)) { txtFilePath.Text = tag.FullPath; } else { btnFileOpen.Enabled = false; txtFilePath.Text = "(Missing!) " + tag.FullPath; } RMGenFile genFile = tag.Object as RMGenFile; if (genFile == null) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.CORRUPTED_MAIN, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(LoggerMessages.GUI.frmPackageAssets.Error.FAILED_CORRUPTED_DATA, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return; } ObjectAndIntCollection obj = comboFileType1.Items.FindObjectAndIntItemWithInt(0, (int)genFile.FileType); if (obj == null) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.CORRUPTED_MAIN, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(LoggerMessages.GUI.frmPackageAssets.Error.FAILED_CORRUPTED_DATA, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return; } comboFileType1.SelectedItem = obj; type1Set = true; //Be wary of this. Set this to false if error occurs. comboFileType2.Text = genFile.BaseOrder.ToString(); comboFileType3.Text = genFile.Order.ToString(); comboFileType4.Text = genFile.Colour.ToString(); type2Set = true; type3Set = true; type4Set = true; } else if (tag.TagObjectType == frmPackAssetTNodeTag.TagType.RMMovieFile) { if (string.IsNullOrWhiteSpace(tag.FullPath)) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.CORRUPTED_MAIN, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(LoggerMessages.GUI.frmPackageAssets.Error.FAILED_PATH_INVALID, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return; } if (string.IsNullOrWhiteSpace(NonVisibleRootDir)) { FileToOpenPath = tag.FullPath; } else { FileToOpenPath = NonVisibleRootDir + "\\" + tag.FullPath; } if (File.Exists(FileToOpenPath)) { txtFilePath.Text = tag.FullPath; } else { btnFileOpen.Enabled = false; txtFilePath.Text = "(Missing!) " + tag.FullPath; } RMMovieFile movieFile = tag.Object as RMMovieFile; if (movieFile == null) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.CORRUPTED_MAIN, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(LoggerMessages.GUI.frmPackageAssets.Error.FAILED_CORRUPTED_DATA, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return; } ObjectAndIntCollection obj = comboFileType1.Items.FindObjectAndIntItemWithInt(0, (int)movieFile.TypeOfFile); if (obj == null) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.CORRUPTED_MAIN, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(LoggerMessages.GUI.frmPackageAssets.Error.FAILED_CORRUPTED_DATA, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return; } comboFileType1.SelectedItem = obj; type1Set = true; //Be wary of this. Set this to false if error occurs. } else if (tag.TagObjectType == frmPackAssetTNodeTag.TagType.RMSingleFile) { if (string.IsNullOrWhiteSpace(tag.FullPath)) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.CORRUPTED_MAIN, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(LoggerMessages.GUI.frmPackageAssets.Error.FAILED_PATH_INVALID, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return; } if (string.IsNullOrWhiteSpace(NonVisibleRootDir)) { FileToOpenPath = tag.FullPath; } else { FileToOpenPath = NonVisibleRootDir + "\\" + tag.FullPath; } if (File.Exists(FileToOpenPath)) { txtFilePath.Text = tag.FullPath; } else { btnFileOpen.Enabled = false; txtFilePath.Text = "(Missing!) " + tag.FullPath; } } else if (tag.TagObjectType == frmPackAssetTNodeTag.TagType.RMTilesetFile) { if (string.IsNullOrWhiteSpace(tag.FullPath)) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.CORRUPTED_MAIN, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(LoggerMessages.GUI.frmPackageAssets.Error.FAILED_PATH_INVALID, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return; } if (string.IsNullOrWhiteSpace(NonVisibleRootDir)) { FileToOpenPath = tag.FullPath; } else { FileToOpenPath = NonVisibleRootDir + "\\" + tag.FullPath; } if (File.Exists(FileToOpenPath)) { txtFilePath.Text = tag.FullPath; } else { btnFileOpen.Enabled = false; txtFilePath.Text = "(Missing!) " + tag.FullPath; } RMTilesetFile tilesetFile = tag.Object as RMTilesetFile; if (tilesetFile == null) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.CORRUPTED_MAIN, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(LoggerMessages.GUI.frmPackageAssets.Error.FAILED_CORRUPTED_DATA, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return; } ObjectAndIntCollection obj = comboFileType1.Items.FindObjectAndIntItemWithInt(0, (int)tilesetFile.FileType); if (obj == null) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.CORRUPTED_MAIN, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(LoggerMessages.GUI.frmPackageAssets.Error.FAILED_CORRUPTED_DATA, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return; } comboFileType1.SelectedItem = obj; type1Set = true; //Be wary of this. Set this to false if error occurs. obj = comboFileType2.Items.FindObjectAndIntItemWithInt(0, (int)tilesetFile.AtlasType); if (obj == null) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.CORRUPTED_MAIN, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(LoggerMessages.GUI.frmPackageAssets.Error.FAILED_CORRUPTED_DATA, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return; } comboFileType2.SelectedItem = obj; type2Set = true; } if (!groupTypeSet && comboGroupType.Items.Count > 0) { comboGroupType.SelectedIndex = 0; } if (!genderSet && comboGroupGender.Items.Count > 0) { comboGroupGender.SelectedIndex = 0; } if (!type1Set && comboFileType1.Items.Count > 0) { comboFileType1.SelectedIndex = 0; } if (!type2Set && comboFileType2.Items.Count > 0) { comboFileType2.SelectedIndex = 0; } if (!type3Set && comboFileType3.Items.Count > 0) { comboFileType3.SelectedIndex = 0; } if (!type4Set && comboFileType4.Items.Count > 0) { comboFileType4.SelectedIndex = 0; } }
public static void InstallGeneratorPartOnGender(string toWhere, string fromRootDir, string rootInstallPath, RMGenPart part, string _namespace) { if (part.Files != null) { int lowestPossiblePos = GeneratorPartsManager.Precision.GetPositionFloorOfPart(part.Gender, part.PartType); int positionOfPart = GeneratorPartsManager.Precision.GetNextVacantPosition(part.Gender, part.PartType, lowestPossiblePos - 1); foreach (RMGenFile file in part.Files) { string dirContainerFile = file.FileType.GetContainingDirectoryName(); string dirContainerGender = part.Gender.GetContainingDirectoryName(); if (string.IsNullOrWhiteSpace(dirContainerFile)) { try { throw new InvalidGeneratorPartFileException(ExceptionMessages.RMPackage.GEN_FILE_NO_TYPE, InvalidGeneratorPartFileException.WhichInvalid.NoType, part); } catch (Exception ex) { Logger.WriteErrorLog(LoggerMessages.PackageManagement.Installer.Error.GEN_INVALID_TYPE, _namespace, ex, BasicDebugLogger.DebugErrorType.Error); throw; } } if (string.IsNullOrWhiteSpace(dirContainerGender)) { try { throw new InvalidGeneratorPartFileException(ExceptionMessages.RMPackage.GEN_FILE_NO_GENDER, InvalidGeneratorPartFileException.WhichInvalid.NoGender, part); } catch (Exception ex) { Logger.WriteErrorLog(LoggerMessages.PackageManagement.Installer.Error.GEN_INVALID_GENDER, _namespace, ex, BasicDebugLogger.DebugErrorType.Error); throw; } } string subPath = toWhere + "\\" + dirContainerFile + "\\" + dirContainerGender; InstallGeneratorFile(subPath, fromRootDir, rootInstallPath, file, positionOfPart, _namespace); } } }
public InvalidGeneratorPartFileException(string message, WhichInvalid whichInvalid, RMGenPart part) : base(message) { TypeOfIssue = whichInvalid; Part = part; }
static void PerformRenumberOnPartsFile(RMGenPart part, ref List <ComparedPath> comparedPaths, string rootPath, string _namespace) { Exception outEx; if (part.Files == null) { return; } foreach (RMGenFile file in part.Files) { if (string.IsNullOrWhiteSpace(file.Path)) { continue; } ComparedPath comparedPath = new ComparedPath(); comparedPath.Old = file.Path; string newPath = string.Empty; try { newPath = Path.GetDirectoryName(file.Path); } catch (Exception ex) { Logger.WriteErrorLog(LoggerMessages.GeneratorPartsManager.RenumberParts.Error.InvalidPath(file.Path), _namespace, ex, BasicDebugLogger.DebugErrorType.CriticalError); throw; } try { newPath += "\\" + file.RetrieveInstallFileName(part.implicitID); } catch (Exception ex) { Logger.WriteErrorLog(LoggerMessages.GeneratorPartsManager.RenumberParts.Error.InvalidPart(comparedPath.Old), _namespace, ex, BasicDebugLogger.DebugErrorType.CriticalError); throw; } comparedPath.New = newPath; string completeOldPath = rootPath + "\\" + comparedPath.Old; string completeTempPath = PMFileSystem.PackMan_TempRenumberDir + "\\" + comparedPath.New; string dirPath = null; try { dirPath = Path.GetDirectoryName(completeTempPath); } catch (Exception ex) { Logger.WriteErrorLog(LoggerMessages.GeneratorPartsManager.RenumberParts.Error.InvalidTempPath(file.Path), _namespace, ex, BasicDebugLogger.DebugErrorType.CriticalError); throw; } if (!Directory.Exists(dirPath) && Helper.CreateFolderSafely(dirPath, _namespace, out outEx, LoggerMessages.GeneralError.CREATE_REQUIRED_DIR_FAILED_ARG) == CreateFolderResult.UserCancelled) { throw outEx; } MoveFileResult moveRes = Helper.MoveFileSafely(completeOldPath, completeTempPath, true, _namespace, out outEx , new MoveFileLogMessages(sourceFileNotFound: LoggerMessages.GeneratorPartsManager.RenumberParts.Error.UnableMoveToTempSrcNotFound , moveFileFailed: LoggerMessages.GeneratorPartsManager.RenumberParts.Error.UnableMoveToTemp)); if (moveRes == MoveFileResult.UserCancelled || moveRes == MoveFileResult.SourceFileNotFound) { throw outEx; } comparedPaths.Add(comparedPath); } }