mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-03-21 17:48:28 -05:00
All subform ViewModels now use transactional cancel semantics matching WinForms: edits happen on a clone, Cancel discards them, Save copies the clone back to the origin via CopyChangesFrom. Gen 1-2: SAVEventReset1, SAVHallOfFame1, SAVMisc2, SAVRTC2 Gen 3: SAVRoamer3, SAVSecretBase3, SAVHallOfFame3, SAVRTC3, SAVMisc3, PokeBlock3CaseEditor, SimplePokedex Gen 4: PokeGear4, Trainer4BR, BattlePass4, Gear4, Apricorn4, HoneyTree4, Underground4, Geonet4, PoffinCase4, Pokedex4 Gen 5: Pokedex5, UnityTower5, DLC5 Gen 6: SAVPokepuff6 Gen 7: SAVHallOfFame7 Gen 8 BDSP: Poffin8b, SealStickers8b, Underground8b Cross-gen: EventFlags, EventFlags2, EventWork, Inventory, MailBox, Wondercard, BoxLayout, TrainerStat
44 lines
1023 B
C#
44 lines
1023 B
C#
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
using PKHeX.Core;
|
|
|
|
namespace PKHeX.Avalonia.ViewModels.Subforms;
|
|
|
|
/// <summary>
|
|
/// ViewModel for the Gen 2 Misc editor.
|
|
/// Provides GS Ball event activation for Crystal saves.
|
|
/// </summary>
|
|
public partial class SAVMisc2ViewModel : SaveEditorViewModelBase
|
|
{
|
|
private readonly SAV2 _origin;
|
|
private readonly SAV2 _sav;
|
|
|
|
[ObservableProperty]
|
|
private bool _showGsBallButton;
|
|
|
|
[ObservableProperty]
|
|
private bool _gsBallEnabled;
|
|
|
|
public SAVMisc2ViewModel(SAV2 sav) : base(sav)
|
|
{
|
|
_origin = sav;
|
|
_sav = (SAV2)sav.Clone();
|
|
_showGsBallButton = _sav.Version is GameVersion.C;
|
|
_gsBallEnabled = !_sav.IsEnabledGSBallMobileEvent;
|
|
}
|
|
|
|
[RelayCommand]
|
|
private void EnableGsBall()
|
|
{
|
|
_sav.EnableGSBallMobileEvent();
|
|
GsBallEnabled = false;
|
|
}
|
|
|
|
[RelayCommand]
|
|
private void Save()
|
|
{
|
|
_origin.CopyChangesFrom(_sav);
|
|
Modified = true;
|
|
}
|
|
}
|