private void OnEnterPressed(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { DialogResult = true; nickname = textBoxName.Text; pokemon.Nickname = GBACharacterEncoding.CheckString(nickname, pokemon.Language); Close(); } }
private void OnSaveClicked(object sender, RoutedEventArgs e) { byte[] trainerNameBytes = GBACharacterEncoding.GetBytes(trainerName, 7); string newTrainerName = GBACharacterEncoding.GetString(trainerNameBytes); bool setName = newTrainerName != gameSave.TrainerName; bool setGender = trainerGender != gameSave.TrainerGender; if (setName || setGender) { MessageBoxResult result = TriggerMessageBox.Show(this, "Warning: Renaming a trainer or changing their gender will also change the OT Trainer of every Pokémon caught by this trainer in all saves. Are you sure you want to continue?", "Warning", MessageBoxButton.YesNo); //if (result == MessageBoxResult.Yes && (gameSave.GameType == GameTypes.Ruby || gameSave.GameType == GameTypes.Sapphire || gameSave.GameType == GameTypes.Emerald)) // result = TriggerMessageBox.Show(this, "Warning: Certain scripts may act incorrectly if you change your gender. This includes after you beat the Elite Four where you will get stuck in a wall. Are you sure you want to continue?", "Warning", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { if (setName) { gameSave.TrainerName = GBACharacterEncoding.CheckString(newTrainerName, gameSave.IsJapanese ? Languages.Japanese : Languages.English); } if (setGender) { gameSave.TrainerGender = trainerGender; } for (int i = -1; i < PokeManager.NumGameSaves; i++) { IGameSave newGameSave = PokeManager.GetGameSaveAt(i); if (newGameSave is ManagerGameSave) { for (int j = 0; j < (newGameSave as ManagerGameSave).NumPokePCRows; j++) { foreach (IPokemon pokemon in (newGameSave as ManagerGameSave).GetPokePCRow(j)) { if (pokemon.TrainerID == gameSave.TrainerID && pokemon.SecretID == gameSave.SecretID) { if (setName) { pokemon.TrainerName = newTrainerName; } if (setGender) { pokemon.TrainerGender = trainerGender; } } } } } else { foreach (IPokemon pokemon in newGameSave.PokePC) { if (pokemon.TrainerID == gameSave.TrainerID && pokemon.SecretID == gameSave.SecretID) { if (setName) { pokemon.TrainerName = newTrainerName; } if (setGender) { pokemon.TrainerGender = trainerGender; } } } } } gameSave.IsChanged = true; PokeManager.RefreshUI(); } } DialogResult = true; }