コード例 #1
0
ファイル: Button.cs プロジェクト: Joxe/TacticsRPG
        protected bool hotkeyPressed()
        {
            if (m_hotkey == null)
            {
                return(false);
            }
            Keys[] l_keys = KeyboardHandler.getPressedKeys();
            foreach (Keys l_key in m_hotkey)
            {
                if (l_keys.Contains(l_key))
                {
                    continue;
                }
                return(false);
            }

            bool l_returnValue = true;

            if (!m_hotkey.Contains(Keys.LeftShift) && !m_hotkey.Contains(Keys.RightShift))
            {
                l_returnValue = !KeyboardHandler.keyPressed(Keys.LeftShift) && !KeyboardHandler.keyPressed(Keys.LeftShift);
            }
            if (!m_hotkey.Contains(Keys.LeftControl) && !m_hotkey.Contains(Keys.RightControl) && l_returnValue)
            {
                l_returnValue = !KeyboardHandler.keyPressed(Keys.LeftControl) && !KeyboardHandler.keyPressed(Keys.RightControl);
            }
            if (!m_hotkey.Contains(Keys.LeftAlt) && !m_hotkey.Contains(Keys.RightAlt) && l_returnValue)
            {
                l_returnValue = !KeyboardHandler.keyPressed(Keys.LeftAlt) && !KeyboardHandler.keyPressed(Keys.RightAlt);
            }
            return(l_returnValue);
        }
コード例 #2
0
ファイル: TextField.cs プロジェクト: Joxe/TacticsRPG
        public override void update()
        {
            if (MouseHandler.lmbDown())
            {
                if (getHitBox().contains(MouseHandler.worldMouse()))
                {
                    m_writing         = true;
                    m_lastPressedKeys = new Dictionary <Keys, TimeSpan>();
                }
                else
                {
                    m_writing = false;
                }
            }

            if (m_writing)
            {
                foreach (KeyValuePair <Keys, TimeSpan> l_keyPair in m_lastPressedKeys)
                {
                    if (!KeyboardHandler.keyPressed(l_keyPair.Key))
                    {
                        m_repeatKeys.Add(l_keyPair.Key);
                    }
                    else if (l_keyPair.Value + m_repeatTime < Game.getInstance().getGameTime().TotalGameTime)
                    {
                        m_repeatKeys.Add(l_keyPair.Key);
                    }
                }
                foreach (Keys l_key in m_repeatKeys)
                {
                    m_lastPressedKeys.Remove(l_key);
                }
                m_repeatKeys.Clear();

                if (m_currentLocale.Equals("euSv"))
                {
                    updateSweden(Game.getInstance().getGameTime());
                }
                if (m_maxLength != 0 && m_textToShow.p_text.Length > m_maxLength)
                {
                    m_textToShow.erase(m_textToShow.p_text.Length - m_maxLength);
                }
                else
                {
                    while (m_textToShow.measureString().X > m_box.getWidth())
                    {
                        m_textToShow.erase(1);
                    }
                }
                m_caret.setXOffset(m_textToShow.measureString().X + 5);
            }
        }
コード例 #3
0
 private void updateKeyboard()
 {
     //TODO DEBUG!!!
     if (KeyboardHandler.keyPressed(Keys.D))
     {
         m_champions.Add("Joxe", new Champion(m_tileMap.p_hover.getMapPosition(), "Joxe", "Warrior", true, "Human"));
         m_tileMap.p_hover.p_object = m_champions["Joxe"];
         m_champions["Joxe"].load();
     }
     if (KeyboardHandler.keyPressed(Keys.F))
     {
         m_champions.Add("Din Mamma", new Champion(m_tileMap.p_hover.getMapPosition(), "Din Mamma", "Mage", false, "Human"));
         m_tileMap.p_hover.p_object = m_champions["Din Mamma"];
         m_champions["Din Mamma"].load();
     }
 }
コード例 #4
0
ファイル: Game.cs プロジェクト: Joxe/TacticsRPG
        protected override void Update(GameTime a_gameTime)
        {
            if (!IsActive)
            {
                return;
            }
            KeyboardHandler.setCurrentKeyboard();
            MouseHandler.setCurrentMouse();
            m_currentGameTime = a_gameTime;

            if (KeyboardHandler.keyPressed(Keys.Escape))
            {
                this.Exit();
            }

            m_currentState.update();
            m_camera.update();
            base.Update(a_gameTime);

            m_previousGameTime = m_currentGameTime;
            KeyboardHandler.setPreviousKeyboard();
            MouseHandler.setPreviousMouse();
        }
コード例 #5
0
ファイル: TextField.cs プロジェクト: Joxe/TacticsRPG
        private void updateSweden(GameTime a_gameTime)
        {
            Keys[] l_keys = KeyboardHandler.getPressedKeys();
            foreach (Keys l_key in l_keys)
            {
                if (!m_lastPressedKeys.ContainsKey(l_key))
                {
                    if (l_key == Keys.Back)
                    {
                        m_textToShow.erase(1);
                    }
                    else if (l_key == Keys.Space)
                    {
                        m_textToShow.addText(" ");
                    }
                    else if (m_acceptLetters && contains(l_key, m_acptLetters))
                    {
                        if (KeyboardHandler.keyPressed(Keys.LeftShift) || KeyboardHandler.keyPressed(Keys.RightShift))
                        {
                            switch (l_key)
                            {
                            case Keys.OemSemicolon:
                                m_textToShow.addText("^");
                                break;

                            case Keys.OemCloseBrackets:
                                m_textToShow.addText("Å");
                                break;

                            case Keys.OemTilde:
                                m_textToShow.addText("Ö");
                                break;

                            case Keys.OemQuotes:
                                m_textToShow.addText("Ä");
                                break;

                            case Keys.OemComma:
                                m_textToShow.addText(";");
                                break;

                            case Keys.OemPeriod:
                                m_textToShow.addText(":");
                                break;

                            case Keys.OemMinus:
                                m_textToShow.addText("_");
                                break;

                            case Keys.OemQuestion:
                                m_textToShow.addText("*");
                                break;

                            case Keys.OemPlus:
                                m_textToShow.addText("?");
                                break;

                            case Keys.OemOpenBrackets:
                                m_textToShow.addText("`");
                                break;

                            default:
                                m_textToShow.addText((char)l_key);
                                break;
                            }
                        }
                        else
                        {
                            switch (l_key)
                            {
                            case Keys.OemSemicolon:
                                m_textToShow.addText("¨");
                                break;

                            case Keys.OemCloseBrackets:
                                m_textToShow.addText("å");
                                break;

                            case Keys.OemTilde:
                                m_textToShow.addText("ö");
                                break;

                            case Keys.OemQuotes:
                                m_textToShow.addText("ä");
                                break;

                            case Keys.OemComma:
                                m_textToShow.addText(",");
                                break;

                            case Keys.OemPeriod:
                                m_textToShow.addText(".");
                                break;

                            case Keys.OemPipe:
                                m_textToShow.addText("'");
                                break;

                            case Keys.OemMinus:
                                m_textToShow.addText("-");
                                break;

                            case Keys.OemQuestion:
                                m_textToShow.addText("'");
                                break;

                            case Keys.OemPlus:
                                m_textToShow.addText("+");
                                break;

                            case Keys.OemOpenBrackets:
                                m_textToShow.addText("´");
                                break;

                            default:
                                m_textToShow.addText(char.ToLower((char)l_key));
                                break;
                            }
                        }
                    }
                    else if (m_acceptSpecials || m_acceptNumbers)
                    {
                        if (m_acceptSpecials && (KeyboardHandler.keyPressed(Keys.LeftShift) || KeyboardHandler.keyPressed(Keys.RightShift)))
                        {
                            if (l_key == Keys.D0)
                            {
                                m_textToShow.addText("=");
                            }
                            else if (l_key == Keys.D1)
                            {
                                m_textToShow.addText("!");
                            }
                            else if (l_key == Keys.D2)
                            {
                                m_textToShow.addText("\"");
                            }
                            else if (l_key == Keys.D3)
                            {
                                m_textToShow.addText("#");
                            }
                            else if (l_key == Keys.D4)
                            {
                                m_textToShow.addText("¤");
                            }
                            else if (l_key == Keys.D5)
                            {
                                m_textToShow.addText("%");
                            }
                            else if (l_key == Keys.D6)
                            {
                                m_textToShow.addText("&");
                            }
                            else if (l_key == Keys.D7)
                            {
                                m_textToShow.addText("/");
                            }
                            else if (l_key == Keys.D8)
                            {
                                m_textToShow.addText("(");
                            }
                            else if (l_key == Keys.D9)
                            {
                                m_textToShow.addText(")");
                            }
                        }
                        else
                        {
                            if (contains(l_key, m_acptNumbers))
                            {
                                string l_string = l_key.ToString().Replace("D", string.Empty);
                                m_textToShow.addText(l_string);
                            }
                        }
                    }
                    if (!(KeyboardHandler.keyWasDown(l_key) && !m_lastPressedKeys.ContainsKey(l_key)))
                    {
                        m_lastPressedKeys.Add(l_key, a_gameTime.TotalGameTime);
                    }
                }
            }
        }