static void InstallTilesetFile(string toWhere, string rootDir, string fromDirectory, RMTilesetGroup tileset, string _namespace) { if (tileset.Files != null) { foreach (RMTilesetFile file in tileset.Files) { string atlasType = file.AtlasType.ToXMLString(); string fileType = file.FileType.ToXMLString(); if (string.IsNullOrWhiteSpace(atlasType)) { atlasType = "unspecified"; } if (string.IsNullOrWhiteSpace(fileType)) { try { throw new InvalidTilesetException(ExceptionMessages.RMPackage.TILESET_FILE_TYPE_NOT_SET, InvalidTilesetException.WhichInvalid.FileType, tileset.Parent); } catch (Exception ex) { Logger.WriteErrorLog(LoggerMessages.PackageManagement.Installer.Error.INVALID_TILESET_FILE_TYPE, _namespace, ex, BasicDebugLogger.DebugErrorType.Error); throw; } } string newFileName = tileset.Name + "_" + atlasType + "." + fileType; string newFile = toWhere + "\\" + newFileName; if (string.IsNullOrWhiteSpace(file.Path)) { try { throw new InvalidTilesetFileException(ExceptionMessages.RMPackage.TILESET_FILE_PATH_NULL, InvalidTilesetFileException.WhichInvalid.NoPath, tileset); } catch (Exception ex) { Logger.WriteErrorLog(LoggerMessages.PackageManagement.Installer.Error.INVALID_TILESET_PATH_NULL, _namespace, ex, BasicDebugLogger.DebugErrorType.Error); throw; } } string oldFilePath = fromDirectory + "\\" + file.Path; Exception outEx; if (Helper.CopyFileSafely(oldFilePath, newFile, true, _namespace, out outEx, new CopyFileLogMessages(copyFileFailed: LoggerMessages.PackageManagement.Installer.Error.TilesetUnableToCopy)) != CopyFileResult.Success) { throw outEx; } file.Path = Helper.GetRelativePath(newFile, rootDir); //file.InstallationStatus = RMPackObject.InstallStatus.Installed; } } }
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 InvalidTilesetFileException(string message, WhichInvalid whichInvalid, RMTilesetGroup parent) : base(message) { TypeOfIssue = whichInvalid; Parent = parent; }