public static int GetNextVacantPosition(RMGenPart.eGender gender, RMGenPart.GenPartType partType, int curPosition) { string pathToVar = PMFileSystem.Generator.Variation.Root + "\\" + gender.GetContainingDirectoryName(); string partToCount = pathToVar + "\\" + RMPConstants.GenFileNamePrefixANDSuffix.VARIATION + "_" + partType.ToParsableXMLString(); Config cfgWithLowestInt = Config.GetConfigFileWithLowestInt(SpecialNumberedParts, gender, partType, curPosition); bool nextIntAlreadyChecked = false; int nextInt = curPosition + 1; if (cfgWithLowestInt == null || cfgWithLowestInt.Integer > nextInt) { nextIntAlreadyChecked = true; } string partToCheck = partToCount + RMGenFile.FormatPosition(nextInt) + RMPConstants.GenFileNamePrefixANDSuffix.PNG; if (File.Exists(partToCheck)) { return(GetNextVacantPosition(gender, partType, nextInt)); } if (!nextIntAlreadyChecked && ShouldSkipPosition(gender, partType, nextInt)) { return(GetNextVacantPosition(gender, partType, nextInt)); } return(nextInt); }
static RMGenFile CreateGenFileFromTempGenFileName(TempGenFileNameParsed parsedFileName, RMGenFile.GenFileType typeOfFile, string path) { RMGenFile newGenFile = new RMGenFile(); newGenFile.BaseOrder = parsedFileName.BaseOrder; newGenFile.Colour = parsedFileName.Colour; newGenFile.FileType = typeOfFile; newGenFile.Order = parsedFileName.Order; newGenFile.Path = path; return(newGenFile); }
static void CopyGeneratorFile(string toWhere, RMGenFile genFile, string _namespace, string rootDir = null) { int tempPos = genFile.Parent.Parent.Parts.IndexOf(genFile.Parent) + 1; string newFileName = null; try { newFileName = genFile.RetrieveInstallFileName(tempPos); } catch (Exception ex) { Logger.WriteErrorLog(LoggerMessages.PackageMaker.Error.GEN_FILE_ERR_FILE_NAME, _namespace, ex, BasicDebugLogger.DebugErrorType.Error); throw; } string copyToPath = toWhere + "\\" + newFileName; if (string.IsNullOrWhiteSpace(genFile.Path)) { try { throw new InvalidGeneratorPartFileException(ExceptionMessages.RMPackage.GEN_FILE_PATH_NULL, InvalidGeneratorPartFileException.WhichInvalid.PathNotSet, genFile.Parent); } catch (Exception ex) { Logger.WriteErrorLog(LoggerMessages.PackageMaker.Error.FILE_PATH_NOT_SET, _namespace, ex, BasicDebugLogger.DebugErrorType.Error); throw; } } Exception outEx; string originFile = genFile.Path; if (!string.IsNullOrWhiteSpace(rootDir)) { originFile = rootDir + "\\" + genFile.Path; } if (Helper.CopyFileSafely(originFile, copyToPath, true, _namespace, out outEx, new CopyFileLogMessages(copyFileFailed: LoggerMessages.PackageUtil.Error.CopyFileFailed)) != CopyFileResult.Success) { throw outEx; } }
void SaveFileInfo(TreeNode node) { string _namespace = MethodBase.GetCurrentMethod().ToLogFormatFullName(); if (node.Tag == null) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.UNABLE_SAVE_FILE_INFO, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(LoggerMessages.GUI.frmPackageAssets.Error.UNABLE_SAVE_FILE_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_FILE_INFO, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(LoggerMessages.GUI.frmPackageAssets.Error.UNABLE_SAVE_FILE_INFO_NULL_TAG, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return; } if (tag.TagObjectType == frmPackAssetTNodeTag.TagType.RMAudioFile) { RMAudioFile audioFile = tag.Object as RMAudioFile; if (audioFile == null) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.UNABLE_SAVE_FILE_INFO, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(LoggerMessages.GUI.frmPackageAssets.Error.UNABLE_SAVE_FILE_INFO_NULL_TAG, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return; } ObjectAndIntCollection objAndIntColl = comboFileType1.SelectedItem as ObjectAndIntCollection; audioFile.TypeOfFile = (RMAudioFile.FileType)objAndIntColl.IntegerCollection[0]; node.Text = tag.ToString(); changesMadeFile = false; return; } else if (tag.TagObjectType == frmPackAssetTNodeTag.TagType.RMCharImageFile) { RMCharImageFile charImageFile = tag.Object as RMCharImageFile; if (charImageFile == null) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.UNABLE_SAVE_FILE_INFO, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(LoggerMessages.GUI.frmPackageAssets.Error.UNABLE_SAVE_FILE_INFO_NULL_TAG, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return; } ObjectAndIntCollection objAndIntColl = comboFileType1.SelectedItem as ObjectAndIntCollection; charImageFile.ImageType = (RMCharImageFile.ImageTypes)objAndIntColl.IntegerCollection[0]; node.Text = tag.ToString(); changesMadeFile = false; return; } else if (tag.TagObjectType == frmPackAssetTNodeTag.TagType.RMGenFile) { RMGenFile genFile = tag.Object as RMGenFile; if (genFile == null) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.UNABLE_SAVE_FILE_INFO, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(LoggerMessages.GUI.frmPackageAssets.Error.UNABLE_SAVE_FILE_INFO_NULL_TAG, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return; } ObjectAndIntCollection objAndIntColl = comboFileType1.SelectedItem as ObjectAndIntCollection; genFile.FileType = (RMGenFile.GenFileType)objAndIntColl.IntegerCollection[0]; int highOrderParse = comboFileType2.Text.TryToInt(0); int lowOrderParse = comboFileType3.Text.TryToInt(0); int colourParse = comboFileType4.Text.TryToInt(0); if (highOrderParse == -1) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.HIGH_ORDER_INVALID, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (lowOrderParse == -1) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.LOW_ORDER_INVALID, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (colourParse == -1) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.COLOUR_INVALID, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } genFile.Order = lowOrderParse; genFile.Colour = colourParse; genFile.BaseOrder = highOrderParse; node.Text = tag.ToString(); changesMadeFile = false; return; } else if (tag.TagObjectType == frmPackAssetTNodeTag.TagType.RMMovieFile) { RMMovieFile movieFile = tag.Object as RMMovieFile; if (movieFile == null) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.UNABLE_SAVE_FILE_INFO, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(LoggerMessages.GUI.frmPackageAssets.Error.UNABLE_SAVE_FILE_INFO_NULL_TAG, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return; } ObjectAndIntCollection objAndIntColl = comboFileType1.SelectedItem as ObjectAndIntCollection; movieFile.TypeOfFile = (RMMovieFile.FileType)objAndIntColl.IntegerCollection[0]; node.Text = tag.ToString(); changesMadeFile = false; return; } else if (tag.TagObjectType == frmPackAssetTNodeTag.TagType.RMTilesetFile) { RMTilesetFile tilesetFile = tag.Object as RMTilesetFile; if (tilesetFile == null) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.UNABLE_SAVE_FILE_INFO, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(LoggerMessages.GUI.frmPackageAssets.Error.UNABLE_SAVE_FILE_INFO_NULL_TAG, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return; } ObjectAndIntCollection objAndIntColl = comboFileType1.SelectedItem as ObjectAndIntCollection; tilesetFile.FileType = (RMTilesetFile.eFileType)objAndIntColl.IntegerCollection[0]; objAndIntColl = comboFileType2.SelectedItem as ObjectAndIntCollection; tilesetFile.AtlasType = (RMTilesetFile.eAtlasType)objAndIntColl.IntegerCollection[0]; node.Text = tag.ToString(); changesMadeFile = false; return; } else if (tag.TagObjectType == frmPackAssetTNodeTag.TagType.RMSingleFile) { return; } Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.UNABLE_SAVE_FILE_INFO, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(LoggerMessages.GUI.frmPackageAssets.Error.UNABLE_SAVE_FILE_INFO_NULL_TAG, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return; }
bool RemoveAsset(TreeNode tNode) { string _namespace = MethodBase.GetCurrentMethod().ToLogFormatFullName(); frmPackAssetTNodeTag assetTag = tNode.Tag as frmPackAssetTNodeTag; if (assetTag == null) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_ASSET_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_ASSET_TAG_NULL, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return(false); } if (assetTag.TagObjectType == frmPackAssetTNodeTag.TagType.RMAudioFile) { RMAudioFile audioFile = assetTag.Object as RMAudioFile; if (audioFile == null) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_ASSET_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_ASSET_TAG_INVALID, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return(false); } if (audioFile.Parent == null) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_ASSET_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_ASSET_PARENT_NULL_INVALID, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return(false); } audioFile.Parent.Files.Remove(audioFile); assetTag.AssociatedNode.Remove(); return(true); } else if (assetTag.TagObjectType == frmPackAssetTNodeTag.TagType.RMCharImageFile) { RMCharImageFile charImageFile = assetTag.Object as RMCharImageFile; if (charImageFile == null) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_ASSET_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_ASSET_TAG_INVALID, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return(false); } if (charImageFile.Parent == null) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_ASSET_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_ASSET_PARENT_NULL_INVALID, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return(false); } charImageFile.Parent.Files.Remove(charImageFile); assetTag.AssociatedNode.Remove(); return(true); } else if (assetTag.TagObjectType == frmPackAssetTNodeTag.TagType.RMGenFile) { RMGenFile genFile = assetTag.Object as RMGenFile; if (genFile == null) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_ASSET_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_ASSET_TAG_INVALID, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return(false); } if (genFile.Parent == null) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_ASSET_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_ASSET_PARENT_NULL_INVALID, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return(false); } genFile.Parent.Files.Remove(genFile); assetTag.AssociatedNode.Remove(); return(true); } else if (assetTag.TagObjectType == frmPackAssetTNodeTag.TagType.RMMovieFile) { RMMovieFile movieFile = assetTag.Object as RMMovieFile; if (movieFile == null) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_ASSET_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_ASSET_TAG_INVALID, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return(false); } if (movieFile.Parent == null) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_ASSET_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_ASSET_PARENT_NULL_INVALID, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return(false); } movieFile.Parent.Files.Remove(movieFile); assetTag.AssociatedNode.Remove(); return(true); } else if (assetTag.TagObjectType == frmPackAssetTNodeTag.TagType.RMSingleFile) { RMSingleFile singleFile = assetTag.Object as RMSingleFile; if (singleFile == null) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_ASSET_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_ASSET_TAG_INVALID, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return(false); } if (singleFile.Parent == null) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_ASSET_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_ASSET_PARENT_NULL_INVALID, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return(false); } singleFile.Parent.Files.Remove(singleFile); assetTag.AssociatedNode.Remove(); return(true); } else if (assetTag.TagObjectType == frmPackAssetTNodeTag.TagType.RMTilesetFile) { RMTilesetFile tilesetFile = assetTag.Object as RMTilesetFile; if (tilesetFile == null) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_ASSET_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_ASSET_TAG_INVALID, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return(false); } if (tilesetFile.Parent == null) { Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_ASSET_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_ASSET_PARENT_NULL_INVALID, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return(false); } tilesetFile.Parent.Files.Remove(tilesetFile); assetTag.AssociatedNode.Remove(); return(true); } Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPackageAssets.DELETE_ASSET_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.WriteErrorLog(frmPackageAssetsMessages.Error.UNABLE_REMOVE_ASSET_INVALID, _namespace, null, BasicDebugLogger.DebugErrorType.Error); return(false); }
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); }
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 InstallGeneratorFile(string toWhere, string fromRootDir, string rootInstallPath, RMGenFile fileToInstall, int position, string _namespace) { string newFileName = null; try { newFileName = fileToInstall.RetrieveInstallFileName(position); } catch (Exception ex) { Logger.WriteErrorLog(LoggerMessages.PackageManagement.Installer.Error.INVALID_GEN_FILE, _namespace, ex, BasicDebugLogger.DebugErrorType.Error); throw; } string copyToPath = toWhere + "\\" + newFileName; if (string.IsNullOrWhiteSpace(fileToInstall.Path)) { try { throw new InvalidGeneratorPartFileException(ExceptionMessages.RMPackage.GEN_FILE_PATH_NULL, InvalidGeneratorPartFileException.WhichInvalid.PathNotSet, fileToInstall.Parent); } catch (Exception ex) { Logger.WriteErrorLog(LoggerMessages.PackageManagement.Installer.Error.NO_FILE_PATH_GEN_FILE, _namespace, ex, BasicDebugLogger.DebugErrorType.Error); throw; } } Exception outEx; string sourceFile = fromRootDir + "\\" + fileToInstall.Path; if (Helper.CopyFileSafely(sourceFile, copyToPath, true, _namespace, out outEx, new CopyFileLogMessages(copyFileFailed: LoggerMessages.PackageManagement.Installer.Error.GeneratorFileFailedCopy)) != CopyFileResult.Success) { throw outEx; } // fileToInstall.InstallationStatus = RMPackObject.InstallStatus.Installed; fileToInstall.Path = Helper.GetRelativePath(copyToPath, rootInstallPath); }
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); }