Ejemplo n.º 1
0
        public static void Processor(bool json)
        {
            Console.Title = "A3DA Converter";
            Program.Choose(1, "a3da", out string[] fileNames);
            if (fileNames.Length < 1)
            {
                return;
            }

            bool mp = false;

            foreach (string file in fileNames)
            {
                if (file.EndsWith(".mp") || file.EndsWith(".json") || file.EndsWith(".farc"))
                {
                    mp = true; break;
                }
            }

            bool   a3dcOpt = false;
            Format format  = Format.NULL;
            string choose  = "";

            Console.Clear();
            Program.ConsoleDesign(true);
            Program.ConsoleDesign("          Choose type of format to export:");
            Program.ConsoleDesign(false);
            Program.ConsoleDesign("        Tip: A3DC Opt - A3DC Optimization");
            Program.ConsoleDesign("     WARNING! CHECK RESULTS AFTER CONVERTING    ");
            Program.ConsoleDesign(false);
            Program.ConsoleDesign("1. A3DA [DT/AC/F]");
            Program.ConsoleDesign("2. A3DC [DT/AC/F]");
            Program.ConsoleDesign("3. A3DC [DT/AC/F] (A3DC Opt)");
            Program.ConsoleDesign("4. A3DA [AFT/FT/M39]");
            Program.ConsoleDesign("5. A3DC [AFT/FT/M39]");
            Program.ConsoleDesign("6. A3DC [AFT/FT/M39] (A3DC Opt)");
            Program.ConsoleDesign("7. A3DC [F2]");
            Program.ConsoleDesign("8. A3DC [F2] (A3DC Opt)");
            Program.ConsoleDesign("9. A3DC [MGF]");
            Program.ConsoleDesign("A. A3DC [MGF] (A3DC Opt)");
            Program.ConsoleDesign("B. A3DC [X]");
            Program.ConsoleDesign("C. A3DC [X] (A3DC Opt)");
            Program.ConsoleDesign("D. A3DC [XHD]");
            Program.ConsoleDesign("E. A3DC [XHD] (A3DC Opt)");
            if (!mp)
            {
                Program.ConsoleDesign($"F. {(json ? "JSON" : "MsgPack")}");
            }
            Program.ConsoleDesign(false);
            Program.ConsoleDesign(true);
            Console.WriteLine();
            choose = Console.ReadLine().ToUpper();
            if (choose == "1")
            {
                format = Format.DT;
            }
            else if (choose == "2")
            {
                format = Format.F;
            }
            else if (choose == "3")
            {
                format = Format.F; a3dcOpt = true;
            }
            else if (choose == "4")
            {
                format = Format.AFT;
            }
            else if (choose == "5")
            {
                format = Format.AFT;
            }
            else if (choose == "6")
            {
                format = Format.AFT; a3dcOpt = true;
            }
            else if (choose == "7")
            {
                format = Format.F2;
            }
            else if (choose == "8")
            {
                format = Format.F2; a3dcOpt = true;
            }
            else if (choose == "9")
            {
                format = Format.MGF;
            }
            else if (choose == "A")
            {
                format = Format.MGF; a3dcOpt = true;
            }
            else if (choose == "B")
            {
                format = Format.X;
            }
            else if (choose == "C")
            {
                format = Format.X; a3dcOpt = true;
            }
            else if (choose == "D")
            {
                format = Format.XHD;
            }
            else if (choose == "E")
            {
                format = Format.XHD; a3dcOpt = true;
            }
            else if (choose == "F")
            {
                format = Format.NULL;
            }
            else
            {
                return;
            }

            int     state;
            string  filepath, ext;
            KKdA3DA a3da;
            KKdFARC farc;

            foreach (string file in fileNames)
            {
                filepath = Path.RemoveExtension(file);
                ext      = Path.GetExtension(file).ToLower();

                Console.Title = "A3DA Converter: " + Path.GetFileNameWithoutExtension(file);
                if (ext == ".farc")
                {
                    using (farc = new KKdFARC(file))
                        FARCProcessor(farc, choose, format, a3dcOpt);
                }
                else if (ext == ".a3da")
                {
                    using (a3da = new KKdA3DA(a3dcOpt))
                    {
                        state = a3da.A3DAReader(filepath);
                        if (state == 1)
                        {
                            if (choose == "F")
                            {
                                a3da.MsgPackWriter(filepath, json);
                            }
                            else
                            {
                                a3da.Head.Format = format;
                                File.WriteAllBytes(filepath + ".a3da", (choose == "1" ||
                                                                        choose == "4") ? a3da.A3DAWriter() : a3da.A3DCWriter());
                            }
                        }
                    }
                }
                else if (ext == ".mp" || ext == ".json")
                {
                    using (a3da = new KKdA3DA(a3dcOpt))
                    {
                        a3da.MsgPackReader(filepath, ext == ".json");
                        a3da.Head.Format = format;

                        File.WriteAllBytes(filepath + ".a3da", (choose == "1" ||
                                                                choose == "4") ? a3da.A3DAWriter() : a3da.A3DCWriter());
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public static void Processor(bool json)
        {
            Console.Title = "A3DA Converter";
            Program.Choose(1, "a3da", out string[] fileNames);
            if (fileNames.Length < 1)
            {
                return;
            }

            bool mp = false;

            foreach (string file in fileNames)
            {
                if (file.EndsWith(".mp") || file.EndsWith(".json") || file.EndsWith(".farc"))
                {
                    mp = true; break;
                }
            }

            Format format = Format.NULL;
            string choose = "";

            if (mp)
            {
                Console.Clear();
                Program.ConsoleDesign(true);
                Program.ConsoleDesign("          Choose type of format to export:");
                Program.ConsoleDesign(false);
                Program.ConsoleDesign("1. A3DA [DT/AC/F]");
                Program.ConsoleDesign("2. A3DC [DT/AC/F]");
                Program.ConsoleDesign("3. A3DA [AFT/FT] ");
                Program.ConsoleDesign("4. A3DC [AFT/FT] ");
                Program.ConsoleDesign("5. A3DC [F2]     ");
                Program.ConsoleDesign("6. A3DC [MGF]    ");
                Program.ConsoleDesign("7. A3DC [X]      ");
                Program.ConsoleDesign(false);
                Program.ConsoleDesign(true);
                Console.WriteLine();
                choose = Console.ReadLine();
                if (choose == "1")
                {
                    format = Format.DT;
                }
                else if (choose == "2")
                {
                    format = Format.F;
                }
                else if (choose == "3")
                {
                    format = Format.AFT;
                }
                else if (choose == "4")
                {
                    format = Format.AFT;
                }
                else if (choose == "5")
                {
                    format = Format.F2LE;
                }
                else if (choose == "6")
                {
                    format = Format.MGF;
                }
                else if (choose == "7")
                {
                    format = Format.X;
                }
                else
                {
                    return;
                }
            }

            int     state;
            string  filepath, ext;
            KKdA3DA a3da;

            foreach (string file in fileNames)
            {
                ext      = Path.GetExtension(file);
                filepath = file.Replace(ext, "");
                ext      = ext.ToLower();

                Console.Title = "A3DA Converter: " + Path.GetFileNameWithoutExtension(file);
                if (ext == ".farc")
                {
                    using (KKdFARC farc = new KKdFARC(file))
                        FARCProcessor(farc, choose, format);
                }
                else if (ext == ".a3da")
                {
                    using (a3da = new KKdA3DA(true))
                    {
                        state = a3da.A3DAReader(filepath);
                        if (state == 1)
                        {
                            a3da.MsgPackWriter(filepath, json);
                        }
                    }
                }
                else if (ext == ".mp" || ext == ".json")
                {
                    using (a3da = new KKdA3DA(true))
                    {
                        a3da.MsgPackReader(filepath, ext == ".json");
                        a3da.Data._.CompressF16 = format > Format.AFT && format <
                                                  Format.FT ? format == Format.MGF ? 2 : 1 : 0;
                        a3da.Head.Format = format;

                        File.WriteAllBytes(filepath + ".a3da", (choose != "1" &&
                                                                choose != "3") ? a3da.A3DCWriter() : a3da.A3DAWriter());
                    }
                }
            }
        }