void ShowDeleteAllDialog() { var messageBox = MessageBox.Create(ScreenManager, "Delete all saves?", _ => OnDeleteAllSavesAccepted()); ScreenManager.AddScreen(messageBox.Screen, GameScreen.ControllingPlayer); }
public override bool Handle(GameConsole console, string[] parameters) { string user; string password; if (parameters.Length == 2) { user = parameters[1]; password = null; } else if (parameters.Length == 2) { user = parameters[1]; password = parameters[2]; } else { return(false); } var saveFileManager = ((object)screenManager.AsDynamic().SaveFileManager).AsDynamic(); if (saveFileManager.AreSaveFilesFull()) { console.AddLine("No free save slots found", Color.Yellow); return(true); } string server; string port; var serverUriParts = parameters[0].Split(':'); if (serverUriParts.Length == 1) { server = serverUriParts[0]; port = "38281"; } else if (serverUriParts.Length == 2) { server = serverUriParts[0]; port = serverUriParts[1]; } else { return(false); } var serverUri = new Uri($"ws://{server}:{port}"); var connectionResult = Client.Connect(serverUri.ToString(), user, password); if (!connectionResult.Successful) { console.AddLine($"Connection Failed: {string.Join(", ", ((LoginFailure)connectionResult).Errors)}", Color.Yellow); return(true); } console.AddLine("Connected!"); var connected = (LoginSuccessful)connectionResult; var slotDataParser = new SlotDataParser(connected.SlotData, Client.SeedString); IsWaitingForDifficulty = true; Seed = slotDataParser.GetSeed(); Settings = slotDataParser.GetSettings(); OnDifficultySelectedHook = saveGame => { saveGame.DataKeyStrings[ArchipelagoItemLocationRandomizer.GameSaveServerKey] = serverUri.ToString(); saveGame.DataKeyStrings[ArchipelagoItemLocationRandomizer.GameSaveUserKey] = user; if (string.IsNullOrEmpty(password)) { saveGame.DataKeyStrings[ArchipelagoItemLocationRandomizer.GameSavePasswordKey] = password; } saveGame.DataKeyStrings[ArchipelagoItemLocationRandomizer.GameSaveConnectionId] = Client.ConnectionId; saveGame.DataKeyInts[ArchipelagoItemLocationMap.GameItemIndex] = 0; saveGame.DataKeyStrings[ArchipelagoItemLocationRandomizer.GameSavePyramidsKeysUnlock] = slotDataParser.GetPyramidKeysGate().ToString(); saveGame.DataKeyStrings[ArchipelagoItemLocationRandomizer.GameSavePersonalItemIds] = JsonConvert.SerializeObject(slotDataParser.GetPersonalItems()); }; object safeFileManager = screenManager.AsDynamic().SaveFileManager; var gameDifficultyMenu = (GameScreen)GameDifficultyMenuType.CreateInstance(false, safeFileManager, (Action <GameSave.EGameDifficultyType>)OnDifficultySelected); screenManager.AddScreen(gameDifficultyMenu, PlayerIndex.One); console.Close(); return(true); }
void UpdateInput(InputState input) { if (!GameScreen.IsActive) { return; } if (input.IsButtonHold(Buttons.LeftTrigger)) { UpdateDescription(true); DisplaySeedId(); DisplayArchipelagoInfo(); if (input.IsNewButtonPress(Buttons.X)) { Dynamic._isDeleting = false; ShowDeleteAllDialog(); } } else { UpdateDescription(false); } if (input.IsNewButtonPress(Buttons.RightTrigger)) { var selectedSaveFile = CurrentSelectedSave; if (selectedSaveFile == null) { return; } ShowSpoilerGenerationDialog(selectedSaveFile); } if (input.IsControllHold() && input.IsKeyHold(Keys.C)) { var seed = CurrentSelectedSave?.GetSeed(); if (!seed.HasValue) { return; } SDL.SDL_SetClipboardText(seed.Value.ToString()); } if (input.IsNewPressTertiary(null)) { var selectedSaveFile = CurrentSelectedSave; if (selectedSaveFile == null) { return; } //if save is cleared, cancel newgame+ menu if (selectedSaveFile.IsGameCleared) { ScreenManager.RemoveScreen(ScreenManager.FirstOrDefaultTimespinnerOfType(MessageBoxScreenType)); } var seed = selectedSaveFile.GetSeed(); if (seed.HasValue && seed.Value.Options.Archipelago) { ScreenManager.AddScreen(ArchipelagoSelectionScreen.Create(ScreenManager), null); } } }
void OpenSettingsMenu(PlayerIndex playerIndex) { var gameSettingsMenu = GameSettingsScreen.Create(ScreenManager); ScreenManager.AddScreen(gameSettingsMenu, playerIndex); }