static List <ComparedPath> PerformRenumber(RMGeneratorCollection collection, string rootPath, string _namespace) { List <ComparedPath> retVal = new List <ComparedPath>(); PerformRenumberOnGender(collection, RMGenPart.eGender.Female, ref retVal, rootPath, _namespace); PerformRenumberOnGender(collection, RMGenPart.eGender.Male, ref retVal, rootPath, _namespace); PerformRenumberOnGender(collection, RMGenPart.eGender.Kid, ref retVal, rootPath, _namespace); return(retVal); }
public static RMGeneratorCollection RetrieveGeneratorCollection(string path, string rootPath, string _namespace, bool trimRootPath, out LogDataList log, RMPackage parent) { log = new LogDataList(); RMGeneratorCollection newCollection = new RMGeneratorCollection(parent); List <RMGenPart> tempListOfFiles = new List <RMGenPart>(); LogDataList outLog = null; string appendedPath = path + "\\" + RMPConstants.LowCaseDirectoryNames.GEN_FACE; if (Directory.Exists(appendedPath)) { RetrieveGeneratorFileParts(appendedPath.ToLower(), rootPath, _namespace, trimRootPath, out outLog, ref tempListOfFiles, RMGenFile.GenFileType.Face, newCollection); log.AppendLogs(outLog); } appendedPath = path + "\\" + RMPConstants.LowCaseDirectoryNames.GEN_SV; if (Directory.Exists(appendedPath)) { RetrieveGeneratorFileParts(appendedPath.ToLower(), rootPath, _namespace, trimRootPath, out outLog, ref tempListOfFiles, RMGenFile.GenFileType.SV, newCollection); log.AppendLogs(outLog); } appendedPath = path + "\\" + RMPConstants.LowCaseDirectoryNames.GEN_TV; if (Directory.Exists(appendedPath)) { RetrieveGeneratorFileParts(appendedPath.ToLower(), rootPath, _namespace, trimRootPath, out outLog, ref tempListOfFiles, RMGenFile.GenFileType.TV, newCollection); log.AppendLogs(outLog); } appendedPath = path + "\\" + RMPConstants.LowCaseDirectoryNames.GEN_TVD; if (Directory.Exists(appendedPath)) { RetrieveGeneratorFileParts(appendedPath.ToLower(), rootPath, _namespace, trimRootPath, out outLog, ref tempListOfFiles, RMGenFile.GenFileType.TVD, newCollection); log.AppendLogs(outLog); } appendedPath = path + "\\" + RMPConstants.LowCaseDirectoryNames.GEN_VARIATION; if (Directory.Exists(appendedPath)) { RetrieveGeneratorFileParts(appendedPath.ToLower(), rootPath, _namespace, trimRootPath, out outLog, ref tempListOfFiles, RMGenFile.GenFileType.Var, newCollection); log.AppendLogs(outLog); } if (tempListOfFiles.Count == 0) { return(null); } newCollection.Parts.AddRange(tempListOfFiles); return(newCollection); }
static UninstallResult UninstallPackage(RMPackage package, string _namespace, out LogDataList log, bool globalPackage = true, string whereToRemove = null) { UninstallResult retVal = UninstallResult.normal; log = new LogDataList(); if (package.Collections != null) { foreach (RMCollection collection in package.Collections) { RMGeneratorCollection genCollection = collection as RMGeneratorCollection; if (genCollection != null) { if (globalPackage) { whereToRemove = PMFileSystem.MV_Installation_Directory; retVal = Generator.UninstallGeneratorParts(whereToRemove, _namespace, genCollection); genCollection = null; } //ignore this collection if not a global package } else { if (globalPackage) { whereToRemove = PMFileSystem.MV_NewData_Dir; } List <RMPackFile> files = collection.RetrieveAllFiles(); if (files != null) { foreach (RMPackFile file in files) { if (string.IsNullOrWhiteSpace(file.Path)) { continue; } string concatPath = whereToRemove + "\\" + file.Path; if (File.Exists(concatPath)) { Exception ex = null; if (Helper.DeleteFileSafely(concatPath, _namespace, out ex, new DeleteFileLogMessages(deleteFailed: UninstallerMessages.Warning.FileDeleteFailed, logGroup: log)) == DeleteFileResult.FileNotFound) { continue; } } } } } } } return(retVal); }
static void CopyGeneratorParts(string toWhere, RMGeneratorCollection collection, string _namespace, string rootDir = null) { try { PerformDirectoryExistenceCheck(toWhere, _namespace); } catch (Exception ex) { Logger.WriteErrorLog(LoggerMessages.PackageMaker.Error.DIR_EXISTENCE_GEN_FAILED, _namespace, ex, BasicDebugLogger.DebugErrorType.Error); throw; } if (collection.Parts != null) { foreach (RMGenPart part in collection.Parts) { CopyGeneratorPart(toWhere + "\\" + DirectoryNames.Generator.ROOT, part, _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); } } }
static void PerformRenumberOnGender(RMGeneratorCollection collection, RMGenPart.eGender gender, ref List <ComparedPath> comparedPaths, string rootPath, string _namespace) { PerformRenumberOnPart(collection, gender, RMGenPart.GenPartType.Accessory_A, ref comparedPaths, rootPath, _namespace); PerformRenumberOnPart(collection, gender, RMGenPart.GenPartType.Accessory_B, ref comparedPaths, rootPath, _namespace); PerformRenumberOnPart(collection, gender, RMGenPart.GenPartType.Beard, ref comparedPaths, rootPath, _namespace); PerformRenumberOnPart(collection, gender, RMGenPart.GenPartType.Beast_Ears, ref comparedPaths, rootPath, _namespace); PerformRenumberOnPart(collection, gender, RMGenPart.GenPartType.Body, ref comparedPaths, rootPath, _namespace); PerformRenumberOnPart(collection, gender, RMGenPart.GenPartType.Cloak, ref comparedPaths, rootPath, _namespace); PerformRenumberOnPart(collection, gender, RMGenPart.GenPartType.Clothing, ref comparedPaths, rootPath, _namespace); PerformRenumberOnPart(collection, gender, RMGenPart.GenPartType.Ears, ref comparedPaths, rootPath, _namespace); PerformRenumberOnPart(collection, gender, RMGenPart.GenPartType.Eyebrows, ref comparedPaths, rootPath, _namespace); PerformRenumberOnPart(collection, gender, RMGenPart.GenPartType.Eyes, ref comparedPaths, rootPath, _namespace); PerformRenumberOnPart(collection, gender, RMGenPart.GenPartType.Face, ref comparedPaths, rootPath, _namespace); PerformRenumberOnPart(collection, gender, RMGenPart.GenPartType.Facial_Mark, ref comparedPaths, rootPath, _namespace); PerformRenumberOnPart(collection, gender, RMGenPart.GenPartType.Front_Hair, ref comparedPaths, rootPath, _namespace); PerformRenumberOnPart(collection, gender, RMGenPart.GenPartType.Glasses, ref comparedPaths, rootPath, _namespace); PerformRenumberOnPart(collection, gender, RMGenPart.GenPartType.Mouth, ref comparedPaths, rootPath, _namespace); PerformRenumberOnPart(collection, gender, RMGenPart.GenPartType.Nose, ref comparedPaths, rootPath, _namespace); PerformRenumberOnPart(collection, gender, RMGenPart.GenPartType.Rear_Hair, ref comparedPaths, rootPath, _namespace); PerformRenumberOnPart(collection, gender, RMGenPart.GenPartType.Tail, ref comparedPaths, rootPath, _namespace); PerformRenumberOnPart(collection, gender, RMGenPart.GenPartType.Wing, ref comparedPaths, rootPath, _namespace); }
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); } } }
static void RetrieveGeneratorFileParts(string path, string rootPath, string _namespace, bool trimRootPath, out LogDataList log, ref List <RMGenPart> collection, RMGenFile.GenFileType whichFilePart, RMGeneratorCollection parent) { log = new LogDataList(); string appendedPath = path + "\\" + RMPConstants.LowCaseDirectoryNames.GEN_PART_FEMALE; LogDataList outLog = null; if (Directory.Exists(appendedPath)) { RetrieveGeneratorPartOnGender(appendedPath.ToLower(), rootPath, _namespace, trimRootPath, out outLog, ref collection, whichFilePart, RMGenPart.eGender.Female, parent); log.AppendLogs(outLog); } appendedPath = path + "\\" + RMPConstants.LowCaseDirectoryNames.GEN_PART_MALE; if (Directory.Exists(appendedPath)) { RetrieveGeneratorPartOnGender(appendedPath.ToLower(), rootPath, _namespace, trimRootPath, out outLog, ref collection, whichFilePart, RMGenPart.eGender.Male, parent); log.AppendLogs(outLog); } appendedPath = path + "\\" + RMPConstants.LowCaseDirectoryNames.GEN_PART_KID; if (Directory.Exists(appendedPath)) { RetrieveGeneratorPartOnGender(appendedPath.ToLower(), rootPath, _namespace, trimRootPath, out outLog, ref collection, whichFilePart, RMGenPart.eGender.Kid, parent); log.AppendLogs(outLog); } }
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); }
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); }
public static void InstallGeneratorParts(string toWhere, string fromRootDir, RMGeneratorCollection collection, string _namespace) { try { PerformDirectoryExistenceCheck(toWhere, _namespace); } catch (Exception ex) { Logger.WriteErrorLog(LoggerMessages.PackageManagement.Installer.Error.UNABLE_MAKE_GEN_DIR_TOP, _namespace, ex, BasicDebugLogger.DebugErrorType.Error); throw; } if (collection.Parts != null) { foreach (RMGenPart part in collection.Parts) { InstallGeneratorPartOnGender(toWhere + "\\" + DirectoryNames.Generator.ROOT, fromRootDir, toWhere, part, _namespace); } } }
public static UninstallResult UninstallGeneratorParts(string whereFrom, string _namespace, RMGeneratorCollection collection) { if (collection == null || collection.Parts == null) { return(UninstallResult.normal); } List <RMPackFile> files = collection.RetrieveAllFiles(); UninstallResult retVal = UninstallResult.normal; if (files != null) { foreach (RMPackFile file in files) { if (string.IsNullOrWhiteSpace(file.Path)) { continue; } string concatPath = whereFrom + "\\" + file.Path; if (File.Exists(concatPath)) { Exception ex = null; if (Helper.DeleteFileSafely(concatPath, _namespace, out ex, LoggerMessages.GeneralError.DELETE_UNUSED_FILE_FAILED_ARG) == DeleteFileResult.UserCancelled) { throw ex; } retVal = UninstallResult.genPartsRemoved; } } } return(retVal); }
public InvalidGeneratorPartException(string message, WhichInvalid whichInvalid, RMGeneratorCollection generator) : base(message) { TypeOfIssue = whichInvalid; Generator = generator; }
public static void RenumberParts(string parentFolderPath, string _namespace, out LogDataList log, bool relinkGlobalPackages = false) { log = new LogDataList(); log.WriteInformationLog(LoggerMessages.GeneratorPartsManager.RenumberParts.Info.RENUMBER_START + parentFolderPath + ".", _namespace); Exception outEx; if (!Directory.Exists(parentFolderPath)) { return; } if (Helper.DeleteFolderSafely(PMFileSystem.PackMan_TempRenumberDir, _namespace, out outEx, LoggerMessages.GeneralError.UNABLE_DELETE_TEMP_DIR_ARG) == DeleteFolderResult.UserCancelled) { throw outEx; } if (Helper.CreateFolderSafely(PMFileSystem.PackMan_TempRenumberDir, _namespace, out outEx, LoggerMessages.GeneralError.UNABLE_CREATE_TEMP_DIR_ARG) == CreateFolderResult.UserCancelled) { throw outEx; } RMPackage tempGenPack = new RMPackage(); tempGenPack.Name = "Generator Parts Renumber Class"; LogDataList outLog; RMImplicit.RetrievePackFromDir(parentFolderPath, _namespace, true, out outLog, ref tempGenPack); log.AppendLogs(outLog); if (tempGenPack.Collections == null || tempGenPack.Collections.Count == 0) { return; } List <ComparedPath> comparedPaths = null; foreach (RMCollection collection in tempGenPack.Collections) { if (collection is RMGeneratorCollection) { RMGeneratorCollection genCollection = collection as RMGeneratorCollection; try { if (genCollection.Parts != null) { comparedPaths = PerformRenumber(genCollection, parentFolderPath, _namespace); } } catch (Exception ex) { Logger.WriteErrorLog(LoggerMessages.GeneratorPartsManager.RenumberParts.Error.RENUMBER_ABORT_GENERAL, _namespace, ex, BasicDebugLogger.DebugErrorType.CriticalError); throw; } } } if (comparedPaths != null && comparedPaths.Count > 0) { foreach (ComparedPath comparedPath in comparedPaths) { string completeTempPath = PMFileSystem.PackMan_TempRenumberDir + "\\" + comparedPath.New; string completeFinalPath = parentFolderPath + "\\" + comparedPath.New; MoveFileResult moveResult = Helper.MoveFileSafely(completeTempPath, completeFinalPath, true, _namespace, out outEx, new MoveFileLogMessages(sourceFileNotFound: LoggerMessages.GeneratorPartsManager.RenumberParts.Error.UnableMoveFinalSrcNotFound , moveFileFailed: LoggerMessages.GeneratorPartsManager.RenumberParts.Error.UnableMoveFinal)); if (moveResult == MoveFileResult.UserCancelled || moveResult == MoveFileResult.SourceFileNotFound) { throw outEx; } if (relinkGlobalPackages && PackageManagement.GlobalPackages != null) { foreach (InstalledPackage package in PackageManagement.GlobalPackages) { if (package.Package != null) { RMGenFile foundFile = package.Package.FindGenFileWithPath(comparedPath.Old); if (foundFile != null) { foundFile.Path = comparedPath.New; package.ChangesMade = true; goto continuehere; } } } } continuehere :; } if (relinkGlobalPackages && PackageManagement.GlobalPackages != null) { foreach (InstalledPackage package in PackageManagement.GlobalPackages) { if (package.ChangesMade && package.Package != null) { package.Package.SaveToFile(package.XMLPath, _namespace, logMessage : new WriteAllTextLogMessages(writeFailed : LoggerMessages.GeneratorPartsManager.RenumberParts.Error.FailedSaveXML)); package.ChangesMade = false; } } } } Helper.DeleteFolderSafely(PMFileSystem.PackMan_TempRenumberDir, _namespace, out outEx, LoggerMessages.GeneralError.UNABLE_DELETE_TEMP_DIR_ARG); log.WriteInformationLog(LoggerMessages.GeneratorPartsManager.RenumberParts.Info.RENUMBER_END + parentFolderPath + ".", _namespace); }