示例#1
0
        public void OnExecute()
        {
            if (Debug)
            {
                Program.debug = true;
            }
            if (!string.IsNullOrEmpty(FileType))
            {
                AbstractFileParser selclass = null;
                switch (FileType.ToLower())
                {
                case "cz0":
                    selclass = new CZ0Parser();
                    break;

                case "cz1":
                    selclass = new CZ1Parser();
                    break;

                case "cz1_4bit":
                    selclass = new CZ1_4bitParser();
                    break;

                case "cz2":
                    selclass = new CZ2Parser();
                    break;

                case "cz3":
                    selclass = new CZ3Parser();
                    break;

                case "cz4":
                    selclass = new CZ4Parser();
                    break;

                case "dat":
                    selclass = new DatParser();
                    break;

                case "pak":
                    if (!string.IsNullOrEmpty(PakCoding))
                    {
                        selclass = new PAKManager(PakCoding);
                    }
                    else
                    {
                        selclass = new PAKManager();
                    }

                    break;

                case "psb":
                    selclass = new PsbScript();
                    break;

                case "info":
                    selclass = new FontInfoParser();
                    break;

                case "scr":
                    if (!FormatOld && !FormatLua && !FormatLuaE && !FormatJson)
                    {
                        FormatJson = true;
                    }
                    if (FormatLua && FormatLuaE)
                    {
                        FormatLuaE = false;     // 优先能导入
                    }
                    if (!string.IsNullOrEmpty(CustomOpcodePath))
                    {
                        selclass = new ScriptParser(GameScript.CUSTOM, CustomOpcodePath,
                                                    FormatOld, FormatLua, FormatLuaE, FormatJson, OnlyText);
                    }
                    else if (!string.IsNullOrEmpty(OpcodePath))
                    {
                        if (OpcodePath != "CUSTOM")
                        {
                            selclass = new ScriptParser((GameScript)Enum.Parse(typeof(GameScript), OpcodePath, true), "",
                                                        FormatOld, FormatLua, FormatLuaE, FormatJson, OnlyText);
                        }
                    }
                    else
                    {
                        throw new Exception("Need Input OpcodePath or CustomOpcodePath!");
                    }

                    if (!string.IsNullOrEmpty(TBLFile))
                    {
                        CustomEncoding.LoadTbl(TBLFile);
                    }
                    break;

                default:
                    break;
                }

                if (ParserMode.ToLower() == "import" || ParserMode.ToLower() == "i")
                {
                    if (File.Exists(FileName))
                    {
                        // 是文件
                        selclass.FileImport(FileName, OutFileName);
                    }
                    else if (Directory.Exists(FileName))
                    {
                        // 是文件夹
                        string outFolder = OutFileName;
                        if (!Directory.Exists(OutFileName))
                        {
                            Console.WriteLine("输出目录不是文件夹,默认输出目录已更改");
                            outFolder = Path.GetDirectoryName(OutFileName);
                        }
                        var files = Directory.GetFiles(FileName, "*");
                        foreach (var file in files)
                        {
                            selclass.FileImport(file, Path.Combine(outFolder, Path.GetFileNameWithoutExtension(file)));
                        }
                    }
                }
                else if (ParserMode.ToLower() == "export" || ParserMode.ToLower() == "e")
                {
                    if (File.Exists(FileName))
                    {
                        // 是文件
                        selclass.FileExport(FileName, OutFileName);
                    }
                    else if (Directory.Exists(FileName))
                    {
                        // 是文件夹
                        string outFolder = OutFileName;
                        if (!Directory.Exists(OutFileName))
                        {
                            Console.WriteLine("输出目录不是文件夹,默认输出目录已更改");
                            outFolder = Path.GetDirectoryName(OutFileName);
                        }
                        var files = Directory.GetFiles(FileName, "*");
                        foreach (var file in files)
                        {
                            selclass.FileExport(file, Path.Combine(outFolder, Path.GetFileNameWithoutExtension(file)));
                        }
                    }
                }
                else
                {
                    throw new Exception("Need Input ParserMode!");
                }
            }


            if (GameList)
            {
                Console.WriteLine(@"Supported Games:
Opcode name    Game name & Platform

SP             《Summer Pocket》Nintendo Switch
CL             《Clannad》Nintendo Switch
TAWL           《Tomoyo After Its a Wonderful Life CS Edition》Nintendo Switch
FLOWERS        《Flowers - Shiki》
ISALND         《ISLAND》Psvita

CUSTOM          Read custom Opcode file. Path: OPCODE/{CUSTOM}.txt
");
            }
            if (OpcodeHelp)
            {
                Console.WriteLine(@"
        Byte,
        Byte2,
        Byte3,
        Byte4,
        UInt16,
        UInt32,
        StringUnicode,
        StringSJIS,
        StringUTF8,
        LenStringUnicode,
        LenStringSJIS,
        Opcode,
        Skip
待完善...
");
            }
        }
        public void OnExecute()
        {
            if (Debug)
            {
                Program.debug = true;
            }
            if (!string.IsNullOrEmpty(FileType))
            {
                AbstractFileParser selclass = null;
                switch (FileType.ToLower())
                {
                case "cz0":
                    selclass = new CZ0Parser();
                    break;

                case "cz1":
                    selclass = new CZ1Parser();
                    break;

                case "cz1_4bit":
                    selclass = new CZ1_4bitParser();
                    break;

                case "cz2":
                    selclass = new CZ2Parser();
                    break;

                case "cz3":
                    selclass = new CZ3Parser();
                    break;

                case "cz4":
                    selclass = new CZ4Parser();
                    break;

                case "dat":
                    selclass = new DatParser();
                    break;

                case "pak":
                    if (!string.IsNullOrEmpty(PakCoding))
                    {
                        selclass = new PAKManager(PakCoding);
                    }
                    else
                    {
                        selclass = new PAKManager();
                    }

                    break;

                case "psb":
                    selclass = new PsbScript();
                    break;

                case "info":
                    selclass = new FontInfoParser();
                    break;

                case "scr":
                    if (!string.IsNullOrEmpty(CustomOpcodePath))
                    {
                        selclass = new ScriptParser(GameScript.CUSTOM, CustomOpcodePath);
                    }
                    else if (!string.IsNullOrEmpty(OpcodePath))
                    {
                        if (OpcodePath != "CUSTOM")
                        {
                            selclass = new ScriptParser((GameScript)Enum.Parse(typeof(GameScript), OpcodePath, true));
                        }
                    }
                    else
                    {
                        throw new Exception("Need Input OpcodePath or CustomOpcodePath!");
                    }

                    if (!string.IsNullOrEmpty(TBLFile))
                    {
                        CustomEncoding.LoadTbl(TBLFile);
                    }
                    break;

                default:
                    break;
                }

                if (ParserMode.ToLower() == "import" || ParserMode.ToLower() == "i")
                {
                    selclass.FileImport(FileName);
                }
                else if (ParserMode.ToLower() == "export" || ParserMode.ToLower() == "e")
                {
                    selclass.FileExport(FileName);
                }
                else
                {
                    throw new Exception("Need Input ParserMode!");
                }
            }


            if (GameList)
            {
                Console.WriteLine(@"Supported Games:
Opcode name    Game name & Platform

SP             《Summer Pocket》Nintendo Switch
CL             《Clannad》Nintendo Switch
TAWL           《Tomoyo After Its a Wonderful Life CS Edition》Nintendo Switch
FLOWERS        《Flowers - Shiki》
ISALND         《ISLAND》Psvita

CUSTOM          Read custom Opcode file. Path: OPCODE/{CUSTOM}.txt
");
            }
            if (OpcodeHelp)
            {
                Console.WriteLine(@"
        Byte,
        Byte2,
        Byte3,
        Byte4,
        UInt16,
        UInt32,
        StringUnicode,
        StringSJIS,
        StringUTF8,
        LenStringUnicode,
        LenStringSJIS,
        Opcode,
        Skip
待完善...
");
            }
        }