PKHeX/PKHeX.Avalonia/ViewModels/Subforms/SAVRTC2ViewModel.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

39 lines
1010 B
C#

using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using PKHeX.Core;
namespace PKHeX.Avalonia.ViewModels.Subforms;
/// <summary>
/// ViewModel for the Gen 2 Real-Time Clock editor.
/// Gen 2 Crystal has an RTC flag that can be reset to force re-initialization.
/// </summary>
public partial class SAVRTC2ViewModel : SaveEditorViewModelBase
{
private readonly SAV2 _origin;
private readonly SAV2 _sav;
[ObservableProperty]
private string _statusText = "RTC is running normally. Use Reset to force clock re-initialization on next boot.";
public SAVRTC2ViewModel(SAV2 sav) : base(sav)
{
_origin = sav;
_sav = (SAV2)sav.Clone();
}
[RelayCommand]
private void ResetRtc()
{
_sav.ResetRTC();
StatusText = "RTC reset flag has been SET. The clock will be re-initialized on next boot.";
}
[RelayCommand]
private void Save()
{
_origin.CopyChangesFrom(_sav);
Modified = true;
}
}