예제 #1
0
파일: Core.cs 프로젝트: Doom2fan/PokesYou
        private static void InitPatches()
        {
            // Don't need to try running the loop if the list is null or there aren't any files in it.
            if (options.PatchFiles == null || options.PatchFiles.Count < 1)
            {
                return;
            }

            for (int i = 0; i < options.PatchFiles.Count; i++)
            {
                ILumpContainer container = null;
                string         file      = options.PatchFiles [i];

                if (File.Exists(file))
                {
                    if (ZipLumpContainer.CheckContainer(file))
                    {
                        container = new ZipLumpContainer(file);
                    }
                }

                if (container != null)
                {
                    GConsole.WriteLine(" Adding \"{0}\", {1} lumps", file, container.Count);
                    LumpManager.AddContainer(container);
                }
                else
                {
                    throw new FatalError(string.Format("Could not identify patch {0}. Stopping execution.", file));
                }
            }
        }
예제 #2
0
파일: Core.cs 프로젝트: Doom2fan/PokesYou
        public static void Run(string [] args)
        {
            long   ticDelta = 0, renderDelta = 0;
            double fpsTime;

            if (closing)
            {
                return;
            }

            if (!CommandLine.Parser.Default.ParseArguments(args, options))
            {
                GConsole.WriteLine("Fatal error: There was an error reading the argument list");
                Console.Read();
                return;
            }

            try {
                /*Data.UDMF.UDMFParser udmfParser = new Data.UDMF.UDMFParser ();
                 * udmfParser.Setup ();
                 *
                 * using (var reader = new StreamReader ("TEXTMAP.txt"))
                 *  udmfParser.Parse (reader);
                 *
                 * Console.ReadKey ();
                 * return;*/

                GConsole.WriteLine("Core: Loading engine.PK3");
                ZipLumpContainer container  = null;
                string           engPK3File = Path.GetFullPath(Path.Combine(Constants.ProgDir, @"engine.pk3"));

                if (File.Exists(engPK3File))
                {
                    if (ZipLumpContainer.CheckContainer(engPK3File))
                    {
                        container = new ZipLumpContainer(engPK3File);
                    }
                }

                if (container == null)
                {
                    throw new FatalError(String.Format("Could not load engine.PK3. Stopping execution."));
                }

                GConsole.WriteLine(" engine.PK3, {0} lumps", container.Count);
                LumpManager.AddContainer(container);

                GConsole.WriteLine("Core: Initializing patches");
                InitPatches();

                GConsole.WriteLine("Core: Generating fixed-point Sin/Cos/Atan LUTs");
                FixedMath.GenerateTables();

                GConsole.WriteLine("Core: Initializing video");
                RenderEngine = OpenTkRenderer.Default;
                RenderEngine.Initialize(800, 600, false);
                RenderEngine.OnFocusChange += Renderer_OnFocusChange;

                GConsole.WriteLine("Core: Initializing playsim");
                Ticker = new Ticker();
                Ticker.Initialize();

                GConsole.WriteLine("Core: Starting game loop");
                ticClock.Reset();
                ticClock.Start();
                renderClock.Reset();
                renderClock.Start();

                while (true)
                {
                    if (closing)
                    {
                        return;
                    }

                    if (ticClock.ElapsedMilliseconds >= Constants.MsecsPerTic)
                    {
                        ticDelta = ticClock.ElapsedMilliseconds;
                        ticClock.Restart();
                        Ticker.Update(ticDelta);
                        Input.ClearTotals();
                    }
                    Input.UpdateInput();

                    renderDelta = renderClock.ElapsedMilliseconds;
                    renderClock.Restart();

                    fpsClock.Restart();
                    RenderEngine.Render(renderDelta);
                    fpsTime = fpsClock.ElapsedMilliseconds;

                    if (RenderEngine.IsUsable())
                    {
                        RenderEngine.WindowTitle = String.Format("Frame time: {0} ms", fpsTime);
                    }
                }
            } catch (FatalError err) {
                DisposeResources();
                GConsole.WriteLine(err.Message);
                Console.ReadKey();
            } catch (VeryFatalError err) {
                DisposeResources();
                GConsole.WriteLine(err.Message);
                Console.ReadKey();
            }
        }