2016-01-23 21:00:44 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace PKHeX
|
|
|
|
|
{
|
|
|
|
|
public partial class SAV_BerryFieldORAS : Form
|
|
|
|
|
{
|
|
|
|
|
public SAV_BerryFieldORAS()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
Util.TranslateInterface(this, Main.curlanguage);
|
2016-01-23 22:50:22 +00:00
|
|
|
|
sav = (byte[])Main.SAV.Data.Clone();
|
2016-01-23 21:00:44 +00:00
|
|
|
|
nup_spec = new[] { NUP_Red, NUP_Blue, NUP_Pink, NUP_Green, NUP_Yellow, NUP_Rainbow, NUP_RedPlus, NUP_BluePlus, NUP_PinkPlus, NUP_GreenPlus, NUP_YellowPlus, NUP_RainbowPlus };
|
2016-01-23 22:50:22 +00:00
|
|
|
|
Label[] lbl_spec = { L_Red, L_Blue, L_Pink, L_Green, L_Yellow, L_Rainbow, L_RedPlus, L_BluePlus, L_PinkPlus, L_GreenPlus, L_YellowPlus, L_RainbowPlus };
|
2016-01-23 21:00:44 +00:00
|
|
|
|
|
|
|
|
|
for (int i = 0; i < lbl_spec.Length; i++)
|
|
|
|
|
{
|
2016-01-23 22:50:22 +00:00
|
|
|
|
lbl_spec[i].Text = $"{Main.pokeblocks[94 + i]}:";
|
|
|
|
|
nup_spec[i].Value = BitConverter.ToUInt32(sav, Main.SAV.Contest + i * 4);
|
2016-01-23 21:00:44 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-01-23 22:50:22 +00:00
|
|
|
|
private readonly NumericUpDown[] nup_spec;
|
|
|
|
|
private readonly byte[] sav;
|
2016-01-23 21:00:44 +00:00
|
|
|
|
|
|
|
|
|
private void B_Cancel_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
private void B_Save_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2016-01-23 22:50:22 +00:00
|
|
|
|
for (int i = 0; i < nup_spec.Length; i++)
|
|
|
|
|
BitConverter.GetBytes((uint)nup_spec[i].Value).CopyTo(sav, Main.SAV.Contest + i * 4);
|
|
|
|
|
Main.SAV.Data = (byte[])sav.Clone();
|
2016-01-23 21:00:44 +00:00
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void B_RandomizeBerries_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2016-01-23 22:50:22 +00:00
|
|
|
|
if (DialogResult.Yes != Util.Prompt(MessageBoxButtons.YesNo, "Repopulate all berry plots with random berries?"))
|
2016-01-23 21:00:44 +00:00
|
|
|
|
return;
|
2016-01-23 22:50:22 +00:00
|
|
|
|
|
|
|
|
|
// Randomize the trees.
|
|
|
|
|
byte[] tree = { 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x80, 0x40, 0x01, 0x00, 0x00, 0x00, };
|
|
|
|
|
var plantable = Legal.Pouch_Berry_XY; // 0 index is None, skip with rand
|
|
|
|
|
for (int i = 0; i < 90; i++) // amount of plots in the game
|
2016-01-23 21:00:44 +00:00
|
|
|
|
{
|
2016-01-23 22:50:22 +00:00
|
|
|
|
ushort berry = plantable[Util.rnd32() % (plantable.Length - 1) + 1]; // get random berry item ID from list
|
|
|
|
|
BitConverter.GetBytes(berry).CopyTo(tree, 6); // put berry into tree.
|
|
|
|
|
tree.CopyTo(sav, Main.SAV.BerryField + 0x10 * i); // put tree into plot
|
2016-01-23 21:00:44 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|