Exemplo n.º 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;
        }
Exemplo n.º 2
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();
        }