2016-06-22 00:35:12 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Windows.Forms;
|
2017-01-08 07:54:09 +00:00
|
|
|
|
using PKHeX.Core;
|
2016-06-22 00:35:12 +00:00
|
|
|
|
|
2017-01-08 07:54:09 +00:00
|
|
|
|
namespace PKHeX.WinForms
|
2016-06-22 00:35:12 +00:00
|
|
|
|
{
|
|
|
|
|
public partial class SAV_SimpleTrainer : Form
|
|
|
|
|
{
|
|
|
|
|
public SAV_SimpleTrainer()
|
|
|
|
|
{
|
2016-12-31 23:45:04 +00:00
|
|
|
|
Loading = true;
|
2016-06-22 00:35:12 +00:00
|
|
|
|
InitializeComponent();
|
2017-01-08 07:54:09 +00:00
|
|
|
|
WinFormsUtil.TranslateInterface(this, Main.curlanguage);
|
2016-06-22 00:35:12 +00:00
|
|
|
|
|
|
|
|
|
cba = new[] {CHK_1, CHK_2, CHK_3, CHK_4, CHK_5, CHK_6, CHK_7, CHK_8};
|
|
|
|
|
TB_OTName.MaxLength = SAV.OTLength;
|
2016-09-09 03:20:32 +00:00
|
|
|
|
B_MaxCash.Click += (sender, e) => MT_Money.Text = SAV.MaxMoney.ToString();
|
2017-02-04 20:13:54 +00:00
|
|
|
|
B_MaxCoins.Click += (sender, e) => MT_Coins.Text = SAV.MaxCoins.ToString();
|
2016-09-09 03:20:32 +00:00
|
|
|
|
MT_Money.Mask = "00000000000".Substring(0, SAV.MaxMoney.ToString().Length);
|
2017-02-04 20:13:54 +00:00
|
|
|
|
MT_Coins.Mask = "00000000000".Substring(0, SAV.MaxCoins.ToString().Length);
|
2016-06-22 00:35:12 +00:00
|
|
|
|
|
2016-07-30 05:36:24 +00:00
|
|
|
|
CB_Gender.Items.Clear();
|
|
|
|
|
CB_Gender.Items.AddRange(Main.gendersymbols.Take(2).ToArray()); // m/f depending on unicode selection
|
|
|
|
|
|
2016-08-30 00:48:05 +00:00
|
|
|
|
L_SID.Visible = MT_SID.Visible = SAV.Generation > 2;
|
|
|
|
|
L_Coins.Visible = B_MaxCoins.Visible = MT_Coins.Visible = SAV.Generation < 3;
|
|
|
|
|
CB_Gender.Visible = SAV.Generation > 1;
|
|
|
|
|
|
2017-01-05 09:14:19 +00:00
|
|
|
|
L_PikaFriend.Visible = MT_PikaFriend.Visible = SAV.Generation == 1;
|
|
|
|
|
|
2016-06-22 00:35:12 +00:00
|
|
|
|
TB_OTName.Text = SAV.OT;
|
|
|
|
|
CB_Gender.SelectedIndex = SAV.Gender;
|
|
|
|
|
MT_TID.Text = SAV.TID.ToString("00000");
|
|
|
|
|
MT_SID.Text = SAV.SID.ToString("00000");
|
|
|
|
|
MT_Money.Text = SAV.Money.ToString();
|
2016-06-26 21:23:41 +00:00
|
|
|
|
MT_Hours.Text = SAV.PlayedHours.ToString();
|
|
|
|
|
MT_Minutes.Text = SAV.PlayedMinutes.ToString();
|
|
|
|
|
MT_Seconds.Text = SAV.PlayedSeconds.ToString();
|
|
|
|
|
|
2016-08-30 00:48:05 +00:00
|
|
|
|
|
|
|
|
|
int badgeval = 0;
|
|
|
|
|
if (SAV is SAV1)
|
|
|
|
|
{
|
|
|
|
|
SAV1 sav1 = (SAV1)SAV;
|
|
|
|
|
MT_Coins.Text = sav1.Coin.ToString();
|
|
|
|
|
badgeval = sav1.Badges;
|
|
|
|
|
|
|
|
|
|
L_Started.Visible = L_Fame.Visible = false;
|
|
|
|
|
CAL_AdventureStartDate.Visible = CAL_HoFDate.Visible = false;
|
|
|
|
|
CAL_AdventureStartTime.Visible = CAL_HoFTime.Visible = false;
|
|
|
|
|
GB_Map.Visible = false;
|
|
|
|
|
GB_Options.Visible = true;
|
|
|
|
|
CB_BattleStyle.Items.AddRange(new[] { "Switch", "Set" });
|
|
|
|
|
CB_SoundType.Items.AddRange(new[] { "Mono", "Stereo", "Earphone2", "Earphone3" });
|
|
|
|
|
CB_TextSpeed.Items.AddRange(new[] { "0 (Instant)", "1 (Fast)", "2", "3 (Normal)", "4", "5 (Slow)", "6", "7" });
|
|
|
|
|
|
|
|
|
|
CHK_BattleEffects.Checked = sav1.BattleEffects;
|
|
|
|
|
CB_BattleStyle.SelectedIndex = sav1.BattleStyleSwitch ? 0 : 1;
|
|
|
|
|
CB_SoundType.SelectedIndex = sav1.Sound;
|
|
|
|
|
CB_TextSpeed.SelectedIndex = sav1.TextSpeed;
|
2017-01-05 09:14:19 +00:00
|
|
|
|
|
|
|
|
|
MT_PikaFriend.Text = sav1.PikaFriendship.ToString();
|
2016-08-30 00:48:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-09-04 01:57:54 +00:00
|
|
|
|
if (SAV is SAV2)
|
|
|
|
|
{
|
|
|
|
|
SAV2 sav2 = (SAV2)SAV;
|
|
|
|
|
MT_Coins.Text = sav2.Coin.ToString();
|
|
|
|
|
|
|
|
|
|
L_Started.Visible = L_Fame.Visible = false;
|
|
|
|
|
CAL_AdventureStartDate.Visible = CAL_HoFDate.Visible = false;
|
|
|
|
|
CAL_AdventureStartTime.Visible = CAL_HoFTime.Visible = false;
|
|
|
|
|
GB_Map.Visible = false;
|
|
|
|
|
GB_Options.Visible = true;
|
|
|
|
|
CB_BattleStyle.Items.AddRange(new[] { "Switch", "Set" });
|
|
|
|
|
CB_SoundType.Items.AddRange(new[] { "Mono", "Stereo" });
|
|
|
|
|
CB_TextSpeed.Items.AddRange(new[] { "0 (Instant)", "1 (Fast)", "2", "3 (Normal)", "4", "5 (Slow)", "6", "7" });
|
|
|
|
|
|
|
|
|
|
CHK_BattleEffects.Checked = sav2.BattleEffects;
|
|
|
|
|
CB_BattleStyle.SelectedIndex = sav2.BattleStyleSwitch ? 0 : 1;
|
|
|
|
|
CB_SoundType.SelectedIndex = sav2.Sound > 0 ? 1 : 0;
|
|
|
|
|
CB_TextSpeed.SelectedIndex = sav2.TextSpeed;
|
|
|
|
|
badgeval = sav2.Badges;
|
|
|
|
|
cba = new[] { CHK_1, CHK_2, CHK_3, CHK_4, CHK_6, CHK_5, CHK_7, CHK_8, CHK_H1, CHK_H2, CHK_H3, CHK_H4, CHK_H5, CHK_H6, CHK_H7, CHK_H8 };
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-26 21:23:41 +00:00
|
|
|
|
if (SAV is SAV3)
|
|
|
|
|
{
|
|
|
|
|
GB_Map.Visible = false;
|
|
|
|
|
GB_Badges.Visible = false; // todo
|
|
|
|
|
|
|
|
|
|
L_Started.Visible = L_Fame.Visible = false;
|
|
|
|
|
CAL_AdventureStartDate.Visible = CAL_HoFDate.Visible = false;
|
|
|
|
|
CAL_AdventureStartTime.Visible = CAL_HoFTime.Visible = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2016-11-26 00:55:17 +00:00
|
|
|
|
if (SAV is SAV3Colosseum || SAV is SAV3XD)
|
|
|
|
|
{
|
|
|
|
|
GB_Map.Visible = false;
|
|
|
|
|
GB_Badges.Visible = false;
|
|
|
|
|
L_Started.Visible = L_Fame.Visible = false;
|
|
|
|
|
CAL_AdventureStartDate.Visible = CAL_HoFDate.Visible = false;
|
|
|
|
|
CAL_AdventureStartTime.Visible = CAL_HoFTime.Visible = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2016-06-22 00:35:12 +00:00
|
|
|
|
|
|
|
|
|
if (SAV is SAV4)
|
|
|
|
|
{
|
|
|
|
|
SAV4 s = (SAV4)SAV;
|
2017-01-01 01:19:35 +00:00
|
|
|
|
NUD_M.Value = s.M;
|
|
|
|
|
NUD_X.Value = s.X;
|
|
|
|
|
NUD_Z.Value = s.Z;
|
|
|
|
|
NUD_Y.Value = s.Y;
|
2016-06-22 00:35:12 +00:00
|
|
|
|
|
|
|
|
|
badgeval = s.Badges;
|
|
|
|
|
if (s.Version == GameVersion.HGSS)
|
|
|
|
|
{
|
|
|
|
|
badgeval |= s.Badges16 << 8;
|
|
|
|
|
cba = cba.Concat(new[] {CHK_H1, CHK_H2, CHK_H3, CHK_H4, CHK_H5, CHK_H6, CHK_H7, CHK_H8}).ToArray();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (SAV is SAV5)
|
|
|
|
|
{
|
|
|
|
|
SAV5 s = (SAV5)SAV;
|
2017-01-01 01:19:35 +00:00
|
|
|
|
NUD_M.Value = s.M;
|
|
|
|
|
NUD_X.Value = s.X;
|
|
|
|
|
NUD_Z.Value = s.Z;
|
|
|
|
|
NUD_Y.Value = s.Y;
|
2016-06-22 00:35:12 +00:00
|
|
|
|
|
|
|
|
|
badgeval = s.Badges;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < cba.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
cba[i].Visible = true;
|
|
|
|
|
cba[i].Checked = (badgeval & 1 << i) != 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CAL_HoFDate.Value = new DateTime(2000, 1, 1).AddSeconds(SAV.SecondsToFame);
|
|
|
|
|
CAL_HoFTime.Value = new DateTime(2000, 1, 1).AddSeconds(SAV.SecondsToFame % 86400);
|
|
|
|
|
CAL_AdventureStartDate.Value = new DateTime(2000, 1, 1).AddSeconds(SAV.SecondsToStart);
|
|
|
|
|
CAL_AdventureStartTime.Value = new DateTime(2000, 1, 1).AddSeconds(SAV.SecondsToStart % 86400);
|
2016-12-31 23:45:04 +00:00
|
|
|
|
|
|
|
|
|
Loading = false;
|
2016-06-22 00:35:12 +00:00
|
|
|
|
}
|
|
|
|
|
private readonly CheckBox[] cba;
|
|
|
|
|
private readonly SaveFile SAV = Main.SAV.Clone();
|
2016-12-31 23:45:04 +00:00
|
|
|
|
private readonly bool Loading;
|
|
|
|
|
private bool MapUpdated;
|
|
|
|
|
|
2016-06-22 00:35:12 +00:00
|
|
|
|
private void changeFFFF(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
MaskedTextBox box = sender as MaskedTextBox;
|
|
|
|
|
if (box.Text == "") box.Text = "0";
|
|
|
|
|
if (Util.ToInt32(box.Text) > 65535) box.Text = "65535";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void B_Save_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
SAV.OT = TB_OTName.Text;
|
|
|
|
|
SAV.Gender = (byte)CB_Gender.SelectedIndex;
|
|
|
|
|
|
|
|
|
|
SAV.TID = (ushort)Util.ToUInt32(MT_TID.Text);
|
|
|
|
|
SAV.SID = (ushort)Util.ToUInt32(MT_SID.Text);
|
|
|
|
|
SAV.Money = Util.ToUInt32(MT_Money.Text);
|
|
|
|
|
|
2016-06-26 21:23:41 +00:00
|
|
|
|
SAV.PlayedHours = ushort.Parse(MT_Hours.Text);
|
|
|
|
|
SAV.PlayedMinutes = ushort.Parse(MT_Minutes.Text) % 60;
|
|
|
|
|
SAV.PlayedSeconds = ushort.Parse(MT_Seconds.Text) % 60;
|
|
|
|
|
|
2016-06-22 00:35:12 +00:00
|
|
|
|
// Copy Badges
|
|
|
|
|
int badgeval = 0;
|
|
|
|
|
for (int i = 0; i < cba.Length; i++)
|
|
|
|
|
badgeval |= (cba[i].Checked ? 1 : 0) << i;
|
|
|
|
|
|
2016-08-30 00:48:05 +00:00
|
|
|
|
if (SAV is SAV1)
|
|
|
|
|
{
|
|
|
|
|
SAV1 sav1 = (SAV1) SAV;
|
2017-02-04 20:13:54 +00:00
|
|
|
|
sav1.Coin = (ushort)Math.Min(Util.ToUInt32(MT_Coins.Text), SAV.MaxCoins);
|
2016-08-30 00:48:05 +00:00
|
|
|
|
sav1.Badges = badgeval & 0xFF;
|
|
|
|
|
|
2017-01-05 09:14:19 +00:00
|
|
|
|
var pf = Util.ToUInt32(MT_PikaFriend.Text);
|
|
|
|
|
if (pf > 255)
|
|
|
|
|
pf = 255;
|
|
|
|
|
sav1.PikaFriendship = (byte) pf;
|
|
|
|
|
|
2016-08-30 00:48:05 +00:00
|
|
|
|
sav1.BattleEffects = CHK_BattleEffects.Checked;
|
|
|
|
|
sav1.BattleStyleSwitch = CB_BattleStyle.SelectedIndex == 0;
|
|
|
|
|
sav1.Sound = CB_SoundType.SelectedIndex;
|
|
|
|
|
sav1.TextSpeed = CB_TextSpeed.SelectedIndex;
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-04 01:57:54 +00:00
|
|
|
|
if (SAV is SAV2)
|
|
|
|
|
{
|
|
|
|
|
SAV2 sav2 = (SAV2)SAV;
|
2017-02-04 20:13:54 +00:00
|
|
|
|
sav2.Coin = (ushort)Math.Min(Util.ToUInt32(MT_Coins.Text), SAV.MaxCoins);
|
2016-09-04 01:57:54 +00:00
|
|
|
|
sav2.Badges = badgeval & 0xFFFF;
|
|
|
|
|
|
|
|
|
|
sav2.BattleEffects = CHK_BattleEffects.Checked;
|
|
|
|
|
sav2.BattleStyleSwitch = CB_BattleStyle.SelectedIndex == 0;
|
|
|
|
|
sav2.Sound = CB_SoundType.SelectedIndex > 0 ? 2 : 0;
|
|
|
|
|
sav2.TextSpeed = CB_TextSpeed.SelectedIndex;
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-22 00:35:12 +00:00
|
|
|
|
if (SAV is SAV4)
|
|
|
|
|
{
|
|
|
|
|
SAV4 s = (SAV4)SAV;
|
2017-01-01 01:19:35 +00:00
|
|
|
|
if (MapUpdated)
|
|
|
|
|
{
|
|
|
|
|
s.M = (int)NUD_M.Value;
|
|
|
|
|
s.X = (int)NUD_X.Value;
|
|
|
|
|
s.Z = (int)NUD_Z.Value;
|
|
|
|
|
s.Y = (int)NUD_Y.Value;
|
|
|
|
|
}
|
2016-06-22 00:35:12 +00:00
|
|
|
|
s.Badges = badgeval & 0xFF;
|
|
|
|
|
if (s.Version == GameVersion.HGSS)
|
|
|
|
|
{
|
|
|
|
|
s.Badges16 = badgeval >> 8;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (SAV is SAV5)
|
|
|
|
|
{
|
|
|
|
|
SAV5 s = (SAV5)SAV;
|
2017-01-01 01:19:35 +00:00
|
|
|
|
if (MapUpdated)
|
|
|
|
|
{
|
|
|
|
|
s.M = (int)NUD_M.Value;
|
|
|
|
|
s.X = (int)NUD_X.Value;
|
|
|
|
|
s.Z = (int)NUD_Z.Value;
|
|
|
|
|
s.Y = (int)NUD_Y.Value;
|
|
|
|
|
}
|
2016-06-22 00:35:12 +00:00
|
|
|
|
s.Badges = badgeval & 0xFF;
|
|
|
|
|
}
|
2016-06-26 21:23:41 +00:00
|
|
|
|
|
2016-06-22 00:35:12 +00:00
|
|
|
|
SAV.SecondsToStart = getSeconds(CAL_AdventureStartDate, CAL_AdventureStartTime);
|
|
|
|
|
SAV.SecondsToFame = getSeconds(CAL_HoFDate, CAL_HoFTime);
|
|
|
|
|
|
|
|
|
|
SAV.Data.CopyTo(Main.SAV.Data, 0);
|
|
|
|
|
Main.SAV.Edited = true;
|
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
private void B_Cancel_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
private int getSeconds(DateTimePicker date, DateTimePicker time)
|
|
|
|
|
{
|
|
|
|
|
int val = (int)(date.Value - new DateTime(2000, 1, 1)).TotalSeconds;
|
|
|
|
|
val -= val % 86400;
|
|
|
|
|
val += (int)(time.Value - new DateTime(2000, 1, 1)).TotalSeconds;
|
|
|
|
|
return val;
|
|
|
|
|
}
|
2016-12-31 23:45:04 +00:00
|
|
|
|
private void changeMapValue(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!Loading)
|
|
|
|
|
MapUpdated = true;
|
|
|
|
|
}
|
2016-06-22 00:35:12 +00:00
|
|
|
|
}
|
|
|
|
|
}
|