Exemplo n.º 1
0
        [STAThread] //for drag and drop :|
        static void Main(string[] args)
        {
#if DEBUG
            //   IntPtr stdHandle = GetStdHandle(STD_OUTPUT_HANDLE);
            //    SafeFileHandle safeFileHandle = new SafeFileHandle(stdHandle, true);
            //   FileStream fs = new FileStream(stdHandle, FileAccess.Write);
            //   StreamWriter sw = new StreamWriter(fs);
            //   Console.SetOut(sw);           
            //AttachConsole(ATTACH_PARENT_PROCESS);
            consoleAlloc = AllocConsole(); //allocate anyway if DEBUG defined
            Console.Title = "Pulse|Debug";
            Console.WriteLine("Running in Debug mode! All console output will be shown");
#endif

            if (args.Length > 0)
            {
                if (args[0].Equals("/debug") && !consoleAlloc)
                {
                    consoleAlloc = AllocConsole();
                    Console.Title = "Pulse|Debug";
                    Console.WriteLine("Running in Debug mode! All console output will be shown");
                }
                else
                {
                    try
                    {
                        string location = new DirectoryInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).Parent.FullName;
                        Console.WriteLine(location);
                        Console.ReadKey();
                        string songFolder = location + "\\songs";
                        ZipFile zf = new ZipFile(args[0]);
                        if (!Directory.Exists(songFolder))
                        {
                            Directory.CreateDirectory(songFolder);
                        }

                        foreach (ZipEntry ze in zf)
                        {
                            ze.Extract(songFolder, ExtractExistingFileAction.OverwriteSilently);
                        }
                    }
                    catch (Exception e)
                    {
                        System.Windows.Forms.MessageBox.Show("Error extracting " + e);
                    }
                    Environment.Exit(0);
                }
            }
            if (!Directory.Exists("replay"))
            {
                Directory.CreateDirectory("replay");
            }
            Config.load();
            //  SongLibrary.loadSongInfo();
            using (Game game = new Game())
            {
#if SENDFATAL

                try
                {
                    game.Run(120.0, Config.Fps);
                }
                catch (Exception e)
                {
                    if (game != null && game.active != null)
                    {
                        if (game.active is EditorScreen)
                        {
                            EditorScreen temp = (EditorScreen)game.active;
                            try
                            {
                                temp.saveMap();
                            }
                            catch
                            {

                            }
                        }
                    }
                    ErrorLog.log("User : "******"n/a") + " Fatal error: " + e.Message + "\n" + e.StackTrace);
                    System.Windows.Forms.MessageBox.Show("A fatal exception: \"" + e.Message + "\" has occured and been reported to the dev team");
                }
#endif

#if !SENDFATAL
                game.Run(120.0, Config.Fps); //want to show where exceptions are
#endif
            }
        }