예제 #1
0
        public override void FileExport(string path, string outpath = null)
        {
            ScriptReader reader = new ScriptReader(path, bytesToOpcodeDict, scriptVersion);

            Console.WriteLine("已加载脚本文件:{0},版本:{1}", Path.GetFileName(path), scriptVersion);
            Console.WriteLine("开始读取脚本...");
            reader.ReadScript_Clear();
            int position;
            int length;
            int i = 0;

            while (reader.ReadScript_CanStepRead())
            {
                Console.WriteLine("== {0:0000} ===================================", i);
                CodeLine code = reader.ReadScript_StepRead(out position, out length);
                Console.WriteLine("文件中位置:{0},长度:{1}", position, length);
                Console.WriteLine("{0}", code.ToStringAll());
                Console.WriteLine("按[E]编辑此Opcode参数列表,其他按键读取下一条");
                if (Console.ReadKey().Key == ConsoleKey.E)
                {
                    Console.WriteLine();
                    Console.WriteLine("按下指定[数字键]修改对应内容:");
                    string tipParamKey = "";
                    if (!hasOpcode)
                    {
                        tipParamKey += "[0]:opcode名,";
                    }

                    for (int j = 0; j < code.paramDatas.Count; j++)
                    {
                        tipParamKey += String.Format("[{0}]:参数{1}({2}),", j + 1, j + 1, code.paramDatas[j].valueString);
                    }
                    tipParamKey += "[Q]:返回";
                    Console.WriteLine(tipParamKey);
                    Console.Write("输入:");
                    ConsoleKey key = Console.ReadKey().Key;
                    Console.WriteLine();
                    List <DataType> types     = new List <DataType>();
                    string          setOpcode = code.opcode;
                    while (key != ConsoleKey.Q)
                    {
                        if (key == ConsoleKey.D0 || key == ConsoleKey.NumPad0)
                        {
                            Console.Write("设置opcode为:");
                            setOpcode = Console.ReadLine();
                            Console.WriteLine();
                        }
                        for (int j = 0; j < code.paramDatas.Count; j++)
                        {
                            if (key == ConsoleKey.D1 + j || key == ConsoleKey.NumPad1 + j)
                            {
                                Console.WriteLine("正在设置参数{0},当前类型:{1},值:{2},",
                                                  j + 1, code.paramDatas[j].type.ToString(), code.paramDatas[j].valueString);
                                Console.Write("设置为的类型:");
                                string type = Console.ReadLine();
                                types.Add((DataType)Enum.Parse(typeof(DataType), type, true));
                                Console.WriteLine();
                            }
                        }
                        Console.WriteLine(tipParamKey);
                        Console.Write("输入:");
                        key = Console.ReadKey().Key;
                        Console.WriteLine();
                    }

                    string temp = setOpcode + "(";
                    for (int k = 0; k < types.Count; k++)
                    {
                        temp += types[k].ToString();
                        if (k < types.Count - 1)
                        {
                            temp += ", ";
                        }
                    }
                    temp += ")";
                    Console.WriteLine();
                    Console.WriteLine("修改结果为:{0},即将重新读取此条...", temp);
                    bytesToOpcodeDict[code.opcodeIndex] = new ScriptOpcode(code.opcodeIndex, temp);
                    reader.ReadScript_Seek(-length);
                    i--;
                }

                i++;
                Console.WriteLine();
            }
        }
예제 #2
0
        public override void FileExport(string path, string outpath = null)
        {
            string outfilepath = outpath;

            if (FormatOld)
            {
                if (outfilepath == null)
                {
                    outfilepath = path + ".txt";
                }
                else if (FormatLua || FormatJson) // 同时导出两种格式,区分
                {
                    outfilepath += ".txt";
                }
                if (Path.GetExtension(outfilepath) != ".txt")
                {
                    outfilepath += ".txt";
                }
                Decompile(path, outfilepath);
            }
            if (FormatLua || FormatLuaE || FormatJson)
            {
                ScriptReader scriptReader = new ScriptReader(path, decompress_dic, ScriptVersion);
                scriptReader.ReadScript();
                outfilepath = outpath;
                if (FormatLua || FormatLuaE)
                {
                    if (outfilepath == null)
                    {
                        outfilepath = path + ".lua";
                    }
                    else if (FormatJson) // 同时导出两种格式,区分
                    {
                        outfilepath += ".lua";
                    }
                    if (Path.GetExtension(outfilepath) != ".lua")
                    {
                        outfilepath += ".lua";
                    }
                    scriptReader.SaveLua(outfilepath, !FormatLuaE);
                }
                outfilepath = outpath;
                if (FormatJson)
                {
                    if (outfilepath == null)
                    {
                        outfilepath = path + ".json";
                    }
                    else if (FormatLua) // 同时导出两种格式,区分
                    {
                        outfilepath += ".json";
                    }
                    if (Path.GetExtension(outfilepath) != ".json")
                    {
                        outfilepath += ".json";
                    }
                    scriptReader.SaveJson(outfilepath);
                }

                if (OnlyText != null)
                {
                    outfilepath += ".string.txt";
                    int mode = 0;
                    switch (OnlyText)
                    {
                    case "replace":
                        mode = 1;
                        break;

                    case "translate":
                        mode = 2;
                        break;

                    case "review":
                    default:
                        mode = 0;
                        break;
                    }
                    scriptReader.SaveString(outfilepath, mode);
                }
                scriptReader.Close();
            }
        }