// ReSharper disable once UnusedMember.Local private void OnDialogResponse(VisibleDialog player, int dialogId, int response, int listItem, string inputText) { if (dialogId != DialogService.DialogId) { return; // Prevent dialog hacks } player.ResponseReceived = true; player.Handler(new DialogResult( response == 1 ? DialogResponse.LeftButton : DialogResponse.RightButtonOrCancel, listItem, inputText)); }
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; } }
public override void Handle(Game game, Packet_Server packet) { Packet_ServerDialog d = packet.Dialog; if (d.Dialog == null) { if (game.GetDialogId(d.DialogId) != -1 && game.dialogs[game.GetDialogId(d.DialogId)].value.IsModal != 0) { game.GuiStateBackToGame(); } if (game.GetDialogId(d.DialogId) != -1) { game.dialogs[game.GetDialogId(d.DialogId)] = null; } if (game.DialogsCount_() == 0) { game.SetFreeMouse(false); } } else { VisibleDialog d2 = new VisibleDialog(); d2.key = d.DialogId; d2.value = d.Dialog; d2.screen = ConvertDialog(game, d2.value); d2.screen.game = game; if (game.GetDialogId(d.DialogId) == -1) { for (int i = 0; i < game.dialogsCount; i++) { if (game.dialogs[i] == null) { game.dialogs[i] = d2; break; } } } else { game.dialogs[game.GetDialogId(d.DialogId)] = d2; } if (d.Dialog.IsModal != 0) { game.guistate = GuiState.ModalDialog; game.SetFreeMouse(true); } } }
internal void DrawDialogs(Game game) { for (int i = 0; i < game.dialogsCount; i++) { if (game.dialogs[i] == null) { continue; } VisibleDialog d = game.dialogs[i]; int x = game.Width() / 2 - d.value.Width / 2; int y = game.Height() / 2 - d.value.Height_ / 2; d.screen.screenx = x; d.screen.screeny = y; d.screen.DrawWidgets(); } }
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; } } } } }
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; } } } } }
// ReSharper disable once UnusedMember.Local private void OnPlayerDisconnect(VisibleDialog player, DisconnectReason _) { player.Handler(new DialogResult(DialogResponse.Disconnected, 0, null)); }