Example #1
0
        protected override void LoadContent()
        {
            base.LoadContent();

            ContentManager Content = Game.Content;

            backgroundImage = new PictureBox(
                Content.Load<Texture2D>(@"Backgrounds\titlescreen"),
                GameRef.ScreenRectangle);
            ControlManager.Add(backgroundImage);

            Texture2D arrowTexture = Content.Load<Texture2D>(@"GUI\leftarrowUp");

            arrowImage = new PictureBox(
                arrowTexture,
                new Rectangle(
                    0,
                    0,
                    arrowTexture.Width,
                    arrowTexture.Height));
            ControlManager.Add(arrowImage);

            startGame = new LinkLabel(Color.Blue);
            startGame.Text = "New Game";
            startGame.Size = startGame.SpriteFont.MeasureString(startGame.Text);
            startGame.Selected += new EventHandler(menuItem_Selected);

            ControlManager.Add(startGame);

            loadGame = new LinkLabel(Color.Blue);
            loadGame.Text = "Load Game";
            loadGame.Size = loadGame.SpriteFont.MeasureString(loadGame.Text);
            loadGame.Selected += menuItem_Selected;

            ControlManager.Add(loadGame);

            exitGame = new LinkLabel(Color.Blue);
            exitGame.Text = "Exit Game";
            exitGame.Size = exitGame.SpriteFont.MeasureString(exitGame.Text);
            exitGame.Selected += menuItem_Selected;

            ControlManager.Add(exitGame);

            ControlManager.NextControl();

            ControlManager.FocusChanged += new EventHandler(ControlManager_FocusChanged);

            Vector2 position = new Vector2(150, 340);
            foreach (Control c in ControlManager)
            {
                if (c is LinkLabel)
                {
                    if (c.Size.X > maxItemWidth)
                        maxItemWidth = c.Size.X;

                    c.Position = position;
                    position.Y += c.Size.Y + 5f;
                }
            }

            ControlManager_FocusChanged(startGame, null);
        }
Example #2
0
        protected override void LoadContent()
        {
            base.LoadContent();

            ContentManager Content = Game.Content;

            backgroundImage = new PictureBox(
                Content.Load<Texture2D>(@"Backgrounds\inventory"),
                GameRef.ScreenRectangle);
            ControlManager.Add(backgroundImage);

            Texture2D arrowTexture = Content.Load<Texture2D>(@"GUI\leftarrowUp");

            arrowImage = new PictureBox(
                arrowTexture,
                new Rectangle(
                    0,
                    0,
                    arrowTexture.Width,
                    arrowTexture.Height));
            ControlManager.Add(arrowImage);

            Inventory = new List<LinkLabel>();

            foreach (Key key in party.keyInv)
            {
                LinkLabel label = new LinkLabel(Color.Chocolate);
                label.Text = key.Name;
                label.Size = label.SpriteFont.MeasureString(label.Text);
                Inventory.Add(label);
                ControlManager.Add(label);
            }

            ControlManager.NextControl();

            ControlManager.FocusChanged += new EventHandler(ControlManager_FocusChanged);

            Vector2 position = new Vector2(55, 120);
            Vector2 position2 = new Vector2(300, 120);

            for (int count = 0; count < ControlManager.Count; count++)
            {
                Control itemControl = ControlManager[count];

                if (itemControl is LinkLabel)
                {
                    if (itemControl.Size.X > maxItemWidth)
                    {
                        maxItemWidth = itemControl.Size.X;
                    }
                    if (count <= 11)
                    {
                        itemControl.Position = position;
                        position.Y += itemControl.Size.Y + 5f;
                    }
                    else if (count >= 12)
                    {
                        itemControl.Position = position2;
                        position2.Y += itemControl.Size.Y + 5f;
                    }
                }
            }

            ControlManager_FocusChanged(Inventory[0], null);
        }