Beispiel #1
0
        private void FormMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            try
            {
                this.SaveLayout();
                RegistryLoader.SaveValue(Name, "play", soundPlayerBar1.Playing);
                RegistryLoader.SaveValue(Name, "granularity", menuSizeSetting.Text);
                RegistryLoader.SaveValue(Name, "time", soundPlayerBar1.Position);
                RegistryLoader.SaveValue(Name, "showFPS", menuFps.Checked);
                RegistryLoader.SaveValue(Name, "compact", menuCompact.Checked);

                multiGraph.SaveLayout();
                log.SaveLayout();
                camera.SaveLayout();
                // rename old
                DefaultFiles.RenameAutoSaveDemoFile();
                // save new
                DemoLoader.SaveToFile(demo, DefaultFiles.GetAutoSaveDemoFilePath());
                demo.Dispose();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #2
0
        private MyApplication()
        {
            gameWindow.KeyDown     += GameWindow_KeyDown;
            gameWindow.RenderFrame += game_RenderFrame;
            visualContext           = new VisualContext();
            var textures = new Textures(visualContext);
            var shaders  = new Shaders(NewShaderFile);

            demo = new DemoModel(visualContext, shaders, textures, false);
            demo.TimeSource.TimeFinished += () => gameWindow.Close();

            var arguments = Environment.GetCommandLineArgs();

            if (3 > arguments.Length)
            {
                MessageBox.Show("DemoRecorder <configfile> <saveDirectory> [<resX> <resY> <frameRate>]"
                                + Environment.NewLine
                                + " Please give the demo config file name as application parameter followed by the render buffer resolution.");
                gameWindow.Close();
            }
            bufferWidth  = gameWindow.Width;
            bufferHeight = gameWindow.Height;
            try
            {
                bufferWidth  = int.Parse(arguments.ElementAt(3));
                bufferHeight = int.Parse(arguments.ElementAt(4));
            }
            catch
            {
                bufferWidth  = gameWindow.Width;
                bufferHeight = gameWindow.Height;
            }
            try
            {
                frameRate = int.Parse(arguments.ElementAt(5));
            }
            catch
            {
                frameRate = 25;
            }
            try
            {
                DemoLoader.LoadFromFile(demo, arguments.ElementAt(1));
                saveDirectory  = Directory.CreateDirectory(arguments.ElementAt(2)).FullName;
                saveDirectory += Path.DirectorySeparatorChar;
                saveDirectory += DateTime.Now.ToString("yyyyMMdd HHmmss");
                saveDirectory += Path.DirectorySeparatorChar;
                Directory.CreateDirectory(saveDirectory);
                fileNumber = 0;
            }
            catch (Exception e)
            {
                MessageBox.Show("Error loading demo '" + arguments.ElementAt(1) + '"'
                                + Environment.NewLine + e.Message);
                gameWindow.Close();
            }
        }
Beispiel #3
0
 private void LoadDemo(string fileName)
 {
     try
     {
         camera.Reset();
         DemoLoader.LoadFromFile(demo, fileName, (obj, args) => log.Append(args.Message));
     }
     catch (Exception e)
     {
         log.Append("No valid demo file found with exception '" + e.Message + "'");
     };
 }
Beispiel #4
0
        private MyApplication()
        {
            gameWindow.Load        += GameWindow_Load;
            gameWindow.KeyDown     += GameWindow_KeyDown;
            gameWindow.RenderFrame += game_RenderFrame;
            visualContext           = new VisualContext();
            var textures = new Textures(visualContext);
            var shaders  = new Shaders(NewShaderFile);

            demo = new DemoModel(visualContext, shaders, textures, false);
            demo.TimeSource.TimeFinished += () => gameWindow.Close();

            var arguments = Environment.GetCommandLineArgs();

            if (1 == arguments.Length)
            {
                MessageBox.Show("DemoPlayer <configfile> [<resX> <resY>]"
                                + Environment.NewLine
                                + " Please give the demo config file name you wish to play as application parameter followed by the render buffer resolution.");
                gameWindow.Close();
            }
            bufferWidth  = gameWindow.Width;
            bufferHeight = gameWindow.Height;
            try
            {
                bufferWidth  = int.Parse(arguments.ElementAt(2));
                bufferHeight = int.Parse(arguments.ElementAt(3));
            }
            catch
            {
                bufferWidth  = gameWindow.Width;
                bufferHeight = gameWindow.Height;
            }
            try
            {
                DemoLoader.LoadFromFile(demo, arguments.ElementAt(1));
            }
            catch (Exception e)
            {
                MessageBox.Show("Error loading demo '" + arguments.ElementAt(1) + '"'
                                + Environment.NewLine + e.Message);
                gameWindow.Close();
            }
        }
Beispiel #5
0
        public FormMain()
        {
            InitializeComponent();

            string demoFilter = DefaultFiles.GetDemoExtension() + " (*" + DefaultFiles.GetDemoExtension() + ")|*" + DefaultFiles.GetDemoExtension();

            menuSizeSetting.SelectedIndexChanged += (sender, e) => glControl.Invalidate();
            multiGraph.ChangedPosition           += (pos) => soundPlayerBar1.Position = pos;
            multiGraph.KeyDown += FormMain_KeyDown;
            camera.Redraw      += (position) => glControl.Invalidate();
            cameraWindowToolStripMenuItem.Click      += (s, e) => camera.Show();
            addCameraUniformsToolStripMenuItem.Click += (s, e) => camera.AddKeyFrames(demo.TimeSource.Position, demo.Uniforms);

            logToolStripMenuItem.Click      += (s, e) => log.Show();
            soundPlayerBar1.PositionChanged += (position) => glControl.Invalidate();
            soundPlayerBar1.PositionChanged += (position) => multiGraph.UpdatePosition(position);
            soundPlayerBar1.PositionChanged += (position) => camera.UpdateFromUniforms(demo.Uniforms, position);

            menuOnTop.CheckedChanged += (s, e) => TopMost = menuOnTop.Checked;
            menuHelp.Click           += (sender, e) => Dialogs.Help();
            menuLoad.Click           += (sender, e) => Dialogs.OpenFile(demoFilter
                                                                        , (fileName) => LoadDemo(fileName));
            menuSound.Click      += (sender, e) => Dialogs.OpenFile("sound (*.*)|*.*", (fileName) => demo.TimeSource.Load(DemoTimeSource.FromMediaFile(fileName), fileName));
            MenuShaderAdd.Click  += (sender, e) => Dialogs.OpenFile("glsl (*.glsl)|*.glsl", (fileName) => AddShader(fileName));
            MenuTextureAdd.Click += (sender, e) => Dialogs.OpenFile("texture (*.*)|*.*", (fileName) => demo.Textures.AddUpdate(fileName));
            menuSave.Click       += (sender, e) => Dialogs.SaveFile(demoFilter, (fileName) =>
            {
                try
                {
                    DemoLoader.SaveToFile(demo, fileName);
                }
                catch (Exception ex)
                {
                    log.Append(ex.Message);
                }
            });
            menuScreenshot.Click += (sender, e) => Dialogs.SaveFile("png (*.png)|*.png", (fileName) => { glControl.Invalidate(); demo.SaveBuffer(fileName); });

            KeyDown += (sender, e) => { camera.KeyChange(e.KeyCode, true); };
            KeyUp   += (sender, e) => { camera.KeyChange(e.KeyCode, false); };
        }