PKHeX/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_RTC3.cs
Kurt 11b2dc35d7 Refactor main form into smaller pieces
pkm editor, sav editor, menus, and a manager to glue the storage slots
together
decouples the pkm/sav editors from a static savefile reference.

improves dragdrop/click view/set/delete indication, hides unavailable
contextmenuitems, and fixes a few incorrect references. Box Subviewer
slots now have all the indication/events that the main save editor slots
have.

pls report behavior bugs 👍
2017-05-22 21:55:12 -07:00

78 lines
2.6 KiB
C#

using System;
using System.Windows.Forms;
using PKHeX.Core;
namespace PKHeX.WinForms
{
public partial class SAV_RTC3 : Form
{
private readonly SaveFile Origin;
private readonly SAV3 SAV;
public SAV_RTC3(SaveFile sav)
{
SAV = (SAV3)(Origin = sav).Clone();
InitializeComponent();
WinFormsUtil.TranslateInterface(this, Main.curlanguage);
ClockInitial = SAV.ClockInitial;
ClockElapsed = SAV.ClockElapsed;
loadData();
}
private readonly SAV3.RTC3 ClockInitial;
private readonly SAV3.RTC3 ClockElapsed;
private void loadData()
{
NUD_IDay.Value = ClockInitial.Day;
NUD_IHour.Value = Math.Min(NUD_IHour.Maximum, ClockInitial.Hour);
NUD_IMinute.Value = Math.Min(NUD_IMinute.Maximum, ClockInitial.Minute);
NUD_ISecond.Value = Math.Min(NUD_ISecond.Maximum, ClockInitial.Second);
NUD_EDay.Value = ClockElapsed.Day;
NUD_EHour.Value = Math.Min(NUD_EHour.Maximum, ClockElapsed.Hour);
NUD_EMinute.Value = Math.Min(NUD_EMinute.Maximum, ClockElapsed.Minute);
NUD_ESecond.Value = Math.Min(NUD_ESecond.Maximum, ClockElapsed.Second);
}
private void saveData()
{
ClockInitial.Day = (ushort)NUD_IDay.Value;
ClockInitial.Hour = (byte)NUD_IHour.Value;
ClockInitial.Minute = (byte)NUD_IMinute.Value;
ClockInitial.Second = (byte)NUD_ISecond.Value;
ClockElapsed.Day = (ushort)NUD_EDay.Value;
ClockElapsed.Hour = (byte)NUD_EHour.Value;
ClockElapsed.Minute = (byte)NUD_EMinute.Value;
ClockElapsed.Second = (byte)NUD_ESecond.Value;
}
private void B_Save_Click(object sender, EventArgs e)
{
saveData();
SAV.ClockInitial = ClockInitial;
SAV.ClockElapsed = ClockElapsed;
Origin.setData(SAV.Data, 0);
Close();
}
private void B_Cancel_Click(object sender, EventArgs e)
{
Close();
}
private void B_Reset_Click(object sender, EventArgs e)
{
NUD_IDay.Value = NUD_IHour.Value = NUD_IMinute.Value = NUD_ISecond.Value = 0;
NUD_EDay.Value = NUD_EHour.Value = NUD_EMinute.Value = NUD_ESecond.Value = 0;
System.Media.SystemSounds.Asterisk.Play();
}
private void B_BerryFix_Click(object sender, EventArgs e)
{
NUD_EDay.Value = Math.Max(2*366 + 2, NUD_EDay.Value); // advance
System.Media.SystemSounds.Asterisk.Play();
}
}
}