public override bool KeyDown(KeyboardEventArgs args) { if (Cancel) { return(false); } char c = Char.ToUpper(args.KeyChar); if (args.Key == Key.Escape) { Log("Cancel"); Cancel = true; _update = true; BackToCredits(); return(true); } else if (_menu != null) { return(_menu.KeyDown(args)); } else if (args.Key == Key.Enter) { _menu = new Menu(Palette) { Title = "Select Load File...", X = 51, Y = 70, MenuWidth = 217, TitleColour = 12, ActiveColour = 11, TextColour = 5, FontId = 0, IndentTitle = 2, RowHeight = 8 }; int i = 0; foreach (SaveGameFile file in SaveGameFile.GetSaveGames(_driveLetter)) { _menu.Items.Add(file.Name, i++).OnSelect(LoadFileHandler(file)); } _cursor = MouseCursor.Pointer; } else if (c >= 'A' && c <= 'Z') { _driveLetter = c; _update = true; return(true); } return(false); }
private void SaveFile(object sender, EventArgs args) { int item = (sender as MenuItem <int>).Value; _gameId = item; SelectedGame = item; _saving = true; _update = true; SaveGameFile file = SaveGameFile.GetSaveGames(_driveLetter).ToArray()[item]; Game.Save(file.SveFile, file.MapFile); }
private void LoadSaveFile(object sender, MenuItemEventArgs <int> args) { int item = args.Value; SaveGameFile file = SaveGameFile.GetSaveGames(_driveLetter).ToArray()[item]; SaveGame.SelectedGame = (item > 3 ? 3 : item); Log("Load game: {0}", file.Name); Destroy(); Game.LoadGame(file.SveFile, file.MapFile); Common.AddScreen(new GamePlay()); }
public override bool KeyDown(KeyboardEventArgs args) { if (_saving) { Destroy(); return(true); } char c = Char.ToUpper(args.KeyChar); if (args.Key == Key.Escape) { Log("Cancel"); Destroy(); return(true); } else if (_menu != null) { return(_menu.KeyDown(args)); } else if (args.Key == Key.Enter) { if (_gameId >= 0) { SaveGameFile file = SaveGameFile.GetSaveGames(_driveLetter).ToArray()[_gameId]; Game.Save(file.SveFile, file.MapFile); _saving = true; _update = true; return(true); } _menu = new Menu(Palette) { Title = "Select Save File...", X = 51, Y = 38, MenuWidth = 217, TitleColour = 12, ActiveColour = 11, TextColour = 5, FontId = 0, IndentTitle = 2, RowHeight = 8 }; int i = 0; foreach (SaveGameFile file in SaveGameFile.GetSaveGames(_driveLetter).Take(4)) { _menu.Items.Add(file.Name, i++).OnSelect(SaveFile); } _menu.ActiveItem = SelectedGame; } else if (c >= 'A' && c <= 'Z') { _driveLetter = c; _update = true; return(true); } return(false); }