Exemple #1
0
        public Editor()
        {
            InitializeComponent();

            ux_OpenProjectDialog.FileOk += (sender, args) => ReadProject(ux_OpenProjectDialog.FileName);

            ux_LayerList.ItemCheck += (sender, args) =>
            {
                var name = (string)ux_LayerList.Items[args.Index];
                if (name == "Collision")
                {
                    ux_LevelEditor.Level.CollisionLayer.Alpha = args.NewValue == CheckState.Checked ? 255f : 0f;
                }
                else
                {
                    ux_LevelEditor.Level.MapLayers.First(ml => ml.Name == name).Alpha = args.NewValue == CheckState.Checked ? 255f : 0f;
                }
            };
            ux_LayerList.SelectedIndexChanged += (sender, args) =>
            {
                var item = ux_LayerList.SelectedItem;
            };

            ux_LevelEntityList.ItemCheck += (sender, args) =>
            {
                var entity = (GameObject)ux_LevelEntityList.SelectedItem;

                if (entity != null)
                {
                    entity.IsAlive = args.NewValue == CheckState.Checked;
                }
            };

            ux_LevelEntityList.DoubleClick += UxLevelEntityListOnDoubleClick;

            ux_LevelEditor.MouseDown += UxLevelEditorOnMouseDown;
            ux_LevelEditor.MouseMove += UxLevelEditorOnMouseMove;
            ux_LevelEditor.KeyDown   += UxLevelEditorOnKeyDown;

            KeyDown += UxLevelEditorOnKeyDown;

            Project.OnCompleteLoadContentDirectory += (sender, args) =>
            {
                var project = (Project)sender;
                project.ContentDirectories.ForEach(ContentCacheManager.AddContentDirectory);

                // TODO: disk op... show progress bar?
                ContentCacheManager.LoadContent(new ContentManager(ServiceLocator.Apply()));
            };

            ux_LevelEditor.MouseWheel += UxLevelEditorOnMouseWheel;

            // setup status bar controls
            AddZoomControlsToStatusBar(ux_StatusBar);

            ux_ShowGrid.Enabled = false;
        }
Exemple #2
0
        public FragEngineGame()
        {
            // TODO: figure out a way to change this to use the IGraphicsDeviceManager interface
            // FIXME: this is f****d. In DIRECTX versions of this code, we _must_ instantiate GraphicsDeviceManager
            // in the initialize, but in OPENGL versions we have to do it here (check the code in Game.cs)
            // it throws an exception if GraphicsDevice is null???? WHAT THE F**K!?!?!?
            Graphics = new GraphicsDeviceManager(this);

            Content.RootDirectory = "Content";

            DataDirectory = new DirectoryInfo(Path.Combine(Directory.GetCurrentDirectory(), "Data"));

            ClearColor = Color.White;

            ServiceLocator.Apply(Services);

            if (!ServiceLocator.Has <GraphicsDevice>())
            {
                ServiceLocator.Add(Graphics.GraphicsDevice);
            }

            if (!ServiceLocator.Has <Camera>())
            {
                ServiceLocator.Add(new Camera(Graphics.GraphicsDevice.Viewport));
            }

            if (!ServiceLocator.Has <IEntityService>())
            {
                ServiceLocator.Add <IEntityService>(new EntityService());
            }

            if (!ServiceLocator.Has <ICollisionService>())
            {
                ServiceLocator.Add <ICollisionService>(new CollisionService());
            }

#if !DEBUG
            Graphics.IsFullScreen              = true;
            Graphics.PreferredBackBufferWidth  = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
            Graphics.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
            Graphics.PreferMultiSampling       = false;
#endif

            // TODO: GGGGGGGGAAAAAAAAAAAAAAAAAHHHHHHHHH WE'RE IO BOUND IN A CTOR!!!!!!!!!!!!!!!!!! FFFFFFFFFFFFFUUUUUUUUUUUUUUUUUUUUUUU
            // ContentCacheManager must be loaded first, this will scan
            // every directory in the content project and load all of the
            // content into a cache
            ContentCacheManager.LoadContent(Content);

            // TODO: in DIRECTX versions we'll have to do this in initialize...
            // maybe move this code there now?
            ScreenManager = new ScreenManager(this);
            Components.Add(ScreenManager);
        }
Exemple #3
0
        private void ProjectOnOnChange(object sender, ProjectChangeEventArgs eventArgs)
        {
            Project = (Project)sender;
            if (eventArgs.PropertyName == "ContentDirectories")
            {
                // total hack, create a level editor control
                // so that a valid GraphicsDevice object is created
                new LevelEditorControl {
                    Height = 100, Width = 100
                }.CreateControl();

                Project.ContentDirectories.ForEach(ContentCacheManager.AddContentDirectory);

                // TODO: disk op... show progress bar?
                ContentCacheManager.LoadContent(new ContentManager(ServiceLocator.Apply()));
            }

            UpdateUserInterface();
        }