Beispiel #1
0
 public static void OnKeyUp(SdlInput.KeyboardEventArgs e)
 {
     if (e.Key == SdlInput.Key.Escape) {
         if (Windows.WindowSwitcher.GameWindow.MenuManager.Visible && Windows.WindowSwitcher.GameWindow.MenuManager.HasModalMenu == false) {
             Windows.WindowSwitcher.GameWindow.MapViewer.Focus();
             Windows.WindowSwitcher.GameWindow.MenuManager.Visible = false;
             Windows.WindowSwitcher.GameWindow.MenuManager.CloseOpenMenus();
         }
     } else if (e.Key == SdlInput.Key.F11) {
         if (System.IO.Directory.Exists(IO.Paths.StartupPath + "Screenshots") == false) {
             System.IO.Directory.CreateDirectory(IO.Paths.StartupPath + "Screenshots");
         }
         int openScreenshot = -1;
         for (int i = 1; i < Int32.MaxValue; i++) {
             if (System.IO.File.Exists(IO.Paths.StartupPath + "Screenshots/Screenshot" + i + ".png") == false) {
                 openScreenshot = i;
                 break;
             }
         }
         if (openScreenshot > -1) {
             Logic.Graphics.SurfaceManager.SaveSurface(SdlDotNet.Graphics.Video.Screen, IO.Paths.StartupPath + "Screenshots/Screenshot" + openScreenshot + ".png");
             ExpKit.Modules.kitChat chat = (ExpKit.Modules.kitChat)Windows.WindowSwitcher.ExpKit.KitContainer.ModuleSwitcher.FindKitModule(Enums.ExpKitModules.Chat);
             if (chat != null) {
                 chat.AppendChat("Screenshot #" + openScreenshot + " saved!", System.Drawing.Color.Yellow);
             }
         }
     } else {
         if (Windows.WindowSwitcher.GameWindow.MenuManager.Visible) {
             Windows.WindowSwitcher.GameWindow.MenuManager.HandleKeyUp(e);
         }
     }
 }
Beispiel #2
0
 public static void OnKeyDown(SdlInput.KeyboardEventArgs e)
 {
     //if (e.Key == SdlInput.Key.Escape) {
     //    if (Windows.WindowSwitcher.GameWindow.MenuManager.Visible && Windows.WindowSwitcher.GameWindow.MenuManager.HasModalMenu == false) {
     //        Windows.WindowSwitcher.GameWindow.MapViewer.Focus();
     //        Windows.WindowSwitcher.GameWindow.MenuManager.Visible = false;
     //        Windows.WindowSwitcher.GameWindow.MenuManager.CloseOpenMenus();
     //    }
     //} else if (e.Key == SdlInput.Key.F11) {
     //    Logic.Graphics.SurfaceManager.SaveSurface(SdlDotNet.Graphics.Video.Screen, IO.Paths.StartupPath + "Screenshot.png");
     //} else {
         if (Windows.WindowSwitcher.GameWindow.MenuManager.Visible) {
             Windows.WindowSwitcher.GameWindow.MenuManager.HandleKeyDown(e);
         }
     //}
 }
 public static void OnKeyUp(SdlInput.KeyboardEventArgs e)
 {
     if (e.Key == IO.ControlLoader.UpKey) {
         MoveUp = false;
     } else if (e.Key == IO.ControlLoader.DownKey) {
         MoveDown = false;
     } else if (e.Key == IO.ControlLoader.LeftKey) {
         MoveLeft = false;
     } else if (e.Key == IO.ControlLoader.RightKey) {
         MoveRight = false;
     } else if (e.Key == IO.ControlLoader.AttackKey) {
         Attacking = false;
     }
     switch (e.Key) {
         case SdlInput.Key.Escape: {
                 if (!Windows.WindowSwitcher.GameWindow.MenuManager.Visible) {
                     Windows.WindowSwitcher.GameWindow.MenuManager.Visible = true;
                     Windows.WindowSwitcher.GameWindow.MenuManager.Focus();
                     Menus.MenuSwitcher.ShowMainMenu();
                     Music.Music.AudioPlayer.PlaySoundEffect("beep2.wav");
                 } else {
                     if (Windows.WindowSwitcher.GameWindow.MenuManager.HasModalMenu == false) {
                         Windows.WindowSwitcher.GameWindow.MapViewer.Focus();
                         Windows.WindowSwitcher.GameWindow.MenuManager.Visible = false;
                         Windows.WindowSwitcher.GameWindow.MenuManager.CloseOpenMenus();
                     }
                 }
             }
             break;
         //case SdlInput.Key.F5: {
         //        if (!Windows.WindowSwitcher.GameWindow.MenuManager.Visible) {
         //            Windows.WindowSwitcher.GameWindow.MenuManager.Visible = true;
         //            Windows.WindowSwitcher.GameWindow.MenuManager.Focus();
         //            Menus.MenuSwitcher.ShowGuildMenu();
         //            Music.Music.AudioPlayer.PlaySoundEffect("beep2.wav");
         //        }
         //    }
         //    break;
         case SdlInput.Key.Home: {
                 TurnPlayer();
             }
             break;
         case SdlInput.Key.End: {
             if (Globals.Tick > PlayerManager.MyPlayer.GetTimer + 250) {
                 PlayerManager.MyPlayer.GetTimer = Globals.Tick;
                 Messenger.SendRefresh();
             }
             }
             break;
         case SdlInput.Key.Return: {
                 if (PlayerManager.MyPlayer.Y - 1 > -1 && PlayerManager.MyPlayer.X >= 0 && PlayerManager.MyPlayer.X <= Maps.MapHelper.ActiveMap.MaxX && PlayerManager.MyPlayer.Y >= 0 && PlayerManager.MyPlayer.Y <= Maps.MapHelper.ActiveMap.MaxY) {
                     if (Maps.MapHelper.ActiveMap.Tile[PlayerManager.MyPlayer.X, PlayerManager.MyPlayer.Y - 1].Type == Enums.TileType.Sign && PlayerManager.MyPlayer.Direction == Enums.Direction.Up) {
                         ExpKit.Modules.kitChat chat = (ExpKit.Modules.kitChat)WindowSwitcher.ExpKit.KitContainer.ModuleSwitcher.FindKitModule(Enums.ExpKitModules.Chat);
                         if (chat != null) {
                             chat.AppendChat("The sign reads:\n", new SdlDotNet.Widgets.CharRenderOptions(Color.Black));
                             if (!string.IsNullOrEmpty(Maps.MapHelper.ActiveMap.Tile[PlayerManager.MyPlayer.X, PlayerManager.MyPlayer.Y - 1].String1.Trim())) {
                                 chat.AppendChat(Maps.MapHelper.ActiveMap.Tile[PlayerManager.MyPlayer.X, PlayerManager.MyPlayer.Y - 1].String1.Trim() + "\n", new SdlDotNet.Widgets.CharRenderOptions(Color.Gray));
                             }
                             if (!string.IsNullOrEmpty(Maps.MapHelper.ActiveMap.Tile[PlayerManager.MyPlayer.X, PlayerManager.MyPlayer.Y - 1].String2.Trim())) {
                                 chat.AppendChat(Maps.MapHelper.ActiveMap.Tile[PlayerManager.MyPlayer.X, PlayerManager.MyPlayer.Y - 1].String2.Trim() + "\n", new SdlDotNet.Widgets.CharRenderOptions(Color.Gray));
                             }
                             if (!string.IsNullOrEmpty(Maps.MapHelper.ActiveMap.Tile[PlayerManager.MyPlayer.X, PlayerManager.MyPlayer.Y - 1].String3.Trim())) {
                                 chat.AppendChat(Maps.MapHelper.ActiveMap.Tile[PlayerManager.MyPlayer.X, PlayerManager.MyPlayer.Y - 1].String3.Trim() + "\n", new SdlDotNet.Widgets.CharRenderOptions(Color.Gray));
                             }
                         }
                     }
                 }
                 Pickup = false;
             }
             break;
     }
 }
        public static void OnKeyDown(SdlInput.KeyboardEventArgs e)
        {
            if (e.Key == IO.ControlLoader.UpKey) {
                MoveUp = true;
                MovePlayer(Enums.Direction.Up, false);
            } else if (e.Key == IO.ControlLoader.DownKey) {
                MoveDown = true;
                MovePlayer(Enums.Direction.Down, false);
            } else if (e.Key == IO.ControlLoader.LeftKey) {
                MoveLeft = true;
                MovePlayer(Enums.Direction.Left, false);
            } else if (e.Key == IO.ControlLoader.RightKey) {
                MoveRight = true;
                MovePlayer(Enums.Direction.Right, false);
            } else if (e.Key == SdlInput.Key.Return) {
                if (!Pickup) {
                    PickupItem();
                    Pickup = true;
                }
                //} else if (e.Key == IO.ControlLoader.AttackKey) {
                //    GameProcessor.CheckAttack();
            } else if (e.Key == SdlInput.Key.W) {
                if (PlayerManager.MyPlayer.Moves[0].MoveNum > -1) {
                    SelectedMove = 0;
                }
            } else if (e.Key == SdlInput.Key.A) {
                if (PlayerManager.MyPlayer.Moves[1].MoveNum > -1) {
                    SelectedMove = 1;
                }
            } else if (e.Key == SdlInput.Key.S) {
                if (PlayerManager.MyPlayer.Moves[2].MoveNum > -1) {
                    SelectedMove = 2;
                }
            } else if (e.Key == SdlInput.Key.D) {
                if (PlayerManager.MyPlayer.Moves[3].MoveNum > -1) {
                    SelectedMove = 3;
                }
            } else if (e.Key == SdlInput.Key.F) {

                if (SelectedMove > -1 && SelectedMove < 4) {
                    PlayerManager.MyPlayer.UseMove(SelectedMove);
                } else {
                    Attacking = true;
                    GameProcessor.CheckAttack();
                }
            } else if (e.Key == SdlInput.Key.Z) {
                int itemNum = 0;
                if (PlayerManager.MyPlayer.Team[1] != null) {
                    itemNum = Players.PlayerManager.MyPlayer.GetInvItemNum(PlayerManager.MyPlayer.Team[0].HeldItemSlot);
                }
                if (itemNum > 0) {
                    if ((int)Items.ItemHelper.Items[itemNum].Type < 8 || (int)Items.ItemHelper.Items[itemNum].Type == 15) {

                    } else {
                        if (SdlInput.Keyboard.IsKeyPressed(SdlInput.Key.LeftControl)) {
                            Messenger.SendThrowItem(PlayerManager.MyPlayer.Team[0].HeldItemSlot);
                        } else {
                            GameProcessor.CheckUseItem(0, PlayerManager.MyPlayer.Team[0].HeldItemSlot);
                        }
                    }
                }
            } else if (e.Key == SdlInput.Key.X) {
                int itemNum = 0;
                if (PlayerManager.MyPlayer.Team[1] != null) {
                    itemNum = Players.PlayerManager.MyPlayer.GetInvItemNum(PlayerManager.MyPlayer.Team[1].HeldItemSlot);
                }
                if (itemNum > 0) {
                    if ((int)Items.ItemHelper.Items[itemNum].Type < 8 || (int)Items.ItemHelper.Items[itemNum].Type == 15) {

                    } else {
                        if (SdlInput.Keyboard.IsKeyPressed(SdlInput.Key.LeftControl)) {
                            Messenger.SendThrowItem(PlayerManager.MyPlayer.Team[1].HeldItemSlot);
                        } else {
                            GameProcessor.CheckUseItem(1, PlayerManager.MyPlayer.Team[1].HeldItemSlot);
                        }
                    }
                }
            } else if (e.Key == SdlInput.Key.C) {
                int itemNum = 0;
                if (PlayerManager.MyPlayer.Team[1] != null) {
                    itemNum = Players.PlayerManager.MyPlayer.GetInvItemNum(PlayerManager.MyPlayer.Team[2].HeldItemSlot);
                }
                if (itemNum > 0) {
                    if ((int)Items.ItemHelper.Items[itemNum].Type < 8 || (int)Items.ItemHelper.Items[itemNum].Type == 15) {

                    } else {
                        if (SdlInput.Keyboard.IsKeyPressed(SdlInput.Key.LeftControl)) {
                            Messenger.SendThrowItem(PlayerManager.MyPlayer.Team[2].HeldItemSlot);
                        } else {
                            GameProcessor.CheckUseItem(2, PlayerManager.MyPlayer.Team[2].HeldItemSlot);
                        }
                    }
                }
            } else if (e.Key == SdlInput.Key.V) {
                int itemNum = 0;
                if (PlayerManager.MyPlayer.Team[1] != null) {
                    itemNum = Players.PlayerManager.MyPlayer.GetInvItemNum(PlayerManager.MyPlayer.Team[3].HeldItemSlot);
                }
                if (itemNum > 0) {
                    if ((int)Items.ItemHelper.Items[itemNum].Type < 8 || (int)Items.ItemHelper.Items[itemNum].Type == 15) {

                    } else {
                        if (SdlInput.Keyboard.IsKeyPressed(SdlInput.Key.LeftControl)) {
                            Messenger.SendThrowItem(PlayerManager.MyPlayer.Team[3].HeldItemSlot);
                        } else {
                            GameProcessor.CheckUseItem(3, PlayerManager.MyPlayer.Team[3].HeldItemSlot);
                        }
                    }
                }
            } else if (e.Key == SdlInput.Key.F11) {
                if (System.IO.Directory.Exists(IO.Paths.StartupPath + "Screenshots") == false) {
                    System.IO.Directory.CreateDirectory(IO.Paths.StartupPath + "Screenshots");
                }
                int openScreenshot = -1;
                for (int i = 1; i < Int32.MaxValue; i++) {
                    if (System.IO.File.Exists(IO.Paths.StartupPath + "Screenshots/Screenshot" + i + ".png") == false) {
                        openScreenshot = i;
                        break;
                    }
                }
                if (openScreenshot > -1) {
                    Logic.Graphics.SurfaceManager.SaveSurface(SdlDotNet.Graphics.Video.Screen, IO.Paths.StartupPath + "Screenshots/Screenshot" + openScreenshot + ".png");
                    ExpKit.Modules.kitChat chat = (ExpKit.Modules.kitChat)Windows.WindowSwitcher.ExpKit.KitContainer.ModuleSwitcher.FindKitModule(Enums.ExpKitModules.Chat);
                    if (chat != null) {
                        chat.AppendChat("Screenshot #" + openScreenshot + " saved!", System.Drawing.Color.Yellow);
                    }
                }

            } else if (e.Key == SdlInput.Key.F1) {
                if (Ranks.IsAllowed(PlayerManager.MyPlayer, Enums.Rank.Moniter)) {
                    Windows.Editors.EditorManager.AdminPanel.Show();
                    SdlDotNet.Widgets.WindowManager.BringWindowToFront(Windows.Editors.EditorManager.AdminPanel);
                }
                /*
                } else if (e.Key == SdlInput.Key.F2) {
                    Players.Inventory inv = Players.PlayerManager.MyPlayer.Inventory;
                    for (int i = 1; i <= inv.Length; i++) {
                        if (inv[i].Num > 0) {
                            if (Items.ItemHelper.Items[inv[i].Num].Type == Enums.ItemType.PotionAddHP) {
                                ExpKit.Modules.kitChat chat = (ExpKit.Modules.kitChat)Windows.WindowSwitcher.ExpKit.KitContainer.ModuleSwitcher.FindKitModule(Enums.ExpKitModules.Chat);
                                if (chat != null) {
                                    chat.AppendChat("You have used a " + Items.ItemHelper.Items[inv[i].Num].Name + "!", Color.Yellow);
                                }
                                Messenger.SendUseItem(i);
                                break;
                            }
                        }
                    }
                } else if (e.Key == SdlInput.Key.F3) {
                    Players.Inventory inv = Players.PlayerManager.MyPlayer.Inventory;
                    for (int i = 1; i <= inv.Length; i++) {
                        if (inv[i].Num > 0) {
                            if (Items.ItemHelper.Items[inv[i].Num].Type == Enums.ItemType.PotionAddPP) {
                                ExpKit.Modules.kitChat chat = (ExpKit.Modules.kitChat)Windows.WindowSwitcher.ExpKit.KitContainer.ModuleSwitcher.FindKitModule(Enums.ExpKitModules.Chat);
                                if (chat != null) {
                                    chat.AppendChat("You have used a " + Items.ItemHelper.Items[inv[i].Num].Name + "!", Color.Yellow);
                                }
                                Messenger.SendUseItem(i);
                                break;
                            }
                        }
                    }
                */
            }
            //else if (e.Key == SdlInput.Key.F4) {
            //    if (Ranks.IsAllowed(PlayerManager.MyPlayer, Enums.Rank.Moniter)) {
            //        Windows.Editors.EditorManager.GuildPanel.Show();
            //        SdlDotNet.Widgets.WindowManager.BringWindowToFront(Windows.Editors.EditorManager.GuildPanel);
            //    }
            //}
            else if (e.Key == SdlInput.Key.F9) {
                Menus.MenuSwitcher.ShowMenu(new Menus.mnuOnlineList("mnuOnlineList"));
                Network.Messenger.SendOnlineListRequest();
            } else if (e.Key == SdlInput.Key.F10) {
                Menus.MenuSwitcher.ShowMenu(new Menus.mnuBattleLog("mnuBattleLog"));
            } else if (e.Key == SdlInput.Key.Tab) {

            } else if (e.Key == SdlInput.Key.One) {
                Messenger.SendActiveCharSwap(0);
            } else if (e.Key == SdlInput.Key.Two) {
                Messenger.SendActiveCharSwap(1);
            } else if (e.Key == SdlInput.Key.Three) {
                Messenger.SendActiveCharSwap(2);
            } else if (e.Key == SdlInput.Key.Four) {
                Messenger.SendActiveCharSwap(3);
            }
        }