Merge branch 'kwsch-master'

This commit is contained in:
easyworld 2016-08-11 20:08:18 +08:00
commit b19cace7cf
2256 changed files with 1856 additions and 197 deletions

View file

@ -1,7 +1,13 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual C# Express 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PKHeX", "PKHeX.csproj", "{B4EFF030-C75A-49F9-A4BC-738D1B61C4AF}"
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PKHeX", "PKHeX\PKHeX.csproj", "{B4EFF030-C75A-49F9-A4BC-738D1B61C4AF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PKHeX.Tests", "Tests\PKHeX.Tests\PKHeX.Tests.csproj", "{8E2499BC-C11A-4809-8737-66D35A625425}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{7C0598C9-DDF3-4ACC-B15D-6A626ADB7530}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -13,8 +19,15 @@ Global
{B4EFF030-C75A-49F9-A4BC-738D1B61C4AF}.Debug|x86.Build.0 = Debug|x86
{B4EFF030-C75A-49F9-A4BC-738D1B61C4AF}.Release|x86.ActiveCfg = Release|x86
{B4EFF030-C75A-49F9-A4BC-738D1B61C4AF}.Release|x86.Build.0 = Release|x86
{8E2499BC-C11A-4809-8737-66D35A625425}.Debug|x86.ActiveCfg = Debug|x86
{8E2499BC-C11A-4809-8737-66D35A625425}.Debug|x86.Build.0 = Debug|x86
{8E2499BC-C11A-4809-8737-66D35A625425}.Release|x86.ActiveCfg = Release|x86
{8E2499BC-C11A-4809-8737-66D35A625425}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{8E2499BC-C11A-4809-8737-66D35A625425} = {7C0598C9-DDF3-4ACC-B15D-6A626ADB7530}
EndGlobalSection
EndGlobal

View file

@ -399,6 +399,7 @@ namespace PKHeX
386, // Deoxys
487, // Giratina
492, // Shaymin
720, // Hoopa
};
internal static readonly int[] BreedMaleOnly =
{

View file

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Deployment.Application;
using System.Diagnostics;
using System.Drawing;
using System.IO;
@ -119,7 +118,7 @@ namespace PKHeX
if (path != null && File.Exists(path))
openQuick(path, force: true);
else
GB_SAVtools.Visible = false;
loadSAV(SAV, null);
}
// Splash Screen closes on its own.
@ -177,7 +176,7 @@ namespace PKHeX
#region Path Variables
public static string WorkingDirectory => ApplicationDeployment.IsNetworkDeployed ? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "PKHeX") : Environment.CurrentDirectory;
public static string WorkingDirectory => Environment.CurrentDirectory;
public static string DatabasePath => Path.Combine(WorkingDirectory, "db");
private static string WC6DatabasePath => Path.Combine(WorkingDirectory, "wc6");
private static string BackupPath => Path.Combine(WorkingDirectory, "bak");
@ -264,7 +263,7 @@ namespace PKHeX
}
private void mainMenuExit(object sender, EventArgs e)
{
if (ModifierKeys == (Keys.Control | Keys.Q)) // Hotkey Triggered
if (ModifierKeys == Keys.Control) // Hotkey Triggered
if (DialogResult.Yes != Util.Prompt(MessageBoxButtons.YesNo, "Quit PKHeX?")) return;
Close();
}
@ -290,11 +289,11 @@ namespace PKHeX
if (z != null)
{ Util.CenterToForm(z, this); z.BringToFront(); return; }
if (Directory.Exists("db"))
if (Directory.Exists(DatabasePath))
new SAV_Database(this).Show();
else
Util.Alert("PKHeX's database was not found",
"Please dump all boxes from a save file, then ensure the 'db' folder exists.");
Util.Alert("PKHeX's database was not found.",
$"Please dump all boxes from a save file, then ensure the '{DatabasePath}' folder exists.");
}
private void mainMenuUnicode(object sender, EventArgs e)
{
@ -740,53 +739,76 @@ namespace PKHeX
sav.Personal = drFRLG == DialogResult.Yes ? PersonalTable.FR : PersonalTable.LG;
}
}
loadSAV(sav, path);
}
private void loadSAV(SaveFile sav, string path)
{
PKM pk = preparePKM();
SAV = sav;
SAV.FilePath = Path.GetDirectoryName(path);
SAV.FileName = Path.GetExtension(path) == ".bak"
? Path.GetFileName(path)?.Split(new[] {" ["}, StringSplitOptions.None)[0]
: Path.GetFileName(path);
L_Save.Text = $"SAV{SAV.Generation}: {Path.GetFileNameWithoutExtension(Util.CleanFileName(SAV.BAKName))}"; // more descriptive
if (path != null) // Actual save file
{
SAV.FilePath = Path.GetDirectoryName(path);
SAV.FileName = Path.GetExtension(path) == ".bak"
? Path.GetFileName(path).Split(new[] { " [" }, StringSplitOptions.None)[0]
: Path.GetFileName(path);
L_Save.Text = $"SAV{SAV.Generation}: {Path.GetFileNameWithoutExtension(Util.CleanFileName(SAV.BAKName))}"; // more descriptive
// If backup folder exists, save a backup.
string backupName = Path.Combine(BackupPath, Util.CleanFileName(SAV.BAKName));
if (SAV.Exportable && Directory.Exists(BackupPath) && !File.Exists(backupName))
File.WriteAllBytes(backupName, SAV.BAK);
GB_SAVtools.Visible = true;
}
else // Blank save file
{
SAV.FilePath = null;
SAV.FileName = "Blank Save File";
L_Save.Text = $"SAV{SAV.Generation}: {SAV.FileName} [{SAV.OT} ({SAV.Version})]";
GB_SAVtools.Visible = false;
}
Menu_ExportSAV.Enabled = B_VerifyCHK.Enabled = SAV.Exportable;
setBoxNames(); // Display the Box Names
if (SAV.HasBox)
{
int startBox = SAV.CurrentBox; // FF if BattleBox
int startBox = path == null ? 0 : SAV.CurrentBox; // FF if BattleBox
if (startBox > SAV.BoxCount - 1) { tabBoxMulti.SelectedIndex = 1; CB_BoxSelect.SelectedIndex = 0; }
else { tabBoxMulti.SelectedIndex = 0; CB_BoxSelect.SelectedIndex = startBox; }
}
setPKXBoxes(); // Reload all of the PKX Windows
// Hide content if not present in game.
GB_SAVtools.Visible = true;
GB_SUBE.Visible = SAV.HasSUBE;
PB_Locked.Visible = SAV.HasBattleBox && SAV.BattleBoxLocked;
PAN_Box.Visible = CB_BoxSelect.Visible = B_BoxLeft.Visible = B_BoxRight.Visible = SAV.HasBox;
Menu_LoadBoxes.Enabled = Menu_DumpBoxes.Enabled = Menu_Report.Enabled = Menu_Modify.Enabled = B_SaveBoxBin.Enabled = SAV.HasBox;
PAN_BattleBox.Visible = L_BattleBox.Visible = L_ReadOnlyPBB.Visible = SAV.HasBattleBox;
GB_Daycare.Visible = SAV.HasDaycare;
GB_Fused.Visible = SAV.HasFused;
GB_GTS.Visible = SAV.HasGTS;
B_OpenSecretBase.Visible = SAV.HasSecretBase;
B_OpenPokepuffs.Visible = SAV.HasPuff;
B_OUTPasserby.Visible = SAV.HasPSS;
B_OpenBoxLayout.Visible = SAV.HasBoxWallpapers;
B_OpenWondercards.Visible = SAV.HasWondercards;
B_OpenSuperTraining.Visible = SAV.HasSuperTrain;
B_OpenHallofFame.Visible = SAV.HasHoF;
B_OpenOPowers.Visible = SAV.HasOPower;
B_OpenPokedex.Visible = SAV.HasPokeDex;
B_OpenBerryField.Visible = SAV.HasBerryField;
B_Pokeblocks.Visible = SAV.HasPokeBlock;
B_JPEG.Visible = SAV.HasJPEG;
B_OpenEventFlags.Visible = SAV.HasEvents;
B_LinkInfo.Visible = SAV.HasLink;
B_CGearSkin.Visible = SAV.Generation == 5;
if (GB_SAVtools.Visible)
{
PAN_BattleBox.Visible = L_BattleBox.Visible = L_ReadOnlyPBB.Visible = SAV.HasBattleBox;
GB_Daycare.Visible = SAV.HasDaycare;
GB_Fused.Visible = SAV.HasFused;
GB_GTS.Visible = SAV.HasGTS;
B_OpenSecretBase.Visible = SAV.HasSecretBase;
B_OpenPokepuffs.Visible = SAV.HasPuff;
B_OUTPasserby.Visible = SAV.HasPSS;
B_OpenBoxLayout.Visible = SAV.HasBoxWallpapers;
B_OpenWondercards.Visible = SAV.HasWondercards;
B_OpenSuperTraining.Visible = SAV.HasSuperTrain;
B_OpenHallofFame.Visible = SAV.HasHoF;
B_OpenOPowers.Visible = SAV.HasOPower;
B_OpenPokedex.Visible = SAV.HasPokeDex;
B_OpenBerryField.Visible = SAV.HasBerryField;
B_Pokeblocks.Visible = SAV.HasPokeBlock;
B_JPEG.Visible = SAV.HasJPEG;
B_OpenEventFlags.Visible = SAV.HasEvents;
B_LinkInfo.Visible = SAV.HasLink;
B_CGearSkin.Visible = SAV.Generation == 5;
}
// Generational Interface
byte[] extraBytes = new byte[1];
@ -800,7 +822,7 @@ namespace PKHeX
PB_MarkPentagon.Visible = SAV.Generation == 6;
PB_Legal.Visible = PB_WarnMove1.Visible = PB_WarnMove2.Visible = PB_WarnMove3.Visible = PB_WarnMove4.Visible = SAV.Generation == 6;
TB_GameSync.Visible = TB_Secure1.Visible = TB_Secure2.Visible = L_GameSync.Visible = L_Secure1.Visible = L_Secure2.Visible = SAV.Generation == 6;
TB_GameSync.Visible = TB_Secure1.Visible = TB_Secure2.Visible = L_GameSync.Visible = L_Secure1.Visible = L_Secure2.Visible = SAV.Exportable && SAV.Generation == 6;
CB_Form.Visible = Label_Form.Visible = CHK_AsEgg.Visible = GB_EggConditions.Visible =
Label_MetDate.Visible = CAL_MetDate.Visible = PB_Mark5.Visible = PB_Mark6.Visible = SAV.Generation >= 4;
@ -866,11 +888,6 @@ namespace PKHeX
// Refresh PK#->PK6 conversion info
PKMConverter.updateConfig(SAV.SubRegion, SAV.Country, SAV.ConsoleRegion, SAV.OT, SAV.Gender);
// If backup folder exists, save a backup.
string backupName = Path.Combine(BackupPath, Util.CleanFileName(SAV.BAKName));
if (SAV.Exportable && Directory.Exists(BackupPath) && !File.Exists(backupName))
File.WriteAllBytes(backupName, SAV.BAK);
// Indicate audibly the save is loaded
SystemSounds.Beep.Play();
}

View file

@ -41,10 +41,14 @@ namespace PKHeX
CB_EncounterType.SelectedValue = pk4.Gen4 ? pk4.EncounterType : 0;
CB_Ball.SelectedValue = pk4.Ball;
if (pk4.Met_Month == 0) { pk4.Met_Month = 1; }
if (pk4.Met_Day == 0) { pk4.Met_Day = 1; }
try { CAL_MetDate.Value = new DateTime(pk4.Met_Year + 2000, pk4.Met_Month, pk4.Met_Day); }
catch { CAL_MetDate.Value = new DateTime(2000, 1, 1); }
if (pk4.MetDate.HasValue)
{
CAL_MetDate.Value = pk4.MetDate.Value;
}
else
{
CAL_MetDate.Value = new DateTime(2000, 1, 1);
}
if (pk4.Egg_Location != 0)
{
@ -53,8 +57,14 @@ namespace PKHeX
GB_EggConditions.Enabled = true;
CB_EggLocation.SelectedValue = pk4.Egg_Location;
try { CAL_EggDate.Value = new DateTime(pk4.Egg_Year + 2000, pk4.Egg_Month, pk4.Egg_Day); }
catch { CAL_MetDate.Value = new DateTime(2000, 1, 1); }
if (pk4.EggMetDate.HasValue)
{
CAL_EggDate.Value = pk4.EggMetDate.Value;
}
else
{
CAL_EggDate.Value = new DateTime(2000, 1, 1);
}
}
else { CAL_EggDate.Value = new DateTime(2000, 01, 01); CHK_AsEgg.Checked = GB_EggConditions.Enabled = false; CB_EggLocation.SelectedValue = 0; }
@ -194,30 +204,22 @@ namespace PKHeX
pk4.Language = Util.getIndex(CB_Language);
// Default Dates
int egg_year = 2000;
int egg_month = 0;
int egg_day = 0;
DateTime? egg_date = null;
int egg_location = 0;
if (CHK_AsEgg.Checked) // If encountered as an egg, load the Egg Met data from fields.
{
egg_year = CAL_EggDate.Value.Year;
egg_month = CAL_EggDate.Value.Month;
egg_day = CAL_EggDate.Value.Day;
egg_date = CAL_EggDate.Value;
egg_location = Util.getIndex(CB_EggLocation);
}
// Egg Met Data
pk4.Egg_Year = egg_year - 2000;
pk4.Egg_Month = egg_month;
pk4.Egg_Day = egg_day;
pk4.EggMetDate = egg_date;
pk4.Egg_Location = egg_location;
// Met Data
pk4.Met_Year = CAL_MetDate.Value.Year - 2000;
pk4.Met_Month = CAL_MetDate.Value.Month;
pk4.Met_Day = CAL_MetDate.Value.Day;
pk4.MetDate = CAL_MetDate.Value;
pk4.Met_Location = Util.getIndex(CB_MetLocation);
if (pk4.IsEgg && pk4.Met_Location == 0) // If still an egg, it has no hatch location/date. Zero it!
pk4.Met_Year = pk4.Met_Month = pk4.Met_Day = 0;
pk4.MetDate = null;
// Toss in Party Stats
Array.Resize(ref pk4.Data, pk4.SIZE_PARTY);

View file

@ -50,10 +50,14 @@ namespace PKHeX
CB_EncounterType.SelectedValue = pk5.Gen4 ? pk5.EncounterType : 0;
CB_Ball.SelectedValue = pk5.Ball;
if (pk5.Met_Month == 0) { pk5.Met_Month = 1; }
if (pk5.Met_Day == 0) { pk5.Met_Day = 1; }
try { CAL_MetDate.Value = new DateTime(pk5.Met_Year + 2000, pk5.Met_Month, pk5.Met_Day); }
catch { CAL_MetDate.Value = new DateTime(2000, 1, 1); }
if (pk5.MetDate.HasValue)
{
CAL_MetDate.Value = pk5.MetDate.Value;
}
else
{
CAL_MetDate.Value = new DateTime(2000, 1, 1);
}
if (pk5.Egg_Location != 0)
{
@ -62,8 +66,14 @@ namespace PKHeX
GB_EggConditions.Enabled = true;
CB_EggLocation.SelectedValue = pk5.Egg_Location;
try { CAL_EggDate.Value = new DateTime(pk5.Egg_Year + 2000, pk5.Egg_Month, pk5.Egg_Day); }
catch { CAL_MetDate.Value = new DateTime(2000, 1, 1); }
if (pk5.EggMetDate.HasValue)
{
CAL_EggDate.Value = pk5.EggMetDate.Value;
}
else
{
CAL_EggDate.Value = new DateTime(2000, 1, 1);
}
}
else { CAL_EggDate.Value = new DateTime(2000, 01, 01); CHK_AsEgg.Checked = GB_EggConditions.Enabled = false; CB_EggLocation.SelectedValue = 0; }
@ -200,30 +210,22 @@ namespace PKHeX
pk5.CurrentFriendship = Util.ToInt32(TB_Friendship.Text);
// Default Dates
int egg_year = 2000;
int egg_month = 0;
int egg_day = 0;
DateTime? egg_date = null;
int egg_location = 0;
if (CHK_AsEgg.Checked) // If encountered as an egg, load the Egg Met data from fields.
if (CHK_AsEgg.Checked) // If encountered as an egg, load the Egg Met data from fields.
{
egg_year = CAL_EggDate.Value.Year;
egg_month = CAL_EggDate.Value.Month;
egg_day = CAL_EggDate.Value.Day;
egg_date = CAL_EggDate.Value;
egg_location = Util.getIndex(CB_EggLocation);
}
// Egg Met Data
pk5.Egg_Year = egg_year - 2000;
pk5.Egg_Month = egg_month;
pk5.Egg_Day = egg_day;
pk5.EggMetDate = egg_date;
pk5.Egg_Location = egg_location;
// Met Data
pk5.Met_Year = CAL_MetDate.Value.Year - 2000;
pk5.Met_Month = CAL_MetDate.Value.Month;
pk5.Met_Day = CAL_MetDate.Value.Day;
pk5.MetDate = CAL_MetDate.Value;
pk5.Met_Location = Util.getIndex(CB_MetLocation);
if (pk5.IsEgg && pk5.Met_Location == 0) // If still an egg, it has no hatch location/date. Zero it!
pk5.Met_Year = pk5.Met_Month = pk5.Met_Day = 0;
pk5.MetDate = null;
pk5.Ball = Util.getIndex(CB_Ball);
pk5.Met_Level = Util.ToInt32(TB_MetLevel.Text);

View file

@ -57,10 +57,14 @@ namespace PKHeX
CB_EncounterType.SelectedValue = pk6.Gen4 ? pk6.EncounterType : 0;
CB_Ball.SelectedValue = pk6.Ball;
if (pk6.Met_Month == 0) { pk6.Met_Month = 1; }
if (pk6.Met_Day == 0) { pk6.Met_Day = 1; }
try { CAL_MetDate.Value = new DateTime(pk6.Met_Year + 2000, pk6.Met_Month, pk6.Met_Day); }
catch { CAL_MetDate.Value = new DateTime(2000, 1, 1); }
if (pk6.MetDate.HasValue)
{
CAL_MetDate.Value = pk6.MetDate.Value;
}
else
{
CAL_MetDate.Value = new DateTime(2000, 1, 1);
}
if (pk6.Egg_Location != 0)
{
@ -69,8 +73,14 @@ namespace PKHeX
GB_EggConditions.Enabled = true;
CB_EggLocation.SelectedValue = pk6.Egg_Location;
try { CAL_EggDate.Value = new DateTime(pk6.Egg_Year + 2000, pk6.Egg_Month, pk6.Egg_Day); }
catch { CAL_MetDate.Value = new DateTime(2000, 1, 1); }
if (pk6.EggMetDate.HasValue)
{
CAL_EggDate.Value = pk6.EggMetDate.Value;
}
else
{
CAL_EggDate.Value = new DateTime(2000, 1, 1);
}
}
else { CAL_EggDate.Value = new DateTime(2000, 01, 01); CHK_AsEgg.Checked = GB_EggConditions.Enabled = false; CB_EggLocation.SelectedValue = 0; }
@ -263,30 +273,22 @@ namespace PKHeX
pk6.OT_Name = TB_OT.Text;
pk6.CurrentFriendship = Util.ToInt32(TB_Friendship.Text);
int egg_year = 2000; // Default Dates
int egg_month = 0;
int egg_day = 0;
DateTime? egg_date = null;
int egg_location = 0;
if (CHK_AsEgg.Checked) // If encountered as an egg, load the Egg Met data from fields.
{
egg_year = CAL_EggDate.Value.Year;
egg_month = CAL_EggDate.Value.Month;
egg_day = CAL_EggDate.Value.Day;
egg_date = CAL_EggDate.Value;
egg_location = Util.getIndex(CB_EggLocation);
}
// Egg Met Data
pk6.Egg_Year = egg_year - 2000;
pk6.Egg_Month = egg_month;
pk6.Egg_Day = egg_day;
pk6.EggMetDate = egg_date;
pk6.Egg_Location = egg_location;
// Met Data
pk6.Met_Year = CAL_MetDate.Value.Year - 2000;
pk6.Met_Month = CAL_MetDate.Value.Month;
pk6.Met_Day = CAL_MetDate.Value.Day;
pk6.MetDate = CAL_MetDate.Value;
pk6.Met_Location = Util.getIndex(CB_MetLocation);
if (pk6.IsEgg && pk6.Met_Location == 0) // If still an egg, it has no hatch location/date. Zero it!
pk6.Met_Year = pk6.Met_Month = pk6.Met_Day = 0;
pk6.MetDate = null;
// 0xD7 Unknown

View file

@ -90,9 +90,48 @@ namespace PKHeX
// Card Attributes
public override int Item { get { return BitConverter.ToUInt16(Data, 0x00); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x00); } }
public ushort Year { get { return BitConverter.ToUInt16(Data, 0xAE); } set { BitConverter.GetBytes(value).CopyTo(Data, 0xAE); } }
public byte Month { get { return Data[0xAD]; } set { Data[0xAD] = value; } }
public byte Day { get { return Data[0xAC]; } set { Data[0xAC] = value; } }
private ushort Year { get { return BitConverter.ToUInt16(Data, 0xAE); } set { BitConverter.GetBytes(value).CopyTo(Data, 0xAE); } }
private byte Month { get { return Data[0xAD]; } set { Data[0xAD] = value; } }
private byte Day { get { return Data[0xAC]; } set { Data[0xAC] = value; } }
/// <summary>
/// Gets or sets the date of the card.
/// </summary>
public DateTime? Date
{
get
{
// Check to see if date is valid
if (!Util.IsDateValid(2000 + Year, Month, Day))
{
return null;
}
else
{
return new DateTime(2000 + Year, Month, Day);
}
}
set
{
if (value.HasValue)
{
// Only update the properties if a value is provided.
Year = (ushort)(value.Value.Year - 2000);
Month = (byte)value.Value.Month;
Day = (byte)value.Value.Day;
}
else
{
// Clear the Met Date.
// If code tries to access MetDate again, null will be returned.
Year = 0;
Month = 0;
Day = 0;
}
}
}
public override int CardID
{
get { return BitConverter.ToUInt16(Data, 0xB0); }
@ -151,9 +190,7 @@ namespace PKHeX
Move3 = Move3,
Move4 = Move4,
Met_Location = MetLocation,
Met_Day = Day,
Met_Month = Month,
Met_Year = Year - 2000,
MetDate = Date,
Egg_Location = EggLocation,
CNT_Cool = CNT_Cool,
CNT_Beauty = CNT_Beauty,
@ -255,9 +292,7 @@ namespace PKHeX
if (IsEgg)
{
// pk.IsEgg = true;
pk.Egg_Day = Day;
pk.Egg_Month = Month;
pk.Egg_Year = Year - 2000;
pk.EggMetDate = Date;
// Force hatch
pk.IsEgg = false;
pk.Met_Location = 4; // Nuvema Town

View file

@ -181,22 +181,17 @@ namespace PKHeX
}
// Generate Met Info
DateTime dt = DateTime.Now;
if (IsPokémon)
{
pk4.Met_Location = pk4.Egg_Location + 3000;
pk4.Egg_Location = 0;
pk4.Met_Day = dt.Day;
pk4.Met_Month = dt.Month;
pk4.Met_Year = dt.Year - 2000;
pk4.MetDate = DateTime.Now;
pk4.IsEgg = false;
}
else
{
pk4.Egg_Location = pk4.Egg_Location + 3000;
pk4.Egg_Day = dt.Day;
pk4.Egg_Month = dt.Month;
pk4.Egg_Year = dt.Year - 2000;
pk4.MetDate = DateTime.Now;
pk4.IsEgg = false;
// Met Location is modified when transferred to pk5; don't worry about it.
}

View file

@ -31,18 +31,56 @@ namespace PKHeX
public override string CardTitle { // Max len 36 char, followed by null terminator
get { return Util.TrimFromZero(Encoding.Unicode.GetString(Data, 2, 72)); }
set { Encoding.Unicode.GetBytes(value.PadRight(36, '\0')).CopyTo(Data, 2); } }
private uint Date {
private uint RawDate {
get { return BitConverter.ToUInt32(Data, 0x4C); }
set { BitConverter.GetBytes(value).CopyTo(Data, 0x4C); } }
public uint Year {
get { return Date/10000; }
set { Date = value*10000 + Date%10000; } }
public uint Month {
get { return Date%10000/100; }
set { Date = Year*10000 + value*100 + Date%100; } }
public uint Day {
get { return Date%100; }
set { Date = Year*10000 + Month*100 + value; } }
private uint Year {
get { return RawDate/10000; }
set { RawDate = value*10000 + RawDate%10000; } }
private uint Month {
get { return RawDate%10000/100; }
set { RawDate = Year*10000 + value*100 + RawDate%100; } }
private uint Day {
get { return RawDate%100; }
set { RawDate = Year*10000 + Month*100 + value; } }
/// <summary>
/// Gets or sets the date of the card.
/// </summary>
public DateTime? Date
{
get
{
// Check to see if date is valid
if (!Util.IsDateValid(2000 + Year, Month, Day))
{
return null;
}
else
{
return new DateTime(2000 + (int)Year, (int)Month, (int)Day);
}
}
set
{
if (value.HasValue)
{
// Only update the properties if a value is provided.
Year = (ushort)(value.Value.Year - 2000);
Month = (byte)value.Value.Month;
Day = (byte)value.Value.Day;
}
else
{
// Clear the Met Date.
// If code tries to access MetDate again, null will be returned.
Year = 0;
Month = 0;
Day = 0;
}
}
}
public int CardLocation { get { return Data[0x50]; } set { Data[0x50] = (byte)value; } }
public int CardType { get { return Data[0x51]; } set { Data[0x51] = (byte)value; } }
@ -281,18 +319,15 @@ namespace PKHeX
pk.Move3_PP = pk.getMovePP(Move3, 0);
pk.Move4_PP = pk.getMovePP(Move4, 0);
if (Day + Month + Year == 0) // No datetime set, typical for wc6full
if (Date.HasValue)
{
DateTime dt = DateTime.Now;
pk.Met_Day = dt.Day;
pk.Met_Month = dt.Month;
pk.Met_Year = dt.Year - 2000;
pk.MetDate = Date.Value;
}
else
{
pk.Met_Day = (int)Day;
pk.Met_Month = (int)Month;
pk.Met_Year = (int)(Year - 2000);
// No datetime set, typical for wc6full
// Set it to now, instead of zeroing it out.
pk.MetDate = DateTime.Now;
}
if (pk.CurrentHandler == 0) // OT
@ -375,9 +410,7 @@ namespace PKHeX
if (IsEgg)
{
pk.IsEgg = true;
pk.Egg_Day = (int) Day;
pk.Egg_Month = (int) Month;
pk.Egg_Year = (int) Year;
pk.EggMetDate = Date;
}
pk.RefreshChecksum();

View file

@ -61,12 +61,9 @@
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Web" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Legality\Analysis.cs" />
@ -298,6 +295,7 @@
</Compile>
<Compile Include="Misc\ComboItem.cs" />
<Compile Include="Util\DataUtil.cs" />
<Compile Include="Util\DateUtil.cs" />
<Compile Include="Util\FormUtil.cs" />
<Compile Include="Util\ImageUtil.cs" />
<Compile Include="Util\PathUtil.cs" />

View file

@ -238,9 +238,7 @@ namespace PKHeX
PKRS_Strain = PKRS_Strain,
PKRS_Days = PKRS_Days,
OT_Gender = OT_Gender,
Met_Year = moment.Year - 2000,
Met_Month = moment.Month,
Met_Day = moment.Day,
MetDate = moment,
Met_Location = 0x37, // Pal Park
RibbonChampionG3Hoenn = RibbonChampionG3Hoenn,

View file

@ -243,12 +243,12 @@ namespace PKHeX
PKX.str2arrayG4(TempNick).CopyTo(Data, 0x68);
}
}
public override int Egg_Year { get { return Data[0x78]; } set { Data[0x78] = (byte)value; } }
public override int Egg_Month { get { return Data[0x79]; } set { Data[0x79] = (byte)value; } }
public override int Egg_Day { get { return Data[0x7A]; } set { Data[0x7A] = (byte)value; } }
public override int Met_Year { get { return Data[0x7B]; } set { Data[0x7B] = (byte)value; } }
public override int Met_Month { get { return Data[0x7C]; } set { Data[0x7C] = (byte)value; } }
public override int Met_Day { get { return Data[0x7D]; } set { Data[0x7D] = (byte)value; } }
protected override int Egg_Year { get { return Data[0x78]; } set { Data[0x78] = (byte)value; } }
protected override int Egg_Month { get { return Data[0x79]; } set { Data[0x79] = (byte)value; } }
protected override int Egg_Day { get { return Data[0x7A]; } set { Data[0x7A] = (byte)value; } }
protected override int Met_Year { get { return Data[0x7B]; } set { Data[0x7B] = (byte)value; } }
protected override int Met_Month { get { return Data[0x7C]; } set { Data[0x7C] = (byte)value; } }
protected override int Met_Day { get { return Data[0x7D]; } set { Data[0x7D] = (byte)value; } }
public override int Egg_Location
{
@ -411,9 +411,7 @@ namespace PKHeX
HeldItem = 0,
OT_Friendship = 70,
// Apply new met date
Met_Year = moment.Year - 2000,
Met_Month = moment.Month,
Met_Day = moment.Day
MetDate = moment
};
// Fix PP

View file

@ -248,12 +248,12 @@ namespace PKHeX
Encoding.Unicode.GetBytes(TempNick).CopyTo(Data, 0x68);
}
}
public override int Egg_Year { get { return Data[0x78]; } set { Data[0x78] = (byte)value; } }
public override int Egg_Month { get { return Data[0x79]; } set { Data[0x79] = (byte)value; } }
public override int Egg_Day { get { return Data[0x7A]; } set { Data[0x7A] = (byte)value; } }
public override int Met_Year { get { return Data[0x7B]; } set { Data[0x7B] = (byte)value; } }
public override int Met_Month { get { return Data[0x7C]; } set { Data[0x7C] = (byte)value; } }
public override int Met_Day { get { return Data[0x7D]; } set { Data[0x7D] = (byte)value; } }
protected override int Egg_Year { get { return Data[0x78]; } set { Data[0x78] = (byte)value; } }
protected override int Egg_Month { get { return Data[0x79]; } set { Data[0x79] = (byte)value; } }
protected override int Egg_Day { get { return Data[0x7A]; } set { Data[0x7A] = (byte)value; } }
protected override int Met_Year { get { return Data[0x7B]; } set { Data[0x7B] = (byte)value; } }
protected override int Met_Month { get { return Data[0x7C]; } set { Data[0x7C] = (byte)value; } }
protected override int Met_Day { get { return Data[0x7D]; } set { Data[0x7D] = (byte)value; } }
public override int Egg_Location { get { return BitConverter.ToUInt16(Data, 0x7E); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x7E); } }
public override int Met_Location { get { return BitConverter.ToUInt16(Data, 0x80); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x80); } }
private byte PKRS { get { return Data[0x82]; } set { Data[0x82] = value; } }
@ -403,12 +403,8 @@ namespace PKHeX
pk6.OT_Name = OT_Name;
// Dates are kept upon transfer
pk6.Met_Year = Met_Year;
pk6.Met_Month = Met_Month;
pk6.Met_Day = Met_Day;
pk6.Egg_Year = Egg_Year;
pk6.Egg_Month = Egg_Month;
pk6.Egg_Day = Egg_Day;
pk6.MetDate = MetDate;
pk6.EggMetDate = EggMetDate;
// Locations are kept upon transfer
pk6.Met_Location = Met_Location;

View file

@ -365,12 +365,12 @@ namespace PKHeX
public int OT_Memory { get { return Data[0xCD]; } set { Data[0xCD] = (byte)value; } }
public int OT_TextVar { get { return BitConverter.ToUInt16(Data, 0xCE); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xCE); } }
public int OT_Feeling { get { return Data[0xD0]; } set { Data[0xD0] = (byte)value; } }
public override int Egg_Year { get { return Data[0xD1]; } set { Data[0xD1] = (byte)value; } }
public override int Egg_Month { get { return Data[0xD2]; } set { Data[0xD2] = (byte)value; } }
public override int Egg_Day { get { return Data[0xD3]; } set { Data[0xD3] = (byte)value; } }
public override int Met_Year { get { return Data[0xD4]; } set { Data[0xD4] = (byte)value; } }
public override int Met_Month { get { return Data[0xD5]; } set { Data[0xD5] = (byte)value; } }
public override int Met_Day { get { return Data[0xD6]; } set { Data[0xD6] = (byte)value; } }
protected override int Egg_Year { get { return Data[0xD1]; } set { Data[0xD1] = (byte)value; } }
protected override int Egg_Month { get { return Data[0xD2]; } set { Data[0xD2] = (byte)value; } }
protected override int Egg_Day { get { return Data[0xD3]; } set { Data[0xD3] = (byte)value; } }
protected override int Met_Year { get { return Data[0xD4]; } set { Data[0xD4] = (byte)value; } }
protected override int Met_Month { get { return Data[0xD5]; } set { Data[0xD5] = (byte)value; } }
protected override int Met_Day { get { return Data[0xD6]; } set { Data[0xD6] = (byte)value; } }
public byte _0xD7 { get { return Data[0xD7]; } set { Data[0xD7] = value; } }
public override int Egg_Location { get { return BitConverter.ToUInt16(Data, 0xD8); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xD8); } }
public override int Met_Location { get { return BitConverter.ToUInt16(Data, 0xDA); } set { BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xDA); } }

View file

@ -125,12 +125,96 @@ namespace PKHeX
public abstract int OT_Friendship { get; set; }
// Future Properties
public virtual int Met_Year { get { return 0; } set { } }
public virtual int Met_Month { get { return 0; } set { } }
public virtual int Met_Day { get { return 0; } set { } }
public virtual int Egg_Year { get { return 0; } set { } }
public virtual int Egg_Month { get { return 0; } set { } }
public virtual int Egg_Day { get { return 0; } set { } }
protected virtual int Met_Year { get { return 0; } set { } }
protected virtual int Met_Month { get { return 0; } set { } }
protected virtual int Met_Day { get { return 0; } set { } }
/// <summary>
/// The date the Pokémon was met.
/// </summary>
/// <returns>A DateTime representing the date the Pokémon was met, or null if either the <see cref="PKM"/> format does not support dates or the stored date is invalid.</returns>
/// <remarks>Not all <see cref="PKM"/> types support the <see cref="MetDate"/> property. In these cases, this property will return null.
///
/// If null is assigned to this property, it will be cleared.</remarks>
public virtual DateTime? MetDate
{
get
{
// Check to see if date is valid
if (!Util.IsDateValid(2000 + Met_Year, Met_Month, Met_Day))
{
return null;
}
else
{
return new DateTime(2000 + Met_Year, Met_Month, Met_Day);
}
}
set
{
if (value.HasValue)
{
// Only update the properties if a value is provided.
Met_Year = value.Value.Year - 2000;
Met_Month = value.Value.Month;
Met_Day = value.Value.Day;
}
else
{
// Clear the Met Date.
// If code tries to access MetDate again, null will be returned.
Met_Year = 0;
Met_Month = 0;
Met_Day = 0;
}
}
}
protected virtual int Egg_Year { get { return 0; } set { } }
protected virtual int Egg_Month { get { return 0; } set { } }
protected virtual int Egg_Day { get { return 0; } set { } }
/// <summary>
/// The date a Pokémon was met as an egg.
/// </summary>
/// <returns>A DateTime representing the date the Pokémon was met as an egg, or null if the <see cref="PKM"/> format does not support dates.</returns>
/// <remarks>Not all <see cref="PKM"/> types support the <see cref="EggMetDate"/> property. In these cases, this property will return null.
///
/// If null is assigned to this property, it will be cleared.</remarks>
public virtual DateTime? EggMetDate
{
get
{
// Check to see if date is valid
if (!Util.IsDateValid(2000 + Egg_Year, Egg_Month, Egg_Day))
{
return null;
}
else
{
return new DateTime(2000 + Egg_Year, Egg_Month, Egg_Day);
}
}
set
{
if (value.HasValue)
{
// Only update the properties if a value is provided.
Egg_Year = value.Value.Year - 2000;
Egg_Month = value.Value.Month;
Egg_Day = value.Value.Day;
}
else
{
// Clear the Met Date.
// If code tries to access MetDate again, null will be returned.
Egg_Year = 0;
Egg_Month = 0;
Egg_Day = 0;
}
}
}
public virtual int OT_Affection { get { return 0; } set { } }
public virtual int RelearnMove1 { get { return 0; } set { } }
public virtual int RelearnMove2 { get { return 0; } set { } }

View file

@ -96,7 +96,7 @@ namespace PKHeX
string[] tmp = spec.Split(new[] { "-" }, StringSplitOptions.None);
if (tmp.Length < 2) return;
Species = Array.IndexOf(species, tmp[0].Replace(" ", ""));
Form = tmp[1].Replace(" ", "");
Form = tmp[1].Trim();
if (tmp.Length > 2)
Form += " " + tmp[2];
}
@ -186,7 +186,7 @@ namespace PKHeX
{
string[] tmp = spec.Split(new[] { "-" }, StringSplitOptions.None);
Species = Array.IndexOf(species, tmp[0].Replace(" ", ""));
Form = tmp[1].Replace(" ", "");
Form = tmp[1].Trim();
if (tmp.Length > 2)
Form += " " + tmp[2];
}

View file

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

View file

Before

Width:  |  Height:  |  Size: 283 B

After

Width:  |  Height:  |  Size: 283 B

View file

Before

Width:  |  Height:  |  Size: 305 B

After

Width:  |  Height:  |  Size: 305 B

View file

Before

Width:  |  Height:  |  Size: 291 B

After

Width:  |  Height:  |  Size: 291 B

View file

Before

Width:  |  Height:  |  Size: 257 B

After

Width:  |  Height:  |  Size: 257 B

View file

Before

Width:  |  Height:  |  Size: 286 B

After

Width:  |  Height:  |  Size: 286 B

View file

Before

Width:  |  Height:  |  Size: 225 B

After

Width:  |  Height:  |  Size: 225 B

View file

Before

Width:  |  Height:  |  Size: 216 B

After

Width:  |  Height:  |  Size: 216 B

View file

Before

Width:  |  Height:  |  Size: 311 B

After

Width:  |  Height:  |  Size: 311 B

View file

Before

Width:  |  Height:  |  Size: 151 B

After

Width:  |  Height:  |  Size: 151 B

View file

Before

Width:  |  Height:  |  Size: 407 B

After

Width:  |  Height:  |  Size: 407 B

View file

Before

Width:  |  Height:  |  Size: 351 B

After

Width:  |  Height:  |  Size: 351 B

View file

Before

Width:  |  Height:  |  Size: 308 B

After

Width:  |  Height:  |  Size: 308 B

View file

Before

Width:  |  Height:  |  Size: 327 B

After

Width:  |  Height:  |  Size: 327 B

View file

Before

Width:  |  Height:  |  Size: 434 B

After

Width:  |  Height:  |  Size: 434 B

View file

Before

Width:  |  Height:  |  Size: 474 B

After

Width:  |  Height:  |  Size: 474 B

View file

Before

Width:  |  Height:  |  Size: 402 B

After

Width:  |  Height:  |  Size: 402 B

View file

Before

Width:  |  Height:  |  Size: 448 B

After

Width:  |  Height:  |  Size: 448 B

View file

Before

Width:  |  Height:  |  Size: 424 B

After

Width:  |  Height:  |  Size: 424 B

View file

Before

Width:  |  Height:  |  Size: 406 B

After

Width:  |  Height:  |  Size: 406 B

View file

Before

Width:  |  Height:  |  Size: 430 B

After

Width:  |  Height:  |  Size: 430 B

View file

Before

Width:  |  Height:  |  Size: 537 B

After

Width:  |  Height:  |  Size: 537 B

Some files were not shown because too many files have changed in this diff Show more