Add g4 poffin editor (misc edits)

Thanks @sora10pls for docs!
https://pastebin.com/jNeVJQi0
This commit is contained in:
Kurt
2019-05-13 22:56:45 -07:00
parent 5140350ceb
commit 091b9e2281
7 changed files with 399 additions and 12 deletions

View File

@@ -1,4 +1,5 @@
using System;
using System.ComponentModel;
namespace PKHeX.Core
{
@@ -10,23 +11,37 @@ public class Poffin4
public Poffin4(byte[] data, int offset)
{
Data = new byte[SIZE];
Array.Copy(data, offset, data, 0, SIZE);
Array.Copy(data, offset, Data, 0, SIZE);
}
private const string Stats = nameof(Stats);
public Poffin4(byte[] data) => Data = data;
public PoffinFlavor4 Type{ get => (PoffinFlavor4)Data[0]; set => Data[0] = (byte)value; }
[Category(Stats), Description("Cool Stat Boost")]
public byte BoostSpicy { get => Data[1]; set => Data[1] = value; }
[Category(Stats), Description("Beauty Stat Boost")]
public byte BoostDry { get => Data[2]; set => Data[2] = value; }
[Category(Stats), Description("Cute Stat Boost")]
public byte BoostSweet { get => Data[3]; set => Data[3] = value; }
[Category(Stats), Description("Smart/Clever Stat Boost")]
public byte BoostBitter { get => Data[4]; set => Data[4] = value; }
[Category(Stats), Description("Tough Stat Boost")]
public byte BoostSour { get => Data[5]; set => Data[5] = value; }
[Category(Stats), Description("Sheen Stat Boost")]
public byte Smoothness { get => Data[6]; set => Data[6] = value; }
// public byte Unused { get => Data[7]; set => Data[7] = value; }
public bool IsManyStat => Type >= PoffinFlavor4.Rich;
public int StatPrimary => IsManyStat ? -1 : (byte)Type / 5;
public int StatSecondary => IsManyStat ? -1 : (byte)Type % 5;
public PoffinFlavor4 StatPrimary => IsManyStat ? PoffinFlavor4.None : (PoffinFlavor4)(((byte) Type / 5) * 6);
public PoffinFlavor4 StatSecondary => IsManyStat ? PoffinFlavor4.None : (PoffinFlavor4)(((byte)Type % 5) * 6);
public void SetAll(byte value = 255, PoffinFlavor4 type = PoffinFlavor4.Rich)
{

View File

@@ -301,6 +301,12 @@
</Compile>
<Compile Include="Subforms\Misc\PKMPreview.cs" />
<Compile Include="Subforms\Misc\PropertyComparer.cs" />
<Compile Include="Subforms\Save Editors\Gen4\PoffinCase4Editor.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Subforms\Save Editors\Gen4\PoffinCase4Editor.Designer.cs">
<DependentUpon>PoffinCase4Editor.cs</DependentUpon>
</Compile>
<Compile Include="Subforms\Save Editors\Gen4\SAV_Apricorn.cs">
<SubType>Form</SubType>
</Compile>
@@ -710,6 +716,9 @@
<SubType>Designer</SubType>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="Subforms\Save Editors\Gen4\PoffinCase4Editor.resx">
<DependentUpon>PoffinCase4Editor.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Subforms\Save Editors\Gen4\SAV_Apricorn.resx">
<DependentUpon>SAV_Apricorn.cs</DependentUpon>
</EmbeddedResource>

View File

@@ -0,0 +1,101 @@
namespace PKHeX.WinForms
{
partial class PoffinCase4Editor
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.LB_Poffins = new System.Windows.Forms.ListBox();
this.B_PoffinDel = new System.Windows.Forms.Button();
this.B_PoffinAll = new System.Windows.Forms.Button();
this.PG_Poffins = new System.Windows.Forms.PropertyGrid();
this.SuspendLayout();
//
// LB_Poffins
//
this.LB_Poffins.FormattingEnabled = true;
this.LB_Poffins.Location = new System.Drawing.Point(0, 2);
this.LB_Poffins.Name = "LB_Poffins";
this.LB_Poffins.Size = new System.Drawing.Size(120, 225);
this.LB_Poffins.TabIndex = 12;
this.LB_Poffins.SelectedIndexChanged += new System.EventHandler(this.LB_Poffins_SelectedIndexChanged);
//
// B_PoffinDel
//
this.B_PoffinDel.Location = new System.Drawing.Point(211, 201);
this.B_PoffinDel.Name = "B_PoffinDel";
this.B_PoffinDel.Size = new System.Drawing.Size(82, 26);
this.B_PoffinDel.TabIndex = 11;
this.B_PoffinDel.Text = "Delete All";
this.B_PoffinDel.UseVisualStyleBackColor = true;
this.B_PoffinDel.Click += new System.EventHandler(this.B_PoffinDel_Click);
//
// B_PoffinAll
//
this.B_PoffinAll.Location = new System.Drawing.Point(126, 201);
this.B_PoffinAll.Name = "B_PoffinAll";
this.B_PoffinAll.Size = new System.Drawing.Size(79, 26);
this.B_PoffinAll.TabIndex = 10;
this.B_PoffinAll.Text = "Give All";
this.B_PoffinAll.UseVisualStyleBackColor = true;
this.B_PoffinAll.Click += new System.EventHandler(this.B_PoffinAll_Click);
//
// PG_Poffins
//
this.PG_Poffins.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.PG_Poffins.HelpVisible = false;
this.PG_Poffins.Location = new System.Drawing.Point(126, 2);
this.PG_Poffins.Name = "PG_Poffins";
this.PG_Poffins.PropertySort = System.Windows.Forms.PropertySort.Categorized;
this.PG_Poffins.Size = new System.Drawing.Size(221, 195);
this.PG_Poffins.TabIndex = 9;
this.PG_Poffins.ToolbarVisible = false;
this.PG_Poffins.PropertyValueChanged += new System.Windows.Forms.PropertyValueChangedEventHandler(this.PG_Poffins_PropertyValueChanged);
//
// PoffinCase4Editor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.LB_Poffins);
this.Controls.Add(this.B_PoffinDel);
this.Controls.Add(this.B_PoffinAll);
this.Controls.Add(this.PG_Poffins);
this.Name = "PoffinCase4Editor";
this.Size = new System.Drawing.Size(347, 232);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.ListBox LB_Poffins;
private System.Windows.Forms.Button B_PoffinDel;
private System.Windows.Forms.Button B_PoffinAll;
private System.Windows.Forms.PropertyGrid PG_Poffins;
}
}

View File

@@ -0,0 +1,89 @@
using System;
using System.Windows.Forms;
using PKHeX.Core;
namespace PKHeX.WinForms
{
public partial class PoffinCase4Editor : UserControl
{
public PoffinCase4Editor() => InitializeComponent();
private PoffinCase4 Case;
private int CurrentIndex = -1;
private bool Updating;
public void Initialize(SAV4 sav)
{
Case = new PoffinCase4(sav);
LB_Poffins.Items.Clear();
for (int i = 0; i < Case.Poffins.Length; i++)
LB_Poffins.Items.Add(GetPoffinText(i));
LB_Poffins.SelectedIndex = 0;
}
private void RefreshList()
{
Updating = true;
for (int i = 0; i < Case.Poffins.Length; i++)
LB_Poffins.Items[i] = GetPoffinText(i);
Updating = false;
}
private string GetPoffinText(int i) => $"{i + 1:000} - {Case.Poffins[i].Type.ToString().Replace('_', '/')}";
public void Save()
{
SaveIndex(CurrentIndex);
Case.Save();
}
private void SaveIndex(int i)
{
// do nothing, propertygrid handles everything
if (i < 0)
return;
Updating = true;
LB_Poffins.Items[i] = GetPoffinText(i);
Updating = false;
}
private void LoadIndex(int i)
{
if (i < 0)
{
LB_Poffins.SelectedIndex = 0;
return;
}
PG_Poffins.SelectedObject = Case.Poffins[i];
}
private void LB_Poffins_SelectedIndexChanged(object sender, EventArgs e)
{
if (Updating)
return;
SaveIndex(CurrentIndex);
LoadIndex(CurrentIndex = LB_Poffins.SelectedIndex);
}
private void B_PoffinAll_Click(object sender, EventArgs e)
{
Case.FillCase();
PG_Poffins.Refresh();
RefreshList();
}
private void B_PoffinDel_Click(object sender, EventArgs e)
{
Case.DeleteAll();
PG_Poffins.Refresh();
RefreshList();
}
private void PG_Poffins_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
{
SaveIndex(LB_Poffins.SelectedIndex);
}
}
}

View File

@@ -0,0 +1,135 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="LB_Poffins.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="B_PoffinDel.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="B_PoffinAll.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="PG_Poffins.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

View File

@@ -101,8 +101,10 @@ private void InitializeComponent()
this.TAB_Walker = new System.Windows.Forms.TabPage();
this.B_UnlockCourses = new System.Windows.Forms.Button();
this.Tab_Misc = new System.Windows.Forms.TabPage();
this.B_AllSealsLegal = new System.Windows.Forms.Button();
this.B_AllSealsIllegal = new System.Windows.Forms.Button();
this.B_AllSealsLegal = new System.Windows.Forms.Button();
this.Tab_Poffins = new System.Windows.Forms.TabPage();
this.poffinCase4Editor1 = new PKHeX.WinForms.PoffinCase4Editor();
this.TC_Misc.SuspendLayout();
this.TAB_Main.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.NUD_Coin)).BeginInit();
@@ -143,6 +145,7 @@ private void InitializeComponent()
((System.ComponentModel.ISupportInitialize)(this.NUD_CastleRankInfo)).BeginInit();
this.TAB_Walker.SuspendLayout();
this.Tab_Misc.SuspendLayout();
this.Tab_Poffins.SuspendLayout();
this.SuspendLayout();
//
// B_Cancel
@@ -169,10 +172,14 @@ private void InitializeComponent()
//
// TC_Misc
//
this.TC_Misc.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.TC_Misc.Controls.Add(this.TAB_Main);
this.TC_Misc.Controls.Add(this.TAB_BF);
this.TC_Misc.Controls.Add(this.TAB_Walker);
this.TC_Misc.Controls.Add(this.Tab_Misc);
this.TC_Misc.Controls.Add(this.Tab_Poffins);
this.TC_Misc.Location = new System.Drawing.Point(12, 13);
this.TC_Misc.Name = "TC_Misc";
this.TC_Misc.SelectedIndex = 0;
@@ -1166,6 +1173,16 @@ private void InitializeComponent()
this.Tab_Misc.Text = "Misc";
this.Tab_Misc.UseVisualStyleBackColor = true;
//
// B_AllSealsIllegal
//
this.B_AllSealsIllegal.Location = new System.Drawing.Point(6, 49);
this.B_AllSealsIllegal.Name = "B_AllSealsIllegal";
this.B_AllSealsIllegal.Size = new System.Drawing.Size(120, 37);
this.B_AllSealsIllegal.TabIndex = 1;
this.B_AllSealsIllegal.Text = "Give All Seals (Illegal)";
this.B_AllSealsIllegal.UseVisualStyleBackColor = true;
this.B_AllSealsIllegal.Click += new System.EventHandler(this.OnBAllSealsLegalOnClick);
//
// B_AllSealsLegal
//
this.B_AllSealsLegal.Location = new System.Drawing.Point(6, 6);
@@ -1176,15 +1193,24 @@ private void InitializeComponent()
this.B_AllSealsLegal.UseVisualStyleBackColor = true;
this.B_AllSealsLegal.Click += new System.EventHandler(this.OnBAllSealsLegalOnClick);
//
// B_AllSealsIllegal
// Tab_Poffins
//
this.B_AllSealsIllegal.Location = new System.Drawing.Point(6, 49);
this.B_AllSealsIllegal.Name = "B_AllSealsIllegal";
this.B_AllSealsIllegal.Size = new System.Drawing.Size(120, 37);
this.B_AllSealsIllegal.TabIndex = 1;
this.B_AllSealsIllegal.Text = "Give All Seals (Illegal)";
this.B_AllSealsIllegal.UseVisualStyleBackColor = true;
this.B_AllSealsIllegal.Click += new System.EventHandler(this.OnBAllSealsLegalOnClick);
this.Tab_Poffins.Controls.Add(this.poffinCase4Editor1);
this.Tab_Poffins.Location = new System.Drawing.Point(4, 22);
this.Tab_Poffins.Name = "Tab_Poffins";
this.Tab_Poffins.Padding = new System.Windows.Forms.Padding(3);
this.Tab_Poffins.Size = new System.Drawing.Size(373, 239);
this.Tab_Poffins.TabIndex = 4;
this.Tab_Poffins.Text = "Poffins";
this.Tab_Poffins.UseVisualStyleBackColor = true;
//
// poffinCase4Editor1
//
this.poffinCase4Editor1.Dock = System.Windows.Forms.DockStyle.Fill;
this.poffinCase4Editor1.Location = new System.Drawing.Point(3, 3);
this.poffinCase4Editor1.Name = "poffinCase4Editor1";
this.poffinCase4Editor1.Size = new System.Drawing.Size(367, 233);
this.poffinCase4Editor1.TabIndex = 0;
//
// SAV_Misc4
//
@@ -1241,6 +1267,7 @@ private void InitializeComponent()
((System.ComponentModel.ISupportInitialize)(this.NUD_CastleRankInfo)).EndInit();
this.TAB_Walker.ResumeLayout(false);
this.Tab_Misc.ResumeLayout(false);
this.Tab_Poffins.ResumeLayout(false);
this.ResumeLayout(false);
}
@@ -1321,5 +1348,7 @@ private void InitializeComponent()
private System.Windows.Forms.TabPage Tab_Misc;
private System.Windows.Forms.Button B_AllSealsIllegal;
private System.Windows.Forms.Button B_AllSealsLegal;
private System.Windows.Forms.TabPage Tab_Poffins;
private PoffinCase4Editor poffinCase4Editor1;
}
}

View File

@@ -76,13 +76,22 @@ public SAV_Misc4(SaveFile sav)
ReadMain();
ReadBattleFrontier();
if (!SAV.HGSS)
{
TC_Misc.Controls.Remove(TAB_Walker);
poffinCase4Editor1.Initialize(SAV);
}
else
{
TC_Misc.Controls.Remove(Tab_Poffins);
}
}
private void B_Save_Click(object sender, EventArgs e)
{
SaveMain();
SaveBattleFrontier();
if (!SAV.HGSS)
poffinCase4Editor1.Save();
Origin.SetData(SAV.Data, 0);
Close();