Exemple #1
0
 public override void OnKeyDown(Game game, KeyEventArgs args)
 {
     for (int i = 0; i < game.dialogsCount; i++)
     {
         if (game.dialogs[i] == null)
         {
             continue;
         }
         game.dialogs[i].screen.OnKeyDown(game, args);
     }
     if (game.guistate == GuiState.Normal)
     {
         if (args.GetKeyCode() == game.GetKey(GlKeys.Escape))
         {
             for (int i = 0; i < game.dialogsCount; i++)
             {
                 if (game.dialogs[i] == null)
                 {
                     continue;
                 }
                 VisibleDialog d = game.dialogs[i];
                 if (d.value.IsModal != 0)
                 {
                     game.dialogs[i] = null;
                     return;
                 }
             }
             game.ShowEscapeMenu();
             args.SetHandled(true);
             return;
         }
     }
     if (game.guistate == GuiState.ModalDialog)
     {
         if (//args.GetKeyCode() == game.GetKey(GlKeys.B) ||
             args.GetKeyCode() == game.GetKey(GlKeys.Escape))
         {
             for (int i = 0; i < game.dialogsCount; i++)
             {
                 if (game.dialogs[i] == null)
                 {
                     continue;
                 }
                 if (game.dialogs[i].value.IsModal != 0)
                 {
                     game.dialogs[i] = null;
                 }
             }
             game.SendPacketClient(ClientPackets.DialogClick("Esc", new string[0], 0));
             game.GuiStateBackToGame();
             args.SetHandled(true);
         }
         return;
     }
 }
Exemple #2
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;
                 }
             }
         }
     }
 }
Exemple #3
0
 public override void OnButton(MenuWidget w)
 {
     if (w.isbutton)
     {
         string[] textValues = new string[WidgetCount];
         for (int i = 0; i < WidgetCount; i++)
         {
             string s = widgets[i].text;
             if (s == null)
             {
                 s = "";
             }
             textValues[i] = s;
         }
         game.SendPacketClient(ClientPackets.DialogClick(w.id, textValues, WidgetCount));
     }
 }
Exemple #4
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;
                 }
             }
         }
     }
 }