Exemple #1
0
        private static void initialize()
        {
            //Figure out the program directory
            ProgramDirectory = Application.ExecutablePath.Remove(Application.ExecutablePath.IndexOf(Path.GetFileName(Application.ExecutablePath)));

            //Make sure the recent project list is valid
            InitRecentProjects();

            //Load the plugins
            Ogmo.PluginLoader = new PluginLoader(Properties.Settings.Default.PluginPath);

            //The levels holder
            Levels = new List<Level>();
            CurrentLevelIndex = -1;

            //The windows
            MainWindow = new MainWindow();
            MainWindow.Shown += new EventHandler(MainWindow_Shown);
            LayersWindow = new LayersWindow();
            ToolsWindow = new ToolsWindow();
            TilePaletteWindow = new TilePaletteWindow();
            EntitiesWindow = new EntitiesWindow();
            EntitySelectionWindow = new EntitySelectionWindow();

            LayersWindow.Show(MainWindow);
            ToolsWindow.Show(MainWindow);
            TilePaletteWindow.Show(MainWindow);
            EntitiesWindow.Show(MainWindow);
            EntitySelectionWindow.Show(MainWindow);
            LayersWindow.EditorVisible = ToolsWindow.EditorVisible = TilePaletteWindow.EditorVisible = EntitiesWindow.EditorVisible = EntitySelectionWindow.EditorVisible = false;

            //Set up graphics stuff
            Parameters = new PresentationParameters();
            Parameters.BackBufferWidth = Math.Max(Ogmo.MainWindow.ClientSize.Width, 1);
            Parameters.BackBufferHeight = Math.Max(Ogmo.MainWindow.ClientSize.Height, 1);
            Parameters.BackBufferFormat = SurfaceFormat.Color;
            Parameters.DepthStencilFormat = DepthFormat.Depth24;
            Parameters.DeviceWindowHandle = Ogmo.MainWindow.Handle;
            Parameters.PresentationInterval = PresentInterval.Immediate;
            Parameters.IsFullScreen = false;
            GraphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, GraphicsProfile.Reach, Parameters);
            EditorDraw = new EditorDraw(GraphicsDevice);

            //Add the exit event
            Application.ApplicationExit += onApplicationExit;
        }