Merge pull request #9 from kwsch/master

Update from upstream repo kwsch/PKHeX
This commit is contained in:
ReignOfComputer
2017-02-09 00:29:59 +08:00
committed by GitHub
21 changed files with 264 additions and 73 deletions

View File

@@ -3981,7 +3981,7 @@ public void InitializeComponent()
this.CB_MainLanguage});
this.Menu_Language.Image = ((System.Drawing.Image)(resources.GetObject("Menu_Language.Image")));
this.Menu_Language.Name = "Menu_Language";
this.Menu_Language.Size = new System.Drawing.Size(152, 22);
this.Menu_Language.Size = new System.Drawing.Size(139, 22);
this.Menu_Language.Text = "Language";
//
// CB_MainLanguage
@@ -4001,7 +4001,7 @@ public void InitializeComponent()
this.Menu_Redo});
this.Menu_Modify.Image = ((System.Drawing.Image)(resources.GetObject("Menu_Modify.Image")));
this.Menu_Modify.Name = "Menu_Modify";
this.Menu_Modify.Size = new System.Drawing.Size(152, 22);
this.Menu_Modify.Size = new System.Drawing.Size(139, 22);
this.Menu_Modify.Text = "Set to SAV";
//
// Menu_ModifyDex
@@ -4058,7 +4058,7 @@ public void InitializeComponent()
this.Menu_Unicode.CheckOnClick = true;
this.Menu_Unicode.CheckState = System.Windows.Forms.CheckState.Checked;
this.Menu_Unicode.Name = "Menu_Unicode";
this.Menu_Unicode.Size = new System.Drawing.Size(152, 22);
this.Menu_Unicode.Size = new System.Drawing.Size(139, 22);
this.Menu_Unicode.Text = "Unicode";
this.Menu_Unicode.Click += new System.EventHandler(this.mainMenuUnicode);
//
@@ -4068,7 +4068,7 @@ public void InitializeComponent()
this.Menu_About.Name = "Menu_About";
this.Menu_About.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.P)));
this.Menu_About.ShowShortcutKeys = false;
this.Menu_About.Size = new System.Drawing.Size(152, 22);
this.Menu_About.Size = new System.Drawing.Size(139, 22);
this.Menu_About.Text = "About &PKHeX";
this.Menu_About.Click += new System.EventHandler(this.mainMenuAbout);
//

View File

@@ -172,9 +172,16 @@ public Main()
#endregion
#region Load Initial File(s)
if (args.Length > 1) // Load the arguments
string pkmArg = null;
foreach (string arg in args.Skip(1)) // skip .exe
{
foreach (string arg in args.Skip(1).Where(a => a.Length > 4))
var fi = new FileInfo(arg);
if (!fi.Exists)
continue;
if (PKX.getIsPKM(fi.Length))
pkmArg = arg;
else
openQuick(arg, force: true);
}
if (!SAV.Exportable) // No SAV loaded from exe args
@@ -203,6 +210,8 @@ public Main()
SAV.Edited = false; // Prevents form close warning from showing until changes are made
}
}
if (pkmArg != null)
openQuick(pkmArg, force: true);
// Splash Screen closes on its own.
BringToFront();
@@ -732,7 +741,7 @@ private void openFile(byte[] input, string path, string ext)
{
openSAV(sav, path);
}
else if ((temp = PKMConverter.getPKMfromBytes(input, prefer: SAV.Generation)) != null)
else if ((temp = PKMConverter.getPKMfromBytes(input, prefer: ext.Length > 0 ? (ext.Last() - 0x30)&7 : SAV.Generation)) != null)
{
PKM pk = PKMConverter.convertToFormat(temp, SAV.PKMType, out c);
if (pk == null)
@@ -1703,9 +1712,17 @@ private void clickQR(object sender, EventArgs e)
if (qr == null) return;
var sprite = dragout.Image;
var la = new LegalityAnalysis(pkx);
if (la.Parsed)
{
var img = la.Valid ? Resources.valid : Resources.warn;
sprite = ImageUtil.LayerImage(sprite, img, 24, 0, 1);
}
string[] r = pkx.QRText;
const string refURL = "PKHeX @ ProjectPokemon.org";
new QR(qr, dragout.Image, r[0], r[1], r[2], $"{refURL} ({pkx.GetType().Name})", pkx).ShowDialog();
string refer = $"PKHeX ({Resources.ProgramVersion})";
new QR(qr, sprite, r[0], r[1], r[2], $"{refer} ({pkx.GetType().Name})", pkx).ShowDialog();
}
}
private void clickFriendship(object sender, EventArgs e)
@@ -3101,13 +3118,14 @@ private void dragoutDrop(object sender, DragEventArgs e)
private void Main_FormClosing(object sender, FormClosingEventArgs e)
{
if (!SAV.Edited)
if (SAV.Edited && DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Any unsaved changes will be lost.", "Are you sure you want to close PKHeX?"))
{
e.Cancel = true;
return;
if (DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Any unsaved changes will be lost.", "Are you sure you want to close PKHeX?"))
{ e.Cancel = true; return; }
}
try { Properties.Settings.Default.Save(); }
catch (Exception x) { File.WriteAllLines("config error.txt", new[] {x.ToString()}); }
catch (Exception x) { File.WriteAllLines("config error.txt", new[] { x.ToString() }); }
}
#endregion
@@ -4156,7 +4174,7 @@ private void pbBoxSlot_DragDrop(object sender, DragEventArgs e)
byte[] data = File.ReadAllBytes(file);
MysteryGift mg = MysteryGift.getMysteryGift(data, fi.Extension);
PKM temp = mg?.convertToPKM(SAV) ?? PKMConverter.getPKMfromBytes(data, prefer: SAV.Generation);
PKM temp = mg?.convertToPKM(SAV) ?? PKMConverter.getPKMfromBytes(data, prefer: fi.Extension.Length > 0 ? (fi.Extension.Last() - 0x30)&7 : SAV.Generation);
string c;
PKM pk = PKMConverter.convertToFormat(temp, SAV.PKMType, out c);

View File

@@ -142,7 +142,11 @@ private PKM preparePK4()
pk4.SID = Util.ToInt32(TB_SID.Text);
pk4.EXP = Util.ToUInt32(TB_EXP.Text);
pk4.PID = Util.getHEXval(TB_PID.Text);
pk4.Ability = (byte)Array.IndexOf(GameInfo.Strings.abilitylist, CB_Ability.Text.Remove(CB_Ability.Text.Length - 4));
if (CB_Ability.Text.Length >= 4)
{
pk4.Ability = (byte)Array.IndexOf(GameInfo.Strings.abilitylist, CB_Ability.Text.Remove(CB_Ability.Text.Length - 4));
}
pk4.FatefulEncounter = CHK_Fateful.Checked;
pk4.Gender = PKX.getGender(Label_Gender.Text);

View File

@@ -247,8 +247,11 @@ private PKM preparePK5()
}
else
{
pk5.Ability = (byte)Array.IndexOf(GameInfo.Strings.abilitylist, CB_Ability.Text.Remove(CB_Ability.Text.Length - 4));
pk5.HiddenAbility = CB_Ability.SelectedIndex > 1; // not 0 or 1
if (CB_Ability.Text.Length >= 4)
{
pk5.Ability = (byte)Array.IndexOf(GameInfo.Strings.abilitylist, CB_Ability.Text.Remove(CB_Ability.Text.Length - 4));
pk5.HiddenAbility = CB_Ability.SelectedIndex > 1; // not 0 or 1
}
}
// Fix Moves if a slot is empty

View File

@@ -184,8 +184,13 @@ private PKM preparePK6()
pk6.TID = Util.ToInt32(TB_TID.Text);
pk6.SID = Util.ToInt32(TB_SID.Text);
pk6.EXP = Util.ToUInt32(TB_EXP.Text);
pk6.Ability = (byte)Array.IndexOf(GameInfo.Strings.abilitylist, CB_Ability.Text.Remove(CB_Ability.Text.Length - 4));
pk6.AbilityNumber = Util.ToInt32(TB_AbilityNumber.Text); // Number
if (CB_Ability.Text.Length >= 4)
{
pk6.Ability = (byte)Array.IndexOf(GameInfo.Strings.abilitylist, CB_Ability.Text.Remove(CB_Ability.Text.Length - 4));
pk6.AbilityNumber = Util.ToInt32(TB_AbilityNumber.Text); // Number
}
// pkx[0x16], pkx[0x17] are handled by the Medals UI (Hits & Training Bag)
pk6.PID = Util.getHEXval(TB_PID.Text);
pk6.Nature = (byte)WinFormsUtil.getIndex(CB_Nature);

View File

@@ -184,8 +184,13 @@ private PKM preparePK7()
pk7.TID = Util.ToInt32(TB_TID.Text);
pk7.SID = Util.ToInt32(TB_SID.Text);
pk7.EXP = Util.ToUInt32(TB_EXP.Text);
pk7.Ability = (byte)Array.IndexOf(GameInfo.Strings.abilitylist, CB_Ability.Text.Remove(CB_Ability.Text.Length - 4));
pk7.AbilityNumber = Util.ToInt32(TB_AbilityNumber.Text); // Number
if (CB_Ability.Text.Length >= 4)
{
pk7.Ability = (byte)Array.IndexOf(GameInfo.Strings.abilitylist, CB_Ability.Text.Remove(CB_Ability.Text.Length - 4));
pk7.AbilityNumber = Util.ToInt32(TB_AbilityNumber.Text); // Number
}
// pkx[0x16], pkx[0x17] are handled by the Medals UI (Hits & Training Bag)
pk7.PID = Util.getHEXval(TB_PID.Text);
pk7.Nature = (byte)WinFormsUtil.getIndex(CB_Nature);

View File

@@ -108,7 +108,7 @@ internal static byte[] getQRData()
pkstr = pkstr.Substring(0, pkstr.IndexOf(cap, StringComparison.Ordinal)); // Trim outro
try
{
if (!pkstr.StartsWith("http") && pkstr.StartsWith(BadQRUrl)) // G7
if (!pkstr.StartsWith("http") && !pkstr.StartsWith(BadQRUrl)) // G7
{
string fstr = Regex.Unescape(pkstr);
byte[] raw = Encoding.Unicode.GetBytes(fstr);

View File

@@ -89,7 +89,7 @@ public SAV_Database(Main f1)
{
FileInfo fi = new FileInfo(file);
if (!fi.Extension.Contains(".pk") || !PKX.getIsPKM(fi.Length)) return;
var pk = PKMConverter.getPKMfromBytes(File.ReadAllBytes(file), file, prefer: Main.SAV.Generation);
var pk = PKMConverter.getPKMfromBytes(File.ReadAllBytes(file), file, prefer: (fi.Extension.Last() - 0x30)&7);
if (pk != null)
dbTemp.Add(pk);
});
@@ -504,6 +504,8 @@ private void B_Search_Click(object sender, EventArgs e)
{
foreach (var cmd in filters)
{
if (cmd.PropertyName == nameof(PKM.Identifier) + "Contains")
return pkm.Identifier.Contains(cmd.PropertyValue);
if (!pkm.GetType().HasPropertyAll(cmd.PropertyName))
return false;
try { if (ReflectUtil.GetValueEquals(pkm, cmd.PropertyName, cmd.PropertyValue) == cmd.Evaluator) continue; }

View File

@@ -202,6 +202,8 @@ private void InitializeComponent()
this.Tab_Multiplayer = new System.Windows.Forms.TabPage();
this.Tab_Maison = new System.Windows.Forms.TabPage();
this.Tab_Appearance = new System.Windows.Forms.TabPage();
this.TB_TRNick = new System.Windows.Forms.TextBox();
this.L_TRNick = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.PB_Badge8)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.PB_Badge6)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.PB_Badge4)).BeginInit();
@@ -416,7 +418,6 @@ private void InitializeComponent()
//
// PB_Badge8
//
this.PB_Badge8.Image = Core.Properties.Resources.badge_8;
this.PB_Badge8.Location = new System.Drawing.Point(248, 63);
this.PB_Badge8.Name = "PB_Badge8";
this.PB_Badge8.Size = new System.Drawing.Size(50, 50);
@@ -427,7 +428,6 @@ private void InitializeComponent()
//
// PB_Badge6
//
this.PB_Badge6.Image = Core.Properties.Resources.badge_6;
this.PB_Badge6.Location = new System.Drawing.Point(142, 63);
this.PB_Badge6.Name = "PB_Badge6";
this.PB_Badge6.Size = new System.Drawing.Size(50, 50);
@@ -438,7 +438,6 @@ private void InitializeComponent()
//
// PB_Badge4
//
this.PB_Badge4.Image = Core.Properties.Resources.badge_4;
this.PB_Badge4.Location = new System.Drawing.Point(248, 10);
this.PB_Badge4.Name = "PB_Badge4";
this.PB_Badge4.Size = new System.Drawing.Size(50, 50);
@@ -449,7 +448,6 @@ private void InitializeComponent()
//
// PB_Badge2
//
this.PB_Badge2.Image = Core.Properties.Resources.badge_2;
this.PB_Badge2.Location = new System.Drawing.Point(142, 10);
this.PB_Badge2.Name = "PB_Badge2";
this.PB_Badge2.Size = new System.Drawing.Size(50, 50);
@@ -460,7 +458,6 @@ private void InitializeComponent()
//
// PB_Badge7
//
this.PB_Badge7.Image = Core.Properties.Resources.badge_7;
this.PB_Badge7.Location = new System.Drawing.Point(195, 63);
this.PB_Badge7.Name = "PB_Badge7";
this.PB_Badge7.Size = new System.Drawing.Size(50, 50);
@@ -471,7 +468,6 @@ private void InitializeComponent()
//
// PB_Badge5
//
this.PB_Badge5.Image = Core.Properties.Resources.badge_5;
this.PB_Badge5.Location = new System.Drawing.Point(89, 63);
this.PB_Badge5.Name = "PB_Badge5";
this.PB_Badge5.Size = new System.Drawing.Size(50, 50);
@@ -482,7 +478,6 @@ private void InitializeComponent()
//
// PB_Badge3
//
this.PB_Badge3.Image = Core.Properties.Resources.badge_3;
this.PB_Badge3.Location = new System.Drawing.Point(195, 10);
this.PB_Badge3.Name = "PB_Badge3";
this.PB_Badge3.Size = new System.Drawing.Size(50, 50);
@@ -493,7 +488,6 @@ private void InitializeComponent()
//
// PB_Badge1
//
this.PB_Badge1.Image = Core.Properties.Resources.badge_1;
this.PB_Badge1.Location = new System.Drawing.Point(89, 10);
this.PB_Badge1.Name = "PB_Badge1";
this.PB_Badge1.Size = new System.Drawing.Size(50, 50);
@@ -2102,6 +2096,8 @@ private void InitializeComponent()
//
// Tab_Appearance
//
this.Tab_Appearance.Controls.Add(this.L_TRNick);
this.Tab_Appearance.Controls.Add(this.TB_TRNick);
this.Tab_Appearance.Controls.Add(this.CB_Skin);
this.Tab_Appearance.Controls.Add(this.CB_Hair);
this.Tab_Appearance.Controls.Add(this.MT_Hat);
@@ -2151,6 +2147,26 @@ private void InitializeComponent()
this.Tab_Appearance.Text = "Appearance";
this.Tab_Appearance.UseVisualStyleBackColor = true;
//
// TB_TRNick
//
this.TB_TRNick.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.TB_TRNick.Location = new System.Drawing.Point(202, 230);
this.TB_TRNick.MaxLength = 12;
this.TB_TRNick.Name = "TB_TRNick";
this.TB_TRNick.Size = new System.Drawing.Size(93, 20);
this.TB_TRNick.TabIndex = 73;
this.TB_TRNick.Text = "WWWWWWWWWWWW";
this.TB_TRNick.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// L_TRNick
//
this.L_TRNick.Location = new System.Drawing.Point(68, 230);
this.L_TRNick.Name = "L_TRNick";
this.L_TRNick.Size = new System.Drawing.Size(128, 20);
this.L_TRNick.TabIndex = 74;
this.L_TRNick.Text = "Trainer Nickname:";
this.L_TRNick.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// SAV_Trainer
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -2379,5 +2395,7 @@ private void InitializeComponent()
private System.Windows.Forms.Label L_Fame;
private System.Windows.Forms.DateTimePicker CAL_HoFDate;
private System.Windows.Forms.DateTimePicker CAL_HoFTime;
private System.Windows.Forms.Label L_TRNick;
private System.Windows.Forms.TextBox TB_TRNick;
}
}

View File

@@ -13,7 +13,12 @@ public SAV_Trainer()
{
InitializeComponent();
if (Main.unicode)
try { TB_OTName.Font = FontUtil.getPKXFont(11); }
try
{
TB_OTName.Font = FontUtil.getPKXFont(11);
if (Main.SAV.XY)
TB_TRNick.Font = TB_OTName.Font;
}
catch (Exception e) { WinFormsUtil.Alert("Font loading failed...", e.ToString()); }
WinFormsUtil.TranslateInterface(this, Main.curlanguage);
@@ -448,6 +453,8 @@ private void getTextBoxes()
MT_1403D.Text = SAV.Data[SAV.TrainerCard + 0x3D].ToString();
MT_1403E.Text = SAV.Data[SAV.TrainerCard + 0x3E].ToString();
MT_1403F.Text = SAV.Data[SAV.TrainerCard + 0x3F].ToString();
TB_TRNick.Text = SAV.OT_Nick;
}
CB_Vivillon.SelectedIndex = SAV.Vivillon;
@@ -540,6 +547,8 @@ private void save()
SAV.Data[SAV.TrainerCard + 0x3D] = byte.Parse(MT_1403D.Text);
SAV.Data[SAV.TrainerCard + 0x3E] = byte.Parse(MT_1403E.Text);
SAV.Data[SAV.TrainerCard + 0x3F] = byte.Parse(MT_1403F.Text);
SAV.OT_Nick = TB_TRNick.Text;
}
// Vivillon

View File

@@ -157,6 +157,7 @@ private void InitializeComponent()
this.NUD_RCStreak0 = new System.Windows.Forms.NumericUpDown();
this.L_CStreak0 = new System.Windows.Forms.Label();
this.Tab_Misc = new System.Windows.Forms.TabPage();
this.CB_Fashion = new System.Windows.Forms.ComboBox();
this.L_SkinColor = new System.Windows.Forms.Label();
this.CB_SkinColor = new System.Windows.Forms.ComboBox();
this.GB_PokeFinder = new System.Windows.Forms.GroupBox();
@@ -170,7 +171,9 @@ private void InitializeComponent()
this.NUD_ThumbsTotal = new System.Windows.Forms.NumericUpDown();
this.L_ThumbsTotal = new System.Windows.Forms.Label();
this.B_Fashion = new System.Windows.Forms.Button();
this.CB_Fashion = new System.Windows.Forms.ComboBox();
this.L_G7TID = new System.Windows.Forms.Label();
this.MT_G7TID = new System.Windows.Forms.MaskedTextBox();
this.B_GenTID = new System.Windows.Forms.Button();
this.TC_Editor.SuspendLayout();
this.Tab_Overview.SuspendLayout();
this.GB_Stats.SuspendLayout();
@@ -207,7 +210,7 @@ private void InitializeComponent()
//
// B_Cancel
//
this.B_Cancel.Location = new System.Drawing.Point(250, 296);
this.B_Cancel.Location = new System.Drawing.Point(250, 334);
this.B_Cancel.Name = "B_Cancel";
this.B_Cancel.Size = new System.Drawing.Size(75, 23);
this.B_Cancel.TabIndex = 0;
@@ -217,7 +220,7 @@ private void InitializeComponent()
//
// B_Save
//
this.B_Save.Location = new System.Drawing.Point(331, 296);
this.B_Save.Location = new System.Drawing.Point(331, 334);
this.B_Save.Name = "B_Save";
this.B_Save.Size = new System.Drawing.Size(75, 23);
this.B_Save.TabIndex = 1;
@@ -453,7 +456,7 @@ private void InitializeComponent()
//
// L_Language
//
this.L_Language.Location = new System.Drawing.Point(14, 77);
this.L_Language.Location = new System.Drawing.Point(202, 82);
this.L_Language.Name = "L_Language";
this.L_Language.Size = new System.Drawing.Size(80, 13);
this.L_Language.TabIndex = 21;
@@ -519,7 +522,7 @@ private void InitializeComponent()
//
this.CB_Language.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CB_Language.FormattingEnabled = true;
this.CB_Language.Location = new System.Drawing.Point(99, 73);
this.CB_Language.Location = new System.Drawing.Point(287, 79);
this.CB_Language.Name = "CB_Language";
this.CB_Language.Size = new System.Drawing.Size(93, 21);
this.CB_Language.TabIndex = 15;
@@ -805,11 +808,14 @@ private void InitializeComponent()
this.TC_Editor.Location = new System.Drawing.Point(12, 12);
this.TC_Editor.Name = "TC_Editor";
this.TC_Editor.SelectedIndex = 0;
this.TC_Editor.Size = new System.Drawing.Size(394, 279);
this.TC_Editor.Size = new System.Drawing.Size(394, 316);
this.TC_Editor.TabIndex = 54;
//
// Tab_Overview
//
this.Tab_Overview.Controls.Add(this.B_GenTID);
this.Tab_Overview.Controls.Add(this.L_G7TID);
this.Tab_Overview.Controls.Add(this.MT_G7TID);
this.Tab_Overview.Controls.Add(this.GB_Stats);
this.Tab_Overview.Controls.Add(this.CB_AlolaTime);
this.Tab_Overview.Controls.Add(this.L_AlolaTime);
@@ -836,7 +842,7 @@ private void InitializeComponent()
this.Tab_Overview.Location = new System.Drawing.Point(4, 22);
this.Tab_Overview.Name = "Tab_Overview";
this.Tab_Overview.Padding = new System.Windows.Forms.Padding(3);
this.Tab_Overview.Size = new System.Drawing.Size(386, 253);
this.Tab_Overview.Size = new System.Drawing.Size(386, 290);
this.Tab_Overview.TabIndex = 0;
this.Tab_Overview.Text = "Overview";
this.Tab_Overview.UseVisualStyleBackColor = true;
@@ -851,7 +857,7 @@ private void InitializeComponent()
this.GB_Stats.Controls.Add(this.L_BP);
this.GB_Stats.Controls.Add(this.L_Value);
this.GB_Stats.Controls.Add(this.CB_Stats);
this.GB_Stats.Location = new System.Drawing.Point(212, 113);
this.GB_Stats.Location = new System.Drawing.Point(212, 130);
this.GB_Stats.Name = "GB_Stats";
this.GB_Stats.Size = new System.Drawing.Size(171, 137);
this.GB_Stats.TabIndex = 60;
@@ -954,14 +960,14 @@ private void InitializeComponent()
//
this.CB_AlolaTime.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CB_AlolaTime.FormattingEnabled = true;
this.CB_AlolaTime.Location = new System.Drawing.Point(287, 89);
this.CB_AlolaTime.Location = new System.Drawing.Point(287, 106);
this.CB_AlolaTime.Name = "CB_AlolaTime";
this.CB_AlolaTime.Size = new System.Drawing.Size(93, 21);
this.CB_AlolaTime.TabIndex = 59;
//
// L_AlolaTime
//
this.L_AlolaTime.Location = new System.Drawing.Point(209, 92);
this.L_AlolaTime.Location = new System.Drawing.Point(209, 109);
this.L_AlolaTime.Name = "L_AlolaTime";
this.L_AlolaTime.Size = new System.Drawing.Size(72, 13);
this.L_AlolaTime.TabIndex = 58;
@@ -985,7 +991,7 @@ private void InitializeComponent()
this.GB_Adventure.Controls.Add(this.L_Minutes);
this.GB_Adventure.Controls.Add(this.CAL_AdventureStartTime);
this.GB_Adventure.Controls.Add(this.CAL_LastSavedTime);
this.GB_Adventure.Location = new System.Drawing.Point(3, 99);
this.GB_Adventure.Location = new System.Drawing.Point(3, 130);
this.GB_Adventure.Name = "GB_Adventure";
this.GB_Adventure.Size = new System.Drawing.Size(200, 151);
this.GB_Adventure.TabIndex = 56;
@@ -1075,7 +1081,7 @@ private void InitializeComponent()
this.Tab_BadgeMap.Controls.Add(this.GB_Map);
this.Tab_BadgeMap.Location = new System.Drawing.Point(4, 22);
this.Tab_BadgeMap.Name = "Tab_BadgeMap";
this.Tab_BadgeMap.Size = new System.Drawing.Size(386, 253);
this.Tab_BadgeMap.Size = new System.Drawing.Size(386, 294);
this.Tab_BadgeMap.TabIndex = 3;
this.Tab_BadgeMap.Text = "Map";
this.Tab_BadgeMap.UseVisualStyleBackColor = true;
@@ -1266,7 +1272,7 @@ private void InitializeComponent()
this.Tab_BattleTree.Location = new System.Drawing.Point(4, 22);
this.Tab_BattleTree.Name = "Tab_BattleTree";
this.Tab_BattleTree.Padding = new System.Windows.Forms.Padding(3);
this.Tab_BattleTree.Size = new System.Drawing.Size(386, 253);
this.Tab_BattleTree.Size = new System.Drawing.Size(386, 294);
this.Tab_BattleTree.TabIndex = 5;
this.Tab_BattleTree.Text = "Battle Tree";
this.Tab_BattleTree.UseVisualStyleBackColor = true;
@@ -1557,11 +1563,24 @@ private void InitializeComponent()
this.Tab_Misc.Location = new System.Drawing.Point(4, 22);
this.Tab_Misc.Name = "Tab_Misc";
this.Tab_Misc.Padding = new System.Windows.Forms.Padding(3);
this.Tab_Misc.Size = new System.Drawing.Size(386, 253);
this.Tab_Misc.Size = new System.Drawing.Size(386, 294);
this.Tab_Misc.TabIndex = 4;
this.Tab_Misc.Text = "Misc";
this.Tab_Misc.UseVisualStyleBackColor = true;
//
// CB_Fashion
//
this.CB_Fashion.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CB_Fashion.FormattingEnabled = true;
this.CB_Fashion.Items.AddRange(new object[] {
"New Game",
"All Legal",
"Everything"});
this.CB_Fashion.Location = new System.Drawing.Point(31, 76);
this.CB_Fashion.Name = "CB_Fashion";
this.CB_Fashion.Size = new System.Drawing.Size(107, 21);
this.CB_Fashion.TabIndex = 60;
//
// L_SkinColor
//
this.L_SkinColor.Location = new System.Drawing.Point(144, 6);
@@ -1719,24 +1738,40 @@ private void InitializeComponent()
this.B_Fashion.UseVisualStyleBackColor = true;
this.B_Fashion.Click += new System.EventHandler(this.B_Fashion_Click);
//
// CB_Fashion
// L_G7TID
//
this.CB_Fashion.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CB_Fashion.FormattingEnabled = true;
this.CB_Fashion.Items.AddRange(new object[] {
"New Game",
"All Legal",
"Everything"});
this.CB_Fashion.Location = new System.Drawing.Point(31, 76);
this.CB_Fashion.Name = "CB_Fashion";
this.CB_Fashion.Size = new System.Drawing.Size(107, 21);
this.CB_Fashion.TabIndex = 60;
this.L_G7TID.Location = new System.Drawing.Point(-1, 78);
this.L_G7TID.Name = "L_G7TID";
this.L_G7TID.Size = new System.Drawing.Size(48, 13);
this.L_G7TID.TabIndex = 61;
this.L_G7TID.Text = "G7TID:";
this.L_G7TID.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// MT_G7TID
//
this.MT_G7TID.Location = new System.Drawing.Point(53, 75);
this.MT_G7TID.Mask = "000000";
this.MT_G7TID.Name = "MT_G7TID";
this.MT_G7TID.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
this.MT_G7TID.Size = new System.Drawing.Size(65, 20);
this.MT_G7TID.TabIndex = 62;
this.MT_G7TID.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// B_GenTID
//
this.B_GenTID.Location = new System.Drawing.Point(124, 75);
this.B_GenTID.Name = "B_GenTID";
this.B_GenTID.Size = new System.Drawing.Size(68, 20);
this.B_GenTID.TabIndex = 63;
this.B_GenTID.Text = "Generate";
this.B_GenTID.UseVisualStyleBackColor = true;
this.B_GenTID.Click += new System.EventHandler(this.B_GenTID_Click);
//
// SAV_Trainer7
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(414, 326);
this.ClientSize = new System.Drawing.Size(414, 366);
this.Controls.Add(this.TC_Editor);
this.Controls.Add(this.B_Save);
this.Controls.Add(this.B_Cancel);
@@ -1931,5 +1966,8 @@ private void InitializeComponent()
private System.Windows.Forms.Label L_Value;
private System.Windows.Forms.Label L_Offset;
private System.Windows.Forms.ComboBox CB_Fashion;
private System.Windows.Forms.Button B_GenTID;
private System.Windows.Forms.Label L_G7TID;
private System.Windows.Forms.MaskedTextBox MT_G7TID;
}
}

View File

@@ -111,6 +111,7 @@ private void getTextBoxes()
MT_TID.Text = SAV.TID.ToString("00000");
MT_SID.Text = SAV.SID.ToString("00000");
MT_G7TID.Text = SAV.TrainerID7.ToString("000000");
MT_Money.Text = SAV.Money.ToString();
CB_Country.SelectedValue = SAV.Country;
@@ -386,11 +387,20 @@ private void changeStatVal(object sender, EventArgs e)
SAV.setRecord(index, (int)NUD_Stat.Value);
}
private void B_GenTID_Click(object sender, EventArgs e)
{
var tuple = SaveUtil.getTIDSID(Util.ToUInt32(MT_G7TID.Text), ModifierKeys == Keys.Control);
MT_TID.Text = tuple.Item1.ToString("D5");
MT_SID.Text = tuple.Item2.ToString("D5");
}
private readonly Dictionary<int, string> RecordList = new Dictionary<int, string>
{
{000, "Steps Taken"},
{001, "Times Saved"},
{003, "Total Battles"},
{004, "Wild Pokémon Battles"},
{005, "Trainer Battles"},
{006, "Pokemon Caught"},
{007, "Pokemon Caught Fishing"},
{008, "Eggs Hatched"},
@@ -403,17 +413,22 @@ private void changeStatVal(object sender, EventArgs e)
{022, "Exp. Points Collected"},
{024, "Deposited in the GTS"},
{025, "Nicknames Given"},
{027, "Battle Points Earned"},
{028, "Battle Points Spent"},
{029, "Super Effective Moves Used"},
{032, "Berry Harvests"},
{033, "Trades at the GTS"},
{034, "Wonder Trades"},
{035, "Quick Links"},
{036, "Pokemon Rides"},
{037, "Beans Given"},
{038, "Festival Coins Spent"},
{039, "Poke Beans Collected"},
{040, "Battles at the Battle Tree"},
{041, "Z-Moves Used"},
{046, "Ran From Battles"},
{050, "Total Thumbs-Ups"},
{052, "Record Thumbs-ups"},
{053, "Pokemon Petted"},
{066, "Guests Interacted With"},
@@ -421,6 +436,7 @@ private void changeStatVal(object sender, EventArgs e)
{110, "Pokemon Defeated (Highest)"},
{112, "Pokemon Caught (Highest)"},
{114, "Trainers Battled (Highest)"},
{115, "Items Picked Up"},
{116, "Pokemon Evolved (Highest)"},
{118, "Fossils Restored"},
{119, "Photos Taken"},
@@ -430,10 +446,13 @@ private void changeStatVal(object sender, EventArgs e)
{128, "Missions Participated In"},
{129, "Facilities Hosted"},
{130, "QR Code Scans"},
{137, "Battle Royal Dome Battles"},
{158, "Outfit Changes"},
{159, "Battle Royal Dome Wins"},
{161, "Pelago Training Sessions"},
{162, "Pelago Hot Spring Sessions"},
{166, "Island Scans"},
{172, "Berry Tree Battles"},
};
}
}

View File

@@ -1170,6 +1170,9 @@ private CheckResult verifyHistory()
return new CheckResult(Severity.Invalid, "Should not have OT memories.", CheckIdentifier.History);
}
if (pkm.Format >= 6 && pkm.GenNumber != pkm.Format && pkm.CurrentHandler != 1)
return new CheckResult(Severity.Invalid, "Current handler cannot be past gen OT for transferred specimen.", CheckIdentifier.History);
if (pkm.HT_Gender > 1)
return new CheckResult(Severity.Invalid, $"HT Gender invalid {pkm.HT_Gender}.", CheckIdentifier.History);

View File

@@ -371,21 +371,21 @@ private static int getMaxSpeciesOrigin(int generation)
switch (generation)
{
case 1:
return Legal.MaxSpeciesID_1;
return MaxSpeciesID_1;
case 2:
return Legal.MaxSpeciesID_2;
return MaxSpeciesID_2;
case 3:
return Legal.MaxSpeciesID_3;
return MaxSpeciesID_3;
case 4:
return Legal.MaxSpeciesID_4;
return MaxSpeciesID_4;
case 5:
return Legal.MaxSpeciesID_5;
return MaxSpeciesID_5;
case 6:
return Legal.MaxSpeciesID_6;
return MaxSpeciesID_6;
case 7:
return Legal.MaxSpeciesID_7;
return MaxSpeciesID_7;
default:
return Legal.MaxSpeciesID_7;
return MaxSpeciesID_7;
}
}
@@ -520,6 +520,9 @@ private static IEnumerable<MysteryGift> getMatchingWC7(PKM pkm, IEnumerable<Myst
}
internal static IEnumerable<int> getLineage(PKM pkm)
{
if (pkm.IsEgg)
return new[] {pkm.Species};
var table = getEvolutionTable(pkm);
var lineage = table.getValidPreEvolutions(pkm, pkm.CurrentLevel);
return lineage.Select(evolution => evolution.Species);
@@ -545,10 +548,16 @@ internal static bool getDexNavValid(PKM pkm)
}
internal static bool getHasEvolved(PKM pkm)
{
if (pkm.IsEgg)
return false;
return getValidPreEvolutions(pkm).Count() > 1;
}
internal static bool getHasEvolvedFormChange(PKM pkm)
{
if (pkm.IsEgg)
return false;
if (pkm.Format >= 7 && EvolveToAlolanForms.Contains(pkm.Species))
return pkm.AltForm == 1;
if (pkm.Species == 678 && pkm.Gender == 1)
@@ -557,6 +566,9 @@ internal static bool getHasEvolvedFormChange(PKM pkm)
}
internal static bool getHasTradeEvolved(PKM pkm)
{
if (pkm.IsEgg)
return false;
var table = getEvolutionTable(pkm);
var lineage = table.getValidPreEvolutions(pkm, 100, skipChecks:true);
return lineage.Any(evolution => EvolutionMethod.TradeMethods.Any(method => method == evolution.Flag)); // Trade Evolutions
@@ -866,6 +878,11 @@ private static IEnumerable<DexLevel> getValidPreEvolutions(PKM pkm, int lvl = -1
{
if (lvl < 0)
lvl = pkm.CurrentLevel;
if (lvl == 1 && pkm.IsEgg)
return new List<DexLevel>
{
new DexLevel { Species = pkm.Species, Level = 1 },
};
if (pkm.Species == 292 && pkm.Met_Level + 1 <= lvl && lvl >= 20)
return new List<DexLevel>
{

View File

@@ -472,6 +472,12 @@ public static partial class Legal
};
internal static readonly int[] Ban_Gen3Ball_AllowG7 =
{
252, 255, 258, //1 - Treeko, Torchic, Mudkip
253, 256, 259, //2
254, 257, 260, //3
387, 390, 393, //1 - Turtwig, Chimchar, Piplup
388, 391, 394, //2
389, 392, 395, //3
495, 498, 501, //1 - Snivy, Tepig, Oshawott
496, 499, 502, //2
497, 500, 503, //3

View File

@@ -619,6 +619,10 @@ public PK7 convertToPK7()
break;
}
pk7.TradeMemory(Bank: true); // oh no, memories on gen7 pkm
pk7.Geo1_Country = PKMConverter.Country;
pk7.Geo1_Region = PKMConverter.Region;
// Bank-accurate data zeroing
for (var i = 0x94; i < 0x9E; i++) pk7.Data[i] = 0; /* Geolocations. */
for (var i = 0xAA; i < 0xB0; i++) pk7.Data[i] = 0; /* Unused/Amie Fullness & Enjoyment. */
@@ -626,10 +630,6 @@ public PK7 convertToPK7()
pk7.Data[0x72] &= 0xFC; /* Clear lower two bits of Super training flags. */
pk7.Data[0xDE] = 0; /* Gen IV encounter type. */
pk7.TradeMemory(Bank: true); // oh no, memories on gen7 pkm
pk7.Geo1_Country = PKMConverter.Country;
pk7.Geo1_Region = PKMConverter.Region;
// Fix Checksum
pk7.RefreshChecksum();

View File

@@ -93,7 +93,7 @@ public override uint PID
public override int CNT_Smart { get { return Data[0x27]; } set { Data[0x27] = (byte)value; } }
public override int CNT_Tough { get { return Data[0x28]; } set { Data[0x28] = (byte)value; } }
public override int CNT_Sheen { get { return Data[0x29]; } set { Data[0x29] = (byte)value; } }
public byte PelagoEventStatus { get { return Data[0x2A]; } protected set { Data[0x2A] = value; } }
public byte PelagoEventStatus { get { return Data[0x2A]; } set { Data[0x2A] = value; } }
private byte PKRS { get { return Data[0x2B]; } set { Data[0x2B] = value; } }
public override int PKRS_Days { get { return PKRS & 0xF; } set { PKRS = (byte)(PKRS & ~0xF | value); } }
public override int PKRS_Strain { get { return PKRS >> 4; } set { PKRS = (byte)(PKRS & 0xF | value << 4); } }

View File

@@ -1,7 +1,19 @@
PKHeX - By Kaphotics
http://projectpokemon.org/pkhex
17/01/31 - New Update:
17/02/07 - New Update:
- Legality:
- - Added: Legality indication for exported QR images (if legality check is available for origin).
- - Added: Legality indication for Box/Party pkm slots (^ + opt-in via Options->Set to SAV).
- - Fixed: More edge cases for legality checks.
- Added: More Generation 7 trainer stat record labels. Thanks skywalker25 & Holla!
- Added: G7TID -> TID/SID generator for Generation 7 Trainer Editor. Thanks RoC!
- Added: QR exporting for non gen6/7 pkm. Only use is for sharing via image rather than file.
- Fixed: Transferred markings are now applied correctly.
- Fixed: Gen 2 inventory items TMHM cap raised from 1 to 99.
- Fixed: Importing japanese pk1 files now transfer to generation 7 without errors.
17/01/31 - New Update: (44550) [295748]
- Added: Default/Illegal(old code) fashion payloads for those wanting to undo/have anything.
- Changed: Internal program version updated to .NET 4.6.
- Changed: Improved exception checking for config & dll exceptions.

View File

@@ -1 +1 @@
20170131
20170207

View File

@@ -398,6 +398,11 @@ public override string OT
get { return Util.TrimFromZero(Encoding.Unicode.GetString(Data, TrainerCard + 0x48, 0x1A)); }
set { Encoding.Unicode.GetBytes(value.PadRight(13, '\0')).CopyTo(Data, TrainerCard + 0x48); }
}
public string OT_Nick
{
get { return Util.TrimFromZero(Encoding.Unicode.GetString(Data, TrainerCard + 0x62, 0x1A)); }
set { Encoding.Unicode.GetBytes(value.PadRight(value.Length + 1, '\0')).CopyTo(Data, TrainerCard + 0x62); }
}
public string Saying1
{
get { return Util.TrimFromZero(Encoding.Unicode.GetString(Data, TrainerCard + 0x7C + 0x22 * 0, 0x22)); }

View File

@@ -975,5 +975,32 @@ public static ushort[] AdvanceGCKeys(ushort[] oldKeys)
return keys;
}
/// <summary>
/// Creates a 16bit TID/SID tuple for a given G7TID.
/// </summary>
/// <param name="G7TID">Desired G7TID</param>
/// <param name="minimizeSID">Optional param to yield minimum SID.</param>
/// <returns>16bit TID/SID tuple</returns>
public static Tuple<uint, uint> getTIDSID(uint G7TID, bool minimizeSID = false)
{
// 32 bit number = 4294 967295
// lowest 6 digits G7TID
// Bare minimum 32bit value to get ID, yields min SID
uint val = G7TID;
if (!minimizeSID) // randomize SID
{
uint s7 = 4294;
if (val > 967295)
s7 -= 1;
s7 = (uint)Util.rand.Next(0, (int)s7);
val += s7 * 1000000;
}
uint TID = val & 0xFFFF;
uint SID = val >> 16;
return new Tuple<uint, uint>(TID, SID);
}
}
}