static void DoSome(string[] args) { ArgumentsWork argwrk = new ArgumentsWork(args); if (argwrk.OpenedFile != "") { ObjectFile file = null; if (argwrk.OpenedArgument.ToLower() == "/stringlist") { file = new ObjectFile(Path.GetFileName(argwrk.OpenedFile), new PersonaEditorLib.FileStructure.Text.StringList(argwrk.OpenedFile, Static.OldEncoding()) { DestEncoding = Static.NewEncoding() }); } else { file = PersonaEditorLib.Utilities.PersonaFile.OpenFile(Path.GetFileName(argwrk.OpenedFile), File.ReadAllBytes(argwrk.OpenedFile), PersonaEditorLib.Utilities.PersonaFile.GetFileType(argwrk.OpenedFile)); } if (file.Object != null) { foreach (var command in argwrk.ArgumentList) { Action <ObjectFile, string, string, Parameters> action = null; if (command.Command == CommandType.Export) { if (command.Type == CommandSubType.Image) { action = ExportImage; } else if (command.Type == CommandSubType.Table) { action = ExportTable; } else if (command.Type == CommandSubType.All) { ExportAll(file, argwrk.OpenedFileDir); } else if (command.Type == CommandSubType.PTP) { action = ExportPTP; } else if (command.Type == CommandSubType.Text) { action = ExportText; } else { action = ExportByType; } } else if (command.Command == CommandType.Import) { if (command.Type == CommandSubType.Image) { action = ImportImage; } else if (command.Type == CommandSubType.Table) { action = ImportTable; } else if (command.Type == CommandSubType.All) { ImportAll(file, argwrk.OpenedFileDir); } else if (command.Type == CommandSubType.PTP) { action = ImportPTP; } else if (command.Type == CommandSubType.Text) { action = ImportText; } } else if (command.Command == CommandType.Save) { SaveFile(file, argwrk.OpenedFileDir, command.Value); } if (action != null) { SubFileAction(action, file, command.Value, argwrk.OpenedFileDir, command.Parameters); } } } } }
static bool Do(string[] args) { try { IConsoleWork work; ArgumentsWork argwrk = new ArgumentsWork(args); if (argwrk.FileType == "-FNT") { work = new FNTConsole(argwrk.FileSource, argwrk.Param); } else if (argwrk.FileType == "-TMX") { work = new TMXConsole(argwrk.FileSource, argwrk.Param); } else if (argwrk.FileType == "-PM1") { work = new PM1Console(argwrk.FileSource, argwrk.Param); } else if (argwrk.FileType == "-BF") { work = new BFConsole(argwrk.FileSource, argwrk.Param); } else if (argwrk.FileType == "-BMD") { work = new BMDConsole(argwrk.FileSource, argwrk.Param); } else if (argwrk.FileType == "-PTP") { work = new PTPConsole(argwrk.FileSource, argwrk.Param); } else if (argwrk.FileType == "-BIN") { work = new BINConsole(argwrk.FileSource, argwrk.Param); } else if (argwrk.FileType == "-BVP") { work = new BVPConsole(argwrk.FileSource, argwrk.Param); } else if (argwrk.FileType == "-TBL") { work = new TBLConsole(argwrk.FileSource, argwrk.Param); } else if (argwrk.FileType == "-TEXT") { work = new TEXTConsole(argwrk.FileSource, argwrk.Param); } else { return(false); } foreach (var command in argwrk.ArgumentList) { if (command.Command == CommandType.Export) { work.Export(command.Type, command.Parameters, command.Value); } else if (command.Command == CommandType.Import) { work.Import(command.Type, command.Parameters, command.Value); } else if (command.Command == CommandType.Save) { work.Save(command.Parameters, command.Value); } } return(true); } catch (Exception ex) { Logging.Write("D", ex); return(false); } }