Example #1
0
        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);
                    }
                }
            }
        }