Пример #1
0
        ////// まとめてテキスト化
        private void AllText_ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //parseディレクトリの読込
            StreamReader sr2 = new StreamReader(
                System.Environment.CurrentDirectory + "\\fighter_directory.ini", Encoding.GetEncoding("utf-8"));
            string parse = sr2.ReadLine();

            sr2.Close();

            StreamReader sr = new StreamReader(
                System.Environment.CurrentDirectory + "\\charlist.txt", Encoding.GetEncoding("utf-8")); //キャラ名リストopen

            string basePath = "";

            FolderBrowserDialog dlg = new FolderBrowserDialog();

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                basePath = dlg.SelectedPath;
                Console.WriteLine(basePath);
            }


            string prepath = parse; //fighterフォルダ

            while (sr.Peek() > -1)
            {
                string fightername = sr.ReadLine(); //キャラ名読み込み
                Console.WriteLine(fightername);

                string charpath = prepath + "\\" + fightername; //作業フォルダcharpath

                FileName = rootPath = String.Empty;
                _curFile = null;
                FileTree.Nodes.Clear();
                tabControl1.TabPages.Clear();
                isRoot = true;

                FileTree.BeginUpdate();

                if (System.IO.File.Exists(charpath + "\\game.bin")) //直下にgame.binがなければbodyまで下りる
                {
                    _curFighter = _manager.OpenFighter(charpath);
                }
                else
                {
                    _curFighter = _manager.OpenFighter(charpath + "\\script\\animcmd\\body");
                }

                TreeNode nScript = new ACMDNode()
                {
                    Text = "ACMD"
                };

                for (int i = 0; i < _curFighter.MotionTable.Count; i++)
                {
                    uint CRC = _curFighter.MotionTable[i];
                    nScript.Nodes.Add(new ScriptGroupNode(_curFighter, CRC)
                    {
                        Text = $"{i:X}-[{CRC:X8}]"
                    });
                }
                TreeNode nParams = new TreeNode("Params");
                TreeNode nMscsb  = new TreeNode("MSCSB");
                FileTree.Nodes.AddRange(new TreeNode[] { nScript, nParams, nMscsb });
                FileTree.EndUpdate();

                cboMode.SelectedIndex = (int)Runtime.WorkingEndian;
                cboMode.Enabled       = true;
                Runtime.isRoot        = true;
                Runtime.rootPath      = charpath;
                Runtime.Instance.Text = String.Format("Main Form - {0}", charpath);

                parseAnimations(parse + "\\" + fightername + "\\motion");

                // テキスト出力
                string filePath = fightername + "\\" + fightername + ".txt"; //bodyを開いている場合はこう

                DirectoryUtils.SafeCreateDirectory(basePath + "\\" + fightername);

                //2つのパスを結合する
                string absolutePath = System.IO.Path.Combine(basePath, filePath);
                //結果を表示する

                using (StreamWriter writer = new StreamWriter(absolutePath, false, Encoding.UTF8))
                {
                    if (isRoot)//isRoot=trueはfighter,falseはFile
                    {
                        writer.Write(_curFighter.Serialize());
                    }
                    else
                    {
                        writer.Write(_curFile.Serialize());
                    }
                }
                //bodyテキスト入力終了

                //weapon内全て書き出し

                FileName = rootPath = String.Empty;
                _curFile = null;
                FileTree.Nodes.Clear();
                tabControl1.TabPages.Clear();
                isRoot = true;

                FileTree.BeginUpdate();


                //char以下の直下のサブフォルダをすべて取得する
                //ワイルドカード"*"は、すべてのフォルダを意味する

                string weaponpath = charpath + "\\script\\animcmd\\weapon";

                if (System.IO.Directory.Exists(weaponpath))
                {
                    string[] subFolders = System.IO.Directory.GetDirectories(weaponpath, "*");

                    foreach (string preweapon in subFolders)

                    {
                        string weapon = System.IO.Path.GetFileName(preweapon);

                        FileName = rootPath = string.Empty;
                        tabControl1.TabPages.Clear();
                        FileTree.Nodes.Clear();
                        isRoot = false;

                        string weapongame = weaponpath + "\\" + weapon + "\\game.bin";

                        if ((_curFile = Manager.OpenFile(weapongame)) == null)
                        {
                            return;
                        }

                        FileTree.BeginUpdate();
                        TreeNode root = new ACMDNode()
                        {
                            Text = "ACMD"
                        };
                        for (int i = 0; i < _curFile.EventLists.Count; i++)
                        {
                            ACMDScript cml = _curFile.EventLists.Values[i];
                            root.Nodes.Add(new ScriptNode($"{i:X}-[{cml.AnimationCRC:X8}]", cml));
                        }
                        FileTree.Nodes.Add(root);
                        FileTree.EndUpdate();

                        cboMode.Enabled       = true;
                        cboMode.SelectedIndex = (int)Runtime.WorkingEndian;

                        FileName = weapongame;
                        Text     = $"Main Form - {FileName}";

                        // テキスト出力
                        string filePath2 = fightername + "\\" + weapon + ".txt"; //bodyを開いている場合はこう

                        //2つのパスを結合する
                        string absolutePath2 = System.IO.Path.Combine(basePath, filePath2);
                        //結果を表示する
                        // C:\dir\file.txt

                        using (StreamWriter writer = new StreamWriter(absolutePath2, false, Encoding.UTF8))
                        {
                            if (isRoot)//isRoot=trueはfighter,falseはFile
                            {
                                writer.Write(_curFighter.Serialize());
                            }
                            else
                            {
                                writer.Write(_curFile.Serialize());
                            }
                        }
                    }
                }
            }
            sr.Close();
        }
Пример #2
0
        public static void compile_acmd(string mlist, string output)
        {
            ACMDFile game       = new ACMDFile(),
                     effect     = new ACMDFile(),
                     sound      = new ACMDFile(),
                     expression = new ACMDFile();


            Directory.CreateDirectory(output);
            Console.WriteLine($">\tCompiling ACMD.. -> \"{output}\"");

            List <uint> hashes = new List <uint>();

            foreach (var line in File.ReadAllLines(mlist))
            {
                if (line.StartsWith("0x"))
                {
                    hashes.Add(Convert.ToUInt32(line.Substring(2), 16));
                }
                else
                {
                    hashes.Add(Crc32.Compute(line.ToLower()));
                }
            }

            foreach (var path in Directory.EnumerateFiles(Path.Combine(Path.GetDirectoryName(mlist), "animcmd"), "*", SearchOption.AllDirectories))
            {
                var defs = ACMDCompiler.CompileFile(path);
                foreach (var move in defs)
                {
#if DEBUG
                    Console.WriteLine($">\tCompiling {move.AnimName}..");
#endif

                    if (move["Main"] != null)
                    {
                        ACMDScript script = new ACMDScript(move.CRC);
                        script.Commands = move["Main"].Cast <ICommand>().ToList();
                        game.Scripts.Add(move.CRC, script);
                    }
                    if (move["Sound"] != null)
                    {
                        ACMDScript script = new ACMDScript(move.CRC);
                        script.Commands = move["Sound"].Cast <ICommand>().ToList();
                        sound.Scripts.Add(move.CRC, script);
                    }
                    if (move["Effect"] != null)
                    {
                        ACMDScript script = new ACMDScript(move.CRC);
                        script.Commands = move["Effect"].Cast <ICommand>().ToList();
                        effect.Scripts.Add(move.CRC, script);
                    }
                    if (move["Expression"] != null)
                    {
                        ACMDScript script = new ACMDScript(move.CRC);
                        script.Commands = move["Expression"].Cast <ICommand>().ToList();
                        expression.Scripts.Add(move.CRC, script);
                    }
                }
            }
            var table = new MTable(hashes, Endian);
            table.Export(Path.Combine(output, "motion.mtable"));
            game.Export(Path.Combine(output, "game.bin"), Endian);
            sound.Export(Path.Combine(output, "sound.bin"), Endian);
            effect.Export(Path.Combine(output, "effect.bin"), Endian);
            expression.Export(Path.Combine(output, "expression.bin"), Endian);
            Console.WriteLine(">\tFinished");
        }
Пример #3
0
        private static void write_movedef(ACMDScript game, ACMDScript effect, ACMDScript sound, ACMDScript expression, string animname, bool unlisted, string outdir)
        {
            using (StreamWriter writer = new StreamWriter(Path.Combine(outdir, $"{animname}.acm")))
            {
                writer.Write($"MoveDef {animname}");
                if (unlisted)
                {
                    writer.Write(" : Unlisted\n");
                }
                else
                {
                    writer.Write("\n");
                }
                writer.WriteLine("{");

                writer.WriteLine("\tMain()\n\t{");
                if (game != null)
                {
                    var commands = game.Deserialize().Split('\n');
                    foreach (string cmd in commands)
                    {
                        writer.WriteLine("\t\t" + cmd.TrimEnd());
                    }
                }
                writer.WriteLine("\t}\n");
                writer.WriteLine("\tEffect()\n\t{");
                if (effect != null)
                {
                    var commands = effect.Deserialize().Split('\n');
                    foreach (string cmd in commands)
                    {
                        writer.WriteLine("\t\t" + cmd.TrimEnd());
                    }
                }
                writer.WriteLine("\t}\n");
                writer.WriteLine("\tSound()\n\t{");
                if (sound != null)
                {
                    var commands = sound.Deserialize().Split('\n');
                    foreach (string cmd in commands)
                    {
                        writer.WriteLine("\t\t" + cmd.TrimEnd());
                    }
                }
                writer.WriteLine("\t}\n");
                writer.WriteLine("\tExpression()\n\t{");
                if (expression != null)
                {
                    var commands = expression.Deserialize().Split('\n');
                    foreach (string cmd in commands)
                    {
                        writer.WriteLine("\t\t" + cmd.TrimEnd());
                    }
                }
                writer.WriteLine("\t}\n");
                writer.WriteLine("}");
            }
        }
Пример #4
0
        public void HandleACMD(string animname)
        {
            //if (ACMDEditor.manualCrc)
            //    return;

            var crc = Crc32.Compute(animname.Replace(".omo", "").ToLower());

            scriptId = -1;

            if (MovesetManager == null)
            {
                ACMDScript = null;
                return;
            }

            // Try and set up the editor
            try
            {
                if (ACMDEditor.crc != crc)
                {
                    ACMDEditor.SetAnimation(crc);
                }
            }
            catch { }

            //Putting scriptId here to get intangibility of the animation, previous method only did it for animations that had game scripts
            if (MovesetManager.ScriptsHashList.Contains(crc))
            {
                scriptId = MovesetManager.ScriptsHashList.IndexOf(crc);
            }

            // Game script specific processing stuff below here
            if (!MovesetManager.Game.Scripts.ContainsKey(crc))
            {
                //Some characters don't have AttackS[3-4]S and use attacks[3-4] crc32 hash on scripts making forge unable to access the script, thus not visualizing these hitboxes
                //If the character doesn't have angled ftilt/fsmash
                if (animname == "AttackS4S.omo" || animname == "AttackS3S.omo")
                {
                    HandleACMD(animname.Replace("S.omo", ".omo"));
                    return;
                }
                //Ryu ftilts
                else if (animname == "AttackS3Ss.omo")
                {
                    HandleACMD(animname.Replace("Ss.omo", "s.omo"));
                    return;
                }
                else if (animname == "AttackS3Sw.omo")
                {
                    HandleACMD(animname.Replace("Sw.omo", "w.omo"));
                    return;
                }
                //Rapid Jab Finisher
                else if (animname == "AttackEnd.omo")
                {
                    HandleACMD("Attack100End.omo");
                    return;
                }
                else if (animname.Contains("ZeldaPhantomMainPhantom"))
                {
                    HandleACMD(animname.Replace("ZeldaPhantomMainPhantom", ""));
                    return;
                }
                else if (animname == "SpecialHi1.omo")
                {
                    HandleACMD("SpecialHi.omo");
                    return;
                }
                else if (animname == "SpecialAirHi1.omo")
                {
                    HandleACMD("SpecialAirHi.omo");
                    return;
                }
                else
                {
                    ACMDScript = null;
                    HitboxList.refresh();
                    VariableViewer.refresh();
                    return;
                }
            }

            //Console.WriteLine("Handling " + animname);
            ACMDScript acmdScript = (ACMDScript)MovesetManager.Game.Scripts[crc];

            // Only update the script if it changed
            if (acmdScript != null)
            {
                // If script wasn't set, or it was set and it changed, load the new script
                if (ACMDScript == null || (ACMDScript != null && ACMDScript.script != acmdScript))
                {
                    ACMDScript = new ForgeACMDScript(acmdScript);
                }
            }
            else
            {
                ACMDScript = null;
            }
        }
Пример #5
0
        public static void decompile_acmd(string mtable, string motionFolder, string output)
        {
            string script_dir = Path.Combine(output, "animcmd");

            Directory.CreateDirectory(script_dir);

            Console.WriteLine($">\tDecompile ACMD.. -> \"{script_dir}\"");

            Endianness endian = Endianness.Big;
            SortedList <string, ACMDFile> files = new SortedList <string, ACMDFile>();

            Dictionary <uint, string> animations = new Dictionary <uint, string>();

            if (!string.IsNullOrEmpty(motionFolder))
            {
                animations = ParseAnimations(motionFolder);
            }

            //string dir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            //if (mtable.Contains(Path.DirectorySeparatorChar))
            //    dir = Path.GetDirectoryName(mtable);
            string dir = Path.GetDirectoryName(mtable);

            foreach (string path in Directory.EnumerateFiles(dir, "*.bin"))
            {
                var file = new ACMDFile(path);
                files.Add(Path.GetFileNameWithoutExtension(path), file);
                endian = file.Endian;
            }
            var table  = new MTable(mtable, endian);
            var hashes = new List <uint>(table.ToList());

            write_mlist(table, animations, Path.Combine(output, "fighter.mlist"));

            // workaround for unlisted moves
            foreach (var f in files)
            {
                foreach (var s in f.Value.Scripts)
                {
                    if (!hashes.Contains(s.Key))
                    {
                        hashes.Add(s.Key);
                    }
                }
            }


            foreach (uint hash in hashes)
            {
                string animName = $"0x{hash:X8}";
                if (animations.ContainsKey(hash))
                {
                    animName = animations[hash];
                }

#if DEBUG
                Console.WriteLine($">\tDecompiling {animName}..");
#endif

                ACMDScript game = null, effect = null, sound = null, expression = null;
                if (files.ContainsKey("game") && files["game"].Scripts.ContainsKey(hash))
                {
                    game = (ACMDScript)files["game"].Scripts[hash];
                }
                if (files.ContainsKey("effect") && files["effect"].Scripts.ContainsKey(hash))
                {
                    effect = (ACMDScript)files["effect"].Scripts[hash];
                }
                if (files.ContainsKey("sound") && files["sound"].Scripts.ContainsKey(hash))
                {
                    sound = (ACMDScript)files["sound"].Scripts[hash];
                }
                if (files.ContainsKey("expression") && files["expression"].Scripts.ContainsKey(hash))
                {
                    expression = (ACMDScript)files["expression"].Scripts[hash];
                }

                write_movedef(game, effect, sound, expression, animName, !table.Contains(hash), script_dir);
            }
            Console.WriteLine(">\tFinished\n");
        }