Ejemplo n.º 1
0
        public void Update(GameTime gameTime)
        {
            Vector2 menuPosition = position;
            Point   p            = Xin.MouseAsPoint;
            Vector2 scale        = new Vector2(
                Settings.Resolution.X / 1280,
                Settings.Resolution.Y / 720);

            Rectangle buttonRect;

            mouseOver = false;

            for (int i = 0; i < menuItems.Count; i++)
            {
                buttonRect = new Rectangle(
                    (int)menuPosition.X,
                    (int)menuPosition.Y,
                    texture.Width,
                    texture.Height).Scale(scale);

                if (buttonRect.Contains(p))
                {
                    selectedIndex = i;
                    mouseOver     = true;
                }

                menuPosition.Y += texture.Height + 50;
            }

            if (!mouseOver && Xin.CheckKeyPress(Keys.Up))
            {
                selectedIndex--;
                if (selectedIndex < 0)
                {
                    selectedIndex = menuItems.Count - 1;
                }
            }
            else if (!mouseOver && Xin.CheckKeyPress(Keys.Down))
            {
                selectedIndex++;
                if (selectedIndex > menuItems.Count - 1)
                {
                    selectedIndex = 0;
                }
            }
        }
Ejemplo n.º 2
0
        private void CheckKeys()
        {
            string newChar = "";

            if (Xin.CheckKeyPress(Keys.A))
            {
                newChar += "a";
            }
            if (Xin.CheckKeyPress(Keys.B))
            {
                newChar += "b";
            }
            if (Xin.CheckKeyPress(Keys.C))
            {
                newChar += "c";
            }
            if (Xin.CheckKeyPress(Keys.D))
            {
                newChar += "d";
            }
            if (Xin.CheckKeyPress(Keys.E))
            {
                newChar += "e";
            }
            if (Xin.CheckKeyPress(Keys.F))
            {
                newChar += "f";
            }
            if (Xin.CheckKeyPress(Keys.G))
            {
                newChar += "g";
            }
            if (Xin.CheckKeyPress(Keys.H))
            {
                newChar += "h";
            }
            if (Xin.CheckKeyPress(Keys.I))
            {
                newChar += "i";
            }
            if (Xin.CheckKeyPress(Keys.J))
            {
                newChar += "j";
            }
            if (Xin.CheckKeyPress(Keys.K))
            {
                newChar += "k";
            }
            if (Xin.CheckKeyPress(Keys.L))
            {
                newChar += "l";
            }
            if (Xin.CheckKeyPress(Keys.M))
            {
                newChar += "m";
            }
            if (Xin.CheckKeyPress(Keys.N))
            {
                newChar += "n";
            }
            if (Xin.CheckKeyPress(Keys.O))
            {
                newChar += "o";
            }
            if (Xin.CheckKeyPress(Keys.P))
            {
                newChar += "p";
            }
            if (Xin.CheckKeyPress(Keys.Q))
            {
                newChar += "q";
            }
            if (Xin.CheckKeyPress(Keys.R))
            {
                newChar += "r";
            }
            if (Xin.CheckKeyPress(Keys.S))
            {
                newChar += "s";
            }
            if (Xin.CheckKeyPress(Keys.T))
            {
                newChar += "t";
            }
            if (Xin.CheckKeyPress(Keys.U))
            {
                newChar += "u";
            }
            if (Xin.CheckKeyPress(Keys.V))
            {
                newChar += "v";
            }
            if (Xin.CheckKeyPress(Keys.W))
            {
                newChar += "w";
            }
            if (Xin.CheckKeyPress(Keys.X))
            {
                newChar += "x";
            }
            if (Xin.CheckKeyPress(Keys.Y))
            {
                newChar += "y";
            }
            if (Xin.CheckKeyPress(Keys.Z))
            {
                newChar += "z";
            }
            if (Xin.CheckKeyPress(Keys.Back))
            {
                if (text.Length != 0)
                {
                    text = text.Remove(text.Length - 1);
                }
            }
            if (Xin.IsKeyDown(Keys.RightShift) ||
                Xin.IsKeyDown(Keys.LeftShift))
            {
                newChar = newChar.ToUpper();
            }
            if (Xin.CheckKeyPress(Keys.Enter))
            {
                canType = false;
            }

            text += newChar;
        }