From a4f43f2afd8b016ed1cd977d942a492f5b46d1d7 Mon Sep 17 00:00:00 2001 From: pokecal Date: Sun, 16 Apr 2017 15:14:07 +0900 Subject: [PATCH 1/2] add Gen3 Badge without RS --- .../Save Editors/SAV_SimpleTrainer.cs | 15 ++++++++++-- PKHeX/Saves/SAV3.cs | 24 ++++++++++++++++++- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/PKHeX.WinForms/Subforms/Save Editors/SAV_SimpleTrainer.cs b/PKHeX.WinForms/Subforms/Save Editors/SAV_SimpleTrainer.cs index bd64bdd63..256e659d7 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/SAV_SimpleTrainer.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/SAV_SimpleTrainer.cs @@ -88,12 +88,17 @@ public SAV_SimpleTrainer() if (SAV is SAV3) { GB_Map.Visible = false; - GB_Badges.Visible = false; // todo + SAV3 sav3 = (SAV3)SAV; + switch (sav3.Version) + { + case GameVersion.E: badgeval = sav3.Badges; break; + case GameVersion.FRLG: badgeval = sav3.Badges; break; + default: GB_Badges.Visible = false; break; // RS + } L_Started.Visible = L_Fame.Visible = false; CAL_AdventureStartDate.Visible = CAL_HoFDate.Visible = false; CAL_AdventureStartTime.Visible = CAL_HoFTime.Visible = false; - return; } if (SAV is SAV3Colosseum || SAV is SAV3XD) { @@ -203,6 +208,12 @@ private void B_Save_Click(object sender, EventArgs e) sav2.TextSpeed = CB_TextSpeed.SelectedIndex; } + if (SAV is SAV3) + { + SAV3 sav3 = (SAV3)SAV; + sav3.Badges = badgeval & 0xFF; + } + if (SAV is SAV4) { SAV4 s = (SAV4)SAV; diff --git a/PKHeX/Saves/SAV3.cs b/PKHeX/Saves/SAV3.cs index 74c2f2551..b5f9732fe 100644 --- a/PKHeX/Saves/SAV3.cs +++ b/PKHeX/Saves/SAV3.cs @@ -286,7 +286,29 @@ public int PlayedFrames get { return Data[BlockOfs[0] + 0x12]; } set { Data[BlockOfs[0] + 0x12] = (byte)value; } } - + public int Badges + { + get + { + switch (Version) + { + case GameVersion.E: return BitConverter.ToUInt16(Data, BlockOfs[2] + 0x3FC) >> 7 & 0xFF; + case GameVersion.FRLG: return Data[BlockOfs[2] + 0x64]; + default: return 0; // RS + } + } + set + { + switch (Version) + { + case GameVersion.E: + BitConverter.GetBytes(BitConverter.ToUInt16(Data, BlockOfs[2] + 0x3FC) & ~(0xFF << 7) | (value << 7)).CopyTo(Data, BlockOfs[2] + 0x3FC); + break; + case GameVersion.FRLG: Data[BlockOfs[2] + 0x64] = (byte)value; break; + default: return; // RS + } + } + } public override uint Money { get From 0adbf8517710672259e68f7a4d3213f4fb2b2401 Mon Sep 17 00:00:00 2001 From: pokecal Date: Sun, 16 Apr 2017 15:37:36 +0900 Subject: [PATCH 2/2] add Gen3(Em) BattleFrontiers Controls for trainerCard icons, streaks. --- .../Save Editors/Gen3/SAV_Misc3.Designer.cs | 406 +++++++++++++++++- .../Subforms/Save Editors/Gen3/SAV_Misc3.cs | 191 ++++++++ 2 files changed, 590 insertions(+), 7 deletions(-) diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Misc3.Designer.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Misc3.Designer.cs index 112cfdff1..91fb398dc 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Misc3.Designer.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Misc3.Designer.cs @@ -68,6 +68,31 @@ private void InitializeComponent() this.CHK_InitialBirth = new System.Windows.Forms.CheckBox(); this.CHK_InitialFaraway = new System.Windows.Forms.CheckBox(); this.B_GetTickets = new System.Windows.Forms.Button(); + this.TAB_BF = new System.Windows.Forms.TabPage(); + this.GB_Streaks = new System.Windows.Forms.GroupBox(); + this.NUD_Stat3 = new System.Windows.Forms.NumericUpDown(); + this.NUD_Stat2 = new System.Windows.Forms.NumericUpDown(); + this.NUD_Stat1 = new System.Windows.Forms.NumericUpDown(); + this.NUD_Stat0 = new System.Windows.Forms.NumericUpDown(); + this.L_Stat3 = new System.Windows.Forms.Label(); + this.L_Stat2 = new System.Windows.Forms.Label(); + this.L_Stat1 = new System.Windows.Forms.Label(); + this.L_Stat0 = new System.Windows.Forms.Label(); + this.CHK_Continue = new System.Windows.Forms.CheckBox(); + this.RB_Stats3_02 = new System.Windows.Forms.RadioButton(); + this.RB_Stats3_01 = new System.Windows.Forms.RadioButton(); + this.CB_Stats2 = new System.Windows.Forms.ComboBox(); + this.CB_Stats1 = new System.Windows.Forms.ComboBox(); + this.GB_FrontierPass = new System.Windows.Forms.GroupBox(); + this.GB_Icons = new System.Windows.Forms.GroupBox(); + this.BTN_SymbolB = new System.Windows.Forms.Button(); + this.BTN_SymbolL = new System.Windows.Forms.Button(); + this.BTN_SymbolK = new System.Windows.Forms.Button(); + this.BTN_SymbolG = new System.Windows.Forms.Button(); + this.BTN_SymbolS = new System.Windows.Forms.Button(); + this.BTN_SymbolT = new System.Windows.Forms.Button(); + this.BTN_SymbolA = new System.Windows.Forms.Button(); + this.CHK_ActivatePass = new System.Windows.Forms.CheckBox(); this.tabControl1.SuspendLayout(); this.TAB_Main.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.NUD_BP)).BeginInit(); @@ -76,12 +101,20 @@ private void InitializeComponent() this.TAB_Ferry.SuspendLayout(); this.GB_Reachable.SuspendLayout(); this.GB_InitialEvent.SuspendLayout(); + this.TAB_BF.SuspendLayout(); + this.GB_Streaks.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.NUD_Stat3)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.NUD_Stat2)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.NUD_Stat1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.NUD_Stat0)).BeginInit(); + this.GB_FrontierPass.SuspendLayout(); + this.GB_Icons.SuspendLayout(); this.SuspendLayout(); // // B_Save // this.B_Save.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.B_Save.Location = new System.Drawing.Point(178, 209); + this.B_Save.Location = new System.Drawing.Point(213, 262); this.B_Save.Name = "B_Save"; this.B_Save.Size = new System.Drawing.Size(75, 23); this.B_Save.TabIndex = 73; @@ -92,7 +125,7 @@ private void InitializeComponent() // B_Cancel // this.B_Cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.B_Cancel.Location = new System.Drawing.Point(97, 209); + this.B_Cancel.Location = new System.Drawing.Point(132, 262); this.B_Cancel.Name = "B_Cancel"; this.B_Cancel.Size = new System.Drawing.Size(75, 23); this.B_Cancel.TabIndex = 72; @@ -108,10 +141,11 @@ private void InitializeComponent() this.tabControl1.Controls.Add(this.TAB_Main); this.tabControl1.Controls.Add(this.TAB_Joyful); this.tabControl1.Controls.Add(this.TAB_Ferry); + this.tabControl1.Controls.Add(this.TAB_BF); this.tabControl1.Location = new System.Drawing.Point(12, 12); this.tabControl1.Name = "tabControl1"; this.tabControl1.SelectedIndex = 0; - this.tabControl1.Size = new System.Drawing.Size(239, 191); + this.tabControl1.Size = new System.Drawing.Size(274, 244); this.tabControl1.TabIndex = 74; // // TAB_Main @@ -125,7 +159,7 @@ private void InitializeComponent() this.TAB_Main.Location = new System.Drawing.Point(4, 22); this.TAB_Main.Name = "TAB_Main"; this.TAB_Main.Padding = new System.Windows.Forms.Padding(3); - this.TAB_Main.Size = new System.Drawing.Size(231, 165); + this.TAB_Main.Size = new System.Drawing.Size(266, 218); this.TAB_Main.TabIndex = 0; this.TAB_Main.Text = "Main"; this.TAB_Main.UseVisualStyleBackColor = true; @@ -195,7 +229,7 @@ private void InitializeComponent() this.TAB_Joyful.Location = new System.Drawing.Point(4, 22); this.TAB_Joyful.Name = "TAB_Joyful"; this.TAB_Joyful.Padding = new System.Windows.Forms.Padding(3); - this.TAB_Joyful.Size = new System.Drawing.Size(231, 165); + this.TAB_Joyful.Size = new System.Drawing.Size(266, 218); this.TAB_Joyful.TabIndex = 1; this.TAB_Joyful.Text = "Joyful"; this.TAB_Joyful.UseVisualStyleBackColor = true; @@ -361,7 +395,7 @@ private void InitializeComponent() this.TAB_Ferry.Location = new System.Drawing.Point(4, 22); this.TAB_Ferry.Name = "TAB_Ferry"; this.TAB_Ferry.Padding = new System.Windows.Forms.Padding(3); - this.TAB_Ferry.Size = new System.Drawing.Size(225, 165); + this.TAB_Ferry.Size = new System.Drawing.Size(266, 218); this.TAB_Ferry.TabIndex = 2; this.TAB_Ferry.Text = "Ferry"; this.TAB_Ferry.UseVisualStyleBackColor = true; @@ -503,11 +537,328 @@ private void InitializeComponent() this.B_GetTickets.UseVisualStyleBackColor = true; this.B_GetTickets.Click += new System.EventHandler(this.B_GetTickets_Click); // + // TAB_BF + // + this.TAB_BF.Controls.Add(this.GB_Streaks); + this.TAB_BF.Controls.Add(this.GB_FrontierPass); + this.TAB_BF.Location = new System.Drawing.Point(4, 22); + this.TAB_BF.Name = "TAB_BF"; + this.TAB_BF.Size = new System.Drawing.Size(266, 218); + this.TAB_BF.TabIndex = 3; + this.TAB_BF.Text = "B.Frontier"; + this.TAB_BF.UseVisualStyleBackColor = true; + // + // GB_Streaks + // + this.GB_Streaks.Controls.Add(this.NUD_Stat3); + this.GB_Streaks.Controls.Add(this.NUD_Stat2); + this.GB_Streaks.Controls.Add(this.NUD_Stat1); + this.GB_Streaks.Controls.Add(this.NUD_Stat0); + this.GB_Streaks.Controls.Add(this.L_Stat3); + this.GB_Streaks.Controls.Add(this.L_Stat2); + this.GB_Streaks.Controls.Add(this.L_Stat1); + this.GB_Streaks.Controls.Add(this.L_Stat0); + this.GB_Streaks.Controls.Add(this.CHK_Continue); + this.GB_Streaks.Controls.Add(this.RB_Stats3_02); + this.GB_Streaks.Controls.Add(this.RB_Stats3_01); + this.GB_Streaks.Controls.Add(this.CB_Stats2); + this.GB_Streaks.Controls.Add(this.CB_Stats1); + this.GB_Streaks.Location = new System.Drawing.Point(146, 6); + this.GB_Streaks.Name = "GB_Streaks"; + this.GB_Streaks.Size = new System.Drawing.Size(114, 206); + this.GB_Streaks.TabIndex = 1; + this.GB_Streaks.TabStop = false; + this.GB_Streaks.Text = "Streaks"; + // + // NUD_Stat3 + // + this.NUD_Stat3.Location = new System.Drawing.Point(55, 183); + this.NUD_Stat3.Maximum = new decimal(new int[] { + 9999, + 0, + 0, + 0}); + this.NUD_Stat3.Name = "NUD_Stat3"; + this.NUD_Stat3.Size = new System.Drawing.Size(47, 20); + this.NUD_Stat3.TabIndex = 12; + this.NUD_Stat3.Value = new decimal(new int[] { + 9999, + 0, + 0, + 0}); + this.NUD_Stat3.ValueChanged += new System.EventHandler(this.ChangeStatVal); + // + // NUD_Stat2 + // + this.NUD_Stat2.Location = new System.Drawing.Point(55, 157); + this.NUD_Stat2.Maximum = new decimal(new int[] { + 9999, + 0, + 0, + 0}); + this.NUD_Stat2.Name = "NUD_Stat2"; + this.NUD_Stat2.Size = new System.Drawing.Size(47, 20); + this.NUD_Stat2.TabIndex = 11; + this.NUD_Stat2.Value = new decimal(new int[] { + 9999, + 0, + 0, + 0}); + this.NUD_Stat2.ValueChanged += new System.EventHandler(this.ChangeStatVal); + // + // NUD_Stat1 + // + this.NUD_Stat1.Location = new System.Drawing.Point(55, 131); + this.NUD_Stat1.Maximum = new decimal(new int[] { + 9999, + 0, + 0, + 0}); + this.NUD_Stat1.Name = "NUD_Stat1"; + this.NUD_Stat1.Size = new System.Drawing.Size(47, 20); + this.NUD_Stat1.TabIndex = 10; + this.NUD_Stat1.Value = new decimal(new int[] { + 9999, + 0, + 0, + 0}); + this.NUD_Stat1.ValueChanged += new System.EventHandler(this.ChangeStatVal); + // + // NUD_Stat0 + // + this.NUD_Stat0.Location = new System.Drawing.Point(55, 105); + this.NUD_Stat0.Maximum = new decimal(new int[] { + 9999, + 0, + 0, + 0}); + this.NUD_Stat0.Name = "NUD_Stat0"; + this.NUD_Stat0.Size = new System.Drawing.Size(47, 20); + this.NUD_Stat0.TabIndex = 6; + this.NUD_Stat0.Value = new decimal(new int[] { + 9999, + 0, + 0, + 0}); + this.NUD_Stat0.ValueChanged += new System.EventHandler(this.ChangeStatVal); + // + // L_Stat3 + // + this.L_Stat3.AutoSize = true; + this.L_Stat3.Location = new System.Drawing.Point(6, 185); + this.L_Stat3.Name = "L_Stat3"; + this.L_Stat3.Size = new System.Drawing.Size(34, 12); + this.L_Stat3.TabIndex = 13; + this.L_Stat3.Text = "Trade"; + // + // L_Stat2 + // + this.L_Stat2.AutoSize = true; + this.L_Stat2.Location = new System.Drawing.Point(6, 159); + this.L_Stat2.Name = "L_Stat2"; + this.L_Stat2.Size = new System.Drawing.Size(26, 12); + this.L_Stat2.TabIndex = 9; + this.L_Stat2.Text = "Max"; + // + // L_Stat1 + // + this.L_Stat1.AutoSize = true; + this.L_Stat1.Location = new System.Drawing.Point(6, 133); + this.L_Stat1.Name = "L_Stat1"; + this.L_Stat1.Size = new System.Drawing.Size(34, 12); + this.L_Stat1.TabIndex = 8; + this.L_Stat1.Text = "Trade"; + // + // L_Stat0 + // + this.L_Stat0.AutoSize = true; + this.L_Stat0.Location = new System.Drawing.Point(6, 107); + this.L_Stat0.Name = "L_Stat0"; + this.L_Stat0.Size = new System.Drawing.Size(43, 12); + this.L_Stat0.TabIndex = 7; + this.L_Stat0.Text = "Current"; + // + // CHK_Continue + // + this.CHK_Continue.AutoSize = true; + this.CHK_Continue.Location = new System.Drawing.Point(6, 85); + this.CHK_Continue.Name = "CHK_Continue"; + this.CHK_Continue.Size = new System.Drawing.Size(69, 16); + this.CHK_Continue.TabIndex = 5; + this.CHK_Continue.Text = "Continue"; + this.CHK_Continue.UseVisualStyleBackColor = true; + this.CHK_Continue.CheckedChanged += new System.EventHandler(this.CHK_Continue_CheckedChanged); + // + // RB_Stats3_02 + // + this.RB_Stats3_02.AutoSize = true; + this.RB_Stats3_02.Location = new System.Drawing.Point(59, 65); + this.RB_Stats3_02.Name = "RB_Stats3_02"; + this.RB_Stats3_02.Size = new System.Drawing.Size(49, 16); + this.RB_Stats3_02.TabIndex = 4; + this.RB_Stats3_02.TabStop = true; + this.RB_Stats3_02.Text = "Open"; + this.RB_Stats3_02.UseVisualStyleBackColor = true; + this.RB_Stats3_02.CheckedChanged += new System.EventHandler(this.ChangeStat); + // + // RB_Stats3_01 + // + this.RB_Stats3_01.AutoSize = true; + this.RB_Stats3_01.Location = new System.Drawing.Point(6, 65); + this.RB_Stats3_01.Name = "RB_Stats3_01"; + this.RB_Stats3_01.Size = new System.Drawing.Size(47, 16); + this.RB_Stats3_01.TabIndex = 3; + this.RB_Stats3_01.TabStop = true; + this.RB_Stats3_01.Text = "Lv50"; + this.RB_Stats3_01.UseVisualStyleBackColor = true; + this.RB_Stats3_01.CheckedChanged += new System.EventHandler(this.ChangeStat); + // + // CB_Stats2 + // + this.CB_Stats2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.CB_Stats2.FormattingEnabled = true; + this.CB_Stats2.Location = new System.Drawing.Point(6, 41); + this.CB_Stats2.Name = "CB_Stats2"; + this.CB_Stats2.Size = new System.Drawing.Size(68, 20); + this.CB_Stats2.TabIndex = 1; + this.CB_Stats2.SelectedIndexChanged += new System.EventHandler(this.ChangeStat); + // + // CB_Stats1 + // + this.CB_Stats1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.CB_Stats1.FormattingEnabled = true; + this.CB_Stats1.Location = new System.Drawing.Point(6, 17); + this.CB_Stats1.Name = "CB_Stats1"; + this.CB_Stats1.Size = new System.Drawing.Size(68, 20); + this.CB_Stats1.TabIndex = 0; + this.CB_Stats1.SelectedIndexChanged += new System.EventHandler(this.ChangeStat1); + // + // GB_FrontierPass + // + this.GB_FrontierPass.Controls.Add(this.GB_Icons); + this.GB_FrontierPass.Controls.Add(this.CHK_ActivatePass); + this.GB_FrontierPass.Location = new System.Drawing.Point(6, 6); + this.GB_FrontierPass.Name = "GB_FrontierPass"; + this.GB_FrontierPass.Size = new System.Drawing.Size(134, 121); + this.GB_FrontierPass.TabIndex = 0; + this.GB_FrontierPass.TabStop = false; + this.GB_FrontierPass.Text = "Frontier Pass"; + // + // GB_Icons + // + this.GB_Icons.Controls.Add(this.BTN_SymbolB); + this.GB_Icons.Controls.Add(this.BTN_SymbolL); + this.GB_Icons.Controls.Add(this.BTN_SymbolK); + this.GB_Icons.Controls.Add(this.BTN_SymbolG); + this.GB_Icons.Controls.Add(this.BTN_SymbolS); + this.GB_Icons.Controls.Add(this.BTN_SymbolT); + this.GB_Icons.Controls.Add(this.BTN_SymbolA); + this.GB_Icons.Location = new System.Drawing.Point(6, 37); + this.GB_Icons.Name = "GB_Icons"; + this.GB_Icons.Size = new System.Drawing.Size(122, 78); + this.GB_Icons.TabIndex = 1; + this.GB_Icons.TabStop = false; + this.GB_Icons.Text = "Symbol Icons"; + // + // BTN_SymbolB + // + this.BTN_SymbolB.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.BTN_SymbolB.Font = new System.Drawing.Font("MS UI Gothic", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(128))); + this.BTN_SymbolB.Location = new System.Drawing.Point(93, 17); + this.BTN_SymbolB.Name = "BTN_SymbolB"; + this.BTN_SymbolB.Size = new System.Drawing.Size(23, 25); + this.BTN_SymbolB.TabIndex = 6; + this.BTN_SymbolB.Text = "B"; + this.BTN_SymbolB.UseVisualStyleBackColor = true; + this.BTN_SymbolB.Click += new System.EventHandler(this.BTN_Symbol_Click); + // + // BTN_SymbolL + // + this.BTN_SymbolL.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.BTN_SymbolL.Font = new System.Drawing.Font("MS UI Gothic", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(128))); + this.BTN_SymbolL.Location = new System.Drawing.Point(79, 47); + this.BTN_SymbolL.Name = "BTN_SymbolL"; + this.BTN_SymbolL.Size = new System.Drawing.Size(23, 25); + this.BTN_SymbolL.TabIndex = 5; + this.BTN_SymbolL.Text = "L"; + this.BTN_SymbolL.UseVisualStyleBackColor = true; + this.BTN_SymbolL.Click += new System.EventHandler(this.BTN_Symbol_Click); + // + // BTN_SymbolK + // + this.BTN_SymbolK.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.BTN_SymbolK.Font = new System.Drawing.Font("MS UI Gothic", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(128))); + this.BTN_SymbolK.Location = new System.Drawing.Point(64, 17); + this.BTN_SymbolK.Name = "BTN_SymbolK"; + this.BTN_SymbolK.Size = new System.Drawing.Size(23, 25); + this.BTN_SymbolK.TabIndex = 4; + this.BTN_SymbolK.Text = "K"; + this.BTN_SymbolK.UseVisualStyleBackColor = true; + this.BTN_SymbolK.Click += new System.EventHandler(this.BTN_Symbol_Click); + // + // BTN_SymbolG + // + this.BTN_SymbolG.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.BTN_SymbolG.Font = new System.Drawing.Font("MS UI Gothic", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(128))); + this.BTN_SymbolG.Location = new System.Drawing.Point(50, 47); + this.BTN_SymbolG.Name = "BTN_SymbolG"; + this.BTN_SymbolG.Size = new System.Drawing.Size(23, 25); + this.BTN_SymbolG.TabIndex = 3; + this.BTN_SymbolG.Text = "G"; + this.BTN_SymbolG.UseVisualStyleBackColor = true; + this.BTN_SymbolG.Click += new System.EventHandler(this.BTN_Symbol_Click); + // + // BTN_SymbolS + // + this.BTN_SymbolS.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.BTN_SymbolS.Font = new System.Drawing.Font("MS UI Gothic", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(128))); + this.BTN_SymbolS.Location = new System.Drawing.Point(35, 17); + this.BTN_SymbolS.Name = "BTN_SymbolS"; + this.BTN_SymbolS.Size = new System.Drawing.Size(23, 25); + this.BTN_SymbolS.TabIndex = 2; + this.BTN_SymbolS.Text = "S"; + this.BTN_SymbolS.UseVisualStyleBackColor = true; + this.BTN_SymbolS.Click += new System.EventHandler(this.BTN_Symbol_Click); + // + // BTN_SymbolT + // + this.BTN_SymbolT.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.BTN_SymbolT.Font = new System.Drawing.Font("MS UI Gothic", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(128))); + this.BTN_SymbolT.Location = new System.Drawing.Point(21, 47); + this.BTN_SymbolT.Name = "BTN_SymbolT"; + this.BTN_SymbolT.Size = new System.Drawing.Size(23, 25); + this.BTN_SymbolT.TabIndex = 1; + this.BTN_SymbolT.Text = "T"; + this.BTN_SymbolT.UseVisualStyleBackColor = true; + this.BTN_SymbolT.Click += new System.EventHandler(this.BTN_Symbol_Click); + // + // BTN_SymbolA + // + this.BTN_SymbolA.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.BTN_SymbolA.Font = new System.Drawing.Font("MS UI Gothic", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(128))); + this.BTN_SymbolA.Location = new System.Drawing.Point(6, 17); + this.BTN_SymbolA.Name = "BTN_SymbolA"; + this.BTN_SymbolA.Size = new System.Drawing.Size(23, 25); + this.BTN_SymbolA.TabIndex = 0; + this.BTN_SymbolA.Text = "A"; + this.BTN_SymbolA.UseVisualStyleBackColor = true; + this.BTN_SymbolA.Click += new System.EventHandler(this.BTN_Symbol_Click); + // + // CHK_ActivatePass + // + this.CHK_ActivatePass.AutoSize = true; + this.CHK_ActivatePass.Location = new System.Drawing.Point(6, 17); + this.CHK_ActivatePass.Name = "CHK_ActivatePass"; + this.CHK_ActivatePass.Size = new System.Drawing.Size(73, 16); + this.CHK_ActivatePass.TabIndex = 0; + this.CHK_ActivatePass.Text = "Activated"; + this.CHK_ActivatePass.UseVisualStyleBackColor = true; + // // SAV_Misc3 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(263, 244); + this.ClientSize = new System.Drawing.Size(295, 297); this.Controls.Add(this.tabControl1); this.Controls.Add(this.B_Save); this.Controls.Add(this.B_Cancel); @@ -523,6 +874,22 @@ private void InitializeComponent() this.TAB_Joyful.ResumeLayout(false); this.TAB_Joyful.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.NUD_Coins)).EndInit(); + this.TAB_Ferry.ResumeLayout(false); + this.TAB_Ferry.PerformLayout(); + this.GB_InitialEvent.ResumeLayout(false); + this.GB_InitialEvent.PerformLayout(); + this.GB_Reachable.ResumeLayout(false); + this.GB_Reachable.PerformLayout(); + this.TAB_BF.ResumeLayout(false); + this.GB_Streaks.ResumeLayout(false); + this.GB_Streaks.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.NUD_Stat3)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.NUD_Stat2)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.NUD_Stat1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.NUD_Stat0)).EndInit(); + this.GB_FrontierPass.ResumeLayout(false); + this.GB_FrontierPass.PerformLayout(); + this.GB_Icons.ResumeLayout(false); this.ResumeLayout(false); } @@ -567,5 +934,30 @@ private void InitializeComponent() private System.Windows.Forms.CheckBox CHK_ReachSouthern; private System.Windows.Forms.CheckBox CHK_Catchable; private System.Windows.Forms.Button B_GetTickets; + private System.Windows.Forms.TabPage TAB_BF; + private System.Windows.Forms.GroupBox GB_FrontierPass; + private System.Windows.Forms.GroupBox GB_Icons; + private System.Windows.Forms.CheckBox CHK_ActivatePass; + private System.Windows.Forms.Button BTN_SymbolS; + private System.Windows.Forms.Button BTN_SymbolT; + private System.Windows.Forms.Button BTN_SymbolA; + private System.Windows.Forms.Button BTN_SymbolB; + private System.Windows.Forms.Button BTN_SymbolL; + private System.Windows.Forms.Button BTN_SymbolK; + private System.Windows.Forms.Button BTN_SymbolG; + private System.Windows.Forms.GroupBox GB_Streaks; + private System.Windows.Forms.ComboBox CB_Stats2; + private System.Windows.Forms.ComboBox CB_Stats1; + private System.Windows.Forms.RadioButton RB_Stats3_02; + private System.Windows.Forms.RadioButton RB_Stats3_01; + private System.Windows.Forms.NumericUpDown NUD_Stat3; + private System.Windows.Forms.NumericUpDown NUD_Stat2; + private System.Windows.Forms.NumericUpDown NUD_Stat1; + private System.Windows.Forms.NumericUpDown NUD_Stat0; + private System.Windows.Forms.Label L_Stat3; + private System.Windows.Forms.Label L_Stat2; + private System.Windows.Forms.Label L_Stat1; + private System.Windows.Forms.Label L_Stat0; + private System.Windows.Forms.CheckBox CHK_Continue; } } diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Misc3.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Misc3.cs index 47ae8cf40..93fc103d3 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Misc3.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Misc3.cs @@ -19,9 +19,15 @@ public SAV_Misc3() tabControl1.Controls.Remove(TAB_Joyful); if (SAV.E) + { readFerry(); + readBF(); + } else + { tabControl1.Controls.Remove(TAB_Ferry); + tabControl1.Controls.Remove(TAB_BF); + } if (SAV.FRLG) TB_OTName.Text = PKX.getString3(SAV.Data, SAV.getBlockOffset(4) + 0xBCC, 8, SAV.Japanese); @@ -37,6 +43,8 @@ private void B_Save_Click(object sender, EventArgs e) saveJoyful(); if (tabControl1.Controls.Contains(TAB_Ferry)) saveFerry(); + if (tabControl1.Controls.Contains(TAB_BF)) + saveBF(); if (SAV.FRLG) SAV.setData(SAV.setString(TB_OTName.Text, TB_OTName.MaxLength), SAV.getBlockOffset(4) + 0xBCC); @@ -187,5 +195,188 @@ private void saveFerry() setFerryFlagFromNum(0x1DB, CHK_InitialNavel.Checked); } #endregion + + #region BattleFrontier + private int[] Symbols; + private int ofsSymbols; + private System.Drawing.Color[] SymbolColorA; + private Button[] SymbolButtonA; + private bool editingcont; + private bool editingval; + private RadioButton[] StatRBA; + private NumericUpDown[] StatNUDA; + private Label[] StatLabelA; + private bool loading; + private int[][] BFF; + private string[][] BFT; + private int[][] BFV; + private string[] BFN; + private void ChangeStat1(object sender, EventArgs e) + { + if (loading) return; + int facility = CB_Stats1.SelectedIndex; + if (facility < 0 || facility >= BFN.Length) return; + editingcont = true; + CB_Stats2.Items.Clear(); + foreach (RadioButton r in StatRBA) + r.Checked = false; + + if (BFT[BFF[facility][1]] == null) CB_Stats2.Visible = false; + else + { + CB_Stats2.Visible = true; + for (int i = 0; i < BFT[BFF[facility][1]].Length; i++) + CB_Stats2.Items.Add(BFT[BFF[facility][1]][i]); + CB_Stats2.SelectedIndex = 0; + } + + for (int i = 0; i < StatLabelA.Length; i++) + StatLabelA[i].Visible = StatLabelA[i].Enabled = StatNUDA[i].Visible = StatNUDA[i].Enabled = Array.IndexOf(BFV[BFF[facility][0]], i) >= 0; + + editingcont = false; + StatRBA[0].Checked = true; + } + private void ChangeStat(object sender, EventArgs e) + { + if (editingcont) return; + StatAddrControl(SetValToSav: -2, SetSavToVal: true); + } + private void StatAddrControl(int SetValToSav = -2, bool SetSavToVal = false) + { + int Facility = CB_Stats1.SelectedIndex; + if (Facility < 0) return; + + int BattleType = CB_Stats2.SelectedIndex; + if (BFT[BFF[Facility][1]] == null) BattleType = 0; + else if (BattleType < 0) return; + else if (BattleType >= BFT[BFF[Facility][1]].Length) return; + + int RBi = -1; + for (int i = 0, j = 0; i < StatRBA.Length; i++) + { + if (!StatRBA[i].Checked) continue; + if (++j > 1) return; + RBi = i; + } + if (RBi < 0) return; + + if (SetValToSav >= 0) + { + ushort val = (ushort)StatNUDA[SetValToSav].Value; + SetValToSav = Array.IndexOf(BFV[BFF[Facility][0]], SetValToSav); + if (SetValToSav < 0) return; + if (val > 9999) val = 9999; + BitConverter.GetBytes(val).CopyTo(SAV.Data, SAV.getBlockOffset(0) + BFF[Facility][2 + SetValToSav] + 4 * BattleType + 2 * RBi); + return; + } + else if (SetValToSav == -1) + { + int p = BFF[Facility][2 + BFV[BFF[Facility][0]].Length + BattleType] + RBi; + BitConverter.GetBytes(BitConverter.ToUInt32(SAV.Data, SAV.getBlockOffset(0) + 0xCDC) & (uint)~(1 << p) | (uint)((CHK_Continue.Checked ? 1 : 0) << p)).CopyTo(SAV.Data, SAV.getBlockOffset(0) + 0xCDC); + return; + } + if (SetSavToVal) + { + editingval = true; + for (int i = 0, vali; i < BFV[BFF[Facility][0]].Length; i++) + { + vali = BitConverter.ToUInt16(SAV.Data, SAV.getBlockOffset(0) + BFF[Facility][2 + i] + 4 * BattleType + 2 * RBi); + if (vali > 9999) vali = 9999; + StatNUDA[BFV[BFF[Facility][0]][i]].Value = vali; + } + CHK_Continue.Checked = (BitConverter.ToUInt32(SAV.Data, SAV.getBlockOffset(0) + 0xCDC) & 1 << (BFF[Facility][2 + BFV[BFF[Facility][0]].Length + BattleType] + RBi)) != 0; + editingval = false; + } + } + private void ChangeStatVal(object sender, EventArgs e) + { + if (editingval) return; + int n = Array.IndexOf(StatNUDA, sender); + if (n < 0) return; + StatAddrControl(SetValToSav: n, SetSavToVal: false); + } + + private void CHK_Continue_CheckedChanged(object sender, EventArgs e) + { + if (editingval) return; + StatAddrControl(SetValToSav: -1, SetSavToVal: false); + } + + private void readBF() + { + loading = true; + BFF = new[] { + // { BFV, BFT, addr(BFV.len), checkBitShift(BFT.len) + new[] { 0, 2, 0xCE0, 0xCF0, 0x00, 0x0E, 0x10, 0x12 }, + new[] { 1, 1, 0xD0C, 0xD14, 0xD1C, 0x02, 0x14 }, + new[] { 0, 1, 0xDC8, 0xDD0, 0x04, 0x16 }, + new[] { 0, 0, 0xDDA, 0xDDE, 0x06 }, + new[] { 2, 1, 0xDE2, 0xDF2, 0xDEA, 0xDFA, 0x08, 0x18 }, + new[] { 1, 0, 0xE04, 0xE08, 0xE0C, 0x0A }, + new[] { 0, 0, 0xE1A, 0xE1E, 0x0C }, + }; + BFV = new[] + { + new[] { 0, 2 }, // Current, Max + new[] { 0, 2, 3 }, // Current, Max, Total + new[] { 0, 1, 2, 3 }, // Current, Trade, Max, Trade + }; + BFT = new[] { + null, + new[] { "Singles", "Doubles" }, + new[] { "Singles", "Doubles", "Multi", "Linked" }, + }; + BFN = new[] + { + "Tower","Dome","Palace","Arena","Factory","Pike","Pyramid" + }; + StatNUDA = new[] { NUD_Stat0, NUD_Stat1, NUD_Stat2, NUD_Stat3 }; + StatLabelA = new[] { L_Stat0, L_Stat1, L_Stat2, L_Stat3 }; + StatRBA = new[] { RB_Stats3_01, RB_Stats3_02 }; + SymbolColorA = new[] { System.Drawing.Color.Transparent, System.Drawing.Color.Silver, System.Drawing.Color.Silver, System.Drawing.Color.Gold }; + SymbolButtonA = new[] { BTN_SymbolA, BTN_SymbolT, BTN_SymbolS, BTN_SymbolG, BTN_SymbolK, BTN_SymbolL, BTN_SymbolB }; + ofsSymbols = SAV.getBlockOffset(2) + 0x408; + int iSymbols = BitConverter.ToInt32(SAV.Data, ofsSymbols) >> 4 & 0x7FFF; + CHK_ActivatePass.Checked = (iSymbols >> 14 & 1) != 0; + Symbols = new int[7]; + for (int i = 0; i < 7; i++) + Symbols[i] = iSymbols >> i * 2 & 3; + setSymbols(); + + CB_Stats1.Items.Clear(); + for (int i = 0; i < BFN.Length; i++) + CB_Stats1.Items.Add(BFN[i]); + + loading = false; + CB_Stats1.SelectedIndex = 0; + } + private void setSymbols() + { + for (int i = 0; i < SymbolButtonA.Length; i++) + SymbolButtonA[i].BackColor = SymbolColorA[Symbols[i]]; + } + private void saveBF() + { + uint iSymbols = 0; + for (int i = 0; i < 7; i++) + iSymbols |= (uint)((Symbols[i] & 3) << i * 2); + if (CHK_ActivatePass.Checked) + iSymbols |= 1 << 14; + BitConverter.GetBytes(BitConverter.ToUInt32(SAV.Data, ofsSymbols) & ~(0x7FFF << 4) | (iSymbols & 0x7FFF) << 4).CopyTo(SAV.Data, ofsSymbols); + } + private void BTN_Symbol_Click(object sender, EventArgs e) + { + int index = Array.IndexOf(SymbolButtonA, sender); + if (index < 0) return; + + // 0 (none) | 1 (silver) | 2 (silver) | 3 (gold) + // bit rotation 00 -> 01 -> 11 -> 00 + if (Symbols[index] == 1) Symbols[index] = 3; + else Symbols[index] = (Symbols[index] + 1) & 3; + + setSymbols(); + } + #endregion + } }