Heavy refactoring

Remove numerous inter-form dependencies, remove hard-coded offsets,
update a few spots to use better programming practices.

Should increase the readability of PKHeX's source code.
This commit is contained in:
Kurt 2015-09-20 20:34:09 -07:00
parent d6bbb57d7b
commit d4ea56cfd6
28 changed files with 1115 additions and 1367 deletions

View file

@ -11,19 +11,15 @@ namespace PKHeX
{
byte[] codedata = new byte[232];
byte[] newdata = new byte[232];
PKX.Structures.SaveGame SaveGame = new PKX.Structures.SaveGame(null);
Form1 m_parent;
byte[] tabdata;
public CodeGenerator(Form1 frm1, byte[] formdata)
public CodeGenerator(byte[] formdata)
{
m_parent = frm1;
tabdata = formdata;
InitializeComponent();
CenterToParent();
RTB_Code.Clear();
TB_Write.Clear();
SaveGame = m_parent.SaveGame;
CB_Box.Items.Clear();
for (int i = 1; i <= 31; i++)
CB_Box.Items.Add(i.ToString());
@ -49,8 +45,8 @@ namespace PKHeX
else if (CB_Source.SelectedIndex == 1)
{
newdata = new byte[0xE8];
Array.Copy(m_parent.savefile,
SaveGame.Box // Box Offset
Array.Copy(Main.savefile,
Main.SaveGame.Box // Box Offset
+ CB_Box.SelectedIndex * (232 * 30) // Box Shift
+ CB_Slot.SelectedIndex * 232, // Slot Shift
newdata, 0, 0xE8);
@ -65,9 +61,9 @@ namespace PKHeX
// Wondercard
newdata = new byte[0x108];
// Wondercard #
int wcn = CB_Slot.SelectedIndex;
int index = CB_Slot.SelectedIndex;
// copy from save, the chosen wondercard offset, to new data
Array.Copy(m_parent.savefile, SaveGame.Wondercard + wcn * 0x108 + 0x100, newdata, 0, 0x108);
Array.Copy(Main.savefile, Main.SaveGame.WondercardData + index * 0x108, newdata, 0, 0x108);
byte[] zerodata = new byte[0x108];
if (!newdata.SequenceEqual(zerodata)) return true;
@ -76,52 +72,6 @@ namespace PKHeX
}
return true;
}
private void changeDataSource(object sender, EventArgs e)
{
int sourceindex = CB_Source.SelectedIndex;
B_Add.Enabled = true;
if (sourceindex == 0)
{
// Hide Box/Etc
CB_Box.Visible = false;
L_Box.Visible = false;
CB_Slot.Visible = false;
L_Slot.Visible = false;
TB_Write.Text = (0x27A00 - 0x5400).ToString("X8"); // Box 1, Slot 1
}
else if (sourceindex == 1)
{
CB_Box.Visible = L_Box.Visible = true;
CB_Slot.Visible = L_Slot.Visible = true;
L_Slot.Text = "Slot:";
CB_Slot.Items.Clear();
for (int i = 1; i <= 30; i++)
CB_Slot.Items.Add(i.ToString());
CB_Slot.SelectedIndex = 0;
TB_Write.Text = (0x27A00 - 0x5400).ToString("X8"); // Box 1, Slot 1
}
else if (sourceindex == 2)
{
CB_Box.Visible = L_Box.Visible = false;
CB_Slot.Visible = L_Slot.Visible = true;
L_Slot.Text = "Card:";
// Set up cards
CB_Slot.Items.Clear();
for (int i = 1; i <= 24; i++)
CB_Slot.Items.Add(i.ToString());
CB_Slot.SelectedIndex = 0;
TB_Write.Text = (0x22000 - 0x5400).ToString("X8"); // WC Slot 1
}
}
private void B_Add_Click(object sender, EventArgs e)
{
@ -236,19 +186,10 @@ namespace PKHeX
{
string result = "";
RTB_Code.Clear();
byte[] cybersav = m_parent.cyberSAV;
byte[] editedsav = m_parent.savefile;
byte[] newcyber = new byte[m_parent.cyberSAV.Length];
Array.Copy(editedsav, 0x5400, newcyber, 0, newcyber.Length);
byte[] cybersav = Main.originalSAV;
byte[] newcyber = Main.savefile;
int boxoffset = 0x22600;
if (m_parent.savegame_oras) boxoffset = 0x33000;
if (!m_parent.cybergadget)
{
Array.Copy(editedsav, m_parent.savindex * 0x7F000 + 0x5400,
newcyber, 0, newcyber.Length);
}
int boxoffset = Main.SaveGame.Box;
int lines = 0; // 65400
for (int i = 0; i < newcyber.Length - 0x200; i += 4)

View file

@ -323,23 +323,23 @@ namespace PKHeX
{
if (gameorigin < 13 && gameorigin > 6 && eggmet)
{
if (locval < 2000) return Form1.metHGSS_00000[locval];
if (locval < 3000) return Form1.metHGSS_02000[locval % 2000];
return Form1.metHGSS_03000[locval % 3000];
if (locval < 2000) return Main.metHGSS_00000[locval];
if (locval < 3000) return Main.metHGSS_02000[locval % 2000];
return Main.metHGSS_03000[locval % 3000];
}
if (gameorigin < 24)
{
if (locval < 30000) return Form1.metBW2_00000[locval];
if (locval < 40000) return Form1.metBW2_30000[locval % 10000 - 1];
if (locval < 60000) return Form1.metBW2_40000[locval % 10000 - 1];
return Form1.metBW2_60000[locval % 10000 - 1];
if (locval < 30000) return Main.metBW2_00000[locval];
if (locval < 40000) return Main.metBW2_30000[locval % 10000 - 1];
if (locval < 60000) return Main.metBW2_40000[locval % 10000 - 1];
return Main.metBW2_60000[locval % 10000 - 1];
}
if (gameorigin > 23)
{
if (locval < 30000) return Form1.metXY_00000[locval];
if (locval < 40000) return Form1.metXY_30000[locval % 10000 - 1];
if (locval < 60000) return Form1.metXY_40000[locval % 10000 - 1];
return Form1.metXY_60000[locval % 10000 - 1];
if (locval < 30000) return Main.metXY_00000[locval];
if (locval < 40000) return Main.metXY_30000[locval % 10000 - 1];
if (locval < 60000) return Main.metXY_40000[locval % 10000 - 1];
return Main.metXY_60000[locval % 10000 - 1];
}
return null; // Shouldn't happen.
}
@ -745,7 +745,7 @@ namespace PKHeX
motgender = (pkx[0xDD]) >> 7;
mencountertype = pkx[0xDE];
mgamevers = pkx[0xDF];
string[] data = getCountryRegionText(pkx[0xE0], pkx[0xE1], Form1.curlanguage);
string[] data = getCountryRegionText(pkx[0xE0], pkx[0xE1], Main.curlanguage);
mcountryID = data[0x0];
mregionID = data[0x1];
mdsregID = pkx[0xE2];
@ -774,26 +774,26 @@ namespace PKHeX
}
try
{
mSpeciesName = Form1.specieslist[mspecies];
mhelditemN = Form1.itemlist[mhelditem];
mNatureName = Form1.natures[mnature];
mHPName = Form1.types[mhptype];
mAbilityName = Form1.abilitylist[mability];
mMove1N = Form1.movelist[mmove1];
mMove2N = Form1.movelist[mmove2];
mMove3N = Form1.movelist[mmove3];
mMove4N = Form1.movelist[mmove4];
mRMove1N = Form1.movelist[meggmove1];
mRMove2N = Form1.movelist[meggmove2];
mRMove3N = Form1.movelist[meggmove3];
mRMove4N = Form1.movelist[meggmove4];
mSpeciesName = Main.specieslist[mspecies];
mhelditemN = Main.itemlist[mhelditem];
mNatureName = Main.natures[mnature];
mHPName = Main.types[mhptype];
mAbilityName = Main.abilitylist[mability];
mMove1N = Main.movelist[mmove1];
mMove2N = Main.movelist[mmove2];
mMove3N = Main.movelist[mmove3];
mMove4N = Main.movelist[mmove4];
mRMove1N = Main.movelist[meggmove1];
mRMove2N = Main.movelist[meggmove2];
mRMove3N = Main.movelist[meggmove3];
mRMove4N = Main.movelist[meggmove4];
mMetLocN = getLocation(false, mgamevers, mmetloc);
mEggLocN = getLocation(true, mgamevers, meggloc);
mLevel = getLevel(mspecies, ref mexp);
mGameN = Form1.gamelist[mgamevers];
mBallN = Form1.balllist[mball];
motlangN = Form1.gamelanguages[motlang] ?? String.Format("UNK {0}", motlang);
mdsregIDN = Form1.consoleregions[mdsregID] ?? String.Format("UNK {0}", mdsregID);
mGameN = Main.gamelist[mgamevers];
mBallN = Main.balllist[mball];
motlangN = Main.gamelanguages[motlang] ?? String.Format("UNK {0}", motlang);
mdsregIDN = Main.consoleregions[mdsregID] ?? String.Format("UNK {0}", mdsregID);
}
catch { return; }
}
@ -942,85 +942,138 @@ namespace PKHeX
}
public struct SaveGame
{
public int Box, TrainerCard, Party, BattleBox, GTS, Daycare, Fused, SUBE, Puff, Item, Trainer1, Trainer2, PCLayout, Wondercard, BerryField, OPower, EventFlag, PokeDex, HoF, PSS, JPEG;
public class Inventory
{
public int HeldItem, KeyItem, Medicine, TMHM, Berry;
public Inventory(string GameID, int Offset)
{
switch (GameID)
{
case "XY":
HeldItem = Offset + 0;
KeyItem = Offset + 0x640;
TMHM = Offset + 0x7C0;
Medicine = Offset + 0x968;
Berry = Offset + 0xA68;
break;
case "ORAS":
HeldItem = Offset + 0;
KeyItem = Offset + 0x640;
TMHM = Offset + 0x7C0;
Medicine = Offset + 0x970;
Berry = Offset + 0xA70;
break;
default:
HeldItem = KeyItem = TMHM = Medicine = Berry = 0;
break;
}
}
}
public int Box, TrainerCard, Party, BattleBox, GTS, Daycare, EonTicket,
Fused, SUBE, Puff, Item, Trainer1, Trainer2, SuperTrain, PSSStats, MaisonStats, Vivillon, SecretBase,
PCLayout, PCBackgrounds, PCFlags, WondercardFlags, WondercardData, BerryField, OPower, EventConst, EventFlag, EventAsh,
PokeDex, PokeDexLanguageFlags, Spinda, EncounterCount, HoF, PSS, JPEG;
public Inventory Items;
public string Name;
public int[] DaycareSlot;
public bool ORAS;
public SaveGame(string GameID)
{
switch (GameID)
{
case "XY":
Name = "XY";
Box = 0x27A00;
TrainerCard = 0x19400;
Party = 0x19600;
BattleBox = 0x09E00;
Daycare = 0x20600;
GTS = 0x1CC00;
Fused = 0x1B400;
SUBE = 0x22C90;
Puff = 0x5400;
Item = 0x5800;
Trainer1 = 0x6800;
Trainer2 = 0x9600;
PCLayout = 0x9800;
Wondercard = 0x21000;
BerryField = 0x20C00;
OPower = 0x1BE00;
EventFlag = 0x19E00;
PokeDex = 0x1A400;
HoF = 0x1E800;
JPEG = 0x5C600;
PSS = 0x0A400;
ORAS = false;
Box = 0x22600;
TrainerCard = 0x14000;
Party = 0x14200;
BattleBox = 0x04A00;
Daycare = 0x1B200;
GTS = 0x17800;
Fused = 0x16000;
SUBE = 0x1D890;
Puff = 0x00000;
Item = 0x00400;
Items = new Inventory(Name, Item);
Trainer1 = 0x1400;
Trainer2 = 0x4200;
PCLayout = 0x4400;
PCBackgrounds = PCLayout + 0x41E;
PCFlags = PCLayout + 0x43D;
WondercardFlags = 0x1BC00;
WondercardData = WondercardFlags + 0x100;
BerryField = 0x1B800;
OPower = 0x16A00;
EventConst = 0x14A00;
EventAsh = -1;
EventFlag = EventConst + 0x2FC;
PokeDex = 0x15000;
PokeDexLanguageFlags = PokeDex + 0x3C8;
Spinda = PokeDex + 0x648;
EncounterCount = -1;
HoF = 0x19400;
SuperTrain = 0x1F200;
JPEG = 0x57200;
MaisonStats = 0x1B1C0;
PSS = 0x05000;
PSSStats = 0x1E400;
Vivillon = 0x4250;
SecretBase = -1;
EonTicket = -1;
break;
case "ORAS":
Name = "ORAS";
Box = 0x38400; // Confirmed
TrainerCard = 0x19400; // Confirmed
Party = 0x19600; // Confirmed
BattleBox = 0x09E00;// Confirmed
Daycare = 0x21000; // Confirmed (thanks Rei)
GTS = 0x1D600; // Confirmed
Fused = 0x1BE00; // Confirmed
SUBE = 0x22C90; // ****not in use, not updating?****
Puff = 0x5400; // Confirmed
Item = 0x5800; // Confirmed
Trainer1 = 0x6800; // Confirmed
Trainer2 = 0x9600; // Confirmed
PCLayout = 0x9800; // Confirmed
Wondercard = 0x22000; // Confirmed
BerryField = 0x20C00; // ****changed****
OPower = 0x1BE00;
EventFlag = 0x19E00; // Confirmed
PokeDex = 0x1A400;
HoF = 0x1F200; // Confirmed
JPEG = 0x6D000; // Confirmed
PSS = 0x0A400; // Confirmed (thanks Rei)
ORAS = true;
Box = 0x33000; // Confirmed
TrainerCard = 0x14000; // Confirmed
Party = 0x14200; // Confirmed
BattleBox = 0x04A00;// Confirmed
Daycare = 0x1BC00; // Confirmed (thanks Rei)
GTS = 0x18200; // Confirmed
Fused = 0x16A00; // Confirmed
SUBE = 0x1D890; // ****not in use, not updating?****
Puff = 0x00000; // Confirmed
Item = 0x00400; // Confirmed
Items = new Inventory(Name, Item);
Trainer1 = 0x01400; // Confirmed
Trainer2 = 0x04200; // Confirmed
PCLayout = 0x04400; // Confirmed
PCBackgrounds = PCLayout + 0x41E;
PCFlags = PCLayout + 0x43D;
WondercardFlags = 0x1CC00; // Confirmed
WondercardData = WondercardFlags + 0x100;
BerryField = 0x1C400; // ****changed****
OPower = 0x17400; // ****changed****
EventConst = 0x14A00;
EventAsh = EventConst + 0x78;
EventFlag = 0x14A00; // Confirmed
PokeDex = 0x15000;
Spinda = PokeDex + 0x680;
EncounterCount = PokeDex + 0x686;
PokeDexLanguageFlags = PokeDex + 0x400;
HoF = 0x19E00; // Confirmed
SuperTrain = 0x20200;
JPEG = 0x67C00; // Confirmed
MaisonStats = 0x1BBC0;
PSS = 0x05000; // Confirmed (thanks Rei)
PSSStats = 0x1F400;
Vivillon = 0x4244;
SecretBase = 0x23A00;
EonTicket = 0x319B8;
break;
default:
Box = TrainerCard = Party = BattleBox = GTS = Daycare =
Fused = SUBE = Puff = Item = Trainer1 = Trainer2 = SecretBase = EonTicket =
PCLayout = PCBackgrounds = PCFlags = WondercardFlags = WondercardData = BerryField = OPower = SuperTrain = MaisonStats = PSSStats = Vivillon =
EventConst = EventAsh = EventFlag = PokeDex = PokeDexLanguageFlags = Spinda = EncounterCount = HoF = PSS = JPEG = 0;
Name = "Unknown";
Box = 0x27A00;
TrainerCard = 0x19400;
Party = 0x19600;
BattleBox = 0x09E00;
Daycare = 0x20600;
GTS = 0x1CC00;
Fused = 0x1B400;
SUBE = 0x22C90;
Puff = 0x5400;
Item = 0x5800;
Trainer1 = 0x6800;
Trainer2 = 0x9600;
PCLayout = 0x9800;
Wondercard = 0x21000;
BerryField = 0x20C00;
OPower = 0x1BE00;
EventFlag = 0x19E00;
PokeDex = 0x1A400;
HoF = 0x1E800;
JPEG = 0x5C600;
PSS = 0x0A400;
ORAS = false;
Items = new Inventory(Name, Item);
break;
}
DaycareSlot = new[] { Daycare, Daycare + 0x1F0 };
}
}
}
@ -1056,7 +1109,7 @@ namespace PKHeX
}
// SAV Manipulation
internal static int detectSAVIndex(byte[] data, ref int savindex)
internal static int detectSAVIndex(byte[] data, out int savindex)
{
SHA256 mySHA256 = SHA256.Create();
{
@ -1106,38 +1159,49 @@ namespace PKHeX
}
return crc;
}
internal static string verifyG6CHK(byte[] savefile, bool oras, int savegame, ref int[] ctr)
internal static string verifyG6CHK(byte[] savefile)
{
string rv = "";
int invalid = 0;
// Prepare Region Loops
int[] start = (oras)
? new [] { 0x05400, 0x05800, 0x06400, 0x06600, 0x06800, 0x06A00, 0x06C00, 0x06E00, 0x07000, 0x07200, 0x07400, 0x09600, 0x09800, 0x09E00, 0x0A400, 0x0F400, 0x14400, 0x19400, 0x19600, 0x19E00, 0x1A400, 0x1B600, 0x1BE00, 0x1C000, 0x1C200, 0x1C800, 0x1CA00, 0x1CE00, 0x1D600, 0x1D800, 0x1DA00, 0x1DC00, 0x1DE00, 0x1E000, 0x1E800, 0x1EE00, 0x1F200, 0x20E00, 0x21000, 0x21400, 0x21800, 0x22000, 0x23C00, 0x24000, 0x24800, 0x24C00, 0x25600, 0x25A00, 0x26200, 0x27000, 0x27200, 0x27400, 0x28200, 0x28A00, 0x28E00, 0x30A00, 0x38400, 0x6D000, }
: new [] { 0x05400, 0x05800, 0x06400, 0x06600, 0x06800, 0x06A00, 0x06C00, 0x06E00, 0x07000, 0x07200, 0x07400, 0x09600, 0x09800, 0x09E00, 0x0A400, 0x0F400, 0x14400, 0x19400, 0x19600, 0x19E00, 0x1A400, 0x1AC00, 0x1B400, 0x1B600, 0x1B800, 0x1BE00, 0x1C000, 0x1C400, 0x1CC00, 0x1CE00, 0x1D000, 0x1D200, 0x1D400, 0x1D600, 0x1DE00, 0x1E400, 0x1E800, 0x20400, 0x20600, 0x20800, 0x20C00, 0x21000, 0x22C00, 0x23000, 0x23800, 0x23C00, 0x24600, 0x24A00, 0x25200, 0x26000, 0x26200, 0x26400, 0x27200, 0x27A00, 0x5C600, };
int[] length = (oras)
? new [] { 0x000002C8, 0x00000B90, 0x0000002C, 0x00000038, 0x00000150, 0x00000004, 0x00000008, 0x000001C0, 0x000000BE, 0x00000024, 0x00002100, 0x00000130, 0x00000440, 0x00000574, 0x00004E28, 0x00004E28, 0x00004E28, 0x00000170, 0x0000061C, 0x00000504, 0x000011CC, 0x00000644, 0x00000104, 0x00000004, 0x00000420, 0x00000064, 0x000003F0, 0x0000070C, 0x00000180, 0x00000004, 0x0000000C, 0x00000048, 0x00000054, 0x00000644, 0x000005C8, 0x000002F8, 0x00001B40, 0x000001F4, 0x000003E0, 0x00000216, 0x00000640, 0x00001A90, 0x00000400, 0x00000618, 0x0000025C, 0x00000834, 0x00000318, 0x000007D0, 0x00000C48, 0x00000078, 0x00000200, 0x00000C84, 0x00000628, 0x00000400, 0x00007AD0, 0x000078B0, 0x00034AD0, 0x0000E058, }
: new [] { 0x000002C8, 0x00000B88, 0x0000002C, 0x00000038, 0x00000150, 0x00000004, 0x00000008, 0x000001C0, 0x000000BE, 0x00000024, 0x00002100, 0x00000140, 0x00000440, 0x00000574, 0x00004E28, 0x00004E28, 0x00004E28, 0x00000170, 0x0000061C, 0x00000504, 0x000006A0, 0x00000644, 0x00000104, 0x00000004, 0x00000420, 0x00000064, 0x000003F0, 0x0000070C, 0x00000180, 0x00000004, 0x0000000C, 0x00000048, 0x00000054, 0x00000644, 0x000005C8, 0x000002F8, 0x00001B40, 0x000001F4, 0x000001F0, 0x00000216, 0x00000390, 0x00001A90, 0x00000308, 0x00000618, 0x0000025C, 0x00000834, 0x00000318, 0x000007D0, 0x00000C48, 0x00000078, 0x00000200, 0x00000C84, 0x00000628, 0x00034AD0, 0x0000E058, };
int csoff = oras ? 0x7B21A : 0x6A81A;
if (savegame == 1) // Offset by 0x7F000
// Dynamic handling of checksums regardless of save size.
int verificationOffset = savefile.Length - 0x200 + 0x10;
if (BitConverter.ToUInt32(savefile, verificationOffset) != 0x42454546)
verificationOffset -= 0x200; // No savegames have more than 0x3D blocks, maybe in the future?
int count = (savefile.Length - verificationOffset - 0x8) / 8;
verificationOffset += 4;
int[] Lengths = new int[count];
ushort[] BlockIDs = new ushort[count];
ushort[] Checksums = new ushort[count];
int[] Start = new int[count];
int CurrentPosition = 0;
for (int i = 0; i < count; i++)
{
start = Array.ConvertAll(start, x => x + 0x7F000);
csoff += 0x7F000;
Start[i] = CurrentPosition;
Lengths[i] = BitConverter.ToInt32(savefile, verificationOffset + 0 + 8 * i);
BlockIDs[i] = BitConverter.ToUInt16(savefile, verificationOffset + 4 + 8 * i);
Checksums[i] = BitConverter.ToUInt16(savefile, verificationOffset + 6 + 8 * i);
CurrentPosition += (Lengths[i] % 0x200 == 0) ? Lengths[i] : (0x200 - Lengths[i] % 0x200 + Lengths[i]);
if ((BlockIDs[i] != 0) || i == 0) continue;
count = i;
break;
}
// Calculate checksums and spit out result.
for (int i = 0; i < length.Length; i++)
// Apply checksums
for (int i = 0; i < count; i++)
{
byte[] array = savefile.Skip(start[i]).Take(length[i]).ToArray();
ushort checksum = ccitt16(array);
ushort actualsum = BitConverter.ToUInt16(savefile, csoff + i*0x8);
if (checksum == actualsum) continue;
ushort chk = ccitt16(savefile.Skip(Start[i]).Take(Lengths[i]).ToArray());
ushort old = BitConverter.ToUInt16(savefile, verificationOffset + 6 + i * 8);
if (chk == old) continue;
invalid++;
rv += String.Format("Invalid: {0} @ Region {1}", i.ToString("X2"), start[i].ToString("X5") + Environment.NewLine);
rv += String.Format("Invalid: {0} @ Region {1}", i.ToString("X2"), Start[i].ToString("X5") + Environment.NewLine);
}
// Return Outputs
rv += String.Format("SAV{2}: {0}/{1}", (start.Length - invalid), start.Length + Environment.NewLine, savegame + 1);
ctr[0] += invalid;
ctr[1] += length.Length - 1;
rv += String.Format("SAV: {0}/{1}", (count - invalid), count + Environment.NewLine);
return rv;
}
internal static string verifyG6SHA(byte[] savefile, bool oras)
@ -1350,28 +1414,40 @@ namespace PKHeX
}
return rv;
}
internal static byte[] writeG6CHK(byte[] savefile, bool oras, int savegame)
internal static void writeG6CHK(byte[] savefile)
{
// Prepare Region Loops
int[] start = (oras)
? new[] { 0x05400, 0x05800, 0x06400, 0x06600, 0x06800, 0x06A00, 0x06C00, 0x06E00, 0x07000, 0x07200, 0x07400, 0x09600, 0x09800, 0x09E00, 0x0A400, 0x0F400, 0x14400, 0x19400, 0x19600, 0x19E00, 0x1A400, 0x1B600, 0x1BE00, 0x1C000, 0x1C200, 0x1C800, 0x1CA00, 0x1CE00, 0x1D600, 0x1D800, 0x1DA00, 0x1DC00, 0x1DE00, 0x1E000, 0x1E800, 0x1EE00, 0x1F200, 0x20E00, 0x21000, 0x21400, 0x21800, 0x22000, 0x23C00, 0x24000, 0x24800, 0x24C00, 0x25600, 0x25A00, 0x26200, 0x27000, 0x27200, 0x27400, 0x28200, 0x28A00, 0x28E00, 0x30A00, 0x38400, 0x6D000, }
: new[] { 0x05400, 0x05800, 0x06400, 0x06600, 0x06800, 0x06A00, 0x06C00, 0x06E00, 0x07000, 0x07200, 0x07400, 0x09600, 0x09800, 0x09E00, 0x0A400, 0x0F400, 0x14400, 0x19400, 0x19600, 0x19E00, 0x1A400, 0x1AC00, 0x1B400, 0x1B600, 0x1B800, 0x1BE00, 0x1C000, 0x1C400, 0x1CC00, 0x1CE00, 0x1D000, 0x1D200, 0x1D400, 0x1D600, 0x1DE00, 0x1E400, 0x1E800, 0x20400, 0x20600, 0x20800, 0x20C00, 0x21000, 0x22C00, 0x23000, 0x23800, 0x23C00, 0x24600, 0x24A00, 0x25200, 0x26000, 0x26200, 0x26400, 0x27200, 0x27A00, 0x5C600, };
int[] length = (oras)
? new[] { 0x000002C8, 0x00000B90, 0x0000002C, 0x00000038, 0x00000150, 0x00000004, 0x00000008, 0x000001C0, 0x000000BE, 0x00000024, 0x00002100, 0x00000130, 0x00000440, 0x00000574, 0x00004E28, 0x00004E28, 0x00004E28, 0x00000170, 0x0000061C, 0x00000504, 0x000011CC, 0x00000644, 0x00000104, 0x00000004, 0x00000420, 0x00000064, 0x000003F0, 0x0000070C, 0x00000180, 0x00000004, 0x0000000C, 0x00000048, 0x00000054, 0x00000644, 0x000005C8, 0x000002F8, 0x00001B40, 0x000001F4, 0x000003E0, 0x00000216, 0x00000640, 0x00001A90, 0x00000400, 0x00000618, 0x0000025C, 0x00000834, 0x00000318, 0x000007D0, 0x00000C48, 0x00000078, 0x00000200, 0x00000C84, 0x00000628, 0x00000400, 0x00007AD0, 0x000078B0, 0x00034AD0, 0x0000E058, }
: new[] { 0x000002C8, 0x00000B88, 0x0000002C, 0x00000038, 0x00000150, 0x00000004, 0x00000008, 0x000001C0, 0x000000BE, 0x00000024, 0x00002100, 0x00000140, 0x00000440, 0x00000574, 0x00004E28, 0x00004E28, 0x00004E28, 0x00000170, 0x0000061C, 0x00000504, 0x000006A0, 0x00000644, 0x00000104, 0x00000004, 0x00000420, 0x00000064, 0x000003F0, 0x0000070C, 0x00000180, 0x00000004, 0x0000000C, 0x00000048, 0x00000054, 0x00000644, 0x000005C8, 0x000002F8, 0x00001B40, 0x000001F4, 0x000001F0, 0x00000216, 0x00000390, 0x00001A90, 0x00000308, 0x00000618, 0x0000025C, 0x00000834, 0x00000318, 0x000007D0, 0x00000C48, 0x00000078, 0x00000200, 0x00000C84, 0x00000628, 0x00034AD0, 0x0000E058, };
int csoff = oras ? 0x7B21A : 0x6A81A;
if (savegame == 1) // Offset by 0x7F000
// Dynamic handling of checksums regardless of save size.
int verificationOffset = savefile.Length - 0x200 + 0x10;
if (BitConverter.ToUInt32(savefile, verificationOffset) != 0x42454546)
verificationOffset -= 0x200; // No savegames have more than 0x3D blocks, maybe in the future?
int count = (savefile.Length - verificationOffset - 0x8) / 8;
verificationOffset += 4;
int[] Lengths = new int[count];
ushort[] BlockIDs = new ushort[count];
ushort[] Checksums = new ushort[count];
int[] Start = new int[count];
int CurrentPosition = 0;
for (int i = 0; i < count; i++)
{
start = Array.ConvertAll(start, x => x + 0x7F000);
csoff += 0x7F000;
Start[i] = CurrentPosition;
Lengths[i] = BitConverter.ToInt32(savefile, verificationOffset + 0 + 8 * i);
BlockIDs[i] = BitConverter.ToUInt16(savefile, verificationOffset + 4 + 8 * i);
Checksums[i] = BitConverter.ToUInt16(savefile, verificationOffset + 6 + 8 * i);
CurrentPosition += (Lengths[i]%0x200 == 0) ? Lengths[i] : (0x200 - Lengths[i]%0x200 + Lengths[i]);
if ((BlockIDs[i] != 0) || i == 0) continue;
count = i;
break;
}
// Calculate checksums and write back to save file.
for (int i = 0; i < length.Length; i++)
// Apply checksums
for (int i = 0; i < count; i++)
{
byte[] array = savefile.Skip(start[i]).Take(length[i]).ToArray();
Array.Copy(BitConverter.GetBytes(ccitt16(array)), 0, savefile, csoff + i * 8, 2);
byte[] array = savefile.Skip(Start[i]).Take(Lengths[i]).ToArray();
Array.Copy(BitConverter.GetBytes(ccitt16(array)), 0, savefile, verificationOffset + 6 + i * 8, 2);
}
return savefile;
}
internal static byte[] writeG6SHA(byte[] savefile, bool oras, int savegame)
{

View file

@ -9,7 +9,7 @@ namespace PKHeX
public QR(Image qr, Image pkm, string top, string bottom, string left, string right)
{
InitializeComponent();
Font font = (Form1.unicode) ? FontLabel.Font : PKX.getPKXFont((float)8.25);
Font font = (Main.unicode) ? FontLabel.Font : PKX.getPKXFont((float)8.25);
Image preview = new Bitmap(45, 45);
using (Graphics gfx = Graphics.FromImage(preview))
{

View file

@ -5,11 +5,9 @@ namespace PKHeX
{
public partial class SplashScreen : Form
{
Form1 m_parent;
public SplashScreen(Form1 frm1)
public SplashScreen()
{
InitializeComponent();
m_parent = frm1;
System.Timers.Timer myTimer = new System.Timers.Timer();
myTimer.Elapsed += DisplayTimeEvent;
myTimer.Interval = 50; // milliseconds per trigger interval
@ -17,9 +15,9 @@ namespace PKHeX
}
public void DisplayTimeEvent(object source, ElapsedEventArgs e)
{
if (!m_parent.init)
if (L_Status.InvokeRequired) L_Status.Invoke((MethodInvoker)delegate { L_Status.Text = Form1.Status; });
else { L_Status.Text = Form1.Status; }
if (!Main.init)
if (L_Status.InvokeRequired) L_Status.Invoke((MethodInvoker)delegate { L_Status.Text = Main.Status; });
else { L_Status.Text = Main.Status; }
else
if (InvokeRequired && IsHandleCreated)
try { Invoke((MethodInvoker)Close); } catch { Close(); }

View file

@ -6,33 +6,16 @@ namespace PKHeX
{
public class pk2pk
{
public byte[] ConvertPKM(byte[] input, byte[] savefile = null, int savindex = -1)
public void setG6TrainerInfo(byte SUBREGION, byte COUNTRY, byte _3DSREGION, string TRAINERNAME, byte TRAINERGENDER)
{
#region Initialize Everything
// Load Species Name Tables
speclang_ja = Util.getStringList("Species", "ja");
speclang_en = Util.getStringList("Species", "en");
speclang_fr = Util.getStringList("Species", "fr");
speclang_it = Util.getStringList("Species", "it");
speclang_de = Util.getStringList("Species", "de");
speclang_es = Util.getStringList("Species", "es");
// Get the 6th Gen Data from the save file if it exists.
int savshift = savindex * 0x7F000;
// Import trainer details for importing, else use the default values that are already defined.
if ((savefile != null && savindex != -1) && (
BitConverter.ToUInt32(savefile, 0x6A810 + savshift) == 0x42454546 ||
BitConverter.ToUInt32(savefile, 0x7B210 + savshift) == 0x42454546)) // Set for X/Y/OR/AS loaded saves.
{
subreg = savefile[0x19426 + savshift];
country = savefile[0x19427 + savshift];
_3DSreg = savefile[0x1942C + savshift];
g6trname = Util.TrimFromZero(Encoding.Unicode.GetString(savefile, 0x19448 + savshift, 0x1A));
g6trgend = savefile[0x19405 + savshift];
subreg = SUBREGION;
country = COUNTRY;
_3DSreg = _3DSREGION;
g6trname = TRAINERNAME;
g6trgend = TRAINERGENDER;
}
#endregion
public byte[] ConvertPKM(byte[] input)
{
#region Convert
if (input.Length == 100 || input.Length == 80) // We have a Gen 3 PKM.
{
@ -56,12 +39,12 @@ namespace PKHeX
}
#region Utility
public DateTime moment = DateTime.Now;
public string[] speclang_ja;
public string[] speclang_en;
public string[] speclang_fr;
public string[] speclang_it;
public string[] speclang_de;
public string[] speclang_es;
public string[] speclang_ja = Util.getStringList("Species", "ja");
public string[] speclang_en = Util.getStringList("Species", "en");
public string[] speclang_fr = Util.getStringList("Species", "fr");
public string[] speclang_it = Util.getStringList("Species", "it");
public string[] speclang_de = Util.getStringList("Species", "de");
public string[] speclang_es = Util.getStringList("Species", "es");
public int country = 0x31; // US
public int subreg = 0x7; // California
public int _3DSreg = 0x1; // Americas

View file

@ -1,6 +1,6 @@
namespace PKHeX
{
partial class Form1
partial class Main
{
/// <summary>
/// Required designer variable.
@ -29,7 +29,7 @@
public void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Main));
this.tabMain = new System.Windows.Forms.TabControl();
this.Tab_Main = new System.Windows.Forms.TabPage();
this.CB_Language = new System.Windows.Forms.ComboBox();
@ -313,7 +313,6 @@
this.B_SwitchSAV = new System.Windows.Forms.Button();
this.B_VerifyCHK = new System.Windows.Forms.Button();
this.L_IntegrityCheck = new System.Windows.Forms.Label();
this.B_VerifySHA = new System.Windows.Forms.Button();
this.B_ExportSAV = new System.Windows.Forms.Button();
this.RTB_S = new System.Windows.Forms.RichTextBox();
this.B_OpenHallofFame = new System.Windows.Forms.Button();
@ -538,7 +537,7 @@
this.TB_PID.TabIndex = 1;
this.TB_PID.Text = "12345678";
this.TB_PID.TextChanged += new System.EventHandler(this.update_ID);
this.TB_PID.MouseHover += new System.EventHandler(this.getTSV);
this.TB_PID.MouseHover += new System.EventHandler(this.updateTSV);
//
// CHK_Nicknamed
//
@ -750,7 +749,7 @@
this.CB_Nature.TabIndex = 9;
this.CB_Nature.SelectedIndexChanged += new System.EventHandler(this.validateComboBox2);
this.CB_Nature.KeyDown += new System.Windows.Forms.KeyEventHandler(this.removedropCB);
this.CB_Nature.MouseHover += new System.EventHandler(this.getNatureModification);
this.CB_Nature.MouseHover += new System.EventHandler(this.updateNatureModification);
this.CB_Nature.Validating += new System.ComponentModel.CancelEventHandler(this.validateComboBox);
//
// Label_3DSRegion
@ -2495,7 +2494,7 @@
this.TB_SID.TabIndex = 2;
this.TB_SID.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.TB_SID.TextChanged += new System.EventHandler(this.update_ID);
this.TB_SID.MouseHover += new System.EventHandler(this.getTSV);
this.TB_SID.MouseHover += new System.EventHandler(this.updateTSV);
//
// TB_TID
//
@ -2507,7 +2506,7 @@
this.TB_TID.TabIndex = 1;
this.TB_TID.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.TB_TID.TextChanged += new System.EventHandler(this.update_ID);
this.TB_TID.MouseHover += new System.EventHandler(this.getTSV);
this.TB_TID.MouseHover += new System.EventHandler(this.updateTSV);
//
// Label_OT
//
@ -3779,7 +3778,6 @@
this.Tab_SAV.Controls.Add(this.B_SwitchSAV);
this.Tab_SAV.Controls.Add(this.B_VerifyCHK);
this.Tab_SAV.Controls.Add(this.L_IntegrityCheck);
this.Tab_SAV.Controls.Add(this.B_VerifySHA);
this.Tab_SAV.Controls.Add(this.B_ExportSAV);
this.Tab_SAV.Controls.Add(this.RTB_S);
this.Tab_SAV.Location = new System.Drawing.Point(4, 22);
@ -3829,17 +3827,6 @@
this.L_IntegrityCheck.TabIndex = 5;
this.L_IntegrityCheck.Text = "Integrity Check:";
//
// B_VerifySHA
//
this.B_VerifySHA.Enabled = false;
this.B_VerifySHA.Location = new System.Drawing.Point(32, 42);
this.B_VerifySHA.Name = "B_VerifySHA";
this.B_VerifySHA.Size = new System.Drawing.Size(75, 23);
this.B_VerifySHA.TabIndex = 1;
this.B_VerifySHA.Text = "Hashes";
this.B_VerifySHA.UseVisualStyleBackColor = true;
this.B_VerifySHA.Click += new System.EventHandler(this.clickVerifySHA);
//
// B_ExportSAV
//
this.B_ExportSAV.Enabled = false;
@ -4039,7 +4026,7 @@
this.L_QR.Visible = false;
this.L_QR.Click += new System.EventHandler(this.clickQR);
//
// Form1
// Main
//
this.AllowDrop = true;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -4056,7 +4043,7 @@
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.Name = "Form1";
this.Name = "Main";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "PKHeX";
this.tabMain.ResumeLayout(false);
@ -4400,7 +4387,6 @@
private System.Windows.Forms.TabPage Tab_SAV;
private System.Windows.Forms.Button B_ExportSAV;
private System.Windows.Forms.Button B_VerifyCHK;
private System.Windows.Forms.Button B_VerifySHA;
private System.Windows.Forms.RichTextBox RTB_S;
private System.Windows.Forms.Button B_BoxRight;
private System.Windows.Forms.Button B_BoxLeft;

File diff suppressed because it is too large Load diff

View file

@ -591,9 +591,6 @@
<metadata name="L_IntegrityCheck.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="B_VerifySHA.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="B_ExportSAV.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>

View file

@ -8,10 +8,10 @@ namespace PKHeX
{
public f2_Text(TextBox TB_NN)
{
Form1.specialChars = true;
Main.specialChars = true;
Hide();
InitializeComponent();
Util.TranslateInterface(this, Form1.curlanguage);
Util.TranslateInterface(this, Main.curlanguage);
TB_Nickname = TB_NN;
Font pkxFont = PKX.getPKXFont(12F);
Label[] lbla =
@ -46,7 +46,7 @@ namespace PKHeX
}
private void onClosed(object sender, FormClosedEventArgs e)
{
Form1.specialChars = false;
Main.specialChars = false;
}
}
}

View file

@ -6,7 +6,7 @@ namespace PKHeX
{
public partial class MemoryAmie : Form
{
Form1 m_parent;
Main m_parent;
public byte[] h = new byte[260]; // Always Visible
private string disabled = "Disabled";
private string notleft = "Never left";
@ -14,14 +14,14 @@ namespace PKHeX
private string past = "Past Gen";
private string withOT = "Memories with"; // these get replaced when the form is translated.
private string[] vartypes = new string[5];
public MemoryAmie(Form1 frm1)
public MemoryAmie(Main frm1) // Keeping the form reference as a lot of control elements are required to operate.
{
InitializeComponent();
CB_Country0.DisplayMember = CB_Country1.DisplayMember = CB_Country2.DisplayMember = CB_Country3.DisplayMember = CB_Country4.DisplayMember = "Text";
CB_Country0.ValueMember = CB_Country1.ValueMember = CB_Country2.ValueMember = CB_Country3.ValueMember = CB_Country4.ValueMember = "Value";
CB_Region0.DisplayMember = CB_Region1.DisplayMember = CB_Region2.DisplayMember = CB_Region3.DisplayMember = CB_Region4.DisplayMember = "Text";
CB_Region0.ValueMember = CB_Region1.ValueMember = CB_Region2.ValueMember = CB_Region3.ValueMember = CB_Region4.ValueMember = "Value";
Util.TranslateInterface(this, Form1.curlanguage);
Util.TranslateInterface(this, Main.curlanguage);
m_parent = frm1;
string[] arguments = Regex.Split(L_Arguments.Text, " ; ");
@ -46,7 +46,7 @@ namespace PKHeX
past = "Past Gen";
withOT = "Memories with";
}
h = m_parent.buff;
h = Main.buff;
getCountries();
getLangStrings();
@ -85,9 +85,9 @@ namespace PKHeX
if (Util.TrimFromZero(m_parent.TB_OTt2.Text) != "")
CB_Handler.Items.AddRange(new object[] { m_parent.TB_OTt2.Text });
else
m_parent.buff[0x93] = 0;
Main.buff[0x93] = 0;
tabControl1.SelectedIndex = CB_Handler.SelectedIndex = m_parent.buff[0x93];
tabControl1.SelectedIndex = CB_Handler.SelectedIndex = Main.buff[0x93];
if (m_parent.CHK_IsEgg.Checked)
{
@ -97,8 +97,8 @@ namespace PKHeX
BTN_Save.Enabled = M_Fullness.Enabled = M_Enjoyment.Enabled = false;
L_Fullness.Enabled = L_Enjoyment.Enabled = false;
GB_M_OT.Text = "N/A: " + Form1.eggname;
GB_M_CT.Text = "N/A: " + Form1.eggname;
GB_M_OT.Text = "N/A: " + Main.eggname;
GB_M_CT.Text = "N/A: " + Main.eggname;
}
else
{
@ -167,8 +167,8 @@ namespace PKHeX
cb1v(CB_CTMemory, 0xA5);
if (!CB_CTVar.Enabled)
{
m_parent.buff[0xA8] = 0;
m_parent.buff[0xA9] = 0;
Main.buff[0xA8] = 0;
Main.buff[0xA9] = 0;
}
else
cb2v(CB_CTVar, 0xA8);
@ -176,21 +176,21 @@ namespace PKHeX
// If memory doesn't contain a feeling/quality
if (!CB_CTFeel.Enabled)
{
m_parent.buff[0xA4] = 0;
m_parent.buff[0xA6] = 0;
Main.buff[0xA4] = 0;
Main.buff[0xA6] = 0;
}
else
{
cb1i(CB_CTFeel, 0xA6);
m_parent.buff[0xA4] = (byte)(CB_CTQual.SelectedIndex + 1);
Main.buff[0xA4] = (byte)(CB_CTQual.SelectedIndex + 1);
}
#endregion
#region // OT MEMORIES
cb1v(CB_OTMemory, 0xCD);
if (!CB_OTVar.Enabled)
{
m_parent.buff[0xCE] = 0;
m_parent.buff[0xCF] = 0;
Main.buff[0xCE] = 0;
Main.buff[0xCF] = 0;
}
else
cb2v(CB_OTVar, 0xCE);
@ -198,13 +198,13 @@ namespace PKHeX
// If memory doesn't contain a feeling/quality
if (!CB_OTFeel.Enabled)
{
m_parent.buff[0xCC] = 0;
m_parent.buff[0xD0] = 0;
Main.buff[0xCC] = 0;
Main.buff[0xD0] = 0;
}
else
{
cb1i(CB_OTFeel, 0xD0);
m_parent.buff[0xCC] = (byte)(CB_OTQual.SelectedIndex + 1);
Main.buff[0xCC] = (byte)(CB_OTQual.SelectedIndex + 1);
}
#endregion
}
@ -263,19 +263,19 @@ namespace PKHeX
{
comboBox.DisplayMember = "Text";
comboBox.ValueMember = "Value";
m_parent.setCountrySubRegion(comboBox, "countries");
Main.setCountrySubRegion(comboBox, "countries");
}
}
private void getLangStrings()
{
// Memory Chooser
int memorycount = Form1.memories.Length - 38;
int memorycount = Main.memories.Length - 38;
string[] memories = new string[memorycount];
int[] allowed = new int[memorycount];
for (int i = 0; i < memorycount; i++)
{
memories[i] = Form1.memories[38 + i];
memories[i] = Main.memories[38 + i];
allowed[i] = i + 1;
}
Array.Resize(ref allowed, allowed.Length - 1);
@ -295,8 +295,8 @@ namespace PKHeX
CB_OTQual.Items.Clear();
for (int i = 0; i < 7; i++)
{
CB_CTQual.Items.Add(Form1.memories[2 + i]);
CB_OTQual.Items.Add(Form1.memories[2 + i]);
CB_CTQual.Items.Add(Main.memories[2 + i]);
CB_OTQual.Items.Add(Main.memories[2 + i]);
}
// Feeling Chooser
@ -304,8 +304,8 @@ namespace PKHeX
CB_OTFeel.Items.Clear();
for (int i = 0; i < 24; i++)
{
CB_CTFeel.Items.Add(Form1.memories[10 + i]);
CB_OTFeel.Items.Add(Form1.memories[10 + i]);
CB_CTFeel.Items.Add(Main.memories[10 + i]);
CB_OTFeel.Items.Add(Main.memories[10 + i]);
}
}
private void getMemoryArguments(string ARG, ComboBox sender)
@ -321,11 +321,11 @@ namespace PKHeX
vs = "";
break;
case "PKM":
argvals = Util.getCBList(Form1.specieslist, null);
argvals = Util.getCBList(Main.specieslist, null);
vs = vartypes[0];
break;
case "GENLOC":
argvals = Util.getCBList(Form1.genloc, null);
argvals = Util.getCBList(Main.genloc, null);
vs = vartypes[1];
break;
case "ITEM":
@ -351,18 +351,18 @@ namespace PKHeX
/* ORAS */
718,719,720,737,738,739,740,741,742,752,753,754,755,756,757,758,759,760,761,762,763,764,765,767,768, 769,770,775
};
var item_list = Util.getCBList(Form1.itemlist, items_allowed);
var item_list = Util.getCBList(Main.itemlist, items_allowed);
#endregion
argvals = item_list;
vs = vartypes[2];
}
break;
case "MOVE":
argvals = Util.getCBList(Form1.movelist, null);
argvals = Util.getCBList(Main.movelist, null);
vs = vartypes[3];
break;
case "LOCATION":
argvals = Util.getCBList(Form1.metXY_00000, Legal.Met_XY_0);
argvals = Util.getCBList(Main.metXY_00000, Legal.Met_XY_0);
vs = vartypes[4];
break;
}
@ -386,17 +386,17 @@ namespace PKHeX
}
private string getMemoryString(ComboBox m, ComboBox arg, ComboBox q, ComboBox f, string tr)
{
string result = "";
string result;
string nn = m_parent.TB_Nickname.Text;
string a = ((Util.cbItem)(arg.SelectedItem) == null) ? arg.Text ?? "ERROR" : ((Util.cbItem)(arg.SelectedItem)).Text;
int mem = Util.getIndex(m);
bool enabled = false;
if (mem == 0)
result = Form1.memories[38];
result = Main.memories[38];
else
{
result = String.Format(Form1.memories[mem + 38], nn, tr, a, f.Text, q.Text);
result = String.Format(Main.memories[mem + 38], nn, tr, a, f.Text, q.Text);
enabled = true;
}
@ -505,7 +505,7 @@ namespace PKHeX
};
int index = Array.IndexOf(cba, sender as ComboBox);
if (Util.getIndex(sender as ComboBox) > 0)
m_parent.setCountrySubRegion(mta[index], "sr_" + Util.getIndex(sender as ComboBox).ToString("000"));
Main.setCountrySubRegion(mta[index], "sr_" + Util.getIndex(sender as ComboBox).ToString("000"));
}
private void update255_MTB(object sender, EventArgs e)

View file

@ -7,20 +7,18 @@ namespace PKHeX
{
public partial class RibbMedal : Form
{
Form1 m_parent;
public RibbMedal(Form1 frm1)
public RibbMedal()
{
InitializeComponent();
Util.TranslateInterface(this, Form1.curlanguage);
m_parent = frm1;
Util.TranslateInterface(this, Main.curlanguage);
// Set up Training Bag Data
comboBox1.Items.Clear();
comboBox1.Items.Add("---");
for (int i = 1; i < Form1.trainingbags.Length - 1; i++)
comboBox1.Items.Add(Form1.trainingbags[i]);
comboBox1.SelectedIndex = m_parent.buff[0x17];
numericUpDown1.Value = m_parent.buff[0x16];
for (int i = 1; i < Main.trainingbags.Length - 1; i++)
comboBox1.Items.Add(Main.trainingbags[i]);
comboBox1.SelectedIndex = Main.buff[0x17];
numericUpDown1.Value = Main.buff[0x16];
getRibbons();
}
private void getRibbons()
@ -67,10 +65,8 @@ namespace PKHeX
for (int i = 0; i < bma.Length; i++)
pba[i].Image = Util.ChangeOpacity(bma[i], 0.1);
int rv = 0; // Read from value (later redefined)
// Populate Medals (what a mess)
rv = m_parent.buff[0x2C];
int rv = Main.buff[0x2C];
updateRibbon(TMedal1_0, rv, 0);
updateRibbon(TMedal1_1, rv, 1);
updateRibbon(TMedal1_2, rv, 2);
@ -79,7 +75,7 @@ namespace PKHeX
updateRibbon(TMedal1_5, rv, 5);
updateRibbon(TMedal1_6, rv, 6);
updateRibbon(TMedal1_7, rv, 7);
rv = m_parent.buff[0x2D];
rv = Main.buff[0x2D];
updateRibbon(TMedal2_0, rv, 0);
updateRibbon(TMedal2_1, rv, 1);
updateRibbon(TMedal2_2, rv, 2);
@ -88,7 +84,7 @@ namespace PKHeX
updateRibbon(TMedal2_5, rv, 5);
updateRibbon(TMedal2_6, rv, 6);
updateRibbon(TMedal2_7, rv, 7);
rv = m_parent.buff[0x2E];
rv = Main.buff[0x2E];
updateRibbon(TMedal3_0, rv, 0);
updateRibbon(TMedal3_1, rv, 1);
updateRibbon(TMedal3_2, rv, 2);
@ -97,7 +93,7 @@ namespace PKHeX
updateRibbon(TMedal3_5, rv, 5);
updateRibbon(TMedal3_6, rv, 6);
updateRibbon(TMedal3_7, rv, 7);
rv = m_parent.buff[0x2F];
rv = Main.buff[0x2F];
updateRibbon(TMedal4_0, rv, 0);
updateRibbon(TMedal4_1, rv, 1);
updateRibbon(TMedal4_2, rv, 2);
@ -108,7 +104,7 @@ namespace PKHeX
updateRibbon(TMedal4_7, rv, 7);
// Populate Kalos Ribbons
rv = m_parent.buff[0x30];
rv = Main.buff[0x30];
updateRibbon(Kalos1a_0, rv, 0);
updateRibbon(Kalos1a_1, rv, 1);
updateRibbon(Kalos1a_2, rv, 2);
@ -117,7 +113,7 @@ namespace PKHeX
updateRibbon(Kalos1a_5, rv, 5);
updateRibbon(Kalos1a_6, rv, 6);
updateRibbon(Kalos1a_7, rv, 7);
rv = m_parent.buff[0x31];
rv = Main.buff[0x31];
updateRibbon(Kalos1b_0, rv, 0);
updateRibbon(Kalos1b_1, rv, 1);
updateRibbon(Kalos1b_2, rv, 2);
@ -126,7 +122,7 @@ namespace PKHeX
updateRibbon(Kalos1b_5, rv, 5);
updateRibbon(Kalos1b_6, rv, 6);
updateRibbon(Kalos1b_7, rv, 7);
rv = m_parent.buff[0x32];
rv = Main.buff[0x32];
updateRibbon(Kalos2a_0, rv, 0);
updateRibbon(Kalos2a_1, rv, 1);
updateRibbon(Kalos2a_2, rv, 2);
@ -135,7 +131,7 @@ namespace PKHeX
updateRibbon(Kalos2a_5, rv, 5);
updateRibbon(Kalos2a_6, rv, 6);
updateRibbon(Kalos2a_7, rv, 7);
rv = m_parent.buff[0x33];
rv = Main.buff[0x33];
updateRibbon(Kalos2b_0, rv, 0);
updateRibbon(Kalos2b_1, rv, 1);
updateRibbon(Kalos2b_2, rv, 2);
@ -146,7 +142,7 @@ namespace PKHeX
updateRibbon(Kalos2b_7, rv, 7);
// Populate Extra Ribbons
rv = m_parent.buff[0x34];
rv = Main.buff[0x34];
updateRibbon(Extra1_0, rv, 0);
updateRibbon(Extra1_1, rv, 1);
updateRibbon(Extra1_2, rv, 2);
@ -155,7 +151,7 @@ namespace PKHeX
// oras
updateRibbon(Extra1_7, rv, 7);
rv = m_parent.buff[0x35];
rv = Main.buff[0x35];
updateRibbon(ORAS_0, rv, 0);
updateRibbon(ORAS_1, rv, 1);
updateRibbon(ORAS_2, rv, 2);
@ -163,10 +159,10 @@ namespace PKHeX
updateRibbon(ORAS_4, rv, 4);
updateRibbon(ORAS_5, rv, 5);
TB_PastContest.Text = m_parent.buff[0x38].ToString();
TB_PastBattle.Text = m_parent.buff[0x39].ToString();
TB_PastContest.Text = Main.buff[0x38].ToString();
TB_PastBattle.Text = Main.buff[0x39].ToString();
rv = m_parent.buff[0x3A];
rv = Main.buff[0x3A];
updateRibbon(CHK_D0, rv, 0);
updateRibbon(CHK_D1, rv, 1);
updateRibbon(CHK_D2, rv, 2);
@ -174,7 +170,7 @@ namespace PKHeX
updateRibbon(CHK_D4, rv, 4);
updateRibbon(CHK_D5, rv, 5);
CHK_Secret.Checked = Convert.ToBoolean(m_parent.buff[0x72]);
CHK_Secret.Checked = Convert.ToBoolean(Main.buff[0x72]);
} // Populate Ribbons prompted
private void setRibbons()
{
@ -212,10 +208,10 @@ namespace PKHeX
kalos2b |= addRibbon(Kalos2b_5);
kalos2b |= addRibbon(Kalos2b_6);
kalos2b |= addRibbon(Kalos2b_7);////
m_parent.buff[0x30] = (byte)kalos1a;
m_parent.buff[0x31] = (byte)kalos1b;
m_parent.buff[0x32] = (byte)kalos2a;
m_parent.buff[0x33] = (byte)kalos2b;
Main.buff[0x30] = (byte)kalos1a;
Main.buff[0x31] = (byte)kalos1b;
Main.buff[0x32] = (byte)kalos2a;
Main.buff[0x33] = (byte)kalos2b;
// Pass Extra Ribbon
int extra1 = 0;
@ -227,7 +223,7 @@ namespace PKHeX
// ORAS
extra1 |= addRibbon(Extra1_7); // Hoenn Champ
m_parent.buff[0x34] = (byte)extra1;
Main.buff[0x34] = (byte)extra1;
int oras = 0;
oras |= addRibbon(ORAS_0);
@ -236,7 +232,7 @@ namespace PKHeX
oras |= addRibbon(ORAS_3);
oras |= addRibbon(ORAS_4);
oras |= addRibbon(ORAS_5);
m_parent.buff[0x35] = (byte)oras;
Main.buff[0x35] = (byte)oras;
// Gather Super Training Medals
int medals1 = 0, medals2 = 0, medals3 = 0, medals4 = 0;
@ -272,13 +268,13 @@ namespace PKHeX
medals4 |= addRibbon(TMedal4_5);
medals4 |= addRibbon(TMedal4_6);
medals4 |= addRibbon(TMedal4_7);////
m_parent.buff[0x2C] = (byte)medals1;
m_parent.buff[0x2D] = (byte)medals2;
m_parent.buff[0x2E] = (byte)medals3;
m_parent.buff[0x2F] = (byte)medals4;
Main.buff[0x2C] = (byte)medals1;
Main.buff[0x2D] = (byte)medals2;
Main.buff[0x2E] = (byte)medals3;
Main.buff[0x2F] = (byte)medals4;
m_parent.buff[0x38] = (byte)Util.ToUInt32(TB_PastContest.Text);
m_parent.buff[0x39] = (byte)Util.ToUInt32(TB_PastBattle.Text);
Main.buff[0x38] = (byte)Util.ToUInt32(TB_PastContest.Text);
Main.buff[0x39] = (byte)Util.ToUInt32(TB_PastBattle.Text);
int dis = 0;
dis |= addRibbon(CHK_D0);
@ -287,9 +283,9 @@ namespace PKHeX
dis |= addRibbon(CHK_D3);
dis |= addRibbon(CHK_D4);
dis |= addRibbon(CHK_D5);
m_parent.buff[0x3A] = (byte)dis;
Main.buff[0x3A] = (byte)dis;
m_parent.buff[0x72] = Convert.ToByte(CHK_Secret.Checked);
Main.buff[0x72] = Convert.ToByte(CHK_Secret.Checked);
} // Saving Ribbons prompted
private void updateRibbon(CheckBox chk, int rv, int sh)
{
@ -332,7 +328,7 @@ namespace PKHeX
TB_PastContest.Text = (Convert.ToInt32(b) * 40).ToString();
TB_PastBattle.Text = (Convert.ToInt32(b) * 8).ToString();
if (m_parent.buff[0xDF] <= 0x10) return; // gen3
if (Main.buff[0xDF] <= 0x10) return; // gen3
TB_PastContest.Text = 0.ToString(); // no past gen ribbons 4-5
TB_PastBattle.Text = 0.ToString();
}
@ -364,8 +360,8 @@ namespace PKHeX
private void BTN_Save_Click(object sender, EventArgs e)
{
m_parent.buff[0x17] = (byte)comboBox1.SelectedIndex;
m_parent.buff[0x16] = (byte)numericUpDown1.Value;
Main.buff[0x17] = (byte)comboBox1.SelectedIndex;
Main.buff[0x16] = (byte)numericUpDown1.Value;
setRibbons();
Close();
} // Save Button

View file

@ -13,7 +13,7 @@ namespace PKHeX
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
Application.Run(new Main());
}
}
}

View file

@ -5,36 +5,29 @@ namespace PKHeX
{
public partial class SAV_BerryField : Form
{
public SAV_BerryField(Form1 frm1, int bfo)
public SAV_BerryField()
{
berryfoffset = bfo;
InitializeComponent();
Util.TranslateInterface(this, Form1.curlanguage);
Form1 mParent = frm1;
Array.Copy(mParent.savefile, sav, 0x100000);
savindex = mParent.savindex;
shiftval = savindex * 0x7F000;
Util.TranslateInterface(this, Main.curlanguage);
sav = (byte[])Main.savefile.Clone();
listBox1.SelectedIndex = 0;
}
int berryfoffset;
public byte[] sav = new byte[0x100000];
public int savindex; int shiftval;
public byte[] sav;
public bool editing = false;
private void changefield(object sender, EventArgs e)
{
// Change Berry Field
int offset = berryfoffset + shiftval;
// Gather Data
int berry = BitConverter.ToUInt16(sav, offset + 0xC + listBox1.SelectedIndex*0x18 + 1 * 0);
int u1 = BitConverter.ToUInt16(sav, offset + 0xC + listBox1.SelectedIndex * 0x18 + 1 * 2);
int u2 = BitConverter.ToUInt16(sav, offset + 0xC + listBox1.SelectedIndex * 0x18 + 2 * 2);
int u3 = BitConverter.ToUInt16(sav, offset + 0xC + listBox1.SelectedIndex * 0x18 + 3 * 2);
int u4 = BitConverter.ToUInt16(sav, offset + 0xC + listBox1.SelectedIndex * 0x18 + 4 * 2);
int u5 = BitConverter.ToUInt16(sav, offset + 0xC + listBox1.SelectedIndex * 0x18 + 5 * 2);
int u6 = BitConverter.ToUInt16(sav, offset + 0xC + listBox1.SelectedIndex * 0x18 + 6 * 2);
int u7 = BitConverter.ToUInt16(sav, offset + 0xC + listBox1.SelectedIndex * 0x18 + 7 * 2);
int berry = BitConverter.ToUInt16(sav, Main.SaveGame.BerryField + 0xC + listBox1.SelectedIndex*0x18 + 1 * 0);
int u1 = BitConverter.ToUInt16(sav, Main.SaveGame.BerryField + 0xC + listBox1.SelectedIndex * 0x18 + 1 * 2);
int u2 = BitConverter.ToUInt16(sav, Main.SaveGame.BerryField + 0xC + listBox1.SelectedIndex * 0x18 + 2 * 2);
int u3 = BitConverter.ToUInt16(sav, Main.SaveGame.BerryField + 0xC + listBox1.SelectedIndex * 0x18 + 3 * 2);
int u4 = BitConverter.ToUInt16(sav, Main.SaveGame.BerryField + 0xC + listBox1.SelectedIndex * 0x18 + 4 * 2);
int u5 = BitConverter.ToUInt16(sav, Main.SaveGame.BerryField + 0xC + listBox1.SelectedIndex * 0x18 + 5 * 2);
int u6 = BitConverter.ToUInt16(sav, Main.SaveGame.BerryField + 0xC + listBox1.SelectedIndex * 0x18 + 6 * 2);
int u7 = BitConverter.ToUInt16(sav, Main.SaveGame.BerryField + 0xC + listBox1.SelectedIndex * 0x18 + 7 * 2);
// Display Data

View file

@ -7,43 +7,38 @@ namespace PKHeX
{
public partial class SAV_BoxLayout : Form
{
public SAV_BoxLayout(Form1 frm1)
public SAV_BoxLayout(int box)
{
m_parent = frm1;
InitializeComponent();
Util.TranslateInterface(this, Form1.curlanguage);
Util.TranslateInterface(this, Main.curlanguage);
sav = (byte[])Main.savefile.Clone();
editing = true;
Array.Copy(m_parent.savefile, sav, 0x100000);
savindex = m_parent.savindex;
// Repopulate Wallpaper names
CB_BG.Items.Clear();
foreach (string wallpaper in Form1.wallpapernames)
foreach (string wallpaper in Main.wallpapernames)
CB_BG.Items.Add(wallpaper);
// Go
LB_BoxSelect.SelectedIndex = m_parent.CB_BoxSelect.SelectedIndex;
LB_BoxSelect.SelectedIndex = box;
}
Form1 m_parent;
public byte[] sav = new byte[0x100000];
public int savindex;
public byte[] sav;
public bool editing;
private void changeBox(object sender, EventArgs e)
{
editing = true;
int index = LB_BoxSelect.SelectedIndex;
int offset = 0x9800 + savindex * 0x7F000;
int bgoff = (0x7F000 * savindex) + 0x9C1E + LB_BoxSelect.SelectedIndex;
int bgoff = Main.SaveGame.PCBackgrounds + LB_BoxSelect.SelectedIndex;
CB_BG.SelectedIndex = sav[bgoff];
changeBoxBG(null, null);
TB_BoxName.Text = Encoding.Unicode.GetString(sav, offset + 0x22 * index, 0x22);
CB_BG.SelectedIndex = sav[0x9C1E + savindex * 0x7F000 + index];
MT_BG1.Text = sav[0x9C3D + savindex * 0x7F000].ToString();
MT_BG2.Text = sav[0x9C3F + savindex * 0x7F000].ToString();
TB_BoxName.Text = Encoding.Unicode.GetString(sav, Main.SaveGame.PCLayout + 0x22 * index, 0x22);
CB_BG.SelectedIndex = sav[bgoff];
MT_BG1.Text = sav[Main.SaveGame.PCFlags + 0].ToString();
CB_Unlocked.SelectedIndex = sav[Main.SaveGame.PCFlags + 1] - 1;
MT_BG2.Text = sav[Main.SaveGame.PCFlags + 2].ToString();
CB_Unlocked.SelectedIndex = sav[0x9C3E + savindex * 0x7F000] - 1;
editing = false;
}
private void changeBoxDetails(object sender, EventArgs e)
@ -51,20 +46,16 @@ namespace PKHeX
if (editing) return;
int index = LB_BoxSelect.SelectedIndex;
int offset = 0x9800 + savindex * 0x7F000;
sav[(0x7F000 * savindex) + 0x9C1E + LB_BoxSelect.SelectedIndex] = (byte)CB_BG.SelectedIndex;
// Get Sender Index
sav[Main.SaveGame.PCBackgrounds + index] = (byte)CB_BG.SelectedIndex;
byte[] boxname = Encoding.Unicode.GetBytes(TB_BoxName.Text);
Array.Resize(ref boxname, 0x22);
Array.Copy(boxname, 0, sav, offset + 0x22 * index, boxname.Length);
Array.Copy(boxname, 0, sav, Main.SaveGame.PCLayout + 0x22 * index, boxname.Length);
sav[0x9C1E + savindex * 0x7F000 + index] = (byte)CB_BG.SelectedIndex;
sav[0x9C3D + savindex * 0x7F000] = (byte)Util.ToUInt32(MT_BG1.Text);
sav[0x9C3F + savindex * 0x7F000] = (byte)Util.ToUInt32(MT_BG2.Text);
sav[0x9C3E + savindex * 0x7F000] = (byte)Util.ToUInt32(CB_Unlocked.Text);
sav[Main.SaveGame.PCBackgrounds + index] = (byte)CB_BG.SelectedIndex;
sav[Main.SaveGame.PCFlags + 0] = (byte)Util.ToUInt32(MT_BG1.Text);
sav[Main.SaveGame.PCFlags + 1] = (byte)Util.ToUInt32(CB_Unlocked.Text);
sav[Main.SaveGame.PCFlags + 2] = (byte)Util.ToUInt32(MT_BG2.Text);
}
private void B_Cancel_Click(object sender, EventArgs e)
{
@ -72,16 +63,16 @@ namespace PKHeX
}
private void B_Save_Click(object sender, EventArgs e)
{
Array.Copy(sav, m_parent.savefile, 0x100000);
m_parent.savedited = true;
Array.Copy(sav, Main.savefile, sav.Length);
Main.savedited = true;
Close();
}
private void changeBoxBG(object sender, EventArgs e)
{
sav[(0x7F000 * savindex) + 0x9C1E + LB_BoxSelect.SelectedIndex] = (byte)CB_BG.SelectedIndex;
sav[Main.SaveGame.PCBackgrounds + LB_BoxSelect.SelectedIndex] = (byte)CB_BG.SelectedIndex;
string imagename = "box_wp" + (CB_BG.SelectedIndex + 1).ToString("00"); if (m_parent.savegame_oras && (CB_BG.SelectedIndex + 1) > 16) imagename += "o";
string imagename = "box_wp" + (CB_BG.SelectedIndex + 1).ToString("00"); if (Main.SaveGame.ORAS && (CB_BG.SelectedIndex + 1) > 16) imagename += "o";
PAN_BG.BackgroundImage = (Image)Properties.Resources.ResourceManager.GetObject(imagename);
}
}

View file

@ -8,12 +8,10 @@ namespace PKHeX
{
public partial class SAV_EventFlagsORAS : Form
{
public SAV_EventFlagsORAS(Form1 frm1)
public SAV_EventFlagsORAS()
{
InitializeComponent();
Util.TranslateInterface(this, Form1.curlanguage);
m_parent = frm1;
savshift = 0x7F000 * m_parent.savindex;
Util.TranslateInterface(this, Main.curlanguage);
AllowDrop = true;
DragEnter += tabMain_DragEnter;
@ -21,14 +19,12 @@ namespace PKHeX
Setup();
nud.Text = "0"; // Prompts an update for flag 0.
MT_Ash.Text = BitConverter.ToUInt16(m_parent.savefile, savshift + 0x14A78 + 0x5400).ToString();
MT_Ash.Text = BitConverter.ToUInt16(Main.savefile, Main.SaveGame.EventAsh).ToString();
}
Form1 m_parent;
public int savshift;
bool setup = true;
public CheckBox[] chka;
public bool[] flags = new bool[3072];
public ushort[] Constants = new ushort[0x2FC / 2];
public ushort[] Constants = new ushort[(Main.SaveGame.EventFlag - Main.SaveGame.EventConst) / 2];
private void B_Cancel_Click(object sender, EventArgs e)
{
Close();
@ -45,15 +41,15 @@ namespace PKHeX
if (flags[i])
data[i / 8] |= (byte)(1 << i % 8);
Array.Copy(data, 0, m_parent.savefile, 0x1A0FC + savshift, 0x180);
Array.Copy(data, 0, Main.savefile, Main.SaveGame.EventFlag, 0x180);
// Copy back Volcanic Ash counter
Array.Copy(BitConverter.GetBytes(Util.ToUInt32(MT_Ash)), 0, m_parent.savefile, 0x14A78 + 0x5400 + savshift, 2);
Array.Copy(BitConverter.GetBytes(Util.ToUInt32(MT_Ash)), 0, Main.savefile, Main.SaveGame.EventAsh, 2);
// Copy back Constants
changeConstantIndex(null, null); // Trigger Saving
for (int i = 0; i < Constants.Length; i++)
Array.Copy(BitConverter.GetBytes(Constants[i]), 0, m_parent.savefile, 0x19E00 + savshift + 2 * i, 2);
Array.Copy(BitConverter.GetBytes(Constants[i]), 0, Main.savefile, Main.SaveGame.EventConst + 2 * i, 2);
Close();
}
@ -105,18 +101,17 @@ namespace PKHeX
//flag_0675, // Chatelaine 50
//flag_2546, // Pokedex
};
int offset = 0x1A0FC + savshift;
byte[] data = new byte[0x180];
Array.Copy(m_parent.savefile, offset, data, 0, 0x180);
Array.Copy(Main.savefile, Main.SaveGame.EventFlag, data, 0, 0x180);
BitArray BitRegion = new BitArray(data);
BitRegion.CopyTo(flags, 0);
// Setup Event Constant Editor
CB_Stats.Items.Clear();
for (int i = 0; i < 0x2FC; i += 2)
for (int i = 0; i < Constants.Length; i += 2)
{
CB_Stats.Items.Add(String.Format("0x{0}", i.ToString("X3")));
Constants[i / 2] = BitConverter.ToUInt16(m_parent.savefile, 0x19E00 + i);
Constants[i / 2] = BitConverter.ToUInt16(Main.savefile, Main.SaveGame.EventConst + i);
}
CB_Stats.SelectedIndex = 0;
@ -159,7 +154,7 @@ namespace PKHeX
else
{
CHK_CustomFlag.Enabled = true;
nud.BackColor = Form1.defaultControlWhite;
nud.BackColor = Main.defaultControlWhite;
CHK_CustomFlag.Checked = flags[flag];
}
}
@ -212,14 +207,14 @@ namespace PKHeX
switch (fi.Length)
{
case 0x100000: // ramsav
Array.Copy(File.ReadAllBytes(path), 0x1A0FC, eventflags, 0, 0x180);
Array.Copy(File.ReadAllBytes(path), Main.SaveGame.EventFlag, eventflags, 0, 0x180);
break;
case 0x76000: // oras main
Array.Copy(File.ReadAllBytes(path), 0x1A0FC - 0x5400, eventflags, 0, 0x180);
Array.Copy(File.ReadAllBytes(path), Main.SaveGame.EventFlag, eventflags, 0, 0x180);
break;
default: // figure it out
if (fi.Name.ToLower().Contains("ram") && fi.Length == 0x80000)
Array.Copy(ram2sav.getMAIN(File.ReadAllBytes(path)), 0x1A0FC - 0x5400, eventflags, 0, 0x180);
Array.Copy(ram2sav.getMAIN(File.ReadAllBytes(path)), Main.SaveGame.EventFlag, eventflags, 0, 0x180);
else
{ Util.Error("Invalid SAV Size", String.Format("File Size: 0x{1} ({0} bytes)", fi.Length, fi.Length.ToString("X5")), "File Loaded: " + path); return; }
break;

View file

@ -8,27 +8,23 @@ namespace PKHeX
{
public partial class SAV_EventFlagsXY : Form
{
public SAV_EventFlagsXY(Form1 frm1)
public SAV_EventFlagsXY()
{
InitializeComponent();
Util.TranslateInterface(this, Form1.curlanguage);
m_parent = frm1;
savshift = 0x7F000 * m_parent.savindex;
Util.TranslateInterface(this, Main.curlanguage);
AllowDrop = true;
DragEnter += tabMain_DragEnter;
DragDrop += tabMain_DragDrop;
Setup();
nud.Text = "0"; // Prompts an update for flag 0.
// No Volcanic Ash in X/Y
}
Form1 m_parent;
public int savshift;
bool setup = true;
public CheckBox[] chka;
public bool[] flags = new bool[3072];
public ushort[] Constants = new ushort[0x2FC / 2];
public ushort[] Constants = new ushort[(Main.SaveGame.EventFlag - Main.SaveGame.EventConst) / 2];
private void B_Cancel_Click(object sender, EventArgs e)
{
Close();
@ -42,16 +38,18 @@ namespace PKHeX
byte[] data = new byte[flags.Length / 8];
for (int i = 0; i < flags.Length; i++)
{
if (flags[i])
data[i / 8] |= (byte)(1 << i % 8);
}
Array.Copy(data, 0, m_parent.savefile, 0x1A0FC + savshift, 0x180);
Array.Copy(data, 0, Main.savefile, Main.SaveGame.EventFlag, 0x180);
// No Volcanic Ash in X/Y
// Copy back Constants
changeConstantIndex(null, null); // Trigger Saving
for (int i = 0; i < Constants.Length; i++)
Array.Copy(BitConverter.GetBytes(Constants[i]), 0, m_parent.savefile, 0x19E00 + savshift + 2 * i, 2);
Array.Copy(BitConverter.GetBytes(Constants[i]), 0, Main.savefile, Main.SaveGame.EventConst + 2 * i, 2);
Close();
}
@ -69,18 +67,17 @@ namespace PKHeX
flag_0675, // Chatelaine 50
flag_2546, // Pokedex
};
int offset = 0x1A0FC + savshift;
byte[] data = new byte[0x180];
Array.Copy(m_parent.savefile, offset, data, 0, 0x180);
Array.Copy(Main.savefile, Main.SaveGame.EventFlag, data, 0, 0x180);
BitArray BitRegion = new BitArray(data);
BitRegion.CopyTo(flags, 0);
// Setup Event Constant Editor
CB_Stats.Items.Clear();
for (int i = 0; i < 0x2FC; i += 2)
for (int i = 0; i < Constants.Length; i += 2)
{
CB_Stats.Items.Add(String.Format("0x{0}", i.ToString("X3")));
Constants[i / 2] = BitConverter.ToUInt16(m_parent.savefile, 0x19E00 + i);
Constants[i / 2] = BitConverter.ToUInt16(Main.savefile, Main.SaveGame.EventConst + i);
}
CB_Stats.SelectedIndex = 0;
@ -123,7 +120,7 @@ namespace PKHeX
else
{
CHK_CustomFlag.Enabled = true;
nud.BackColor = Form1.defaultControlWhite;
nud.BackColor = Main.defaultControlWhite;
CHK_CustomFlag.Checked = flags[flag];
}
}
@ -178,14 +175,14 @@ namespace PKHeX
switch (fi.Length)
{
case 0x100000: // ramsav
Array.Copy(File.ReadAllBytes(path), 0x1A0FC, eventflags, 0, 0x180);
Array.Copy(File.ReadAllBytes(path), Main.SaveGame.EventFlag, eventflags, 0, 0x180);
break;
case 0x65600: // xy main
Array.Copy(File.ReadAllBytes(path), 0x1A0FC - 0x5400, eventflags, 0, 0x180);
case 0x76000: // oras main
Array.Copy(File.ReadAllBytes(path), Main.SaveGame.EventFlag, eventflags, 0, 0x180);
break;
default: // figure it out
if (fi.Name.ToLower().Contains("ram") && fi.Length == 0x70000)
Array.Copy(ram2sav.getMAIN(File.ReadAllBytes(path)), 0x1A0FC - 0x5400, eventflags, 0, 0x180);
if (fi.Name.ToLower().Contains("ram") && fi.Length == 0x80000)
Array.Copy(ram2sav.getMAIN(File.ReadAllBytes(path)), Main.SaveGame.EventFlag, eventflags, 0, 0x180);
else
{ Util.Error("Invalid SAV Size", String.Format("File Size: 0x{1} ({0} bytes)", fi.Length, fi.Length.ToString("X5")), "File Loaded: " + path); return; }
break;

View file

@ -7,16 +7,13 @@ namespace PKHeX
{
public partial class SAV_HallOfFame : Form
{
public SAV_HallOfFame(Form1 frm1)
public SAV_HallOfFame()
{
InitializeComponent();
Util.TranslateInterface(this, Form1.curlanguage);
m_parent = frm1;
Array.Copy(m_parent.savefile, sav, 0x100000);
savindex = m_parent.savindex;
shiftval = savindex * 0x7F000;
if (m_parent.savegame_oras) data_offset = 0x1F200;
Array.Copy(sav, shiftval + data_offset, data, 0, data.Length); //Copy HoF section of save into Data
Util.TranslateInterface(this, Main.curlanguage);
sav = (byte[])Main.savefile.Clone();
Array.Copy(sav, Main.SaveGame.HoF, data, 0, data.Length); //Copy HoF section of save into Data
Setup();
editor_spec = new object[]{
GB_OT,
@ -51,15 +48,10 @@ namespace PKHeX
catch (Exception e) { Util.Alert("Font loading failed...", e.ToString()); }
editing = true;
}
Form1 m_parent;
public byte[] sav = new byte[0x100000];
public int savindex; int shiftval;
public bool editing;
private int data_offset = 0x1E800;
private string[] types = Form1.types;
private string[] forms = Form1.forms;
private string[] gendersymbols = Form1.gendersymbols;
private string[] gendersymbols = Main.gendersymbols;
private byte[] data = new byte[0x1B40];
private object[] editor_spec;
@ -75,7 +67,7 @@ namespace PKHeX
#region Species
{
var species_list = Util.getCBList(Form1.specieslist, null);
var species_list = Util.getCBList(Main.specieslist, null);
species_list.RemoveAt(0); // Remove 0th Entry
CB_Species.DisplayMember = "Text";
CB_Species.ValueMember = "Value";
@ -87,17 +79,17 @@ namespace PKHeX
CB_Move1.DisplayMember = CB_Move2.DisplayMember = CB_Move3.DisplayMember = CB_Move4.DisplayMember = "Text";
CB_Move1.ValueMember = CB_Move2.ValueMember = CB_Move3.ValueMember = CB_Move4.ValueMember = "Value";
CB_Move1.DataSource = new BindingSource(m_parent.CB_Move1.DataSource, null);
CB_Move2.DataSource = new BindingSource(m_parent.CB_Move1.DataSource, null);
CB_Move3.DataSource = new BindingSource(m_parent.CB_Move1.DataSource, null);
CB_Move4.DataSource = new BindingSource(m_parent.CB_Move1.DataSource, null);
CB_Move1.DataSource = new BindingSource(Main.MoveDataSource, null);
CB_Move2.DataSource = new BindingSource(Main.MoveDataSource, null);
CB_Move3.DataSource = new BindingSource(Main.MoveDataSource, null);
CB_Move4.DataSource = new BindingSource(Main.MoveDataSource, null);
}
#endregion
#region Items
{
CB_HeldItem.DisplayMember = "Text";
CB_HeldItem.ValueMember = "Value";
CB_HeldItem.DataSource = new BindingSource(m_parent.CB_HeldItem.DataSource, null);
CB_HeldItem.DataSource = new BindingSource(Main.ItemDataSource, null);
}
#endregion
}
@ -107,7 +99,7 @@ namespace PKHeX
}
private void B_Close_Click(object sender, EventArgs e)
{
Array.Copy(data, 0, m_parent.savefile, shiftval + data_offset, data.Length);
Array.Copy(data, 0, Main.savefile, Main.SaveGame.HoF, data.Length);
Close();
}
private void displayEntry(object sender, EventArgs e)
@ -172,14 +164,14 @@ namespace PKHeX
string shinystr = (shiny == 1) ? "Yes" : "No";
s += "Name: " + nickname;
s += " (" + Form1.specieslist[species] + " - " + genderstr + ")" + Environment.NewLine;
s += " (" + Main.specieslist[species] + " - " + genderstr + ")" + Environment.NewLine;
s += "Level: " + level + Environment.NewLine;
s += "Shiny: " + shinystr + Environment.NewLine;
s += "Held Item: " + Form1.itemlist[helditem] + Environment.NewLine;
s += "Move 1: " + Form1.movelist[move1] + Environment.NewLine;
s += "Move 2: " + Form1.movelist[move2] + Environment.NewLine;
s += "Move 3: " + Form1.movelist[move3] + Environment.NewLine;
s += "Move 4: " + Form1.movelist[move4] + Environment.NewLine;
s += "Held Item: " + Main.itemlist[helditem] + Environment.NewLine;
s += "Move 1: " + Main.movelist[move1] + Environment.NewLine;
s += "Move 2: " + Main.movelist[move2] + Environment.NewLine;
s += "Move 3: " + Main.movelist[move3] + Environment.NewLine;
s += "Move 4: " + Main.movelist[move4] + Environment.NewLine;
s += "OT: " + OTname + " (" + TID + "/" + SID + ")" + Environment.NewLine;
s += Environment.NewLine;
@ -240,7 +232,7 @@ namespace PKHeX
CHK_Nicknamed.Checked = nick == 1;
m_parent.setForms(species, CB_Form);
Main.setForms(species, CB_Form);
CB_Form.SelectedIndex = (int)form;
setGenderLabel((int)gender);
updateNickname(sender, e);
@ -360,7 +352,7 @@ namespace PKHeX
else
{
// get language
string l = Form1.curlanguage;
string l = Main.curlanguage;
TB_Nickname.Text = Util.getStringList("Species", l)[species];
}
}
@ -371,7 +363,7 @@ namespace PKHeX
private void updateSpecies(object sender, EventArgs e)
{
int species = Util.getIndex(CB_Species);
m_parent.setForms(species, CB_Form);
Main.setForms(species, CB_Form);
updateNickname(null, null);
}
private void updateShiny(object sender, EventArgs e)
@ -449,7 +441,7 @@ namespace PKHeX
{
TextBox tb = (!(sender is TextBox)) ? TB_Nickname : (sender as TextBox);
// Special Character Form
if (ModifierKeys == Keys.Control && !Form1.specialChars)
if (ModifierKeys == Keys.Control && !Main.specialChars)
(new f2_Text(tb)).Show();
}
}

View file

@ -6,25 +6,11 @@ namespace PKHeX
{
public partial class SAV_Inventory : Form
{
public SAV_Inventory(Form1 frm1)
public SAV_Inventory()
{
InitializeComponent();
Util.TranslateInterface(this, Form1.curlanguage);
m_parent = frm1;
Array.Copy(m_parent.savefile, sav, 0x100000);
savindex = m_parent.savindex;
shiftval = savindex * 0x7F000;
if (m_parent.savegame_oras)
{
bagoffsets = new[]
{
0x05800,
0x05E40,
0x05FC0,
0x06170,
0x06270,
};
}
Util.TranslateInterface(this, Main.curlanguage);
sav = (byte[])Main.savefile.Clone();
getListItems();
getListKeyItems();
@ -36,15 +22,13 @@ namespace PKHeX
popItems();
B_DisplayItems.Text = Form1.itempouch[0];
B_DisplayMedicine.Text = Form1.itempouch[1];
B_DisplayTMHM.Text = Form1.itempouch[2];
B_DisplayBerries.Text = Form1.itempouch[3];
B_DisplayKeyItems.Text = Form1.itempouch[4];
B_DisplayItems.Text = Main.itempouch[0];
B_DisplayMedicine.Text = Main.itempouch[1];
B_DisplayTMHM.Text = Main.itempouch[2];
B_DisplayBerries.Text = Main.itempouch[3];
B_DisplayKeyItems.Text = Main.itempouch[4];
}
Form1 m_parent;
public byte[] sav = new byte[0x100000];
public int savindex; int shiftval;
public byte[] sav;
public string[] item_val;
public string[] keyitem_val;
@ -52,46 +36,38 @@ namespace PKHeX
public string[] medicine_val;
public string[] berries_val;
public int[] bagoffsets =
{
0x05800,
0x05E40,
0x05FC0,
0x06168,
0x06268,
};
// Initialize String Tables
private void getListItems()
{
ushort[] itemlist = (m_parent.savegame_oras) ? Legal.Pouch_Items_ORAS : Legal.Pouch_Items_XY;
ushort[] itemlist = (Main.SaveGame.ORAS) ? Legal.Pouch_Items_ORAS : Legal.Pouch_Items_XY;
item_val = new string[itemlist.Length];
for (int i = 0; i < itemlist.Length; i++)
item_val[i] = Form1.itemlist[itemlist[i]];
item_val[i] = Main.itemlist[itemlist[i]];
Array.Sort(item_val);
}
private void getListKeyItems()
{
ushort[] itemlist = (m_parent.savegame_oras) ? Legal.Pouch_Key_ORAS : Legal.Pouch_Key_XY;
ushort[] itemlist = (Main.SaveGame.ORAS) ? Legal.Pouch_Key_ORAS : Legal.Pouch_Key_XY;
keyitem_val = new string[itemlist.Length];
for (int i = 0; i < itemlist.Length; i++)
keyitem_val[i] = Form1.itemlist[itemlist[i]];
keyitem_val[i] = Main.itemlist[itemlist[i]];
Array.Sort(keyitem_val);
}
private void getListTMHM()
{
ushort[] itemlist = (m_parent.savegame_oras) ? Legal.Pouch_TMHM_ORAS : Legal.Pouch_TMHM_XY;
ushort[] itemlist = (Main.SaveGame.ORAS) ? Legal.Pouch_TMHM_ORAS : Legal.Pouch_TMHM_XY;
tmhm_val = new string[itemlist.Length];
for (int i = 0; i < itemlist.Length; i++)
tmhm_val[i] = Form1.itemlist[itemlist[i]];
tmhm_val[i] = Main.itemlist[itemlist[i]];
// Array.Sort(tmhm_val); Already sorted, keep HMs last.
}
private void getListMedicine()
{
ushort[] itemlist = (m_parent.savegame_oras) ? Legal.Pouch_Medicine_ORAS : Legal.Pouch_Medicine_XY;
ushort[] itemlist = (Main.SaveGame.ORAS) ? Legal.Pouch_Medicine_ORAS : Legal.Pouch_Medicine_XY;
medicine_val = new string[itemlist.Length];
for (int i = 0; i < itemlist.Length; i++)
medicine_val[i] = Form1.itemlist[itemlist[i]];
medicine_val[i] = Main.itemlist[itemlist[i]];
Array.Sort(medicine_val);
}
private void getListBerries()
@ -99,34 +75,34 @@ namespace PKHeX
ushort[] itemlist = Legal.Pouch_Berry_XY;
berries_val = new string[itemlist.Length];
for (int i = 0; i < itemlist.Length; i++)
berries_val[i] = Form1.itemlist[itemlist[i]];
berries_val[i] = Main.itemlist[itemlist[i]];
Array.Sort(berries_val);
}
// Populate DataGrid
private void popItems()
{
int offset = bagoffsets[0] + shiftval;
int offset = Main.SaveGame.Items.HeldItem;
populateList(item_val, offset, item_val.Length - 1); // max 400
}
private void popKeyItems()
{
int offset = bagoffsets[1] + shiftval;
int offset = Main.SaveGame.Items.KeyItem;
populateList(keyitem_val, offset, keyitem_val.Length - 1); // max 96
}
private void popTMHM()
{
int offset = bagoffsets[2] + shiftval;
int offset = Main.SaveGame.Items.TMHM;
populateList(tmhm_val, offset, tmhm_val.Length - 1);
}
private void popMedicine()
{
int offset = bagoffsets[3] + shiftval;
int offset = Main.SaveGame.Items.Medicine;
populateList(medicine_val, offset, medicine_val.Length - 1); // 64 total slots
}
private void popBerries()
{
int offset = bagoffsets[4] + shiftval;
int offset = Main.SaveGame.Items.Berry;
populateList(berries_val, offset, berries_val.Length - 1); // 102 slots
}
@ -164,7 +140,7 @@ namespace PKHeX
for (int i = 0; i < itemcount; i++)
{
int itemvalue = BitConverter.ToUInt16(sav, offset + i*4);
try { itemname = Form1.itemlist[itemvalue]; }
try { itemname = Main.itemlist[itemvalue]; }
catch
{
Util.Error("Unknown item detected.", "Item ID: " + itemvalue, "Item is after: " + itemname);
@ -195,25 +171,15 @@ namespace PKHeX
{
int offset = 0;
if (B_DisplayItems.ForeColor == Color.Red)
{
offset = bagoffsets[0] + shiftval;
}
offset = Main.SaveGame.Items.HeldItem;
else if (B_DisplayKeyItems.ForeColor == Color.Red)
{
offset = bagoffsets[1] + shiftval;
}
offset = Main.SaveGame.Items.KeyItem;
else if (B_DisplayTMHM.ForeColor == Color.Red)
{
offset = bagoffsets[2] + shiftval;
}
offset = Main.SaveGame.Items.TMHM;
else if (B_DisplayMedicine.ForeColor == Color.Red)
{
offset = bagoffsets[3] + shiftval;
}
offset = Main.SaveGame.Items.Medicine;
else if (B_DisplayBerries.ForeColor == Color.Red)
{
offset = bagoffsets[4] + shiftval;
}
offset = Main.SaveGame.Items.Berry;
// Fetch Data
int itemcount = dataGridView1.Rows.Count;
@ -221,7 +187,7 @@ namespace PKHeX
for (int i = 0; i < itemcount; i++)
{
string item = dataGridView1.Rows[i].Cells[0].Value.ToString();
int itemindex = Array.IndexOf(Form1.itemlist, item);
int itemindex = Array.IndexOf(Main.itemlist, item);
int itemcnt;
try
{ itemcnt = Convert.ToUInt16(dataGridView1.Rows[i].Cells[1].Value.ToString()); }
@ -235,29 +201,28 @@ namespace PKHeX
if (itemcnt == 0)
itemcnt++; // No 0 count of items
else if (itemcnt > 995)
itemcnt = 995;
itemcnt = 995; // cap out
// Write Data into Save File
Array.Copy(BitConverter.GetBytes(itemindex), 0, sav, offset + 4 * (i - emptyslots), 2); // item #
Array.Copy(BitConverter.GetBytes(itemcnt), 0, sav, offset + 4 * (i - emptyslots) + 2, 2); // count
Array.Copy(BitConverter.GetBytes((ushort)itemindex), 0, sav, offset + 4 * (i - emptyslots), 2); // item #
Array.Copy(BitConverter.GetBytes((ushort)itemcnt), 0, sav, offset + 4 * (i - emptyslots) + 2, 2); // count
}
// Delete Empty Trash
for (int i = itemcount - emptyslots; i < itemcount; i++)
{
Array.Copy(BitConverter.GetBytes(0), 0, sav, offset + 4 * i + 0, 2); // item #
Array.Copy(BitConverter.GetBytes(0), 0, sav, offset + 4 * i + 2, 2); // count
Array.Copy(BitConverter.GetBytes((ushort)0), 0, sav, offset + 4 * i + 0, 2); // item #
Array.Copy(BitConverter.GetBytes((ushort)0), 0, sav, offset + 4 * i + 2, 2); // count
}
// Load New Button Color, after finished we'll load the new data.
Button btn = sender as Button;
B_DisplayItems.ForeColor =
B_DisplayKeyItems.ForeColor =
B_DisplayTMHM.ForeColor =
B_DisplayMedicine.ForeColor =
B_DisplayBerries.ForeColor = Form1.defaultControlText;
B_DisplayBerries.ForeColor = Main.defaultControlText;
btn.ForeColor = Color.Red;
(sender as Button).ForeColor = Color.Red;
}
private void giveAll(string[] inarray, int count)
{
@ -275,7 +240,7 @@ namespace PKHeX
saveBag(sender);
popItems();
if (ModifierKeys == Keys.Alt)
giveAll(item_val,995);
giveAll(item_val, 995);
}
private void B_DisplayKeyItems_Click(object sender, EventArgs e)
{
@ -299,7 +264,7 @@ namespace PKHeX
saveBag(sender);
popMedicine();
if (ModifierKeys == Keys.Alt)
giveAll(medicine_val,995);
giveAll(medicine_val, 995);
}
private void B_DisplayBerries_Click(object sender, EventArgs e)
{
@ -307,7 +272,7 @@ namespace PKHeX
saveBag(sender);
popBerries();
if (ModifierKeys == Keys.Alt)
giveAll(berries_val,995);
giveAll(berries_val, 995);
}
private void B_Cancel_Click(object sender, EventArgs e)
{
@ -316,8 +281,8 @@ namespace PKHeX
private void B_Save_Click(object sender, EventArgs e)
{
saveBag(sender);
Array.Copy(sav, m_parent.savefile, 0x100000);
m_parent.savedited = true;
Array.Copy(sav, Main.savefile, Main.savefile.Length);
Main.savedited = true;
Close();
}
}

View file

@ -6,15 +6,12 @@ namespace PKHeX
{
public partial class SAV_OPower : Form
{
public SAV_OPower(Form1 frm1)
public SAV_OPower()
{
m_parent = frm1;
if (m_parent.savegame_oras) opoweroffset = 0x1C800;
InitializeComponent();
Util.TranslateInterface(this, Form1.curlanguage);
Util.TranslateInterface(this, Main.curlanguage);
LoadData();
}
Form1 m_parent;
private void B_Cancel_Click(object sender, EventArgs e)
{
@ -25,10 +22,9 @@ namespace PKHeX
SaveData();
Close();
}
private int opoweroffset = 0x1BE00;
private void LoadData()
{
int o = opoweroffset + m_parent.savindex * 0x7F000; // offset
int o = Main.SaveGame.OPower;
// Fill up the 17 o-powers
// 1 2 3 4 5 10 use 4 bytes, everything else uses 3
@ -53,17 +49,18 @@ namespace PKHeX
CB_14.SelectedIndex = getIndex(o, 3); o += 3; // 35-37
CB_15.SelectedIndex = getIndex(o, 3); o += 3; // 38-3A
CB_16.SelectedIndex = getIndex(o, 3); o += 3; // 3B-3D
CB_17.SelectedIndex = getIndex(o, 3); o += 3; // 3E-40
CB_17.SelectedIndex = getIndex(o, 3);//o += 3; // 3E-40
// Load Maxes
CHK_1.Checked = Convert.ToBoolean(m_parent.savefile[0x1BE00 + 0x00]);
CHK_2.Checked = Convert.ToBoolean(m_parent.savefile[0x1BE00 + 0x05]);
CHK_3.Checked = Convert.ToBoolean(m_parent.savefile[0x1BE00 + 0x0A]);
CHK_4.Checked = Convert.ToBoolean(m_parent.savefile[0x1BE00 + 0x0F]);
CHK_5.Checked = Convert.ToBoolean(m_parent.savefile[0x1BE00 + 0x14]);
CHK_6.Checked = Convert.ToBoolean(m_parent.savefile[0x1BE00 + 0x19]);
CHK_7.Checked = Convert.ToBoolean(m_parent.savefile[0x1BE00 + 0x26]);
CHK_8.Checked = Convert.ToBoolean(m_parent.savefile[0x1BE00 + 0x2B]);
o = Main.SaveGame.OPower;
CHK_1.Checked = Convert.ToBoolean(Main.savefile[o + 0x00]);
CHK_2.Checked = Convert.ToBoolean(Main.savefile[o + 0x05]);
CHK_3.Checked = Convert.ToBoolean(Main.savefile[o + 0x0A]);
CHK_4.Checked = Convert.ToBoolean(Main.savefile[o + 0x0F]);
CHK_5.Checked = Convert.ToBoolean(Main.savefile[o + 0x14]);
CHK_6.Checked = Convert.ToBoolean(Main.savefile[o + 0x19]);
CHK_7.Checked = Convert.ToBoolean(Main.savefile[o + 0x26]);
CHK_8.Checked = Convert.ToBoolean(Main.savefile[o + 0x2B]);
}
private void SaveData()
{
@ -79,7 +76,7 @@ namespace PKHeX
0x27,
0x2C,0x2F,0x32,0x35,0x38,0x3B,0x3E,
};
int o = opoweroffset + m_parent.savindex * 0x7F000; // offset
int o = Main.SaveGame.OPower; // offset
for (int i = 0; i < cba.Length; i++)
{
@ -88,19 +85,19 @@ namespace PKHeX
{
data[c] = 1;
}
Array.Copy(data, 0, m_parent.savefile, o + offsets[i], data.Length);
Array.Copy(data, 0, Main.savefile, o + offsets[i], data.Length);
}
// Save Maxes
m_parent.savefile[m_parent.savindex * 0x7F000 + opoweroffset + 0x00] = Convert.ToByte(CHK_1.Checked);
m_parent.savefile[m_parent.savindex * 0x7F000 + opoweroffset + 0x05] = Convert.ToByte(CHK_2.Checked);
m_parent.savefile[m_parent.savindex * 0x7F000 + opoweroffset + 0x0A] = Convert.ToByte(CHK_3.Checked);
m_parent.savefile[m_parent.savindex * 0x7F000 + opoweroffset + 0x0F] = Convert.ToByte(CHK_4.Checked);
m_parent.savefile[m_parent.savindex * 0x7F000 + opoweroffset + 0x14] = Convert.ToByte(CHK_5.Checked);
m_parent.savefile[m_parent.savindex * 0x7F000 + opoweroffset + 0x19] = Convert.ToByte(CHK_6.Checked);
m_parent.savefile[m_parent.savindex * 0x7F000 + opoweroffset + 0x26] = Convert.ToByte(CHK_7.Checked);
m_parent.savefile[m_parent.savindex * 0x7F000 + opoweroffset + 0x2B] = Convert.ToByte(CHK_8.Checked);
Main.savefile[o + 0x00] = Convert.ToByte(CHK_1.Checked);
Main.savefile[o + 0x05] = Convert.ToByte(CHK_2.Checked);
Main.savefile[o + 0x0A] = Convert.ToByte(CHK_3.Checked);
Main.savefile[o + 0x0F] = Convert.ToByte(CHK_4.Checked);
Main.savefile[o + 0x14] = Convert.ToByte(CHK_5.Checked);
Main.savefile[o + 0x19] = Convert.ToByte(CHK_6.Checked);
Main.savefile[o + 0x26] = Convert.ToByte(CHK_7.Checked);
Main.savefile[o + 0x2B] = Convert.ToByte(CHK_8.Checked);
}
private int getIndex(int o, int l)
{
@ -111,7 +108,7 @@ namespace PKHeX
byte[] _4 = { 01, 01, 01, 01, };
byte[] data = new byte[4];
Array.Copy(m_parent.savefile, o, data, 0, l);
Array.Copy(Main.savefile, o, data, 0, l);
if (data.SequenceEqual(_4)) return 4;
if (data.SequenceEqual(_3)) return 3;

View file

@ -6,23 +6,18 @@ namespace PKHeX
{
public partial class SAV_PokedexORAS : Form
{
public SAV_PokedexORAS(Form1 frm1)
public SAV_PokedexORAS()
{
InitializeComponent();
Util.TranslateInterface(this, Form1.curlanguage);
m_parent = frm1;
Array.Copy(m_parent.savefile, sav, sav.Length);
sv = m_parent.savindex * 0x7F000;
dexoffset += sv;
Util.TranslateInterface(this, Main.curlanguage);
sav = (byte[])Main.savefile.Clone();
Setup();
editing = false;
LB_Species.SelectedIndex = 0;
TB_Spinda.Text = BitConverter.ToUInt32(sav, dexoffset + 0x680).ToString("X8");
TB_Spinda.Text = BitConverter.ToUInt32(sav, Main.SaveGame.Spinda).ToString("X8");
}
private int dexoffset = 0x15000 + 0x5400;
Form1 m_parent;
public byte[] sav = new byte[0x100000];
public int sv;
public byte[] sav;
public bool[,] specbools = new bool[9, 0x60 * 8];
public bool[,] langbools = new bool[7, 0x60 * 8];
bool editing = true;
@ -35,7 +30,7 @@ namespace PKHeX
// Fill List
#region Species
{
var species_list = Util.getCBList(Form1.specieslist, null);
var species_list = Util.getCBList(Main.specieslist, null);
species_list.RemoveAt(0); // Remove 0th Entry
CB_Species.DisplayMember = "Text";
CB_Species.ValueMember = "Value";
@ -43,8 +38,8 @@ namespace PKHeX
}
#endregion
for (int i = 1; i < Form1.specieslist.Length; i++)
LB_Species.Items.Add(i.ToString("000") + " - " + Form1.specieslist[i]);
for (int i = 1; i < Main.specieslist.Length; i++)
LB_Species.Items.Add(i.ToString("000") + " - " + Main.specieslist[i]);
getBools();
}
@ -105,7 +100,7 @@ namespace PKHeX
// Load Encountered Count
editing = true;
MT_Count.Text = BitConverter.ToUInt16(sav, dexoffset + 0x686 + (pk - 1) * 2).ToString();
MT_Count.Text = BitConverter.ToUInt16(sav, Main.SaveGame.EncounterCount + (pk - 1) * 2).ToString();
editing = false;
}
private void removedropCB(object sender, KeyEventArgs e)
@ -146,7 +141,7 @@ namespace PKHeX
saveChanges();
// Return back to the parent savefile
Array.Copy(sav, m_parent.savefile, sav.Length);
Array.Copy(sav, Main.savefile, sav.Length);
Close();
}
private void saveChanges()
@ -161,7 +156,7 @@ namespace PKHeX
if (specbools[p, i])
sdata[i / 8] |= (byte)(1 << i % 8);
Array.Copy(sdata, 0, sav, sv + dexoffset + 0x8 + 0x60 * p, 0x60);
Array.Copy(sdata, 0, sav, Main.SaveGame.PokeDex + 0x8 + 0x60 * p, 0x60);
}
// Build new bool array for the Languages
@ -178,12 +173,12 @@ namespace PKHeX
if (languagedata[i])
ldata[i / 8] |= (byte)(1 << i % 8);
Array.Copy(ldata, 0, sav, sv + dexoffset + 0x400, 0x27C);
Array.Copy(ldata, 0, sav, Main.SaveGame.PokeDexLanguageFlags, 0x27C);
}
// Store Spinda Spot
uint PID = Util.getHEXval(TB_Spinda);
Array.Copy(BitConverter.GetBytes(PID), 0, sav, dexoffset + 0x680, 4);
Array.Copy(BitConverter.GetBytes(PID), 0, sav, Main.SaveGame.Spinda, 4);
}
private void getBools()
@ -192,7 +187,7 @@ namespace PKHeX
for (int i = 0; i < 9; i++)
{
byte[] data = new byte[0x60];
int offset = dexoffset + 0x8 + 0x60 * i;
int offset = Main.SaveGame.PokeDex + 0x8 + 0x60 * i;
Array.Copy(sav, offset, data, 0, 0x60);
BitArray BitRegion = new BitArray(data);
for (int b = 0; b < (0x60 * 8); b++)
@ -201,7 +196,7 @@ namespace PKHeX
// Fill Language arrays
byte[] langdata = new byte[0x280];
Array.Copy(sav, dexoffset + 0x400, langdata, 0, 0x280);
Array.Copy(sav, Main.SaveGame.PokeDexLanguageFlags, langdata, 0, 0x280);
BitArray LangRegion = new BitArray(langdata);
for (int b = 0; b < (721); b++) // 721 Species
for (int i = 0; i < 7; i++) // 7 Languages
@ -243,12 +238,12 @@ namespace PKHeX
// Copy Full Dex Byte Array
// Native Byte Writing
for (int i = 0; i < 0x5A; i++)
sav[sv + 0x1A400 + 8 + i] = 0xFF;
sav[sv + 8 + 0x1A45A] = 0x01;
sav[Main.SaveGame.PokeDex + 8 + i] = 0xFF;
// Write remainder
sav[Main.SaveGame.PokeDex + 8 + 0x5A] = 0x01;
// Midsection Writing
{
// starting at 0x15068;
#region Payload
uint[] payload =
{
@ -454,24 +449,25 @@ namespace PKHeX
};
#endregion
for (int i = 0; i < payload.Length; i++)
Array.Copy(BitConverter.GetBytes(payload[i]), 0, sav, sv + 0x5400 + 0x15068 + 4 * i, 4);
Array.Copy(BitConverter.GetBytes(payload[i]), 0, sav, Main.SaveGame.PokeDex + 68 + 4 * i, 4);
}
// Language Writing
for (int i = 0; i < 0x9D; i++)
Array.Copy(BitConverter.GetBytes(0xFFFFFFFF), 0, sav ,sv + 0x5400 + 0x15400 + 4 * i, 4);
Array.Copy(BitConverter.GetBytes(0x007FFFFF), 0, sav ,sv + 0x5400 + 0x15674, 4);
Array.Copy(BitConverter.GetBytes(0xFFFFFFFF), 0, sav, Main.SaveGame.PokeDexLanguageFlags + 4 * i, 4);
Array.Copy(BitConverter.GetBytes(0x007FFFFF), 0, sav, Main.SaveGame.PokeDexLanguageFlags + 4 * 0x9D, 4);
// Encounter Count Writing (999*all species)
for (int i = 0; i < 0x2D1; i++)
Array.Copy(BitConverter.GetBytes(999), 0, sav, sv + 0x5400 + 0x15686 + i * 2, 2);
Array.Copy(BitConverter.GetBytes(999), 0, sav, Main.SaveGame.EncounterCount + i * 2, 2);
// Turn off Italian Petlil
sav[0x1A9DF + sv] &= 0xFE;
sav[Main.SaveGame.PokeDexLanguageFlags + 0x1DF] &= 0xFE;
// Forms Bool Writing
for (int i = 0; i < 0x9C; i++)
sav[sv + 0x5400 + 0x15000 + 0x364 + i] = 0xFF;
sav[sv + 0x5400 + 0x15000 + 0x3FF] = 0x8F; // make sure we don't have FF because CGSE may screw up.
sav[Main.SaveGame.PokeDex + 0x364 + i] = 0xFF;
sav[Main.SaveGame.PokeDex + 0x3FF] = 0x8F; // make sure we don't have FF because CGSE may screw up.
// Fetch the dex bools
getBools();
@ -483,7 +479,7 @@ namespace PKHeX
private void changeEncounteredCount(object sender, EventArgs e)
{
if (!editing)
Array.Copy(BitConverter.GetBytes(Math.Min(0xFFFF, Util.ToUInt32(MT_Count))), 0, sav, dexoffset + 0x686 + (Util.getIndex(CB_Species) - 1) * 2, 2);
Array.Copy(BitConverter.GetBytes(Math.Min(0xFFFF, Util.ToUInt32(MT_Count))), 0, sav, Main.SaveGame.EncounterCount + (Util.getIndex(CB_Species) - 1) * 2, 2);
}
}
}

View file

@ -6,21 +6,17 @@ namespace PKHeX
{
public partial class SAV_PokedexXY : Form
{
public SAV_PokedexXY(Form1 frm1)
public SAV_PokedexXY()
{
InitializeComponent();
Util.TranslateInterface(this, Form1.curlanguage);
m_parent = frm1;
Array.Copy(m_parent.savefile, sav, sav.Length);
savshift = m_parent.savindex * 0x7F000;
Util.TranslateInterface(this, Main.curlanguage);
sav = (byte[])Main.savefile.Clone();
Setup();
editing = false;
LB_Species.SelectedIndex = 0;
TB_Spinda.Text = BitConverter.ToUInt32(sav, 0x1AA48 + Convert.ToInt16(m_parent.savegame_oras) * 0x38).ToString("X8");
TB_Spinda.Text = BitConverter.ToUInt32(sav, Main.SaveGame.Spinda).ToString("X8");
}
Form1 m_parent;
public byte[] sav = new byte[0x100000];
public int savshift;
public byte[] sav;
public bool[,] specbools = new bool[10, 0x60 * 8];
public bool[,] langbools = new bool[7, 0x60 * 8];
public bool[] foreignbools = new bool[0x52 * 8];
@ -34,7 +30,7 @@ namespace PKHeX
// Fill List
#region Species
{
var species_list = Util.getCBList(Form1.specieslist, null);
var species_list = Util.getCBList(Main.specieslist, null);
species_list.RemoveAt(0); // Remove 0th Entry
CB_Species.DisplayMember = "Text";
CB_Species.ValueMember = "Value";
@ -42,8 +38,8 @@ namespace PKHeX
}
#endregion
for (int i = 1; i < Form1.specieslist.Length; i++)
LB_Species.Items.Add(i.ToString("000") + " - " + Form1.specieslist[i]);
for (int i = 1; i < Main.specieslist.Length; i++)
LB_Species.Items.Add(i.ToString("000") + " - " + Main.specieslist[i]);
for (int i = 722; i <= 0x300; i++)
LB_Species.Items.Add(i.ToString("000") + " - ???");
@ -167,7 +163,7 @@ namespace PKHeX
saveChanges();
// Return back to the parent savefile
Array.Copy(sav, m_parent.savefile, sav.Length);
Array.Copy(sav, Main.savefile, sav.Length);
Close();
}
private void saveChanges()
@ -182,7 +178,7 @@ namespace PKHeX
if (specbools[p, i])
sdata[i / 8] |= (byte)(1 << i % 8);
Array.Copy(sdata, 0, sav, savshift + 0x1A408 + 0x60 * p, 0x60);
Array.Copy(sdata, 0, sav, Main.SaveGame.PokeDex + 8 + 0x60 * p, 0x60);
}
// Build new bool array for the Languages
@ -199,7 +195,7 @@ namespace PKHeX
if (languagedata[i])
ldata[i / 8] |= (byte)(1 << i % 8);
Array.Copy(ldata, 0, sav, savshift + 0x1A7C8, 0x280);
Array.Copy(ldata, 0, sav, Main.SaveGame.PokeDexLanguageFlags, 0x280);
}
// Return Foreign Array
@ -208,12 +204,12 @@ namespace PKHeX
for (int i = 0; i < 0x52 * 8; i++)
if (foreignbools[i])
foreigndata[i / 8] |= (byte)(1 << i % 8);
Array.Copy(foreigndata, 0, sav, savshift + 0x1AA4C, 0x52);
Array.Copy(foreigndata, 0, sav, Main.SaveGame.PokeDex + 0x64C, 0x52);
}
// Store Spinda Spot
uint PID = Util.getHEXval(TB_Spinda);
Array.Copy(BitConverter.GetBytes(PID), 0, sav, 0x1AA48 + Convert.ToInt16(m_parent.savegame_oras) * 0x38 + savshift, 4);
Array.Copy(BitConverter.GetBytes(PID), 0, sav, Main.SaveGame.Spinda, 4);
}
private void getBools()
@ -222,7 +218,7 @@ namespace PKHeX
for (int i = 0; i < 0xA; i++)
{
byte[] data = new byte[0x60];
Array.Copy(sav, savshift + 0x1A408 + 0x60 * i, data, 0, 0x60);
Array.Copy(sav, Main.SaveGame.PokeDex + 8 + 0x60 * i, data, 0, 0x60);
BitArray BitRegion = new BitArray(data);
for (int b = 0; b < (0x60 * 8); b++)
specbools[i, b] = BitRegion[b];
@ -230,7 +226,7 @@ namespace PKHeX
// Fill Language arrays
byte[] langdata = new byte[0x280];
Array.Copy(sav, savshift + 0x1A7C8, langdata, 0, 0x280);
Array.Copy(sav, Main.SaveGame.PokeDexLanguageFlags, langdata, 0, 0x280);
BitArray LangRegion = new BitArray(langdata);
for (int b = 0; b < (721); b++) // 721 Species
for (int i = 0; i < 7; i++) // 7 Languages
@ -239,7 +235,7 @@ namespace PKHeX
// Fill Foreign array
{
byte[] foreigndata = new byte[0x52];
Array.Copy(sav, savshift + 0x1AA4C, foreigndata, 0, 0x52);
Array.Copy(sav, Main.SaveGame.PokeDex + 0x64C, foreigndata, 0, 0x52);
BitArray ForeignRegion = new BitArray(foreigndata);
for (int b = 0; b < (0x52 * 8); b++)
foreignbools[b] = ForeignRegion[b];
@ -286,15 +282,15 @@ namespace PKHeX
byte[] fulldex = Properties.Resources.fulldex_XY;
if (ModifierKeys != Keys.Control)
{
Array.Copy(fulldex, 0x008, sav, savshift + 0x1A408, 0x638);
Array.Copy(fulldex, 0x008, sav, Main.SaveGame.PokeDex + 8, 0x638);
}
else
{
Array.Copy(fulldex, 0x008, sav, savshift + 0x1A408, 0x1E0); // Copy Partitions 1-5
Array.Copy(fulldex, 0x368, sav, savshift + 0x1A768, 0x2D8); // Copy A & language
Array.Copy(fulldex, 0x008, sav, Main.SaveGame.PokeDex + 8, 0x1E0); // Copy Partitions 1-5
Array.Copy(fulldex, 0x368, sav, Main.SaveGame.PokeDex + 0x368, 0x2D8); // Copy A & language
}
// Skip the unknown sections then
Array.Copy(fulldex, 0x64C, sav, savshift + 0x1AA4C, 0x054);
Array.Copy(fulldex, 0x64C, sav, Main.SaveGame.PokeDex + 0x64C, 0x054);
// Fetch the dex bools
getBools();

View file

@ -29,7 +29,7 @@
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SAV_Pokepuff));
this.dataGridView1 = new System.Windows.Forms.DataGridView();
this.dgv = new System.Windows.Forms.DataGridView();
this.B_Save = new System.Windows.Forms.Button();
this.B_Cancel = new System.Windows.Forms.Button();
this.B_All = new System.Windows.Forms.Button();
@ -37,31 +37,31 @@
this.B_None = new System.Windows.Forms.Button();
this.L_Count = new System.Windows.Forms.Label();
this.MT_CNT = new System.Windows.Forms.MaskedTextBox();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dgv)).BeginInit();
this.SuspendLayout();
//
// dataGridView1
// dgv
//
this.dataGridView1.AllowUserToAddRows = false;
this.dataGridView1.AllowUserToDeleteRows = false;
this.dataGridView1.AllowUserToResizeColumns = false;
this.dataGridView1.AllowUserToResizeRows = false;
this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)));
this.dataGridView1.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
this.dataGridView1.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None;
this.dataGridView1.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.ColumnHeadersVisible = false;
this.dataGridView1.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnEnter;
this.dataGridView1.Location = new System.Drawing.Point(12, 43);
this.dataGridView1.MultiSelect = false;
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.RowHeadersVisible = false;
this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect;
this.dataGridView1.ShowEditingIcon = false;
this.dataGridView1.Size = new System.Drawing.Size(200, 186);
this.dataGridView1.TabIndex = 11;
this.dataGridView1.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dropclick);
this.dgv.AllowUserToAddRows = false;
this.dgv.AllowUserToDeleteRows = false;
this.dgv.AllowUserToResizeColumns = false;
this.dgv.AllowUserToResizeRows = false;
this.dgv.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)));
this.dgv.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
this.dgv.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None;
this.dgv.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
this.dgv.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgv.ColumnHeadersVisible = false;
this.dgv.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnEnter;
this.dgv.Location = new System.Drawing.Point(12, 43);
this.dgv.MultiSelect = false;
this.dgv.Name = "dgv";
this.dgv.RowHeadersVisible = false;
this.dgv.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect;
this.dgv.ShowEditingIcon = false;
this.dgv.Size = new System.Drawing.Size(200, 186);
this.dgv.TabIndex = 11;
this.dgv.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dropclick);
//
// B_Save
//
@ -148,7 +148,7 @@
this.Controls.Add(this.B_All);
this.Controls.Add(this.B_Cancel);
this.Controls.Add(this.B_Save);
this.Controls.Add(this.dataGridView1);
this.Controls.Add(this.dgv);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(240, 750);
@ -157,7 +157,7 @@
this.Name = "SAV_Pokepuff";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Poké Puffs Editor";
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dgv)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@ -165,7 +165,7 @@
#endregion
private System.Windows.Forms.DataGridView dataGridView1;
private System.Windows.Forms.DataGridView dgv;
private System.Windows.Forms.Button B_Save;
private System.Windows.Forms.Button B_Cancel;
private System.Windows.Forms.Button B_All;

View file

@ -5,14 +5,13 @@ namespace PKHeX
{
public partial class SAV_Pokepuff : Form
{
public SAV_Pokepuff(Form1 frm1)
public SAV_Pokepuff()
{
InitializeComponent();
Util.TranslateInterface(this, Form1.curlanguage);
m_parent = frm1;
Array.Copy(m_parent.savefile, sav, 0x100000);
pfa = Form1.puffs;
savindex = m_parent.savindex;
Util.TranslateInterface(this, Main.curlanguage);
sav = (byte[])Main.savefile.Clone();
pfa = Main.puffs;
pfa[0] = "---";
Setup();
@ -20,9 +19,7 @@ namespace PKHeX
new ToolTip().SetToolTip(B_All, "Hold CTRL to give Deluxe instead of Supreme.");
}
private Form1 m_parent;
public byte[] sav = new byte[0x100000];
public int savindex;
public byte[] sav;
private string[] pfa =
{
"Empty",
@ -34,8 +31,8 @@ namespace PKHeX
};
private void Setup()
{
dataGridView1.Rows.Clear();
dataGridView1.Columns.Clear();
dgv.Rows.Clear();
dgv.Columns.Clear();
DataGridViewColumn dgvIndex = new DataGridViewTextBoxColumn();
{
@ -57,24 +54,21 @@ namespace PKHeX
dgvPuff.Width = 135;
dgvPuff.FlatStyle = FlatStyle.Flat;
}
dataGridView1.Columns.Add(dgvIndex);
dataGridView1.Columns.Add(dgvPuff);
dgv.Columns.Add(dgvIndex);
dgv.Columns.Add(dgvPuff);
dataGridView1.Rows.Add(100);
int offset = 0x5400 + 0x7F000*savindex;
dgv.Rows.Add(100);
for (int i = 0; i < 100; i++)
{
dataGridView1.Rows[i].Cells[0].Value = (i + 1).ToString();
dataGridView1.Rows[i].Cells[1].Value = pfa[sav[offset + i]];
dgv.Rows[i].Cells[0].Value = (i + 1).ToString();
dgv.Rows[i].Cells[1].Value = pfa[sav[Main.SaveGame.Puff + i]];
}
MT_CNT.Text = BitConverter.ToUInt32(sav, offset + 100).ToString("0");
MT_CNT.Text = BitConverter.ToUInt32(sav, Main.SaveGame.Puff + 100).ToString("0");
}
private void dropclick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex != 1) return;
ComboBox comboBox = (ComboBox) dataGridView1.EditingControl;
comboBox.DroppedDown = true;
((ComboBox)(sender as DataGridView).EditingControl).DroppedDown = true;
}
private void B_Cancel_Click(object sender, EventArgs e)
@ -94,7 +88,7 @@ namespace PKHeX
for (int i = 0; i < 100; i++)
newpuffs[i] = (byte) (Util.rnd32()%basemod + basepuff);
Array.Copy(newpuffs, 0, sav, 0x5400 + savindex*0x7F000, 100);
Array.Copy(newpuffs, 0, sav, Main.SaveGame.Puff, 100);
Setup();
}
private void B_None_Click(object sender, EventArgs e)
@ -105,7 +99,7 @@ namespace PKHeX
newpuffs[2] = 3;
newpuffs[3] = 4;
newpuffs[4] = 5;
Array.Copy(newpuffs, 0, sav, 0x5400 + savindex*0x7F000, 100);
Array.Copy(newpuffs, 0, sav, Main.SaveGame.Puff, 100);
Setup();
}
private void B_Sort_Click(object sender, EventArgs e)
@ -115,7 +109,7 @@ namespace PKHeX
{
for (int i = 0; i < 100; i++)
{
string puff = dataGridView1.Rows[i].Cells[1].Value.ToString();
string puff = dgv.Rows[i].Cells[1].Value.ToString();
puffarray[i] = (byte) Array.IndexOf(pfa, puff);
}
Array.Sort(puffarray);
@ -126,7 +120,7 @@ namespace PKHeX
int count = 0;
for (int i = 0; i < 100; i++)
{
string puff = dataGridView1.Rows[i].Cells[1].Value.ToString();
string puff = dgv.Rows[i].Cells[1].Value.ToString();
byte puffval = (byte) Array.IndexOf(pfa, puff);
if (puffval == 0) continue;
puffarray[count] = puffval;
@ -136,7 +130,7 @@ namespace PKHeX
Array.Sort(puffarray);
Array.Resize(ref puffarray, 100);
}
Array.Copy(puffarray, 0, sav, 0x5400 + savindex*0x7F000, 100);
Array.Copy(puffarray, 0, sav, Main.SaveGame.Puff, 100);
Setup();
}
private void B_Save_Click(object sender, EventArgs e)
@ -145,7 +139,7 @@ namespace PKHeX
int emptyslots = 0;
for (int i = 0; i < 100; i++)
{
string puff = dataGridView1.Rows[i].Cells[1].Value.ToString();
string puff = dgv.Rows[i].Cells[1].Value.ToString();
if (Array.IndexOf(pfa, puff) == 0)
{
emptyslots++;
@ -154,9 +148,9 @@ namespace PKHeX
puffarray[i - emptyslots] = (byte) Array.IndexOf(pfa, puff);
}
Array.Copy(puffarray, 0, sav, 0x5400 + savindex*0x7F000, 100);
Array.Copy(sav, m_parent.savefile, 0x100000);
m_parent.savedited = true;
Array.Copy(puffarray, 0, sav, Main.SaveGame.Puff, 100);
Array.Copy(sav, Main.savefile, sav.Length);
Main.savedited = true;
Close();
}
}

View file

@ -6,13 +6,12 @@ namespace PKHeX
{
public partial class SAV_SecretBase : Form
{
public SAV_SecretBase(Form1 frm1)
public SAV_SecretBase()
{
InitializeComponent();
Util.TranslateInterface(this, Form1.curlanguage);
m_parent = frm1;
Array.Copy(m_parent.savefile, sav, 0x100000);
abilitylist = Form1.abilitylist;
Util.TranslateInterface(this, Main.curlanguage);
sav = (byte[])Main.savefile.Clone();
abilitylist = Main.abilitylist;
setupComboBoxes();
popFavorite();
@ -20,14 +19,11 @@ namespace PKHeX
LB_Favorite.SelectedIndex = 0;
// MT_Flags.Text = BitConverter.ToUInt16(sav, 0x24800 + 0x140).ToString(); PSS Stat transmitted
MT_Flags.Text = BitConverter.ToUInt32(sav, 0x2942C).ToString(); // read counter
MT_Flags.Text = BitConverter.ToUInt32(sav, Main.SaveGame.SecretBase + 0x62C).ToString(); // read counter
B_SAV2FAV(null, null);
}
Form1 m_parent;
public byte[] sav = new byte[0x100000];
public byte[] sav;
public bool editing;
private const int sv = 0;
private const int fav_offset = 0x23A00;
private bool loading = true;
public static string[] abilitylist = { };
@ -37,32 +33,32 @@ namespace PKHeX
{
CB_Ball.DisplayMember = "Text";
CB_Ball.ValueMember = "Value";
CB_Ball.DataSource = new BindingSource(m_parent.CB_Ball.DataSource, null);
CB_Ball.DataSource = new BindingSource(Main.BallDataSource, null);
}
{
CB_HeldItem.DisplayMember = "Text";
CB_HeldItem.ValueMember = "Value";
CB_HeldItem.DataSource = new BindingSource(m_parent.CB_HeldItem.DataSource, null);
CB_HeldItem.DataSource = new BindingSource(Main.ItemDataSource, null);
}
{
CB_Species.DisplayMember = "Text";
CB_Species.ValueMember = "Value";
CB_Species.DataSource = new BindingSource(m_parent.CB_Species.DataSource, null);
CB_Species.DataSource = new BindingSource(Main.SpeciesDataSource, null);
}
{
CB_Nature.DisplayMember = "Text";
CB_Nature.ValueMember = "Value";
CB_Nature.DataSource = new BindingSource(m_parent.CB_Nature.DataSource, null);
CB_Nature.DataSource = new BindingSource(Main.NatureDataSource, null);
}
#region Moves
{
CB_Move1.DisplayMember = CB_Move2.DisplayMember = CB_Move3.DisplayMember = CB_Move4.DisplayMember = "Text";
CB_Move1.ValueMember = CB_Move2.ValueMember = CB_Move3.ValueMember = CB_Move4.ValueMember = "Value";
CB_Move1.DataSource = new BindingSource(m_parent.CB_Move1.DataSource, null);
CB_Move2.DataSource = new BindingSource(m_parent.CB_Move1.DataSource, null);
CB_Move3.DataSource = new BindingSource(m_parent.CB_Move1.DataSource, null);
CB_Move4.DataSource = new BindingSource(m_parent.CB_Move1.DataSource, null);
CB_Move1.DataSource = new BindingSource(Main.MoveDataSource, null);
CB_Move2.DataSource = new BindingSource(Main.MoveDataSource, null);
CB_Move3.DataSource = new BindingSource(Main.MoveDataSource, null);
CB_Move4.DataSource = new BindingSource(Main.MoveDataSource, null);
}
#endregion
}
@ -72,13 +68,13 @@ namespace PKHeX
{
LB_Favorite.Items.Clear();
const int playeroff = fav_offset + 0x5400 + 0x326;
const int favoff = fav_offset + 0x5400 + 0x63A;
string OT = Util.TrimFromZero(Encoding.Unicode.GetString(sav, sv + playeroff + 0x218, 0x1A));
int playeroff = Main.SaveGame.SecretBase + 0x326;
int favoff = Main.SaveGame.SecretBase + 0x63A;
string OT = Util.TrimFromZero(Encoding.Unicode.GetString(sav, playeroff + 0x218, 0x1A));
LB_Favorite.Items.Add("* " + OT);
for (int i = 0; i < 30; i++)
{
string BaseTrainer = Util.TrimFromZero(Encoding.Unicode.GetString(sav, sv + favoff + i * 0x3E0 + 0x218, 0x1A));
string BaseTrainer = Util.TrimFromZero(Encoding.Unicode.GetString(sav, favoff + i * 0x3E0 + 0x218, 0x1A));
if (BaseTrainer.Length < 1 || BaseTrainer[0] == '\0')
BaseTrainer = "Empty";
LB_Favorite.Items.Add(i + " " + BaseTrainer);
@ -89,24 +85,24 @@ namespace PKHeX
loading = true;
int index = LB_Favorite.SelectedIndex;
if (index < 0) return;
int offset = fav_offset + 0x5400 + 0x25A;
int offset = Main.SaveGame.SecretBase + 0x25A;
// Base Offset Changing
if (index == 0) offset = fav_offset + 0x5400 + 0x326;
if (index == 0) offset = Main.SaveGame.SecretBase + 0x326;
else offset += 0x3E0 * index;
string TrainerName = Util.TrimFromZero(Encoding.Unicode.GetString(sav, sv + offset + 0x218, 0x1A));
string TrainerName = Util.TrimFromZero(Encoding.Unicode.GetString(sav, offset + 0x218, 0x1A));
TB_FOT.Text = TrainerName;
TB_FT1.Text = Util.TrimFromZero(Encoding.Unicode.GetString(sav, sv + offset + 0x232 + 0x22 * 0, 0x22));
TB_FT2.Text = Util.TrimFromZero(Encoding.Unicode.GetString(sav, sv + offset + 0x232 + 0x22 * 1, 0x22));
TB_FT1.Text = Util.TrimFromZero(Encoding.Unicode.GetString(sav, offset + 0x232 + 0x22 * 0, 0x22));
TB_FT2.Text = Util.TrimFromZero(Encoding.Unicode.GetString(sav, offset + 0x232 + 0x22 * 1, 0x22));
string saying1 = Util.TrimFromZero(Encoding.Unicode.GetString(sav, sv + offset + 0x276 + 0x22 * 0, 0x22));
string saying2 = Util.TrimFromZero(Encoding.Unicode.GetString(sav, sv + offset + 0x276 + 0x22 * 1, 0x22));
string saying3 = Util.TrimFromZero(Encoding.Unicode.GetString(sav, sv + offset + 0x276 + 0x22 * 2, 0x22));
string saying4 = Util.TrimFromZero(Encoding.Unicode.GetString(sav, sv + offset + 0x276 + 0x22 * 3, 0x22));
string saying1 = Util.TrimFromZero(Encoding.Unicode.GetString(sav, offset + 0x276 + 0x22 * 0, 0x22));
string saying2 = Util.TrimFromZero(Encoding.Unicode.GetString(sav, offset + 0x276 + 0x22 * 1, 0x22));
string saying3 = Util.TrimFromZero(Encoding.Unicode.GetString(sav, offset + 0x276 + 0x22 * 2, 0x22));
string saying4 = Util.TrimFromZero(Encoding.Unicode.GetString(sav, offset + 0x276 + 0x22 * 3, 0x22));
int baseloc = BitConverter.ToInt16(sav, sv + offset);
int baseloc = BitConverter.ToInt16(sav, offset);
NUD_FBaseLocation.Value = baseloc;
TB_FSay1.Text = saying1; TB_FSay2.Text = saying2; TB_FSay3.Text = saying3; TB_FSay4.Text = saying4;
@ -115,7 +111,7 @@ namespace PKHeX
objdata = new byte[25, 12];
for (int i = 0; i < 25; i++)
for (int z = 0; z < 12; z++)
objdata[i, z] = sav[sv + offset + 2 + 12 * i + z];
objdata[i, z] = sav[offset + 2 + 12 * i + z];
NUD_FObject.Value = 1; // Trigger Update
changeObjectIndex(null, null);
@ -126,7 +122,7 @@ namespace PKHeX
if (index > 0)
for (int i = 0; i < 3; i++)
for (int z = 0; z < 0x34; z++)
pkmdata[i, z] = sav[sv + offset + 0x32E + 0x34 * i + z];
pkmdata[i, z] = sav[offset + 0x32E + 0x34 * i + z];
NUD_FPKM.Value = 1;
changeFavPKM(null, null); // Trigger Update
@ -146,54 +142,54 @@ namespace PKHeX
if (LB_Favorite.Items[index].ToString().Substring(LB_Favorite.Items[index].ToString().Length - 5, 5) == "Empty")
{ Util.Error("Sorry, no overwriting an empty base with someone else's."); return; }
if (index < 0) return;
int offset = fav_offset + 0x5400 + 0x25A;
int offset = Main.SaveGame.SecretBase + 0x25A;
// Base Offset Changing
if (index == 0)
offset = fav_offset + 0x5400 + 0x326;
offset = Main.SaveGame.SecretBase + 0x326;
else offset += 0x3E0 * index;
string TrainerName = TB_FOT.Text;
byte[] tr = Encoding.Unicode.GetBytes(TrainerName);
Array.Resize(ref tr, 0x22); Array.Copy(tr, 0, sav, sv + offset + 0x218, 0x1A);
Array.Resize(ref tr, 0x22); Array.Copy(tr, 0, sav, offset + 0x218, 0x1A);
string team1 = TB_FT1.Text;
string team2 = TB_FT2.Text;
byte[] t1 = Encoding.Unicode.GetBytes(team1);
Array.Resize(ref t1, 0x22); Array.Copy(t1, 0, sav, sv + offset + 0x232 + 0x22 * 0, 0x22);
Array.Resize(ref t1, 0x22); Array.Copy(t1, 0, sav, offset + 0x232 + 0x22 * 0, 0x22);
byte[] t2 = Encoding.Unicode.GetBytes(team2);
Array.Resize(ref t2, 0x22); Array.Copy(t2, 0, sav, sv + offset + 0x232 + 0x22 * 1, 0x22);
Array.Resize(ref t2, 0x22); Array.Copy(t2, 0, sav, offset + 0x232 + 0x22 * 1, 0x22);
string saying1 = TB_FSay1.Text;
string saying2 = TB_FSay2.Text;
string saying3 = TB_FSay3.Text;
string saying4 = TB_FSay4.Text;
byte[] s1 = Encoding.Unicode.GetBytes(saying1);
Array.Resize(ref s1, 0x22); Array.Copy(s1, 0, sav, sv + offset + 0x276 + 0x22 * 0, 0x22);
Array.Resize(ref s1, 0x22); Array.Copy(s1, 0, sav, offset + 0x276 + 0x22 * 0, 0x22);
byte[] s2 = Encoding.Unicode.GetBytes(saying2);
Array.Resize(ref s2, 0x22); Array.Copy(s2, 0, sav, sv + offset + 0x276 + 0x22 * 1, 0x22);
Array.Resize(ref s2, 0x22); Array.Copy(s2, 0, sav, offset + 0x276 + 0x22 * 1, 0x22);
byte[] s3 = Encoding.Unicode.GetBytes(saying3);
Array.Resize(ref s3, 0x22); Array.Copy(s3, 0, sav, sv + offset + 0x276 + 0x22 * 2, 0x22);
Array.Resize(ref s3, 0x22); Array.Copy(s3, 0, sav, offset + 0x276 + 0x22 * 2, 0x22);
byte[] s4 = Encoding.Unicode.GetBytes(saying4);
Array.Resize(ref s4, 0x22); Array.Copy(s4, 0, sav, sv + offset + 0x276 + 0x22 * 3, 0x22);
Array.Resize(ref s4, 0x22); Array.Copy(s4, 0, sav, offset + 0x276 + 0x22 * 3, 0x22);
int baseloc = (int)NUD_FBaseLocation.Value;
if (baseloc < 3) baseloc = 0; // skip 1/2 baselocs as they are dummied out ingame.
Array.Copy(BitConverter.GetBytes(baseloc), 0, sav, sv + offset, 2);
Array.Copy(BitConverter.GetBytes(baseloc), 0, sav, offset, 2);
TB_FOT.Text = TrainerName; TB_FSay1.Text = saying1; TB_FSay2.Text = saying2; TB_FSay3.Text = saying3; TB_FSay4.Text = saying4;
// Copy back Objects
for (int i = 0; i < 25; i++)
for (int z = 0; z < 12; z++)
sav[sv + offset + 2 + 12 * i + z] = objdata[i, z];
sav[offset + 2 + 12 * i + z] = objdata[i, z];
if (GB_PKM.Enabled) // Copy pkm data back in
{
saveFavPKM();
for (int i = 0; i < 3; i++)
for (int z = 0; z < 0x34; z++)
sav[sv + offset + 0x32E + 0x34 * i + z] = pkmdata[i, z];
sav[offset + 0x32E + 0x34 * i + z] = pkmdata[i, z];
}
popFavorite();
LB_Favorite.SelectedIndex = index;
@ -207,22 +203,21 @@ namespace PKHeX
private void B_Save_Click(object sender, EventArgs e)
{
uint flags = Util.ToUInt32(MT_Flags);
Array.Copy(BitConverter.GetBytes(flags), 0, sav, 0x24800 + 0x140, 4); // write pss
Array.Copy(BitConverter.GetBytes(flags), 0, sav, 0x2942C, 4); // write counter
Array.Copy(sav, m_parent.savefile, 0x100000);
m_parent.savedited = true;
Array.Copy(BitConverter.GetBytes(flags), 0, sav, Main.SaveGame.PSSStats + 0x140, 4); // write pss
Array.Copy(BitConverter.GetBytes(flags), 0, sav, Main.SaveGame.SecretBase + 0x62C, 4); // write counter
Array.Copy(sav, Main.savefile, sav.Length);
Main.savedited = true;
Close();
}
private void B_GiveDecor_Click(object sender, EventArgs e)
{
const int offset = sv + 0x23A00 + 0x5400;
for (int i = 0; i < 173; i++)
{
// int qty = BitConverter.ToUInt16(sav, offset + i * 4);
// int has = BitConverter.ToUInt16(sav, offset + i * 4 + 2);
sav[offset + i * 4] = 25;
sav[offset + i * 4 + 2] = 1;
sav[Main.SaveGame.SecretBase + i * 4] = 25;
sav[Main.SaveGame.SecretBase + i * 4 + 2] = 1;
}
}
@ -416,18 +411,18 @@ namespace PKHeX
CHK_Shiny.Checked = isshiny;
// Set Form
m_parent.setForms(spec, CB_Form);
Main.setForms(spec, CB_Form);
int form = genform >> 3;
CB_Form.SelectedIndex = form;
// Set Ability
m_parent.setAbilityList(MT_AbilNo, spec, CB_Ability, CB_Form);
Main.setAbilityList(MT_AbilNo, spec, CB_Ability, CB_Form);
}
private void updateSpecies(object sender, EventArgs e)
{
// Get Forms for Given Species
m_parent.setForms(Util.getIndex(CB_Species), CB_Form);
Main.setForms(Util.getIndex(CB_Species), CB_Form);
// Check for Gender Changes
// Get Gender Threshold
@ -442,15 +437,15 @@ namespace PKHeX
genderflag = 0;
setGenderLabel();
m_parent.setAbilityList(MT_AbilNo, Util.getIndex(CB_Species), CB_Ability, CB_Form);
Main.setAbilityList(MT_AbilNo, Util.getIndex(CB_Species), CB_Ability, CB_Form);
}
private void updateForm(object sender, EventArgs e)
{
m_parent.setAbilityList(MT_AbilNo, Util.getIndex(CB_Species), CB_Ability, CB_Form);
Main.setAbilityList(MT_AbilNo, Util.getIndex(CB_Species), CB_Ability, CB_Form);
// If form has a single gender, account for it.
if (PKX.getGender(CB_Form.Text) < 2)
Label_Gender.Text = Form1.gendersymbols[CB_Form.SelectedIndex];
Label_Gender.Text = Main.gendersymbols[CB_Form.SelectedIndex];
}
private int genderflag;
@ -464,11 +459,11 @@ namespace PKHeX
return;
if (gt < 256) // If not a single gender(less) species:
Label_Gender.Text = Form1.gendersymbols[PKX.getGender(Label_Gender.Text) ^ 1];
Label_Gender.Text = Main.gendersymbols[PKX.getGender(Label_Gender.Text) ^ 1];
}
private void setGenderLabel()
{
Label_Gender.Text = Form1.gendersymbols[genderflag];
Label_Gender.Text = Main.gendersymbols[genderflag];
}
private void B_FDelete_Click(object sender, EventArgs e)
@ -476,8 +471,8 @@ namespace PKHeX
if (LB_Favorite.SelectedIndex < 1) { Util.Alert("Cannot delete your Secret Base."); return; }
int index = LB_Favorite.SelectedIndex - 1;
const int favoff = fav_offset + 0x5400 + 0x63A;
string BaseTrainer = Util.TrimFromZero(Encoding.Unicode.GetString(sav, sv + favoff + index * 0x3E0 + 0x218, 0x1A));
int favoff = Main.SaveGame.SecretBase + 0x63A;
string BaseTrainer = Util.TrimFromZero(Encoding.Unicode.GetString(sav, favoff + index * 0x3E0 + 0x218, 0x1A));
if (BaseTrainer.Length < 1 || BaseTrainer[0] == '\0')
BaseTrainer = "Empty";
@ -487,7 +482,7 @@ namespace PKHeX
return;
const int max = 29;
const int size = 0x3E0;
int offset = sv + favoff + index * size;
int offset = favoff + index * size;
if (index != max) Array.Copy(sav, offset + size, sav, offset, size * (max - index));
// Ensure Last Entry is Cleared
Array.Copy(new byte[size], 0, sav, size * max, size);

View file

@ -5,30 +5,26 @@ namespace PKHeX
{
public partial class SAV_SuperTrain : Form
{
public SAV_SuperTrain(Form1 frm1)
public SAV_SuperTrain(Main frm1)
{
m_parent = frm1;
savindex = m_parent.savindex;
Array.Copy(m_parent.savefile, sav, 0x100000);
if (m_parent.savegame_oras) data_offset = 0x25600;
trba = Form1.trainingbags;
sav = (byte[])Main.savefile.Clone();
trba = Main.trainingbags;
trba[0] = "---";
offsetTime = data_offset + 0x08 + 0x7F000 * savindex;
offsetSpec = data_offset + 0x188 + 0x7F000 * savindex;
offsetVal = data_offset + 0x18A + 0x7F000 * savindex;
offsetTime = Main.SaveGame.SuperTrain + 0x08;
offsetSpec = Main.SaveGame.SuperTrain + 0x188;
offsetVal = Main.SaveGame.SuperTrain + 0x18A;
InitializeComponent();
Util.TranslateInterface(this, Form1.curlanguage);
string[] stages = Form1.trainingstage;
Util.TranslateInterface(this, Main.curlanguage);
string[] stages = Main.trainingstage;
listBox1.Items.Clear();
for (int i = 0; i < 30; i++)
listBox1.Items.Add((i + 1).ToString("00") + " - " + stages[i + 2]);
setup();
}
Form1 m_parent;
public byte[] sav = new byte[0x100000];
public int savindex;
private int data_offset = 0x24600;
Main m_parent;
public byte[] sav;
private string[] trba = {
"Empty",
"HP Bag S","HP Bag M","HP Bag L",
@ -91,7 +87,7 @@ namespace PKHeX
dataGridView1.Columns.Add(dgvBag);
dataGridView1.Rows.Add(12);
int offset = data_offset + 0x308 + 0x7F000 * savindex;
int offset = Main.SaveGame.SuperTrain + 0x308;
for (int i = 0; i < 12; i++)
{
dataGridView1.Rows[i].Cells[0].Value = (i + 1).ToString();
@ -131,7 +127,7 @@ namespace PKHeX
}
bagarray[i - emptyslots] = (byte)Array.IndexOf(trba, bag);
}
int offsetTime = data_offset + 0x10 + 0x7F000 * savindex;
int offsetTime = Main.SaveGame.SuperTrain + 0x10;
try
{
byte[] data = BitConverter.GetBytes(Single.Parse(TB_Time1.Text));
@ -147,14 +143,14 @@ namespace PKHeX
}
catch { }
{
int offsetSpec = data_offset + 0x188 + 0x7F000 * savindex;
int offsetSpec = Main.SaveGame.SuperTrain + 0x188;
byte[] data = BitConverter.GetBytes(Convert.ToUInt16(CB_S2.SelectedValue.ToString()));
Array.Resize(ref data, 2);
Array.Copy(data, 0, sav, offsetSpec + 4 * 30, 2);
}
Array.Copy(bagarray, 0, sav, data_offset + 0x308 + savindex * 0x7F000, 12);
Array.Copy(sav, m_parent.savefile, 0x100000);
m_parent.savedited = true;
Array.Copy(bagarray, 0, sav, Main.SaveGame.SuperTrain + 0x308, 12);
Array.Copy(sav, Main.savefile, Main.savefile.Length);
Main.savedited = true;
Close();
}
private void B_Cancel_Click(object sender, EventArgs e)

View file

@ -8,27 +8,17 @@ namespace PKHeX
{
public partial class SAV_Trainer : Form
{
private const int TrainerCard = 0x19400;
private const int Trainer1 = 0x6800;
private const int Trainer2 = 0x9600;
private int Maison = 0x205C0;
private int VivillonForm = 0x9650;
public SAV_Trainer(Form1 frm1)
public SAV_Trainer()
{
InitializeComponent();
if (!Form1.unicode)
if (!Main.unicode)
try { TB_OTName.Font = PKX.getPKXFont(11); }
catch (Exception e) { Util.Alert("Font loading failed...", e.ToString()); }
Util.TranslateInterface(this, Form1.curlanguage);
m_parent = frm1;
Array.Copy(m_parent.savefile, sav, 0x100000);
savindex = m_parent.savindex;
savshift = savindex * 0x7F000;
if (m_parent.savegame_oras)
Util.TranslateInterface(this, Main.curlanguage);
sav = (byte[])Main.savefile.Clone();
if (Main.SaveGame.ORAS)
{
psssatoffset = 0x24800; Maison += 0xA00;
VivillonForm = 0x9644;
Width = (int)((float)Width * 428 / 590);
CB_Multi.Enabled = true;
L_MultiplayerSprite.Enabled = true; // Multiplayer Sprite Label
@ -41,7 +31,7 @@ namespace PKHeX
getComboBoxes();
getTextBoxes();
getBadges();
GB_Map.Enabled = !Form1.ramsavloaded;
GB_Map.Enabled = !Main.ramsavloaded;
statdata = new[] {
"0x000", "0x000", // Steps taken?
@ -203,10 +193,7 @@ namespace PKHeX
CB_Stats.SelectedIndex = 0;
}
private string[] statdata = { };
Form1 m_parent;
public byte[] sav = new byte[0x100000];
public int savshift;
public int savindex;
public bool editing;
public byte badgeval;
public ToolTip Tip1 = new ToolTip();
@ -244,7 +231,7 @@ namespace PKHeX
CB_Country.ValueMember = "Value";
CB_Region.DisplayMember = "Text";
CB_Region.ValueMember = "Value";
m_parent.setCountrySubRegion(CB_Country, "countries");
Main.setCountrySubRegion(CB_Country, "countries");
var oras_sprite_list = new[] {
//new { Text = "Calem", Value = 00 },
@ -327,25 +314,14 @@ namespace PKHeX
CB_Multi.ValueMember = "Value";
CB_Multi.DataSource = oras_sprite_list;
L_Vivillon.Text = Form1.specieslist[666] + ":";
m_parent.setForms(666, CB_Vivillon);
L_Vivillon.Text = Main.specieslist[666] + ":";
Main.setForms(666, CB_Vivillon);
}
private void getBadges()
{
// Fetch Badges
Bitmap[] bma = {
Properties.Resources.badge_1,
Properties.Resources.badge_2,
Properties.Resources.badge_3,
Properties.Resources.badge_4,
Properties.Resources.badge_5,
Properties.Resources.badge_6,
Properties.Resources.badge_7,
Properties.Resources.badge_8,
};
if (m_parent.savegame_oras)
{
bma = new[] {
Bitmap[] bma = (Main.SaveGame.ORAS) ?
new[] {
Properties.Resources.badge_01, // ORAS Badges
Properties.Resources.badge_02,
Properties.Resources.badge_03,
@ -354,48 +330,53 @@ namespace PKHeX
Properties.Resources.badge_06,
Properties.Resources.badge_07,
Properties.Resources.badge_08,
} :
new [] {
Properties.Resources.badge_1, // XY Badges
Properties.Resources.badge_2,
Properties.Resources.badge_3,
Properties.Resources.badge_4,
Properties.Resources.badge_5,
Properties.Resources.badge_6,
Properties.Resources.badge_7,
Properties.Resources.badge_8,
};
}
CheckBox[] cba = { cb1, cb2, cb3, cb4, cb5, cb6, cb7, cb8, };
PictureBox[] pba = { pb1, pb2, pb3, pb4, pb5, pb6, pb7, pb8, };
for (int i = 0; i < 8; i++)
{
pba[i].Image = Util.ChangeOpacity(bma[i], !cba[i].Checked ? 0.1 : 1);
}
}
private void getTextBoxes()
{
badgeval = sav[Trainer2 + 0xC + savindex * 0x7F000];
badgeval = sav[Main.SaveGame.Trainer2 + 0xC];
CheckBox[] cba = { cb1, cb2, cb3, cb4, cb5, cb6, cb7, cb8, };
for (int i = 0; i < 8; i++)
cba[i].Checked = (badgeval & (1 << i)) != 0;
// Get Data
string OT_NAME = Encoding.Unicode.GetString(sav, TrainerCard + 0x48 + savshift, 0x1A);
// string RIV_NAME = Encoding.Unicode.GetString(sav, Trainer2 + 0x10 + savshift, 0x1A);
string OT_NAME = Encoding.Unicode.GetString(sav, Main.SaveGame.TrainerCard + 0x48, 0x1A);
CB_Game.SelectedIndex = sav[TrainerCard + 0x04 + savshift] - 0x18;
CB_Gender.SelectedIndex = sav[TrainerCard + 0x05 + savshift];
CB_Game.SelectedIndex = sav[Main.SaveGame.TrainerCard + 0x04] - 0x18;
CB_Gender.SelectedIndex = sav[Main.SaveGame.TrainerCard + 0x05];
int TID = BitConverter.ToUInt16(sav, TrainerCard + 0x0 + savshift);
int SID = BitConverter.ToUInt16(sav, TrainerCard + 0x2 + savshift);
uint money = BitConverter.ToUInt32(sav, Trainer2 + 0x8 + savshift);
int TID = BitConverter.ToUInt16(sav, Main.SaveGame.TrainerCard + 0x0);
int SID = BitConverter.ToUInt16(sav, Main.SaveGame.TrainerCard + 0x2);
uint money = BitConverter.ToUInt32(sav, Main.SaveGame.Trainer2 + 0x8);
string saying1 = Encoding.Unicode.GetString(sav, TrainerCard + 0x7C + savshift, 0x20);
string saying2 = Encoding.Unicode.GetString(sav, TrainerCard + 0x9E + savshift, 0x20);
string saying3 = Encoding.Unicode.GetString(sav, TrainerCard + 0xC0 + savshift, 0x20);
string saying4 = Encoding.Unicode.GetString(sav, TrainerCard + 0xE2 + savshift, 0x20);
string saying5 = Encoding.Unicode.GetString(sav, TrainerCard + 0x104 + savshift, 0x20);
string saying1 = Encoding.Unicode.GetString(sav, Main.SaveGame.TrainerCard + 0x7C, 0x20);
string saying2 = Encoding.Unicode.GetString(sav, Main.SaveGame.TrainerCard + 0x9E, 0x20);
string saying3 = Encoding.Unicode.GetString(sav, Main.SaveGame.TrainerCard + 0xC0, 0x20);
string saying4 = Encoding.Unicode.GetString(sav, Main.SaveGame.TrainerCard + 0xE2, 0x20);
string saying5 = Encoding.Unicode.GetString(sav, Main.SaveGame.TrainerCard + 0x104, 0x20);
int _region = sav[TrainerCard + 0x26 + savshift];
int _country = sav[TrainerCard + 0x27 + savshift];
int _3dsreg = sav[TrainerCard + 0x2C + savshift];
int _language = sav[TrainerCard + 0x2D + savshift];
int _region = sav[Main.SaveGame.TrainerCard + 0x26];
int _country = sav[Main.SaveGame.TrainerCard + 0x27];
int _3dsreg = sav[Main.SaveGame.TrainerCard + 0x2C];
int _language = sav[Main.SaveGame.TrainerCard + 0x2D];
// Display Data
TB_OTName.Text = OT_NAME;
//TB_Rival.Text = RIV_NAME;
MT_TID.Text = TID.ToString("00000");
MT_SID.Text = SID.ToString("00000");
@ -414,85 +395,85 @@ namespace PKHeX
CB_Language.SelectedValue = _language;
// Maison Data
TB_MCSN.Text = BitConverter.ToUInt16(sav, savshift + Maison + 2 * 0).ToString();
TB_MCSS.Text = BitConverter.ToUInt16(sav, savshift + Maison + 2 * 1).ToString();
TB_MCSN.Text = BitConverter.ToUInt16(sav, Main.SaveGame.MaisonStats + 2 * 0).ToString();
TB_MCSS.Text = BitConverter.ToUInt16(sav, Main.SaveGame.MaisonStats + 2 * 1).ToString();
TB_MBSN.Text = BitConverter.ToUInt16(sav, savshift + Maison + 2 * 2).ToString();
TB_MBSS.Text = BitConverter.ToUInt16(sav, savshift + Maison + 2 * 3).ToString();
TB_MBSN.Text = BitConverter.ToUInt16(sav, Main.SaveGame.MaisonStats + 2 * 2).ToString();
TB_MBSS.Text = BitConverter.ToUInt16(sav, Main.SaveGame.MaisonStats + 2 * 3).ToString();
TB_MCDN.Text = BitConverter.ToUInt16(sav, savshift + Maison + 2 * 4).ToString();
TB_MCDS.Text = BitConverter.ToUInt16(sav, savshift + Maison + 2 * 5).ToString();
TB_MCDN.Text = BitConverter.ToUInt16(sav, Main.SaveGame.MaisonStats + 2 * 4).ToString();
TB_MCDS.Text = BitConverter.ToUInt16(sav, Main.SaveGame.MaisonStats + 2 * 5).ToString();
TB_MBDN.Text = BitConverter.ToUInt16(sav, savshift + Maison + 2 * 6).ToString();
TB_MBDS.Text = BitConverter.ToUInt16(sav, savshift + Maison + 2 * 7).ToString();
TB_MBDN.Text = BitConverter.ToUInt16(sav, Main.SaveGame.MaisonStats + 2 * 6).ToString();
TB_MBDS.Text = BitConverter.ToUInt16(sav, Main.SaveGame.MaisonStats + 2 * 7).ToString();
TB_MCTN.Text = BitConverter.ToUInt16(sav, savshift + Maison + 2 * 8).ToString();
TB_MCTS.Text = BitConverter.ToUInt16(sav, savshift + Maison + 2 * 9).ToString();
TB_MCTN.Text = BitConverter.ToUInt16(sav, Main.SaveGame.MaisonStats + 2 * 8).ToString();
TB_MCTS.Text = BitConverter.ToUInt16(sav, Main.SaveGame.MaisonStats + 2 * 9).ToString();
TB_MBTN.Text = BitConverter.ToUInt16(sav, savshift + Maison + 2 * 10).ToString();
TB_MBTS.Text = BitConverter.ToUInt16(sav, savshift + Maison + 2 * 11).ToString();
TB_MBTN.Text = BitConverter.ToUInt16(sav, Main.SaveGame.MaisonStats + 2 * 10).ToString();
TB_MBTS.Text = BitConverter.ToUInt16(sav, Main.SaveGame.MaisonStats + 2 * 11).ToString();
TB_MCRN.Text = BitConverter.ToUInt16(sav, savshift + Maison + 2 * 12).ToString();
TB_MCRS.Text = BitConverter.ToUInt16(sav, savshift + Maison + 2 * 13).ToString();
TB_MCRN.Text = BitConverter.ToUInt16(sav, Main.SaveGame.MaisonStats + 2 * 12).ToString();
TB_MCRS.Text = BitConverter.ToUInt16(sav, Main.SaveGame.MaisonStats + 2 * 13).ToString();
TB_MBRN.Text = BitConverter.ToUInt16(sav, savshift + Maison + 2 * 14).ToString();
TB_MBRS.Text = BitConverter.ToUInt16(sav, savshift + Maison + 2 * 15).ToString();
TB_MBRN.Text = BitConverter.ToUInt16(sav, Main.SaveGame.MaisonStats + 2 * 14).ToString();
TB_MBRS.Text = BitConverter.ToUInt16(sav, Main.SaveGame.MaisonStats + 2 * 15).ToString();
TB_MCMN.Text = BitConverter.ToUInt16(sav, savshift + Maison + 2 * 16).ToString();
TB_MCMS.Text = BitConverter.ToUInt16(sav, savshift + Maison + 2 * 17).ToString();
TB_MCMN.Text = BitConverter.ToUInt16(sav, Main.SaveGame.MaisonStats + 2 * 16).ToString();
TB_MCMS.Text = BitConverter.ToUInt16(sav, Main.SaveGame.MaisonStats + 2 * 17).ToString();
TB_MBMN.Text = BitConverter.ToUInt16(sav, savshift + Maison + 2 * 18).ToString();
TB_MBMS.Text = BitConverter.ToUInt16(sav, savshift + Maison + 2 * 19).ToString();
TB_MBMN.Text = BitConverter.ToUInt16(sav, Main.SaveGame.MaisonStats + 2 * 18).ToString();
TB_MBMS.Text = BitConverter.ToUInt16(sav, Main.SaveGame.MaisonStats + 2 * 19).ToString();
TB_CoordM.Text = BitConverter.ToUInt16(sav, savshift + Trainer1 + 0x02).ToString();
TB_CoordX.Text = BitConverter.ToSingle(sav, savshift + Trainer1 + 0x10).ToString();
TB_CoordZ.Text = BitConverter.ToSingle(sav, savshift + Trainer1 + 0x14).ToString();
TB_CoordY.Text = BitConverter.ToSingle(sav, savshift + Trainer1 + 0x18).ToString();
TB_CoordM.Text = BitConverter.ToUInt16(sav, Main.SaveGame.Trainer1 + 0x02).ToString();
TB_CoordX.Text = BitConverter.ToSingle(sav, Main.SaveGame.Trainer1 + 0x10).ToString();
TB_CoordZ.Text = BitConverter.ToSingle(sav, Main.SaveGame.Trainer1 + 0x14).ToString();
TB_CoordY.Text = BitConverter.ToSingle(sav, Main.SaveGame.Trainer1 + 0x18).ToString();
// Load BP and PokeMiles
TB_BP.Text = BitConverter.ToUInt32(sav, savshift + Trainer2 + 0x3C - 0xC * Convert.ToInt16(m_parent.savegame_oras)).ToString();
TB_PM.Text = BitConverter.ToUInt32(sav, savshift + psssatoffset + 0xFC).ToString();
TB_BP.Text = BitConverter.ToUInt32(sav, Main.SaveGame.Trainer2 + 0x3C - 0xC * Convert.ToInt16(Main.SaveGame.ORAS)).ToString();
TB_PM.Text = BitConverter.ToUInt32(sav, Main.SaveGame.PSSStats + 0xFC).ToString();
// Temp ORAS
GB_Misc.Visible = true;
TB_Style.Text = sav[0x694D + savshift].ToString();
TB_Style.Text = sav[0x694D].ToString();
// Load Play Time
MT_Hours.Text = BitConverter.ToUInt16(sav, savshift + 0x6C00).ToString();
MT_Minutes.Text = sav[0x6C02 + savshift].ToString();
MT_Seconds.Text = sav[0x6C03 + savshift].ToString();
MT_Hours.Text = BitConverter.ToUInt16(sav, 0x6C00).ToString();
MT_Minutes.Text = sav[0x6C02].ToString();
MT_Seconds.Text = sav[0x6C03].ToString();
// Load PSS Sprite
int sprite = sav[TrainerCard + 0x07];
int sprite = sav[Main.SaveGame.TrainerCard + 0x07];
CB_Multi.SelectedValue = sprite;
PB_Sprite.Image = (Image)Properties.Resources.ResourceManager.GetObject("tr_" + sprite.ToString("00"));
// Load Clothing Data
int hat = sav[TrainerCard + 0x31 + savshift] >> 3;
int haircolor = sav[TrainerCard + 0x31 + savshift] & 7;
int hat = sav[Main.SaveGame.TrainerCard + 0x31] >> 3;
int haircolor = sav[Main.SaveGame.TrainerCard + 0x31] & 7;
MT_Hat.Text = hat.ToString();
MT_HairColor.Text = haircolor.ToString();
MT_14030.Text = sav[TrainerCard + 0x30 + savshift].ToString();
MT_14031.Text = sav[TrainerCard + 0x31 + savshift].ToString();
MT_14032.Text = sav[TrainerCard + 0x32 + savshift].ToString();
MT_14033.Text = sav[TrainerCard + 0x33 + savshift].ToString();
MT_14034.Text = sav[TrainerCard + 0x34 + savshift].ToString();
MT_14035.Text = sav[TrainerCard + 0x35 + savshift].ToString();
MT_14036.Text = sav[TrainerCard + 0x36 + savshift].ToString();
MT_14037.Text = sav[TrainerCard + 0x37 + savshift].ToString();
MT_14038.Text = sav[TrainerCard + 0x38 + savshift].ToString();
MT_14039.Text = sav[TrainerCard + 0x39 + savshift].ToString();
MT_1403A.Text = sav[TrainerCard + 0x3A + savshift].ToString();
MT_1403B.Text = sav[TrainerCard + 0x3B + savshift].ToString();
MT_1403C.Text = sav[TrainerCard + 0x3C + savshift].ToString();
MT_1403D.Text = sav[TrainerCard + 0x3D + savshift].ToString();
MT_1403E.Text = sav[TrainerCard + 0x3E + savshift].ToString();
MT_1403F.Text = sav[TrainerCard + 0x3F + savshift].ToString();
MT_14030.Text = sav[Main.SaveGame.TrainerCard + 0x30].ToString();
MT_14031.Text = sav[Main.SaveGame.TrainerCard + 0x31].ToString();
MT_14032.Text = sav[Main.SaveGame.TrainerCard + 0x32].ToString();
MT_14033.Text = sav[Main.SaveGame.TrainerCard + 0x33].ToString();
MT_14034.Text = sav[Main.SaveGame.TrainerCard + 0x34].ToString();
MT_14035.Text = sav[Main.SaveGame.TrainerCard + 0x35].ToString();
MT_14036.Text = sav[Main.SaveGame.TrainerCard + 0x36].ToString();
MT_14037.Text = sav[Main.SaveGame.TrainerCard + 0x37].ToString();
MT_14038.Text = sav[Main.SaveGame.TrainerCard + 0x38].ToString();
MT_14039.Text = sav[Main.SaveGame.TrainerCard + 0x39].ToString();
MT_1403A.Text = sav[Main.SaveGame.TrainerCard + 0x3A].ToString();
MT_1403B.Text = sav[Main.SaveGame.TrainerCard + 0x3B].ToString();
MT_1403C.Text = sav[Main.SaveGame.TrainerCard + 0x3C].ToString();
MT_1403D.Text = sav[Main.SaveGame.TrainerCard + 0x3D].ToString();
MT_1403E.Text = sav[Main.SaveGame.TrainerCard + 0x3E].ToString();
MT_1403F.Text = sav[Main.SaveGame.TrainerCard + 0x3F].ToString();
// Vivillon
byte vivillon = sav[VivillonForm + savshift];
byte vivillon = sav[Main.SaveGame.Vivillon];
CB_Vivillon.SelectedIndex = vivillon;
}
private void save()
@ -500,8 +481,8 @@ namespace PKHeX
string OT_Name = TB_OTName.Text;
//string RIV_Name = TB_Rival.Text;
sav[TrainerCard + 0x04 + savshift] = (byte)(CB_Game.SelectedIndex + 0x18);
sav[TrainerCard + 0x05 + savshift] = (byte)CB_Gender.SelectedIndex;
sav[Main.SaveGame.TrainerCard + 0x04] = (byte)(CB_Game.SelectedIndex + 0x18);
sav[Main.SaveGame.TrainerCard + 0x05] = (byte)CB_Gender.SelectedIndex;
uint TID = Util.ToUInt32(MT_TID.Text);
uint SID = Util.ToUInt32(MT_SID.Text);
@ -518,36 +499,21 @@ namespace PKHeX
uint _3dsreg = Util.ToUInt32(CB_3DSReg.SelectedValue.ToString());
uint _language = Util.ToUInt32(CB_Language.SelectedValue.ToString());
Array.Copy(BitConverter.GetBytes(TID), 0, sav, TrainerCard + 0x0 + savshift, 2);
Array.Copy(BitConverter.GetBytes(SID), 0, sav, TrainerCard + 0x2 + savshift, 2);
Array.Copy(BitConverter.GetBytes(money), 0, sav, Trainer2 + 0x8 + savshift, 4);
Array.Copy(BitConverter.GetBytes(_region), 0, sav, TrainerCard + 0x26 + savshift, 1);
Array.Copy(BitConverter.GetBytes(_country), 0, sav, TrainerCard + 0x27 + savshift, 1);
Array.Copy(BitConverter.GetBytes(_3dsreg), 0, sav, TrainerCard + 0x2C + savshift, 1);
Array.Copy(BitConverter.GetBytes(_language), 0, sav, TrainerCard + 0x2D + savshift, 1);
Array.Copy(BitConverter.GetBytes(TID), 0, sav, Main.SaveGame.TrainerCard + 0x0, 2);
Array.Copy(BitConverter.GetBytes(SID), 0, sav, Main.SaveGame.TrainerCard + 0x2, 2);
Array.Copy(BitConverter.GetBytes(money), 0, sav, Main.SaveGame.Trainer2 + 0x8, 4);
Array.Copy(BitConverter.GetBytes(_region), 0, sav, Main.SaveGame.TrainerCard + 0x26, 1);
Array.Copy(BitConverter.GetBytes(_country), 0, sav, Main.SaveGame.TrainerCard + 0x27, 1);
Array.Copy(BitConverter.GetBytes(_3dsreg), 0, sav, Main.SaveGame.TrainerCard + 0x2C, 1);
Array.Copy(BitConverter.GetBytes(_language), 0, sav, Main.SaveGame.TrainerCard + 0x2D, 1);
byte[] OT = Encoding.Unicode.GetBytes(OT_Name);
Array.Resize(ref OT, 0x1A);
Array.Copy(OT, 0, sav, TrainerCard + 0x48 + savshift, 0x1A);
//byte[] Rival = Encoding.Unicode.GetBytes(RIV_Name);
//Array.Resize(ref Rival, 0x1A);
//Array.Copy(Rival, 0, sav, 0x9610 + savshift, 0x1A);
Array.Copy(Encoding.Unicode.GetBytes(OT_Name.PadRight(13, '\0')), 0, sav, Main.SaveGame.TrainerCard + 0x48, 0x1A);
byte[] s1 = Encoding.Unicode.GetBytes(saying1);
Array.Resize(ref s1, 0x22);
Array.Copy(s1, 0, sav, TrainerCard + 0x7C + savshift, 0x22);
byte[] s2 = Encoding.Unicode.GetBytes(saying2);
Array.Resize(ref s2, 0x22);
Array.Copy(s2, 0, sav, TrainerCard + 0x9E + savshift, 0x22);
byte[] s3 = Encoding.Unicode.GetBytes(saying3);
Array.Resize(ref s3, 0x22);
Array.Copy(s3, 0, sav, TrainerCard + 0xC0 + savshift, 0x22);
byte[] s4 = Encoding.Unicode.GetBytes(saying4);
Array.Resize(ref s4, 0x22);
Array.Copy(s4, 0, sav, TrainerCard + 0xE2 + savshift, 0x22);
byte[] s5 = Encoding.Unicode.GetBytes(saying5);
Array.Resize(ref s5, 0x22);
Array.Copy(s5, 0, sav, TrainerCard + 0x104 + savshift, 0x22);
Array.Copy(Encoding.Unicode.GetBytes(saying1.PadRight(17, '\0')), 0, sav, Main.SaveGame.TrainerCard + 0x7C, 0x22);
Array.Copy(Encoding.Unicode.GetBytes(saying2.PadRight(17, '\0')), 0, sav, Main.SaveGame.TrainerCard + 0x9E, 0x22);
Array.Copy(Encoding.Unicode.GetBytes(saying3.PadRight(17, '\0')), 0, sav, Main.SaveGame.TrainerCard + 0xC0, 0x22);
Array.Copy(Encoding.Unicode.GetBytes(saying4.PadRight(17, '\0')), 0, sav, Main.SaveGame.TrainerCard + 0xE2, 0x22);
Array.Copy(Encoding.Unicode.GetBytes(saying5.PadRight(17, '\0')), 0, sav, Main.SaveGame.TrainerCard + 0x104, 0x22);
// New stuff.
// Copy Maison Data in
@ -559,74 +525,69 @@ namespace PKHeX
TB_MCRN,TB_MCRS,TB_MBRN,TB_MBRS,
TB_MCMN,TB_MCMS,TB_MBMN,TB_MBMS,
};
for (int i = 0; i < tba.Length; i++)
{
byte[] streak = BitConverter.GetBytes(Util.ToUInt32(tba[i].Text));
Array.Resize(ref streak, 2);
Array.Copy(streak, 0, sav, Maison + 2 * i + savshift, 2);
}
Array.Copy(BitConverter.GetBytes(UInt16.Parse(tba[i].Text)), 0, sav, Main.SaveGame.MaisonStats + 2 * i, 2);
// Copy Position
byte[] m = BitConverter.GetBytes(Int16.Parse(TB_CoordM.Text)); Array.Resize(ref m, 2); Array.Copy(m, 0, sav, savshift + Trainer1 + 0x02, 2);
byte[] x = BitConverter.GetBytes(Single.Parse(TB_CoordX.Text)); Array.Resize(ref x, 4); Array.Copy(x, 0, sav, savshift + Trainer1 + 0x10, 4);
byte[] z = BitConverter.GetBytes(Single.Parse(TB_CoordZ.Text)); Array.Resize(ref z, 4); Array.Copy(z, 0, sav, savshift + Trainer1 + 0x14, 4);
byte[] y = BitConverter.GetBytes(Single.Parse(TB_CoordY.Text)); Array.Resize(ref y, 4); Array.Copy(y, 0, sav, savshift + Trainer1 + 0x18, 4);
Array.Copy(BitConverter.GetBytes(UInt16.Parse(TB_CoordM.Text)), 0, sav, Main.SaveGame.Trainer1 + 0x02, 2); // m
Array.Copy(BitConverter.GetBytes(Single.Parse(TB_CoordX.Text)), 0, sav, Main.SaveGame.Trainer1 + 0x10, 4); // x
Array.Copy(BitConverter.GetBytes(Single.Parse(TB_CoordZ.Text)), 0, sav, Main.SaveGame.Trainer1 + 0x14, 4); // y
Array.Copy(BitConverter.GetBytes(Single.Parse(TB_CoordY.Text)), 0, sav, Main.SaveGame.Trainer1 + 0x18, 4); // z
byte[] bp = BitConverter.GetBytes(Util.ToUInt32(TB_BP.Text)); Array.Resize(ref bp, 2); Array.Copy(bp, 0, sav, savshift + 0x963C - 0xC * Convert.ToInt16(m_parent.savegame_oras), 2);
byte[] pm = BitConverter.GetBytes(Util.ToUInt32(TB_PM.Text)); Array.Resize(ref pm, 4); Array.Copy(pm, 0, sav, savshift + psssatoffset + 0xFC, 4); Array.Copy(pm, 0, sav, savshift + psssatoffset + 0x100, 4);
sav[0x694D + savshift] = Byte.Parse(TB_Style.Text);
Array.Copy(BitConverter.GetBytes(UInt16.Parse(TB_BP.Text)), 0, sav, 0x963C - 0xC * Convert.ToInt16(Main.SaveGame.ORAS), 2);
Array.Copy(BitConverter.GetBytes(Util.ToUInt32(TB_PM.Text)), 0, sav, Main.SaveGame.PSSStats + 0xFC, 4);
Array.Copy(BitConverter.GetBytes(Util.ToUInt32(TB_PM.Text)), 0, sav, Main.SaveGame.PSSStats + 0x100, 4);
sav[0x694D] = Byte.Parse(TB_Style.Text);
// Copy Badges
badgeval = 0;
CheckBox[] cba = { cb1, cb2, cb3, cb4, cb5, cb6, cb7, cb8, };
for (int i = 0; i < 8; i++)
badgeval |= (byte)(Convert.ToByte(cba[i].Checked) << i);
sav[0x960C + savshift] = badgeval;
sav[0x960C] = badgeval;
// Save PlayTime
byte[] h = BitConverter.GetBytes(UInt16.Parse(MT_Hours.Text)); Array.Resize(ref h, 2); Array.Copy(h, 0, sav, savshift + 0x6C00, 2);
sav[0x6C02 + savshift] = (byte)(UInt16.Parse(MT_Minutes.Text) % 60);
sav[0x6C03 + savshift] = (byte)(UInt16.Parse(MT_Seconds.Text) % 60);
Array.Copy(BitConverter.GetBytes(UInt16.Parse(MT_Hours.Text)), 0, sav, 0x6C00, 2);
sav[0x6C02] = (byte)(UInt16.Parse(MT_Minutes.Text) % 60);
sav[0x6C03] = (byte)(UInt16.Parse(MT_Seconds.Text) % 60);
// Sprite
sav[TrainerCard + 0x07] = Convert.ToByte(CB_Multi.SelectedValue);
sav[Main.SaveGame.TrainerCard + 0x07] = Convert.ToByte(CB_Multi.SelectedValue);
sav[TrainerCard + 0x31] = (byte)(Byte.Parse(MT_HairColor.Text) + (Byte.Parse(MT_Hat.Text) << 3));
sav[TrainerCard + 0x30 + savshift] = Byte.Parse(MT_14030.Text);
//sav[TrainerCard + 0x31 + savshift] = Byte.Parse(MT_14031.Text);
sav[TrainerCard + 0x32 + savshift] = Byte.Parse(MT_14032.Text);
sav[TrainerCard + 0x33 + savshift] = Byte.Parse(MT_14033.Text);
sav[TrainerCard + 0x34 + savshift] = Byte.Parse(MT_14034.Text);
sav[TrainerCard + 0x35 + savshift] = Byte.Parse(MT_14035.Text);
sav[TrainerCard + 0x36 + savshift] = Byte.Parse(MT_14036.Text);
sav[TrainerCard + 0x37 + savshift] = Byte.Parse(MT_14037.Text);
sav[TrainerCard + 0x38 + savshift] = Byte.Parse(MT_14038.Text);
sav[TrainerCard + 0x39 + savshift] = Byte.Parse(MT_14039.Text);
sav[TrainerCard + 0x3A + savshift] = Byte.Parse(MT_1403A.Text);
sav[TrainerCard + 0x3B + savshift] = Byte.Parse(MT_1403B.Text);
sav[TrainerCard + 0x3C + savshift] = Byte.Parse(MT_1403C.Text);
sav[TrainerCard + 0x3D + savshift] = Byte.Parse(MT_1403D.Text);
sav[TrainerCard + 0x3E + savshift] = Byte.Parse(MT_1403E.Text);
sav[TrainerCard + 0x3F + savshift] = Byte.Parse(MT_1403F.Text);
// Appearance
sav[Main.SaveGame.TrainerCard + 0x30] = Byte.Parse(MT_14030.Text);
sav[Main.SaveGame.TrainerCard + 0x31] = (byte)(Byte.Parse(MT_HairColor.Text) + (Byte.Parse(MT_Hat.Text) << 3));
sav[Main.SaveGame.TrainerCard + 0x32] = Byte.Parse(MT_14032.Text);
sav[Main.SaveGame.TrainerCard + 0x33] = Byte.Parse(MT_14033.Text);
sav[Main.SaveGame.TrainerCard + 0x34] = Byte.Parse(MT_14034.Text);
sav[Main.SaveGame.TrainerCard + 0x35] = Byte.Parse(MT_14035.Text);
sav[Main.SaveGame.TrainerCard + 0x36] = Byte.Parse(MT_14036.Text);
sav[Main.SaveGame.TrainerCard + 0x37] = Byte.Parse(MT_14037.Text);
sav[Main.SaveGame.TrainerCard + 0x38] = Byte.Parse(MT_14038.Text);
sav[Main.SaveGame.TrainerCard + 0x39] = Byte.Parse(MT_14039.Text);
sav[Main.SaveGame.TrainerCard + 0x3A] = Byte.Parse(MT_1403A.Text);
sav[Main.SaveGame.TrainerCard + 0x3B] = Byte.Parse(MT_1403B.Text);
sav[Main.SaveGame.TrainerCard + 0x3C] = Byte.Parse(MT_1403C.Text);
sav[Main.SaveGame.TrainerCard + 0x3D] = Byte.Parse(MT_1403D.Text);
sav[Main.SaveGame.TrainerCard + 0x3E] = Byte.Parse(MT_1403E.Text);
sav[Main.SaveGame.TrainerCard + 0x3F] = Byte.Parse(MT_1403F.Text);
// Vivillon
sav[VivillonForm + savshift] = (byte)CB_Vivillon.SelectedIndex;
sav[Main.SaveGame.Vivillon] = (byte)CB_Vivillon.SelectedIndex;
}
private void clickOT(object sender, MouseEventArgs e)
{
TextBox tb = (!(sender is TextBox)) ? TB_OTName : (sender as TextBox);
// Special Character Form
if (ModifierKeys == Keys.Control && !Form1.specialChars)
if (ModifierKeys == Keys.Control && !Main.specialChars)
(new f2_Text(tb)).Show();
}
private void showTSV(object sender, EventArgs e)
{
uint TID = Util.ToUInt32(MT_TID.Text);
uint SID = Util.ToUInt32(MT_SID.Text);
uint tsv = (TID ^ SID) >> 4;
uint tsv = PKX.getTSV(TID, SID);
Tip1.SetToolTip(MT_TID, "TSV: " + tsv.ToString("0000"));
Tip2.SetToolTip(MT_SID, "TSV: " + tsv.ToString("0000"));
}
@ -638,8 +599,8 @@ namespace PKHeX
private void B_Save_Click(object sender, EventArgs e)
{
save();
Array.Copy(sav, m_parent.savefile, 0x100000);
m_parent.savedited = true;
Array.Copy(sav, Main.savefile, Main.savefile.Length);
Main.savedited = true;
Close();
}
private void B_MaxCash_Click(object sender, EventArgs e)
@ -672,16 +633,14 @@ namespace PKHeX
if (box.Text == "") box.Text = "0";
if (Util.ToInt32(box.Text) > 65535) box.Text = "65535";
}
private int psssatoffset = 0x23800;
private void changeStat(object sender, EventArgs e)
{
editing = true;
{
int pssoff = psssatoffset + savindex * 0x7F000;
string offsetstr = statdata[CB_Stats.SelectedIndex * 2];
int offset = (int)new System.ComponentModel.Int32Converter().ConvertFromString(offsetstr);
MT_Stat.Text = BitConverter.ToUInt32(sav, pssoff + offset).ToString();
MT_Stat.Text = BitConverter.ToUInt32(sav, Main.SaveGame.PSSStats + offset).ToString();
L_Offset.Text = "0x" + offset.ToString("X3");
}
editing = false;
@ -690,14 +649,13 @@ namespace PKHeX
{
if (editing) return;
int pssoff = psssatoffset + savindex * 0x7F000;
string offsetstr = statdata[CB_Stats.SelectedIndex * 2];
int offset = (int)new System.ComponentModel.Int32Converter().ConvertFromString(offsetstr);
uint val = UInt32.Parse(MT_Stat.Text);
byte[] data = BitConverter.GetBytes(val);
Array.Resize(ref data, 4);
Array.Copy(data, 0, sav, pssoff + offset, 4);
Array.Copy(data, 0, sav, Main.SaveGame.PSSStats + offset, 4);
}
private void giveAllAccessories(object sender, EventArgs e)
{
@ -711,13 +669,13 @@ namespace PKHeX
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
Array.Copy(data, 0, sav, savshift + 0x6E00, 0x6C);
Array.Copy(data, 0, sav, 0x6E00, 0x6C);
}
private void updateCountry(object sender, EventArgs e)
{
if (Util.getIndex(sender as ComboBox) > 0)
m_parent.setCountrySubRegion(CB_Region, "sr_" + Util.getIndex(sender as ComboBox).ToString("000"));
Main.setCountrySubRegion(CB_Region, "sr_" + Util.getIndex(sender as ComboBox).ToString("000"));
}
private void toggleBadge(object sender, EventArgs e)
{
@ -728,7 +686,7 @@ namespace PKHeX
private void CB_Multi_SelectedIndexChanged(object sender, EventArgs e)
{
PB_Sprite.Image = (Image)Properties.Resources.ResourceManager.GetObject((m_parent.savegame_oras) ? "tr_" + Util.getIndex(CB_Multi).ToString("00") : "tr_00");
PB_Sprite.Image = (Image)Properties.Resources.ResourceManager.GetObject((Main.SaveGame.ORAS) ? "tr_" + Util.getIndex(CB_Multi).ToString("00") : "tr_00");
}
}
}

View file

@ -9,14 +9,11 @@ namespace PKHeX
{
public partial class SAV_Wondercard : Form
{
public SAV_Wondercard(Form1 frm1, byte[] wcdata = null)
public SAV_Wondercard(byte[] wcdata = null)
{
InitializeComponent();
Util.TranslateInterface(this, Form1.curlanguage);
m_parent = frm1;
Array.Copy(m_parent.savefile, sav, 0x100000);
savindex = m_parent.savindex;
if (m_parent.savegame_oras) wcoffset = 0x22100;
Util.TranslateInterface(this, Main.curlanguage);
sav = (byte[])Main.savefile.Clone();
populateWClist();
populateReceived();
@ -32,12 +29,9 @@ namespace PKHeX
Array.Copy(wcdata, wondercard_data, wcdata.Length);
loadwcdata();
}
Form1 m_parent;
public byte[] sav = new byte[0x100000];
public byte[] sav;
public byte[] wondercard_data = new byte[0x108];
public int savindex;
private int wcoffset = 0x21100;
private const uint herpesval = 0x225D73C2;
private const uint EonTicketConst = 0x225D73C2;
// Repopulation Functions
private void populateWClist()
@ -45,7 +39,7 @@ namespace PKHeX
LB_WCs.Items.Clear();
for (int i = 0; i < 24; i++)
{
int offset = wcoffset + savindex * 0x7F000 + i * 0x108;
int offset = Main.SaveGame.WondercardData + i * 0x108;
int cardID = BitConverter.ToUInt16(sav, offset);
if (cardID == 0)
LB_WCs.Items.Add((i + 1).ToString("00") + " - Empty");
@ -79,10 +73,9 @@ namespace PKHeX
}
private void populateReceived()
{
int offset = wcoffset - 0x100 + savindex * 0x7F000;
LB_Received.Items.Clear();
for (int i = 1; i < 2048; i++)
if ((((sav[offset + i / 8]) >> (i % 8)) & 0x1) == 1)
if ((((sav[Main.SaveGame.WondercardFlags + i / 8]) >> (i % 8)) & 0x1) == 1)
LB_Received.Items.Add(i.ToString("0000"));
}
@ -128,7 +121,7 @@ namespace PKHeX
{
// Load Wondercard from Save File
int index = LB_WCs.SelectedIndex;
int offset = wcoffset + savindex * 0x7F000 + index * 0x108;
int offset = Main.SaveGame.WondercardData + index * 0x108;
Array.Copy(sav, offset, wondercard_data, 0, 0x108);
loadwcdata();
}
@ -136,11 +129,11 @@ namespace PKHeX
{
// Write Wondercard to Save File
int index = LB_WCs.SelectedIndex;
int offset = wcoffset + savindex * 0x7F000 + index * 0x108;
if (m_parent.savegame_oras) // ORAS Only
int offset = Main.SaveGame.WondercardData + index * 0x108;
if (Main.SaveGame.ORAS) // ORAS Only
if (BitConverter.ToUInt16(wondercard_data, 0) == 0x800) // Eon Ticket #
if (BitConverter.ToUInt16(wondercard_data, 0x68) == 0x2D6) // Eon Ticket
Array.Copy(BitConverter.GetBytes(herpesval), 0, sav, 0x319B8 + 0x5400 + savindex * 0x7F000, 4);
Array.Copy(BitConverter.GetBytes(EonTicketConst), 0, sav, Main.SaveGame.EonTicket, 4);
Array.Copy(wondercard_data, 0, sav, offset, 0x108);
populateWClist();
int cardID = BitConverter.ToUInt16(wondercard_data, 0);
@ -153,7 +146,7 @@ namespace PKHeX
private void B_DeleteWC_Click(object sender, EventArgs e)
{
int index = LB_WCs.SelectedIndex;
int offset = wcoffset + savindex * 0x7F000 + index * 0x108;
int offset = Main.SaveGame.WondercardData + index * 0x108;
byte[] zeros = new byte[0x108];
Array.Copy(zeros, 0, sav, offset, 0x108);
populateWClist();
@ -166,7 +159,7 @@ namespace PKHeX
}
private void B_Save_Click(object sender, EventArgs e)
{
int offset = wcoffset - 0x100 + savindex * 0x7F000;
int offset = Main.SaveGame.WondercardFlags;
// Make sure all of the Received Flags are flipped!
byte[] wcflags = new byte[0x100];
@ -186,8 +179,8 @@ namespace PKHeX
Array.Copy(sav, offset + j * 0x108, sav, offset + (j - 1) * 0x108, 0x108);
}
Array.Copy(sav, m_parent.savefile, 0x100000);
m_parent.savedited = true;
Array.Copy(sav, Main.savefile, sav.Length);
Main.savedited = true;
Close();
}
@ -265,7 +258,7 @@ namespace PKHeX
int item = BitConverter.ToUInt16(data, 0x68);
int qty = BitConverter.ToUInt16(data, 0x70);
s += "Item: " + Form1.itemlist[item] + Environment.NewLine + "Quantity: " + qty;
s += "Item: " + Main.itemlist[item] + Environment.NewLine + "Quantity: " + qty;
}
else if (cardtype == 0) // PKM
{
@ -283,12 +276,12 @@ namespace PKHeX
"{1} @ {2} --- {7} - {8}/{9}{0}" +
"{3} / {4} / {5} / {6}{0}",
Environment.NewLine,
Form1.specieslist[species],
Form1.itemlist[helditem],
Form1.movelist[move1],
Form1.movelist[move2],
Form1.movelist[move3],
Form1.movelist[move4],
Main.specieslist[species],
Main.itemlist[helditem],
Main.movelist[move1],
Main.movelist[move2],
Main.movelist[move3],
Main.movelist[move4],
OTname, TID.ToString("00000"), SID.ToString("00000"));
}
else
@ -337,7 +330,7 @@ namespace PKHeX
else
{
if (wondercard_data.SequenceEqual((new byte[wondercard_data.Length])))
{ Util.Alert("No wondercard data found"); return; }
{ Util.Alert("No wondercard data found in loaded slot!"); return; }
if (BitConverter.ToUInt16(wondercard_data, 0x68) == 726 && wondercard_data[0x51] == 1)
{ Util.Alert("Eon Ticket Wondercards will not function properly", "Inject to the save file instead."); return; }
// Prep data

View file

@ -2,6 +2,7 @@
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
@ -17,17 +18,15 @@ namespace PKHeX
InitializeComponent();
dgData.DoubleBuffered(true);
}
public void PopulateData(byte[] InputData, int savindex, int baseoffset)
public void PopulateData(byte[] InputData, int BoxDataOffset)
{
SaveData = new byte[InputData.Length];
Array.Copy(InputData, SaveData, InputData.Length);
SaveData = (byte[])InputData.Clone();
PokemonList PL = new PokemonList();
if (savindex > 1) savindex = 0;
BoxBar.Maximum = 930 + 100;
BoxBar.Step = 1;
for (int BoxNum = 0; BoxNum < 31; BoxNum++)
{
int boxoffset = baseoffset + 0x7F000 * savindex + BoxNum * (0xE8 * 30);
int boxoffset = BoxDataOffset + BoxNum * (0xE8 * 30);
for (int SlotNum = 0; SlotNum < 30; SlotNum++)
{
BoxBar.PerformStep();
@ -78,11 +77,10 @@ namespace PKHeX
var cells = row.Cells.Cast<DataGridViewCell>();
sb.AppendLine(string.Join(",", cells.Select(cell => "\"" + cell.Value + "\"").ToArray()));
}
System.IO.File.WriteAllText(path, sb.ToString(), Encoding.UTF8);
File.WriteAllText(path, sb.ToString(), Encoding.UTF8);
}
public class PokemonList : SortableBindingList<PKX> { }
}
public static class ExtensionMethods // Speed up scrolling
{