コード例 #1
0
        private void do2DConvert()
        {
            string ac_path   = "";
            string ft_path   = "";
            string fs_path   = "";
            string ct_path   = "";
            bool   ask_user  = false;
            bool   skip_robs = false;

            if (File.Exists("config.txt"))
            {
                StreamReader sr = new StreamReader("config.txt");
                while (sr.Peek() > -1)
                {
                    var line  = sr.ReadLine();
                    var lines = line.Split('=');
                    if (lines[0] == "AC")
                    {
                        ac_path = lines[1];
                    }
                    if (lines[0] == "FT")
                    {
                        ft_path = lines[1];
                    }
                    if (lines[0] == "FS")
                    {
                        fs_path = lines[1];
                    }
                    if (lines[0] == "CT")
                    {
                        ct_path = lines[1];
                    }
                    if (lines[0] == "I_HAVE_CHANGED_THIS")
                    {
                        if (lines[1] == "TRUE")
                        {
                            ask_user = true;
                        }
                    }
                    if (lines[0] == "SKIP_2D")
                    {
                        if (lines[1] == "TRUE")
                        {
                            skip_robs = true;
                        }
                    }
                }
                sr.Close();
            }

            if ((ask_user) && (!skip_robs))
            {
                Logs.WriteLine("Sel2D Start");
                string[] filespl = System.IO.Directory.GetFiles(ft_path + @"\2d\", "spr_sel_pv*.farc", SearchOption.AllDirectories);
                string[] filesfs = { };
                string[] filesct = { };
                if (fs_path != "")
                {
                    filesfs = System.IO.Directory.GetFiles(fs_path + @"\2d\", "spr_sel_pv*.farc", SearchOption.AllDirectories);
                }
                if (ct_path != "")
                {
                    filesct = System.IO.Directory.GetFiles(ct_path + @"\2d\", "spr_sel_pv*.farc", SearchOption.AllDirectories);
                }
                string[] files = filespl.Concat(filesfs).ToArray().Concat(filesct).ToArray();


                foreach (var filePath in files)
                {
                    if ((!File.Exists(ac_path + @"\2d\" + Path.GetFileNameWithoutExtension(filePath) + ".farc")) && (Path.GetFileNameWithoutExtension(filePath) != "spr_sel_pv"))
                    {
                        Logs.WriteLine("Processing " + Path.GetFileNameWithoutExtension(filePath));
                        string farcpath = filePath;

                        var spriteset = new SpriteSet();

                        using (var farcArchive = BinaryFile.Load <FarcArchive>(farcpath))
                            using (var entryStream = farcArchive.Open(farcArchive.Entries.First(), EntryStreamMode.MemoryStream))
                                spriteset.Load(entryStream);

                        foreach (var i in spriteset.Sprites)
                        {
                            i.Field01 = 0x0000000D;
                        }


                        spriteset.Save("temp");

                        FarcArchive newfarc = new FarcArchive();
                        newfarc.Add(Path.GetFileNameWithoutExtension(filePath) + ".bin", "temp");
                        newfarc.Save(ac_path + "\\2d\\" + Path.GetFileName(filePath));
                    }
                    //newfarc.Dispose();
                }
            }
        }