Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            Console.CursorVisible = false;
            Console.WriteLine("/*");
            Console.WriteLine("****************************");
            Console.WriteLine("**         ModiMe         **");
            Console.WriteLine("** The new way to modify  **");
            Console.WriteLine("**       your games       **");
            Console.WriteLine("****************************");
            Console.WriteLine("~~~~~~~~ by pleoNeX ~~~~~~~~");
            Console.WriteLine("| Version: {0,-16}|", Assembly.GetExecutingAssembly().GetName().Version);
            Console.WriteLine("~~~~~ Good RomHacking! ~~~~~");
            Console.WriteLine("*/");
            Console.WriteLine();

            Stopwatch watch = new Stopwatch();
            watch.Start();

            int argIdx = 0;

            // Get global settings
            string[] inputNames = new string[0];
            for (; argIdx < args.Length; argIdx++) {
                if (args[argIdx].StartsWith("--set-input-names=")) {
                    inputNames = args[argIdx++].Substring(18).
                                 Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    break;
                }
            }

            // Import. Single file as input
            if (args.Length >= 5 && (args[argIdx] == "-i" || args[argIdx] == "-inew" || args[argIdx] == "-e")) {
                string xmlGame    = args[argIdx + 1];
                string xmlEdit    = args[argIdx + 2];
                string outputFile = (args[argIdx] == "-e") ? null : args[argIdx + 4];
                string inputFile  = args[argIdx + 3];
                string filename   = (inputNames.Length > 0) ? inputNames[0] : Path.GetFileName(inputFile);

                Console.WriteLine("Time to import!");
                Console.WriteLine("From {0}", inputFile);
                Console.WriteLine("To   {0}", outputFile);
                Console.WriteLine("Game specs:   {0}", xmlGame);
                Console.WriteLine("Modify specs: {0}", xmlEdit);
                Console.WriteLine("Now... Let's start!");
                Console.WriteLine();

                DataStream stream = new DataStream(inputFile, FileMode.Open, FileAccess.Read);
                GameFile mainFile = new GameFile(filename, stream);
                Worker worker = new Worker(xmlGame, xmlEdit, mainFile);

                bool result = false;
                if (args[argIdx] == "-i")
                    result = worker.Import();
                else if (args[argIdx] == "-inew")
                    result = worker.Import(File.GetLastWriteTime(inputFile));
                else if (args[argIdx] == "-e")
                    result = worker.Export();

                // On error
                if (!result) {
                    Console.WriteLine("Press a key to quit. . .");
                    Console.ReadKey(true);
                    return;
                }

                if (args[argIdx] == "-i" || args[argIdx] == "-inew")
                    worker.Write(outputFile);
            } else {
                ShowHelp();
            }

            watch.Stop();
            Console.WriteLine();
            Console.WriteLine("Done! It took: {0}", watch.Elapsed);
            Console.CursorVisible = true;
            #if !DEBUG
            Console.WriteLine("Press any key to quit . . .");
            Console.ReadKey(true);
            #endif
        }
Exemplo n.º 2
0
        private static void TestXmlImporting(string romPath)
        {
            DataStream romStream = new DataStream(romPath, FileMode.Open, FileAccess.Read);
            GameFile rom  = new GameFile(Path.GetFileName(romPath), romStream);

            XDocument xmlGame = XDocument.Load(Path.Combine(AppPath, "ExampleGame.xml"));
            XDocument xmlEdit = XDocument.Load(Path.Combine(AppPath, "ExampleEdition.xml"));

            Worker worker = new Worker(xmlGame, xmlEdit, rom);
            worker.Import();
            worker.Write("/lab/nds/projects/generic/test.nds");
        }