mirror of
https://github.com/kwsch/PKHeX
synced 2025-02-17 05:48:44 +00:00
Implement SAV1 exporting.
This commit is contained in:
parent
8cfe57d504
commit
b94f3c8918
7 changed files with 126 additions and 17 deletions
1
PKHeX/MainWindow/Main.Designer.cs
generated
1
PKHeX/MainWindow/Main.Designer.cs
generated
|
@ -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
|
||||
|
|
|
@ -862,12 +862,13 @@ namespace PKHeX
|
|||
|
||||
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;
|
||||
|
||||
CHK_Nicknamed.Enabled = SAV.Generation > 2;
|
||||
|
||||
if (1 <= sav.Generation && sav.Generation <= 2)
|
||||
{
|
||||
Label_SPD.Visible = TB_SPDEV.Visible = TB_SPDIV.Visible = Stat_SPD.Visible = false;
|
||||
|
@ -2141,6 +2142,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)
|
||||
|
@ -2943,6 +2946,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()
|
||||
{
|
||||
|
@ -3155,6 +3180,7 @@ namespace PKHeX
|
|||
}
|
||||
private void getBox(object sender, EventArgs e)
|
||||
{
|
||||
SAV.CurrentBox = CB_BoxSelect.SelectedIndex;
|
||||
setPKXBoxes();
|
||||
}
|
||||
private void switchDaycare(object sender, EventArgs e)
|
||||
|
|
|
@ -22,6 +22,7 @@ namespace PKHeX
|
|||
|
||||
// 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;
|
||||
|
@ -55,6 +56,8 @@ namespace PKHeX
|
|||
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();
|
||||
|
|
|
@ -101,7 +101,25 @@ namespace PKHeX
|
|||
public override byte[] DecryptedBoxData => Encrypt().ToArray();
|
||||
public override byte[] DecryptedPartyData => Encrypt().ToArray();
|
||||
|
||||
public override bool IsNicknamed { get { throw new NotImplementedException(); } set { } }
|
||||
public override bool IsNicknamed
|
||||
{
|
||||
get
|
||||
{
|
||||
string spName = PKX.getSpeciesName(Species, Japanese ? 1 : 2).ToUpper();
|
||||
return
|
||||
!nick.SequenceEqual(
|
||||
PKX.setG1Str(spName, Japanese)
|
||||
.Concat(Enumerable.Repeat((byte) 0x50, StringLength - spName.Length - 1)));
|
||||
}
|
||||
set { }
|
||||
}
|
||||
|
||||
public void setNotNicknamed()
|
||||
{
|
||||
string spName = PKX.getSpeciesName(Species, Japanese ? 1 : 2).ToUpper();
|
||||
nick = PKX.setG1Str(spName, Japanese).Concat(Enumerable.Repeat((byte)0x50, StringLength - spName.Length - 1)).ToArray();
|
||||
}
|
||||
|
||||
|
||||
#region Stored Attributes
|
||||
public override int Species
|
||||
|
@ -343,12 +361,16 @@ namespace PKHeX
|
|||
set
|
||||
{
|
||||
if (value == null) return;
|
||||
Pokemon[i] = (PK1)value.Clone();
|
||||
Pokemon[i] = (PK1)(((PK1)value).Clone());
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Pokemon.Any(pk => (pk.Species == 0)))
|
||||
Count = (byte) Array.FindIndex(Pokemon, pk => (pk.Species == 0));
|
||||
else
|
||||
Count = Capacity;
|
||||
for (int i = 0; i < Count; i++)
|
||||
{
|
||||
Data[1 + i] = (byte)PKX.setG1Species(Pokemon[i].Species);
|
||||
|
|
|
@ -1841,6 +1841,7 @@ namespace PKHeX
|
|||
{"ば", 0x3A},
|
||||
{"び", 0x3B},
|
||||
{"ぶ", 0x3C},
|
||||
{"ベ", 0x3D},
|
||||
{"べ", 0x3D},
|
||||
{"ぼ", 0x3E},
|
||||
{"パ", 0x40},
|
||||
|
@ -1851,13 +1852,16 @@ namespace PKHeX
|
|||
{"ぴ", 0x45},
|
||||
{"ぷ", 0x46},
|
||||
{"ぺ", 0x47},
|
||||
{"ペ", 0x47},
|
||||
{"ぽ", 0x48},
|
||||
{"\0", 0x50},
|
||||
{"トレーナー", 0x5D},
|
||||
{"ア", 0x80},
|
||||
{"イ", 0x81},
|
||||
{"ウ", 0x82},
|
||||
{"ェ", 0x83},
|
||||
{"エ", 0x83},
|
||||
{"オ", 0x84},
|
||||
{"ォ", 0x84},
|
||||
{"カ", 0x85},
|
||||
{"キ", 0x86},
|
||||
|
@ -1942,6 +1946,7 @@ namespace PKHeX
|
|||
{"ゆ", 0xD5},
|
||||
{"よ", 0xD6},
|
||||
{"ら", 0xD7},
|
||||
{"リ", 0xD8},
|
||||
{"り", 0xD8},
|
||||
{"る", 0xD9},
|
||||
{"れ", 0xDA},
|
||||
|
@ -1955,6 +1960,8 @@ namespace PKHeX
|
|||
{"ょ", 0xE2},
|
||||
{"ー", 0xE3},
|
||||
{"ァ", 0xE9},
|
||||
{"♂", 0xEF},
|
||||
{"♀", 0xF5}
|
||||
};
|
||||
|
||||
static Dictionary<byte, string> RBY2U_J => new Dictionary<byte, string> {
|
||||
|
@ -1995,7 +2002,7 @@ namespace PKHeX
|
|||
{0x3A, "ば"},
|
||||
{0x3B, "び"},
|
||||
{0x3C, "ぶ"},
|
||||
{0x3D, "べ"},
|
||||
{0x3D, "ベ"},
|
||||
{0x3E, "ぼ"},
|
||||
{0x40, "パ"},
|
||||
{0x41, "ピ"},
|
||||
|
@ -2004,15 +2011,15 @@ namespace PKHeX
|
|||
{0x44, "ぱ"},
|
||||
{0x45, "ぴ"},
|
||||
{0x46, "ぷ"},
|
||||
{0x47, "ぺ"},
|
||||
{0x47, "ペ"},
|
||||
{0x48, "ぽ"},
|
||||
{0x50, "\0"},
|
||||
{0x5D, "トレーナー"},
|
||||
{0x80, "ア"},
|
||||
{0x81, "イ"},
|
||||
{0x82, "ウ"},
|
||||
{0x83, "エ"},
|
||||
{0x84, "ォ"},
|
||||
{0x83, "ェ"},
|
||||
{0x84, "オ"},
|
||||
{0x85, "カ"},
|
||||
{0x86, "キ"},
|
||||
{0x87, "ク"},
|
||||
|
@ -2096,7 +2103,7 @@ namespace PKHeX
|
|||
{0xD5, "ゆ"},
|
||||
{0xD6, "よ"},
|
||||
{0xD7, "ら"},
|
||||
{0xD8, "り"},
|
||||
{0xD8, "リ"},
|
||||
{0xD9, "る"},
|
||||
{0xDA, "れ"},
|
||||
{0xDB, "ろ"},
|
||||
|
@ -2109,6 +2116,8 @@ namespace PKHeX
|
|||
{0xE2, "ょ"},
|
||||
{0xE3, "ー"},
|
||||
{0xE9, "ァ"},
|
||||
{0xEF, "♂"},
|
||||
{0xF5, "♀"}
|
||||
};
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace PKHeX
|
|||
Personal = PersonalTable.RBY;
|
||||
|
||||
// Stash boxes after the save file's end.
|
||||
byte[] TempBox = new byte[SIZE_BOX];
|
||||
byte[] TempBox = new byte[SIZE_STOREDBOX];
|
||||
for (int i = 0; i < BoxCount; i++)
|
||||
{
|
||||
if (i < BoxCount / 2)
|
||||
|
@ -87,8 +87,16 @@ namespace PKHeX
|
|||
}
|
||||
}
|
||||
|
||||
File.WriteAllBytes("temp.sav", Data);
|
||||
|
||||
byte[] rawDC = new byte[0x38];
|
||||
Array.Copy(Data, Japanese ? 0x2CA7 : 0x2CF4, rawDC, 0, rawDC.Length);
|
||||
byte[] TempDaycare = new byte[PokemonList1.GetDataLength(PokemonList1.CapacityType.Single, Japanese)];
|
||||
TempDaycare[0] = rawDC[0];
|
||||
Array.Copy(rawDC, 1, TempDaycare, 2 + 1 + PKX.SIZE_1PARTY + StringLength, StringLength);
|
||||
Array.Copy(rawDC, 1 + StringLength, TempDaycare, 2 + 1 + PKX.SIZE_1PARTY, StringLength);
|
||||
Array.Copy(rawDC, 1 + 2 * StringLength, TempDaycare, 2 + 1, PKX.SIZE_1STORED);
|
||||
PokemonList1 daycareList = new PokemonList1(TempDaycare, PokemonList1.CapacityType.Single, Japanese);
|
||||
daycareList.GetBytes().CopyTo(Data, getPartyOffset(7));
|
||||
Daycare = getPartyOffset(7);
|
||||
|
||||
if (!Exportable)
|
||||
resetBoxes();
|
||||
|
@ -97,10 +105,47 @@ namespace PKHeX
|
|||
private const int SIZE_RESERVED = 0x8000; // unpacked box data
|
||||
public override byte[] Write(bool DSV)
|
||||
{
|
||||
// TODO: Implement Box Data Relocation
|
||||
for (int i = 0; i < BoxCount; i++)
|
||||
{
|
||||
PokemonList1 boxPL = new PokemonList1(Japanese ? PokemonList1.CapacityType.StoredJP : PokemonList1.CapacityType.Stored, Japanese);
|
||||
int slot = 0;
|
||||
for (int j = 0; j < boxPL.Pokemon.Length; j++)
|
||||
{
|
||||
PK1 boxPK = (PK1) getPKM(getData(getBoxOffset(i) + j*SIZE_STORED, SIZE_STORED));
|
||||
if (boxPK.Species > 0)
|
||||
boxPL[slot++] = boxPK;
|
||||
}
|
||||
if (i < BoxCount / 2)
|
||||
boxPL.GetBytes().CopyTo(Data, 0x4000 + i * SIZE_STOREDBOX);
|
||||
else
|
||||
boxPL.GetBytes().CopyTo(Data, 0x6000 + (i - BoxCount / 2) * SIZE_STOREDBOX);
|
||||
if (i == CurrentBox)
|
||||
boxPL.GetBytes().CopyTo(Data, Japanese ? 0x302D : 0x30C0);
|
||||
}
|
||||
|
||||
PokemonList1 partyPL = new PokemonList1(PokemonList1.CapacityType.Party, Japanese);
|
||||
int pSlot = 0;
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
PK1 partyPK = (PK1)getPKM(getData(getPartyOffset(i), SIZE_STORED));
|
||||
if (partyPK.Species > 0)
|
||||
partyPL[pSlot++] = partyPK;
|
||||
}
|
||||
partyPL.GetBytes().CopyTo(Data, Japanese ? 0x2ED5 : 0x2F2C);
|
||||
|
||||
// Daycare is read-only, but in case it ever becomes editable, copy it back in.
|
||||
byte[] rawDC = getData(getDaycareSlotOffset(0, 0), SIZE_STORED);
|
||||
byte[] dc = new byte[1 + 2*StringLength + PKX.SIZE_1STORED];
|
||||
dc[0] = rawDC[0];
|
||||
Array.Copy(rawDC, 2 + 1 + PKX.SIZE_1PARTY + StringLength, dc, 1, StringLength);
|
||||
Array.Copy(rawDC, 2 + 1 + PKX.SIZE_1PARTY, dc, 1 + StringLength, StringLength);
|
||||
Array.Copy(rawDC, 2 + 1, dc, 1 + 2*StringLength, PKX.SIZE_1STORED);
|
||||
dc.CopyTo(Data, Japanese ? 0x2CA7 : 0x2CF4);
|
||||
|
||||
setChecksums();
|
||||
Array.Resize(ref Data, Data.Length - SIZE_RESERVED);
|
||||
return Data;
|
||||
byte[] outData = new byte[Data.Length - SIZE_RESERVED];
|
||||
Array.Copy(Data, outData, outData.Length);
|
||||
return outData;
|
||||
}
|
||||
|
||||
|
||||
|
@ -110,7 +155,10 @@ namespace PKHeX
|
|||
public override int SIZE_STORED => Japanese ? PKX.SIZE_1JLIST : PKX.SIZE_1ULIST;
|
||||
public override int SIZE_PARTY => Japanese ? PKX.SIZE_1JLIST : PKX.SIZE_1ULIST;
|
||||
|
||||
public int SIZE_BOX => PokemonList1.GetDataLength(Japanese ? PokemonList1.CapacityType.StoredJP : PokemonList1.CapacityType.Stored, Japanese);
|
||||
public int SIZE_BOX => BoxSlotCount*SIZE_STORED;
|
||||
|
||||
public int SIZE_STOREDBOX => PokemonList1.GetDataLength(Japanese ? PokemonList1.CapacityType.StoredJP : PokemonList1.CapacityType.Stored, Japanese);
|
||||
|
||||
public override PKM BlankPKM => new PK1(null, null, Japanese);
|
||||
protected override Type PKMType => typeof(PK1);
|
||||
|
||||
|
|
|
@ -361,7 +361,7 @@ namespace PKHeX
|
|||
Console.WriteLine("");
|
||||
Edited = true;
|
||||
}
|
||||
public void setStoredSlot(PKM pkm, int offset, bool? trade = null, bool? dex = null)
|
||||
public virtual void setStoredSlot(PKM pkm, int offset, bool? trade = null, bool? dex = null)
|
||||
{
|
||||
if (pkm == null) return;
|
||||
if (pkm.GetType() != PKMType)
|
||||
|
|
Loading…
Add table
Reference in a new issue