diff --git a/PKHeX/Legality/Core.cs b/PKHeX/Legality/Core.cs index 29fcad10c..f29c885f9 100644 --- a/PKHeX/Legality/Core.cs +++ b/PKHeX/Legality/Core.cs @@ -525,7 +525,7 @@ namespace PKHeX if (lvl >= pk6.Met_Level && lvl >= evo.Level) dl.Add(new DexLevel {Species = evo.Species, Level = lvl}); else break; - if (evo.Level > 1) // Level Up (from previous level) + if (evo.Level > 2) // Level Up (from previous level) lvl--; } return dl; diff --git a/PKHeX/MainWindow/Main.Designer.cs b/PKHeX/MainWindow/Main.Designer.cs index 51e1d7dc1..91aaf0b79 100644 --- a/PKHeX/MainWindow/Main.Designer.cs +++ b/PKHeX/MainWindow/Main.Designer.cs @@ -245,7 +245,6 @@ this.Menu_ModifyPKM = new System.Windows.Forms.ToolStripMenuItem(); this.Menu_Unicode = new System.Windows.Forms.ToolStripMenuItem(); this.Menu_About = new System.Windows.Forms.ToolStripMenuItem(); - this.L_Save = new System.Windows.Forms.Label(); this.tabBoxMulti = new System.Windows.Forms.TabControl(); this.Tab_Box = new System.Windows.Forms.TabPage(); this.PAN_Box = new System.Windows.Forms.Panel(); @@ -348,10 +347,10 @@ this.B_OpenOPowers = new System.Windows.Forms.Button(); this.B_OpenEventFlags = new System.Windows.Forms.Button(); this.B_OpenPokedex = new System.Windows.Forms.Button(); - this.B_OpenBerryField = new System.Windows.Forms.Button(); - this.B_OpenSecretBase = new System.Windows.Forms.Button(); - this.B_Pokeblocks = new System.Windows.Forms.Button(); this.B_LinkInfo = new System.Windows.Forms.Button(); + this.B_OpenBerryField = new System.Windows.Forms.Button(); + this.B_Pokeblocks = new System.Windows.Forms.Button(); + this.B_OpenSecretBase = new System.Windows.Forms.Button(); this.B_OpenPokepuffs = new System.Windows.Forms.Button(); this.B_OpenSuperTraining = new System.Windows.Forms.Button(); this.B_OpenHallofFame = new System.Windows.Forms.Button(); @@ -363,6 +362,7 @@ this.mnuLQR = new System.Windows.Forms.ToolStripMenuItem(); this.mnuLSave = new System.Windows.Forms.ToolStripMenuItem(); this.PB_Legal = new System.Windows.Forms.PictureBox(); + this.L_UpdateAvailable = new System.Windows.Forms.LinkLabel(); this.tabMain.SuspendLayout(); this.Tab_Main.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.Label_IsShiny)).BeginInit(); @@ -926,6 +926,7 @@ this.TB_Nickname.Name = "TB_Nickname"; this.TB_Nickname.Size = new System.Drawing.Size(122, 20); this.TB_Nickname.TabIndex = 5; + this.TB_Nickname.TextChanged += new System.EventHandler(this.updateIsNicknamed); this.TB_Nickname.MouseDown += new System.Windows.Forms.MouseEventHandler(this.updateNicknameClick); // // CB_Species @@ -2985,16 +2986,6 @@ this.Menu_About.Text = "About &PKHeX"; this.Menu_About.Click += new System.EventHandler(this.mainMenuAbout); // - // L_Save - // - this.L_Save.AutoSize = true; - this.L_Save.Location = new System.Drawing.Point(300, 5); - this.L_Save.Name = "L_Save"; - this.L_Save.Size = new System.Drawing.Size(54, 13); - this.L_Save.TabIndex = 4; - this.L_Save.Text = "SAV: N/A"; - this.L_Save.Click += new System.EventHandler(this.clickSaveFileName); - // // tabBoxMulti // this.tabBoxMulti.Controls.Add(this.Tab_Box); @@ -3007,6 +2998,7 @@ this.tabBoxMulti.Size = new System.Drawing.Size(310, 225); this.tabBoxMulti.TabIndex = 50; this.tabBoxMulti.Click += new System.EventHandler(this.clickBoxSort); + this.tabBoxMulti.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.clickBoxDouble); // // Tab_Box // @@ -4454,6 +4446,16 @@ this.B_OpenPokedex.UseVisualStyleBackColor = true; this.B_OpenPokedex.Click += new System.EventHandler(this.B_OpenPokedex_Click); // + // B_LinkInfo + // + this.B_LinkInfo.Location = new System.Drawing.Point(96, 61); + this.B_LinkInfo.Name = "B_LinkInfo"; + this.B_LinkInfo.Size = new System.Drawing.Size(87, 23); + this.B_LinkInfo.TabIndex = 23; + this.B_LinkInfo.Text = "Link Data"; + this.B_LinkInfo.UseVisualStyleBackColor = true; + this.B_LinkInfo.Click += new System.EventHandler(this.B_LinkInfo_Click); + // // B_OpenBerryField // this.B_OpenBerryField.Location = new System.Drawing.Point(189, 61); @@ -4464,17 +4466,6 @@ this.B_OpenBerryField.UseVisualStyleBackColor = true; this.B_OpenBerryField.Click += new System.EventHandler(this.B_OpenBerryField_Click); // - // B_OpenSecretBase - // - this.B_OpenSecretBase.Location = new System.Drawing.Point(96, 90); - this.B_OpenSecretBase.Name = "B_OpenSecretBase"; - this.B_OpenSecretBase.Size = new System.Drawing.Size(87, 23); - this.B_OpenSecretBase.TabIndex = 21; - this.B_OpenSecretBase.Text = "Secret Base"; - this.B_OpenSecretBase.UseVisualStyleBackColor = true; - this.B_OpenSecretBase.Visible = false; - this.B_OpenSecretBase.Click += new System.EventHandler(this.B_OpenSecretBase_Click); - // // B_Pokeblocks // this.B_Pokeblocks.Location = new System.Drawing.Point(3, 90); @@ -4486,15 +4477,16 @@ this.B_Pokeblocks.Visible = false; this.B_Pokeblocks.Click += new System.EventHandler(this.B_OpenPokeblocks_Click); // - // B_LinkInfo + // B_OpenSecretBase // - this.B_LinkInfo.Location = new System.Drawing.Point(96, 61); - this.B_LinkInfo.Name = "B_LinkInfo"; - this.B_LinkInfo.Size = new System.Drawing.Size(87, 23); - this.B_LinkInfo.TabIndex = 23; - this.B_LinkInfo.Text = "Link Data"; - this.B_LinkInfo.UseVisualStyleBackColor = true; - this.B_LinkInfo.Click += new System.EventHandler(this.B_LinkInfo_Click); + this.B_OpenSecretBase.Location = new System.Drawing.Point(96, 90); + this.B_OpenSecretBase.Name = "B_OpenSecretBase"; + this.B_OpenSecretBase.Size = new System.Drawing.Size(87, 23); + this.B_OpenSecretBase.TabIndex = 21; + this.B_OpenSecretBase.Text = "Secret Base"; + this.B_OpenSecretBase.UseVisualStyleBackColor = true; + this.B_OpenSecretBase.Visible = false; + this.B_OpenSecretBase.Click += new System.EventHandler(this.B_OpenSecretBase_Click); // // B_OpenPokepuffs // @@ -4603,16 +4595,28 @@ this.PB_Legal.TabStop = false; this.PB_Legal.Click += new System.EventHandler(this.clickLegality); // + // L_UpdateAvailable + // + this.L_UpdateAvailable.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.L_UpdateAvailable.Location = new System.Drawing.Point(305, 5); + this.L_UpdateAvailable.Name = "L_UpdateAvailable"; + this.L_UpdateAvailable.Size = new System.Drawing.Size(300, 13); + this.L_UpdateAvailable.TabIndex = 102; + this.L_UpdateAvailable.TabStop = true; + this.L_UpdateAvailable.Text = "New Update Available!"; + this.L_UpdateAvailable.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + this.L_UpdateAvailable.Visible = false; + // // Main // this.AllowDrop = true; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(614, 361); + this.Controls.Add(this.L_UpdateAvailable); this.Controls.Add(this.PB_Legal); this.Controls.Add(this.dragout); this.Controls.Add(this.tabBoxMulti); - this.Controls.Add(this.L_Save); this.Controls.Add(this.tabMain); this.Controls.Add(this.menuStrip1); this.Controls.Add(this.GB_SAVtools); @@ -4883,7 +4887,6 @@ private System.Windows.Forms.Label L_Characteristic; private System.Windows.Forms.TextBox TB_IVTotal; private System.Windows.Forms.Label L_Potential; - private System.Windows.Forms.Label L_Save; private System.Windows.Forms.TabControl tabBoxMulti; private System.Windows.Forms.TabPage Tab_Box; private System.Windows.Forms.TabPage Tab_PartyBattle; @@ -5084,6 +5087,7 @@ private System.Windows.Forms.FlowLayoutPanel FLP_PKMEditors; private System.Windows.Forms.Button B_LinkInfo; private System.Windows.Forms.Button B_CGearSkin; + private System.Windows.Forms.LinkLabel L_UpdateAvailable; } } diff --git a/PKHeX/MainWindow/Main.cs b/PKHeX/MainWindow/Main.cs index 6e413c97c..eaadc2bc3 100644 --- a/PKHeX/MainWindow/Main.cs +++ b/PKHeX/MainWindow/Main.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Drawing; +using System.Globalization; using System.IO; using System.Linq; using System.Media; @@ -17,8 +18,33 @@ namespace PKHeX { #region Initialize Form new Thread(() => new SplashScreen().ShowDialog()).Start(); - slotPkmSource = SAV.BlankPKM.EncryptedPartyData; + DragInfo.slotPkmSource = SAV.BlankPKM.EncryptedPartyData; InitializeComponent(); + + // Check for Updates + L_UpdateAvailable.Click += (sender, e) => { Process.Start(ThreadPath); }; + new Thread(() => + { + string data = Util.getStringFromURL(VersionPath); + if (data == null) + return; + try + { + DateTime upd = DateTime.ParseExact(data, "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None); + DateTime cur = DateTime.ParseExact(Properties.Resources.ProgramVersion, "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None); + + if (upd <= cur) + return; + + string message = $"New Update Available! {upd.ToString("d")}"; + if (InvokeRequired) + try { Invoke((MethodInvoker) delegate { L_UpdateAvailable.Visible = true; L_UpdateAvailable.Text = message; }); } + catch { L_UpdateAvailable.Visible = true; L_UpdateAvailable.Text = message; } + else { L_UpdateAvailable.Visible = true; L_UpdateAvailable.Text = message; } + } + catch { } + }).Start(); + CB_ExtraBytes.SelectedIndex = 0; SaveFile.SetUpdateDex = Menu_ModifyDex.Checked; SaveFile.SetUpdatePKM = Menu_ModifyPKM.Checked; @@ -54,7 +80,10 @@ namespace PKHeX foreach (PictureBox pb in PAN_Box.Controls) { pb.AllowDrop = true; // The PictureBoxes have their own drag&drop event handlers (pbBoxSlot) + pb.GiveFeedback += (sender, e) => { e.UseDefaultCursors = false; }; } + dragout.GiveFeedback += (sender, e) => { e.UseDefaultCursors = false; }; + GiveFeedback += (sender, e) => { e.UseDefaultCursors = false; }; foreach (TabPage tab in tabMain.TabPages) { tab.AllowDrop = true; @@ -148,6 +177,7 @@ namespace PKHeX public static string[] wallpapernames, puffs = { }; public static bool unicode; public static List MoveDataSource, ItemDataSource, SpeciesDataSource, BallDataSource, NatureDataSource, AbilityDataSource, VersionDataSource; + private static List metGen2, metGen3, metGen4, metGen5, metGen6; public static volatile bool formInitialized, fieldsInitialized, fieldsLoaded; private static int colorizedbox = -1; @@ -169,7 +199,7 @@ namespace PKHeX "中文", // CHN "Português", // Portuguese }; - private static string origintrack; + private static GameVersion origintrack; private readonly PictureBox[] SlotPictureBoxes, movePB, relearnPB; private readonly ToolTip Tip1 = new ToolTip(), Tip2 = new ToolTip(), Tip3 = new ToolTip(), NatureTip = new ToolTip(); #endregion @@ -180,6 +210,8 @@ namespace PKHeX public static string DatabasePath => Path.Combine(WorkingDirectory, "db"); private static string WC6DatabasePath => Path.Combine(WorkingDirectory, "wc6"); private static string BackupPath => Path.Combine(WorkingDirectory, "bak"); + private static string ThreadPath => @"https://projectpokemon.org/forums/showthread.php?36986"; + private static string VersionPath => @"https://raw.githubusercontent.com/kwsch/PKHeX/master/PKHeX/Resources/text/version.txt"; #endregion @@ -234,7 +266,7 @@ namespace PKHeX SaveFileDialog sfd = new SaveFileDialog { Filter = $"Decrypted PKM File|*.{pkx}" + - $"|Encrypted PKM File|*.{ekx}" + + (SAV.Generation > 2 ? "" : $"|Encrypted PKM File|*.{ekx}") + "|Binary File|*.bin" + "|All Files|*.*", DefaultExt = pkx, @@ -589,6 +621,8 @@ namespace PKHeX PKM pk = PKMConverter.convertToFormat(temp, SAV.Generation, out c); if (pk == null) Util.Alert("Conversion failed.", c); + else if (SAV.Generation == 1 && ((PK1) pk).Japanese != SAV.GetJapanese) + Util.Alert($"Cannot load {(SAV.GetJapanese ? "an International" : "a Japanese")} PK1 in {(SAV.GetJapanese ? "a Japanese" : "an International")} save file."); else populateFields(pk); Console.WriteLine(c); @@ -707,7 +741,7 @@ namespace PKHeX SaveFile sav = SaveUtil.getVariantSAV(input); if (sav == null || sav.Version == GameVersion.Invalid) { Util.Error("Invalid save file loaded. Aborting.", path); return; } - if (sav.Generation <= 3) // Japanese Save files are different. Get isJapanese + if (sav.Generation == 3) // Japanese Save files are different. Get isJapanese { if (sav.Version == GameVersion.Unknown) { @@ -752,7 +786,7 @@ namespace PKHeX 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 + Text = "PKHeX - " + $"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)); @@ -765,12 +799,17 @@ namespace PKHeX { SAV.FilePath = null; SAV.FileName = "Blank Save File"; - L_Save.Text = $"SAV{SAV.Generation}: {SAV.FileName} [{SAV.OT} ({SAV.Version})]"; + Text = "PKHeX - " + $"SAV{SAV.Generation}: {SAV.FileName} [{SAV.OT} ({SAV.Version})]"; GB_SAVtools.Visible = false; } Menu_ExportSAV.Enabled = B_VerifyCHK.Enabled = SAV.Exportable; + // Close subforms that are save dependent + Type[] f = { typeof(SAV_BoxViewer), typeof(f2_Text) }; + foreach (var form in Application.OpenForms.Cast
().Where(form => f.Contains(form.GetType())).ToArray()) + form.Close(); + setBoxNames(); // Display the Box Names if (SAV.HasBox) { @@ -831,11 +870,77 @@ namespace PKHeX TB_AbilityNumber.Visible = SAV.Generation >= 6 && DEV_Ability.Enabled; CB_Ability.Visible = !DEV_Ability.Enabled && SAV.Generation >= 3; + GB_ExtraBytes.Visible = SAV.Generation > 1; + GB_Markings.Visible = SAV.Generation > 2; + + Label_HeldItem.Visible = CB_HeldItem.Visible = SAV.Generation > 1; + Label_Total.Visible = TB_IVTotal.Visible = TB_EVTotal.Visible = L_Potential.Visible = + Label_HiddenPowerPrefix.Visible = CB_HPType.Visible = SAV.Generation > 1; + Label_CharacteristicPrefix.Visible = L_Characteristic.Visible = SAV.Generation > 1; + Label_ContestStats.Visible = Label_Cool.Visible = Label_Tough.Visible = Label_Smart.Visible = + Label_Sheen.Visible = Label_Beauty.Visible = Label_Cute.Visible = TB_Cool.Visible = TB_Tough.Visible = + TB_Smart.Visible = TB_Sheen.Visible = TB_Beauty.Visible = TB_Cute.Visible = Label_Nature.Visible = + CB_Nature.Visible = Label_Language.Visible = CB_Language.Visible = Label_Ability.Visible = + Label_Friendship.Visible = Label_HatchCounter.Visible = TB_Friendship.Visible = BTN_RerollPID.Visible = + Label_PID.Visible = TB_PID.Visible = Label_SID.Visible = TB_SID.Visible = SAV.Generation >= 3; + + // Met Tab + CHK_Fateful.Visible = Label_OriginGame.Visible = Label_Ball.Visible = Label_MetLevel.Visible = + CB_MetLocation.Visible = Label_MetLocation.Visible = SAV.Generation > 2 || (SAV.Version == GameVersion.GSC); + CB_GameOrigin.Visible = CB_Ball.Visible = TB_MetLevel.Visible = SAV.Generation > 2; + + CHK_Infected.Visible = CHK_Cured.Visible = SAV.Generation >= 3; + + // Second daycare slot + SlotPictureBoxes[43].Visible = SAV.Generation > 1; + + CHK_IsEgg.Visible = Label_Gender.Visible = SAV.Generation > 1; + + Label_OTGender.Visible = SAV.Generation > 1; + + if (1 <= sav.Generation && sav.Generation <= 2) + { + Label_SPD.Visible = TB_SPDEV.Visible = TB_SPDIV.Visible = Stat_SPD.Visible = false; + Label_SPA.Text = "Spc"; + TB_HPIV.ReadOnly = true; + MaskedTextBox[] evControls = { TB_SPAEV, TB_HPEV, TB_ATKEV, TB_DEFEV, TB_SPEEV, TB_SPDEV }; + foreach (var ctrl in evControls) + { + ctrl.Mask = "00000"; + ctrl.Size = new Size(37, 20); + } + Control[] statControls = {Stat_HP, Stat_ATK, Stat_DEF, Stat_SPA, Stat_SPD, Stat_SPE}; + foreach (Control ctrl in statControls) + ctrl.Location = new Point(173, ctrl.Location.Y); + Label_Stats.Location = new Point(168, Label_Stats.Location.Y); + } + else + { + Label_SPD.Visible = TB_SPDEV.Visible = TB_SPDIV.Visible = Stat_SPD.Visible = true; + Label_SPA.Text = "SpA"; + TB_HPIV.ReadOnly = false; + MaskedTextBox[] evControls = { TB_SPAEV, TB_HPEV, TB_ATKEV, TB_DEFEV, TB_SPEEV, TB_SPDEV }; + foreach (var ctrl in evControls) + { + ctrl.Mask = "000"; + ctrl.Size = new Size(31, 20); + } + Control[] statControls = { Stat_HP, Stat_ATK, Stat_DEF, Stat_SPA, Stat_SPD, Stat_SPE }; + foreach (Control ctrl in statControls) + ctrl.Location = new Point(167, ctrl.Location.Y); + Label_Stats.Location = new Point(162, Label_Stats.Location.Y); + } + // Recenter PKM SubEditors FLP_PKMEditors.Location = new Point((tabMain.TabPages[4].Width - FLP_PKMEditors.Width) / 2, FLP_PKMEditors.Location.Y); switch (SAV.Generation) { + case 1: + getFieldsfromPKM = populateFieldsPK1; + getPKMfromFields = preparePK1; + extraBytes = new byte[] {}; + break; case 3: getFieldsfromPKM = populateFieldsPK3; getPKMfromFields = preparePK3; @@ -865,7 +970,7 @@ namespace PKHeX bool init = fieldsInitialized; fieldsInitialized = false; populateFilteredDataSources(); - populateFields(pkm.Format != SAV.Generation ? SAV.BlankPKM : pk); + populateFields((pkm.Format != SAV.Generation || SAV.Generation == 1) ? SAV.BlankPKM : pk); fieldsInitialized |= init; // SAV Specific Limits @@ -878,10 +983,13 @@ namespace PKHeX TB_Level.Visible = !HaX; // Load Extra Byte List - CB_ExtraBytes.Items.Clear(); - foreach (byte b in extraBytes) - CB_ExtraBytes.Items.Add("0x" + b.ToString("X2")); - CB_ExtraBytes.SelectedIndex = 0; + if (GB_ExtraBytes.Visible) + { + CB_ExtraBytes.Items.Clear(); + foreach (byte b in extraBytes) + CB_ExtraBytes.Items.Add("0x" + b.ToString("X2")); + CB_ExtraBytes.SelectedIndex = 0; + } // Refresh PK#->PK6 conversion info PKMConverter.updateConfig(SAV.SubRegion, SAV.Country, SAV.ConsoleRegion, SAV.OT, SAV.Gender); @@ -1043,7 +1151,7 @@ namespace PKHeX abilitylist[0] = itemlist[0] = movelist[0] = metXY_00000[0] = metBW2_00000[0] = metHGSS_00000[0] = "(" + itemlist[0] + ")"; // Force an update to the met locations - origintrack = ""; + origintrack = GameVersion.Unknown; // Update Legality Analysis strings LegalityAnalysis.movelist = movelist; @@ -1100,6 +1208,54 @@ namespace PKHeX MoveDataSource = Util.getCBList(movelist, null); + #region Met Locations + // Gen 2 + { + var met_list = Util.getCBList(metRSEFRLG_00000, Enumerable.Range(0, 0x5F).ToArray()); + met_list = Util.getOffsetCBList(met_list, metRSEFRLG_00000, 00000, new[] { 253, 254, 255 }); + metGen2 = null; + } + // Gen 3 + { + var met_list = Util.getCBList(metRSEFRLG_00000, Enumerable.Range(0, 213).ToArray()); + met_list = Util.getOffsetCBList(met_list, metRSEFRLG_00000, 00000, new[] { 253, 254, 255 }); + metGen3 = met_list; + } + // Gen 4 + { + var met_list = Util.getCBList(metHGSS_00000, new[] { 0 }); + met_list = Util.getOffsetCBList(met_list, metHGSS_02000, 2000, new[] { 2000 }); + met_list = Util.getOffsetCBList(met_list, metHGSS_02000, 2000, new[] { 2002 }); + met_list = Util.getOffsetCBList(met_list, metHGSS_03000, 3000, new[] { 3001 }); + met_list = Util.getOffsetCBList(met_list, metHGSS_00000, 0000, Legal.Met_HGSS_0); + met_list = Util.getOffsetCBList(met_list, metHGSS_02000, 2000, Legal.Met_HGSS_2); + met_list = Util.getOffsetCBList(met_list, metHGSS_03000, 3000, Legal.Met_HGSS_3); + metGen4 = met_list; + } + // Gen 5 + { + var met_list = Util.getCBList(metBW2_00000, new[] { 0 }); + met_list = Util.getOffsetCBList(met_list, metBW2_60000, 60001, new[] { 60002 }); + met_list = Util.getOffsetCBList(met_list, metBW2_30000, 30001, new[] { 30003 }); + met_list = Util.getOffsetCBList(met_list, metBW2_00000, 00000, Legal.Met_BW2_0); + met_list = Util.getOffsetCBList(met_list, metBW2_30000, 30001, Legal.Met_BW2_3); + met_list = Util.getOffsetCBList(met_list, metBW2_40000, 40001, Legal.Met_BW2_4); + met_list = Util.getOffsetCBList(met_list, metBW2_60000, 60001, Legal.Met_BW2_6); + metGen5 = met_list; + } + // Gen 6 + { + var met_list = Util.getCBList(metXY_00000, new[] { 0 }); + met_list = Util.getOffsetCBList(met_list, metXY_60000, 60001, new[] { 60002 }); + met_list = Util.getOffsetCBList(met_list, metXY_30000, 30001, new[] { 30002 }); + met_list = Util.getOffsetCBList(met_list, metXY_00000, 00000, Legal.Met_XY_0); + met_list = Util.getOffsetCBList(met_list, metXY_30000, 30001, Legal.Met_XY_3); + met_list = Util.getOffsetCBList(met_list, metXY_40000, 40001, Legal.Met_XY_4); + met_list = Util.getOffsetCBList(met_list, metXY_60000, 60001, Legal.Met_XY_6); + metGen6 = met_list; + } + #endregion + CB_EncounterType.DataSource = Util.getCBList(encountertypelist, new[] { 0 }, Legal.Gen4EncounterTypes); CB_HPType.DataSource = Util.getCBList(types.Skip(1).Take(16).ToArray(), null); CB_Nature.DataSource = new BindingSource(NatureDataSource, null); @@ -1108,12 +1264,15 @@ namespace PKHeX } private void populateFilteredDataSources() { - string[] items = itemlist; - if (SAV.Generation == 3) - items = g3items; + if (SAV.Generation > 1) + { + string[] items = itemlist; + if (SAV.Generation == 3) + items = g3items; - ItemDataSource = Util.getCBList(items, (HaX ? Enumerable.Range(0, SAV.MaxItemID) : SAV.HeldItems.Select(i => (int)i)).ToArray()); - CB_HeldItem.DataSource = new BindingSource(ItemDataSource.Where(i => i.Value <= SAV.MaxItemID).ToList(), null); + ItemDataSource = Util.getCBList(items, (HaX ? Enumerable.Range(0, SAV.MaxItemID) : SAV.HeldItems.Select(i => (int)i)).ToArray()); + CB_HeldItem.DataSource = new BindingSource(ItemDataSource.Where(i => i.Value <= SAV.MaxItemID).ToList(), null); + } CB_Ball.DataSource = new BindingSource(BallDataSource.Where(b => b.Value <= SAV.MaxBallID).ToList(), null); CB_Species.DataSource = new BindingSource(SpeciesDataSource.Where(s => s.Value <= SAV.MaxSpeciesID).ToList(), null); @@ -1225,6 +1384,8 @@ namespace PKHeX formnum = CB_Form.SelectedIndex; int[] abils = SAV.Personal.getAbilities(species, formnum); + if (abils[1] == 0) + abils[1] = abils[0]; string[] abilIdentifier = {" (1)", " (2)", " (H)"}; List ability_list = abils.Where(a => a != 0).Select((t, i) => abilitylist[t] + abilIdentifier[i]).ToList(); if (!ability_list.Any()) @@ -1247,8 +1408,8 @@ namespace PKHeX bool isShiny = pkm.IsShiny; // Set the Controls - BTN_Shinytize.Visible = BTN_Shinytize.Enabled = !isShiny; - Label_IsShiny.Visible = isShiny; + BTN_Shinytize.Visible = BTN_Shinytize.Enabled = !isShiny && SAV.Generation > 2; + Label_IsShiny.Visible = isShiny && SAV.Generation > 1; // Refresh Markings (for Shiny Star if applicable) setMarkings(); @@ -1494,7 +1655,11 @@ namespace PKHeX } changingFields = false; if (fieldsLoaded) + { pkm.EXP = Util.ToUInt32(TB_EXP.Text); + if (SAV.Generation < 3) + pkm.Stat_Level = Util.ToInt32(TB_Level.Text); + } updateStats(); updateLegality(); } @@ -1524,8 +1689,8 @@ namespace PKHeX private void updateIVs(object sender, EventArgs e) { if (changingFields || !fieldsInitialized) return; - if (sender != null && Util.ToInt32(((MaskedTextBox) sender).Text) > 31) - ((MaskedTextBox) sender).Text = "31"; + if (sender != null && Util.ToInt32(((MaskedTextBox) sender).Text) > SAV.MaxIV) + ((MaskedTextBox) sender).Text = SAV.MaxIV.ToString("00"); changingFields = true; @@ -1536,6 +1701,11 @@ namespace PKHeX pkm.IV_SPE = Util.ToInt32(TB_SPEIV.Text); pkm.IV_SPA = Util.ToInt32(TB_SPAIV.Text); pkm.IV_SPD = Util.ToInt32(TB_SPDIV.Text); + + if (SAV.Generation < 3) + { + TB_HPIV.Text = pkm.IV_HP.ToString("00"); + } CB_HPType.SelectedValue = pkm.HPType; changingFields = false; @@ -1591,30 +1761,31 @@ namespace PKHeX if (ModifierKeys == Keys.Control || ModifierKeys == Keys.Shift) { // Max IVs - TB_HPIV.Text = 31.ToString(); - TB_ATKIV.Text = 31.ToString(); - TB_DEFIV.Text = 31.ToString(); - TB_SPAIV.Text = 31.ToString(); - TB_SPDIV.Text = 31.ToString(); - TB_SPEIV.Text = 31.ToString(); + TB_HPIV.Text = SAV.MaxIV.ToString(); + TB_ATKIV.Text = SAV.MaxIV.ToString(); + TB_DEFIV.Text = SAV.MaxIV.ToString(); + TB_SPAIV.Text = SAV.MaxIV.ToString(); + TB_SPDIV.Text = SAV.MaxIV.ToString(); + TB_SPEIV.Text = SAV.MaxIV.ToString(); } else { - TB_HPIV.Text = (Util.rnd32() & 0x1F).ToString(); - TB_ATKIV.Text = (Util.rnd32() & 0x1F).ToString(); - TB_DEFIV.Text = (Util.rnd32() & 0x1F).ToString(); - TB_SPAIV.Text = (Util.rnd32() & 0x1F).ToString(); - TB_SPDIV.Text = (Util.rnd32() & 0x1F).ToString(); - TB_SPEIV.Text = (Util.rnd32() & 0x1F).ToString(); + TB_HPIV.Text = (Util.rnd32() & SAV.MaxIV).ToString(); + TB_ATKIV.Text = (Util.rnd32() & SAV.MaxIV).ToString(); + TB_DEFIV.Text = (Util.rnd32() & SAV.MaxIV).ToString(); + TB_SPAIV.Text = (Util.rnd32() & SAV.MaxIV).ToString(); + TB_SPDIV.Text = (Util.rnd32() & SAV.MaxIV).ToString(); + TB_SPEIV.Text = (Util.rnd32() & SAV.MaxIV).ToString(); } changingFields = false; updateIVs(null, null); } private void updateRandomEVs(object sender, EventArgs e) { + changingFields = true; if (ModifierKeys == Keys.Control || ModifierKeys == Keys.Shift) { - // Max IVs + // Max EVs TB_HPEV.Text = 0.ToString(); TB_ATKEV.Text = 0.ToString(); TB_DEFEV.Text = 0.ToString(); @@ -1624,7 +1795,7 @@ namespace PKHeX } else { - byte[] evs = PKX.getRandomEVs(); + var evs = PKX.getRandomEVs(SAV.Generation); TB_HPEV.Text = evs[0].ToString(); TB_ATKEV.Text = evs[1].ToString(); TB_DEFEV.Text = evs[2].ToString(); @@ -1632,6 +1803,8 @@ namespace PKHeX TB_SPDEV.Text = evs[4].ToString(); TB_SPEEV.Text = evs[5].ToString(); } + changingFields = false; + updateEVs(null, null); } private void updateRandomPID(object sender, EventArgs e) { @@ -1649,6 +1822,9 @@ namespace PKHeX pkm.setPIDNature(Util.getIndex(CB_Nature)); else if (sender == BTN_RerollPID) pkm.setPIDGender(pkm.Gender); + else if (sender == CB_Ability && CB_Ability.SelectedIndex != pkm.PIDAbility && pkm.PIDAbility > -1) + pkm.PID = PKX.getRandomPID(pkm.Species, pkm.Gender, pkm.Version, pkm.Nature, pkm.Format, (uint)(CB_Ability.SelectedIndex * 0x10001)); + TB_PID.Text = pkm.PID.ToString("X8"); getQuickFiller(dragout); if (pkm.GenNumber < 6 && TB_EC.Visible) @@ -1713,7 +1889,10 @@ namespace PKHeX if (Util.getIndex(CB_Species) == 201) { if (fieldsLoaded && SAV.Generation == 3) - updateRandomPID(sender, e); // Fix AltForm + { + pkm.setPIDUnown3(CB_Form.SelectedIndex); + TB_PID.Text = pkm.PID.ToString("X8"); + } } else if (PKX.getGender(CB_Form.Text) < 2) Label_Gender.Text = CB_Form.Text; @@ -1864,114 +2043,112 @@ namespace PKHeX updateLegality(); } + private IEnumerable getLocationList(GameVersion Version, int SaveFormat, bool egg) + { + if (egg) + { + if (Version < GameVersion.W && SaveFormat >= 5) + return metGen4; + } + + switch (Version) + { + case GameVersion.CXD: + if (SaveFormat == 3) + return metGen3; + break; + + case GameVersion.R: + case GameVersion.S: + if (SaveFormat == 3) + return metGen3.OrderByDescending(loc => loc.Value <= 87); // Ferry + break; + case GameVersion.E: + if (SaveFormat == 3) + return metGen3.OrderByDescending(loc => loc.Value <= 87 || (loc.Value >= 196 && loc.Value <= 212)); // Trainer Hill + break; + case GameVersion.FR: + case GameVersion.LG: + if (SaveFormat == 3) + return metGen3.OrderByDescending(loc => loc.Value > 87 && loc.Value < 197); // Celadon Dept. + break; + + case GameVersion.D: + case GameVersion.P: + if (SaveFormat == 4 || (SaveFormat >= 5 && egg)) + return metGen4.Take(4).Concat(metGen6.Skip(4).OrderByDescending(loc => loc.Value <= 111)); // Battle Park + break; + + case GameVersion.Pt: + if (SaveFormat == 4 || (SaveFormat >= 5 && egg)) + return metGen4.Take(4).Concat(metGen6.Skip(4).OrderByDescending(loc => loc.Value <= 125)); // Rock Peak Ruins + break; + + case GameVersion.HG: + case GameVersion.SS: + if (SaveFormat == 4 || (SaveFormat >= 5 && egg)) + return metGen4.Take(4).Concat(metGen6.Skip(4).OrderByDescending(loc => loc.Value > 125 && loc.Value < 234)); // Celadon Dept. + break; + + case GameVersion.B: + case GameVersion.W: + return metGen5; + + case GameVersion.B2: + case GameVersion.W2: + return metGen5.Take(3).Concat(metGen5.Skip(3).OrderByDescending(loc => loc.Value <= 116)); // Abyssal Ruins + + case GameVersion.X: + case GameVersion.Y: + return metGen6.Take(3).Concat(metGen6.Skip(3).OrderByDescending(loc => loc.Value <= 168)); // Unknown Dungeon + + case GameVersion.OR: + case GameVersion.AS: + return metGen6.Take(3).Concat(metGen6.Skip(3).OrderByDescending(loc => loc.Value > 168 && loc.Value <= 354)); // Secret Base + } + + // Currently on a future game, return corresponding list for generation + if (Version <= GameVersion.CXD && SaveFormat == 4) + return metGen4.Where(loc => loc.Value == 0x37) // Pal Park to front + .Concat(metGen4.Take(4)) + .Concat(metGen4.Skip(4).Where(loc => loc.Value != 0x37)); + + if (Version < GameVersion.X && SaveFormat >= 5) // PokéTransfer to front + return metGen5.Where(loc => loc.Value == 30001) + .Concat(metGen5.Take(3)) + .Concat(metGen5.Skip(3).Where(loc => loc.Value != 30001)); + + return metGen6; + } private void updateOriginGame(object sender, EventArgs e) { - int Version = Util.getIndex(CB_GameOrigin); - - if (SAV.Generation == 3 && origintrack != "Gen3") + GameVersion Version = (GameVersion)Util.getIndex(CB_GameOrigin); + + // check if differs + GameVersion newTrack = SaveUtil.getVersionGroup(Version); + if (newTrack != origintrack) { - var met_list = Util.getCBList(metRSEFRLG_00000, Enumerable.Range(0, 213).ToArray()); - met_list = Util.getOffsetCBList(met_list, metRSEFRLG_00000, 00000, new[] {253, 254, 255}); - origintrack = "Gen3"; + var met_list = getLocationList(Version, SAV.Generation, egg:false); CB_MetLocation.DisplayMember = "Text"; CB_MetLocation.ValueMember = "Value"; - CB_MetLocation.DataSource = met_list; - CB_MetLocation.SelectedValue = 0; - } - else if (SAV.Generation == 4 && origintrack != "Gen4") - { - var met_list = Util.getCBList(metHGSS_00000, new[] { 0 }); - met_list = Util.getOffsetCBList(met_list, metHGSS_02000, 2000, new[] { 2000 }); - met_list = Util.getOffsetCBList(met_list, metHGSS_02000, 2000, new[] { 2002 }); - met_list = Util.getOffsetCBList(met_list, metHGSS_03000, 3000, new[] { 3001 }); - met_list = Util.getOffsetCBList(met_list, metHGSS_00000, 0000, Legal.Met_HGSS_0); - met_list = Util.getOffsetCBList(met_list, metHGSS_02000, 2000, Legal.Met_HGSS_2); - met_list = Util.getOffsetCBList(met_list, metHGSS_03000, 3000, Legal.Met_HGSS_3); - CB_MetLocation.DisplayMember = "Text"; - CB_MetLocation.ValueMember = "Value"; - CB_MetLocation.DataSource = met_list; + CB_MetLocation.DataSource = new BindingSource(met_list, null); + CB_MetLocation.SelectedIndex = 0; // transporter or pal park for past gen pkm + + var egg_list = getLocationList(Version, SAV.Generation, egg:true); CB_EggLocation.DisplayMember = "Text"; CB_EggLocation.ValueMember = "Value"; - CB_EggLocation.DataSource = new BindingSource(met_list, null); - CB_EggLocation.SelectedValue = 0; - CB_MetLocation.SelectedValue = 0; - origintrack = "Gen4"; - } - else if (Version < 24 && origintrack != "Past" && SAV.Generation >= 5) - { - // Load Past Gen Locations - #region B2W2 Met Locations - { - // Build up our met list - var met_list = Util.getCBList(metBW2_00000, new[] { 0 }); - met_list = Util.getOffsetCBList(met_list, metBW2_60000, 60001, new[] { 60002 }); - met_list = Util.getOffsetCBList(met_list, metBW2_30000, 30001, new[] { 30003 }); - met_list = Util.getOffsetCBList(met_list, metBW2_00000, 00000, Legal.Met_BW2_0); - met_list = Util.getOffsetCBList(met_list, metBW2_30000, 30001, Legal.Met_BW2_3); - met_list = Util.getOffsetCBList(met_list, metBW2_40000, 40001, Legal.Met_BW2_4); - met_list = Util.getOffsetCBList(met_list, metBW2_60000, 60001, Legal.Met_BW2_6); - CB_MetLocation.DisplayMember = "Text"; - CB_MetLocation.ValueMember = "Value"; - CB_MetLocation.DataSource = met_list; - CB_EggLocation.DisplayMember = "Text"; - CB_EggLocation.ValueMember = "Value"; - CB_EggLocation.DataSource = new BindingSource(met_list, null); - CB_EggLocation.SelectedValue = 0; - CB_MetLocation.SelectedValue = Version < 20 ? 30001 : 60001; - origintrack = "Past"; - } - #endregion - } - else if (Version > 23 && origintrack != "XY") - { - // Load X/Y/OR/AS locations - #region ORAS Met Locations - { - // Build up our met list - var met_list = Util.getCBList(metXY_00000, new[] { 0 }); - met_list = Util.getOffsetCBList(met_list, metXY_60000, 60001, new[] { 60002 }); - met_list = Util.getOffsetCBList(met_list, metXY_30000, 30001, new[] { 30002 }); - met_list = Util.getOffsetCBList(met_list, metXY_00000, 00000, Legal.Met_XY_0); - met_list = Util.getOffsetCBList(met_list, metXY_30000, 30001, Legal.Met_XY_3); - met_list = Util.getOffsetCBList(met_list, metXY_40000, 40001, Legal.Met_XY_4); - met_list = Util.getOffsetCBList(met_list, metXY_60000, 60001, Legal.Met_XY_6); - CB_MetLocation.DisplayMember = "Text"; - CB_MetLocation.ValueMember = "Value"; - CB_MetLocation.DataSource = met_list; - CB_EggLocation.DisplayMember = "Text"; - CB_EggLocation.ValueMember = "Value"; - CB_EggLocation.DataSource = new BindingSource(met_list, null); - CB_EggLocation.SelectedValue = 0; - CB_MetLocation.SelectedValue = 0; - origintrack = "XY"; - } - #endregion - } + CB_EggLocation.DataSource = new BindingSource(egg_list, null); + CB_EggLocation.SelectedIndex = CHK_AsEgg.Checked ? 1 : 0; // daycare : none - if (SAV.Generation >= 4 && Version < 0x10 && origintrack != "Gen4") - { - // Load Gen 4 egg locations if Gen 4 Origin. - #region HGSS Met Locations - var met_list = Util.getCBList(metHGSS_00000, new[] { 0 }); - met_list = Util.getOffsetCBList(met_list, metHGSS_02000, 2000, new[] { 2000 }); - met_list = Util.getOffsetCBList(met_list, metHGSS_02000, 2000, new[] { 2002 }); - met_list = Util.getOffsetCBList(met_list, metHGSS_03000, 3000, new[] { 3001 }); - met_list = Util.getOffsetCBList(met_list, metHGSS_00000, 0000, Legal.Met_HGSS_0); - met_list = Util.getOffsetCBList(met_list, metHGSS_02000, 2000, Legal.Met_HGSS_2); - met_list = Util.getOffsetCBList(met_list, metHGSS_03000, 3000, Legal.Met_HGSS_3); - - CB_EggLocation.DisplayMember = "Text"; - CB_EggLocation.ValueMember = "Value"; - CB_EggLocation.DataSource = met_list; - CB_EggLocation.SelectedValue = 0; - origintrack = "Gen4"; - #endregion + origintrack = newTrack; } // Visibility logic for Gen 4 encounter type; only show for Gen 4 Pokemon. if (SAV.Generation >= 4) { - bool g4 = Version >= 7 && Version <= 12 && Version != 9; + bool g4 = Version >= GameVersion.HG && Version <= GameVersion.Pt; + if ((int) Version == 9) // invalid + g4 = false; CB_EncounterType.Visible = Label_EncounterType.Visible = g4; if (!g4) CB_EncounterType.SelectedValue = 0; @@ -1980,7 +2157,7 @@ namespace PKHeX setMarkings(); // Set/Remove KB marking if (!fieldsLoaded) return; - pkm.Version = Version; + pkm.Version = (int)Version; updateLegality(); } private void updateExtraByteValue(object sender, EventArgs e) @@ -2043,6 +2220,8 @@ namespace PKHeX if (SAV.Generation < 5) // All caps GenIV and previous nick = nick.ToUpper(); TB_Nickname.Text = nick; + if (SAV.Generation == 1) + ((PK1)pkm).setNotNicknamed(); } } private void updateNicknameClick(object sender, MouseEventArgs e) @@ -2097,8 +2276,9 @@ namespace PKHeX } } // Display hatch counter if it is an egg, Display Friendship if it is not. - Label_HatchCounter.Visible = CHK_IsEgg.Checked; - Label_Friendship.Visible = !CHK_IsEgg.Checked; + Label_HatchCounter.Visible = CHK_IsEgg.Checked && SAV.Generation > 1; + Label_Friendship.Visible = !CHK_IsEgg.Checked && SAV.Generation > 2; + // Update image to (not) show egg. if (!fieldsInitialized) return; @@ -2200,10 +2380,15 @@ namespace PKHeX if (!fieldsInitialized) return; validateComboBox(sender, e); - if (sender == CB_Ability) - TB_AbilityNumber.Text = (1 << CB_Ability.SelectedIndex).ToString(); - if (fieldsLoaded && sender == CB_Nature && SAV.Generation <= 4) - updateRandomPID(sender, e); + if (fieldsLoaded) + { + if (sender == CB_Ability && SAV.Generation >= 6) + TB_AbilityNumber.Text = (1 << CB_Ability.SelectedIndex).ToString(); + if (sender == CB_Ability && SAV.Generation <= 5 && CB_Ability.SelectedIndex < 2) // not hidden + updateRandomPID(sender, e); + if (sender == CB_Nature && SAV.Generation <= 4) + updateRandomPID(sender, e); + } updateNatureModification(sender, null); updateIVs(null, null); // updating Nature will trigger stats to update as well } @@ -2218,28 +2403,13 @@ namespace PKHeX if (new[] { CB_Move1, CB_Move2, CB_Move3, CB_Move4 }.Contains(sender)) // Move updatePP(sender, e); - // Refresh Relearn if... - if (new[] { CB_RelearnMove1, CB_RelearnMove2, CB_RelearnMove3, CB_RelearnMove4 }.Contains(sender)) - { - if (pkm.Format < 6) - return; - ((PK6) pkm).RelearnMoves = new[] { Util.getIndex(CB_RelearnMove1), Util.getIndex(CB_RelearnMove2), Util.getIndex(CB_RelearnMove3), Util.getIndex(CB_RelearnMove4) }; - Legality.updateRelearnLegality(); - for (int i = 0; i < 4; i++) - movePB[i].Visible = !Legality.vRelearn[i].Valid; - } - // else, Refresh Moves - { - pkm.Moves = new[] { Util.getIndex(CB_Move1), Util.getIndex(CB_Move2), Util.getIndex(CB_Move3), Util.getIndex(CB_Move4) }; - Legality.updateMoveLegality(); - for (int i = 0; i < 4; i++) - movePB[i].Visible = !Legality.vMoves[i].Valid; - } - if (relearnPB.Any(p => p.Visible) || movePB.Any(p => p.Visible)) - { - Legality.Valid = false; - PB_Legal.Image = Properties.Resources.warn; - } + if (pkm.Format < 6) + return; + + // Legality + pkm.Moves = new[] { Util.getIndex(CB_Move1), Util.getIndex(CB_Move2), Util.getIndex(CB_Move3), Util.getIndex(CB_Move4) }; + pkm.RelearnMoves = new[] { Util.getIndex(CB_RelearnMove1), Util.getIndex(CB_RelearnMove2), Util.getIndex(CB_RelearnMove3), Util.getIndex(CB_RelearnMove4) }; + updateLegality(); } private void validateLocation(object sender, EventArgs e) { @@ -2275,8 +2445,15 @@ namespace PKHeX // Refresh Move Legality for (int i = 0; i < 4; i++) movePB[i].Visible = !Legality.vMoves[i].Valid && !HaX; + + int[] suggested = Legality.getSuggestedRelearn(); for (int i = 0; i < 4; i++) - relearnPB[i].Visible = !Legality.vRelearn[i].Valid && !HaX; + { + if (pkm.RelearnMoves[i] == 0 && suggested[i] != 0) + relearnPB[i].Visible = !HaX; + else + relearnPB[i].Visible = !Legality.vRelearn[i].Valid && !HaX; + } } private void updateStats() { @@ -2366,7 +2543,7 @@ namespace PKHeX for (int i = 0; i < cba.Length; i++) { int back = cba[i].BackColor.ToArgb(); - if (back == SystemColors.Control.ToArgb() || back == 0 || + if (!cba[i].Visible || back == SystemColors.Control.ToArgb() || back == 0 || !(back != -1 & back != defaultControlWhite.ToArgb())) continue; if (i < 6) // Main Tab tabMain.SelectedIndex = 0; @@ -2378,7 +2555,7 @@ namespace PKHeX } #endregion // Further logic checking - if (Convert.ToUInt32(TB_EVTotal.Text) > 510 && !CHK_HackedStats.Checked) + if (SAV.Generation >= 3 && Convert.ToUInt32(TB_EVTotal.Text) > 510 && !CHK_HackedStats.Checked) { tabMain.SelectedIndex = 2; goto invalid; } // If no errors detected... if (Util.getIndex(CB_Species) != 0) return true; @@ -2389,18 +2566,21 @@ namespace PKHeX invalid: { SystemSounds.Exclamation.Play(); return false; } } - private static string[] verifyPKMtoSAV(PKM pk) + public static string[] verifyPKMtoSAV(PKM pk) { // Check if PKM properties are outside of the valid range List errata = new List(); - if (pk.HeldItem > itemlist.Length) - errata.Add($"Item Index beyond range: {pk.HeldItem}"); - else + if (SAV.Generation > 1) { - if (pk.HeldItem > SAV.MaxItemID) - errata.Add($"Game can't obtain item: {itemlist[pk.HeldItem]}"); - if (!pk.CanHoldItem(SAV.HeldItems)) - errata.Add($"Game can't hold item: {itemlist[pk.HeldItem]}"); + if (pk.HeldItem > itemlist.Length) + errata.Add($"Item Index beyond range: {pk.HeldItem}"); + else + { + if (pk.HeldItem > SAV.MaxItemID) + errata.Add($"Game can't obtain item: {itemlist[pk.HeldItem]}"); + if (!pk.CanHoldItem(SAV.HeldItems)) + errata.Add($"Game can't hold item: {itemlist[pk.HeldItem]}"); + } } if (pk.Species > specieslist.Length) @@ -2440,6 +2620,9 @@ namespace PKHeX { string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); openQuick(files[0]); + e.Effect = DragDropEffects.Copy; + + Cursor = DefaultCursor; } // Decrypted Export private void dragout_MouseDown(object sender, MouseEventArgs e) @@ -2461,10 +2644,13 @@ namespace PKHeX try { File.WriteAllBytes(newfile, dragdata); + PictureBox pb = (PictureBox)sender; + Cursor = DragInfo.Cursor = new Cursor(((Bitmap)pb.Image).GetHicon()); DoDragDrop(new DataObject(DataFormats.FileDrop, new[] { newfile }), DragDropEffects.Move); } catch (Exception x) { Util.Error("Drag & Drop Error", x.ToString()); } + Cursor = DragInfo.Cursor = DefaultCursor; File.Delete(newfile); } private void dragout_DragOver(object sender, DragEventArgs e) @@ -2482,7 +2668,11 @@ namespace PKHeX } private void dragoutDrop(object sender, DragEventArgs e) { - openQuick(((string[])e.Data.GetData(DataFormats.FileDrop))[0]); + string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); + openQuick(files[0]); + e.Effect = DragDropEffects.Copy; + + Cursor = DefaultCursor; } #endregion @@ -2558,7 +2748,7 @@ namespace PKHeX } private void clickBoxSort(object sender, EventArgs e) { - if (tabBoxMulti.SelectedIndex != 0) + if (tabBoxMulti.SelectedTab != Tab_Box) return; if (!SAV.HasBox) return; @@ -2599,6 +2789,31 @@ namespace PKHeX Util.Alert("Current Box sorted!"); } } + private void clickBoxDouble(object sender, MouseEventArgs e) + { + if (tabBoxMulti.SelectedTab == Tab_SAV) + { + clickSaveFileName(sender, e); + return; + } + if (tabBoxMulti.SelectedTab != Tab_Box) + return; + if (!SAV.HasBox) + return; + if (ModifierKeys != Keys.Shift) + { + var z = Application.OpenForms.Cast().FirstOrDefault(form => form.GetType() == typeof(SAV_BoxViewer)) as SAV_BoxViewer; + if (z != null) + { Util.CenterToForm(z, this); z.BringToFront(); return; } + } + new SAV_BoxViewer(this).Show(); + } + public int swapBoxesViewer(int viewBox) + { + int mainBox = CB_BoxSelect.SelectedIndex; + CB_BoxSelect.SelectedIndex = viewBox; + return mainBox; + } private void clickSlot(object sender, EventArgs e) { @@ -2812,6 +3027,28 @@ namespace PKHeX SAV.Edited = true; } } + + private void updateIsNicknamed(object sender, EventArgs e) + { + if (!CHK_Nicknamed.Checked) + { + int species = Util.getIndex(CB_Species); + if (species < 1 || species > SAV.MaxSpeciesID) + return; + int lang = Util.getIndex(CB_Language); + if (CHK_IsEgg.Checked) species = 0; // Set species to 0 to get the egg name. + string nick = PKX.getSpeciesName(CHK_IsEgg.Checked ? 0 : species, lang); + + if (SAV.Generation < 5) // All caps GenIV and previous + nick = nick.ToUpper(); + if (TB_Nickname.Text != nick) + { + CHK_Nicknamed.Checked = true; + pkm.Nickname = TB_Nickname.Text; + } + } + } + // Generic Subfunctions // private void setParty() { @@ -2869,9 +3106,18 @@ namespace PKHeX int boxoffset = SAV.getBoxOffset(CB_BoxSelect.SelectedIndex); int boxbgval = SAV.getBoxWallpaper(CB_BoxSelect.SelectedIndex); PAN_Box.BackgroundImage = BoxWallpaper.getWallpaper(SAV, boxbgval); - for (int i = 0; i < 30; i++) - getSlotFiller(boxoffset + SAV.SIZE_STORED * i, SlotPictureBoxes[i]); + { + if (i < SAV.BoxSlotCount) + { + getSlotFiller(boxoffset + SAV.SIZE_STORED * i, SlotPictureBoxes[i]); + } + else + { + SlotPictureBoxes[i].Image = null; + SlotPictureBoxes[i].Visible = false; + } + } } // Reload Party @@ -2961,8 +3207,8 @@ namespace PKHeX catch { CB_BoxSelect.Items.Clear(); - for (int i = 0; i < SAV.BoxCount; i++) - CB_BoxSelect.Items.Add("BOX " + (i+1)); + for (int i = 1; i <= SAV.BoxCount; i++) + CB_BoxSelect.Items.Add($"BOX {i}"); } if (selectedbox < CB_BoxSelect.Items.Count) CB_BoxSelect.SelectedIndex = selectedbox; // restore selected box @@ -2973,7 +3219,7 @@ namespace PKHeX pk = pk ?? preparePKM(false); // don't perform control loss click if (pb == dragout) mnuLQR.Enabled = pk.Species != 0; // Species - pb.Image = pk.Sprite; + pb.Image = pk.Species != 0 ? pk.Sprite : null; if (pb.BackColor == Color.Red) pb.BackColor = Color.Transparent; } @@ -2984,6 +3230,7 @@ namespace PKHeX // 00s present in slot. pb.Image = null; pb.BackColor = Color.Transparent; + pb.Visible = true; return; } PKM p = SAV.getStoredSlot(offset); @@ -2992,11 +3239,13 @@ namespace PKHeX // Bad Egg present in slot. pb.Image = null; pb.BackColor = Color.Red; + pb.Visible = true; return; } // Something stored in slot. Only display if species is valid. pb.Image = p.Species == 0 ? null : p.Sprite; pb.BackColor = Color.Transparent; + pb.Visible = true; } private void getSlotColor(int slot, Image color) { @@ -3012,6 +3261,7 @@ namespace PKHeX } private void getBox(object sender, EventArgs e) { + SAV.CurrentBox = CB_BoxSelect.SelectedIndex; setPKXBoxes(); } private void switchDaycare(object sender, EventArgs e) @@ -3197,6 +3447,8 @@ namespace PKHeX new SAV_PokedexORAS().ShowDialog(); else if (SAV.XY) new SAV_PokedexXY().ShowDialog(); + else if (SAV.RBY) + new SAV_SimplePokedex().ShowDialog(); } private void B_OUTPasserby_Click(object sender, EventArgs e) { @@ -3293,7 +3545,7 @@ namespace PKHeX // Drag and drop related functions private void pbBoxSlot_MouseClick(object sender, MouseEventArgs e) { - if (slotDragDropInProgress) + if (DragInfo.slotDragDropInProgress) return; clickSlot(sender, e); @@ -3301,43 +3553,45 @@ namespace PKHeX private void pbBoxSlot_MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) - slotLeftMouseIsDown = false; + DragInfo.slotLeftMouseIsDown = false; if (e.Button == MouseButtons.Right) - slotRightMouseIsDown = false; + DragInfo.slotRightMouseIsDown = false; } private void pbBoxSlot_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) - slotLeftMouseIsDown = true; + DragInfo.slotLeftMouseIsDown = true; if (e.Button == MouseButtons.Right) - slotRightMouseIsDown = true; + DragInfo.slotRightMouseIsDown = true; } private void pbBoxSlot_MouseMove(object sender, MouseEventArgs e) { - if (slotDragDropInProgress) + if (DragInfo.slotDragDropInProgress) return; - if (slotLeftMouseIsDown) + if (DragInfo.slotLeftMouseIsDown) { // The goal is to create a temporary PKX file for the underlying Pokemon // and use that file to perform a drag drop operation. // Abort if there is no Pokemon in the given slot. - if (((PictureBox)sender).Image == null) + PictureBox pb = (PictureBox)sender; + if (pb.Image == null) return; // Set flag to prevent re-entering. - slotDragDropInProgress = true; + DragInfo.slotDragDropInProgress = true; - slotSourceSlotNumber = getSlot(sender); - int offset = getPKXOffset(slotSourceSlotNumber); + DragInfo.slotSourceSlotNumber = getSlot(pb); + int offset = getPKXOffset(DragInfo.slotSourceSlotNumber); // Prepare Data - slotPkmSource = SAV.getData(offset, SAV.SIZE_STORED); - slotSourceOffset = offset; + DragInfo.slotPkmSource = SAV.getData(offset, SAV.SIZE_STORED); + DragInfo.slotSourceOffset = offset; + DragInfo.slotSourceBoxNumber = DragInfo.slotSourceSlotNumber >= 30 ? -1 : CB_BoxSelect.SelectedIndex; // Make a new file name based off the PID - byte[] dragdata = SAV.decryptPKM(slotPkmSource); + byte[] dragdata = SAV.decryptPKM(DragInfo.slotPkmSource); Array.Resize(ref dragdata, SAV.SIZE_STORED); PKM pkx = SAV.getPKM(dragdata); string filename = pkx.FileName; @@ -3347,34 +3601,52 @@ namespace PKHeX try { File.WriteAllBytes(newfile, dragdata); + var img = (Bitmap)pb.Image; + DragInfo.Cursor = Cursor.Current = new Cursor(img.GetHicon()); + pb.Image = null; + pb.BackgroundImage = Properties.Resources.slotDrag; // Thread Blocks on DoDragDrop - ((PictureBox)sender).DoDragDrop(new DataObject(DataFormats.FileDrop, new[] { newfile }), DragDropEffects.Move); + DragInfo.CurrentPath = newfile; + DragDropEffects result = pb.DoDragDrop(new DataObject(DataFormats.FileDrop, new[] { newfile }), DragDropEffects.Move); + if (!DragInfo.SourceValid || result != DragDropEffects.Link) // not dropped to another box slot, restore img + pb.Image = img; + else // refresh image + getQuickFiller(pb, SAV.getStoredSlot(DragInfo.slotSourceOffset)); + pb.BackgroundImage = null; + + if (DragInfo.slotDestinationBoxNumber == DragInfo.slotSourceBoxNumber) + SlotPictureBoxes[DragInfo.slotDestinationSlotNumber].Image = img; + + if (result == DragDropEffects.Copy) // viewed in tabs, apply 'view' highlight + getSlotColor(DragInfo.slotSourceSlotNumber, Properties.Resources.slotView); } catch (Exception x) { Util.Error("Drag & Drop Error:", x.ToString()); } - slotSourceOffset = 0; + DragInfo.Reset(); + Cursor = DefaultCursor; // Browser apps need time to load data since the file isn't moved to a location on the user's local storage. // Tested 10ms -> too quick, 100ms was fine. 500ms should be safe? new Thread(() => { Thread.Sleep(500); - if (File.Exists(newfile)) + if (File.Exists(newfile) && DragInfo.CurrentPath == null) File.Delete(newfile); }).Start(); } } private void pbBoxSlot_DragDrop(object sender, DragEventArgs e) { - int slotDestinationSlotNumber = getSlot(sender); - int slotDestinationOffset = getPKXOffset(slotDestinationSlotNumber); + DragInfo.slotDestinationSlotNumber = getSlot(sender); + DragInfo.slotDestinationOffset = getPKXOffset(DragInfo.slotDestinationSlotNumber); + DragInfo.slotDestinationBoxNumber = CB_BoxSelect.SelectedIndex; // Check for In-Dropped files (PKX,SAV,ETC) string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); if (Directory.Exists(files[0])) { loadBoxesFromDB(files[0]); return; } - if (slotSourceOffset == 0) + if (DragInfo.slotSourceOffset < 0) // file { if (files.Length <= 0) return; @@ -3400,45 +3672,46 @@ namespace PKHeX { Console.WriteLine(c); Console.WriteLine(concat); return; } } - SAV.setStoredSlot(pk, slotDestinationOffset); - getQuickFiller(SlotPictureBoxes[slotDestinationSlotNumber], pk); - getSlotColor(slotDestinationSlotNumber, Properties.Resources.slotSet); + SAV.setStoredSlot(pk, DragInfo.slotDestinationOffset); + getQuickFiller(SlotPictureBoxes[DragInfo.slotDestinationSlotNumber], pk); + getSlotColor(DragInfo.slotDestinationSlotNumber, Properties.Resources.slotSet); Console.WriteLine(c); } else { - PKM pkz = SAV.getStoredSlot(slotSourceOffset); - if (ModifierKeys == Keys.Alt && slotDestinationSlotNumber > -1) // overwrite delete old slot + PKM pkz = SAV.getStoredSlot(DragInfo.slotSourceOffset); + if (!DragInfo.SourceValid) { } // not overwritable, do nothing + else if (ModifierKeys == Keys.Alt && DragInfo.DestinationValid) // overwrite delete old slot { - // Clear from slot - getQuickFiller(SlotPictureBoxes[slotSourceSlotNumber], SAV.BlankPKM); // picturebox - SAV.setStoredSlot(SAV.BlankPKM, slotSourceOffset); // savefile + // Clear from slot + if (DragInfo.SameBox) + getQuickFiller(SlotPictureBoxes[DragInfo.slotSourceSlotNumber], SAV.BlankPKM); // picturebox + + SAV.setStoredSlot(SAV.BlankPKM, DragInfo.slotSourceOffset); } - else if (ModifierKeys != Keys.Control && slotDestinationSlotNumber > -1) + else if (ModifierKeys != Keys.Control && DragInfo.DestinationValid) { - if (((PictureBox)sender).Image != null) - { - // Load data from destination - PKM pk = SAV.getStoredSlot(slotDestinationOffset); + // Load data from destination + PKM pk = ((PictureBox) sender).Image != null + ? SAV.getStoredSlot(DragInfo.slotDestinationOffset) + : SAV.BlankPKM; - // Set destination pokemon image to source picture box - getQuickFiller(SlotPictureBoxes[slotSourceSlotNumber], pk); + // Set destination pokemon image to source picture box + if (DragInfo.SameBox) + getQuickFiller(SlotPictureBoxes[DragInfo.slotSourceSlotNumber], pk); - // Set destination pokemon data to source slot - SAV.setStoredSlot(pk, slotSourceOffset); - } - else - { - // Set blank to source slot - SAV.setStoredSlot(SAV.BlankPKM, slotSourceOffset); - SlotPictureBoxes[slotSourceSlotNumber].Image = null; - } + // Set destination pokemon data to source slot + SAV.setStoredSlot(pk, DragInfo.slotSourceOffset); } + else if (DragInfo.SameBox) + getQuickFiller(SlotPictureBoxes[DragInfo.slotSourceSlotNumber], pkz); + // Copy from temp to destination slot. - SAV.setStoredSlot(pkz, slotDestinationOffset); - getQuickFiller(SlotPictureBoxes[slotDestinationSlotNumber], pkz); + SAV.setStoredSlot(pkz, DragInfo.slotDestinationOffset); + getQuickFiller(SlotPictureBoxes[DragInfo.slotDestinationSlotNumber], pkz); - slotSourceOffset = 0; // Clear offset value + e.Effect = DragDropEffects.Link; + Cursor = DefaultCursor; } } private void pbBoxSlot_DragEnter(object sender, DragEventArgs e) @@ -3447,23 +3720,59 @@ namespace PKHeX e.Effect = DragDropEffects.Copy; else if (e.Data != null) // within e.Effect = DragDropEffects.Move; + + if (DragInfo.slotDragDropInProgress) + Cursor = DragInfo.Cursor; } private void pbBoxSlot_QueryContinueDrag(object sender, QueryContinueDragEventArgs e) { if (e.Action == DragAction.Cancel || e.Action == DragAction.Drop) { - slotLeftMouseIsDown = false; - slotRightMouseIsDown = false; - slotDragDropInProgress = false; + DragInfo.slotLeftMouseIsDown = false; + DragInfo.slotRightMouseIsDown = false; + DragInfo.slotDragDropInProgress = false; + } + } + + public static class DragInfo + { + public static bool slotLeftMouseIsDown; + public static bool slotRightMouseIsDown; + public static bool slotDragDropInProgress; + + public static byte[] slotPkmSource; + public static byte[] slotPkmDestination; + + public static int slotSourceOffset = -1; + public static int slotSourceSlotNumber = -1; + public static int slotSourceBoxNumber = -1; + + public static int slotDestinationOffset = -1; + public static int slotDestinationSlotNumber = -1; + public static int slotDestinationBoxNumber = -1; + + public static Cursor Cursor; + public static string CurrentPath; + + public static bool SameBox => slotSourceBoxNumber > -1 && slotSourceBoxNumber == slotDestinationBoxNumber; + public static bool SourceValid => slotSourceBoxNumber > -1; + public static bool DestinationValid => slotDestinationBoxNumber > -1; + public static void Reset() + { + slotLeftMouseIsDown = false; + slotRightMouseIsDown = false; + slotDragDropInProgress = false; + + slotPkmSource = null; + slotSourceOffset = slotSourceSlotNumber = slotSourceBoxNumber = -1; + slotPkmDestination = null; + slotDestinationOffset = slotSourceBoxNumber = slotDestinationBoxNumber = -1; + + Cursor = null; + CurrentPath = null; } } - private static bool slotLeftMouseIsDown = false; - private static bool slotRightMouseIsDown = false; - private static bool slotDragDropInProgress = false; - private byte[] slotPkmSource; - private int slotSourceOffset; - private int slotSourceSlotNumber = -1; #endregion } } diff --git a/PKHeX/MainWindow/Main.resx b/PKHeX/MainWindow/Main.resx index 1d654adaa..df010947a 100644 --- a/PKHeX/MainWindow/Main.resx +++ b/PKHeX/MainWindow/Main.resx @@ -877,9 +877,6 @@ True - - True - True @@ -1332,6 +1329,9 @@ SiSLGvswRQAAAABJRU5ErkJggg== + + True + True diff --git a/PKHeX/MainWindow/MainPK1.cs b/PKHeX/MainWindow/MainPK1.cs new file mode 100644 index 000000000..3057dc27f --- /dev/null +++ b/PKHeX/MainWindow/MainPK1.cs @@ -0,0 +1,125 @@ +using System; + +namespace PKHeX +{ + public partial class Main + { + private void populateFieldsPK1() + { + PK1 pk1 = pkm as PK1; + if (pk1 == null) + return; + + // Do first + pk1.Stat_Level = PKX.getLevel(pk1.Species, pk1.EXP); + if (pk1.Stat_Level == 100) + pk1.EXP = PKX.getEXP(pk1.Stat_Level, pk1.Species); + + CB_Species.SelectedValue = pk1.Species; + TB_Level.Text = pk1.Stat_Level.ToString(); + TB_EXP.Text = pk1.EXP.ToString(); + + // Load rest + TB_TID.Text = pk1.TID.ToString("00000"); + CHK_Nicknamed.Checked = pk1.IsNicknamed; + TB_Nickname.Text = pk1.Nickname; + TB_OT.Text = pk1.OT_Name; + GB_OT.BackgroundImage = null; + + // Reset Label and ComboBox visibility, as well as non-data checked status. + Label_PKRS.Visible = false; + Label_PKRSdays.Visible = false; + + TB_HPIV.Text = pk1.IV_HP.ToString(); + TB_ATKIV.Text = pk1.IV_ATK.ToString(); + TB_DEFIV.Text = pk1.IV_DEF.ToString(); + TB_SPEIV.Text = pk1.IV_SPE.ToString(); + TB_SPAIV.Text = pk1.IV_SPA.ToString(); + + TB_HPEV.Text = pk1.EV_HP.ToString(); + TB_ATKEV.Text = pk1.EV_ATK.ToString(); + TB_DEFEV.Text = pk1.EV_DEF.ToString(); + TB_SPEEV.Text = pk1.EV_SPE.ToString(); + TB_SPAEV.Text = pk1.EV_SPA.ToString(); + + CB_Move1.SelectedValue = pk1.Move1; + CB_Move2.SelectedValue = pk1.Move2; + CB_Move3.SelectedValue = pk1.Move3; + CB_Move4.SelectedValue = pk1.Move4; + CB_PPu1.SelectedIndex = pk1.Move1_PPUps; + CB_PPu2.SelectedIndex = pk1.Move2_PPUps; + CB_PPu3.SelectedIndex = pk1.Move3_PPUps; + CB_PPu4.SelectedIndex = pk1.Move4_PPUps; + TB_PP1.Text = pk1.Move1_PP.ToString(); + TB_PP2.Text = pk1.Move2_PP.ToString(); + TB_PP3.Text = pk1.Move3_PP.ToString(); + TB_PP4.Text = pk1.Move4_PP.ToString(); + + CB_Language.SelectedIndex = pk1.Japanese ? 0 : 1; + + updateStats(); + + TB_EXP.Text = pk1.EXP.ToString(); + } + private PKM preparePK1() + { + PK1 pk1 = pkm as PK1; + if (pk1 == null) + return null; + + pk1.Species = Util.getIndex(CB_Species); + pk1.TID = Util.ToInt32(TB_TID.Text); + pk1.EXP = Util.ToUInt32(TB_EXP.Text); + + pk1.EV_HP = Util.ToInt32(TB_HPEV.Text); + pk1.EV_ATK = Util.ToInt32(TB_ATKEV.Text); + pk1.EV_DEF = Util.ToInt32(TB_DEFEV.Text); + pk1.EV_SPE = Util.ToInt32(TB_SPEEV.Text); + pk1.EV_SPC = Util.ToInt32(TB_SPAEV.Text); + + pk1.Nickname = TB_Nickname.Text; + pk1.Move1 = Util.getIndex(CB_Move1); + pk1.Move2 = Util.getIndex(CB_Move2); + pk1.Move3 = Util.getIndex(CB_Move3); + pk1.Move4 = Util.getIndex(CB_Move4); + pk1.Move1_PP = Util.getIndex(CB_Move1) > 0 ? Util.ToInt32(TB_PP1.Text) : 0; + pk1.Move2_PP = Util.getIndex(CB_Move2) > 0 ? Util.ToInt32(TB_PP2.Text) : 0; + pk1.Move3_PP = Util.getIndex(CB_Move3) > 0 ? Util.ToInt32(TB_PP3.Text) : 0; + pk1.Move4_PP = Util.getIndex(CB_Move4) > 0 ? Util.ToInt32(TB_PP4.Text) : 0; + pk1.Move1_PPUps = Util.getIndex(CB_Move1) > 0 ? CB_PPu1.SelectedIndex : 0; + pk1.Move2_PPUps = Util.getIndex(CB_Move2) > 0 ? CB_PPu2.SelectedIndex : 0; + pk1.Move3_PPUps = Util.getIndex(CB_Move3) > 0 ? CB_PPu3.SelectedIndex : 0; + pk1.Move4_PPUps = Util.getIndex(CB_Move4) > 0 ? CB_PPu4.SelectedIndex : 0; + + pk1.IV_HP = Util.ToInt32(TB_HPIV.Text); + pk1.IV_ATK = Util.ToInt32(TB_ATKIV.Text); + pk1.IV_DEF = Util.ToInt32(TB_DEFIV.Text); + pk1.IV_SPE = Util.ToInt32(TB_SPEIV.Text); + pk1.IV_SPA = Util.ToInt32(TB_SPAIV.Text); + + pk1.OT_Name = TB_OT.Text; + + // Toss in Party Stats + Array.Resize(ref pk1.Data, pk1.SIZE_PARTY); + pk1.Stat_Level = Util.ToInt32(TB_Level.Text); + pk1.Stat_HPCurrent = Util.ToInt32(Stat_HP.Text); + pk1.Stat_HPMax = Util.ToInt32(Stat_HP.Text); + pk1.Stat_ATK = Util.ToInt32(Stat_ATK.Text); + pk1.Stat_DEF = Util.ToInt32(Stat_DEF.Text); + pk1.Stat_SPE = Util.ToInt32(Stat_SPE.Text); + pk1.Stat_SPA = Util.ToInt32(Stat_SPA.Text); + pk1.Stat_SPD = Util.ToInt32(Stat_SPD.Text); + + if (HaX) + { + pk1.Stat_Level = (byte)Math.Min(Convert.ToInt32(MT_Level.Text), byte.MaxValue); + } + + // Fix Moves if a slot is empty + pk1.FixMoves(); + + pk1.RefreshChecksum(); + return pk1; + } + } +} diff --git a/PKHeX/MainWindow/MainPK4.cs b/PKHeX/MainWindow/MainPK4.cs index 4e27d2d69..fef518fd0 100644 --- a/PKHeX/MainWindow/MainPK4.cs +++ b/PKHeX/MainWindow/MainPK4.cs @@ -134,7 +134,15 @@ namespace PKHeX { int[] abils = SAV.Personal.getAbilities(pk4.Species, pk4.AltForm); int abil = Array.IndexOf(abils, pk4.Ability); - CB_Ability.SelectedIndex = abil < 0 || abil >= CB_Ability.Items.Count ? 0 : abil; + + if (abil < 0) + CB_Ability.SelectedIndex = 0; + else if (abil == 2) + CB_Ability.SelectedIndex = 2; + else if (abils[0] == abils[1] || abils[1] == 0) + CB_Ability.SelectedIndex = pk4.PIDAbility; + else + CB_Ability.SelectedIndex = abil < 0 || abil >= CB_Ability.Items.Count ? 0 : abil; } } private PKM preparePK4() diff --git a/PKHeX/MainWindow/MainPK5.cs b/PKHeX/MainWindow/MainPK5.cs index c48dde3d3..286871469 100644 --- a/PKHeX/MainWindow/MainPK5.cs +++ b/PKHeX/MainWindow/MainPK5.cs @@ -145,7 +145,15 @@ namespace PKHeX { int[] abils = SAV.Personal.getAbilities(pk5.Species, pk5.AltForm); int abil = Array.IndexOf(abils, pk5.Ability); - CB_Ability.SelectedIndex = abil < 0 || abil >= CB_Ability.Items.Count ? 0 : abil; + + if (abil < 0) + CB_Ability.SelectedIndex = 0; + else if (abil == 2) + CB_Ability.SelectedIndex = 2; + else if (abils[0] == abils[1] || abils[1] == 0) + CB_Ability.SelectedIndex = pk5.PIDAbility; + else + CB_Ability.SelectedIndex = abil < 0 || abil >= CB_Ability.Items.Count ? 0 : abil; } } private PKM preparePK5() diff --git a/PKHeX/Misc/QR.cs b/PKHeX/Misc/QR.cs index ebf8dc130..e4df20778 100644 --- a/PKHeX/Misc/QR.cs +++ b/PKHeX/Misc/QR.cs @@ -1,7 +1,5 @@ using System; using System.Drawing; -using System.IO; -using System.Net; using System.Web; using System.Windows.Forms; @@ -57,10 +55,7 @@ namespace PKHeX string webURL = "http://api.qrserver.com/v1/read-qr-code/?fileurl=" + HttpUtility.UrlEncode(address); try { - HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(webURL); - HttpWebResponse httpWebReponse = (HttpWebResponse)httpWebRequest.GetResponse(); - var reader = new StreamReader(httpWebReponse.GetResponseStream()); - string data = reader.ReadToEnd(); + string data = Util.getStringFromURL(webURL); if (data.Contains("could not find")) { Util.Alert("Reader could not find QR data in the image."); return null; } if (data.Contains("filetype not supported")) { Util.Alert("Input URL is not valid. Double check that it is an image (jpg/png).", address); return null; } // Quickly convert the json response to a data string @@ -82,10 +77,7 @@ namespace PKHeX try { - HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(webURL); - HttpWebResponse httpWebReponse = (HttpWebResponse)httpWebRequest.GetResponse(); - Stream stream = httpWebReponse.GetResponseStream(); - if (stream != null) return Image.FromStream(stream); + return Util.getImageFromURL(webURL); } catch { diff --git a/PKHeX/MysteryGifts/PGT.cs b/PKHeX/MysteryGifts/PGT.cs index 911754cf9..25c935e3c 100644 --- a/PKHeX/MysteryGifts/PGT.cs +++ b/PKHeX/MysteryGifts/PGT.cs @@ -116,12 +116,12 @@ namespace PKHeX } } - private GiftType Type { get { return (GiftType)Data[0]; } set {Data[0] = (byte)value; } } - public bool IsHatched => Type == GiftType.Pokémon; - public bool IsEgg => Type == GiftType.PokémonEgg; - public bool IsManaphyEgg => Type == GiftType.ManaphyEgg; - public override bool IsItem { get { return Type == GiftType.Item; } set { if (value) CardType = (int)GiftType.Item; } } - public override bool IsPokémon { get { return Type == GiftType.Pokémon || Type == GiftType.PokémonEgg || Type == GiftType.ManaphyEgg; } set { } } + private GiftType PGTGiftType { get { return (GiftType)Data[0]; } set {Data[0] = (byte)value; } } + public bool IsHatched => PGTGiftType == GiftType.Pokémon; + public bool IsEgg => PGTGiftType == GiftType.PokémonEgg; + public bool IsManaphyEgg => PGTGiftType == GiftType.ManaphyEgg; + public override bool IsItem { get { return PGTGiftType == GiftType.Item; } set { if (value) CardType = (int)GiftType.Item; } } + public override bool IsPokémon { get { return PGTGiftType == GiftType.Pokémon || PGTGiftType == GiftType.PokémonEgg || PGTGiftType == GiftType.ManaphyEgg; } set { } } public override PKM convertToPKM(SaveFile SAV) { diff --git a/PKHeX/PKHeX.csproj b/PKHeX/PKHeX.csproj index a0a1c2b8b..3e73dbbef 100644 --- a/PKHeX/PKHeX.csproj +++ b/PKHeX/PKHeX.csproj @@ -73,6 +73,9 @@ + + Form + Form @@ -90,11 +93,13 @@ + + @@ -114,6 +119,7 @@ + @@ -189,6 +195,18 @@ SAV_PokeBlockORAS.cs + + Form + + + SAV_BoxViewer.cs + + + Form + + + SAV_SimplePokedex.cs + Form @@ -294,10 +312,12 @@ SplashScreen.cs + + @@ -338,6 +358,12 @@ SAV_PokeBlockORAS.cs + + SAV_BoxViewer.cs + + + SAV_SimplePokedex.cs + SAV_Database.cs @@ -451,6 +477,7 @@ + @@ -2704,7 +2731,15 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + + + AAABAAIAEBAAAAEAIABoBAAAJgAAACAgAAABACAAqBAAAI4EAAAoAAAAEAAAACAAAAABACAAAAAAAAAE + AAAAAAAAAAAAAAAAAAAAAAAAIyMjAQAAAAALCwsPJiYmJysrKycqKionKSkpJykpKScpKSknKioqJyoq + KicrKysnJycnJw0ODQ8AAAAAJiYmAQAAAABpaWlHq6ur17+/v+6+vr7svr6+7b6+vu2+vr7tvr6+7b6+ + vu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f0Dg5GGwAAAAAAAAAAFhZxAiUl + eIUZGcr/FBTI/xUVyv8WFsv/FhbM/xYWzP8WFsz/FhbN/xcXzf8XF83/FxfN/xcXzv8XF87/FxfO/xcX + zv8XF87/FxfN/xcXzf8WFs3/FhbM/xYWzP8WFsz/FhbL/xUVyv8UFMj/GBjJ/yYmeogWFnYCAAAAAAAA + AAAAAAAAGBh1BzMzk50kJNP+FxfK/xgYzP8YGMz/GBjN/xgYzf8YGM3/GBjN/xgYzf8ZGc7/GRnO/xkZ + zv8ZGc7/GRnO/xkZzv8YGM3/GBjN/xgYzf8YGM3/GBjN/xgYzP8YGMz/FxfK/yMj0v4zM5WfFBRkBwAA + AAAAAAAAAAAAAAAAAAAAAAAAHBx7Ay0tdkg3N5emMTGpxSwsp8gsLKfILCynyCwsp8gsLKfILCynyCws + p8gsLKfILCynyCwsp8gsLKfILCynyCwsp8gsLKfILCynyCwsp8gsLKfILCynyDExqcU2NpenLi54Shsb + ewMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAP//////////8AAAD+AAAAfAAAADwAAAA8AAAAPAAAADwAAAA8AA + AAPAAAADwAAAA8AAAAPAAAADwAAAA8AAAAPAAAADwAAAA8AAAAPAAAADwAAAA8AAAAPAAAADwAAAA8AA + AAPAAAADwAAAA8AAAAPAAAAD4AAAB/gAAB////// + + + \ No newline at end of file diff --git a/PKHeX/Subforms/Save Editors/SAV_EventFlags.cs b/PKHeX/Subforms/Save Editors/SAV_EventFlags.cs index 006653a9c..4d15c321f 100644 --- a/PKHeX/Subforms/Save Editors/SAV_EventFlags.cs +++ b/PKHeX/Subforms/Save Editors/SAV_EventFlags.cs @@ -171,8 +171,8 @@ namespace PKHeX }; var mtb = new NumericUpDown { - Maximum = short.MaxValue, - Minimum = short.MinValue, + Maximum = ushort.MaxValue, + Minimum = ushort.MinValue, Value = Constants[num[i]], Name = constTag + num[i].ToString("0000"), Margin = Padding.Empty, diff --git a/PKHeX/Subforms/Save Editors/SAV_Inventory.cs b/PKHeX/Subforms/Save Editors/SAV_Inventory.cs index b9094f50a..c997680e7 100644 --- a/PKHeX/Subforms/Save Editors/SAV_Inventory.cs +++ b/PKHeX/Subforms/Save Editors/SAV_Inventory.cs @@ -10,7 +10,19 @@ namespace PKHeX { InitializeComponent(); Util.TranslateInterface(this, Main.curlanguage); - itemlist = SAV.Generation == 3 ? Main.g3items : Main.itemlist; + switch (SAV.Generation) + { + case 1: + itemlist = PKX.getG1ItemList(); + B_GiveAll.Visible = false; // Can't give all, not enough room + break; + case 3: + itemlist = Main.g3items; + break; + default: + itemlist = Main.itemlist; + break; + } Pouches = SAV.Inventory; getBags(); } @@ -155,6 +167,8 @@ namespace PKHeX itemcnt++; // No 0 count of items else if (itemcnt > 995) itemcnt = 995; // cap out + else if (itemcnt > 99 && SAV.Generation < 3) + itemcnt = 99; if (itemindex == 0) // Compression of Empty Slots continue; diff --git a/PKHeX/Subforms/Save Editors/SAV_SimplePokedex.Designer.cs b/PKHeX/Subforms/Save Editors/SAV_SimplePokedex.Designer.cs new file mode 100644 index 000000000..cf25e0653 --- /dev/null +++ b/PKHeX/Subforms/Save Editors/SAV_SimplePokedex.Designer.cs @@ -0,0 +1,179 @@ +namespace PKHeX +{ + partial class SAV_SimplePokedex + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SAV_SimplePokedex)); + this.B_Save = new System.Windows.Forms.Button(); + this.B_Cancel = new System.Windows.Forms.Button(); + this.B_CaughtNone = new System.Windows.Forms.Button(); + this.B_CaughtAll = new System.Windows.Forms.Button(); + this.B_SeenNone = new System.Windows.Forms.Button(); + this.B_SeenAll = new System.Windows.Forms.Button(); + this.label2 = new System.Windows.Forms.Label(); + this.CLB_Caught = new System.Windows.Forms.CheckedListBox(); + this.Label_Seen = new System.Windows.Forms.Label(); + this.CLB_Seen = new System.Windows.Forms.CheckedListBox(); + this.SuspendLayout(); + // + // B_Save + // + this.B_Save.Location = new System.Drawing.Point(146, 301); + this.B_Save.Name = "B_Save"; + this.B_Save.Size = new System.Drawing.Size(85, 23); + this.B_Save.TabIndex = 19; + this.B_Save.Text = "Save"; + this.B_Save.UseVisualStyleBackColor = true; + this.B_Save.Click += new System.EventHandler(this.B_Save_Click); + // + // B_Cancel + // + this.B_Cancel.Location = new System.Drawing.Point(53, 301); + this.B_Cancel.Name = "B_Cancel"; + this.B_Cancel.Size = new System.Drawing.Size(85, 23); + this.B_Cancel.TabIndex = 18; + this.B_Cancel.Text = "Cancel"; + this.B_Cancel.UseVisualStyleBackColor = true; + this.B_Cancel.Click += new System.EventHandler(this.B_Cancel_Click); + // + // B_CaughtNone + // + this.B_CaughtNone.Location = new System.Drawing.Point(151, 267); + this.B_CaughtNone.Name = "B_CaughtNone"; + this.B_CaughtNone.Size = new System.Drawing.Size(120, 23); + this.B_CaughtNone.TabIndex = 17; + this.B_CaughtNone.Text = "Caught None"; + this.B_CaughtNone.UseVisualStyleBackColor = true; + this.B_CaughtNone.Click += new System.EventHandler(this.B_CaughtNone_Click); + // + // B_CaughtAll + // + this.B_CaughtAll.Location = new System.Drawing.Point(151, 238); + this.B_CaughtAll.Name = "B_CaughtAll"; + this.B_CaughtAll.Size = new System.Drawing.Size(120, 23); + this.B_CaughtAll.TabIndex = 16; + this.B_CaughtAll.Text = "Caught All"; + this.B_CaughtAll.UseVisualStyleBackColor = true; + this.B_CaughtAll.Click += new System.EventHandler(this.B_CaughtAll_Click); + // + // B_SeenNone + // + this.B_SeenNone.Location = new System.Drawing.Point(14, 267); + this.B_SeenNone.Name = "B_SeenNone"; + this.B_SeenNone.Size = new System.Drawing.Size(120, 23); + this.B_SeenNone.TabIndex = 15; + this.B_SeenNone.Text = "Seen None"; + this.B_SeenNone.UseVisualStyleBackColor = true; + this.B_SeenNone.Click += new System.EventHandler(this.B_SeenNone_Click); + // + // B_SeenAll + // + this.B_SeenAll.Location = new System.Drawing.Point(14, 238); + this.B_SeenAll.Name = "B_SeenAll"; + this.B_SeenAll.Size = new System.Drawing.Size(120, 23); + this.B_SeenAll.TabIndex = 14; + this.B_SeenAll.Text = "Seen All"; + this.B_SeenAll.UseVisualStyleBackColor = true; + this.B_SeenAll.Click += new System.EventHandler(this.B_SeenAll_Click); + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(151, 13); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(44, 13); + this.label2.TabIndex = 13; + this.label2.Text = "Caught:"; + // + // CLB_Caught + // + this.CLB_Caught.FormattingEnabled = true; + this.CLB_Caught.Location = new System.Drawing.Point(151, 33); + this.CLB_Caught.Name = "CLB_Caught"; + this.CLB_Caught.Size = new System.Drawing.Size(120, 199); + this.CLB_Caught.TabIndex = 12; + this.CLB_Caught.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.CLB_Caught_ItemCheck); + // + // Label_Seen + // + this.Label_Seen.AutoSize = true; + this.Label_Seen.Location = new System.Drawing.Point(14, 13); + this.Label_Seen.Name = "Label_Seen"; + this.Label_Seen.Size = new System.Drawing.Size(35, 13); + this.Label_Seen.TabIndex = 11; + this.Label_Seen.Text = "Seen:"; + // + // CLB_Seen + // + this.CLB_Seen.FormattingEnabled = true; + this.CLB_Seen.Location = new System.Drawing.Point(14, 33); + this.CLB_Seen.Name = "CLB_Seen"; + this.CLB_Seen.Size = new System.Drawing.Size(120, 199); + this.CLB_Seen.TabIndex = 10; + this.CLB_Seen.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.CLB_Seen_ItemCheck); + // + // SAV_SimplePokedex + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(284, 336); + this.Controls.Add(this.B_Save); + this.Controls.Add(this.B_Cancel); + this.Controls.Add(this.B_CaughtNone); + this.Controls.Add(this.B_CaughtAll); + this.Controls.Add(this.B_SeenNone); + this.Controls.Add(this.B_SeenAll); + this.Controls.Add(this.label2); + this.Controls.Add(this.CLB_Caught); + this.Controls.Add(this.Label_Seen); + this.Controls.Add(this.CLB_Seen); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MaximumSize = new System.Drawing.Size(300, 375); + this.MinimumSize = new System.Drawing.Size(300, 375); + this.Name = "SAV_SimplePokedex"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Pokedex Editor"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button B_Save; + private System.Windows.Forms.Button B_Cancel; + private System.Windows.Forms.Button B_CaughtNone; + private System.Windows.Forms.Button B_CaughtAll; + private System.Windows.Forms.Button B_SeenNone; + private System.Windows.Forms.Button B_SeenAll; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.CheckedListBox CLB_Caught; + private System.Windows.Forms.Label Label_Seen; + private System.Windows.Forms.CheckedListBox CLB_Seen; + } +} \ No newline at end of file diff --git a/PKHeX/Subforms/Save Editors/SAV_SimplePokedex.cs b/PKHeX/Subforms/Save Editors/SAV_SimplePokedex.cs new file mode 100644 index 000000000..cdbc25af7 --- /dev/null +++ b/PKHeX/Subforms/Save Editors/SAV_SimplePokedex.cs @@ -0,0 +1,90 @@ +using System; +using System.Windows.Forms; + +namespace PKHeX +{ + public partial class SAV_SimplePokedex : Form + { + public SAV_SimplePokedex() + { + InitializeComponent(); + Util.TranslateInterface(this, Main.curlanguage); + seen = new bool[SAV.MaxSpeciesID]; + caught = new bool[SAV.MaxSpeciesID]; + + string[] spec = Util.getSpeciesList(Main.curlanguage); + for (int i = 0; i < seen.Length; i++) + { + PKM tempPkm = new PK6(); + tempPkm.Species = i + 1; + seen[i] = SAV.getSeen(tempPkm); + caught[i] = SAV.getCaught(tempPkm); + CLB_Seen.Items.Add(spec[i + 1]); + CLB_Caught.Items.Add(spec[i + 1]); + CLB_Seen.SetItemChecked(i, seen[i]); + CLB_Caught.SetItemChecked(i, caught[i]); + } + initialized = true; + } + private readonly SaveFile SAV = Main.SAV.Clone(); + + private readonly bool[] seen; + private readonly bool[] caught; + private readonly bool initialized; + + private void B_Save_Click(object sender, EventArgs e) + { + for (int i = 0; i < seen.Length; i++) + { + PKM tempPkm = new PK6(); + tempPkm.Species = i + 1; + SAV.setSeen(tempPkm, seen[i]); + SAV.setCaught(tempPkm, caught[i]); + } + SAV.Data.CopyTo(Main.SAV.Data, 0); + Main.SAV.Edited = true; + Close(); + } + + private void B_Cancel_Click(object sender, EventArgs e) + { + Close(); + } + + private void B_SeenAll_Click(object sender, EventArgs e) + { + for (int i = 0; i < SAV.MaxSpeciesID; i++) + CLB_Seen.SetItemChecked(i, true); + } + + private void B_SeenNone_Click(object sender, EventArgs e) + { + for (int i = 0; i < SAV.MaxSpeciesID; i++) + CLB_Seen.SetItemChecked(i, false); + } + + private void B_CaughtAll_Click(object sender, EventArgs e) + { + for (int i = 0; i < SAV.MaxSpeciesID; i++) + CLB_Caught.SetItemChecked(i, true); + } + + private void B_CaughtNone_Click(object sender, EventArgs e) + { + for (int i = 0; i < SAV.MaxSpeciesID; i++) + CLB_Caught.SetItemChecked(i, false); + } + + private void CLB_Seen_ItemCheck(object sender, ItemCheckEventArgs e) + { + if (!initialized) return; + seen[e.Index] = e.NewValue == CheckState.Checked; + } + + private void CLB_Caught_ItemCheck(object sender, ItemCheckEventArgs e) + { + if (!initialized) return; + caught[e.Index] = e.NewValue == CheckState.Checked; + } + } +} diff --git a/PKHeX/Subforms/Save Editors/SAV_SimplePokedex.resx b/PKHeX/Subforms/Save Editors/SAV_SimplePokedex.resx new file mode 100644 index 000000000..603f660be --- /dev/null +++ b/PKHeX/Subforms/Save Editors/SAV_SimplePokedex.resx @@ -0,0 +1,216 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + AAABAAIAEBAAAAEAIABoBAAAJgAAACAgAAABACAAqBAAAI4EAAAoAAAAEAAAACAAAAABACAAAAAAAAAE + AAAAAAAAAAAAAAAAAAAAAAAAIyMjAQAAAAALCwsPJiYmJysrKycqKionKSkpJykpKScpKSknKioqJyoq + KicrKysnJycnJw0ODQ8AAAAAJiYmAQAAAABpaWlHq6ur17+/v+6+vr7svr6+7b6+vu2+vr7tvr6+7b6+ + vu2+vr7tvr6+7L+/v+6rq6vXampqSAAAAAAoKSgXvr++3eLi4v/g4OD94eHh/+Hh4f/i4uL/4uLi/+Li + 4v/i4uL/4eHh/+Dh4P/g4OD94uLi/7+/v90sLCwXfn5+PNna2frg4OD/39/f/uHh4f7h4eH+39/f/uDg + 4P7g4OD+39/f/uHh4f7h4OH+39/f/t/g3//a2tr6g4ODPoOCgz7X19f64+Pj/+Li4v7k5OT/4+Tj//Ly + 8v/19fX/9PT0//T09P/k5OT/5OTk/+Pj4/7j4+P/19jX+4qLikCDhIM+2tra++Xl5f/k5eT+5OTk//Lz + 8v+urq7/RUVF/z4+Pv+Zmpn/8fHx/+Xm5f/k5eT+5eXl/9ra2vyLi4tAhYWFPuXm5vvx8vP/7+/w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N5emMTGpxSwsp8gsLKfILCynyCwsp8gsLKfILCynyCws + p8gsLKfILCynyCwsp8gsLKfILCynyCwsp8gsLKfILCynyCwsp8gsLKfILCynyDExqcU2NpenLi54Shsb + ewMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAP//////////8AAAD+AAAAfAAAADwAAAA8AAAAPAAAADwAAAA8AA + AAPAAAADwAAAA8AAAAPAAAADwAAAA8AAAAPAAAADwAAAA8AAAAPAAAADwAAAA8AAAAPAAAADwAAAA8AA + AAPAAAADwAAAA8AAAAPAAAAD4AAAB/gAAB////// + + + \ No newline at end of file diff --git a/PKHeX/Subforms/Save Editors/SAV_SimpleTrainer.Designer.cs b/PKHeX/Subforms/Save Editors/SAV_SimpleTrainer.Designer.cs index 111a04802..9cdf8aca3 100644 --- a/PKHeX/Subforms/Save Editors/SAV_SimpleTrainer.Designer.cs +++ b/PKHeX/Subforms/Save Editors/SAV_SimpleTrainer.Designer.cs @@ -28,6 +28,7 @@ /// private void InitializeComponent() { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SAV_SimpleTrainer)); this.GB_Adventure = new System.Windows.Forms.GroupBox(); this.L_Started = new System.Windows.Forms.Label(); this.CAL_AdventureStartDate = new System.Windows.Forms.DateTimePicker(); @@ -63,6 +64,9 @@ this.B_Save = new System.Windows.Forms.Button(); this.B_Cancel = new System.Windows.Forms.Button(); this.GB_Trainer = new System.Windows.Forms.GroupBox(); + this.B_MaxCoins = new System.Windows.Forms.Button(); + this.L_Coins = new System.Windows.Forms.Label(); + this.MT_Coins = new System.Windows.Forms.MaskedTextBox(); this.GB_Badges = new System.Windows.Forms.GroupBox(); this.CHK_H8 = new System.Windows.Forms.CheckBox(); this.CHK_H7 = new System.Windows.Forms.CheckBox(); @@ -80,6 +84,14 @@ this.CHK_3 = new System.Windows.Forms.CheckBox(); this.CHK_2 = new System.Windows.Forms.CheckBox(); this.CHK_1 = new System.Windows.Forms.CheckBox(); + this.GB_Options = new System.Windows.Forms.GroupBox(); + this.label1 = new System.Windows.Forms.Label(); + this.CB_SoundType = new System.Windows.Forms.ComboBox(); + this.LBL_TextSpeed = new System.Windows.Forms.Label(); + this.CB_TextSpeed = new System.Windows.Forms.ComboBox(); + this.LBL_BattleStyle = new System.Windows.Forms.Label(); + this.CB_BattleStyle = new System.Windows.Forms.ComboBox(); + this.CHK_BattleEffects = new System.Windows.Forms.CheckBox(); this.GB_Adventure.SuspendLayout(); this.GB_Map.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.NUD_Z)).BeginInit(); @@ -88,6 +100,7 @@ ((System.ComponentModel.ISupportInitialize)(this.NUD_X)).BeginInit(); this.GB_Trainer.SuspendLayout(); this.GB_Badges.SuspendLayout(); + this.GB_Options.SuspendLayout(); this.SuspendLayout(); // // GB_Adventure @@ -248,7 +261,7 @@ this.CB_Gender.Items.AddRange(new object[] { "♂", "♀"}); - this.CB_Gender.Location = new System.Drawing.Point(99, 55); + this.CB_Gender.Location = new System.Drawing.Point(119, 55); this.CB_Gender.Name = "CB_Gender"; this.CB_Gender.Size = new System.Drawing.Size(40, 21); this.CB_Gender.TabIndex = 68; @@ -458,6 +471,9 @@ // // GB_Trainer // + this.GB_Trainer.Controls.Add(this.B_MaxCoins); + this.GB_Trainer.Controls.Add(this.L_Coins); + this.GB_Trainer.Controls.Add(this.MT_Coins); this.GB_Trainer.Controls.Add(this.TB_OTName); this.GB_Trainer.Controls.Add(this.B_MaxCash); this.GB_Trainer.Controls.Add(this.MT_SID); @@ -475,6 +491,37 @@ this.GB_Trainer.TabStop = false; this.GB_Trainer.Text = "Trainer"; // + // B_MaxCoins + // + this.B_MaxCoins.Location = new System.Drawing.Point(95, 56); + this.B_MaxCoins.Name = "B_MaxCoins"; + this.B_MaxCoins.Size = new System.Drawing.Size(20, 20); + this.B_MaxCoins.TabIndex = 71; + this.B_MaxCoins.Text = "+"; + this.B_MaxCoins.UseVisualStyleBackColor = true; + this.B_MaxCoins.Visible = false; + // + // L_Coins + // + this.L_Coins.AutoSize = true; + this.L_Coins.Location = new System.Drawing.Point(11, 59); + this.L_Coins.Name = "L_Coins"; + this.L_Coins.Size = new System.Drawing.Size(36, 13); + this.L_Coins.TabIndex = 70; + this.L_Coins.Text = "Coins:"; + this.L_Coins.Visible = false; + // + // MT_Coins + // + this.MT_Coins.Location = new System.Drawing.Point(53, 55); + this.MT_Coins.Mask = "00000"; + this.MT_Coins.Name = "MT_Coins"; + this.MT_Coins.RightToLeft = System.Windows.Forms.RightToLeft.Yes; + this.MT_Coins.Size = new System.Drawing.Size(39, 20); + this.MT_Coins.TabIndex = 69; + this.MT_Coins.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + this.MT_Coins.Visible = false; + // // GB_Badges // this.GB_Badges.Controls.Add(this.CHK_H8); @@ -660,17 +707,100 @@ this.CHK_1.UseVisualStyleBackColor = true; this.CHK_1.Visible = false; // + // GB_Options + // + this.GB_Options.Controls.Add(this.label1); + this.GB_Options.Controls.Add(this.CB_SoundType); + this.GB_Options.Controls.Add(this.LBL_TextSpeed); + this.GB_Options.Controls.Add(this.CB_TextSpeed); + this.GB_Options.Controls.Add(this.LBL_BattleStyle); + this.GB_Options.Controls.Add(this.CB_BattleStyle); + this.GB_Options.Controls.Add(this.CHK_BattleEffects); + this.GB_Options.Location = new System.Drawing.Point(217, 99); + this.GB_Options.Name = "GB_Options"; + this.GB_Options.Size = new System.Drawing.Size(157, 125); + this.GB_Options.TabIndex = 72; + this.GB_Options.TabStop = false; + this.GB_Options.Text = "Options"; + this.GB_Options.Visible = false; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(3, 71); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(68, 13); + this.label1.TabIndex = 25; + this.label1.Text = "Sound Type:"; + // + // CB_SoundType + // + this.CB_SoundType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.CB_SoundType.FormattingEnabled = true; + this.CB_SoundType.Location = new System.Drawing.Point(71, 68); + this.CB_SoundType.Name = "CB_SoundType"; + this.CB_SoundType.Size = new System.Drawing.Size(80, 21); + this.CB_SoundType.TabIndex = 24; + // + // LBL_TextSpeed + // + this.LBL_TextSpeed.AutoSize = true; + this.LBL_TextSpeed.Location = new System.Drawing.Point(6, 98); + this.LBL_TextSpeed.Name = "LBL_TextSpeed"; + this.LBL_TextSpeed.Size = new System.Drawing.Size(65, 13); + this.LBL_TextSpeed.TabIndex = 23; + this.LBL_TextSpeed.Text = "Text Speed:"; + // + // CB_TextSpeed + // + this.CB_TextSpeed.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.CB_TextSpeed.FormattingEnabled = true; + this.CB_TextSpeed.Location = new System.Drawing.Point(71, 95); + this.CB_TextSpeed.Name = "CB_TextSpeed"; + this.CB_TextSpeed.Size = new System.Drawing.Size(80, 21); + this.CB_TextSpeed.TabIndex = 22; + // + // LBL_BattleStyle + // + this.LBL_BattleStyle.AutoSize = true; + this.LBL_BattleStyle.Location = new System.Drawing.Point(8, 44); + this.LBL_BattleStyle.Name = "LBL_BattleStyle"; + this.LBL_BattleStyle.Size = new System.Drawing.Size(63, 13); + this.LBL_BattleStyle.TabIndex = 21; + this.LBL_BattleStyle.Text = "Battle Style:"; + // + // CB_BattleStyle + // + this.CB_BattleStyle.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.CB_BattleStyle.FormattingEnabled = true; + this.CB_BattleStyle.Location = new System.Drawing.Point(71, 41); + this.CB_BattleStyle.Name = "CB_BattleStyle"; + this.CB_BattleStyle.Size = new System.Drawing.Size(80, 21); + this.CB_BattleStyle.TabIndex = 20; + // + // CHK_BattleEffects + // + this.CHK_BattleEffects.AutoSize = true; + this.CHK_BattleEffects.Location = new System.Drawing.Point(26, 18); + this.CHK_BattleEffects.Name = "CHK_BattleEffects"; + this.CHK_BattleEffects.Size = new System.Drawing.Size(111, 17); + this.CHK_BattleEffects.TabIndex = 19; + this.CHK_BattleEffects.Text = "Use Battle Effects"; + this.CHK_BattleEffects.UseVisualStyleBackColor = true; + // // SAV_SimpleTrainer // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(384, 261); + this.Controls.Add(this.GB_Options); this.Controls.Add(this.GB_Badges); this.Controls.Add(this.GB_Trainer); this.Controls.Add(this.B_Save); this.Controls.Add(this.B_Cancel); this.Controls.Add(this.GB_Map); this.Controls.Add(this.GB_Adventure); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MinimumSize = new System.Drawing.Size(400, 300); this.Name = "SAV_SimpleTrainer"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; @@ -686,6 +816,8 @@ this.GB_Trainer.PerformLayout(); this.GB_Badges.ResumeLayout(false); this.GB_Badges.PerformLayout(); + this.GB_Options.ResumeLayout(false); + this.GB_Options.PerformLayout(); this.ResumeLayout(false); } @@ -744,5 +876,16 @@ private System.Windows.Forms.CheckBox CHK_H3; private System.Windows.Forms.CheckBox CHK_H2; private System.Windows.Forms.CheckBox CHK_H1; + private System.Windows.Forms.Button B_MaxCoins; + private System.Windows.Forms.Label L_Coins; + private System.Windows.Forms.MaskedTextBox MT_Coins; + private System.Windows.Forms.GroupBox GB_Options; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.ComboBox CB_SoundType; + private System.Windows.Forms.Label LBL_TextSpeed; + private System.Windows.Forms.ComboBox CB_TextSpeed; + private System.Windows.Forms.Label LBL_BattleStyle; + private System.Windows.Forms.ComboBox CB_BattleStyle; + private System.Windows.Forms.CheckBox CHK_BattleEffects; } } \ No newline at end of file diff --git a/PKHeX/Subforms/Save Editors/SAV_SimpleTrainer.cs b/PKHeX/Subforms/Save Editors/SAV_SimpleTrainer.cs index cd77cf21f..ea487cb4c 100644 --- a/PKHeX/Subforms/Save Editors/SAV_SimpleTrainer.cs +++ b/PKHeX/Subforms/Save Editors/SAV_SimpleTrainer.cs @@ -14,10 +14,15 @@ namespace PKHeX cba = new[] {CHK_1, CHK_2, CHK_3, CHK_4, CHK_5, CHK_6, CHK_7, CHK_8}; TB_OTName.MaxLength = SAV.OTLength; B_MaxCash.Click += (sender, e) => MT_Money.Text = "9,999,999"; + B_MaxCoins.Click += (sender, e) => MT_Coins.Text = "9999"; CB_Gender.Items.Clear(); CB_Gender.Items.AddRange(Main.gendersymbols.Take(2).ToArray()); // m/f depending on unicode selection + 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; + TB_OTName.Text = SAV.OT; CB_Gender.SelectedIndex = SAV.Gender; MT_TID.Text = SAV.TID.ToString("00000"); @@ -27,6 +32,29 @@ namespace PKHeX MT_Minutes.Text = SAV.PlayedMinutes.ToString(); MT_Seconds.Text = SAV.PlayedSeconds.ToString(); + + 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; + } + if (SAV is SAV3) { GB_Map.Visible = false; @@ -38,7 +66,6 @@ namespace PKHeX return; } - int badgeval = 0; if (SAV is SAV4) { SAV4 s = (SAV4)SAV; @@ -104,6 +131,18 @@ namespace PKHeX for (int i = 0; i < cba.Length; i++) badgeval |= (cba[i].Checked ? 1 : 0) << i; + if (SAV is SAV1) + { + SAV1 sav1 = (SAV1) SAV; + sav1.Coin = (ushort) Util.ToUInt32(MT_Coins.Text); + sav1.Badges = badgeval & 0xFF; + + sav1.BattleEffects = CHK_BattleEffects.Checked; + sav1.BattleStyleSwitch = CB_BattleStyle.SelectedIndex == 0; + sav1.Sound = CB_SoundType.SelectedIndex; + sav1.TextSpeed = CB_TextSpeed.SelectedIndex; + } + if (SAV is SAV4) { SAV4 s = (SAV4)SAV; diff --git a/PKHeX/Subforms/Save Editors/SAV_SimpleTrainer.resx b/PKHeX/Subforms/Save Editors/SAV_SimpleTrainer.resx index 1af7de150..603f660be 100644 --- a/PKHeX/Subforms/Save Editors/SAV_SimpleTrainer.resx +++ b/PKHeX/Subforms/Save Editors/SAV_SimpleTrainer.resx @@ -117,4 +117,100 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + AAABAAIAEBAAAAEAIABoBAAAJgAAACAgAAABACAAqBAAAI4EAAAoAAAAEAAAACAAAAABACAAAAAAAAAE + AAAAAAAAAAAAAAAAAAAAAAAAIyMjAQAAAAALCwsPJiYmJysrKycqKionKSkpJykpKScpKSknKioqJyoq + KicrKysnJycnJw0ODQ8AAAAAJiYmAQAAAABpaWlHq6ur17+/v+6+vr7svr6+7b6+vu2+vr7tvr6+7b6+ + vu2+vr7tvr6+7L+/v+6rq6vXampqSAAAAAAoKSgXvr++3eLi4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yv8WFsv/FhbM/xYWzP8WFsz/FhbN/xcXzf8XF83/FxfN/xcXzv8XF87/FxfO/xcX + zv8XF87/FxfN/xcXzf8WFs3/FhbM/xYWzP8WFsz/FhbL/xUVyv8UFMj/GBjJ/yYmeogWFnYCAAAAAAAA + AAAAAAAAGBh1BzMzk50kJNP+FxfK/xgYzP8YGMz/GBjN/xgYzf8YGM3/GBjN/xgYzf8ZGc7/GRnO/xkZ + zv8ZGc7/GRnO/xkZzv8YGM3/GBjN/xgYzf8YGM3/GBjN/xgYzP8YGMz/FxfK/yMj0v4zM5WfFBRkBwAA + AAAAAAAAAAAAAAAAAAAAAAAAHBx7Ay0tdkg3N5emMTGpxSwsp8gsLKfILCynyCwsp8gsLKfILCynyCws + p8gsLKfILCynyCwsp8gsLKfILCynyCwsp8gsLKfILCynyCwsp8gsLKfILCynyDExqcU2NpenLi54Shsb + ewMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAP//////////8AAAD+AAAAfAAAADwAAAA8AAAAPAAAADwAAAA8AA + AAPAAAADwAAAA8AAAAPAAAADwAAAA8AAAAPAAAADwAAAA8AAAAPAAAADwAAAA8AAAAPAAAADwAAAA8AA + AAPAAAADwAAAA8AAAAPAAAAD4AAAB/gAAB////// + + \ No newline at end of file diff --git a/PKHeX/Util/ByteUtil.cs b/PKHeX/Util/ByteUtil.cs new file mode 100644 index 000000000..0418dbdb9 --- /dev/null +++ b/PKHeX/Util/ByteUtil.cs @@ -0,0 +1,48 @@ +namespace PKHeX +{ + public partial class Util + { + /// + /// Swaps the Endianness of an int + /// + /// Value to swap endianness of. + /// The endianness-swapped value. + internal static int SwapEndianness(int val) + { + return (int) SwapEndianness((uint) val); + } + + /// + /// Swaps the Endianness of a uint + /// + /// Value to swap endianness of. + /// The endianness-swapped value. + internal static uint SwapEndianness(uint val) + { + return ((val & 0x000000FF) << 24) + | ((val & 0x0000FF00) << 8) + | ((val & 0x00FF0000) >> 8) + | ((val & 0xFF000000) >> 24); + } + + /// + /// Swaps the Endianness of a short + /// + /// Value to swap endianness of. + /// The endianness-swapped value. + internal static int SwapEndianness(short val) + { + return (short)SwapEndianness((ushort)val); + } + + /// + /// Swaps the Endianness of a ushort + /// + /// Value to swap endianness of. + /// The endianness-swapped value. + internal static ushort SwapEndianness(ushort val) + { + return (ushort) (((val & 0x00FF) << 8) | ((val & 0xFF00) >> 8)); + } + } +} diff --git a/PKHeX/Util/DateUtil.cs b/PKHeX/Util/DateUtil.cs index 0cff93c7f..3902c7e87 100644 --- a/PKHeX/Util/DateUtil.cs +++ b/PKHeX/Util/DateUtil.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; namespace PKHeX { diff --git a/PKHeX/Util/NetUtil.cs b/PKHeX/Util/NetUtil.cs new file mode 100644 index 000000000..d013c8b25 --- /dev/null +++ b/PKHeX/Util/NetUtil.cs @@ -0,0 +1,41 @@ +using System; +using System.Drawing; +using System.IO; +using System.Net; + +namespace PKHeX +{ + public partial class Util + { + public static string getStringFromURL(string webURL) + { + try + { + HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(webURL); + HttpWebResponse httpWebReponse = (HttpWebResponse)httpWebRequest.GetResponse(); + var reader = new StreamReader(httpWebReponse.GetResponseStream()); + return reader.ReadToEnd(); + } + catch (Exception e) + { + Console.WriteLine(e.Message); + return null; + } + } + public static Image getImageFromURL(string webURL) + { + try + { + HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(webURL); + HttpWebResponse httpWebReponse = (HttpWebResponse)httpWebRequest.GetResponse(); + Stream stream = httpWebReponse.GetResponseStream(); + return stream != null ? Image.FromStream(stream) : null; + } + catch (Exception e) + { + Console.WriteLine(e.Message); + return null; + } + } + } +}