PKHeX/PKHeX.Avalonia/ViewModels/Subforms/SAVMisc2ViewModel.cs
montanon 8b3da88a13 Convert all 37 remaining VMs to clone+CopyChangesFrom pattern
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
2026-03-18 15:32:37 -03:00

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;
}
}