Refresh Trainer Editor on ability change

This commit is contained in:
Miguel Terol Espino 2024-03-17 14:52:09 +01:00
parent 3f2f5c0731
commit 2e8a44343e
2 changed files with 17 additions and 0 deletions

View File

@ -7767,6 +7767,16 @@ namespace DSPRE {
}
}
}
public void RefreshAbilities(int forPokemon) {
DialogResult res = MessageBox.Show("You have modified a Pokemon's ability.\nDo you wish to refresh the Trainer Editor so your changes are available?", "Refresh Trainer Editor", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (res.Equals(DialogResult.Yes)) {
int currentIndex = trainerComboBox.SelectedIndex;
SetupTrainerEditor();
trainerComboBox.SelectedIndex = currentIndex;
}
}
private void SetupTrainerEditor() {
Helpers.DisableHandlers();

View File

@ -18,6 +18,7 @@ namespace DSPRE {
private PokemonPersonalData currentLoadedFile = null;
private static bool dirty = false;
private bool modifiedAbilities = false;
private static readonly string formName = "Personal Data Editor";
PokemonEditor _parent;
@ -275,6 +276,7 @@ namespace DSPRE {
}
currentLoadedFile.firstAbility = (byte)ability1InputComboBox.SelectedIndex;
setDirty(true);
modifiedAbilities = true;
}
private void ability2InputComboBox_SelectedIndexChanged(object sender, EventArgs e) {
if (Helpers.HandlersDisabled) {
@ -282,6 +284,7 @@ namespace DSPRE {
}
currentLoadedFile.secondAbility = (byte)ability2InputComboBox.SelectedIndex;
setDirty(true);
modifiedAbilities = true;
}
private void eggGroup1InputCombobox_SelectedIndexChanged(object sender, EventArgs e) {
if (Helpers.HandlersDisabled) {
@ -391,6 +394,10 @@ namespace DSPRE {
}
private void saveDataButton_Click(object sender, EventArgs e) {
currentLoadedFile.SaveToFileDefaultDir(currentLoadedId, true);
if (modifiedAbilities) {
EditorPanels.MainProgram.RefreshAbilities(currentLoadedId);
modifiedAbilities = false;
}
setDirty(false);
}
//-------------------------------