/// <summary>
        /// Load the content of this animation bar.
        /// </summary>
        public override void LoadContent()
        {
            //The inherited method.
            base.LoadContent();

            //Load the brushes.
            _FrameDelimiter = new LineBrush(2, Color.Black);
            _ProgressMarker = new LineBrush(2, Color.Red);
            _FrameDelimiter.Load(GUI.GraphicsDevice);
            _ProgressMarker.Load(GUI.GraphicsDevice);

            //Create the textures and sprite fonts needed.
            _BackgroundTexture = DrawingHelper.CreateRectangleTexture(GUI.GraphicsDevice, (int)Width, (int)Height, new Color(0, 0, 0, 155), Color.Black);
            _SelectedFrameTexture = DrawingHelper.CreateRectangleTexture(GUI.GraphicsDevice, (int)_FrameWidth, (int)Height, Color.DarkSeaGreen, Color.Black);
            _KeyframeTexture = DrawingHelper.CreateRectangleTexture(GUI.GraphicsDevice, (int)_FrameWidth, (int)Height, Color.CadetBlue, Color.Black);

            //Load the play button's content.
            _PlayButton.LoadContent();
        }
Exemple #2
0
        /// <summary>
        /// Initialize the level editor.
        /// </summary>
        /// <param name="viewport">The window's viewport.</param>
        public void Initialize(Rectangle viewport)
        {
            //Initialize some variables.
            _State = EditorState.Idle;
            _GUI = new GraphicalUserInterface();
            _SelectedItem = null;
            _SelectedLayer = null;
            _Camera = new Camera2D(viewport, new Rectangle(0, 0, 10000, 5000));
            _Level = new Level("Level 1", _Camera);
            _DebugSystem = new DebugSystem(_Level.World);

            //Enable the debug view from start.
            _DebugSystem.Debug(true);

            //Hook up to some of the level's events.
            _Level.LayerChanged += OnLayerChanged;

            //Create the GUI items.
            _TreeView = new TreeView(_GUI, new Vector2(0, 50), 275, 450);
            _PropertyList = new List(_GUI, new Vector2(0, 505), 275, 200);
            _ItemModifier = new ItemModifier(_GUI, new Vector2(viewport.Width - 300, 50), 300, 500);
            _Menu = new Menu(_GUI, new Vector2(0, 0), 500, 30);

            //Add items to the GUI.
            _GUI.AddItem(_TreeView);
            _GUI.AddItem(_PropertyList);
            _GUI.AddItem(_ItemModifier);
            _GUI.AddItem(_Menu);

            //Brushes.
            _SelectionBrush = new LineBrush(1, Color.Gainsboro);

            #region Menu
            //Play with the menu.
            _Menu.AddMenuItem();
            _Menu.AddMenuItem();
            _Menu.AddMenuItem();
            _Menu.AddMenuItem();
            _Menu.MenuItems[0].AddListItem();
            _Menu.MenuItems[0].AddListItem();
            _Menu.MenuItems[0].AddListItem();
            _Menu.MenuItems[1].AddListItem();
            _Menu.MenuItems[1].AddListItem();
            _Menu.MenuItems[1].AddListItem();
            _Menu.MenuItems[2].AddListItem();
            _Menu.MenuItems[2].AddListItem();
            _Menu.MenuItems[2].AddListItem();
            _Menu.MenuItems[3].AddListItem();
            _Menu.MenuItems[3].AddListItem();
            _Menu.MenuItems[3].AddListItem();
            _Menu.MenuItems[0].IsScrollable = false;
            _Menu.MenuItems[1].IsScrollable = false;
            _Menu.MenuItems[2].IsScrollable = false;
            _Menu.MenuItems[3].IsScrollable = false;
            _Menu.MenuItems[0].IsFixed = false;
            _Menu.MenuItems[1].IsFixed = false;
            _Menu.MenuItems[2].IsFixed = false;
            _Menu.MenuItems[3].IsFixed = false;
            _Menu.MenuItems[0].Text = "File";
            _Menu.MenuItems[1].Text = "Edit";
            _Menu.MenuItems[2].Text = "View";
            _Menu.MenuItems[3].Text = "Physics";
            _Menu.MenuItems[0][0].Label.Text = "New Level";
            _Menu.MenuItems[0][1].Label.Text = "Open Level";
            _Menu.MenuItems[0][2].Label.Text = "Save Level";
            _Menu.MenuItems[1][0].Label.Text = "Add Item";
            _Menu.MenuItems[1][1].Label.Text = "Add Layer";
            _Menu.MenuItems[1][2].Label.Text = "Delete Layer";
            _Menu.MenuItems[2][0].Label.Text = "Zoom";
            _Menu.MenuItems[2][1].Label.Text = "Scroll";
            _Menu.MenuItems[2][2].Label.Text = "Windows";
            _Menu.MenuItems[3][0].Label.Text = "Play";
            _Menu.MenuItems[3][1].Label.Text = "Pause";
            _Menu.MenuItems[3][2].Label.Text = "Stop";
            #endregion

            //Hook up some events.
            _GUI.ItemClicked += OnGUIClicked;
            _TreeView.Ticked += OnTreeViewNodeTicked;
            _Menu.MenuOptionSelect += OnMenuOptionSelected;

            #region Test
            //Add layers.
            Layer layer1 = AddLayer("Layer 1", new Vector2(.6f, .6f));
            Layer layer2 = AddLayer("Layer 2", new Vector2(.5f, .5f));
            Layer layer3 = AddLayer("Layer 3", new Vector2(.7f, .7f));
            Layer layer4 = AddLayer("Layer 4", new Vector2(.63f, .63f));
            Layer layer5 = AddLayer("Layer 5", Vector2.One);
            Layer layer6 = AddLayer("Layer 6", new Vector2(.99f, 0.99f));
            Layer layer7 = AddLayer("Layer 7", new Vector2(1.5f, 1));

            //Add items.
            AddTextureItem(layer1, @"General/Textures/Hazy_Field[1]", "Background Hazy", new Vector2(0, 50), 0, Vector2.One);
            AddTextureItem(layer1, @"General/Textures/Hazy_Field[2]", "Background Hazy", new Vector2(0, 1000), 0, Vector2.One);
            AddTextureItem(layer1, @"General/Textures/Ruins[1]", "Background Ruins", new Vector2(2000, 50), 0, Vector2.One);
            AddTextureItem(layer2, @"General/Textures/FrozenMetalGroundV1[1]", "Ground", new Vector2(0, 700), 0, Vector2.One);
            AddTextureItem(layer2, @"General/Textures/Backdrop_Guy[1]", "Backdrop Guy", new Vector2(1900, 200), 0, Vector2.One);
            AddTextureItem(layer3, @"General/Textures/Hazy_Field_Tree[1]", "Hazy Field Tree", new Vector2(0, 1200), 0, Vector2.One);
            AddTextureItem(layer4, @"General/Textures/Hazy_Field_Pillar[1]", "Hazy Field Pillar", new Vector2(1200, 1500), 0, Vector2.One);
            AddTextureItem(layer5, @"General/Textures/Fern", "Fern 1", new Vector2(500, 500), 0, Vector2.One);
            AddTextureItem(layer5, @"General/Textures/Rock[1]", "Rock 1", new Vector2(400, 500), 0, Vector2.One);
            AddTextureItem(layer6, @"General/Textures/Fern", "Fern 2", new Vector2(515, 515), 0, Vector2.One);
            AddTextureItem(layer7, @"General/Textures/Pine_Tree", "Pine Tree", new Vector2(600, 0), 0, Vector2.One);
            AddTextureItem(layer7, @"General/Textures/Rock[2]", "Rock 2", new Vector2(300, 550), 0, Vector2.One);

            Box box1 = Factory.Instance.AddBox(layer5, "Ground", @"General/Textures/FrozenMetalGroundV1[1]", new Vector2(800, 700), 937, 32);
            box1.Limbs[0].Body.BodyType = FarseerPhysics.Dynamics.BodyType.Static;

            for (int i = 0; i <= 5; i++)
            {
                Box box2 = Factory.Instance.AddBox(layer5, "Box", @"General/Textures/BlueBoxV1[1]", new Vector2(500 + 50 * i, 50), 26, 27);
                box2.Limbs[0].Body.Restitution = .1f * i;
                //box2.Parts[0].Body.Mass = 1 + 1 * i;
            }
            #endregion
        }
        /// <summary>
        /// Load the content of this bone dialog.
        /// </summary>
        public override void LoadContent()
        {
            //The inherited method.
            base.LoadContent();

            //Create and load the item's brushes.
            _BoneBrush = new FarseerPhysics.DrawingSystem.LineBrush(1, Color.Black);
            _OriginBrush = new FarseerPhysics.DrawingSystem.LineBrush(1, Color.Green);
            _BoneEndBrush = new FarseerPhysics.DrawingSystem.LineBrush(1, Color.Red);
            _BoneBrush.Load(GUI.GraphicsDevice);
            _OriginBrush.Load(GUI.GraphicsDevice);
            _BoneEndBrush.Load(GUI.GraphicsDevice);
        }
        /// <summary>
        /// Load the content of this sprite dialog.
        /// </summary>
        public override void LoadContent()
        {
            //The inherited method.
            base.LoadContent();

            //Create the item's texture and set its position.
            _BoneBrush = new FarseerPhysics.DrawingSystem.LineBrush(1, Color.Black);
            _OriginBrush = new FarseerPhysics.DrawingSystem.LineBrush(1, Color.Green);
            _BoneEndBrush = new FarseerPhysics.DrawingSystem.LineBrush(1, Color.Red);
            _BoneBrush.Load(GUI.GraphicsDevice);
            _OriginBrush.Load(GUI.GraphicsDevice);
            _BoneEndBrush.Load(GUI.GraphicsDevice);

            //Clear the lists to prevent duplicates.
            _Textures.Clear();
            _List.Clear();

            //Load the list with items.
            foreach (string t in Directory.GetFiles(GUI.ContentManager.RootDirectory, "*.xnb", SearchOption.AllDirectories).ToList<string>())
            {
                //Add a new label to the list, but only if the item in question is a texture.
                if (t.Contains("Textures"))
                {
                    //Remove the "Content\" and the ".xnb" from the name.
                    //t = t.Remove(0, 8).Remove(t.Length - 4, 4);
                    //Save all textures' names.
                    _Textures.Add(t.Replace(@"Content\", "").Replace(".xnb", ""));
                    //Add the list item.
                    _List.AddItem();
                    (_List[_List.Items.Count - 1] as LabelListItem).Label.Text = t.Replace(".xnb", "").Substring((t.LastIndexOf('\\') + 1));
                }
            }
        }