Exemplo n.º 1
0
    public override void OnKeyPress(Game game_, KeyPressEventArgs args)
    {
        if (game.guistate != GuiState.Normal)
        {
            //Don't open chat when not in normal game
            return;
        }
        int eKeyChar = args.GetKeyChar();
        int chart    = 116;
        int charT    = 84;
        int chary    = 121;
        int charY    = 89;

        if ((eKeyChar == chart || eKeyChar == charT) && game.GuiTyping == TypingState.None)
        {
            game.GuiTyping       = TypingState.Typing;
            game.GuiTypingBuffer = "";
            game.IsTeamchat      = false;
            return;
        }
        if ((eKeyChar == chary || eKeyChar == charY) && game.GuiTyping == TypingState.None)
        {
            game.GuiTyping       = TypingState.Typing;
            game.GuiTypingBuffer = "";
            game.IsTeamchat      = true;
            return;
        }
        if (game.GuiTyping == TypingState.Typing)
        {
            int c = eKeyChar;
            if (game.platform.IsValidTypingChar(c))
            {
                game.GuiTypingBuffer = StringTools.StringAppend(game.platform, game.GuiTypingBuffer, game.CharToString(c));
            }
            int charTab = 9;
            //Handles player name autocomplete in chat
            if (c == charTab && game.platform.StringTrim(game.GuiTypingBuffer) != "")
            {
                IntRef   partsLength = new IntRef();
                string[] parts       = game.platform.StringSplit(game.GuiTypingBuffer, " ", partsLength);
                string   completed   = DoAutocomplete(parts[partsLength.value - 1]);
                if (completed == "")
                {
                    //No completion available. Abort.
                    return;
                }
                else if (partsLength.value == 1)
                {
                    //Part is first word. Format as "<name>: "
                    game.GuiTypingBuffer = StringTools.StringAppend(game.platform, completed, ": ");
                }
                else
                {
                    //Part is not first. Just complete "<name> "
                    parts[partsLength.value - 1] = completed;
                    game.GuiTypingBuffer         = StringTools.StringAppend(game.platform, game.platform.StringJoin(parts, " "), " ");
                }
            }
        }
    }
Exemplo n.º 2
0
 public void HandleKeyPress(KeyPressEventArgs e)
 {
     if (e.GetKeyChar() == 70 || e.GetKeyChar() == 102) // 'F', 'f'
     {
         filter += 1;
         if (filter == 3)
         {
             filter = 0;
         }
     }
     if (e.GetKeyChar() == 96) // '`'
     {
         screen.OnBackPressed();
     }
     screen.OnKeyPress(e);
 }
Exemplo n.º 3
0
 public override void OnKeyPress(Game game_, KeyPressEventArgs e)
 {
     if (!visible)
     {
         return;
     }
     if (e.GetKeyChar() == 8) // backspace
     {
         return;
     }
     for (int i = maxColumns - 1; i > cursorColumn; i--)
     {
         buffer[cursorLine][i] = buffer[cursorLine][i - 1];
     }
     buffer[cursorLine][cursorColumn] = e.GetKeyChar();
     cursorColumn++;
     e.SetHandled(true);
 }
Exemplo n.º 4
0
 void KeyPress(KeyPressEventArgs e)
 {
     for (int i = 0; i < WidgetCount; i++)
     {
         MenuWidget w = widgets[i];
         if (w != null)
         {
             if (w.hasKeyboardFocus)
             {
                 if (e.GetKeyChar() == 9 || e.GetKeyChar() == 13) // tab, enter
                 {
                     if (w.type == WidgetType.Button && e.GetKeyChar() == 13)
                     {
                         //Call OnButton when enter is pressed and widget is a button
                         OnButton(w);
                         return;
                     }
                     else if (w.nextWidget != -1)
                     {
                         //Just switch focus otherwise
                         w.LoseFocus();
                         widgets[w.nextWidget].GetFocus();
                         return;
                     }
                 }
             }
             if (w.type == WidgetType.Textbox)
             {
                 if (w.editing)
                 {
                     string s = menu.CharToString(e.GetKeyChar());
                     if (e.GetKeyChar() == 8) // backspace
                     {
                         if (menu.StringLength(w.text) > 0)
                         {
                             w.text = StringTools.StringSubstring(menu.p, w.text, 0, menu.StringLength(w.text) - 1);
                         }
                         return;
                     }
                     if (e.GetKeyChar() == 22) //paste
                     {
                         if (menu.p.ClipboardContainsText())
                         {
                             w.text = StringTools.StringAppend(menu.p, w.text, menu.p.ClipboardGetText());
                         }
                         return;
                     }
                     if (menu.p.IsValidTypingChar(e.GetKeyChar()))
                     {
                         w.text = StringTools.StringAppend(menu.p, w.text, s);
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 5
0
    public override void OnKeyPress(Game game_, KeyPressEventArgs args)
    {
        if (game.guistate != GuiState.Inventory)
        {
            return;
        }
        int keyChar = args.GetKeyChar();

        if (keyChar == 49)
        {
            game.ActiveMaterial = 0;
        }
        if (keyChar == 50)
        {
            game.ActiveMaterial = 1;
        }
        if (keyChar == 51)
        {
            game.ActiveMaterial = 2;
        }
        if (keyChar == 52)
        {
            game.ActiveMaterial = 3;
        }
        if (keyChar == 53)
        {
            game.ActiveMaterial = 4;
        }
        if (keyChar == 54)
        {
            game.ActiveMaterial = 5;
        }
        if (keyChar == 55)
        {
            game.ActiveMaterial = 6;
        }
        if (keyChar == 56)
        {
            game.ActiveMaterial = 7;
        }
        if (keyChar == 57)
        {
            game.ActiveMaterial = 8;
        }
        if (keyChar == 48)
        {
            game.ActiveMaterial = 9;
        }
    }
Exemplo n.º 6
0
 public override void OnKeyPress(Game game, KeyPressEventArgs args)
 {
     if (game.guistate != GuiState.ModalDialog &&
         game.guistate != GuiState.Normal)
     {
         return;
     }
     if (game.IsTyping)
     {
         // Do not handle key presses when chat is opened
         return;
     }
     for (int i = 0; i < game.dialogsCount; i++)
     {
         if (game.dialogs[i] == null)
         {
             continue;
         }
         game.dialogs[i].screen.OnKeyPress(game, args);
     }
     for (int k = 0; k < game.dialogsCount; k++)
     {
         if (game.dialogs[k] == null)
         {
             continue;
         }
         VisibleDialog d = game.dialogs[k];
         for (int i = 0; i < d.value.WidgetsCount; i++)
         {
             Packet_Widget w = d.value.Widgets[i];
             if (w == null)
             {
                 continue;
             }
             // Only typeable characters are handled by KeyPress (for special characters use KeyDown)
             string valid = "abcdefghijklmnopqrstuvwxyz1234567890\t ";
             if (game.platform.StringContains(valid, game.CharToString(w.ClickKey)))
             {
                 if (args.GetKeyChar() == w.ClickKey)
                 {
                     game.SendPacketClient(ClientPackets.DialogClick(w.Id, new string[0], 0));
                     return;
                 }
             }
         }
     }
 }
Exemplo n.º 7
0
 void KeyPress(KeyPressEventArgs e)
 {
     for (int i = 0; i < WidgetCount; i++)
     {
         MenuWidget w = widgets[i];
         if (w != null)
         {
             if (w.type == WidgetType.Textbox)
             {
                 if (w.editing)
                 {
                     if (menu.p.IsValidTypingChar(e.GetKeyChar()))
                     {
                         w.text = StringTools.StringAppend(menu.p, w.text, menu.CharToString(e.GetKeyChar()));
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 8
0
 public override void OnKeyPress(Game game, KeyPressEventArgs args)
 {
     if (game.guistate != GuiState.ModalDialog &&
         game.guistate != GuiState.Normal)
     {
         return;
     }
     for (int i = 0; i < game.dialogsCount; i++)
     {
         if (game.dialogs[i] == null)
         {
             continue;
         }
         game.dialogs[i].screen.OnKeyPress(game, args);
     }
     for (int k = 0; k < game.dialogsCount; k++)
     {
         if (game.dialogs[k] == null)
         {
             continue;
         }
         VisibleDialog d = game.dialogs[k];
         for (int i = 0; i < d.value.WidgetsCount; i++)
         {
             Packet_Widget w = d.value.Widgets[i];
             if (w == null)
             {
                 continue;
             }
             string valid = (StringTools.StringAppend(game.platform, "abcdefghijklmnopqrstuvwxyz1234567890\t ", game.CharToString(27)));
             if (game.platform.StringContains(valid, game.CharToString(w.ClickKey)))
             {
                 if (args.GetKeyChar() == w.ClickKey)
                 {
                     game.SendPacketClient(ClientPackets.DialogClick(w.Id, new string[0], 0));
                     return;
                 }
             }
         }
     }
 }
Exemplo n.º 9
0
    public override void OnKeyPress(Game game_, KeyPressEventArgs args)
    {
        if (game.guistate != GuiState.Normal)
        {
            //Don't open chat when not in normal game
            return;
        }
        int eKeyChar = args.GetKeyChar();
        int chart    = 116;
        int charT    = 84;
        int chary    = 121;
        int charY    = 89;

        if ((eKeyChar == chart || eKeyChar == charT) && game.GuiTyping == TypingState.None)
        {
            game.GuiTyping       = TypingState.Typing;
            game.GuiTypingBuffer = "";
            game.IsTeamchat      = false;
            return;
        }
        if ((eKeyChar == chary || eKeyChar == charY) && game.GuiTyping == TypingState.None)
        {
            game.GuiTyping       = TypingState.Typing;
            game.GuiTypingBuffer = "";
            game.IsTeamchat      = true;
            return;
        }
        if (game.GuiTyping == TypingState.Typing)
        {
            int c = eKeyChar;
            if (game.platform.IsValidTypingChar(c))
            {
                game.GuiTypingBuffer = StringTools.StringAppend(game.platform, game.GuiTypingBuffer, game.CharToString(c));
            }
        }
    }
Exemplo n.º 10
0
 void KeyPress(KeyPressEventArgs e)
 {
     for (int i = 0; i < WidgetCount; i++)
     {
         MenuWidget w = widgets[i];
         if (w != null)
         {
             if (w.type == WidgetType.Textbox)
             {
                 if (w.editing)
                 {
                     string s = CharToString(e.GetKeyChar());
                     if (e.GetKeyChar() == 8) // backspace
                     {
                         if (StringTools.StringLength(game.platform, w.text) > 0)
                         {
                             w.text = StringTools.StringSubstring(game.platform, w.text, 0, StringTools.StringLength(game.platform, w.text) - 1);
                         }
                         return;
                     }
                     if (e.GetKeyChar() == 9 || e.GetKeyChar() == 13) // tab, enter
                     {
                         return;
                     }
                     if (e.GetKeyChar() == 22) //paste
                     {
                         if (game.platform.ClipboardContainsText())
                         {
                             w.text = StringTools.StringAppend(game.platform, w.text, game.platform.ClipboardGetText());
                         }
                         return;
                     }
                     if (game.platform.IsValidTypingChar(e.GetKeyChar()))
                     {
                         w.text = StringTools.StringAppend(game.platform, w.text, s);
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 11
0
 public override void OnKeyPress(Game game_, KeyPressEventArgs args)
 {
     if (game.guistate != GuiState.Normal)
     {
         //Don't open chat when not in normal game
         return;
     }
     int eKeyChar = args.GetKeyChar();
     int chart = 116;
     int charT = 84;
     int chary = 121;
     int charY = 89;
     if ((eKeyChar == chart || eKeyChar == charT) && game.GuiTyping == TypingState.None)
     {
         game.GuiTyping = TypingState.Typing;
         game.GuiTypingBuffer = "";
         game.IsTeamchat = false;
         return;
     }
     if ((eKeyChar == chary || eKeyChar == charY) && game.GuiTyping == TypingState.None)
     {
         game.GuiTyping = TypingState.Typing;
         game.GuiTypingBuffer = "";
         game.IsTeamchat = true;
         return;
     }
     if (game.GuiTyping == TypingState.Typing)
     {
         int c = eKeyChar;
         if (game.platform.IsValidTypingChar(c))
         {
             game.GuiTypingBuffer = StringTools.StringAppend(game.platform, game.GuiTypingBuffer, game.CharToString(c));
         }
         int charTab = 9;
         //Handles player name autocomplete in chat
         if (c == charTab && game.platform.StringTrim(game.GuiTypingBuffer) != "")
         {
             IntRef partsLength = new IntRef();
             string[] parts = game.platform.StringSplit(game.GuiTypingBuffer, " ", partsLength);
             string completed = DoAutocomplete(parts[partsLength.value - 1]);
             if (completed == "")
             {
                 //No completion available. Abort.
                 return;
             }
             else if (partsLength.value == 1)
             {
                 //Part is first word. Format as "<name>: "
                 game.GuiTypingBuffer = StringTools.StringAppend(game.platform, completed, ": ");
             }
             else
             {
                 //Part is not first. Just complete "<name> "
                 parts[partsLength.value - 1] = completed;
                 game.GuiTypingBuffer = StringTools.StringAppend(game.platform, game.platform.StringJoin(parts, " "), " ");
             }
         }
     }
 }
Exemplo n.º 12
0
 public override void OnKeyPress(KeyPressEventArgs e)
 {
     game.KeyPress(e.GetKeyChar());
 }
Exemplo n.º 13
0
 public void HandleKeyPress(KeyPressEventArgs e)
 {
     if (e.GetKeyChar() == 70 || e.GetKeyChar() == 102) // 'F', 'f'
     {
         filter += 1;
         if (filter == 3)
         {
             filter = 0;
         }
     }
     if (e.GetKeyChar() == 96) // '`'
     {
         screen.OnBackPressed();
     }
     screen.OnKeyPress(e);
 }
Exemplo n.º 14
0
 void KeyPress(KeyPressEventArgs e)
 {
     for (int i = 0; i < WidgetCount; i++)
     {
         MenuWidget w = widgets[i];
         if (w != null)
         {
             if (w.type == WidgetType.Textbox)
             {
                 if (w.editing)
                 {
                     if (menu.p.IsValidTypingChar(e.GetKeyChar()))
                     {
                         w.text = StringTools.StringAppend(menu.p, w.text, menu.CharToString(e.GetKeyChar()));
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 15
0
 public override void OnKeyPress(Game game_, KeyPressEventArgs args)
 {
     if (game.guistate != GuiState.Inventory)
     {
         return;
     }
     int keyChar = args.GetKeyChar();
     if (keyChar == 49) { game.ActiveMaterial = 0; }
     if (keyChar == 50) { game.ActiveMaterial = 1; }
     if (keyChar == 51) { game.ActiveMaterial = 2; }
     if (keyChar == 52) { game.ActiveMaterial = 3; }
     if (keyChar == 53) { game.ActiveMaterial = 4; }
     if (keyChar == 54) { game.ActiveMaterial = 5; }
     if (keyChar == 55) { game.ActiveMaterial = 6; }
     if (keyChar == 56) { game.ActiveMaterial = 7; }
     if (keyChar == 57) { game.ActiveMaterial = 8; }
     if (keyChar == 48) { game.ActiveMaterial = 9; }
 }
Exemplo n.º 16
0
 public override void OnKeyPress(Game game_, KeyPressEventArgs args)
 {
     if (game.guistate != GuiState.Normal)
     {
         //Don't open chat when not in normal game
         return;
     }
     int eKeyChar = args.GetKeyChar();
     int chart = 116;
     int charT = 84;
     int chary = 121;
     int charY = 89;
     if ((eKeyChar == chart || eKeyChar == charT) && game.GuiTyping == TypingState.None)
     {
         game.GuiTyping = TypingState.Typing;
         game.GuiTypingBuffer = "";
         game.IsTeamchat = false;
         return;
     }
     if ((eKeyChar == chary || eKeyChar == charY) && game.GuiTyping == TypingState.None)
     {
         game.GuiTyping = TypingState.Typing;
         game.GuiTypingBuffer = "";
         game.IsTeamchat = true;
         return;
     }
     if (game.GuiTyping == TypingState.Typing)
     {
         int c = eKeyChar;
         if (game.platform.IsValidTypingChar(c))
         {
             game.GuiTypingBuffer = StringTools.StringAppend(game.platform, game.GuiTypingBuffer, game.CharToString(c));
         }
         int charTab = 9;
         //Handles player name autocomplete in chat
         if (c == charTab && game.platform.StringTrim(game.GuiTypingBuffer) != "")
         {
             for (int i = 0; i < game.entitiesCount; i++)
             {
                 Entity entity = game.entities[i];
                 if (entity == null) { continue; }
                 if (entity.drawName == null) { continue; }
                 if (!entity.drawName.ClientAutoComplete) { continue; }
                 DrawName p = entity.drawName;
                 //Use substring here because player names are internally in format &xNAME (so we need to cut first 2 characters)
                 if (game.platform.StringStartsWithIgnoreCase(StringTools.StringSubstringToEnd(game.platform, p.Name, 2), game.GuiTypingBuffer))
                 {
                     game.GuiTypingBuffer = StringTools.StringAppend(game.platform, StringTools.StringSubstringToEnd(game.platform, p.Name, 2), ": ");
                     break;
                 }
             }
         }
     }
 }
Exemplo n.º 17
0
 public override void OnKeyPress(Game game, KeyPressEventArgs args)
 {
     if (game.guistate != GuiState.ModalDialog
         && game.guistate != GuiState.Normal)
     {
         return;
     }
     for (int i = 0; i < game.dialogsCount; i++)
     {
         if (game.dialogs[i] == null) { continue; }
         game.dialogs[i].screen.OnKeyPress(game, args);
     }
     for (int k = 0; k < game.dialogsCount; k++)
     {
         if (game.dialogs[k] == null)
         {
             continue;
         }
         VisibleDialog d = game.dialogs[k];
         for (int i = 0; i < d.value.WidgetsCount; i++)
         {
             Packet_Widget w = d.value.Widgets[i];
             if (w == null)
             {
                 continue;
             }
             // Only typeable characters are handled by KeyPress (for special characters use KeyDown)
             string valid = "abcdefghijklmnopqrstuvwxyz1234567890\t ";
             if (game.platform.StringContains(valid, game.CharToString(w.ClickKey)))
             {
                 if (args.GetKeyChar() == w.ClickKey)
                 {
                     game.SendPacketClient(ClientPackets.DialogClick(w.Id, new string[0], 0));
                     return;
                 }
             }
         }
     }
 }
Exemplo n.º 18
0
 void KeyPress(KeyPressEventArgs e)
 {
     for (int i = 0; i < WidgetCount; i++)
     {
         MenuWidget w = widgets[i];
         if (w != null)
         {
             if (w.hasKeyboardFocus)
             {
                 if (e.GetKeyChar() == 9 || e.GetKeyChar() == 13) // tab, enter
                 {
                     if (w.type == WidgetType.Button && e.GetKeyChar() == 13)
                     {
                         //Call OnButton when enter is pressed and widget is a button
                         OnButton(w);
                         return;
                     }
                     else if (w.nextWidget != -1)
                     {
                         //Just switch focus otherwise
                         w.LoseFocus();
                         widgets[w.nextWidget].GetFocus();
                         return;
                     }
                 }
             }
             if (w.type == WidgetType.Textbox)
             {
                 if (w.editing)
                 {
                     string s = menu.CharToString(e.GetKeyChar());
                     if (e.GetKeyChar() == 8) // backspace
                     {
                         if (menu.StringLength(w.text) > 0)
                         {
                             w.text = StringTools.StringSubstring(menu.p, w.text, 0, menu.StringLength(w.text) - 1);
                         }
                         return;
                     }
                     if (e.GetKeyChar() == 22) //paste
                     {
                         if (menu.p.ClipboardContainsText())
                         {
                             w.text = StringTools.StringAppend(menu.p, w.text, menu.p.ClipboardGetText());
                         }
                         return;
                     }
                     if (menu.p.IsValidTypingChar(e.GetKeyChar()))
                     {
                         w.text = StringTools.StringAppend(menu.p, w.text, s);
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 19
0
 public override void OnKeyPress(Game game_, KeyPressEventArgs args)
 {
     if (game.guistate != GuiState.Normal)
     {
         //Don't open chat when not in normal game
         return;
     }
     int eKeyChar = args.GetKeyChar();
     int chart = 116;
     int charT = 84;
     int chary = 121;
     int charY = 89;
     if ((eKeyChar == chart || eKeyChar == charT) && game.GuiTyping == TypingState.None)
     {
         game.GuiTyping = TypingState.Typing;
         game.GuiTypingBuffer = "";
         game.IsTeamchat = false;
         return;
     }
     if ((eKeyChar == chary || eKeyChar == charY) && game.GuiTyping == TypingState.None)
     {
         game.GuiTyping = TypingState.Typing;
         game.GuiTypingBuffer = "";
         game.IsTeamchat = true;
         return;
     }
     if (game.GuiTyping == TypingState.Typing)
     {
         int c = eKeyChar;
         if (game.platform.IsValidTypingChar(c))
         {
             game.GuiTypingBuffer = StringTools.StringAppend(game.platform, game.GuiTypingBuffer, game.CharToString(c));
         }
     }
 }
Exemplo n.º 20
0
 public override void OnKeyPress(Game game_, KeyPressEventArgs e)
 {
     if (!visible)
     {
         return;
     }
     if (e.GetKeyChar() == 8) // backspace
     {
         return;
     }
     for (int i = maxColumns - 1; i > cursorColumn; i--)
     {
         buffer[cursorLine][i] = buffer[cursorLine][i - 1];
     }
     buffer[cursorLine][cursorColumn] = e.GetKeyChar();
     cursorColumn++;
     e.SetHandled(true);
 }
Exemplo n.º 21
0
    public override void OnKeyPress(Game game_, KeyPressEventArgs args)
    {
        if (game.guistate != GuiState.Normal)
        {
            //Don't open chat when not in normal game
            return;
        }
        int eKeyChar = args.GetKeyChar();
        int chart    = 116;
        int charT    = 84;
        int chary    = 121;
        int charY    = 89;

        if ((eKeyChar == chart || eKeyChar == charT) && game.GuiTyping == TypingState.None)
        {
            game.GuiTyping       = TypingState.Typing;
            game.GuiTypingBuffer = "";
            game.IsTeamchat      = false;
            return;
        }
        if ((eKeyChar == chary || eKeyChar == charY) && game.GuiTyping == TypingState.None)
        {
            game.GuiTyping       = TypingState.Typing;
            game.GuiTypingBuffer = "";
            game.IsTeamchat      = true;
            return;
        }
        if (game.GuiTyping == TypingState.Typing)
        {
            int c = eKeyChar;
            if (game.platform.IsValidTypingChar(c))
            {
                game.GuiTypingBuffer = StringTools.StringAppend(game.platform, game.GuiTypingBuffer, game.CharToString(c));
            }
            int charTab = 9;
            //Handles player name autocomplete in chat
            if (c == charTab && game.platform.StringTrim(game.GuiTypingBuffer) != "")
            {
                for (int i = 0; i < game.entitiesCount; i++)
                {
                    Entity entity = game.entities[i];
                    if (entity == null)
                    {
                        continue;
                    }
                    if (entity.drawName == null)
                    {
                        continue;
                    }
                    if (!entity.drawName.ClientAutoComplete)
                    {
                        continue;
                    }
                    DrawName p = entity.drawName;
                    //Use substring here because player names are internally in format &xNAME (so we need to cut first 2 characters)
                    if (game.platform.StringStartsWithIgnoreCase(StringTools.StringSubstringToEnd(game.platform, p.Name, 2), game.GuiTypingBuffer))
                    {
                        game.GuiTypingBuffer = StringTools.StringAppend(game.platform, StringTools.StringSubstringToEnd(game.platform, p.Name, 2), ": ");
                        break;
                    }
                }
            }
        }
    }
Exemplo n.º 22
0
 public override void OnKeyPress(KeyPressEventArgs e)
 {
     game.KeyPress(e.GetKeyChar());
 }