mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-10-01 08:56:40 -05:00
Add super training block details & to block access
Use some properties in the super training editor, not gonna rewrite that even though it really needs it :)
This commit is contained in:
@@ -5,5 +5,6 @@ public interface ISaveBlock6Main : ISaveBlock6Core, IPokePuff, IOPower, ILink
|
||||
BoxLayout6 BoxLayout { get; }
|
||||
BattleBox6 BattleBoxBlock { get; }
|
||||
MysteryBlock6 MysteryBlock { get; }
|
||||
SuperTrainBlock SuperTrain { get; }
|
||||
}
|
||||
}
|
||||
@@ -86,6 +86,7 @@ public class SaveBlockAccessorAO : ISaveBlockAccessor<BlockInfo6>, ISaveBlock6Ma
|
||||
public SangoInfoBlock Sango { get; }
|
||||
public Link6 LinkBlock { get; }
|
||||
public Misc6AO Misc { get; }
|
||||
public SuperTrainBlock SuperTrain { get; }
|
||||
|
||||
public SaveBlockAccessorAO(SAV6AO sav)
|
||||
{
|
||||
@@ -103,8 +104,9 @@ public SaveBlockAccessorAO(SAV6AO sav)
|
||||
OPowerBlock = new OPower6(sav, 0x17400);
|
||||
MysteryBlock = new MysteryBlock6(sav, 0x1CC00);
|
||||
Records = new Record6(sav, 0x1F400);
|
||||
Sango = new SangoInfoBlock(sav, 0x2B600);
|
||||
SuperTrain = new SuperTrainBlock(sav, 0x20200);
|
||||
LinkBlock = new Link6(sav, 0x20E00);
|
||||
Sango = new SangoInfoBlock(sav, 0x2B600);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -92,6 +92,7 @@ public SaveBlockAccessorXY(SAV6XY sav)
|
||||
OPowerBlock = new OPower6(sav, 0x16A00);
|
||||
MysteryBlock = new MysteryBlock6(sav, 0x1BC00);
|
||||
Records = new Record6(sav, 0x1E400);
|
||||
SuperTrain = new SuperTrainBlock(sav, 0x1F200);
|
||||
LinkBlock = new Link6(sav, 0x1FE00);
|
||||
}
|
||||
|
||||
@@ -101,6 +102,7 @@ public SaveBlockAccessorXY(SAV6XY sav)
|
||||
public OPower6 OPowerBlock { get; }
|
||||
public MysteryBlock6 MysteryBlock { get; }
|
||||
public Link6 LinkBlock { get; }
|
||||
public SuperTrainBlock SuperTrain { get; }
|
||||
|
||||
public Misc6XY Misc { get; }
|
||||
public Zukan6XY Zukan { get; }
|
||||
|
||||
@@ -42,7 +42,6 @@ public abstract class SAV6 : SAV_BEEF, ITrainerStatRecord, ISaveBlock6Core
|
||||
|
||||
protected int WondercardFlags { get; set; } = int.MinValue;
|
||||
protected int JPEG { get; set; } = int.MinValue;
|
||||
public int SuperTrain { get; protected set; } = int.MinValue;
|
||||
public int MaisonStats { get; protected set; } = int.MinValue;
|
||||
public int PSS { get; protected set; } = int.MinValue;
|
||||
public int SUBE { get; protected set; } = int.MinValue;
|
||||
|
||||
@@ -49,7 +49,6 @@ private void Initialize()
|
||||
Daycare = 0x1BC00;
|
||||
BerryField = 0x1C400;
|
||||
WondercardFlags = 0x1CC00;
|
||||
SuperTrain = 0x20200;
|
||||
Contest = 0x23600;
|
||||
SecretBase = 0x23A00;
|
||||
EonTicket = 0x319B8;
|
||||
@@ -83,6 +82,7 @@ private void Initialize()
|
||||
public BoxLayout6 BoxLayout => Blocks.BoxLayout;
|
||||
public BattleBox6 BattleBoxBlock => Blocks.BattleBoxBlock;
|
||||
public MysteryBlock6 MysteryBlock => Blocks.MysteryBlock;
|
||||
public SuperTrainBlock SuperTrain => Blocks.SuperTrain;
|
||||
|
||||
public Misc6AO Misc => Blocks.Misc;
|
||||
public Zukan6AO Zukan => Blocks.Zukan;
|
||||
|
||||
@@ -45,7 +45,6 @@ private void Initialize()
|
||||
Daycare = 0x1B200;
|
||||
BerryField = 0x1B800;
|
||||
WondercardFlags = 0x1BC00;
|
||||
SuperTrain = 0x1F200;
|
||||
Box = 0x22600;
|
||||
JPEG = 0x57200;
|
||||
|
||||
@@ -76,6 +75,7 @@ private void Initialize()
|
||||
public BoxLayout6 BoxLayout => Blocks.BoxLayout;
|
||||
public BattleBox6 BattleBoxBlock => Blocks.BattleBoxBlock;
|
||||
public MysteryBlock6 MysteryBlock => Blocks.MysteryBlock;
|
||||
public SuperTrainBlock SuperTrain => Blocks.SuperTrain;
|
||||
#endregion
|
||||
|
||||
protected override void SetDex(PKM pkm) => Blocks.Zukan.SetDex(pkm);
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace PKHeX.Core
|
||||
using System;
|
||||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
public class SuperTrainBlock : SaveBlock
|
||||
{
|
||||
@@ -17,5 +19,198 @@ public class SuperTrainBlock : SaveBlock
|
||||
// 0x318 total size
|
||||
|
||||
// SS-F-G = u16 species, u8 form, u8 gender
|
||||
|
||||
private const int MAX = 48;
|
||||
|
||||
public byte[] Bytes8
|
||||
{
|
||||
get => Data.Slice(Offset + 0, 8);
|
||||
set
|
||||
{
|
||||
if (value.Length != 8)
|
||||
throw new ArgumentException(nameof(value));
|
||||
value.CopyTo(Data, Offset + 0);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the record time.
|
||||
/// </summary>
|
||||
/// <param name="index">Index of the record.</param>
|
||||
public float GetTime1(int index)
|
||||
{
|
||||
if ((uint) index >= MAX)
|
||||
throw new ArgumentException(nameof(index));
|
||||
|
||||
return BitConverter.ToSingle(Data, Offset + 0x08 + (4 * index));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the record time.
|
||||
/// </summary>
|
||||
/// <param name="index">Index of the record.</param>
|
||||
/// <param name="value">Value to set.</param>
|
||||
public void SetTime1(int index, float value = 0)
|
||||
{
|
||||
if ((uint)index >= MAX)
|
||||
throw new ArgumentException(nameof(index));
|
||||
|
||||
BitConverter.GetBytes(value).CopyTo(Data, Offset + 0x08 + (4 * index));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the record time.
|
||||
/// </summary>
|
||||
/// <param name="index">Index of the record.</param>
|
||||
public float GetTime2(int index)
|
||||
{
|
||||
if ((uint)index >= MAX)
|
||||
throw new ArgumentException(nameof(index));
|
||||
|
||||
return BitConverter.ToSingle(Data, Offset + 0xC8 + (4 * index));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the record time.
|
||||
/// </summary>
|
||||
/// <param name="index">Index of the record.</param>
|
||||
/// <param name="value">Value to set.</param>
|
||||
public void SetTime2(int index, float value = 0)
|
||||
{
|
||||
if ((uint)index >= MAX)
|
||||
throw new ArgumentException(nameof(index));
|
||||
|
||||
BitConverter.GetBytes(value).CopyTo(Data, Offset + 0xC8 + (4 * index));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an object which will edit the record directly from data.
|
||||
/// </summary>
|
||||
/// <param name="index">Index of the record.</param>
|
||||
/// <returns>Object that will edit the record data if modified.</returns>
|
||||
public SuperTrainingSpeciesRecord GetHolder1(int index)
|
||||
{
|
||||
if ((uint)index >= MAX)
|
||||
throw new ArgumentException(nameof(index));
|
||||
|
||||
return new SuperTrainingSpeciesRecord(Data, Offset + 0x188 + (4 * index));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an object which will edit the record directly from data.
|
||||
/// </summary>
|
||||
/// <param name="index">Index of the record.</param>
|
||||
/// <returns>Object that will edit the record data if modified.</returns>
|
||||
public SuperTrainingSpeciesRecord GetHolder2(int index)
|
||||
{
|
||||
if ((uint)index >= MAX)
|
||||
throw new ArgumentException(nameof(index));
|
||||
|
||||
return new SuperTrainingSpeciesRecord(Data, Offset + 0x248 + (4 * index));
|
||||
}
|
||||
|
||||
public byte[] Bags
|
||||
{
|
||||
get => Data.Slice(Offset + 0x308, 12);
|
||||
set
|
||||
{
|
||||
if (value.Length != 12)
|
||||
throw new ArgumentException(nameof(value));
|
||||
value.CopyTo(Data, Offset + 0x308);
|
||||
}
|
||||
}
|
||||
|
||||
public byte GetBag(int index)
|
||||
{
|
||||
if ((uint)index >= 12)
|
||||
throw new ArgumentException(nameof(index));
|
||||
return Data[Offset + 0x308 + index];
|
||||
}
|
||||
|
||||
public void SetBag(int index, byte value)
|
||||
{
|
||||
if ((uint)index >= 12)
|
||||
throw new ArgumentException(nameof(index));
|
||||
Data[Offset + 0x308 + index] = value;
|
||||
}
|
||||
|
||||
public void ClearBag(int index) => SetBag(index, 0);
|
||||
|
||||
public uint EndValue
|
||||
{
|
||||
get => BitConverter.ToUInt32(Data, Offset + 0x314);
|
||||
set => BitConverter.GetBytes(value).CopyTo(Data, Offset + 0x314);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears all data for the record.
|
||||
/// </summary>
|
||||
/// <param name="index">Index of the record.</param>
|
||||
public void ClearRecord1(int index)
|
||||
{
|
||||
if ((uint)index >= MAX)
|
||||
throw new ArgumentException(nameof(index));
|
||||
|
||||
SetTime1(index, 0f);
|
||||
GetHolder1(index).Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears all data for the record.
|
||||
/// </summary>
|
||||
/// <param name="index">Index of the record.</param>
|
||||
public void ClearRecord2(int index)
|
||||
{
|
||||
if ((uint)index >= MAX)
|
||||
throw new ArgumentException(nameof(index));
|
||||
|
||||
SetTime2(index, 0f);
|
||||
GetHolder2(index).Clear();
|
||||
}
|
||||
}
|
||||
|
||||
public class SuperTrainingSpeciesRecord
|
||||
{
|
||||
private readonly byte[] Data;
|
||||
private readonly int Offset;
|
||||
|
||||
public SuperTrainingSpeciesRecord(byte[] data, int offset)
|
||||
{
|
||||
Data = data;
|
||||
Offset = offset;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="PKM.Species"/> of the Record Holder.
|
||||
/// </summary>
|
||||
public ushort Species
|
||||
{
|
||||
get => BitConverter.ToUInt16(Data, Offset + 0);
|
||||
set => BitConverter.GetBytes(value).CopyTo(Data, Offset + 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="PKM.AltForm"/> of the Record Holder.
|
||||
/// </summary>
|
||||
public byte AltForm
|
||||
{
|
||||
get => Data[Offset + 2];
|
||||
set => Data[Offset + 2] = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="PKM.Gender"/> of the Record Holder.
|
||||
/// </summary>
|
||||
/// <seealso cref="PKHeX.Core.Gender"/>
|
||||
public byte Gender
|
||||
{
|
||||
get => Data[Offset + 3];
|
||||
set => Data[Offset + 3] = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Wipes the record holder's pkm-related data.
|
||||
/// </summary>
|
||||
public void Clear() => Species = AltForm = Gender = 0;
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ public partial class SAV_SuperTrain : Form
|
||||
{
|
||||
private readonly SaveFile Origin;
|
||||
private readonly SAV6 SAV;
|
||||
private readonly SuperTrainBlock STB;
|
||||
|
||||
public SAV_SuperTrain(SaveFile sav)
|
||||
{
|
||||
@@ -17,9 +18,11 @@ public SAV_SuperTrain(SaveFile sav)
|
||||
SAV = (SAV6)(Origin = sav).Clone();
|
||||
trba = GameInfo.Strings.trainingbags;
|
||||
trba[0] = "---";
|
||||
offsetTime = SAV.SuperTrain + 0x08;
|
||||
offsetSpec = SAV.SuperTrain + 0x188;
|
||||
offsetVal = SAV.SuperTrain + 0x18A;
|
||||
STB = ((ISaveBlock6Main) SAV).SuperTrain;
|
||||
var ofs = STB.Offset;
|
||||
offsetTime = ofs + 0x08;
|
||||
offsetSpec = ofs + 0x188;
|
||||
offsetVal = ofs + 0x18A;
|
||||
string[] stages = GameInfo.Strings.trainingstage;
|
||||
listBox1.Items.Clear();
|
||||
for (int i = 0; i < 32; i++)
|
||||
@@ -81,11 +84,10 @@ private void FillTrainingBags()
|
||||
dataGridView1.Columns.Add(dgvBag);
|
||||
|
||||
dataGridView1.Rows.Add(12);
|
||||
int offset = SAV.SuperTrain + 0x308;
|
||||
for (int i = 0; i < 12; i++)
|
||||
{
|
||||
dataGridView1.Rows[i].Cells[0].Value = (i + 1).ToString();
|
||||
dataGridView1.Rows[i].Cells[1].Value = trba[SAV.Data[offset + i]];
|
||||
dataGridView1.Rows[i].Cells[1].Value = trba[STB.GetBag(i)];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +136,7 @@ private void B_Save_Click(object sender, EventArgs e)
|
||||
if (float.TryParse(TB_Time2.Text, out var t2))
|
||||
SAV.SetData(BitConverter.GetBytes(t2), offsetTime + (4 * 31));
|
||||
SAV.SetData(BitConverter.GetBytes((ushort)WinFormsUtil.GetIndex(CB_S2)), offsetSpec + (4 * 30));
|
||||
bagarray.CopyTo(SAV.Data, SAV.SuperTrain + 0x308);
|
||||
STB.Bags = bagarray;
|
||||
Origin.CopyChangesFrom(SAV);
|
||||
Close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user