Example #1
0
        private void Tick(object sender, TickEventArgs e)
        {
#if Release
            try
            {
#endif
            if (first)
            {
                new Thread(StartThread).Start();
                physicsTimer.Enabled = false;
                first = false;
                demo.AddObjects();
                lastTime = DateTime.Now;
            }
            else
            {
                physicsTimer.EndUpdate();
            }
            MeleeSound.PlaySounds();

            DrawGLScene();

            physicsTimer.BeginUpdate();

            Video.GLSwapBuffers();

#if Release
        }

        catch (Exception ex)
        {
            ErrorBox.DisplayError(ex);
        }
#endif
        }
        public static void Load()
        {
#if Release
            try
            {
#endif

            //Music.Volume = (3 / 4) * Music.Volume;
            DirectoryInfo soundDir = new DirectoryInfo(SuperMeleePaths.MusicDir);
            foreach (FileInfo info in soundDir.GetFiles("*.ogg"))
            {
                string name  = Path.GetFileNameWithoutExtension(info.Name);
                Music  music = new Music(info.FullName);
                musics.Add(name, music);
            }
            foreach (FileInfo info in soundDir.GetFiles("*.mod"))
            {
                string name  = Path.GetFileNameWithoutExtension(info.Name);
                Music  music = new Music(info.FullName);
                musics.Add(name, music);
            }
            DefaultMusic = "Battle";
            Music.EnableMusicFinishedCallback();

#if Release
        }

        catch (Exception ex)
        {
            ErrorBox.DisplayError(ex);
        }
#endif
        }
Example #3
0
        /// <summary>
        /// Initializes methods common to all NeHe lessons
        /// </summary>
        protected void Initialize(BaseDisplayDemo demo)
        {
#if Release
            try
            {
#endif
            //Mixer.Open(22050, AudioFormat.Default, 2, 2048);



            // Sets keyboard events
            // Sets the ticker to update OpenGL Context
            Events.Tick += new TickEventHandler(this.Tick);
            // Sets the resize window event
            Events.VideoResize += new VideoResizeEventHandler(Events_VideoResize);
            Events.Quit        += new QuitEventHandler(Events_Quit);
            // Set the Frames per second.
            Events.Fps = 60;
            targetDT   = (float)1 / (float)Events.Fps;
            // Creates SDL.NET Surface to hold an OpenGL scene
            //screen = Video.SetVideoModeWindowOpenGL(width, height, true);
            //Environment.
            //screen = Video.SetVideoModeOpenGL(width, height, 16);
            screen = Video.SetVideoModeWindowOpenGL(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width / 2, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height / 2, true);

            //Video.WindowIcon();
            // Video.
            //Video.SetVideoModeWindowOpenGL(Video.Screen.Width,Video.Screen.Height,true);
            //Tao.Sdl.Sdl.SDL_WM_IconifyWindow();


            // Sets Window icon and title
            this.WindowAttributes();

            MeleeMusic.PlayDefault();
            this.demo    = demo;
            physicsTimer = new PhysicsTimer(Update2, 1 / (float)Events.Fps, 3);
            physicsTimer.Start(false);

#if Release
        }
        catch (Exception ex)
        {
            ErrorBox.DisplayError(ex);
            throw;
        }
#endif
        }
Example #4
0
        //		private void Resize (object sender, VideoResizeEventArgs e)
        //		{
        //			screen = Video.SetVideoModeWindowOpenGL(e.Width, e.Height, true);
        //			if (screen.Width != e.Width || screen.Height != e.Height)
        //			{
        //				//this.InitGL();
        //				this.Reshape();
        //			}
        //		}


        /// <summary>
        /// Starts lesson
        /// </summary>
        public void Run()
        {
#if Release
            try
            {
#endif
            Reshape();
            InitGL();
            Thread.CurrentThread.Priority = ThreadPriority.Highest;
            Events.Run();
#if Release
        }

        catch (Exception ex)
        {
            ErrorBox.DisplayError(ex);
        }
#endif
        }
Example #5
0
        private void Integrate(object dt)
        {
            FileIOPermission permission = new FileIOPermission(PermissionState.Unrestricted);

            permission.AllFiles = FileIOPermissionAccess.AllAccess;
            permission.Deny();
#if Release
            try
            {
#endif
            Integrate((float)dt);
#if Release
        }
        catch (ThreadAbortException) { Console.WriteLine("ThreadAbortException in Integrate"); }
        catch (ThreadInterruptedException) { Console.WriteLine("ThreadInterruptedException in Integrate"); }
        catch (Exception ex)
        {
            ErrorBox.DisplayError(ex);
        }
#endif
        }
Example #6
0
 public void Error(string text)
 {
     ErrorDisplay.DisplayError(text);
 }
Example #7
0
        public static List <ShipLoader> GetShips()
        {
            List <ShipLoader> returnvalues = new List <ShipLoader>();

            DirectoryInfo info = new DirectoryInfo(SuperMeleePaths.ShipDir);

            if (info.Exists)
            {
                string AssemblyInfoPath = Path.GetTempFileName();
                File.WriteAllLines(AssemblyInfoPath, AssemblyInfo);
                CompilerParameters parameters = new CompilerParameters(assemblyNames);
                foreach (DirectoryInfo dirinfo in info.GetDirectories())
                {
                    FileInfo[] fileinfos = dirinfo.GetFiles("*.cs");
                    if (fileinfos.Length > 0)
                    {
#if Release
                        try
                        {
#endif
                        string sourceFile = fileinfos[0].FullName;
                        string directory  = dirinfo.FullName + Path.DirectorySeparatorChar;
                        string shipsName  = dirinfo.Name.Replace(Path.DirectorySeparatorChar, '.');

                        string infoFile   = directory + "CompiledInfo.txt";
                        string binFile    = directory + shipsName + ".dll";
                        string errorFile  = directory + "CompilerErrors.txt";
                        string configFile = directory + ShipLoader.ConfigFileName;

                        /*string infoFile = Path.ChangeExtension(sourceFile, ".CompiledInfo.txt");
                         * string binFile = Path.ChangeExtension(sourceFile, ".dll");
                         * string errorFile = Path.ChangeExtension(sourceFile, ".Error.txt");*/



                        if (File.Exists(infoFile))
                        {
                            Console.WriteLine("Loading " + shipsName);
                            try
                            {
                                string[] CompiledInfo = File.ReadAllLines(infoFile);
                                if (CompiledInfo.Length > 0 &&
                                    File.Exists(binFile) &&
                                    CompiledInfo[0] == GetHash(sourceFile, binFile))
                                {
                                    ShipLoader loader = GetShipFromAssembly(Assembly.LoadFile(binFile));
                                    loader.ShipDirectory = dirinfo.FullName + Path.DirectorySeparatorChar;
                                    returnvalues.Add(loader);
                                    continue;
                                }
                            }
                            catch (UnauthorizedAccessException) { }
                            Console.WriteLine("Loading Failed");
                            File.Delete(infoFile);
                        }
                        if (CheckNamespaceUse(sourceFile, errorFile))
                        {
                            Console.WriteLine("Compiling " + shipsName);
                            parameters.OutputAssembly = binFile;
                            if (File.Exists(binFile))
                            {
                                File.Delete(binFile);
                            }
                            if (File.Exists(configFile))
                            {
                                File.Delete(configFile);
                            }
                            string[] paths = new string[fileinfos.Length + 1];
                            paths[0] = AssemblyInfoPath;
                            for (int pos = 0; pos < fileinfos.Length; ++pos)
                            {
                                paths[pos + 1] = fileinfos[pos].FullName;
                            }
                            CompilerResults results = provider.CompileAssemblyFromFile(parameters, paths);
                            if (results.Errors.Count > 0)
                            {
                                using (StreamWriter writer = new StreamWriter(errorFile))
                                {
                                    foreach (CompilerError error in results.Errors)
                                    {
                                        writer.WriteLine("{0} {1} Description: {2} File: {3} Line: {4} Column: {5}",
                                                         (error.IsWarning) ? ("Warning") : ("Error"),
                                                         error.ErrorNumber,
                                                         error.ErrorText,
                                                         error.FileName,
                                                         error.Line,
                                                         error.Column);
                                    }
                                }
                                continue;
                            }
                            ShipLoader loader = GetShipFromAssembly(results.CompiledAssembly);
                            loader.ShipDirectory = dirinfo.FullName + Path.DirectorySeparatorChar;
                            returnvalues.Add(loader);

                            File.WriteAllLines(infoFile, new string[] { GetHash(sourceFile, binFile) });
                            File.SetAttributes(infoFile, File.GetAttributes(infoFile) | FileAttributes.Hidden);
                            File.SetAttributes(binFile, File.GetAttributes(binFile) | FileAttributes.Hidden);
                            if (File.Exists(errorFile))
                            {
                                File.Delete(errorFile);
                            }
                        }
#if Release
                    }
                    catch (Exception ex)
                    {
                        ErrorBox.DisplayError(ex);
                    }
#endif
                    }
                }
                File.Delete(AssemblyInfoPath);
            }
            return(returnvalues);
        }