public UserInterface(MapRegion mapRegion, WaveInformation waveInformation,
     CommandInfoBar commandInfoBar, Session s)
 {
     MapRegion = mapRegion;
     WaveInformation = waveInformation;
     CommandInfoBar = commandInfoBar;
     session = s;
     mouse = new Mouse(session.Map.MouseTexture);
     session.SetUI(this);
 }
        public override void LoadContent()
        {
            ContentManager content = ScreenSystem.Content;
            font = content.Load<SpriteFont>(@"Fonts/menu");
            smallfont = content.Load<SpriteFont>(@"Fonts/menusmall");

            inactiveButtonTexture = content.Load<Texture2D>("Textures\\Menu\\inactivebutton");
            activeButtonTexture = content.Load<Texture2D>("Textures\\Menu\\activebutton");

            Selected = new Color(214, 232, 223);
            Normal = new Color(104, 173, 178);

            mouse = new Mouse(content.Load<Texture2D>("Textures\\menu\\mouse"));

            musicBlock = new UIBlock(ScreenSystem.GraphicsDevice, new Rectangle(10, 110, ScreenSystem.Viewport.Width - 10, 100), Color.White);
            soundBlock = new UIBlock(ScreenSystem.GraphicsDevice, new Rectangle(10, 220, ScreenSystem.Viewport.Width - 10, 100), Color.White);

            Vector2 pos = new Vector2((int)(musicBlock.Dimensions.Left + inactiveButtonTexture.Width), (int)(musicBlock.Dimensions.Top + inactiveButtonTexture.Height));
            Button b = new Button(inactiveButtonTexture, pos,
                new Text(String.Format("Music:{0}%", (int)(Settings.MusicVolume * 100)), font, new Vector2(pos.X - (inactiveButtonTexture.Width / 2) + 10, pos.Y - (inactiveButtonTexture.Height / 2))), Normal, this);
            b.LeftClickEvent += new EventHandler(music_LeftClickEvent);
            musicBlock.Add("MusicButton", b);

            Text minstructions = new Text("Select the Music button to change settings", smallfont, new Vector2(b.Position.X + (b.Texture.Width / 2) + 10, b.ButtonText.Position.Y));
            musicBlock.Add("MusicInstructions", minstructions);

            pos = new Vector2((int)(soundBlock.Dimensions.Left + inactiveButtonTexture.Width), (int)(soundBlock.Dimensions.Top + inactiveButtonTexture.Height));
            b = new Button(inactiveButtonTexture, pos,
                new Text(String.Format("Sound:{0}%", (int)(Settings.SoundVolume * 100)), font, new Vector2(pos.X - (inactiveButtonTexture.Width / 2) + 10, pos.Y - (inactiveButtonTexture.Height / 2))), Normal, this);
            b.LeftClickEvent += new EventHandler(sound_LeftClickEvent);
            soundBlock.Add("SoundButton", b);

            minstructions = new Text("Select the Sound button to change settings", smallfont, new Vector2(b.Position.X + (b.Texture.Width / 2) + 10, b.ButtonText.Position.Y));
            soundBlock.Add("SoundInstructions", minstructions);

            backmessage = "Press Escape to go back";
        }
        public void Update(GameTime gameTime, Mouse activeMouse)
        {
            base.Update(gameTime);

            bool intersect = activeMouse.Rectangle.Intersects(Rectangle);

            if ( intersect || (ActiveMouse != null &&
                (LeftState != ObjectClickedState.Normal || RightState != ObjectClickedState.Normal)))
            {
                ActiveMouse = activeMouse;

                if(intersect) OnHover();

                if (ActiveMouse.LeftClick && (LeftState == ObjectClickedState.Normal
                    || LeftState == ObjectClickedState.Released))
                {
                    LeftState = ObjectClickedState.Clicked;
                    OnLeftClick();
                }
                else if (ActiveMouse.LeftClick && LeftState == ObjectClickedState.Clicked)
                {
                    OnHeldLeftClick();
                }
                else if (ActiveMouse.LeftRelease && LeftState == ObjectClickedState.Clicked)
                {
                    LeftState = ObjectClickedState.Released;
                    OnLeftRelease();
                }
                else if (!ActiveMouse.LeftClick && LeftState == ObjectClickedState.Released)
                {
                    LeftState = ObjectClickedState.Normal;
                    OnLeftNormal();
                }

                if (ActiveMouse.RightClick && (RightState == ObjectClickedState.Normal
                    || RightState == ObjectClickedState.Released))
                {
                    RightState = ObjectClickedState.Clicked;
                    OnRightClick();
                }
                else if (ActiveMouse.RightClick && LeftState == ObjectClickedState.Clicked)
                {
                    OnHeldRightClick();
                }
                else if (ActiveMouse.RightRelease && RightState == ObjectClickedState.Clicked)
                {
                    RightState = ObjectClickedState.Released;
                    OnRightRelease();
                }
                else if (!ActiveMouse.RightClick && RightState == ObjectClickedState.Released)
                {
                    RightState = ObjectClickedState.Normal;
                    OnRightNormal();
                }

                if (LeftState != ObjectClickedState.Normal || RightState != ObjectClickedState.Normal)
                    ActiveMouse.ClickedObject = this;
                else if (ActiveMouse.ClickedObject == this)
                    ActiveMouse.ClickedObject = null;
            }

            else
            {
                if (ActiveMouse != null)
                {
                    ActiveMouse.ClickedObject = null;
                    ActiveMouse = null;
                    OnLeave();
                }
            }
        }