Style updates

This commit is contained in:
Kurt 2018-08-04 10:06:06 -07:00
parent 53857df647
commit c3136187de
45 changed files with 926 additions and 321 deletions

View file

@ -1078,13 +1078,15 @@ namespace PKHeX.WinForms.Controls
if (sav is SAV4BR br) if (sav is SAV4BR br)
{ {
L_SaveSlot.Visible = CB_SaveSlot.Visible = true; L_SaveSlot.Visible = CB_SaveSlot.Visible = true;
var list = br.SaveNames.Select((z, i) => new ComboItem { Text = z, Value = i }).ToList(); var list = br.SaveNames.Select((z, i) => new ComboItem {Text = z, Value = i}).ToList();
CB_SaveSlot.InitializeBinding(); CB_SaveSlot.InitializeBinding();
CB_SaveSlot.DataSource = new BindingSource(list, null); CB_SaveSlot.DataSource = new BindingSource(list, null);
CB_SaveSlot.SelectedValue = br.CurrentSlot; CB_SaveSlot.SelectedValue = br.CurrentSlot;
} }
else else
{
L_SaveSlot.Visible = CB_SaveSlot.Visible = false; L_SaveSlot.Visible = CB_SaveSlot.Visible = false;
}
switch (sav.Generation) switch (sav.Generation)
{ {

View file

@ -11,17 +11,17 @@ namespace PKHeX.WinForms
public string Position => pkm.Identifier; public string Position => pkm.Identifier;
public Image Sprite => pkm.Sprite(); public Image Sprite => pkm.Sprite();
public string Nickname => pkm.Nickname; public string Nickname => pkm.Nickname;
public string Species => Get(GameInfo.Strings.specieslist, pkm.Species); public string Species => Get(Strings.specieslist, pkm.Species);
public string Nature => Get(GameInfo.Strings.natures, pkm.Nature); public string Nature => Get(Strings.natures, pkm.Nature);
public string Gender => Get(Main.GenderSymbols, pkm.Gender); public string Gender => Get(Main.GenderSymbols, pkm.Gender);
public string ESV => pkm.PSV.ToString("0000"); public string ESV => pkm.PSV.ToString("0000");
public string HP_Type => Get(GameInfo.Strings.types, pkm.HPType + 1); public string HP_Type => Get(Strings.types, pkm.HPType + 1);
public string Ability => Get(GameInfo.Strings.abilitylist, pkm.Ability); public string Ability => Get(Strings.abilitylist, pkm.Ability);
public string Move1 => Get(GameInfo.Strings.movelist, pkm.Move1); public string Move1 => Get(Strings.movelist, pkm.Move1);
public string Move2 => Get(GameInfo.Strings.movelist, pkm.Move2); public string Move2 => Get(Strings.movelist, pkm.Move2);
public string Move3 => Get(GameInfo.Strings.movelist, pkm.Move3); public string Move3 => Get(Strings.movelist, pkm.Move3);
public string Move4 => Get(GameInfo.Strings.movelist, pkm.Move4); public string Move4 => Get(Strings.movelist, pkm.Move4);
public string HeldItem => Get(GameInfo.Strings.itemlist, pkm.HeldItem); public string HeldItem => Get(Strings.itemlist, pkm.HeldItem);
public string HP => Stats[0].ToString(); public string HP => Stats[0].ToString();
public string ATK => Stats[1].ToString(); public string ATK => Stats[1].ToString();
public string DEF => Stats[2].ToString(); public string DEF => Stats[2].ToString();
@ -30,10 +30,10 @@ namespace PKHeX.WinForms
public string SPE => Stats[3].ToString(); public string SPE => Stats[3].ToString();
public string MetLoc => pkm.GetLocationString(eggmet: false); public string MetLoc => pkm.GetLocationString(eggmet: false);
public string EggLoc => pkm.GetLocationString(eggmet: true); public string EggLoc => pkm.GetLocationString(eggmet: true);
public string Ball => Get(GameInfo.Strings.balllist, pkm.Ball); public string Ball => Get(Strings.balllist, pkm.Ball);
public string OT => pkm.OT_Name; public string OT => pkm.OT_Name;
public string Version => Get(GameInfo.Strings.gamelist, pkm.Version); public string Version => Get(Strings.gamelist, pkm.Version);
public string OTLang => Get(GameInfo.Strings.gamelanguages, pkm.Language) ?? $"UNK {pkm.Language}"; public string OTLang => Get(Strings.gamelanguages, pkm.Language) ?? $"UNK {pkm.Language}";
public string Legal { get { var la = new LegalityAnalysis(pkm); return la.Parsed ? la.Valid.ToString() : "-"; } } public string Legal { get { var la = new LegalityAnalysis(pkm); return la.Parsed ? la.Valid.ToString() : "-"; } }
public string CountryID => pkm.Format > 5 ? pkm.Country.ToString() : "N/A"; public string CountryID => pkm.Format > 5 ? pkm.Country.ToString() : "N/A";
public string RegionID => pkm.Format > 5 ? pkm.Region.ToString() : "N/A"; public string RegionID => pkm.Format > 5 ? pkm.Region.ToString() : "N/A";
@ -90,10 +90,10 @@ namespace PKHeX.WinForms
public int Move2_PPUp => pkm.Move2_PPUps; public int Move2_PPUp => pkm.Move2_PPUps;
public int Move3_PPUp => pkm.Move3_PPUps; public int Move3_PPUp => pkm.Move3_PPUps;
public int Move4_PPUp => pkm.Move4_PPUps; public int Move4_PPUp => pkm.Move4_PPUps;
public string Relearn1 => Get(GameInfo.Strings.movelist, pkm.RelearnMove1); public string Relearn1 => Get(Strings.movelist, pkm.RelearnMove1);
public string Relearn2 => Get(GameInfo.Strings.movelist, pkm.RelearnMove2); public string Relearn2 => Get(Strings.movelist, pkm.RelearnMove2);
public string Relearn3 => Get(GameInfo.Strings.movelist, pkm.RelearnMove3); public string Relearn3 => Get(Strings.movelist, pkm.RelearnMove3);
public string Relearn4 => Get(GameInfo.Strings.movelist, pkm.RelearnMove4); public string Relearn4 => Get(Strings.movelist, pkm.RelearnMove4);
public ushort Checksum => pkm.Checksum; public ushort Checksum => pkm.Checksum;
public int Friendship => pkm.OT_Friendship; public int Friendship => pkm.OT_Friendship;
public int OT_Affection => pkm.OT_Affection; public int OT_Affection => pkm.OT_Affection;
@ -107,9 +107,12 @@ namespace PKHeX.WinForms
#endregion #endregion
public PKMPreview(PKM p) private readonly GameStrings Strings;
public PKMPreview(PKM p, GameStrings strings)
{ {
pkm = p; pkm = p;
Strings = strings;
Stats = pkm.GetStats(pkm.PersonalInfo); Stats = pkm.GetStats(pkm.PersonalInfo);
} }

View file

@ -60,8 +60,10 @@ namespace PKHeX.WinForms
{ {
int count = Count; int count = Count;
for (int i = 0; i < count; ++i) for (int i = 0; i < count; ++i)
{
if (prop.GetValue(this[i]).Equals(key)) if (prop.GetValue(this[i]).Equals(key))
return i; return i;
}
return -1; return -1;
} }

View file

@ -55,10 +55,8 @@ namespace PKHeX.WinForms
private const string PrefixLabel = "L_"; private const string PrefixLabel = "L_";
private const string PrefixCHK = "CHK_"; private const string PrefixCHK = "CHK_";
private void B_Cancel_Click(object sender, EventArgs e) private void B_Cancel_Click(object sender, EventArgs e) => Close();
{
Close();
}
private void B_Save_Click(object sender, EventArgs e) private void B_Save_Click(object sender, EventArgs e)
{ {
Save(); Save();
@ -86,6 +84,7 @@ namespace PKHeX.WinForms
foreach (ColumnStyle style in TLP.ColumnStyles) foreach (ColumnStyle style in TLP.ColumnStyles)
style.SizeType = SizeType.AutoSize; style.SizeType = SizeType.AutoSize;
} }
private static void AddRegimenChoice(RegimenInfo reg, TableLayoutPanel TLP) private static void AddRegimenChoice(RegimenInfo reg, TableLayoutPanel TLP)
{ {
// Get row we add to // Get row we add to
@ -131,6 +130,7 @@ namespace PKHeX.WinForms
{ {
public readonly string Name; public readonly string Name;
public bool CompletedRegimen; public bool CompletedRegimen;
internal RegimenInfo(string name, bool completedRegimen) internal RegimenInfo(string name, bool completedRegimen)
{ {
Name = name; Name = name;
@ -141,8 +141,10 @@ namespace PKHeX.WinForms
private void B_All_Click(object sender, EventArgs e) private void B_All_Click(object sender, EventArgs e)
{ {
if (CHK_SecretUnlocked.Checked) // only give dist if Secret is Unlocked (None -> All -> All*) if (CHK_SecretUnlocked.Checked) // only give dist if Secret is Unlocked (None -> All -> All*)
{
foreach (var c in TLP_DistSuperTrain.Controls.OfType<CheckBox>()) foreach (var c in TLP_DistSuperTrain.Controls.OfType<CheckBox>())
c.Checked = true; c.Checked = true;
}
if (pkm is PK6) if (pkm is PK6)
{ {
@ -152,6 +154,7 @@ namespace PKHeX.WinForms
foreach (var c in TLP_SuperTrain.Controls.OfType<CheckBox>()) foreach (var c in TLP_SuperTrain.Controls.OfType<CheckBox>())
c.Checked = true; c.Checked = true;
} }
private void B_None_Click(object sender, EventArgs e) private void B_None_Click(object sender, EventArgs e)
{ {
CHK_SecretUnlocked.Checked = false; CHK_SecretUnlocked.Checked = false;
@ -161,6 +164,7 @@ namespace PKHeX.WinForms
foreach (var c in TLP_DistSuperTrain.Controls.OfType<CheckBox>()) foreach (var c in TLP_DistSuperTrain.Controls.OfType<CheckBox>())
c.Checked = false; c.Checked = false;
} }
private void CHK_Secret_CheckedChanged(object sender, EventArgs e) private void CHK_Secret_CheckedChanged(object sender, EventArgs e)
{ {
if (!(pkm is PK6)) if (!(pkm is PK6))

View file

@ -2,7 +2,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection;
using System.Text; using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using PKHeX.Core; using PKHeX.Core;
@ -19,6 +18,7 @@ namespace PKHeX.WinForms
CenterToParent(); CenterToParent();
GetContextMenu(); GetContextMenu();
} }
private void GetContextMenu() private void GetContextMenu()
{ {
var mnuHide = new ToolStripMenuItem { Name = "mnuHide", Text = MsgReportColumnHide, }; var mnuHide = new ToolStripMenuItem { Name = "mnuHide", Text = MsgReportColumnHide, };
@ -55,10 +55,11 @@ namespace PKHeX.WinForms
SuspendLayout(); SuspendLayout();
BoxBar.Step = 1; BoxBar.Step = 1;
var PL = new PokemonList<PKMPreview>(); var PL = new PokemonList<PKMPreview>();
var strings = GameInfo.Strings;
foreach (PKM pkm in Data.Where(pkm => pkm.ChecksumValid && pkm.Species != 0)) foreach (PKM pkm in Data.Where(pkm => pkm.ChecksumValid && pkm.Species != 0))
{ {
pkm.Stat_Level = PKX.GetLevel(pkm.Species, pkm.EXP); // recalc Level pkm.Stat_Level = PKX.GetLevel(pkm.Species, pkm.EXP); // recalc Level
PL.Add(new PKMPreview(pkm)); PL.Add(new PKMPreview(pkm, strings));
BoxBar.PerformStep(); BoxBar.PerformStep();
} }
@ -86,12 +87,14 @@ namespace PKHeX.WinForms
ResumeLayout(); ResumeLayout();
} }
private void Data_Sorted(object sender, EventArgs e) private void Data_Sorted(object sender, EventArgs e)
{ {
int height = SpriteUtil.GetSprite(1, 0, 0, 0, false, false).Height + 1; // dummy sprite, max height of a row int height = SpriteUtil.GetSprite(1, 0, 0, 0, false, false).Height + 1; // dummy sprite, max height of a row
for (int i = 0; i < dgData.Rows.Count; i++) for (int i = 0; i < dgData.Rows.Count; i++)
dgData.Rows[i].Height = height; dgData.Rows[i].Height = height;
} }
private void PromptSaveCSV(object sender, FormClosingEventArgs e) private void PromptSaveCSV(object sender, FormClosingEventArgs e)
{ {
if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, MsgReportExportCSV) != DialogResult.Yes) if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, MsgReportExportCSV) != DialogResult.Yes)
@ -104,6 +107,7 @@ namespace PKHeX.WinForms
if (savecsv.ShowDialog() == DialogResult.OK) if (savecsv.ShowDialog() == DialogResult.OK)
Export_CSV(savecsv.FileName); Export_CSV(savecsv.FileName);
} }
private void Export_CSV(string path) private void Export_CSV(string path)
{ {
var sb = new StringBuilder(); var sb = new StringBuilder();
@ -151,13 +155,4 @@ namespace PKHeX.WinForms
return newlines; return newlines;
} }
} }
public static class ExtensionMethods
{
public static void DoubleBuffered(this DataGridView dgv, bool setting)
{
Type dgvType = dgv.GetType();
PropertyInfo pi = dgvType.GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic);
pi.SetValue(dgv, setting, null);
}
}
} }

View file

@ -329,9 +329,27 @@ namespace PKHeX.WinForms
} }
private void LoadDatabase() private void LoadDatabase()
{
RawDB = LoadPKMSaves(DatabasePath, Main.BackupPath, EXTERNAL_SAV, SAV);
// Load stats for pkm who do not have any
foreach (var pk in RawDB.Where(z => z.Stat_Level == 0))
{
pk.Stat_Level = pk.CurrentLevel;
pk.SetStats(pk.GetStats(pk.PersonalInfo));
}
try
{
BeginInvoke(new MethodInvoker(() => SetResults(RawDB)));
}
catch { /* Window Closed? */ }
}
private static List<PKM> LoadPKMSaves(string pkmdb, string savdb, string EXTERNAL_SAV, SaveFile SAV)
{ {
var dbTemp = new ConcurrentBag<PKM>(); var dbTemp = new ConcurrentBag<PKM>();
var files = Directory.EnumerateFiles(DatabasePath, "*", SearchOption.AllDirectories); var files = Directory.EnumerateFiles(pkmdb, "*", SearchOption.AllDirectories);
Parallel.ForEach(files, file => Parallel.ForEach(files, file =>
{ {
FileInfo fi = new FileInfo(file); FileInfo fi = new FileInfo(file);
@ -344,7 +362,7 @@ namespace PKHeX.WinForms
}); });
#if LOADALL #if LOADALL
if (SaveUtil.GetSavesFromFolder(Main.BackupPath, false, out IEnumerable<string> result)) if (SaveUtil.GetSavesFromFolder(savdb, false, out IEnumerable<string> result))
{ {
Parallel.ForEach(result, file => Parallel.ForEach(result, file =>
{ {
@ -364,25 +382,14 @@ namespace PKHeX.WinForms
}); });
} }
#endif #endif
// Fetch from save file
var savpkm = SAV.BoxData.Where(pk => pk.Species != 0);
var bakpkm = dbTemp.Where(pk => pk.Species != 0).OrderBy(pk => pk.Identifier);
var db = bakpkm.Concat(savpkm).Where(pk => pk.ChecksumValid && pk.Sanity == 0);
// Prepare Database // Prepare Database
RawDB = new List<PKM>(dbTemp.OrderBy(pk => pk.Identifier) return new List<PKM>(db);
.Concat(SAV.BoxData.Where(pk => pk.Species != 0)) // Fetch from save file
.Where(pk => pk.ChecksumValid && pk.Species != 0 && pk.Sanity == 0)
.Distinct());
// Load stats for pkm who do not have any
foreach (var pk in RawDB.Where(z => z.Stat_Level == 0))
{
pk.Stat_Level = pk.CurrentLevel;
pk.SetStats(pk.GetStats(pk.PersonalInfo));
}
try
{
BeginInvoke(new MethodInvoker(() => SetResults(RawDB)));
}
catch { /* Window Closed? */ }
} }
// IO Usage // IO Usage

View file

@ -10,6 +10,7 @@ namespace PKHeX.WinForms
{ {
private readonly G1OverworldSpawner Overworld; private readonly G1OverworldSpawner Overworld;
private void SAV_EventReset1_FormClosing(object sender, FormClosingEventArgs e) => Overworld.Save(); private void SAV_EventReset1_FormClosing(object sender, FormClosingEventArgs e) => Overworld.Save();
public SAV_EventReset1(SaveFile sav) public SAV_EventReset1(SaveFile sav)
{ {
InitializeComponent(); InitializeComponent();
@ -33,7 +34,7 @@ namespace PKHeX.WinForms
var b = new Button var b = new Button
{ {
Text = pkmname, Enabled = pair.IsDespawned, Text = pkmname, Enabled = pair.IsDespawned,
Size = new Size(Width / 2 - 25, 22), Size = new Size((Width / 2) - 25, 22),
}; };
b.Click += (s, e) => b.Click += (s, e) =>
{ {

View file

@ -60,7 +60,7 @@ namespace PKHeX.WinForms
} }
} }
else else
TB_OTName.Visible = L_TrainerName.Visible = GB_TCM.Visible = false; { TB_OTName.Visible = L_TrainerName.Visible = GB_TCM.Visible = false; }
NUD_BP.Value = Math.Min(NUD_BP.Maximum, SAV.BP); NUD_BP.Value = Math.Min(NUD_BP.Maximum, SAV.BP);
NUD_Coins.Value = Math.Min(NUD_Coins.Maximum, SAV.Coin); NUD_Coins.Value = Math.Min(NUD_Coins.Maximum, SAV.Coin);
@ -95,6 +95,7 @@ namespace PKHeX.WinForms
#region Joyful #region Joyful
private int JUMPS_IN_ROW, JUMPS_SCORE, JUMPS_5_IN_ROW; private int JUMPS_IN_ROW, JUMPS_SCORE, JUMPS_5_IN_ROW;
private int BERRIES_IN_ROW, BERRIES_SCORE, BERRIES_5_IN_ROW; private int BERRIES_IN_ROW, BERRIES_SCORE, BERRIES_5_IN_ROW;
private void ReadJoyful() private void ReadJoyful()
{ {
switch (SAV.Version) switch (SAV.Version)
@ -125,6 +126,7 @@ namespace PKHeX.WinForms
TB_B2.Text = Math.Min((ushort)9999, BitConverter.ToUInt16(SAV.Data, BERRIES_SCORE)).ToString(); TB_B2.Text = Math.Min((ushort)9999, BitConverter.ToUInt16(SAV.Data, BERRIES_SCORE)).ToString();
TB_B3.Text = Math.Min((ushort)9999, BitConverter.ToUInt16(SAV.Data, BERRIES_5_IN_ROW)).ToString(); TB_B3.Text = Math.Min((ushort)9999, BitConverter.ToUInt16(SAV.Data, BERRIES_5_IN_ROW)).ToString();
} }
private void SaveJoyful() private void SaveJoyful()
{ {
BitConverter.GetBytes((ushort)Util.ToUInt32(TB_J1.Text)).CopyTo(SAV.Data, JUMPS_IN_ROW); BitConverter.GetBytes((ushort)Util.ToUInt32(TB_J1.Text)).CopyTo(SAV.Data, JUMPS_IN_ROW);
@ -142,8 +144,10 @@ namespace PKHeX.WinForms
var Pouches = SAV.Inventory; var Pouches = SAV.Inventory;
var itemlist = GameInfo.Strings.GetItemStrings(SAV.Generation, SAV.Version).ToArray(); var itemlist = GameInfo.Strings.GetItemStrings(SAV.Generation, SAV.Version).ToArray();
for (int i = 0; i < itemlist.Length; i++) for (int i = 0; i < itemlist.Length; i++)
{
if (string.IsNullOrEmpty(itemlist[i])) if (string.IsNullOrEmpty(itemlist[i]))
itemlist[i] = $"(Item #{i:000})"; itemlist[i] = $"(Item #{i:000})";
}
const int oldsea = 0x178; const int oldsea = 0x178;
int[] tickets = {0x109, 0x113, 0x172, 0x173, oldsea }; // item IDs int[] tickets = {0x109, 0x113, 0x172, 0x173, oldsea }; // item IDs
@ -198,6 +202,7 @@ namespace PKHeX.WinForms
B_GetTickets.Enabled = false; B_GetTickets.Enabled = false;
} }
private void ReadFerry() private void ReadFerry()
{ {
CHK_Catchable.Checked = IsFerryFlagActive(0x864); CHK_Catchable.Checked = IsFerryFlagActive(0x864);
@ -211,14 +216,17 @@ namespace PKHeX.WinForms
CHK_InitialFaraway.Checked = IsFerryFlagActive(0x1B0); CHK_InitialFaraway.Checked = IsFerryFlagActive(0x1B0);
CHK_InitialNavel.Checked = IsFerryFlagActive(0x1DB); CHK_InitialNavel.Checked = IsFerryFlagActive(0x1DB);
} }
private bool IsFerryFlagActive(int n) private bool IsFerryFlagActive(int n)
{ {
return SAV.GetEventFlag(n); return SAV.GetEventFlag(n);
} }
private void SetFerryFlagFromNum(int n, bool b) private void SetFerryFlagFromNum(int n, bool b)
{ {
SAV.SetEventFlag(n, b); SAV.SetEventFlag(n, b);
} }
private void SaveFerry() private void SaveFerry()
{ {
SetFerryFlagFromNum(0x864, CHK_Catchable.Checked); SetFerryFlagFromNum(0x864, CHK_Catchable.Checked);
@ -260,7 +268,10 @@ namespace PKHeX.WinForms
foreach (RadioButton r in StatRBA) foreach (RadioButton r in StatRBA)
r.Checked = false; r.Checked = false;
if (BFT[BFF[facility][1]] == null) CB_Stats2.Visible = false; if (BFT[BFF[facility][1]] == null)
{
CB_Stats2.Visible = false;
}
else else
{ {
CB_Stats2.Visible = true; CB_Stats2.Visible = true;
@ -275,11 +286,13 @@ namespace PKHeX.WinForms
editingcont = false; editingcont = false;
StatRBA[0].Checked = true; StatRBA[0].Checked = true;
} }
private void ChangeStat(object sender, EventArgs e) private void ChangeStat(object sender, EventArgs e)
{ {
if (editingcont) return; if (editingcont) return;
StatAddrControl(SetValToSav: -2, SetSavToVal: true); StatAddrControl(SetValToSav: -2, SetSavToVal: true);
} }
private void StatAddrControl(int SetValToSav = -2, bool SetSavToVal = false) private void StatAddrControl(int SetValToSav = -2, bool SetSavToVal = false)
{ {
int Facility = CB_Stats1.SelectedIndex; int Facility = CB_Stats1.SelectedIndex;
@ -305,14 +318,14 @@ namespace PKHeX.WinForms
SetValToSav = Array.IndexOf(BFV[BFF[Facility][0]], SetValToSav); SetValToSav = Array.IndexOf(BFV[BFF[Facility][0]], SetValToSav);
if (SetValToSav < 0) return; if (SetValToSav < 0) return;
if (val > 9999) val = 9999; if (val > 9999) val = 9999;
BitConverter.GetBytes(val).CopyTo(SAV.Data, SAV.GetBlockOffset(0) + BFF[Facility][2 + SetValToSav] + 4 * BattleType + 2 * RBi); BitConverter.GetBytes(val).CopyTo(SAV.Data, SAV.GetBlockOffset(0) + BFF[Facility][2 + SetValToSav] + (4 * BattleType) + (2 * RBi));
return; return;
} }
if (SetValToSav == -1) if (SetValToSav == -1)
{ {
int p = BFF[Facility][2 + BFV[BFF[Facility][0]].Length + BattleType] + RBi; int p = BFF[Facility][2 + BFV[BFF[Facility][0]].Length + BattleType] + RBi;
int offset = SAV.GetBlockOffset(0) + 0xCDC; int offset = SAV.GetBlockOffset(0) + 0xCDC;
BitConverter.GetBytes(BitConverter.ToUInt32(SAV.Data, offset) & (uint)~(1 << p) | (uint)((CHK_Continue.Checked ? 1 : 0) << p)).CopyTo(SAV.Data, offset); BitConverter.GetBytes((BitConverter.ToUInt32(SAV.Data, offset) & (uint)~(1 << p)) | (uint)((CHK_Continue.Checked ? 1 : 0) << p)).CopyTo(SAV.Data, offset);
return; return;
} }
if (!SetSavToVal) if (!SetSavToVal)
@ -321,13 +334,14 @@ namespace PKHeX.WinForms
editingval = true; editingval = true;
for (int i = 0; i < BFV[BFF[Facility][0]].Length; i++) for (int i = 0; i < BFV[BFF[Facility][0]].Length; i++)
{ {
int vali = BitConverter.ToUInt16(SAV.Data, SAV.GetBlockOffset(0) + BFF[Facility][2 + i] + 4 * BattleType + 2 * RBi); int vali = BitConverter.ToUInt16(SAV.Data, SAV.GetBlockOffset(0) + BFF[Facility][2 + i] + (4 * BattleType) + (2 * RBi));
if (vali > 9999) vali = 9999; if (vali > 9999) vali = 9999;
StatNUDA[BFV[BFF[Facility][0]][i]].Value = vali; StatNUDA[BFV[BFF[Facility][0]][i]].Value = vali;
} }
CHK_Continue.Checked = (BitConverter.ToUInt32(SAV.Data, SAV.GetBlockOffset(0) + 0xCDC) & 1 << (BFF[Facility][2 + BFV[BFF[Facility][0]].Length + BattleType] + RBi)) != 0; CHK_Continue.Checked = (BitConverter.ToUInt32(SAV.Data, SAV.GetBlockOffset(0) + 0xCDC) & 1 << (BFF[Facility][2 + BFV[BFF[Facility][0]].Length + BattleType] + RBi)) != 0;
editingval = false; editingval = false;
} }
private void ChangeStatVal(object sender, EventArgs e) private void ChangeStatVal(object sender, EventArgs e)
{ {
if (editingval) return; if (editingval) return;
@ -390,11 +404,13 @@ namespace PKHeX.WinForms
loading = false; loading = false;
CB_Stats1.SelectedIndex = 0; CB_Stats1.SelectedIndex = 0;
} }
private void SetFrontierSymbols() private void SetFrontierSymbols()
{ {
for (int i = 0; i < SymbolButtonA.Length; i++) for (int i = 0; i < SymbolButtonA.Length; i++)
SymbolButtonA[i].BackColor = SymbolColorA[Symbols[i]]; SymbolButtonA[i].BackColor = SymbolColorA[Symbols[i]];
} }
private void SaveBattleFrontier() private void SaveBattleFrontier()
{ {
uint iSymbols = 0; uint iSymbols = 0;
@ -403,9 +419,10 @@ namespace PKHeX.WinForms
if (CHK_ActivatePass.Checked) if (CHK_ActivatePass.Checked)
iSymbols |= 1 << 14; iSymbols |= 1 << 14;
uint val = (uint)(BitConverter.ToUInt32(SAV.Data, ofsSymbols) & ~(0x7FFF << 4) | (iSymbols & 0x7FFF) << 4); uint val = (uint)((BitConverter.ToUInt32(SAV.Data, ofsSymbols) & ~(0x7FFF << 4)) | (iSymbols & 0x7FFF) << 4);
BitConverter.GetBytes(val).CopyTo(SAV.Data, ofsSymbols); BitConverter.GetBytes(val).CopyTo(SAV.Data, ofsSymbols);
} }
private void BTN_Symbol_Click(object sender, EventArgs e) private void BTN_Symbol_Click(object sender, EventArgs e)
{ {
int index = Array.IndexOf(SymbolButtonA, sender); int index = Array.IndexOf(SymbolButtonA, sender);

View file

@ -8,6 +8,7 @@ namespace PKHeX.WinForms
{ {
private readonly SaveFile Origin; private readonly SaveFile Origin;
private readonly SAV3 SAV; private readonly SAV3 SAV;
public SAV_RTC3(SaveFile sav) public SAV_RTC3(SaveFile sav)
{ {
InitializeComponent(); InitializeComponent();
@ -34,6 +35,7 @@ namespace PKHeX.WinForms
NUD_EMinute.Value = Math.Min(NUD_EMinute.Maximum, ClockElapsed.Minute); NUD_EMinute.Value = Math.Min(NUD_EMinute.Maximum, ClockElapsed.Minute);
NUD_ESecond.Value = Math.Min(NUD_ESecond.Maximum, ClockElapsed.Second); NUD_ESecond.Value = Math.Min(NUD_ESecond.Maximum, ClockElapsed.Second);
} }
private void SaveData() private void SaveData()
{ {
ClockInitial.Day = (ushort)NUD_IDay.Value; ClockInitial.Day = (ushort)NUD_IDay.Value;
@ -46,6 +48,7 @@ namespace PKHeX.WinForms
ClockElapsed.Minute = (byte)NUD_EMinute.Value; ClockElapsed.Minute = (byte)NUD_EMinute.Value;
ClockElapsed.Second = (byte)NUD_ESecond.Value; ClockElapsed.Second = (byte)NUD_ESecond.Value;
} }
private void B_Save_Click(object sender, EventArgs e) private void B_Save_Click(object sender, EventArgs e)
{ {
SaveData(); SaveData();
@ -56,10 +59,12 @@ namespace PKHeX.WinForms
Origin.SetData(SAV.Data, 0); Origin.SetData(SAV.Data, 0);
Close(); Close();
} }
private void B_Cancel_Click(object sender, EventArgs e) private void B_Cancel_Click(object sender, EventArgs e)
{ {
Close(); Close();
} }
private void B_Reset_Click(object sender, EventArgs e) private void B_Reset_Click(object sender, EventArgs e)
{ {
NUD_IDay.Value = NUD_IHour.Value = NUD_IMinute.Value = NUD_ISecond.Value = 0; NUD_IDay.Value = NUD_IHour.Value = NUD_IMinute.Value = NUD_ISecond.Value = 0;
@ -69,7 +74,7 @@ namespace PKHeX.WinForms
private void B_BerryFix_Click(object sender, EventArgs e) private void B_BerryFix_Click(object sender, EventArgs e)
{ {
NUD_EDay.Value = Math.Max(2*366 + 2, NUD_EDay.Value); // advance NUD_EDay.Value = Math.Max((2 * 366) + 2, NUD_EDay.Value); // advance
System.Media.SystemSounds.Asterisk.Play(); System.Media.SystemSounds.Asterisk.Play();
} }
} }

View file

@ -36,6 +36,7 @@ namespace PKHeX.WinForms
CHK_Active.Checked = Reader.Active; CHK_Active.Checked = Reader.Active;
NUD_Level.Value = Math.Min(NUD_Level.Maximum, Reader.CurrentLevel); NUD_Level.Value = Math.Min(NUD_Level.Maximum, Reader.CurrentLevel);
} }
private void SaveData() private void SaveData()
{ {
int[] IVs = new int[6]; int[] IVs = new int[6];
@ -49,11 +50,13 @@ namespace PKHeX.WinForms
Reader.Active = CHK_Active.Checked; Reader.Active = CHK_Active.Checked;
Reader.CurrentLevel = (int)NUD_Level.Value; Reader.CurrentLevel = (int)NUD_Level.Value;
} }
private void B_Save_Click(object sender, EventArgs e) private void B_Save_Click(object sender, EventArgs e)
{ {
SaveData(); SaveData();
Close(); Close();
} }
private void B_Cancel_Click(object sender, EventArgs e) private void B_Cancel_Click(object sender, EventArgs e)
{ {
Close(); Close();

View file

@ -19,6 +19,7 @@ namespace PKHeX.WinForms
private readonly SAV4 SAV; private readonly SAV4 SAV;
private const int Count = 7; private const int Count = 7;
private static readonly string[] itemlist = {"Red", "Yellow", "Blue", "Green", "Pink", "White", "Black"}; private static readonly string[] itemlist = {"Red", "Yellow", "Blue", "Green", "Pink", "White", "Black"};
private void Setup() private void Setup()
{ {
dgv.Rows.Clear(); dgv.Rows.Clear();
@ -63,18 +64,21 @@ namespace PKHeX.WinForms
{ {
Close(); Close();
} }
private void B_All_Click(object sender, EventArgs e) private void B_All_Click(object sender, EventArgs e)
{ {
for (int i = 0; i < Count; i++) for (int i = 0; i < Count; i++)
SAV.SetApricornCount(i, 99); SAV.SetApricornCount(i, 99);
Setup(); Setup();
} }
private void B_None_Click(object sender, EventArgs e) private void B_None_Click(object sender, EventArgs e)
{ {
for (int i = 0; i < Count; i++) for (int i = 0; i < Count; i++)
SAV.SetApricornCount(i, 0); SAV.SetApricornCount(i, 0);
Setup(); Setup();
} }
private void B_Save_Click(object sender, EventArgs e) private void B_Save_Click(object sender, EventArgs e)
{ {
for (int i = 0; i < Count; i++) for (int i = 0; i < Count; i++)

View file

@ -9,6 +9,7 @@ namespace PKHeX.WinForms
{ {
private readonly SaveFile Origin; private readonly SaveFile Origin;
private readonly SAV4 SAV; private readonly SAV4 SAV;
public SAV_HoneyTree(SaveFile sav) public SAV_HoneyTree(SaveFile sav)
{ {
InitializeComponent(); InitializeComponent();
@ -37,6 +38,7 @@ namespace PKHeX.WinForms
private int TreeSpecies => Table[(int)NUD_Group.Value][(int)NUD_Slot.Value]; private int TreeSpecies => Table[(int)NUD_Group.Value][(int)NUD_Slot.Value];
private void B_Catchable_Click(object sender, EventArgs e) => NUD_Time.Value = 1080; private void B_Catchable_Click(object sender, EventArgs e) => NUD_Time.Value = 1080;
private void ChangeGroupSlot(object sender, EventArgs e) private void ChangeGroupSlot(object sender, EventArgs e)
{ {
int species = TreeSpecies; int species = TreeSpecies;
@ -51,12 +53,14 @@ namespace PKHeX.WinForms
if (species == 446 && !MunchlaxTrees.Contains(CB_TreeList.SelectedIndex)) if (species == 446 && !MunchlaxTrees.Contains(CB_TreeList.SelectedIndex))
WinFormsUtil.Alert("Catching Munchlax in this tree will make it illegal for this savegame's TID/SID combination."); WinFormsUtil.Alert("Catching Munchlax in this tree will make it illegal for this savegame's TID/SID combination.");
} }
private void ChangeTree(object sender, EventArgs e) private void ChangeTree(object sender, EventArgs e)
{ {
SaveTree(); SaveTree();
entry = CB_TreeList.SelectedIndex; entry = CB_TreeList.SelectedIndex;
ReadTree(); ReadTree();
} }
private void ReadTree() private void ReadTree()
{ {
loading = true; loading = true;
@ -70,6 +74,7 @@ namespace PKHeX.WinForms
ChangeGroupSlot(null, null); ChangeGroupSlot(null, null);
loading = false; loading = false;
} }
private void SaveTree() private void SaveTree()
{ {
if (Tree == null) if (Tree == null)
@ -89,6 +94,7 @@ namespace PKHeX.WinForms
Origin.SetData(SAV.Data, 0); Origin.SetData(SAV.Data, 0);
Close(); Close();
} }
private void B_Cancel_Click(object sender, EventArgs e) => Close(); private void B_Cancel_Click(object sender, EventArgs e) => Close();
} }
} }

View file

@ -13,6 +13,7 @@ namespace PKHeX.WinForms
{ {
private readonly SaveFile Origin; private readonly SaveFile Origin;
private readonly SAV4 SAV; private readonly SAV4 SAV;
public SAV_Misc4(SaveFile sav) public SAV_Misc4(SaveFile sav)
{ {
InitializeComponent(); InitializeComponent();
@ -98,6 +99,7 @@ namespace PKHeX.WinForms
private readonly int ofsUGFlagCount = -1; private readonly int ofsUGFlagCount = -1;
private readonly int ofsPoketch = -1; private readonly int ofsPoketch = -1;
private int[] FlyDestC; private int[] FlyDestC;
private void ReadMain() private void ReadMain()
{ {
NUD_Coin.Value = SAV.Coin; NUD_Coin.Value = SAV.Coin;
@ -145,6 +147,7 @@ namespace PKHeX.WinForms
CB_UpgradeMap.SelectedIndex = index; CB_UpgradeMap.SelectedIndex = index;
} }
} }
private void SaveMain() private void SaveMain()
{ {
SAV.Coin = (uint)NUD_Coin.Value; SAV.Coin = (uint)NUD_Coin.Value;
@ -154,25 +157,30 @@ namespace PKHeX.WinForms
if (FlyDestC[i] < 32) if (FlyDestC[i] < 32)
{ {
if (CLB_FlyDest.GetItemChecked(i)) if (CLB_FlyDest.GetItemChecked(i))
valFly |= (uint)1 << FlyDestC[i]; valFly |= (uint) 1 << FlyDestC[i];
else else
valFly &= ~((uint)1 << FlyDestC[i]); valFly &= ~((uint) 1 << FlyDestC[i]);
}
else
{
var o = ofsFly + (FlyDestC[i] >> 3);
SAV.Data[o] = (byte)((SAV.Data[o] & ~(1 << (FlyDestC[i] & 7))) | (CLB_FlyDest.GetItemChecked(i) ? 1 << (FlyDestC[i] & 7) : 0));
} }
else SAV.Data[ofsFly + (FlyDestC[i] >> 3)] = (byte)(SAV.Data[ofsFly + (FlyDestC[i] >> 3)] & ~(1 << (FlyDestC[i] & 7)) | (CLB_FlyDest.GetItemChecked(i) ? 1 << (FlyDestC[i] & 7) : 0));
} }
BitConverter.GetBytes(valFly).CopyTo(SAV.Data, ofsFly); BitConverter.GetBytes(valFly).CopyTo(SAV.Data, ofsFly);
BitConverter.GetBytes((ushort)NUD_BP.Value).CopyTo(SAV.Data, ofsBP); BitConverter.GetBytes((ushort)NUD_BP.Value).CopyTo(SAV.Data, ofsBP);
if (ofsPoketch > 0) SavePoketch(); if (ofsPoketch > 0) SavePoketch();
if (ofsUGFlagCount > 0) if (ofsUGFlagCount > 0)
BitConverter.GetBytes(BitConverter.ToUInt32(SAV.Data, ofsUGFlagCount) & ~(uint)0xFFFFF | (uint)NUD_UGFlags.Value).CopyTo(SAV.Data, ofsUGFlagCount); BitConverter.GetBytes((BitConverter.ToUInt32(SAV.Data, ofsUGFlagCount) & ~(uint)0xFFFFF) | (uint)NUD_UGFlags.Value).CopyTo(SAV.Data, ofsUGFlagCount);
if (ofsMap > 0) if (ofsMap > 0)
{ {
int valMap = CB_UpgradeMap.SelectedIndex; int valMap = CB_UpgradeMap.SelectedIndex;
if (valMap >= 0) if (valMap >= 0)
SAV.Data[ofsMap] = (byte)(SAV.Data[ofsMap] & 0xE7 | valMap << 3); SAV.Data[ofsMap] = (byte)((SAV.Data[ofsMap] & 0xE7) | valMap << 3);
} }
} }
private void B_AllFlyDest_Click(object sender, EventArgs e) private void B_AllFlyDest_Click(object sender, EventArgs e)
{ {
for (int i = 0; i < CLB_FlyDest.Items.Count; i++) for (int i = 0; i < CLB_FlyDest.Items.Count; i++)
@ -184,6 +192,7 @@ namespace PKHeX.WinForms
private byte[] ColorTable; private byte[] ColorTable;
private bool[] oldPoketchVal; private bool[] oldPoketchVal;
private readonly ToolTip tip1 = new ToolTip(); private readonly ToolTip tip1 = new ToolTip();
private void ReadPoketch() private void ReadPoketch()
{ {
string[] PoketchTitle = new[] { string[] PoketchTitle = new[] {
@ -214,19 +223,22 @@ namespace PKHeX.WinForms
tip1.SetToolTip(PB_DotArtist, tip); tip1.SetToolTip(PB_DotArtist, tip);
TAB_Main.AllowDrop = true; TAB_Main.AllowDrop = true;
} }
private void SavePoketch() private void SavePoketch()
{ {
byte count = 0; byte count = 0;
for (int i = 1; i <= CLB_Poketch.Items.Count; i++) for (int i = 1; i <= CLB_Poketch.Items.Count; i++)
{ {
if (CLB_Poketch.GetItemChecked(i-1)) if (CLB_Poketch.GetItemChecked(i - 1))
{ {
count++; count++;
if (!oldPoketchVal[i]) if (!oldPoketchVal[i])
SAV.Data[ofsPoketch + i] = 1; SAV.Data[ofsPoketch + i] = 1;
} }
else if (oldPoketchVal[i]) else if (oldPoketchVal[i])
{
SAV.Data[ofsPoketch + i] = 0; SAV.Data[ofsPoketch + i] = 0;
}
} }
SAV.Data[ofsPoketch - 2] = count; SAV.Data[ofsPoketch - 2] = count;
byte current = SAV.Data[ofsPoketch - 1]; byte current = SAV.Data[ofsPoketch - 1];
@ -242,22 +254,30 @@ namespace PKHeX.WinForms
if (inp.Length != 120) return; if (inp.Length != 120) return;
byte[] dupbyte = new byte[23040]; byte[] dupbyte = new byte[23040];
for (int iy = 0; iy < 20; iy++) for (int iy = 0; iy < 20; iy++)
{
for (int ix = 0; ix < 24; ix++) for (int ix = 0; ix < 24; ix++)
{ {
var ib = ix + 24 * iy; var ib = ix + (24 * iy);
var ict = ColorTable[inp[ib >> 2] >> (ib % 4 << 1) & 3]; var ict = ColorTable[inp[ib >> 2] >> (ib % 4 << 1) & 3];
var iz = 12 * ix + 0x480 * iy; var iz = (12 * ix) + (0x480 * iy);
for (int izy = 0; izy < 4; izy++) for (int izy = 0; izy < 4; izy++)
{
for (int izx = 0; izx < 4; izx++) for (int izx = 0; izx < 4; izx++)
{
for (int ic = 0; ic < 3; ic++) for (int ic = 0; ic < 3; ic++)
dupbyte[ic + 3 * izx + 0x120 * izy + iz] = ict; dupbyte[ic + (3 * izx) + (0x120 * izy) + iz] = ict;
}
}
} }
}
Bitmap dabmp = new Bitmap(96, 80); Bitmap dabmp = new Bitmap(96, 80);
BitmapData dabdata = dabmp.LockBits(new Rectangle(0, 0, dabmp.Width, dabmp.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb); BitmapData dabdata = dabmp.LockBits(new Rectangle(0, 0, dabmp.Width, dabmp.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
System.Runtime.InteropServices.Marshal.Copy(dupbyte, 0, dabdata.Scan0, dupbyte.Length); System.Runtime.InteropServices.Marshal.Copy(dupbyte, 0, dabdata.Scan0, dupbyte.Length);
dabmp.UnlockBits(dabdata); dabmp.UnlockBits(dabdata);
PB_DotArtist.Image = dabmp; PB_DotArtist.Image = dabmp;
} }
private void SetFlagsFromFileName(string inpFileName) private void SetFlagsFromFileName(string inpFileName)
{ {
if (new FileInfo(inpFileName).Length > 2058) return; // 24*20*4(ARGB)=1920 if (new FileInfo(inpFileName).Length > 2058) return; // 24*20*4(ARGB)=1920
@ -278,12 +298,14 @@ namespace PKHeX.WinForms
byte[] BrightCount = new byte[0x100]; byte[] BrightCount = new byte[0x100];
byte[] iBrightCount = new byte[0x100]; byte[] iBrightCount = new byte[0x100];
for (int iy = 0; iy < 20; iy++) for (int iy = 0; iy < 20; iy++)
{
for (int ix = 0; ix < 24; ix++) for (int ix = 0; ix < 24; ix++)
{ {
var ig = (byte)(0xFF * bmp.GetPixel(ix, iy).GetBrightness()); var ig = (byte)(0xFF * bmp.GetPixel(ix, iy).GetBrightness());
BrightMap[ix + 24 * iy] = ig; BrightMap[ix + (24 * iy)] = ig;
BrightCount[ig]++; BrightCount[ig]++;
} }
}
int ColorCount = BrightCount.Count(v => v > 0); int ColorCount = BrightCount.Count(v => v > 0);
if (ColorCount > 4 || ColorCount == 0) return; if (ColorCount > 4 || ColorCount == 0) return;
@ -297,8 +319,11 @@ namespace PKHeX.WinForms
{ {
BrightCount.CopyTo(iBrightCount, 0); BrightCount.CopyTo(iBrightCount, 0);
for (int i = 0, j = 0; i < 0x100; i++) for (int i = 0, j = 0; i < 0x100; i++)
{
if (iBrightCount[i] > 0) if (iBrightCount[i] > 0)
iBrightCount[i] = LCT[j++]; iBrightCount[i] = LCT[j++];
}
var errtot = 0; var errtot = 0;
for (int i = 0; i < 480; i++) for (int i = 0; i < 480; i++)
errtot += Math.Abs(BrightMap[i] - ColorTable[iBrightCount[BrightMap[i]]]); errtot += Math.Abs(BrightMap[i] - ColorTable[iBrightCount[BrightMap[i]]]);
@ -311,8 +336,11 @@ namespace PKHeX.WinForms
if (LCT[0] >= 4) break; if (LCT[0] >= 4) break;
} }
for (int i = 0, j = 0; i < 0x100; i++) for (int i = 0, j = 0; i < 0x100; i++)
{
if (BrightCount[i] > 0) if (BrightCount[i] > 0)
BrightCount[i] = mLCT[j++]; BrightCount[i] = mLCT[j++];
}
for (int i = 0; i < 480; i++) for (int i = 0; i < 480; i++)
BrightMap[i] = BrightCount[BrightMap[i]]; BrightMap[i] = BrightCount[BrightMap[i]];
@ -353,7 +381,7 @@ namespace PKHeX.WinForms
else if (inpX > 95) inpX = 95; else if (inpX > 95) inpX = 95;
if (inpY < 0) inpY = 0; if (inpY < 0) inpY = 0;
else if (inpY > 79) inpY = 79; else if (inpY > 79) inpY = 79;
int i = (inpX >> 2) + 24 * (inpY >> 2); int i = (inpX >> 2) + (24 * (inpY >> 2));
byte[] ndab = new byte[120]; byte[] ndab = new byte[120];
DotArtistByte.CopyTo(ndab, 0); DotArtistByte.CopyTo(ndab, 0);
byte c = (byte)(ndab[i >> 2] >> (i % 4 << 1) & 3); byte c = (byte)(ndab[i >> 2] >> (i % 4 << 1) & 3);
@ -386,6 +414,7 @@ namespace PKHeX.WinForms
SetFlagsFromFileName(t[0]); SetFlagsFromFileName(t[0]);
SetPictureBoxFromFlags(DotArtistByte); SetPictureBoxFromFlags(DotArtistByte);
} }
private void PB_DotArtist_MouseClick(object sender, MouseEventArgs e) private void PB_DotArtist_MouseClick(object sender, MouseEventArgs e)
{ {
SetFlagsFromClickPoint(e.X, e.Y); SetFlagsFromClickPoint(e.X, e.Y);
@ -410,6 +439,7 @@ namespace PKHeX.WinForms
private NumericUpDown[] HallNUDA; private NumericUpDown[] HallNUDA;
private bool HallStatUpdated; private bool HallStatUpdated;
private int ofsHallStat = -1; private int ofsHallStat = -1;
private void ReadBattleFrontier() private void ReadBattleFrontier()
{ {
BFV = new[] { BFV = new[] {
@ -491,14 +521,18 @@ namespace PKHeX.WinForms
editing = false; editing = false;
CB_Stats1.SelectedIndex = 0; CB_Stats1.SelectedIndex = 0;
} }
private void SaveBattleFrontier() private void SaveBattleFrontier()
{ {
if (ofsPrints > 0) if (ofsPrints > 0)
{
for (int i = 0; i < Prints.Length; i++) for (int i = 0; i < Prints.Length; i++)
{ {
if (Prints[i] == 1 + Math.Sign((BitConverter.ToUInt16(SAV.Data, ofsPrints + (i << 1)) >> 1) - 1)) continue; if (Prints[i] == 1 + Math.Sign((BitConverter.ToUInt16(SAV.Data, ofsPrints + (i << 1)) >> 1) - 1)) continue;
BitConverter.GetBytes(Prints[i] << 1).CopyTo(SAV.Data, ofsPrints + (i << 1)); BitConverter.GetBytes(Prints[i] << 1).CopyTo(SAV.Data, ofsPrints + (i << 1));
} }
}
if (HallStatUpdated) if (HallStatUpdated)
BitConverter.GetBytes(SaveUtil.CRC16_CCITT(SAV.Data, ofsHallStat, 0xBAE)).CopyTo(SAV.Data, ofsHallStat + 0xBAE); BitConverter.GetBytes(SaveUtil.CRC16_CCITT(SAV.Data, ofsHallStat, 0xBAE)).CopyTo(SAV.Data, ofsHallStat + 0xBAE);
} }
@ -508,6 +542,7 @@ namespace PKHeX.WinForms
for (int i = 0; i < PrintButtonA.Length; i++) for (int i = 0; i < PrintButtonA.Length; i++)
PrintButtonA[i].BackColor = PrintColorA[Prints[i]]; PrintButtonA[i].BackColor = PrintColorA[Prints[i]];
} }
private void BTN_Print_Click(object sender, EventArgs e) private void BTN_Print_Click(object sender, EventArgs e)
{ {
int index = Array.IndexOf(PrintButtonA, sender); int index = Array.IndexOf(PrintButtonA, sender);
@ -551,6 +586,7 @@ namespace PKHeX.WinForms
editing = false; editing = false;
CB_Stats2.SelectedIndex = 0; CB_Stats2.SelectedIndex = 0;
} }
private void ChangeStat(object sender, EventArgs e) private void ChangeStat(object sender, EventArgs e)
{ {
if (editing) return; if (editing) return;
@ -571,12 +607,13 @@ namespace PKHeX.WinForms
editing = false; editing = false;
} }
} }
private void StatAddrControl(int SetValToSav = -2, bool SetSavToVal = false) private void StatAddrControl(int SetValToSav = -2, bool SetSavToVal = false)
{ {
int Facility = CB_Stats1.SelectedIndex; int Facility = CB_Stats1.SelectedIndex;
int BattleType = CB_Stats2.SelectedIndex; int BattleType = CB_Stats2.SelectedIndex;
int RBi = StatRBA[1].Checked ? 1 : 0; int RBi = StatRBA[1].Checked ? 1 : 0;
int addrVal = SAV.GBO + BFF[Facility][2] + BFF[Facility][3] * BattleType + (RBi << 3); int addrVal = SAV.GBO + BFF[Facility][2] + (BFF[Facility][3] * BattleType) + (RBi << 3);
int addrFlag = SAV.GBO + BFF[Facility][4]; int addrFlag = SAV.GBO + BFF[Facility][4];
byte maskFlag = (byte)(1 << BattleType + (RBi << 2)); byte maskFlag = (byte)(1 << BattleType + (RBi << 2));
int TowerContinueCountOfs = SAV.DP ? 3 : 1; int TowerContinueCountOfs = SAV.DP ? 3 : 1;
@ -618,10 +655,12 @@ namespace PKHeX.WinForms
if (Facility == 3) SAV.Data[addrFlag + 1] |= 0x01; // not found what this flag means if (Facility == 3) SAV.Data[addrFlag + 1] |= 0x01; // not found what this flag means
} }
else else
{
SAV.Data[addrFlag] &= (byte)~maskFlag; SAV.Data[addrFlag] &= (byte)~maskFlag;
return; }
} }
} }
private void ChangeStatVal(object sender, EventArgs e) private void ChangeStatVal(object sender, EventArgs e)
{ {
if (editing) return; if (editing) return;
@ -632,7 +671,9 @@ namespace PKHeX.WinForms
if (CB_Stats1.SelectedIndex == 0 && Math.Floor(StatNUDA[0].Value / 7) != StatNUDA[1].Value) if (CB_Stats1.SelectedIndex == 0 && Math.Floor(StatNUDA[0].Value / 7) != StatNUDA[1].Value)
{ {
if (n == 0) if (n == 0)
{
StatNUDA[1].Value = Math.Floor(StatNUDA[0].Value / 7); StatNUDA[1].Value = Math.Floor(StatNUDA[0].Value / 7);
}
else if (n == 1) else if (n == 1)
{ {
if (StatNUDA[0].Maximum > StatNUDA[1].Value * 7) if (StatNUDA[0].Maximum > StatNUDA[1].Value * 7)
@ -650,6 +691,7 @@ namespace PKHeX.WinForms
} }
private int species = -1; private int species = -1;
private void ChangeSpecies(object sender, EventArgs e) private void ChangeSpecies(object sender, EventArgs e)
{ {
species = (int)CB_Species.SelectedValue; species = (int)CB_Species.SelectedValue;
@ -658,9 +700,10 @@ namespace PKHeX.WinForms
GetHallStat(); GetHallStat();
editing = false; editing = false;
} }
private void GetCastleStat() private void GetCastleStat()
{ {
int ofs = SAV.GBO + BFF[3][2] + BFF[3][3] * CB_Stats2.SelectedIndex + 0x0A; int ofs = SAV.GBO + BFF[3][2] + (BFF[3][3] * CB_Stats2.SelectedIndex) + 0x0A;
NumericUpDown[] na = { NUD_CastleRankRcv, NUD_CastleRankItem, NUD_CastleRankInfo }; NumericUpDown[] na = { NUD_CastleRankRcv, NUD_CastleRankItem, NUD_CastleRankInfo };
for (int i = 0; i < na.Length; i++) for (int i = 0; i < na.Length; i++)
{ {
@ -668,17 +711,19 @@ namespace PKHeX.WinForms
na[i].Value = val > na[i].Maximum ? na[i].Maximum : val < na[i].Minimum ? na[i].Minimum : val; na[i].Value = val > na[i].Maximum ? na[i].Maximum : val < na[i].Minimum ? na[i].Minimum : val;
} }
} }
private void NUD_CastleRank_ValueChanged(object sender, EventArgs e) private void NUD_CastleRank_ValueChanged(object sender, EventArgs e)
{ {
if (editing) return; if (editing) return;
NumericUpDown[] na = new[] { NUD_CastleRankRcv, NUD_CastleRankItem, NUD_CastleRankInfo }; NumericUpDown[] na = new[] { NUD_CastleRankRcv, NUD_CastleRankItem, NUD_CastleRankInfo };
int i = Array.IndexOf(na, sender); int i = Array.IndexOf(na, sender);
if (i < 0) return; if (i < 0) return;
BitConverter.GetBytes((int)na[i].Value).CopyTo(SAV.Data, SAV.GBO + BFF[3][2] + BFF[3][3] * CB_Stats2.SelectedIndex + 0x0A + (i << 1)); BitConverter.GetBytes((int)na[i].Value).CopyTo(SAV.Data, SAV.GBO + BFF[3][2] + (BFF[3][3] * CB_Stats2.SelectedIndex) + 0x0A + (i << 1));
} }
private void GetHallStat() private void GetHallStat()
{ {
int ofscur = SAV.GBO + BFF[2][2] + BFF[2][3] * CB_Stats2.SelectedIndex; int ofscur = SAV.GBO + BFF[2][2] + (BFF[2][3] * CB_Stats2.SelectedIndex);
int curspe = BitConverter.ToInt16(SAV.Data, ofscur + 4); int curspe = BitConverter.ToInt16(SAV.Data, ofscur + 4);
bool c = curspe == species; bool c = curspe == species;
CHK_HallCurrent.Checked = c; CHK_HallCurrent.Checked = c;
@ -698,7 +743,7 @@ namespace PKHeX.WinForms
if (ofsHallStat > 0) if (ofsHallStat > 0)
{ {
ushort v = BitConverter.ToUInt16(SAV.Data, ofsHallStat + 4 + 0x3DE * CB_Stats2.SelectedIndex + (species << 1)); ushort v = BitConverter.ToUInt16(SAV.Data, ofsHallStat + 4 + (0x3DE * CB_Stats2.SelectedIndex) + (species << 1));
NUD_HallStreaks.Value = v > 9999 ? 9999 : v; NUD_HallStreaks.Value = v > 9999 ? 9999 : v;
} }
} }
@ -706,7 +751,7 @@ namespace PKHeX.WinForms
private void CHK_HallCurrent_CheckedChanged(object sender, EventArgs e) private void CHK_HallCurrent_CheckedChanged(object sender, EventArgs e)
{ {
if (editing) return; if (editing) return;
BitConverter.GetBytes((ushort)(CHK_HallCurrent.Checked ? species : 0)).CopyTo(SAV.Data, SAV.GBO + BFF[2][2] + BFF[2][3] * CB_Stats2.SelectedIndex + 4); BitConverter.GetBytes((ushort)(CHK_HallCurrent.Checked ? species : 0)).CopyTo(SAV.Data, SAV.GBO + BFF[2][2] + (BFF[2][3] * CB_Stats2.SelectedIndex) + 4);
editing = true; editing = true;
GetHallStat(); GetHallStat();
editing = false; editing = false;
@ -717,15 +762,15 @@ namespace PKHeX.WinForms
if (editing) return; if (editing) return;
int i = Array.IndexOf(HallNUDA, sender); int i = Array.IndexOf(HallNUDA, sender);
if (i < 0) return; if (i < 0) return;
int ofs = SAV.GBO + BFF[2][2] + BFF[2][3] * CB_Stats2.SelectedIndex + 6 + (i >> 1 << 1); int ofs = SAV.GBO + BFF[2][2] + (BFF[2][3] * CB_Stats2.SelectedIndex) + 6 + (i >> 1 << 1);
SAV.Data[ofs] = (byte)(SAV.Data[ofs] & ~(0xF << ((i & 1) << 2)) | (int)HallNUDA[i].Value << ((i & 1) << 2)); SAV.Data[ofs] = (byte)((SAV.Data[ofs] & ~(0xF << ((i & 1) << 2))) | (int)HallNUDA[i].Value << ((i & 1) << 2));
L_SumHall.Text = HallNUDA.Sum(x => x.Value).ToString(); L_SumHall.Text = HallNUDA.Sum(x => x.Value).ToString();
} }
private void NUD_HallStreaks_ValueChanged(object sender, EventArgs e) private void NUD_HallStreaks_ValueChanged(object sender, EventArgs e)
{ {
if (editing || ofsHallStat < 0) return; if (editing || ofsHallStat < 0) return;
BitConverter.GetBytes((ushort)NUD_HallStreaks.Value).CopyTo(SAV.Data, ofsHallStat + 4 + 0x3DE * CB_Stats2.SelectedIndex + (species << 1)); BitConverter.GetBytes((ushort)NUD_HallStreaks.Value).CopyTo(SAV.Data, ofsHallStat + 4 + (0x3DE * CB_Stats2.SelectedIndex) + (species << 1));
HallStatUpdated = true; HallStatUpdated = true;
} }
#endregion #endregion

View file

@ -10,6 +10,7 @@ namespace PKHeX.WinForms
{ {
private readonly SaveFile Origin; private readonly SaveFile Origin;
private readonly SAV4 SAV; private readonly SAV4 SAV;
public SAV_Pokedex4(SaveFile sav) public SAV_Pokedex4(SaveFile sav)
{ {
InitializeComponent(); InitializeComponent();
@ -60,6 +61,7 @@ namespace PKHeX.WinForms
GetEntry(); GetEntry();
editing = false; editing = false;
} }
private void ChangeLBSpecies(object sender, EventArgs e) private void ChangeLBSpecies(object sender, EventArgs e)
{ {
if (editing) return; if (editing) return;
@ -76,13 +78,14 @@ namespace PKHeX.WinForms
private const string MALE = "Male"; private const string MALE = "Male";
private const string FEMALE = "Female"; private const string FEMALE = "Female";
private static readonly int[] DPLangSpecies = { 23, 25, 54, 77, 120, 129, 202, 214, 215, 216, 228, 278, 287, 315 }; private static readonly int[] DPLangSpecies = { 23, 25, 54, 77, 120, 129, 202, 214, 215, 216, 228, 278, 287, 315 };
private void GetEntry() private void GetEntry()
{ {
// Load Bools for the data // Load Bools for the data
int bit = species - 1; int bit = species - 1;
byte mask = (byte)(1 << (bit & 7)); byte mask = (byte)(1 << (bit & 7));
int ofs = SAV.PokeDex + (bit >> 3) + 0x4; int ofs = SAV.PokeDex + (bit >> 3) + 0x4;
int FormOffset1 = SAV.PokeDex + 4 + brSize * 4 + 4; int FormOffset1 = SAV.PokeDex + 4 + (brSize * 4) + 4;
int PokeDexLanguageFlags = FormOffset1 + (SAV.HGSS ? 0x3C : 0x20); int PokeDexLanguageFlags = FormOffset1 + (SAV.HGSS ? 0x3C : 0x20);
int l_ofs = !SAV.DP ? species : 1 + Array.IndexOf(DPLangSpecies, species); int l_ofs = !SAV.DP ? species : 1 + Array.IndexOf(DPLangSpecies, species);
if (l_ofs > 0) if (l_ofs > 0)
@ -95,13 +98,16 @@ namespace PKHeX.WinForms
} }
} }
else else
for (int i = 0; i < LangCount; i++) CL[i].Enabled = CL[i].Checked = false; {
for (int i = 0; i < LangCount; i++)
CL[i].Enabled = CL[i].Checked = false;
}
bool bit2 = (SAV.Data[ofs + brSize * 2] & mask) != 0; bool bit2 = (SAV.Data[ofs + (brSize * 2)] & mask) != 0;
bool bit3 = (SAV.Data[ofs + brSize * 3] & mask) != 0; bool bit3 = (SAV.Data[ofs + (brSize * 3)] & mask) != 0;
CHK_Seen.Checked = (SAV.Data[ofs + brSize * 1] & mask) != 0; CHK_Seen.Checked = (SAV.Data[ofs + (brSize * 1)] & mask) != 0;
CHK_Caught.Checked = (SAV.Data[ofs + brSize * 0] & mask) != 0; CHK_Caught.Checked = (SAV.Data[ofs + (brSize * 0)] & mask) != 0;
// Genders // Genders
LB_Gender.Items.Clear(); LB_Gender.Items.Clear();
@ -165,46 +171,46 @@ namespace PKHeX.WinForms
// Check if already Seen // Check if already Seen
if (!CHK_Seen.Checked || LB_Gender.Items.Count == 0) if (!CHK_Seen.Checked || LB_Gender.Items.Count == 0)
{ {
SAV.Data[ofs + brSize * 0] &= (byte)~mask; SAV.Data[ofs + (brSize * 0)] &= (byte)~mask;
SAV.Data[ofs + brSize * 1] &= (byte)~mask; SAV.Data[ofs + (brSize * 1)] &= (byte)~mask;
SAV.Data[ofs + brSize * 2] &= (byte)~mask; SAV.Data[ofs + (brSize * 2)] &= (byte)~mask;
SAV.Data[ofs + brSize * 3] &= (byte)~mask; SAV.Data[ofs + (brSize * 3)] &= (byte)~mask;
} }
else // Is Seen else // Is Seen
{ {
// Set the Species Owned Flag // Set the Species Owned Flag
if (CHK_Caught.Checked) if (CHK_Caught.Checked)
SAV.Data[ofs + brSize * 0] |= mask; SAV.Data[ofs + (brSize * 0)] |= mask;
else else
SAV.Data[ofs + brSize * 0] &= (byte)~mask; SAV.Data[ofs + (brSize * 0)] &= (byte)~mask;
SAV.Data[ofs + brSize * 1] |= mask; SAV.Data[ofs + (brSize * 1)] |= mask;
switch ((string)LB_Gender.Items[0]) switch ((string)LB_Gender.Items[0])
{ {
case GENDERLESS: case GENDERLESS:
SAV.Data[ofs + brSize * 2] &= (byte)~mask; SAV.Data[ofs + (brSize * 2)] &= (byte)~mask;
SAV.Data[ofs + brSize * 3] &= (byte)~mask; SAV.Data[ofs + (brSize * 3)] &= (byte)~mask;
break; break;
case FEMALE: case FEMALE:
SAV.Data[ofs + brSize * 2] |= mask; // set SAV.Data[ofs + (brSize * 2)] |= mask; // set
if (LB_Gender.Items.Count != 1) // Male present if (LB_Gender.Items.Count != 1) // Male present
SAV.Data[ofs + brSize * 3] &= (byte)~mask; // unset SAV.Data[ofs + (brSize * 3)] &= (byte)~mask; // unset
else else
SAV.Data[ofs + brSize * 3] |= mask; // set SAV.Data[ofs + (brSize * 3)] |= mask; // set
break; break;
case MALE: case MALE:
SAV.Data[ofs + brSize * 2] &= (byte)~mask; // unset SAV.Data[ofs + (brSize * 2)] &= (byte)~mask; // unset
if (LB_Gender.Items.Count != 1) // Female present if (LB_Gender.Items.Count != 1) // Female present
SAV.Data[ofs + brSize * 3] |= mask; // set SAV.Data[ofs + (brSize * 3)] |= mask; // set
else else
SAV.Data[ofs + brSize * 3] &= (byte)~mask; // unset SAV.Data[ofs + (brSize * 3)] &= (byte)~mask; // unset
break; break;
default: default:
throw new ArgumentException("Invalid Gender???"); throw new ArgumentException("Invalid Gender???");
} }
} }
int FormOffset1 = SAV.PokeDex + 4 + 4 * brSize + 4; int FormOffset1 = SAV.PokeDex + 4 + (4 * brSize) + 4;
int PokeDexLanguageFlags = FormOffset1 + (SAV.HGSS ? 0x3C : 0x20); int PokeDexLanguageFlags = FormOffset1 + (SAV.HGSS ? 0x3C : 0x20);
int l_ofs = !SAV.DP ? species : (1 + Array.IndexOf(DPLangSpecies, species)); int l_ofs = !SAV.DP ? species : (1 + Array.IndexOf(DPLangSpecies, species));
if (l_ofs > 0) if (l_ofs > 0)
@ -231,6 +237,7 @@ namespace PKHeX.WinForms
{ {
Close(); Close();
} }
private void B_Save_Click(object sender, EventArgs e) private void B_Save_Click(object sender, EventArgs e)
{ {
SetEntry(); SetEntry();
@ -259,6 +266,7 @@ namespace PKHeX.WinForms
else else
SeenAll(); SeenAll();
} }
private void B_Modify_Click(object sender, EventArgs e) private void B_Modify_Click(object sender, EventArgs e)
{ {
Button btn = (Button)sender; Button btn = (Button)sender;
@ -276,6 +284,7 @@ namespace PKHeX.WinForms
foreach (var c in CL) foreach (var c in CL)
c.Checked = false; c.Checked = false;
} }
private void SeenAll() private void SeenAll()
{ {
LB_Gender.Items.AddRange(LB_NGender.Items); LB_Gender.Items.AddRange(LB_NGender.Items);
@ -285,6 +294,7 @@ namespace PKHeX.WinForms
LB_NForm.Items.Clear(); LB_NForm.Items.Clear();
CHK_Seen.Checked = true; CHK_Seen.Checked = true;
} }
private void ModifyAll(object sender, EventArgs e) private void ModifyAll(object sender, EventArgs e)
{ {
int lang = SAV.Language - 1; int lang = SAV.Language - 1;
@ -309,13 +319,17 @@ namespace PKHeX.WinForms
{ {
CHK_Caught.Checked = true; CHK_Caught.Checked = true;
for (int j = 0; j < CL.Length; j++) // set SAV language (and others if Complete) for (int j = 0; j < CL.Length; j++) // set SAV language (and others if Complete)
CL[j].Checked = sender == mnuComplete || mnuCaughtNone != sender && j == lang; CL[j].Checked = sender == mnuComplete || (mnuCaughtNone != sender && j == lang);
} }
else if (caughtN) else if (caughtN)
{
CHK_Caught.Checked = false; CHK_Caught.Checked = false;
}
else if (!CHK_Seen.Checked) else if (!CHK_Seen.Checked)
{
foreach (CheckBox t in CL) foreach (CheckBox t in CL)
t.Checked = false; t.Checked = false;
}
} }
SetEntry(); SetEntry();
@ -368,6 +382,7 @@ namespace PKHeX.WinForms
dest.Items.Add(item); dest.Items.Add(item);
dest.SelectedIndex = dest.Items.Count - 1; dest.SelectedIndex = dest.Items.Count - 1;
} }
private void MoveGender(object sender, EventArgs e) private void MoveGender(object sender, EventArgs e)
{ {
if (editing) if (editing)
@ -414,6 +429,7 @@ namespace PKHeX.WinForms
dest.Items.Add(item); dest.Items.Add(item);
dest.SelectedIndex = dest.Items.Count - 1; dest.SelectedIndex = dest.Items.Count - 1;
} }
private void MoveForm(object sender, EventArgs e) private void MoveForm(object sender, EventArgs e)
{ {
if (editing) if (editing)

View file

@ -1,5 +1,4 @@
using System; using System;
using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using PKHeX.Core; using PKHeX.Core;
@ -9,6 +8,7 @@ namespace PKHeX.WinForms
{ {
private readonly SaveFile Origin; private readonly SaveFile Origin;
private readonly SAV4 SAV; private readonly SAV4 SAV;
public SAV_Underground(SaveFile sav) public SAV_Underground(SaveFile sav)
{ {
InitializeComponent(); InitializeComponent();

View file

@ -12,6 +12,7 @@ namespace PKHeX.WinForms
{ {
private readonly SaveFile Origin; private readonly SaveFile Origin;
private readonly SAV5 SAV; private readonly SAV5 SAV;
public SAV_CGearSkin(SaveFile sav) public SAV_CGearSkin(SaveFile sav)
{ {
InitializeComponent(); InitializeComponent();
@ -49,6 +50,7 @@ namespace PKHeX.WinForms
WinFormsUtil.Error(ex.Message); WinFormsUtil.Error(ex.Message);
} }
} }
private void B_ExportPNG_Click(object sender, EventArgs e) private void B_ExportPNG_Click(object sender, EventArgs e)
{ {
Image png = PB_Background.Image; Image png = PB_Background.Image;
@ -63,6 +65,7 @@ namespace PKHeX.WinForms
png.Save(sfd.FileName, ImageFormat.Png); png.Save(sfd.FileName, ImageFormat.Png);
} }
private void B_ImportCGB_Click(object sender, EventArgs e) private void B_ImportCGB_Click(object sender, EventArgs e)
{ {
OpenFileDialog ofd = new OpenFileDialog OpenFileDialog ofd = new OpenFileDialog
@ -99,6 +102,7 @@ namespace PKHeX.WinForms
byte[] data = bg.GetSkin(true); byte[] data = bg.GetSkin(true);
File.WriteAllBytes(sfd.FileName, data); File.WriteAllBytes(sfd.FileName, data);
} }
private void B_Save_Click(object sender, EventArgs e) private void B_Save_Click(object sender, EventArgs e)
{ {
byte[] bgdata = bg.GetSkin(SAV.B2W2); byte[] bgdata = bg.GetSkin(SAV.B2W2);
@ -109,6 +113,7 @@ namespace PKHeX.WinForms
} }
Close(); Close();
} }
private void B_Cancel_Click(object sender, EventArgs e) private void B_Cancel_Click(object sender, EventArgs e)
{ {
Close(); Close();

View file

@ -10,6 +10,7 @@ namespace PKHeX.WinForms
{ {
private readonly SaveFile Origin; private readonly SaveFile Origin;
private readonly SAV5 SAV; private readonly SAV5 SAV;
public SAV_Misc5(SaveFile sav) public SAV_Misc5(SaveFile sav)
{ {
InitializeComponent(); InitializeComponent();
@ -44,6 +45,7 @@ namespace PKHeX.WinForms
private uint valLibPass; private uint valLibPass;
private bool bLibPass; private bool bLibPass;
private const int ofsKS = 0x25828; private const int ofsKS = 0x25828;
private readonly uint[] keyKS = { private readonly uint[] keyKS = {
// 0x34525, 0x11963, // Selected City // 0x34525, 0x11963, // Selected City
// 0x31239, 0x15657, 0x49589, // Selected Difficulty // 0x31239, 0x15657, 0x49589, // Selected Difficulty
@ -51,8 +53,10 @@ namespace PKHeX.WinForms
0x35691, 0x18256, 0x59389, 0x48292, 0x09892, // Obtained Keys(EasyMode, Challenge, City, Iron, Iceberg) 0x35691, 0x18256, 0x59389, 0x48292, 0x09892, // Obtained Keys(EasyMode, Challenge, City, Iron, Iceberg)
0x93389, 0x22843, 0x34771, 0xAB031, 0xB3818 // Unlocked(EasyMode, Challenge, City, Iron, Iceberg) 0x93389, 0x22843, 0x34771, 0xAB031, 0xB3818 // Unlocked(EasyMode, Challenge, City, Iron, Iceberg)
}; };
private uint[] valKS; private uint[] valKS;
private bool[] bKS; private bool[] bKS;
private void ReadMain() private void ReadMain()
{ {
string[] FlyDestA = null; string[] FlyDestA = null;
@ -145,9 +149,11 @@ namespace PKHeX.WinForms
{ {
GB_Roamer.Visible = CHK_LibertyPass.Visible = false; GB_Roamer.Visible = CHK_LibertyPass.Visible = false;
// KeySystem // KeySystem
string[] KeySystemA = { string[] KeySystemA =
{
"Obtain EasyKey", "Obtain ChallengeKey", "Obtain CityKey", "Obtain IronKey", "Obtain IcebergKey", "Obtain EasyKey", "Obtain ChallengeKey", "Obtain CityKey", "Obtain IronKey", "Obtain IcebergKey",
"Unlock EasyMode", "Unlock ChallengeMode", "Unlock City", "Unlock IronChamber", "Unlock IcebergChamber" "Unlock EasyMode", "Unlock ChallengeMode", "Unlock City", "Unlock IronChamber",
"Unlock IcebergChamber"
}; };
uint KSID = BitConverter.ToUInt32(SAV.Data, ofsKS + 0x34); uint KSID = BitConverter.ToUInt32(SAV.Data, ofsKS + 0x34);
valKS = new uint[keyKS.Length]; valKS = new uint[keyKS.Length];
@ -160,8 +166,12 @@ namespace PKHeX.WinForms
CLB_KeySystem.Items.Add(KeySystemA[i], bKS[i]); CLB_KeySystem.Items.Add(KeySystemA[i], bKS[i]);
} }
} }
else GB_KeySystem.Visible = GB_Roamer.Visible = CHK_LibertyPass.Visible = false; else
{
GB_KeySystem.Visible = GB_Roamer.Visible = CHK_LibertyPass.Visible = false;
}
} }
private void SaveMain() private void SaveMain()
{ {
uint valFly = BitConverter.ToUInt32(SAV.Data, ofsFly); uint valFly = BitConverter.ToUInt32(SAV.Data, ofsFly);
@ -170,11 +180,15 @@ namespace PKHeX.WinForms
if (FlyDestC[i] < 32) if (FlyDestC[i] < 32)
{ {
if (CLB_FlyDest.GetItemChecked(i)) if (CLB_FlyDest.GetItemChecked(i))
valFly |= (uint)1 << FlyDestC[i]; valFly |= (uint) 1 << FlyDestC[i];
else else
valFly &= ~((uint)1 << FlyDestC[i]); valFly &= ~((uint) 1 << FlyDestC[i]);
}
else
{
var ofs = ofsFly + (FlyDestC[i] >> 3);
SAV.Data[ofs] = (byte)((SAV.Data[ofs] & ~(1 << (FlyDestC[i] & 7))) | ((CLB_FlyDest.GetItemChecked(i) ? 1 : 0) << (FlyDestC[i] & 7)));
} }
else SAV.Data[ofsFly + (FlyDestC[i] >> 3)] = (byte)(SAV.Data[ofsFly + (FlyDestC[i] >> 3)] & ~(1 << (FlyDestC[i] & 7)) | ((CLB_FlyDest.GetItemChecked(i) ? 1 : 0) << (FlyDestC[i] & 7)));
} }
BitConverter.GetBytes(valFly).CopyTo(SAV.Data, ofsFly); BitConverter.GetBytes(valFly).CopyTo(SAV.Data, ofsFly);
@ -191,7 +205,7 @@ namespace PKHeX.WinForms
SAV.Data[ofsRoamer + 0x2E + i] = (byte)d; SAV.Data[ofsRoamer + 0x2E + i] = (byte)d;
if (c != 1) if (c != 1)
continue; continue;
new byte[14].CopyTo(SAV.Data, ofsRoamer + 4 + i * 0x14); new byte[14].CopyTo(SAV.Data, ofsRoamer + 4 + (i * 0x14));
SAV.Data[ofsRoamer + 0x2C + i] = 0; SAV.Data[ofsRoamer + 0x2C + i] = 0;
} }
@ -203,10 +217,13 @@ namespace PKHeX.WinForms
{ {
// KeySystem // KeySystem
for (int i = 0; i < CLB_KeySystem.Items.Count; i++) for (int i = 0; i < CLB_KeySystem.Items.Count; i++)
{
if (CLB_KeySystem.GetItemChecked(i) ^ bKS[i]) if (CLB_KeySystem.GetItemChecked(i) ^ bKS[i])
BitConverter.GetBytes(bKS[i] ? 0 : valKS[i]).CopyTo(SAV.Data, ofsKS + (i << 2)); BitConverter.GetBytes(bKS[i] ? 0 : valKS[i]).CopyTo(SAV.Data, ofsKS + (i << 2));
}
} }
} }
private void B_AllFlyDest_Click(object sender, EventArgs e) private void B_AllFlyDest_Click(object sender, EventArgs e)
{ {
for (int i = 0; i < CLB_FlyDest.Items.Count; i++) for (int i = 0; i < CLB_FlyDest.Items.Count; i++)
@ -260,12 +277,14 @@ namespace PKHeX.WinForms
new[] { 2400 }, // 37 new[] { 2400 }, // 37
new[] { 2557 } // 38 new[] { 2557 } // 38
}; };
private bool editing; private bool editing;
private const int ofsFM = 0x25900; private const int ofsFM = 0x25900;
private readonly ToolTip TipExpB = new ToolTip(), TipExpW = new ToolTip(); private readonly ToolTip TipExpB = new ToolTip(), TipExpW = new ToolTip();
private NumericUpDown[] nudaE, nudaF; private NumericUpDown[] nudaE, nudaF;
private ComboBox[] cba; private ComboBox[] cba;
private ToolTip[] ta; private ToolTip[] ta;
private void ReadEntralink() private void ReadEntralink()
{ {
editing = true; editing = true;
@ -383,6 +402,7 @@ namespace PKHeX.WinForms
SetEntreeExpTooltip(); SetEntreeExpTooltip();
editing = false; editing = false;
} }
private void SaveEntralink() private void SaveEntralink()
{ {
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
@ -400,6 +420,7 @@ namespace PKHeX.WinForms
BitConverter.GetBytes((ushort)nudaF[i].Value).CopyTo(SAV.Data, ofsFM + 0xF0 + (i << 1)); BitConverter.GetBytes((ushort)nudaF[i].Value).CopyTo(SAV.Data, ofsFM + 0xF0 + (i << 1));
SAV.Data[ofsFM + 0xFA] = (byte)NUD_FMMostParticipants.Value; SAV.Data[ofsFM + 0xFA] = (byte)NUD_FMMostParticipants.Value;
} }
private void SetEntreeExpTooltip(bool? isBlack = null) private void SetEntreeExpTooltip(bool? isBlack = null)
{ {
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
@ -410,7 +431,7 @@ namespace PKHeX.WinForms
if (lv < 9) if (lv < 9)
exp = lv * (lv + 1) * 5 / 2; exp = lv * (lv + 1) * 5 / 2;
else else
exp = (lv - 9) * 50 + 225; exp = ((lv - 9) * 50) + 225;
exp += (int)nudaE[(i << 1) + 1].Value; exp += (int)nudaE[(i << 1) + 1].Value;
var lvl = lv == 999 ? -1 : nudaE[(i << 1) + 1].Maximum - nudaE[(i << 1) + 1].Value + 1; var lvl = lv == 999 ? -1 : nudaE[(i << 1) + 1].Maximum - nudaE[(i << 1) + 1].Value + 1;
var tip0 = $"{(i == 0 ? "White" : "Black")} LV {lv}{Environment.NewLine}" + var tip0 = $"{(i == 0 ? "White" : "Black")} LV {lv}{Environment.NewLine}" +
@ -421,6 +442,7 @@ namespace PKHeX.WinForms
ta[i].SetToolTip(nudaE[(i << 1) + 1], tip0); ta[i].SetToolTip(nudaE[(i << 1) + 1], tip0);
} }
} }
private void SetNudMax(bool? isBlack = null) private void SetNudMax(bool? isBlack = null)
{ {
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
@ -428,18 +450,20 @@ namespace PKHeX.WinForms
if (isBlack == true) if (isBlack == true)
continue; continue;
var lv = (int)nudaE[i << 1].Value; var lv = (int)nudaE[i << 1].Value;
var expmax = lv > 8 ? 49 : lv * 5 + 4; var expmax = lv > 8 ? 49 : (lv * 5) + 4;
if (nudaE[(i << 1) + 1].Value > expmax) if (nudaE[(i << 1) + 1].Value > expmax)
nudaE[(i << 1) + 1].Value = expmax; nudaE[(i << 1) + 1].Value = expmax;
nudaE[(i << 1) + 1].Maximum = expmax; nudaE[(i << 1) + 1].Maximum = expmax;
} }
} }
private void SetFMVal(int ofsB, int len, uint val) private void SetFMVal(int ofsB, int len, uint val)
{ {
int s = LB_FunfestMissions.SelectedIndex; int s = LB_FunfestMissions.SelectedIndex;
if (s < 0 || s >= FMUnlockConditions.Length) return; if (s < 0 || s >= FMUnlockConditions.Length) return;
BitConverter.GetBytes(BitConverter.ToUInt32(SAV.Data, ofsFM + (s << 2)) & ~(~(uint)0 >> (32 - len) << ofsB) | val << ofsB).CopyTo(SAV.Data, ofsFM + (s << 2)); BitConverter.GetBytes((BitConverter.ToUInt32(SAV.Data, ofsFM + (s << 2)) & ~(~(uint)0 >> (32 - len) << ofsB)) | val << ofsB).CopyTo(SAV.Data, ofsFM + (s << 2));
} }
private void LB_FunfestMissions_SelectedIndexChanged(object sender, EventArgs e) private void LB_FunfestMissions_SelectedIndexChanged(object sender, EventArgs e)
{ {
int s = LB_FunfestMissions.SelectedIndex; int s = LB_FunfestMissions.SelectedIndex;
@ -487,8 +511,11 @@ namespace PKHeX.WinForms
const int FunfestFlag = 2438; const int FunfestFlag = 2438;
SAV.Data[0x2025E + (FunfestFlag >> 3)] |= 1 << (FunfestFlag & 7); SAV.Data[0x2025E + (FunfestFlag >> 3)] |= 1 << (FunfestFlag & 7);
foreach (int[] ia in FMUnlockConditions) foreach (int[] ia in FMUnlockConditions)
{
for (int i = 0; i < ia?.Length; i++) for (int i = 0; i < ia?.Length; i++)
SAV.Data[0x2025E + (ia[i] >> 3)] |= (byte)(1 << (ia[i] & 7)); SAV.Data[0x2025E + (ia[i] >> 3)] |= (byte)(1 << (ia[i] & 7));
}
L_FMUnlocked.Visible = true; L_FMUnlocked.Visible = true;
L_FMLocked.Visible = false; L_FMLocked.Visible = false;
} }
@ -551,6 +578,7 @@ namespace PKHeX.WinForms
} }
private IList<EntreeSlot> CurrentSlots; private IList<EntreeSlot> CurrentSlots;
private void ChangeArea(object sender, EventArgs e) private void ChangeArea(object sender, EventArgs e)
{ {
var area = WinFormsUtil.GetIndex(CB_Areas); var area = WinFormsUtil.GetIndex(CB_Areas);
@ -560,6 +588,7 @@ namespace PKHeX.WinForms
LB_Slots.Items.Add(z); LB_Slots.Items.Add(z);
LB_Slots.SelectedIndex = 0; LB_Slots.SelectedIndex = 0;
} }
private void ChangeSlot(object sender, EventArgs e) private void ChangeSlot(object sender, EventArgs e)
{ {
CurrentSlot = null; CurrentSlot = null;
@ -575,6 +604,7 @@ namespace PKHeX.WinForms
} }
private EntreeSlot CurrentSlot; private EntreeSlot CurrentSlot;
private void UpdateSlotValue(object sender, EventArgs e) private void UpdateSlotValue(object sender, EventArgs e)
{ {
if (CurrentSlot == null) if (CurrentSlot == null)
@ -588,15 +618,26 @@ namespace PKHeX.WinForms
SetGenders(CurrentSlot); SetGenders(CurrentSlot);
} }
else if (sender == CB_Move) else if (sender == CB_Move)
{
CurrentSlot.Move = WinFormsUtil.GetIndex(CB_Move); CurrentSlot.Move = WinFormsUtil.GetIndex(CB_Move);
}
else if (sender == CB_Gender) else if (sender == CB_Gender)
{
CurrentSlot.Gender = WinFormsUtil.GetIndex(CB_Gender); CurrentSlot.Gender = WinFormsUtil.GetIndex(CB_Gender);
}
else if (sender == CB_Form) else if (sender == CB_Form)
{
CurrentSlot.Form = CB_Form.SelectedIndex; CurrentSlot.Form = CB_Form.SelectedIndex;
}
else if (sender == CHK_Invisible) else if (sender == CHK_Invisible)
{
CurrentSlot.Invisible = CHK_Invisible.Checked; CurrentSlot.Invisible = CHK_Invisible.Checked;
}
else if (sender == NUD_Animation) else if (sender == NUD_Animation)
{
CurrentSlot.Animation = (int)NUD_Animation.Value; CurrentSlot.Animation = (int)NUD_Animation.Value;
}
SetSprite(CurrentSlot); SetSprite(CurrentSlot);
} }
@ -645,6 +686,7 @@ namespace PKHeX.WinForms
list.Add(new ComboItem { Text = "Female", Value = 1 }); list.Add(new ComboItem { Text = "Female", Value = 1 });
return list; return list;
} }
private void SetForms(EntreeSlot slot) private void SetForms(EntreeSlot slot)
{ {
bool hasForms = PersonalTable.B2W2[slot.Species].HasFormes || slot.Species == 414; bool hasForms = PersonalTable.B2W2[slot.Species].HasFormes || slot.Species == 414;

View file

@ -11,6 +11,7 @@ namespace PKHeX.WinForms
{ {
private readonly SaveFile Origin; private readonly SaveFile Origin;
private readonly SAV5 SAV; private readonly SAV5 SAV;
public SAV_Pokedex5(SaveFile sav) public SAV_Pokedex5(SaveFile sav)
{ {
InitializeComponent(); InitializeComponent();
@ -61,6 +62,7 @@ namespace PKHeX.WinForms
GetEntry(); GetEntry();
editing = false; editing = false;
} }
private void ChangeLBSpecies(object sender, EventArgs e) private void ChangeLBSpecies(object sender, EventArgs e)
{ {
if (editing) return; if (editing) return;
@ -72,6 +74,7 @@ namespace PKHeX.WinForms
GetEntry(); GetEntry();
editing = false; editing = false;
} }
private void ChangeDisplayed(object sender, EventArgs e) private void ChangeDisplayed(object sender, EventArgs e)
{ {
if (!((CheckBox) sender).Checked) if (!((CheckBox) sender).Checked)
@ -87,10 +90,13 @@ namespace PKHeX.WinForms
CHK_P4.Checked |= CHK_P8.Checked; CHK_P4.Checked |= CHK_P8.Checked;
CHK_P5.Checked |= CHK_P9.Checked; CHK_P5.Checked |= CHK_P9.Checked;
} }
private void ChangeEncountered(object sender, EventArgs e) private void ChangeEncountered(object sender, EventArgs e)
{ {
if (!(CHK_P2.Checked || CHK_P3.Checked || CHK_P4.Checked || CHK_P5.Checked)) if (!(CHK_P2.Checked || CHK_P3.Checked || CHK_P4.Checked || CHK_P5.Checked))
{
CHK_P6.Checked = CHK_P7.Checked = CHK_P8.Checked = CHK_P9.Checked = false; CHK_P6.Checked = CHK_P7.Checked = CHK_P8.Checked = CHK_P9.Checked = false;
}
else if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked)) else if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked))
{ {
if (sender == CHK_P2 && CHK_P2.Checked) if (sender == CHK_P2 && CHK_P2.Checked)
@ -143,15 +149,16 @@ namespace PKHeX.WinForms
return; return;
for (int i = 0; i < forms.Length; i++) // Seen for (int i = 0; i < forms.Length; i++) // Seen
CLB_FormsSeen.Items.Add(forms[i], formbools[f + i + 0*FormLen*8]); CLB_FormsSeen.Items.Add(forms[i], formbools[f + i + (0 *FormLen*8)]);
for (int i = 0; i < forms.Length; i++) // Seen Shiny for (int i = 0; i < forms.Length; i++) // Seen Shiny
CLB_FormsSeen.Items.Add($"* {forms[i]}", formbools[f + i + 1*FormLen*8]); CLB_FormsSeen.Items.Add($"* {forms[i]}", formbools[f + i + (1 *FormLen*8)]);
for (int i = 0; i < forms.Length; i++) // Displayed for (int i = 0; i < forms.Length; i++) // Displayed
CLB_FormDisplayed.Items.Add(forms[i], formbools[f + i + 2*FormLen*8]); CLB_FormDisplayed.Items.Add(forms[i], formbools[f + i + (2 *FormLen*8)]);
for (int i = 0; i < forms.Length; i++) // Displayed Shiny for (int i = 0; i < forms.Length; i++) // Displayed Shiny
CLB_FormDisplayed.Items.Add($"* {forms[i]}", formbools[f + i + 3*FormLen*8]); CLB_FormDisplayed.Items.Add($"* {forms[i]}", formbools[f + i + (3 *FormLen*8)]);
} }
private void SetEntry() private void SetEntry()
{ {
if (species < 0) if (species < 0)
@ -161,8 +168,10 @@ namespace PKHeX.WinForms
specbools[i, species - 1] = CP[i].Checked; specbools[i, species - 1] = CP[i].Checked;
if (species <= 493) if (species <= 493)
{
for (int i = 0; i < 7; i++) for (int i = 0; i < 7; i++)
langbools[i, species - 1] = CL[i].Checked; langbools[i, species - 1] = CL[i].Checked;
}
int fc = SAV.Personal[species].FormeCount; int fc = SAV.Personal[species].FormeCount;
int f = SAV.B2W2 ? SaveUtil.GetDexFormIndexB2W2(species, fc) : SaveUtil.GetDexFormIndexBW(species, fc); int f = SAV.B2W2 ? SaveUtil.GetDexFormIndexB2W2(species, fc) : SaveUtil.GetDexFormIndexBW(species, fc);
@ -170,15 +179,15 @@ namespace PKHeX.WinForms
return; return;
for (int i = 0; i < CLB_FormsSeen.Items.Count/2; i++) // Seen for (int i = 0; i < CLB_FormsSeen.Items.Count/2; i++) // Seen
formbools[f + i + 0*FormLen*8] = CLB_FormsSeen.GetItemChecked(i); formbools[f + i + (0 *FormLen*8)] = CLB_FormsSeen.GetItemChecked(i);
for (int i = 0; i < CLB_FormsSeen.Items.Count/2; i++) // Seen Shiny for (int i = 0; i < CLB_FormsSeen.Items.Count/2; i++) // Seen Shiny
formbools[f + i + 1*FormLen*8] = CLB_FormsSeen.GetItemChecked(i + CLB_FormsSeen.Items.Count/2); formbools[f + i + (1 *FormLen*8)] = CLB_FormsSeen.GetItemChecked(i + (CLB_FormsSeen.Items.Count/2));
editing = true; editing = true;
for (int i = 0; i < CLB_FormDisplayed.Items.Count/2; i++) // Displayed for (int i = 0; i < CLB_FormDisplayed.Items.Count/2; i++) // Displayed
formbools[f + i + 2*FormLen*8] = CLB_FormDisplayed.GetItemChecked(i); formbools[f + i + (2 *FormLen*8)] = CLB_FormDisplayed.GetItemChecked(i);
for (int i = 0; i < CLB_FormDisplayed.Items.Count/2; i++) // Displayed Shiny for (int i = 0; i < CLB_FormDisplayed.Items.Count/2; i++) // Displayed Shiny
formbools[f + i + 3*FormLen*8] = CLB_FormDisplayed.GetItemChecked(i + CLB_FormDisplayed.Items.Count/2); formbools[f + i + (3 *FormLen*8)] = CLB_FormDisplayed.GetItemChecked(i + (CLB_FormDisplayed.Items.Count/2));
editing = false; editing = false;
} }
@ -189,7 +198,7 @@ namespace PKHeX.WinForms
for (int i = 0; i < arrCount; i++) for (int i = 0; i < arrCount; i++)
{ {
byte[] data = new byte[brSize]; byte[] data = new byte[brSize];
Array.Copy(SAV.Data, SAV.PokeDex + 8 + brSize * i, data, 0, brSize); Array.Copy(SAV.Data, SAV.PokeDex + 8 + (brSize * i), data, 0, brSize);
BitArray BitRegion = new BitArray(data); BitArray BitRegion = new BitArray(data);
for (int b = 0; b < brSize * 8; b++) for (int b = 0; b < brSize * 8; b++)
specbools[i, b] = BitRegion[b]; specbools[i, b] = BitRegion[b];
@ -200,14 +209,17 @@ namespace PKHeX.WinForms
Array.Copy(SAV.Data, SAV.PokeDexLanguageFlags, langdata, 0, LangSize); Array.Copy(SAV.Data, SAV.PokeDexLanguageFlags, langdata, 0, LangSize);
BitArray LangRegion = new BitArray(langdata); BitArray LangRegion = new BitArray(langdata);
for (int b = 0; b < 493; b++) for (int b = 0; b < 493; b++)
{
for (int i = 0; i < 7; i++) // 7 Languages for (int i = 0; i < 7; i++) // 7 Languages
langbools[i, b] = LangRegion[7 * b + i]; langbools[i, b] = LangRegion[(7 * b) + i];
}
byte[] formdata = new byte[FormLen*4]; byte[] formdata = new byte[FormLen*4];
int FormDex = SAV.PokeDex + 0x8 + brSize*9; int FormDex = SAV.PokeDex + 0x8 + (brSize * 9);
Array.Copy(SAV.Data, FormDex, formdata, 0, formdata.Length); Array.Copy(SAV.Data, FormDex, formdata, 0, formdata.Length);
formbools = new BitArray(formdata); formbools = new BitArray(formdata);
} }
private void SetData() private void SetData()
{ {
// Save back the Species Bools // Save back the Species Bools
@ -217,10 +229,12 @@ namespace PKHeX.WinForms
byte[] sdata = new byte[brSize]; byte[] sdata = new byte[brSize];
for (int i = 0; i < brSize * 8; i++) for (int i = 0; i < brSize * 8; i++)
{
if (specbools[p, i]) if (specbools[p, i])
sdata[i>>3] |= (byte)(1 << (i&7)); sdata[i>>3] |= (byte)(1 << (i&7));
}
sdata.CopyTo(SAV.Data, SAV.PokeDex + 8 + brSize * p); sdata.CopyTo(SAV.Data, SAV.PokeDex + 8 + (brSize * p));
} }
// Build new bool array for the Languages // Build new bool array for the Languages
@ -229,19 +243,23 @@ namespace PKHeX.WinForms
int speciesCount = langbools.GetLength(1); int speciesCount = langbools.GetLength(1);
bool[] languagedata = new bool[speciesCount << 3]; bool[] languagedata = new bool[speciesCount << 3];
for (int i = 0; i < speciesCount; i++) for (int i = 0; i < speciesCount; i++)
{
for (int l = 0; l < langCount; l++) for (int l = 0; l < langCount; l++)
languagedata[i * langCount + l] = langbools[l, i]; languagedata[(i * langCount) + l] = langbools[l, i];
}
// Return to Byte Array // Return to Byte Array
byte[] ldata = new byte[languagedata.Length>>3]; byte[] ldata = new byte[languagedata.Length>>3];
for (int i = 0; i < languagedata.Length; i++) for (int i = 0; i < languagedata.Length; i++)
{
if (languagedata[i]) if (languagedata[i])
ldata[i>>3] |= (byte)(1 << (i&7)); ldata[i>>3] |= (byte)(1 << (i&7));
}
ldata.CopyTo(SAV.Data, SAV.PokeDexLanguageFlags); ldata.CopyTo(SAV.Data, SAV.PokeDexLanguageFlags);
} }
int FormDex = SAV.PokeDex + 0x8 + brSize * 9; int FormDex = SAV.PokeDex + 0x8 + (brSize * 9);
formbools.CopyTo(SAV.Data, FormDex); formbools.CopyTo(SAV.Data, FormDex);
} }
@ -249,6 +267,7 @@ namespace PKHeX.WinForms
{ {
Close(); Close();
} }
private void B_Save_Click(object sender, EventArgs e) private void B_Save_Click(object sender, EventArgs e)
{ {
SetEntry(); SetEntry();
@ -281,16 +300,22 @@ namespace PKHeX.WinForms
CHK_P3.Checked = CHK_P5.Checked = gt != 0 && gt != 255 && ModifierKeys != Keys.Control; CHK_P3.Checked = CHK_P5.Checked = gt != 0 && gt != 255 && ModifierKeys != Keys.Control;
if (ModifierKeys == Keys.Control) if (ModifierKeys == Keys.Control)
{
foreach (var chk in new[] { CHK_P6, CHK_P7, CHK_P8, CHK_P9 }) foreach (var chk in new[] { CHK_P6, CHK_P7, CHK_P8, CHK_P9 })
chk.Checked = false; chk.Checked = false;
}
else if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked)) else if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked))
{
(gt != 254 ? CHK_P6 : CHK_P7).Checked = true; (gt != 254 ? CHK_P6 : CHK_P7).Checked = true;
}
} }
private void B_Modify_Click(object sender, EventArgs e) private void B_Modify_Click(object sender, EventArgs e)
{ {
Button btn = (Button)sender; Button btn = (Button)sender;
modifyMenu.Show(btn.PointToScreen(new Point(0, btn.Height))); modifyMenu.Show(btn.PointToScreen(new Point(0, btn.Height)));
} }
private void ModifyAll(object sender, EventArgs e) private void ModifyAll(object sender, EventArgs e)
{ {
int lang = SAV.Language; int lang = SAV.Language;
@ -298,6 +323,7 @@ namespace PKHeX.WinForms
lang--; lang--;
if (sender == mnuSeenNone || sender == mnuSeenAll || sender == mnuComplete) if (sender == mnuSeenNone || sender == mnuSeenAll || sender == mnuComplete)
{
for (int i = 0; i < LB_Species.Items.Count; i++) for (int i = 0; i < LB_Species.Items.Count; i++)
{ {
int gt = SAV.Personal[i + 1].Gender; int gt = SAV.Personal[i + 1].Gender;
@ -318,11 +344,15 @@ namespace PKHeX.WinForms
} }
if (!CHK_P1.Checked) if (!CHK_P1.Checked)
{
foreach (CheckBox t in CL) foreach (CheckBox t in CL)
t.Checked = false; t.Checked = false;
}
} }
}
if (sender == mnuCaughtNone || sender == mnuCaughtAll || sender == mnuComplete) if (sender == mnuCaughtNone || sender == mnuCaughtAll || sender == mnuComplete)
{
for (int i = 0; i < CB_Species.Items.Count; i++) for (int i = 0; i < CB_Species.Items.Count; i++)
{ {
int gt = SAV.Personal[i + 1].Gender; int gt = SAV.Personal[i + 1].Gender;
@ -338,8 +368,10 @@ namespace PKHeX.WinForms
if (mnuCaughtNone == sender) if (mnuCaughtNone == sender)
{ {
if (!(CHK_P2.Checked || CHK_P3.Checked || CHK_P4.Checked || CHK_P5.Checked)) // if seen if (!(CHK_P2.Checked || CHK_P3.Checked || CHK_P4.Checked || CHK_P5.Checked)) // if seen
{
if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked)) // not displayed if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked)) // not displayed
(gt != 254 ? CHK_P6 : CHK_P7).Checked = true; // check one (gt != 254 ? CHK_P6 : CHK_P7).Checked = true; // check one
}
} }
if (mnuCaughtNone != sender) if (mnuCaughtNone != sender)
{ {
@ -360,6 +392,7 @@ namespace PKHeX.WinForms
(gt != 254 ? CHK_P6 : CHK_P7).Checked = true; (gt != 254 ? CHK_P6 : CHK_P7).Checked = true;
} }
} }
}
SetEntry(); SetEntry();
SetData(); SetData();
@ -376,16 +409,20 @@ namespace PKHeX.WinForms
// Only allow one form to be displayed if the user sets a new display value // Only allow one form to be displayed if the user sets a new display value
if (e.NewValue != CheckState.Checked) return; if (e.NewValue != CheckState.Checked) return;
for (int i = 0; i < CLB_FormDisplayed.Items.Count; i++) for (int i = 0; i < CLB_FormDisplayed.Items.Count; i++)
{
if (i != e.Index) if (i != e.Index)
CLB_FormDisplayed.SetItemChecked(i, false); CLB_FormDisplayed.SetItemChecked(i, false);
else if (sender == CLB_FormDisplayed) else if (sender == CLB_FormDisplayed)
CLB_FormsSeen.SetItemChecked(e.Index, true); // ensure this form is seen CLB_FormsSeen.SetItemChecked(e.Index, true); // ensure this form is seen
}
} }
private void B_ModifyForms_Click(object sender, EventArgs e) private void B_ModifyForms_Click(object sender, EventArgs e)
{ {
Button btn = (Button)sender; Button btn = (Button)sender;
modifyMenuForms.Show(btn.PointToScreen(new Point(0, btn.Height))); modifyMenuForms.Show(btn.PointToScreen(new Point(0, btn.Height)));
} }
private void ModifyAllForms(object sender, EventArgs e) private void ModifyAllForms(object sender, EventArgs e)
{ {
if (sender == mnuFormNone) if (sender == mnuFormNone)

View file

@ -6,13 +6,13 @@ namespace PKHeX.WinForms
{ {
public partial class SAV_BerryFieldXY : Form public partial class SAV_BerryFieldXY : Form
{ {
private readonly SaveFile Origin;
private readonly SAV6 SAV; private readonly SAV6 SAV;
public SAV_BerryFieldXY(SaveFile sav) public SAV_BerryFieldXY(SaveFile sav)
{ {
InitializeComponent(); InitializeComponent();
WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage); WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage);
SAV = (SAV6)(Origin = sav).Clone(); SAV = (SAV6)sav;
listBox1.SelectedIndex = 0; listBox1.SelectedIndex = 0;
} }
@ -21,14 +21,15 @@ namespace PKHeX.WinForms
// Change Berry Field // Change Berry Field
// Gather Data // Gather Data
int berry = BitConverter.ToUInt16(SAV.Data, SAV.BerryField + 0xC + listBox1.SelectedIndex*0x18 + 1 * 0); int ofs = SAV.BerryField + 0xC + (listBox1.SelectedIndex * 0x18);
int u1 = BitConverter.ToUInt16(SAV.Data, SAV.BerryField + 0xC + listBox1.SelectedIndex * 0x18 + 1 * 2); int berry = BitConverter.ToUInt16(SAV.Data, ofs + (2 * 0));
int u2 = BitConverter.ToUInt16(SAV.Data, SAV.BerryField + 0xC + listBox1.SelectedIndex * 0x18 + 2 * 2); int u1 = BitConverter.ToUInt16(SAV.Data, ofs + (2 * 1));
int u3 = BitConverter.ToUInt16(SAV.Data, SAV.BerryField + 0xC + listBox1.SelectedIndex * 0x18 + 3 * 2); int u2 = BitConverter.ToUInt16(SAV.Data, ofs + (2 * 2));
int u4 = BitConverter.ToUInt16(SAV.Data, SAV.BerryField + 0xC + listBox1.SelectedIndex * 0x18 + 4 * 2); int u3 = BitConverter.ToUInt16(SAV.Data, ofs + (2 * 3));
int u5 = BitConverter.ToUInt16(SAV.Data, SAV.BerryField + 0xC + listBox1.SelectedIndex * 0x18 + 5 * 2); int u4 = BitConverter.ToUInt16(SAV.Data, ofs + (2 * 4));
int u6 = BitConverter.ToUInt16(SAV.Data, SAV.BerryField + 0xC + listBox1.SelectedIndex * 0x18 + 6 * 2); int u5 = BitConverter.ToUInt16(SAV.Data, ofs + (2 * 5));
int u7 = BitConverter.ToUInt16(SAV.Data, SAV.BerryField + 0xC + listBox1.SelectedIndex * 0x18 + 7 * 2); int u6 = BitConverter.ToUInt16(SAV.Data, ofs + (2 * 6));
int u7 = BitConverter.ToUInt16(SAV.Data, ofs + (2 * 7));
// Display Data // Display Data
TB_Berry.Text = berry.ToString(); TB_Berry.Text = berry.ToString();

View file

@ -9,6 +9,7 @@ namespace PKHeX.WinForms
{ {
private readonly SaveFile Origin; private readonly SaveFile Origin;
private readonly SaveFile SAV; private readonly SaveFile SAV;
public SAV_BoxLayout(SaveFile sav, int box) public SAV_BoxLayout(SaveFile sav, int box)
{ {
InitializeComponent(); InitializeComponent();
@ -51,12 +52,14 @@ namespace PKHeX.WinForms
return false; return false;
} }
} }
private void LoadBoxNames() private void LoadBoxNames()
{ {
LB_BoxSelect.Items.Clear(); LB_BoxSelect.Items.Clear();
for (int i = 0; i < SAV.BoxCount; i++) for (int i = 0; i < SAV.BoxCount; i++)
LB_BoxSelect.Items.Add(SAV.GetBoxName(i)); LB_BoxSelect.Items.Add(SAV.GetBoxName(i));
} }
private void LoadUnlockedCount() private void LoadUnlockedCount()
{ {
if (SAV.BoxesUnlocked <= 0) if (SAV.BoxesUnlocked <= 0)
@ -72,6 +75,7 @@ namespace PKHeX.WinForms
CB_Unlocked.Items.Add(i); CB_Unlocked.Items.Add(i);
CB_Unlocked.SelectedIndex = Math.Min(max, SAV.BoxesUnlocked); CB_Unlocked.SelectedIndex = Math.Min(max, SAV.BoxesUnlocked);
} }
private void LoadFlags() private void LoadFlags()
{ {
byte[] flags = SAV.BoxFlags; byte[] flags = SAV.BoxFlags;
@ -99,6 +103,7 @@ namespace PKHeX.WinForms
private NumericUpDown[] flagArr = new NumericUpDown[0]; private NumericUpDown[] flagArr = new NumericUpDown[0];
private bool editing; private bool editing;
private bool renamingBox; private bool renamingBox;
private void ChangeBox(object sender, EventArgs e) private void ChangeBox(object sender, EventArgs e)
{ {
if (renamingBox) if (renamingBox)
@ -110,6 +115,7 @@ namespace PKHeX.WinForms
editing = false; editing = false;
} }
private void ChangeBoxDetails(object sender, EventArgs e) private void ChangeBoxDetails(object sender, EventArgs e)
{ {
if (editing) if (editing)
@ -120,10 +126,12 @@ namespace PKHeX.WinForms
LB_BoxSelect.Items[LB_BoxSelect.SelectedIndex] = TB_BoxName.Text; LB_BoxSelect.Items[LB_BoxSelect.SelectedIndex] = TB_BoxName.Text;
renamingBox = false; renamingBox = false;
} }
private void B_Cancel_Click(object sender, EventArgs e) private void B_Cancel_Click(object sender, EventArgs e)
{ {
Close(); Close();
} }
private void B_Save_Click(object sender, EventArgs e) private void B_Save_Click(object sender, EventArgs e)
{ {
if (flagArr.Length > 0) if (flagArr.Length > 0)
@ -184,7 +192,10 @@ namespace PKHeX.WinForms
WinFormsUtil.Alert("Locked/Team slots prevent movement of box(es)."); WinFormsUtil.Alert("Locked/Team slots prevent movement of box(es).");
} }
else else
{
ChangeBox(null, null); ChangeBox(null, null);
}
editing = renamingBox = false; editing = renamingBox = false;
} }
} }

View file

@ -12,6 +12,7 @@ namespace PKHeX.WinForms
{ {
private readonly SaveFile Origin; private readonly SaveFile Origin;
private readonly SAV6 SAV; private readonly SAV6 SAV;
public SAV_HallOfFame(SaveFile sav) public SAV_HallOfFame(SaveFile sav)
{ {
InitializeComponent(); InitializeComponent();
@ -53,6 +54,7 @@ namespace PKHeX.WinForms
catch (Exception e) { WinFormsUtil.Alert("Font loading failed...", e.ToString()); } catch (Exception e) { WinFormsUtil.Alert("Font loading failed...", e.ToString()); }
editing = true; editing = true;
} }
private bool editing; private bool editing;
private readonly string[] gendersymbols = Main.GenderSymbols; private readonly string[] gendersymbols = Main.GenderSymbols;
@ -91,11 +93,13 @@ namespace PKHeX.WinForms
{ {
Close(); Close();
} }
private void B_Close_Click(object sender, EventArgs e) private void B_Close_Click(object sender, EventArgs e)
{ {
Origin.SetData(data, SAV.HoF); Origin.SetData(data, SAV.HoF);
Close(); Close();
} }
private void DisplayEntry(object sender, EventArgs e) private void DisplayEntry(object sender, EventArgs e)
{ {
editing = false; editing = false;
@ -180,16 +184,21 @@ namespace PKHeX.WinForms
NUP_PartyIndex.Value = 1; NUP_PartyIndex.Value = 1;
NUP_PartyIndex_ValueChanged(sender, e); NUP_PartyIndex_ValueChanged(sender, e);
} }
else editing = true; else
end: {
editing = true;
}
end:
RTB.Lines = s.ToArray(); RTB.Lines = s.ToArray();
RTB.Font = new Font("Courier New", 8); RTB.Font = new Font("Courier New", 8);
} }
private void NUP_PartyIndex_ValueChanged(object sender, EventArgs e) private void NUP_PartyIndex_ValueChanged(object sender, EventArgs e)
{ {
editing = false; editing = false;
int index = LB_DataEntry.SelectedIndex; int index = LB_DataEntry.SelectedIndex;
int offset = index * 0x1B4 + (Convert.ToInt32(NUP_PartyIndex.Value)-1) * 0x48; int offset = (index * 0x1B4) + ((Convert.ToInt32(NUP_PartyIndex.Value)-1) * 0x48);
if (offset < 0) return; if (offset < 0) return;
@ -235,6 +244,7 @@ namespace PKHeX.WinForms
bpkx.Image = SpriteUtil.GetSprite(species, (int)form, (int)gender, item, false, shiny == 1); bpkx.Image = SpriteUtil.GetSprite(species, (int)form, (int)gender, item, false, shiny == 1);
editing = true; editing = true;
} }
private void Write_Entry(object sender, EventArgs e) private void Write_Entry(object sender, EventArgs e)
{ {
if (!editing) if (!editing)
@ -244,7 +254,7 @@ namespace PKHeX.WinForms
int index = LB_DataEntry.SelectedIndex; int index = LB_DataEntry.SelectedIndex;
int partymember = Convert.ToInt32(NUP_PartyIndex.Value) - 1; int partymember = Convert.ToInt32(NUP_PartyIndex.Value) - 1;
int offset = index * 0x1B4 + partymember * 0x48; int offset = (index * 0x1B4) + (partymember * 0x48);
BitConverter.GetBytes(Convert.ToUInt16(CB_Species.SelectedValue)).CopyTo(data, offset + 0x00); BitConverter.GetBytes(Convert.ToUInt16(CB_Species.SelectedValue)).CopyTo(data, offset + 0x00);
BitConverter.GetBytes(Convert.ToUInt16(CB_HeldItem.SelectedValue)).CopyTo(data, offset + 0x02); BitConverter.GetBytes(Convert.ToUInt16(CB_HeldItem.SelectedValue)).CopyTo(data, offset + 0x02);
@ -296,6 +306,7 @@ namespace PKHeX.WinForms
bpkx.Image = SpriteUtil.GetSprite(WinFormsUtil.GetIndex(CB_Species), CB_Form.SelectedIndex & 0x1F, PKX.GetGenderFromString(Label_Gender.Text), WinFormsUtil.GetIndex(CB_HeldItem), false, CHK_Shiny.Checked); bpkx.Image = SpriteUtil.GetSprite(WinFormsUtil.GetIndex(CB_Species), CB_Form.SelectedIndex & 0x1F, PKX.GetGenderFromString(Label_Gender.Text), WinFormsUtil.GetIndex(CB_HeldItem), false, CHK_Shiny.Checked);
DisplayEntry(null, null); // refresh text view DisplayEntry(null, null); // refresh text view
} }
private void Validate_TextBoxes() private void Validate_TextBoxes()
{ {
TB_Level.Text = Math.Min(Util.ToInt32(TB_Level.Text), 100).ToString(); TB_Level.Text = Math.Min(Util.ToInt32(TB_Level.Text), 100).ToString();
@ -303,6 +314,7 @@ namespace PKHeX.WinForms
TB_TID.Text = Math.Min(Util.ToInt32(TB_TID.Text), ushort.MaxValue).ToString(); TB_TID.Text = Math.Min(Util.ToInt32(TB_TID.Text), ushort.MaxValue).ToString();
TB_SID.Text = Math.Min(Util.ToInt32(TB_SID.Text), ushort.MaxValue).ToString(); TB_SID.Text = Math.Min(Util.ToInt32(TB_SID.Text), ushort.MaxValue).ToString();
} }
private void UpdateNickname(object sender, EventArgs e) private void UpdateNickname(object sender, EventArgs e)
{ {
if (!CHK_Nicknamed.Checked) if (!CHK_Nicknamed.Checked)
@ -310,13 +322,18 @@ namespace PKHeX.WinForms
// Fetch Current Species and set it as Nickname Text // Fetch Current Species and set it as Nickname Text
int species = WinFormsUtil.GetIndex(CB_Species); int species = WinFormsUtil.GetIndex(CB_Species);
if (species == 0 || species > 721) if (species == 0 || species > 721)
TB_Nickname.Text = "";
else try
{ {
// get language TB_Nickname.Text = "";
TB_Nickname.Text = PKX.GetSpeciesNameGeneration(species, SAV.Language, 6); }
else
{
try
{
// get language
TB_Nickname.Text = PKX.GetSpeciesNameGeneration(species, SAV.Language, 6);
}
catch { }
} }
catch { }
} }
TB_Nickname.ReadOnly = !CHK_Nicknamed.Checked; TB_Nickname.ReadOnly = !CHK_Nicknamed.Checked;
@ -332,11 +349,13 @@ namespace PKHeX.WinForms
CB_Form.InitializeBinding(); CB_Form.InitializeBinding();
CB_Form.DataSource = PKX.GetFormList(species, GameInfo.Strings.types, GameInfo.Strings.forms, Main.GenderSymbols, SAV.Generation).ToList(); CB_Form.DataSource = PKX.GetFormList(species, GameInfo.Strings.types, GameInfo.Strings.forms, Main.GenderSymbols, SAV.Generation).ToList();
} }
private void UpdateSpecies(object sender, EventArgs e) private void UpdateSpecies(object sender, EventArgs e)
{ {
SetForms(); SetForms();
UpdateNickname(null, null); UpdateNickname(null, null);
} }
private void UpdateShiny(object sender, EventArgs e) private void UpdateShiny(object sender, EventArgs e)
{ {
if (!editing) if (!editing)
@ -345,6 +364,7 @@ namespace PKHeX.WinForms
Write_Entry(null, null); Write_Entry(null, null);
} }
private void UpdateGender(object sender, EventArgs e) private void UpdateGender(object sender, EventArgs e)
{ {
// Get Gender Threshold // Get Gender Threshold
@ -376,6 +396,7 @@ namespace PKHeX.WinForms
Write_Entry(null, null); Write_Entry(null, null);
} }
private void SetGenderLabel(int gender) private void SetGenderLabel(int gender)
{ {
if (gender == 0) if (gender == 0)
@ -397,8 +418,8 @@ namespace PKHeX.WinForms
{ {
if (LB_DataEntry.SelectedIndex < 1) { WinFormsUtil.Alert("Cannot delete your first Hall of Fame Clear entry."); return; } if (LB_DataEntry.SelectedIndex < 1) { WinFormsUtil.Alert("Cannot delete your first Hall of Fame Clear entry."); return; }
int index = LB_DataEntry.SelectedIndex; int index = LB_DataEntry.SelectedIndex;
if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, $"Delete Entry {index} from your records?") if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, $"Delete Entry {index} from your records?") != DialogResult.Yes)
!= DialogResult.Yes) return; return;
int offset = index * 0x1B4; int offset = index * 0x1B4;
if (index != 15) Array.Copy(data, offset + 0x1B4, data, offset, 0x1B4 * (15 - index)); if (index != 15) Array.Copy(data, offset + 0x1B4, data, offset, 0x1B4 * (15 - index));

View file

@ -10,6 +10,7 @@ namespace PKHeX.WinForms
{ {
private readonly SaveFile Origin; private readonly SaveFile Origin;
private readonly SAV6 SAV; private readonly SAV6 SAV;
public SAV_Link6(SaveFile sav) public SAV_Link6(SaveFile sav)
{ {
InitializeComponent(); InitializeComponent();
@ -46,10 +47,12 @@ namespace PKHeX.WinForms
Origin.SetData(SAV.Data, 0); Origin.SetData(SAV.Data, 0);
Close(); Close();
} }
private void B_Cancel_Click(object sender, EventArgs e) private void B_Cancel_Click(object sender, EventArgs e)
{ {
Close(); Close();
} }
private void B_Import_Click(object sender, EventArgs e) private void B_Import_Click(object sender, EventArgs e)
{ {
OpenFileDialog ofd = new OpenFileDialog {Filter = PL6.Filter}; OpenFileDialog ofd = new OpenFileDialog {Filter = PL6.Filter};
@ -64,6 +67,7 @@ namespace PKHeX.WinForms
LoadLinkData(data); LoadLinkData(data);
B_Export.Enabled = true; B_Export.Enabled = true;
} }
private void B_Export_Click(object sender, EventArgs e) private void B_Export_Click(object sender, EventArgs e)
{ {
if (LinkInfo.Data == null) if (LinkInfo.Data == null)

View file

@ -30,6 +30,7 @@ namespace PKHeX.WinForms
} }
private void B_Cancel_Click(object sender, EventArgs e) => Close(); private void B_Cancel_Click(object sender, EventArgs e) => Close();
private void B_Save_Click(object sender, EventArgs e) private void B_Save_Click(object sender, EventArgs e)
{ {
SaveData(); SaveData();
@ -40,6 +41,7 @@ namespace PKHeX.WinForms
private static readonly string[] Values = Enum.GetNames(typeof(OPower6Value)); private static readonly string[] Values = Enum.GetNames(typeof(OPower6Value));
private OPower6Type Current; private OPower6Type Current;
private void SaveData() private void SaveData()
{ {
Data.MasterFlag = CHK_Master.Checked; Data.MasterFlag = CHK_Master.Checked;
@ -63,6 +65,7 @@ namespace PKHeX.WinForms
CHK_MAX.Enabled = Data.GetHasOPowerMAX(Current); CHK_MAX.Enabled = Data.GetHasOPowerMAX(Current);
CHK_MAX.Checked = Data.GetOPowerMAX(Current); CHK_MAX.Checked = Data.GetOPowerMAX(Current);
} }
private void SaveCurrent() private void SaveCurrent()
{ {
Data.SetOPowerLevel(Current, CB_Value.SelectedIndex); Data.SetOPowerLevel(Current, CB_Value.SelectedIndex);

View file

@ -8,6 +8,7 @@ namespace PKHeX.WinForms
{ {
private readonly SaveFile Origin; private readonly SaveFile Origin;
private readonly SAV6 SAV; private readonly SAV6 SAV;
public SAV_PokeBlockORAS(SaveFile sav) public SAV_PokeBlockORAS(SaveFile sav)
{ {
InitializeComponent(); InitializeComponent();
@ -19,19 +20,21 @@ namespace PKHeX.WinForms
for (int i = 0; i < lbl_spec.Length; i++) for (int i = 0; i < lbl_spec.Length; i++)
{ {
lbl_spec[i].Text = $"{GameInfo.Strings.pokeblocks[94 + i]}:"; lbl_spec[i].Text = $"{GameInfo.Strings.pokeblocks[94 + i]}:";
nup_spec[i].Value = BitConverter.ToUInt32(SAV.Data, SAV.Contest + i * 4); nup_spec[i].Value = BitConverter.ToUInt32(SAV.Data, SAV.Contest + (i * 4));
} }
} }
private readonly NumericUpDown[] nup_spec; private readonly NumericUpDown[] nup_spec;
private void B_Cancel_Click(object sender, EventArgs e) private void B_Cancel_Click(object sender, EventArgs e)
{ {
Close(); Close();
} }
private void B_Save_Click(object sender, EventArgs e) private void B_Save_Click(object sender, EventArgs e)
{ {
for (int i = 0; i < nup_spec.Length; i++) for (int i = 0; i < nup_spec.Length; i++)
BitConverter.GetBytes((uint)nup_spec[i].Value).CopyTo(SAV.Data, SAV.Contest + i * 4); BitConverter.GetBytes((uint)nup_spec[i].Value).CopyTo(SAV.Data, SAV.Contest + (i * 4));
Origin.SetData(SAV.Data, 0); Origin.SetData(SAV.Data, 0);
Close(); Close();
} }
@ -48,9 +51,10 @@ namespace PKHeX.WinForms
{ {
ushort berry = plantable[Util.Rand.Next(1, plantable.Length)]; // get random berry item ID from list ushort berry = plantable[Util.Rand.Next(1, plantable.Length)]; // get random berry item ID from list
BitConverter.GetBytes(berry).CopyTo(tree, 6); // put berry into tree. BitConverter.GetBytes(berry).CopyTo(tree, 6); // put berry into tree.
tree.CopyTo(SAV.Data, SAV.BerryField + 0x10 * i); // put tree into plot tree.CopyTo(SAV.Data, SAV.BerryField + (0x10 * i)); // put tree into plot
} }
} }
private void B_GiveAllBlocks_Click(object sender, EventArgs e) private void B_GiveAllBlocks_Click(object sender, EventArgs e)
{ {
foreach (NumericUpDown n in nup_spec) foreach (NumericUpDown n in nup_spec)

View file

@ -11,6 +11,7 @@ namespace PKHeX.WinForms
{ {
private readonly SaveFile Origin; private readonly SaveFile Origin;
private readonly SAV6 SAV; private readonly SAV6 SAV;
public SAV_PokedexORAS(SaveFile sav) public SAV_PokedexORAS(SaveFile sav)
{ {
InitializeComponent(); InitializeComponent();
@ -59,6 +60,7 @@ namespace PKHeX.WinForms
GetEntry(); GetEntry();
editing = false; editing = false;
} }
private void ChangeLBSpecies(object sender, EventArgs e) private void ChangeLBSpecies(object sender, EventArgs e)
{ {
if (editing) return; if (editing) return;
@ -70,6 +72,7 @@ namespace PKHeX.WinForms
GetEntry(); GetEntry();
editing = false; editing = false;
} }
private void ChangeDisplayed(object sender, EventArgs e) private void ChangeDisplayed(object sender, EventArgs e)
{ {
if (!((CheckBox) sender).Checked) if (!((CheckBox) sender).Checked)
@ -85,10 +88,13 @@ namespace PKHeX.WinForms
CHK_P4.Checked |= CHK_P8.Checked; CHK_P4.Checked |= CHK_P8.Checked;
CHK_P5.Checked |= CHK_P9.Checked; CHK_P5.Checked |= CHK_P9.Checked;
} }
private void ChangeEncountered(object sender, EventArgs e) private void ChangeEncountered(object sender, EventArgs e)
{ {
if (!(CHK_P2.Checked || CHK_P3.Checked || CHK_P4.Checked || CHK_P5.Checked)) if (!(CHK_P2.Checked || CHK_P3.Checked || CHK_P4.Checked || CHK_P5.Checked))
{
CHK_P6.Checked = CHK_P7.Checked = CHK_P8.Checked = CHK_P9.Checked = false; CHK_P6.Checked = CHK_P7.Checked = CHK_P8.Checked = CHK_P9.Checked = false;
}
else if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked)) else if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked))
{ {
if (sender == CHK_P2 && CHK_P2.Checked) if (sender == CHK_P2 && CHK_P2.Checked)
@ -121,7 +127,7 @@ namespace PKHeX.WinForms
CHK_P3.Enabled = CHK_P5.Enabled = CHK_P7.Enabled = CHK_P9.Enabled = gt != 0 && gt != 255; // Not Male-Only and Not Genderless CHK_P3.Enabled = CHK_P5.Enabled = CHK_P7.Enabled = CHK_P9.Enabled = gt != 0 && gt != 255; // Not Male-Only and Not Genderless
// Load Encountered Count // Load Encountered Count
MT_Count.Text = BitConverter.ToUInt16(SAV.Data, SAV.EncounterCount + (pk - 1) * 2).ToString(); MT_Count.Text = BitConverter.ToUInt16(SAV.Data, SAV.EncounterCount + ((pk - 1) * 2)).ToString();
CLB_FormsSeen.Items.Clear(); CLB_FormsSeen.Items.Clear();
CLB_FormDisplayed.Items.Clear(); CLB_FormDisplayed.Items.Clear();
@ -136,15 +142,16 @@ namespace PKHeX.WinForms
// 0x26 packs of bools // 0x26 packs of bools
for (int i = 0; i < forms.Length; i++) // Seen for (int i = 0; i < forms.Length; i++) // Seen
CLB_FormsSeen.Items.Add(forms[i], formbools[f + i + 0*FormLen*8]); CLB_FormsSeen.Items.Add(forms[i], formbools[f + i + (0 *FormLen*8)]);
for (int i = 0; i < forms.Length; i++) // Seen Shiny for (int i = 0; i < forms.Length; i++) // Seen Shiny
CLB_FormsSeen.Items.Add($"* {forms[i]}", formbools[f + i + 1*FormLen*8]); CLB_FormsSeen.Items.Add($"* {forms[i]}", formbools[f + i + (1 *FormLen*8)]);
for (int i = 0; i < forms.Length; i++) // Displayed for (int i = 0; i < forms.Length; i++) // Displayed
CLB_FormDisplayed.Items.Add(forms[i], formbools[f + i + 2*FormLen*8]); CLB_FormDisplayed.Items.Add(forms[i], formbools[f + i + (2 *FormLen*8)]);
for (int i = 0; i < forms.Length; i++) // Displayed Shiny for (int i = 0; i < forms.Length; i++) // Displayed Shiny
CLB_FormDisplayed.Items.Add($"* {forms[i]}", formbools[f + i + 3*FormLen*8]); CLB_FormDisplayed.Items.Add($"* {forms[i]}", formbools[f + i + (3 *FormLen*8)]);
} }
private void SetEntry() private void SetEntry()
{ {
if (species < 0) if (species < 0)
@ -168,7 +175,7 @@ namespace PKHeX.WinForms
langbools[5, species - 1] = CHK_L6.Checked; langbools[5, species - 1] = CHK_L6.Checked;
langbools[6, species - 1] = CHK_L7.Checked; langbools[6, species - 1] = CHK_L7.Checked;
BitConverter.GetBytes((ushort)Math.Min(0xFFFF, Util.ToUInt32(MT_Count.Text))).CopyTo(SAV.Data, SAV.EncounterCount + (species - 1) * 2); BitConverter.GetBytes((ushort)Math.Min(0xFFFF, Util.ToUInt32(MT_Count.Text))).CopyTo(SAV.Data, SAV.EncounterCount + ((species - 1) * 2));
int fc = SAV.Personal[species].FormeCount; int fc = SAV.Personal[species].FormeCount;
int f = SaveUtil.GetDexFormIndexORAS(species, fc); int f = SaveUtil.GetDexFormIndexORAS(species, fc);
@ -176,15 +183,15 @@ namespace PKHeX.WinForms
return; return;
for (int i = 0; i < CLB_FormsSeen.Items.Count/2; i++) // Seen for (int i = 0; i < CLB_FormsSeen.Items.Count/2; i++) // Seen
formbools[f + i + 0*FormLen*8] = CLB_FormsSeen.GetItemChecked(i); formbools[f + i + (0 *FormLen*8)] = CLB_FormsSeen.GetItemChecked(i);
for (int i = 0; i < CLB_FormsSeen.Items.Count/2; i++) // Seen Shiny for (int i = 0; i < CLB_FormsSeen.Items.Count/2; i++) // Seen Shiny
formbools[f + i + 1*FormLen*8] = CLB_FormsSeen.GetItemChecked(i + CLB_FormsSeen.Items.Count/2); formbools[f + i + (1 *FormLen*8)] = CLB_FormsSeen.GetItemChecked(i + (CLB_FormsSeen.Items.Count/2));
editing = true; editing = true;
for (int i = 0; i < CLB_FormDisplayed.Items.Count/2; i++) // Displayed for (int i = 0; i < CLB_FormDisplayed.Items.Count/2; i++) // Displayed
formbools[f + i + 2*FormLen*8] = CLB_FormDisplayed.GetItemChecked(i); formbools[f + i + (2 *FormLen*8)] = CLB_FormDisplayed.GetItemChecked(i);
for (int i = 0; i < CLB_FormDisplayed.Items.Count/2; i++) // Displayed Shiny for (int i = 0; i < CLB_FormDisplayed.Items.Count/2; i++) // Displayed Shiny
formbools[f + i + 3*FormLen*8] = CLB_FormDisplayed.GetItemChecked(i + CLB_FormDisplayed.Items.Count/2); formbools[f + i + (3 *FormLen*8)] = CLB_FormDisplayed.GetItemChecked(i + (CLB_FormDisplayed.Items.Count/2));
editing = false; editing = false;
} }
@ -194,7 +201,7 @@ namespace PKHeX.WinForms
for (int i = 0; i < 9; i++) for (int i = 0; i < 9; i++)
{ {
byte[] data = new byte[0x60]; byte[] data = new byte[0x60];
int offset = SAV.PokeDex + 0x8 + 0x60 * i; int offset = SAV.PokeDex + 0x8 + (0x60 * i);
Array.Copy(SAV.Data, offset, data, 0, data.Length); Array.Copy(SAV.Data, offset, data, 0, data.Length);
BitArray BitRegion = new BitArray(data); BitArray BitRegion = new BitArray(data);
for (int b = 0; b < 0x60 * 8; b++) for (int b = 0; b < 0x60 * 8; b++)
@ -205,14 +212,17 @@ namespace PKHeX.WinForms
byte[] langdata = new byte[0x280]; byte[] langdata = new byte[0x280];
Array.Copy(SAV.Data, SAV.PokeDexLanguageFlags, langdata, 0, langdata.Length); Array.Copy(SAV.Data, SAV.PokeDexLanguageFlags, langdata, 0, langdata.Length);
BitArray LangRegion = new BitArray(langdata); BitArray LangRegion = new BitArray(langdata);
for (int b = 0; b < 721; b++) // 721 Species for (int b = 0; b < SAV.MaxSpeciesID; b++) // 721 Species
{
for (int i = 0; i < 7; i++) // 7 Languages for (int i = 0; i < 7; i++) // 7 Languages
langbools[i, b] = LangRegion[7 * b + i]; langbools[i, b] = LangRegion[(7 * b) + i];
}
byte[] formdata = new byte[FormLen*4]; byte[] formdata = new byte[FormLen*4];
Array.Copy(SAV.Data, SAV.PokeDex + 0x368, formdata, 0, formdata.Length); Array.Copy(SAV.Data, SAV.PokeDex + 0x368, formdata, 0, formdata.Length);
formbools = new BitArray(formdata); formbools = new BitArray(formdata);
} }
private void SetData() private void SetData()
{ {
// Save back the Species Bools // Save back the Species Bools
@ -222,24 +232,30 @@ namespace PKHeX.WinForms
byte[] sdata = new byte[0x60]; byte[] sdata = new byte[0x60];
for (int i = 0; i < 0x60*8; i++) for (int i = 0; i < 0x60*8; i++)
{
if (specbools[p, i]) if (specbools[p, i])
sdata[i/8] |= (byte) (1 << i%8); sdata[i/8] |= (byte) (1 << i%8);
}
sdata.CopyTo(SAV.Data, SAV.PokeDex + 8 + 0x60*p); sdata.CopyTo(SAV.Data, SAV.PokeDex + 8 + (0x60 * p));
} }
// Build new bool array for the Languages // Build new bool array for the Languages
bool[] languagedata = new bool[0x27C*8]; bool[] languagedata = new bool[0x27C*8];
for (int i = 0; i < 722; i++) for (int i = 0; i <= SAV.MaxSpeciesID; i++)
{
for (int l = 0; l < 7; l++) for (int l = 0; l < 7; l++)
languagedata[i*7 + l] = langbools[l, i]; languagedata[(i * 7) + l] = langbools[l, i];
}
// Return to Byte Array // Return to Byte Array
byte[] ldata = new byte[languagedata.Length/8]; byte[] ldata = new byte[languagedata.Length/8];
for (int i = 0; i < languagedata.Length; i++) for (int i = 0; i < languagedata.Length; i++)
{
if (languagedata[i]) if (languagedata[i])
ldata[i/8] |= (byte) (1 << i%8); ldata[i/8] |= (byte) (1 << i%8);
}
ldata.CopyTo(SAV.Data, SAV.PokeDexLanguageFlags); ldata.CopyTo(SAV.Data, SAV.PokeDexLanguageFlags);
@ -254,6 +270,7 @@ namespace PKHeX.WinForms
{ {
Close(); Close();
} }
private void B_Save_Click(object sender, EventArgs e) private void B_Save_Click(object sender, EventArgs e)
{ {
SetEntry(); SetEntry();
@ -286,10 +303,14 @@ namespace PKHeX.WinForms
CHK_P3.Checked = CHK_P5.Checked = gt != 0 && gt != 255 && ModifierKeys != Keys.Control; CHK_P3.Checked = CHK_P5.Checked = gt != 0 && gt != 255 && ModifierKeys != Keys.Control;
if (ModifierKeys == Keys.Control) if (ModifierKeys == Keys.Control)
foreach (var chk in new[]{CHK_P6, CHK_P7, CHK_P8, CHK_P9}) {
foreach (var chk in new[] { CHK_P6, CHK_P7, CHK_P8, CHK_P9 })
chk.Checked = false; chk.Checked = false;
}
else if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked)) else if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked))
{
(gt != 254 ? CHK_P6 : CHK_P7).Checked = true; (gt != 254 ? CHK_P6 : CHK_P7).Checked = true;
}
for (int i = 0; i < CLB_FormsSeen.Items.Count; i++) for (int i = 0; i < CLB_FormsSeen.Items.Count; i++)
CLB_FormsSeen.SetItemChecked(i, ModifierKeys != Keys.Control); CLB_FormsSeen.SetItemChecked(i, ModifierKeys != Keys.Control);
@ -299,23 +320,25 @@ namespace PKHeX.WinForms
if (Util.ToInt32(MT_Count.Text) == 0) if (Util.ToInt32(MT_Count.Text) == 0)
MT_Count.Text = "1"; MT_Count.Text = "1";
} }
private void B_Modify_Click(object sender, EventArgs e) private void B_Modify_Click(object sender, EventArgs e)
{ {
Button btn = (Button)sender; Button btn = (Button)sender;
modifyMenu.Show(btn.PointToScreen(new Point(0, btn.Height))); modifyMenu.Show(btn.PointToScreen(new Point(0, btn.Height)));
} }
private void ModifyAll(object sender, EventArgs e) private void ModifyAll(object sender, EventArgs e)
{ {
if (mnuDexNav == sender) if (mnuDexNav == sender)
{ {
for (int i = 0; i < 0x2D1; i++) for (int i = 0; i < SAV.MaxSpeciesID; i++)
BitConverter.GetBytes((ushort)999).CopyTo(SAV.Data, SAV.EncounterCount + i * 2); BitConverter.GetBytes((ushort)999).CopyTo(SAV.Data, SAV.EncounterCount + (i * 2));
return; return;
} }
if (mnuResetNav == sender) if (mnuResetNav == sender)
{ {
for (int i = 0; i < 0x2D1; i++) for (int i = 0; i < SAV.MaxSpeciesID; i++)
BitConverter.GetBytes((ushort)0).CopyTo(SAV.Data, SAV.EncounterCount + i * 2); BitConverter.GetBytes((ushort)0).CopyTo(SAV.Data, SAV.EncounterCount + (i * 2));
return; return;
} }
@ -324,6 +347,7 @@ namespace PKHeX.WinForms
lang--; lang--;
if (sender == mnuSeenNone || sender == mnuSeenAll || sender == mnuComplete) if (sender == mnuSeenNone || sender == mnuSeenAll || sender == mnuComplete)
{
for (int i = 0; i < CB_Species.Items.Count; i++) for (int i = 0; i < CB_Species.Items.Count; i++)
{ {
int gt = SAV.Personal[i + 1].Gender; int gt = SAV.Personal[i + 1].Gender;
@ -344,11 +368,15 @@ namespace PKHeX.WinForms
} }
if (!CHK_P1.Checked) if (!CHK_P1.Checked)
{
foreach (CheckBox t in CL) foreach (CheckBox t in CL)
t.Checked = false; t.Checked = false;
}
} }
}
if (sender == mnuCaughtNone || sender == mnuCaughtAll || sender == mnuComplete) if (sender == mnuCaughtNone || sender == mnuCaughtAll || sender == mnuComplete)
{
for (int i = 0; i < LB_Species.Items.Count; i++) for (int i = 0; i < LB_Species.Items.Count; i++)
{ {
int gt = SAV.Personal[i + 1].Gender; int gt = SAV.Personal[i + 1].Gender;
@ -361,8 +389,10 @@ namespace PKHeX.WinForms
if (mnuCaughtNone == sender) if (mnuCaughtNone == sender)
{ {
if (!(CHK_P2.Checked || CHK_P3.Checked || CHK_P4.Checked || CHK_P5.Checked)) // if seen if (!(CHK_P2.Checked || CHK_P3.Checked || CHK_P4.Checked || CHK_P5.Checked)) // if seen
{
if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked)) // not displayed if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked)) // not displayed
(gt != 254 ? CHK_P6 : CHK_P7).Checked = true; // check one (gt != 254 ? CHK_P6 : CHK_P7).Checked = true; // check one
}
} }
if (mnuCaughtNone != sender) if (mnuCaughtNone != sender)
{ {
@ -383,6 +413,7 @@ namespace PKHeX.WinForms
(gt != 254 ? CHK_P6 : CHK_P7).Checked = true; (gt != 254 ? CHK_P6 : CHK_P7).Checked = true;
} }
} }
}
SetEntry(); SetEntry();
SetData(); SetData();
@ -401,16 +432,20 @@ namespace PKHeX.WinForms
// Only allow one form to be displayed if the user sets a new display value // Only allow one form to be displayed if the user sets a new display value
if (e.NewValue != CheckState.Checked) return; if (e.NewValue != CheckState.Checked) return;
for (int i = 0; i < CLB_FormDisplayed.Items.Count; i++) for (int i = 0; i < CLB_FormDisplayed.Items.Count; i++)
{
if (i != e.Index) if (i != e.Index)
CLB_FormDisplayed.SetItemChecked(i, false); CLB_FormDisplayed.SetItemChecked(i, false);
else if (sender == CLB_FormDisplayed) else if (sender == CLB_FormDisplayed)
CLB_FormsSeen.SetItemChecked(e.Index, true); // ensure this form is seen CLB_FormsSeen.SetItemChecked(e.Index, true); // ensure this form is seen
}
} }
private void B_ModifyForms_Click(object sender, EventArgs e) private void B_ModifyForms_Click(object sender, EventArgs e)
{ {
Button btn = (Button)sender; Button btn = (Button)sender;
modifyMenuForms.Show(btn.PointToScreen(new Point(0, btn.Height))); modifyMenuForms.Show(btn.PointToScreen(new Point(0, btn.Height)));
} }
private void ModifyAllForms(object sender, EventArgs e) private void ModifyAllForms(object sender, EventArgs e)
{ {
if (sender == mnuFormNone) if (sender == mnuFormNone)

View file

@ -11,6 +11,7 @@ namespace PKHeX.WinForms
{ {
private readonly SaveFile Origin; private readonly SaveFile Origin;
private readonly SAV6 SAV; private readonly SAV6 SAV;
public SAV_PokedexXY(SaveFile sav) public SAV_PokedexXY(SaveFile sav)
{ {
InitializeComponent(); InitializeComponent();
@ -60,6 +61,7 @@ namespace PKHeX.WinForms
GetEntry(); GetEntry();
editing = false; editing = false;
} }
private void ChangeLBSpecies(object sender, EventArgs e) private void ChangeLBSpecies(object sender, EventArgs e)
{ {
if (editing) return; if (editing) return;
@ -71,6 +73,7 @@ namespace PKHeX.WinForms
GetEntry(); GetEntry();
editing = false; editing = false;
} }
private void ChangeDisplayed(object sender, EventArgs e) private void ChangeDisplayed(object sender, EventArgs e)
{ {
if (!((CheckBox) sender).Checked) if (!((CheckBox) sender).Checked)
@ -86,10 +89,13 @@ namespace PKHeX.WinForms
CHK_P4.Checked |= CHK_P8.Checked; CHK_P4.Checked |= CHK_P8.Checked;
CHK_P5.Checked |= CHK_P9.Checked; CHK_P5.Checked |= CHK_P9.Checked;
} }
private void ChangeEncountered(object sender, EventArgs e) private void ChangeEncountered(object sender, EventArgs e)
{ {
if (!(CHK_P2.Checked || CHK_P3.Checked || CHK_P4.Checked || CHK_P5.Checked)) if (!(CHK_P2.Checked || CHK_P3.Checked || CHK_P4.Checked || CHK_P5.Checked))
{
CHK_P6.Checked = CHK_P7.Checked = CHK_P8.Checked = CHK_P9.Checked = false; CHK_P6.Checked = CHK_P7.Checked = CHK_P8.Checked = CHK_P9.Checked = false;
}
else if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked)) else if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked))
{ {
if (sender == CHK_P2 && CHK_P2.Checked) if (sender == CHK_P2 && CHK_P2.Checked)
@ -137,15 +143,16 @@ namespace PKHeX.WinForms
// 0x26 packs of bools // 0x26 packs of bools
for (int i = 0; i < forms.Length; i++) // Seen for (int i = 0; i < forms.Length; i++) // Seen
CLB_FormsSeen.Items.Add(forms[i], formbools[f + i + 0*FormLen*8]); CLB_FormsSeen.Items.Add(forms[i], formbools[f + i + (0 *FormLen*8)]);
for (int i = 0; i < forms.Length; i++) // Seen Shiny for (int i = 0; i < forms.Length; i++) // Seen Shiny
CLB_FormsSeen.Items.Add($"* {forms[i]}", formbools[f + i + 1*FormLen*8]); CLB_FormsSeen.Items.Add($"* {forms[i]}", formbools[f + i + (1 *FormLen*8)]);
for (int i = 0; i < forms.Length; i++) // Displayed for (int i = 0; i < forms.Length; i++) // Displayed
CLB_FormDisplayed.Items.Add(forms[i], formbools[f + i + 2*FormLen*8]); CLB_FormDisplayed.Items.Add(forms[i], formbools[f + i + (2 *FormLen*8)]);
for (int i = 0; i < forms.Length; i++) // Displayed Shiny for (int i = 0; i < forms.Length; i++) // Displayed Shiny
CLB_FormDisplayed.Items.Add($"* {forms[i]}", formbools[f + i + 3*FormLen*8]); CLB_FormDisplayed.Items.Add($"* {forms[i]}", formbools[f + i + (3 *FormLen*8)]);
} }
private void SetEntry() private void SetEntry()
{ {
if (species < 0) if (species < 0)
@ -177,15 +184,15 @@ namespace PKHeX.WinForms
return; return;
for (int i = 0; i < CLB_FormsSeen.Items.Count/2; i++) // Seen for (int i = 0; i < CLB_FormsSeen.Items.Count/2; i++) // Seen
formbools[f + i + 0*FormLen*8] = CLB_FormsSeen.GetItemChecked(i); formbools[f + i + (0 *FormLen*8)] = CLB_FormsSeen.GetItemChecked(i);
for (int i = 0; i < CLB_FormsSeen.Items.Count/2; i++) // Seen Shiny for (int i = 0; i < CLB_FormsSeen.Items.Count/2; i++) // Seen Shiny
formbools[f + i + 1*FormLen*8] = CLB_FormsSeen.GetItemChecked(i + CLB_FormsSeen.Items.Count/2); formbools[f + i + (1 *FormLen*8)] = CLB_FormsSeen.GetItemChecked(i + (CLB_FormsSeen.Items.Count/2));
editing = true; editing = true;
for (int i = 0; i < CLB_FormDisplayed.Items.Count/2; i++) // Displayed for (int i = 0; i < CLB_FormDisplayed.Items.Count/2; i++) // Displayed
formbools[f + i + 2*FormLen*8] = CLB_FormDisplayed.GetItemChecked(i); formbools[f + i + (2 *FormLen*8)] = CLB_FormDisplayed.GetItemChecked(i);
for (int i = 0; i < CLB_FormDisplayed.Items.Count/2; i++) // Displayed Shiny for (int i = 0; i < CLB_FormDisplayed.Items.Count/2; i++) // Displayed Shiny
formbools[f + i + 3*FormLen*8] = CLB_FormDisplayed.GetItemChecked(i + CLB_FormDisplayed.Items.Count/2); formbools[f + i + (3 *FormLen*8)] = CLB_FormDisplayed.GetItemChecked(i + (CLB_FormDisplayed.Items.Count/2));
editing = false; editing = false;
} }
@ -195,7 +202,7 @@ namespace PKHeX.WinForms
for (int i = 0; i < 9; i++) for (int i = 0; i < 9; i++)
{ {
byte[] data = new byte[0x60]; byte[] data = new byte[0x60];
Array.Copy(SAV.Data, SAV.PokeDex + 8 + 0x60 * i, data, 0, 0x60); Array.Copy(SAV.Data, SAV.PokeDex + 8 + (0x60 * i), data, 0, 0x60);
BitArray BitRegion = new BitArray(data); BitArray BitRegion = new BitArray(data);
for (int b = 0; b < 0x60 * 8; b++) for (int b = 0; b < 0x60 * 8; b++)
specbools[i, b] = BitRegion[b]; specbools[i, b] = BitRegion[b];
@ -206,8 +213,10 @@ namespace PKHeX.WinForms
Array.Copy(SAV.Data, SAV.PokeDexLanguageFlags, langdata, 0, 0x280); Array.Copy(SAV.Data, SAV.PokeDexLanguageFlags, langdata, 0, 0x280);
BitArray LangRegion = new BitArray(langdata); BitArray LangRegion = new BitArray(langdata);
for (int b = 0; b < 721; b++) // 721 Species for (int b = 0; b < 721; b++) // 721 Species
{
for (int i = 0; i < 7; i++) // 7 Languages for (int i = 0; i < 7; i++) // 7 Languages
langbools[i, b] = LangRegion[7 * b + i]; langbools[i, b] = LangRegion[(7 * b) + i];
}
// Fill Foreign array // Fill Foreign array
byte[] foreigndata = new byte[0x52]; byte[] foreigndata = new byte[0x52];
@ -220,6 +229,7 @@ namespace PKHeX.WinForms
Array.Copy(SAV.Data, SAV.PokeDex + 0x368, formdata, 0, formdata.Length); Array.Copy(SAV.Data, SAV.PokeDex + 0x368, formdata, 0, formdata.Length);
formbools = new BitArray(formdata); formbools = new BitArray(formdata);
} }
private void SetData() private void SetData()
{ {
// Save back the Species Bools // Save back the Species Bools
@ -229,25 +239,31 @@ namespace PKHeX.WinForms
byte[] sdata = new byte[0x60]; byte[] sdata = new byte[0x60];
for (int i = 0; i < 0x60 * 8; i++) for (int i = 0; i < 0x60 * 8; i++)
{
if (specbools[p, i]) if (specbools[p, i])
sdata[i / 8] |= (byte)(1 << i % 8); sdata[i / 8] |= (byte)(1 << i % 8);
}
sdata.CopyTo(SAV.Data, SAV.PokeDex + 8 + 0x60 * p); sdata.CopyTo(SAV.Data, SAV.PokeDex + 8 + (0x60 * p));
} }
// Build new bool array for the Languages // Build new bool array for the Languages
{ {
bool[] languagedata = new bool[0x280 * 8]; bool[] languagedata = new bool[0x280 * 8];
for (int i = 0; i < 731; i++) for (int i = 0; i < 731; i++)
{
for (int l = 0; l < 7; l++) for (int l = 0; l < 7; l++)
languagedata[i * 7 + l] = langbools[l, i]; languagedata[(i * 7) + l] = langbools[l, i];
}
// Return to Byte Array // Return to Byte Array
byte[] ldata = new byte[languagedata.Length / 8]; byte[] ldata = new byte[languagedata.Length / 8];
for (int i = 0; i < languagedata.Length; i++) for (int i = 0; i < languagedata.Length; i++)
{
if (languagedata[i]) if (languagedata[i])
ldata[i / 8] |= (byte)(1 << i % 8); ldata[i / 8] |= (byte)(1 << i % 8);
}
ldata.CopyTo(SAV.Data, SAV.PokeDexLanguageFlags); ldata.CopyTo(SAV.Data, SAV.PokeDexLanguageFlags);
} }
@ -258,8 +274,11 @@ namespace PKHeX.WinForms
{ {
byte[] foreigndata = new byte[0x52]; byte[] foreigndata = new byte[0x52];
for (int i = 0; i < 0x52 * 8; i++) for (int i = 0; i < 0x52 * 8; i++)
{
if (foreignbools[i]) if (foreignbools[i])
foreigndata[i / 8] |= (byte)(1 << i % 8); foreigndata[i / 8] |= (byte)(1 << i % 8);
}
foreigndata.CopyTo(SAV.Data, SAV.PokeDex + 0x64C); foreigndata.CopyTo(SAV.Data, SAV.PokeDex + 0x64C);
} }
@ -272,6 +291,7 @@ namespace PKHeX.WinForms
{ {
Close(); Close();
} }
private void B_Save_Click(object sender, EventArgs e) private void B_Save_Click(object sender, EventArgs e)
{ {
SetEntry(); SetEntry();
@ -309,16 +329,22 @@ namespace PKHeX.WinForms
CHK_P3.Checked = CHK_P5.Checked = gt != 0 && gt != 255 && ModifierKeys != Keys.Control; CHK_P3.Checked = CHK_P5.Checked = gt != 0 && gt != 255 && ModifierKeys != Keys.Control;
if (ModifierKeys == Keys.Control) if (ModifierKeys == Keys.Control)
{
foreach (var chk in new[] { CHK_P6, CHK_P7, CHK_P8, CHK_P9 }) foreach (var chk in new[] { CHK_P6, CHK_P7, CHK_P8, CHK_P9 })
chk.Checked = false; chk.Checked = false;
}
else if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked)) else if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked))
{
(gt != 254 ? CHK_P6 : CHK_P7).Checked = true; (gt != 254 ? CHK_P6 : CHK_P7).Checked = true;
}
} }
private void B_Modify_Click(object sender, EventArgs e) private void B_Modify_Click(object sender, EventArgs e)
{ {
Button btn = (Button)sender; Button btn = (Button)sender;
modifyMenu.Show(btn.PointToScreen(new Point(0, btn.Height))); modifyMenu.Show(btn.PointToScreen(new Point(0, btn.Height)));
} }
private void ModifyAll(object sender, EventArgs e) private void ModifyAll(object sender, EventArgs e)
{ {
int lang = SAV.Language; int lang = SAV.Language;
@ -326,6 +352,7 @@ namespace PKHeX.WinForms
lang--; lang--;
if (sender == mnuSeenNone || sender == mnuSeenAll || sender == mnuComplete) if (sender == mnuSeenNone || sender == mnuSeenAll || sender == mnuComplete)
{
for (int i = 0; i < LB_Species.Items.Count; i++) for (int i = 0; i < LB_Species.Items.Count; i++)
{ {
int gt = SAV.Personal[i + 1].Gender; int gt = SAV.Personal[i + 1].Gender;
@ -346,11 +373,15 @@ namespace PKHeX.WinForms
} }
if (!CHK_P1.Checked && !CHK_F1.Checked) if (!CHK_P1.Checked && !CHK_F1.Checked)
{
foreach (CheckBox t in CL) foreach (CheckBox t in CL)
t.Checked = false; t.Checked = false;
}
} }
}
if (sender == mnuCaughtNone || sender == mnuCaughtAll || sender == mnuComplete) if (sender == mnuCaughtNone || sender == mnuCaughtAll || sender == mnuComplete)
{
for (int i = 0; i < CB_Species.Items.Count; i++) for (int i = 0; i < CB_Species.Items.Count; i++)
{ {
int gt = SAV.Personal[i + 1].Gender; int gt = SAV.Personal[i + 1].Gender;
@ -363,8 +394,10 @@ namespace PKHeX.WinForms
if (mnuCaughtNone == sender) if (mnuCaughtNone == sender)
{ {
if (!(CHK_P2.Checked || CHK_P3.Checked || CHK_P4.Checked || CHK_P5.Checked)) // if seen if (!(CHK_P2.Checked || CHK_P3.Checked || CHK_P4.Checked || CHK_P5.Checked)) // if seen
{
if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked)) // not displayed if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked)) // not displayed
(gt != 254 ? CHK_P6 : CHK_P7).Checked = true; // check one (gt != 254 ? CHK_P6 : CHK_P7).Checked = true; // check one
}
} }
if (mnuCaughtNone != sender) if (mnuCaughtNone != sender)
{ {
@ -385,6 +418,7 @@ namespace PKHeX.WinForms
(gt != 254 ? CHK_P6 : CHK_P7).Checked = true; (gt != 254 ? CHK_P6 : CHK_P7).Checked = true;
} }
} }
}
SetEntry(); SetEntry();
SetData(); SetData();
@ -403,16 +437,20 @@ namespace PKHeX.WinForms
// Only allow one form to be displayed if the user sets a new display value // Only allow one form to be displayed if the user sets a new display value
if (e.NewValue != CheckState.Checked) return; if (e.NewValue != CheckState.Checked) return;
for (int i = 0; i < CLB_FormDisplayed.Items.Count; i++) for (int i = 0; i < CLB_FormDisplayed.Items.Count; i++)
{
if (i != e.Index) if (i != e.Index)
CLB_FormDisplayed.SetItemChecked(i, false); CLB_FormDisplayed.SetItemChecked(i, false);
else if (sender == CLB_FormDisplayed) else if (sender == CLB_FormDisplayed)
CLB_FormsSeen.SetItemChecked(e.Index, true); // ensure this form is seen CLB_FormsSeen.SetItemChecked(e.Index, true); // ensure this form is seen
}
} }
private void B_ModifyForms_Click(object sender, EventArgs e) private void B_ModifyForms_Click(object sender, EventArgs e)
{ {
Button btn = (Button)sender; Button btn = (Button)sender;
modifyMenuForms.Show(btn.PointToScreen(new Point(0, btn.Height))); modifyMenuForms.Show(btn.PointToScreen(new Point(0, btn.Height)));
} }
private void ModifyAllForms(object sender, EventArgs e) private void ModifyAllForms(object sender, EventArgs e)
{ {
if (sender == mnuFormNone) if (sender == mnuFormNone)

View file

@ -9,6 +9,7 @@ namespace PKHeX.WinForms
{ {
private readonly SaveFile Origin; private readonly SaveFile Origin;
private readonly SAV6 SAV; private readonly SAV6 SAV;
public SAV_Pokepuff(SaveFile sav) public SAV_Pokepuff(SaveFile sav)
{ {
InitializeComponent(); InitializeComponent();
@ -23,6 +24,7 @@ namespace PKHeX.WinForms
private readonly string[] pfa = GameInfo.Strings.puffs; private readonly string[] pfa = GameInfo.Strings.puffs;
private int PuffCount { get; set; } private int PuffCount { get; set; }
private void Setup() private void Setup()
{ {
dgv.Rows.Clear(); dgv.Rows.Clear();
@ -78,24 +80,28 @@ namespace PKHeX.WinForms
{ {
Close(); Close();
} }
private void B_All_Click(object sender, EventArgs e) private void B_All_Click(object sender, EventArgs e)
{ {
int[] plus10 = {21, 22}; int[] plus10 = {21, 22};
byte[] newpuffs = new byte[PuffCount]; byte[] newpuffs = new byte[PuffCount];
if (ModifierKeys == Keys.Control) if (ModifierKeys == Keys.Control)
{
for (int i = 0; i < PuffCount; i++) for (int i = 0; i < PuffCount; i++)
newpuffs[i] = (byte)plus10[Util.Rand.Next(2)]; newpuffs[i] = (byte)plus10[Util.Rand.Next(2)];
}
else else
{ {
for (int i = 0; i < PuffCount; i++) for (int i = 0; i < PuffCount; i++)
newpuffs[i] = (byte)(i % (pfa.Length - 1) + 1); newpuffs[i] = (byte)((i % (pfa.Length - 1)) + 1);
Util.Shuffle(newpuffs); Util.Shuffle(newpuffs);
} }
Array.Copy(newpuffs, 0, SAV.Data, SAV.Puff, PuffCount); Array.Copy(newpuffs, 0, SAV.Data, SAV.Puff, PuffCount);
Setup(); Setup();
} }
private void B_None_Click(object sender, EventArgs e) private void B_None_Click(object sender, EventArgs e)
{ {
byte[] newpuffs = new byte[PuffCount]; byte[] newpuffs = new byte[PuffCount];
@ -107,6 +113,7 @@ namespace PKHeX.WinForms
Array.Copy(newpuffs, 0, SAV.Data, SAV.Puff, PuffCount); Array.Copy(newpuffs, 0, SAV.Data, SAV.Puff, PuffCount);
Setup(); Setup();
} }
private void B_Sort_Click(object sender, EventArgs e) private void B_Sort_Click(object sender, EventArgs e)
{ {
var puffs = GetPuffs(false); var puffs = GetPuffs(false);
@ -132,6 +139,7 @@ namespace PKHeX.WinForms
Array.Resize(ref arr, PuffCount); Array.Resize(ref arr, PuffCount);
return arr; return arr;
} }
private void B_Save_Click(object sender, EventArgs e) private void B_Save_Click(object sender, EventArgs e)
{ {
SAV.Puffs = GetPuffs(); SAV.Puffs = GetPuffs();

View file

@ -1,5 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
@ -11,6 +10,7 @@ namespace PKHeX.WinForms
{ {
private readonly SaveFile Origin; private readonly SaveFile Origin;
private readonly SAV6 SAV; private readonly SAV6 SAV;
public SAV_SecretBase(SaveFile sav) public SAV_SecretBase(SaveFile sav)
{ {
InitializeComponent(); InitializeComponent();
@ -68,12 +68,13 @@ namespace PKHeX.WinForms
LB_Favorite.Items.Add($"* {OT}"); LB_Favorite.Items.Add($"* {OT}");
for (int i = 0; i < 30; i++) for (int i = 0; i < 30; i++)
{ {
string BaseTrainer = Util.TrimFromZero(Encoding.Unicode.GetString(SAV.Data, favoff + i * 0x3E0 + 0x218, 0x1A)); string BaseTrainer = Util.TrimFromZero(Encoding.Unicode.GetString(SAV.Data, favoff + (i * 0x3E0) + 0x218, 0x1A));
if (BaseTrainer.Length < 1 || BaseTrainer[0] == '\0') if (BaseTrainer.Length < 1 || BaseTrainer[0] == '\0')
BaseTrainer = "Empty"; BaseTrainer = "Empty";
LB_Favorite.Items.Add($"{i} {BaseTrainer}"); LB_Favorite.Items.Add($"{i} {BaseTrainer}");
} }
} }
private void B_SAV2FAV(object sender, EventArgs e) private void B_SAV2FAV(object sender, EventArgs e)
{ {
loading = true; loading = true;
@ -88,24 +89,26 @@ namespace PKHeX.WinForms
string TrainerName = Util.TrimFromZero(Encoding.Unicode.GetString(SAV.Data, offset + 0x218, 0x1A)); string TrainerName = Util.TrimFromZero(Encoding.Unicode.GetString(SAV.Data, offset + 0x218, 0x1A));
TB_FOT.Text = TrainerName; TB_FOT.Text = TrainerName;
TB_FT1.Text = Util.TrimFromZero(Encoding.Unicode.GetString(SAV.Data, offset + 0x232 + 0x22 * 0, 0x22)); TB_FT1.Text = Util.TrimFromZero(Encoding.Unicode.GetString(SAV.Data, offset + 0x232 + (0x22 * 0), 0x22));
TB_FT2.Text = Util.TrimFromZero(Encoding.Unicode.GetString(SAV.Data, offset + 0x232 + 0x22 * 1, 0x22)); TB_FT2.Text = Util.TrimFromZero(Encoding.Unicode.GetString(SAV.Data, offset + 0x232 + (0x22 * 1), 0x22));
string saying1 = Util.TrimFromZero(Encoding.Unicode.GetString(SAV.Data, offset + 0x276 + 0x22 * 0, 0x22)); string saying1 = Util.TrimFromZero(Encoding.Unicode.GetString(SAV.Data, offset + 0x276 + (0x22 * 0), 0x22));
string saying2 = Util.TrimFromZero(Encoding.Unicode.GetString(SAV.Data, offset + 0x276 + 0x22 * 1, 0x22)); string saying2 = Util.TrimFromZero(Encoding.Unicode.GetString(SAV.Data, offset + 0x276 + (0x22 * 1), 0x22));
string saying3 = Util.TrimFromZero(Encoding.Unicode.GetString(SAV.Data, offset + 0x276 + 0x22 * 2, 0x22)); string saying3 = Util.TrimFromZero(Encoding.Unicode.GetString(SAV.Data, offset + 0x276 + (0x22 * 2), 0x22));
string saying4 = Util.TrimFromZero(Encoding.Unicode.GetString(SAV.Data, offset + 0x276 + 0x22 * 3, 0x22)); string saying4 = Util.TrimFromZero(Encoding.Unicode.GetString(SAV.Data, offset + 0x276 + (0x22 * 3), 0x22));
int baseloc = BitConverter.ToInt16(SAV.Data, offset); NUD_FBaseLocation.Value = BitConverter.ToInt16(SAV.Data, offset);
NUD_FBaseLocation.Value = baseloc;
TB_FSay1.Text = saying1; TB_FSay2.Text = saying2; TB_FSay3.Text = saying3; TB_FSay4.Text = saying4; TB_FSay1.Text = saying1; TB_FSay2.Text = saying2; TB_FSay3.Text = saying3; TB_FSay4.Text = saying4;
// Gather data for Object Array // Gather data for Object Array
objdata = new byte[25, 12]; objdata = new byte[25, 12];
for (int i = 0; i < 25; i++) for (int i = 0; i < 25; i++)
{
for (int z = 0; z < 12; z++) for (int z = 0; z < 12; z++)
objdata[i, z] = SAV.Data[offset + 2 + 12 * i + z]; objdata[i, z] = SAV.Data[offset + 2 + (12 * i) + z];
}
NUD_FObject.Value = 1; // Trigger Update NUD_FObject.Value = 1; // Trigger Update
ChangeObjectIndex(null, null); ChangeObjectIndex(null, null);
@ -114,17 +117,23 @@ namespace PKHeX.WinForms
// Trainer Pokemon // Trainer Pokemon
pkmdata = new byte[3, 0x34]; pkmdata = new byte[3, 0x34];
if (index > 0) if (index > 0)
{
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
{
for (int z = 0; z < 0x34; z++) for (int z = 0; z < 0x34; z++)
pkmdata[i, z] = SAV.Data[offset + 0x32E + 0x34 * i + z]; pkmdata[i, z] = SAV.Data[offset + 0x32E + (0x34 * i) + z];
}
}
NUD_FPKM.Value = 1; NUD_FPKM.Value = 1;
ChangeFavPKM(null, null); // Trigger Update ChangeFavPKM(null, null); // Trigger Update
loading = false; loading = false;
} }
private byte[,] objdata; private byte[,] objdata;
private byte[,] pkmdata; private byte[,] pkmdata;
private void B_FAV2SAV(object sender, EventArgs e) private void B_FAV2SAV(object sender, EventArgs e)
{ {
// Write data back to save // Write data back to save
@ -152,22 +161,22 @@ namespace PKHeX.WinForms
string team1 = TB_FT1.Text; string team1 = TB_FT1.Text;
string team2 = TB_FT2.Text; string team2 = TB_FT2.Text;
byte[] t1 = Encoding.Unicode.GetBytes(team1); byte[] t1 = Encoding.Unicode.GetBytes(team1);
Array.Resize(ref t1, 0x22); Array.Copy(t1, 0, SAV.Data, offset + 0x232 + 0x22 * 0, 0x22); Array.Resize(ref t1, 0x22); Array.Copy(t1, 0, SAV.Data, offset + 0x232 + (0x22 * 0), 0x22);
byte[] t2 = Encoding.Unicode.GetBytes(team2); byte[] t2 = Encoding.Unicode.GetBytes(team2);
Array.Resize(ref t2, 0x22); Array.Copy(t2, 0, SAV.Data, offset + 0x232 + 0x22 * 1, 0x22); Array.Resize(ref t2, 0x22); Array.Copy(t2, 0, SAV.Data, offset + 0x232 + (0x22 * 1), 0x22);
string saying1 = TB_FSay1.Text; string saying1 = TB_FSay1.Text;
string saying2 = TB_FSay2.Text; string saying2 = TB_FSay2.Text;
string saying3 = TB_FSay3.Text; string saying3 = TB_FSay3.Text;
string saying4 = TB_FSay4.Text; string saying4 = TB_FSay4.Text;
byte[] s1 = Encoding.Unicode.GetBytes(saying1); byte[] s1 = Encoding.Unicode.GetBytes(saying1);
Array.Resize(ref s1, 0x22); Array.Copy(s1, 0, SAV.Data, offset + 0x276 + 0x22 * 0, 0x22); Array.Resize(ref s1, 0x22); Array.Copy(s1, 0, SAV.Data, offset + 0x276 + (0x22 * 0), 0x22);
byte[] s2 = Encoding.Unicode.GetBytes(saying2); byte[] s2 = Encoding.Unicode.GetBytes(saying2);
Array.Resize(ref s2, 0x22); Array.Copy(s2, 0, SAV.Data, offset + 0x276 + 0x22 * 1, 0x22); Array.Resize(ref s2, 0x22); Array.Copy(s2, 0, SAV.Data, offset + 0x276 + (0x22 * 1), 0x22);
byte[] s3 = Encoding.Unicode.GetBytes(saying3); byte[] s3 = Encoding.Unicode.GetBytes(saying3);
Array.Resize(ref s3, 0x22); Array.Copy(s3, 0, SAV.Data, offset + 0x276 + 0x22 * 2, 0x22); Array.Resize(ref s3, 0x22); Array.Copy(s3, 0, SAV.Data, offset + 0x276 + (0x22 * 2), 0x22);
byte[] s4 = Encoding.Unicode.GetBytes(saying4); byte[] s4 = Encoding.Unicode.GetBytes(saying4);
Array.Resize(ref s4, 0x22); Array.Copy(s4, 0, SAV.Data, offset + 0x276 + 0x22 * 3, 0x22); Array.Resize(ref s4, 0x22); Array.Copy(s4, 0, SAV.Data, offset + 0x276 + (0x22 * 3), 0x22);
int baseloc = (int)NUD_FBaseLocation.Value; int baseloc = (int)NUD_FBaseLocation.Value;
if (baseloc < 3) baseloc = 0; // skip 1/2 baselocs as they are dummied out ingame. if (baseloc < 3) baseloc = 0; // skip 1/2 baselocs as they are dummied out ingame.
@ -177,15 +186,19 @@ namespace PKHeX.WinForms
// Copy back Objects // Copy back Objects
for (int i = 0; i < 25; i++) for (int i = 0; i < 25; i++)
{
for (int z = 0; z < 12; z++) for (int z = 0; z < 12; z++)
SAV.Data[offset + 2 + 12 * i + z] = objdata[i, z]; SAV.Data[offset + 2 + (12 * i) + z] = objdata[i, z];
}
if (GB_PKM.Enabled) // Copy pkm data back in if (GB_PKM.Enabled) // Copy pkm data back in
{ {
SaveFavPKM(); SaveFavPKM();
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
{
for (int z = 0; z < 0x34; z++) for (int z = 0; z < 0x34; z++)
SAV.Data[offset + 0x32E + 0x34 * i + z] = pkmdata[i, z]; SAV.Data[offset + 0x32E + (0x34 * i) + z] = pkmdata[i, z];
}
} }
PopFavorite(); PopFavorite();
LB_Favorite.SelectedIndex = index; LB_Favorite.SelectedIndex = index;
@ -196,6 +209,7 @@ namespace PKHeX.WinForms
{ {
Close(); Close();
} }
private void B_Save_Click(object sender, EventArgs e) private void B_Save_Click(object sender, EventArgs e)
{ {
uint flags = Util.ToUInt32(MT_Flags.Text); uint flags = Util.ToUInt32(MT_Flags.Text);
@ -204,6 +218,7 @@ namespace PKHeX.WinForms
Origin.SetData(SAV.Data, 0); Origin.SetData(SAV.Data, 0);
Close(); Close();
} }
private void B_GiveDecor_Click(object sender, EventArgs e) private void B_GiveDecor_Click(object sender, EventArgs e)
{ {
for (int i = 0; i < 173; i++) for (int i = 0; i < 173; i++)
@ -211,8 +226,8 @@ namespace PKHeX.WinForms
// int qty = BitConverter.ToUInt16(sav, offset + i * 4); // int qty = BitConverter.ToUInt16(sav, offset + i * 4);
// int has = BitConverter.ToUInt16(sav, offset + i * 4 + 2); // int has = BitConverter.ToUInt16(sav, offset + i * 4 + 2);
SAV.Data[SAV.SecretBase + i * 4] = 25; SAV.Data[SAV.SecretBase + (i * 4)] = 25;
SAV.Data[SAV.SecretBase + i * 4 + 2] = 1; SAV.Data[SAV.SecretBase + (i * 4) + 2] = 1;
} }
} }
@ -241,6 +256,7 @@ namespace PKHeX.WinForms
editing = false; editing = false;
} }
private void ChangeObjectQuality(object sender, EventArgs e) private void ChangeObjectQuality(object sender, EventArgs e)
{ {
if (editing) return; if (editing) return;
@ -259,6 +275,7 @@ namespace PKHeX.WinForms
} }
private int currentpkm; private int currentpkm;
private void ChangeFavPKM(object sender, EventArgs e) private void ChangeFavPKM(object sender, EventArgs e)
{ {
int index = (int)NUD_FPKM.Value; int index = (int)NUD_FPKM.Value;
@ -266,6 +283,7 @@ namespace PKHeX.WinForms
currentpkm = index; currentpkm = index;
LoadFavPKM(); LoadFavPKM();
} }
private void SaveFavPKM() private void SaveFavPKM()
{ {
if (loading || !GB_PKM.Enabled) return; if (loading || !GB_PKM.Enabled) return;
@ -317,6 +335,7 @@ namespace PKHeX.WinForms
for (int i = 0; i < 0x34; i++) // Copy data back to storage. for (int i = 0; i < 0x34; i++) // Copy data back to storage.
pkmdata[index - 1, i] = pkm[i]; pkmdata[index - 1, i] = pkm[i];
} }
private void LoadFavPKM() private void LoadFavPKM()
{ {
int index = currentpkm - 1; int index = currentpkm - 1;
@ -454,6 +473,7 @@ namespace PKHeX.WinForms
SetGenderLabel(); SetGenderLabel();
SetAbilityList(); SetAbilityList();
} }
private void UpdateForm(object sender, EventArgs e) private void UpdateForm(object sender, EventArgs e)
{ {
SetAbilityList(); SetAbilityList();
@ -464,6 +484,7 @@ namespace PKHeX.WinForms
} }
private int genderflag; private int genderflag;
private void Label_Gender_Click(object sender, EventArgs e) private void Label_Gender_Click(object sender, EventArgs e)
{ {
// Get Gender Threshold // Get Gender Threshold
@ -475,6 +496,7 @@ namespace PKHeX.WinForms
if (gt < 256) // If not a single gender(less) species: if (gt < 256) // If not a single gender(less) species:
Label_Gender.Text = Main.GenderSymbols[PKX.GetGenderFromString(Label_Gender.Text) ^ 1]; Label_Gender.Text = Main.GenderSymbols[PKX.GetGenderFromString(Label_Gender.Text) ^ 1];
} }
private void SetGenderLabel() private void SetGenderLabel()
{ {
Label_Gender.Text = Main.GenderSymbols[genderflag]; Label_Gender.Text = Main.GenderSymbols[genderflag];
@ -486,7 +508,7 @@ namespace PKHeX.WinForms
int index = LB_Favorite.SelectedIndex - 1; int index = LB_Favorite.SelectedIndex - 1;
int favoff = SAV.SecretBase + 0x63A; int favoff = SAV.SecretBase + 0x63A;
string BaseTrainer = Util.TrimFromZero(Encoding.Unicode.GetString(SAV.Data, favoff + index * 0x3E0 + 0x218, 0x1A)); string BaseTrainer = Util.TrimFromZero(Encoding.Unicode.GetString(SAV.Data, favoff + (index * 0x3E0) + 0x218, 0x1A));
if (string.IsNullOrEmpty(BaseTrainer)) if (string.IsNullOrEmpty(BaseTrainer))
BaseTrainer = "Empty"; BaseTrainer = "Empty";
@ -495,7 +517,7 @@ namespace PKHeX.WinForms
const int max = 29; const int max = 29;
const int size = 0x3E0; const int size = 0x3E0;
int offset = favoff + index * size; int offset = favoff + (index * size);
if (index != max) Array.Copy(SAV.Data, offset + size, SAV.Data, offset, size * (max - index)); if (index != max) Array.Copy(SAV.Data, offset + size, SAV.Data, offset, size * (max - index));
// Ensure Last Entry is Cleared // Ensure Last Entry is Cleared
Array.Copy(new byte[size], 0, SAV.Data, size * max, size); Array.Copy(new byte[size], 0, SAV.Data, size * max, size);

View file

@ -9,6 +9,7 @@ namespace PKHeX.WinForms
{ {
private readonly SaveFile Origin; private readonly SaveFile Origin;
private readonly SAV6 SAV; private readonly SAV6 SAV;
public SAV_SuperTrain(SaveFile sav) public SAV_SuperTrain(SaveFile sav)
{ {
InitializeComponent(); InitializeComponent();
@ -31,6 +32,7 @@ namespace PKHeX.WinForms
private readonly int offsetVal; private readonly int offsetVal;
private readonly int offsetTime; private readonly int offsetTime;
private readonly int offsetSpec; private readonly int offsetSpec;
private void Setup() private void Setup()
{ {
dataGridView1.Rows.Clear(); dataGridView1.Rows.Clear();
@ -45,10 +47,11 @@ namespace PKHeX.WinForms
listBox1.SelectedIndex = 0; listBox1.SelectedIndex = 0;
FillTrainingBags(); FillTrainingBags();
CB_S2.SelectedValue = (int)BitConverter.ToUInt16(SAV.Data, offsetSpec + 4 * 30); CB_S2.SelectedValue = (int)BitConverter.ToUInt16(SAV.Data, offsetSpec + (4 * 30));
TB_Time1.Text = BitConverter.ToSingle(SAV.Data, offsetTime + 4 * 30).ToString(); TB_Time1.Text = BitConverter.ToSingle(SAV.Data, offsetTime + (4 * 30)).ToString();
TB_Time2.Text = BitConverter.ToSingle(SAV.Data, offsetTime + 4 * 31).ToString(); TB_Time2.Text = BitConverter.ToSingle(SAV.Data, offsetTime + (4 * 31)).ToString();
} }
private void FillTrainingBags() private void FillTrainingBags()
{ {
DataGridViewColumn dgvIndex = new DataGridViewTextBoxColumn(); DataGridViewColumn dgvIndex = new DataGridViewTextBoxColumn();
@ -65,8 +68,10 @@ namespace PKHeX.WinForms
}; };
{ {
foreach (string t in trba) foreach (string t in trba)
{
if (t.Length > 0) if (t.Length > 0)
dgvBag.Items.Add(t); dgvBag.Items.Add(t);
}
dgvBag.DisplayIndex = 1; dgvBag.DisplayIndex = 1;
dgvBag.Width = 135; dgvBag.Width = 135;
@ -83,6 +88,7 @@ namespace PKHeX.WinForms
dataGridView1.Rows[i].Cells[1].Value = trba[SAV.Data[offset + i]]; dataGridView1.Rows[i].Cells[1].Value = trba[SAV.Data[offset + i]];
} }
} }
private void DropClick(object sender, DataGridViewCellEventArgs e) private void DropClick(object sender, DataGridViewCellEventArgs e)
{ {
try try
@ -95,16 +101,18 @@ namespace PKHeX.WinForms
} }
private bool loading = true; private bool loading = true;
private void ChangeListRecordSelection(object sender, EventArgs e) private void ChangeListRecordSelection(object sender, EventArgs e)
{ {
int index = listBox1.SelectedIndex; int index = listBox1.SelectedIndex;
if (index < 0) return; if (index < 0) return;
loading = true; loading = true;
TB_Time.Text = BitConverter.ToSingle(SAV.Data, offsetTime + 4 * index).ToString(); TB_Time.Text = BitConverter.ToSingle(SAV.Data, offsetTime + (4 * index)).ToString();
TB_Unk.Text = BitConverter.ToUInt16(SAV.Data, offsetVal + 4 * index).ToString(); TB_Unk.Text = BitConverter.ToUInt16(SAV.Data, offsetVal + (4 * index)).ToString();
CB_Species.SelectedValue = (int)BitConverter.ToUInt16(SAV.Data, offsetSpec + 4 * index); CB_Species.SelectedValue = (int)BitConverter.ToUInt16(SAV.Data, offsetSpec + (4 * index));
loading = false; loading = false;
} }
private void B_Save_Click(object sender, EventArgs e) private void B_Save_Click(object sender, EventArgs e)
{ {
// Copy Bags // Copy Bags
@ -120,34 +128,38 @@ namespace PKHeX.WinForms
} }
bagarray[i - emptyslots] = (byte)Array.IndexOf(trba, bag); bagarray[i - emptyslots] = (byte)Array.IndexOf(trba, bag);
} }
try { BitConverter.GetBytes(float.Parse(TB_Time1.Text)).CopyTo(SAV.Data, offsetTime + 4 * 30); } catch { } try { BitConverter.GetBytes(float.Parse(TB_Time1.Text)).CopyTo(SAV.Data, offsetTime + (4 * 30)); } catch { }
try { BitConverter.GetBytes(float.Parse(TB_Time2.Text)).CopyTo(SAV.Data, offsetTime + 4 * 31); } catch { } try { BitConverter.GetBytes(float.Parse(TB_Time2.Text)).CopyTo(SAV.Data, offsetTime + (4 * 31)); } catch { }
BitConverter.GetBytes((ushort)WinFormsUtil.GetIndex(CB_S2)).CopyTo(SAV.Data, offsetSpec + 4 * 30); BitConverter.GetBytes((ushort)WinFormsUtil.GetIndex(CB_S2)).CopyTo(SAV.Data, offsetSpec + (4 * 30));
bagarray.CopyTo(SAV.Data, SAV.SuperTrain + 0x308); bagarray.CopyTo(SAV.Data, SAV.SuperTrain + 0x308);
Origin.SetData(SAV.Data, 0); Origin.SetData(SAV.Data, 0);
Close(); Close();
} }
private void B_Cancel_Click(object sender, EventArgs e) private void B_Cancel_Click(object sender, EventArgs e)
{ {
Close(); Close();
} }
private void ChangeRecordSpecies(object sender, EventArgs e) private void ChangeRecordSpecies(object sender, EventArgs e)
{ {
int index = listBox1.SelectedIndex; int index = listBox1.SelectedIndex;
if (index < 0 || loading) return; if (index < 0 || loading) return;
BitConverter.GetBytes(WinFormsUtil.GetIndex(CB_Species)).CopyTo(SAV.Data, offsetSpec + 4 * index); BitConverter.GetBytes(WinFormsUtil.GetIndex(CB_Species)).CopyTo(SAV.Data, offsetSpec + (4 * index));
} }
private void ChangeRecordVal(object sender, EventArgs e) private void ChangeRecordVal(object sender, EventArgs e)
{ {
int index = listBox1.SelectedIndex; int index = listBox1.SelectedIndex;
if (index < 0 || loading) return; if (index < 0 || loading) return;
try { BitConverter.GetBytes(ushort.Parse(TB_Unk.Text)).CopyTo(SAV.Data, offsetVal + 4 * index); } catch { } try { BitConverter.GetBytes(ushort.Parse(TB_Unk.Text)).CopyTo(SAV.Data, offsetVal + (4 * index)); } catch { }
} }
private void ChangeRecordTime(object sender, EventArgs e) private void ChangeRecordTime(object sender, EventArgs e)
{ {
int index = listBox1.SelectedIndex; int index = listBox1.SelectedIndex;
if (index < 0 || loading) return; if (index < 0 || loading) return;
try { BitConverter.GetBytes(float.Parse(TB_Time.Text)).CopyTo(SAV.Data, offsetTime + 4 * index); } catch { } try { BitConverter.GetBytes(float.Parse(TB_Time.Text)).CopyTo(SAV.Data, offsetTime + (4 * index)); } catch { }
} }
} }
} }

View file

@ -10,19 +10,22 @@ namespace PKHeX.WinForms
{ {
private readonly SaveFile Origin; private readonly SaveFile Origin;
private readonly SAV6 SAV; private readonly SAV6 SAV;
public SAV_Trainer(SaveFile sav) public SAV_Trainer(SaveFile sav)
{ {
InitializeComponent(); InitializeComponent();
WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage); WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage);
SAV = (SAV6)(Origin = sav).Clone(); SAV = (SAV6)(Origin = sav).Clone();
if (Main.Unicode) if (Main.Unicode)
{
try try
{ {
TB_OTName.Font = FontUtil.GetPKXFont(11); TB_OTName.Font = FontUtil.GetPKXFont(11);
if (SAV.XY) if (SAV.XY)
TB_TRNick.Font = TB_OTName.Font; TB_TRNick.Font = TB_OTName.Font;
} }
catch (Exception e) { WinFormsUtil.Alert("Font loading failed...", e.ToString()); } catch (Exception e) { WinFormsUtil.Alert("Font loading failed...", e.ToString()); }
}
B_MaxCash.Click += (sender, e) => MT_Money.Text = "9,999,999"; B_MaxCash.Click += (sender, e) => MT_Money.Text = "9,999,999";
@ -213,11 +216,12 @@ namespace PKHeX.WinForms
CB_Stats.Items.Clear(); CB_Stats.Items.Clear();
for (int i = 0; i < statdata.Length / 2; i++) for (int i = 0; i < statdata.Length / 2; i++)
CB_Stats.Items.Add(statdata[2 * i + 1]); CB_Stats.Items.Add(statdata[(2 * i) + 1]);
CB_Stats.SelectedIndex = 0; CB_Stats.SelectedIndex = 0;
CHK_MegaUnlocked.Checked = SAV.IsMegaEvolutionUnlocked; CHK_MegaUnlocked.Checked = SAV.IsMegaEvolutionUnlocked;
} }
private readonly string[] statdata; private readonly string[] statdata;
private bool editing; private bool editing;
private readonly ToolTip Tip1 = new ToolTip(), Tip2 = new ToolTip(); private readonly ToolTip Tip1 = new ToolTip(), Tip2 = new ToolTip();
@ -332,12 +336,14 @@ namespace PKHeX.WinForms
CB_Vivillon.InitializeBinding(); CB_Vivillon.InitializeBinding();
CB_Vivillon.DataSource = PKX.GetFormList(666, GameInfo.Strings.types, GameInfo.Strings.forms, Main.GenderSymbols, 6).ToList(); CB_Vivillon.DataSource = PKX.GetFormList(666, GameInfo.Strings.types, GameInfo.Strings.forms, Main.GenderSymbols, 6).ToList();
} }
private void GetBadges() private void GetBadges()
{ {
var bma = GetGen6BadgeSprites(SAV.ORAS); var bma = GetGen6BadgeSprites(SAV.ORAS);
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
pba[i].Image = ImageUtil.ChangeOpacity(bma[i], cba[i].Checked ? 1 : 0.1); pba[i].Image = ImageUtil.ChangeOpacity(bma[i], cba[i].Checked ? 1 : 0.1);
} }
private static Bitmap[] GetGen6BadgeSprites(bool ORAS) private static Bitmap[] GetGen6BadgeSprites(bool ORAS)
{ {
if (ORAS) if (ORAS)
@ -391,20 +397,27 @@ namespace PKHeX.WinForms
// Maison Data // Maison Data
if (SAV.MaisonStats > -1) if (SAV.MaisonStats > -1)
{
for (int i = 0; i < MaisonRecords.Length; i++) for (int i = 0; i < MaisonRecords.Length; i++)
MaisonRecords[i].Text = SAV.GetMaisonStat(i).ToString(); MaisonRecords[i].Text = SAV.GetMaisonStat(i).ToString();
}
NUD_M.Value = SAV.M; NUD_M.Value = SAV.M;
// Sanity Check Map Coordinates // Sanity Check Map Coordinates
if (!GB_Map.Enabled || SAV.X%0.5 != 0 || SAV.Z%0.5 != 0 || SAV.Y%0.5 != 0) if (!GB_Map.Enabled || SAV.X%0.5 != 0 || SAV.Z%0.5 != 0 || SAV.Y%0.5 != 0)
GB_Map.Enabled = false;
else try
{ {
NUD_X.Value = (decimal)SAV.X; GB_Map.Enabled = false;
NUD_Z.Value = (decimal)SAV.Z; }
NUD_Y.Value = (decimal)SAV.Y; else
{
try
{
NUD_X.Value = (decimal)SAV.X;
NUD_Z.Value = (decimal)SAV.Z;
NUD_Y.Value = (decimal)SAV.Y;
}
catch { GB_Map.Enabled = false; }
} }
catch { GB_Map.Enabled = false; }
// Load BP and PokeMiles // Load BP and PokeMiles
TB_BP.Text = SAV.BP.ToString(); TB_BP.Text = SAV.BP.ToString();
@ -463,6 +476,7 @@ namespace PKHeX.WinForms
CAL_HoFDate.Value = new DateTime(2000, 1, 1).AddSeconds(SAV.SecondsToFame); CAL_HoFDate.Value = new DateTime(2000, 1, 1).AddSeconds(SAV.SecondsToFame);
CAL_HoFTime.Value = new DateTime(2000, 1, 1).AddSeconds(SAV.SecondsToFame % 86400); CAL_HoFTime.Value = new DateTime(2000, 1, 1).AddSeconds(SAV.SecondsToFame % 86400);
} }
private void Save() private void Save()
{ {
SAV.Game = (byte)(CB_Game.SelectedIndex + 0x18); SAV.Game = (byte)(CB_Game.SelectedIndex + 0x18);
@ -486,8 +500,10 @@ namespace PKHeX.WinForms
// Copy Maison Data in // Copy Maison Data in
if (SAV.MaisonStats > -1) if (SAV.MaisonStats > -1)
{
for (int i = 0; i < MaisonRecords.Length; i++) for (int i = 0; i < MaisonRecords.Length; i++)
SAV.SetMaisonStat(i, ushort.Parse(MaisonRecords[i].Text)); SAV.SetMaisonStat(i, ushort.Parse(MaisonRecords[i].Text));
}
// Copy Position // Copy Position
if (GB_Map.Enabled && MapUpdated) if (GB_Map.Enabled && MapUpdated)
@ -572,6 +588,7 @@ namespace PKHeX.WinForms
d.ShowDialog(); d.ShowDialog();
tb.Text = d.FinalString; tb.Text = d.FinalString;
} }
private void ShowTSV(object sender, EventArgs e) private void ShowTSV(object sender, EventArgs e)
{ {
uint TID = Util.ToUInt32(MT_TID.Text); uint TID = Util.ToUInt32(MT_TID.Text);
@ -585,16 +602,19 @@ namespace PKHeX.WinForms
{ {
Close(); Close();
} }
private void B_Save_Click(object sender, EventArgs e) private void B_Save_Click(object sender, EventArgs e)
{ {
Save(); Save();
Origin.SetData(SAV.Data, 0); Origin.SetData(SAV.Data, 0);
Close(); Close();
} }
private void ChangeBadge(object sender, EventArgs e) private void ChangeBadge(object sender, EventArgs e)
{ {
GetBadges(); GetBadges();
} }
private void ChangeSpecial(object sender, EventArgs e) private void ChangeSpecial(object sender, EventArgs e)
{ {
MaskedTextBox box = sender as MaskedTextBox; MaskedTextBox box = sender as MaskedTextBox;
@ -605,18 +625,21 @@ namespace PKHeX.WinForms
if (box == MT_Hat) if (box == MT_Hat)
box.Text = (val > 31 ? 31 : val).ToString(); box.Text = (val > 31 ? 31 : val).ToString();
} }
private void Change255(object sender, EventArgs e) private void Change255(object sender, EventArgs e)
{ {
MaskedTextBox box = (MaskedTextBox)sender; MaskedTextBox box = (MaskedTextBox)sender;
if (box.Text.Length == 0) box.Text = "0"; if (box.Text.Length == 0) box.Text = "0";
if (Util.ToInt32(box.Text) > 255) box.Text = "255"; if (Util.ToInt32(box.Text) > 255) box.Text = "255";
} }
private void ChangeFFFF(object sender, EventArgs e) private void ChangeFFFF(object sender, EventArgs e)
{ {
MaskedTextBox box = (MaskedTextBox)sender; MaskedTextBox box = (MaskedTextBox)sender;
if (box.Text.Length == 0) box.Text = "0"; if (box.Text.Length == 0) box.Text = "0";
if (Util.ToInt32(box.Text) > 65535) box.Text = "65535"; if (Util.ToInt32(box.Text) > 65535) box.Text = "65535";
} }
private void ChangeStat(object sender, EventArgs e) private void ChangeStat(object sender, EventArgs e)
{ {
editing = true; editing = true;
@ -625,12 +648,14 @@ namespace PKHeX.WinForms
L_Offset.Text = $"0x{offset:X3}"; L_Offset.Text = $"0x{offset:X3}";
editing = false; editing = false;
} }
private void ChangeStatVal(object sender, EventArgs e) private void ChangeStatVal(object sender, EventArgs e)
{ {
if (editing) return; if (editing) return;
int offset = Convert.ToInt32(statdata[CB_Stats.SelectedIndex * 2].Substring(2), 16); int offset = Convert.ToInt32(statdata[CB_Stats.SelectedIndex * 2].Substring(2), 16);
SAV.SetPSSStat(offset/4, uint.Parse(MT_Stat.Text)); SAV.SetPSSStat(offset/4, uint.Parse(MT_Stat.Text));
} }
private void GiveAllAccessories(object sender, EventArgs e) private void GiveAllAccessories(object sender, EventArgs e)
{ {
SAV.UnlockAllAccessories(); SAV.UnlockAllAccessories();
@ -642,10 +667,12 @@ namespace PKHeX.WinForms
if (sender is ComboBox c && (index = WinFormsUtil.GetIndex(c)) > 0) if (sender is ComboBox c && (index = WinFormsUtil.GetIndex(c)) > 0)
Main.SetCountrySubRegion(CB_Region, $"sr_{index:000}"); Main.SetCountrySubRegion(CB_Region, $"sr_{index:000}");
} }
private void ToggleBadge(object sender, EventArgs e) private void ToggleBadge(object sender, EventArgs e)
{ {
cba[Array.IndexOf(pba, sender)].Checked ^= true; cba[Array.IndexOf(pba, sender)].Checked ^= true;
} }
private void ChangeMapValue(object sender, EventArgs e) private void ChangeMapValue(object sender, EventArgs e)
{ {
if (!editing) if (!editing)

View file

@ -1116,7 +1116,7 @@
this.mnuSave.Name = "mnuSave"; this.mnuSave.Name = "mnuSave";
this.mnuSave.Size = new System.Drawing.Size(122, 22); this.mnuSave.Size = new System.Drawing.Size(122, 22);
this.mnuSave.Text = "Save PKM"; this.mnuSave.Text = "Save PKM";
this.mnuSave.Click += new System.EventHandler(this.mnuSave_Click); this.mnuSave.Click += new System.EventHandler(this.MnuSave_Click);
// //
// L_Grade // L_Grade
// //

View file

@ -10,6 +10,7 @@ namespace PKHeX.WinForms
{ {
private readonly SaveFile Origin; private readonly SaveFile Origin;
private readonly SAV7 SAV; private readonly SAV7 SAV;
public SAV_FestivalPlaza(SaveFile sav) public SAV_FestivalPlaza(SaveFile sav)
{ {
InitializeComponent(); InitializeComponent();
@ -17,6 +18,7 @@ namespace PKHeX.WinForms
editing = true; editing = true;
typeMAX = SAV.USUM ? 0x7F : 0x7C; typeMAX = SAV.USUM ? 0x7F : 0x7C;
TB_PlazaName.Text = SAV.FestivalPlazaName; TB_PlazaName.Text = SAV.FestivalPlazaName;
if (SAV.USUM) if (SAV.USUM)
{ {
PBs = new[] { ppkx1, ppkx2, ppkx3 }; PBs = new[] { ppkx1, ppkx2, ppkx3 };
@ -24,10 +26,16 @@ namespace PKHeX.WinForms
LoadBattleAgency(); LoadBattleAgency();
} }
else else
{
TC_Editor.TabPages.Remove(Tab_BattleAgency); TC_Editor.TabPages.Remove(Tab_BattleAgency);
}
if (Main.Unicode) if (Main.Unicode)
{
try { TB_OTName.Font = FontUtil.GetPKXFont(11); } try { TB_OTName.Font = FontUtil.GetPKXFont(11); }
catch (Exception e) { WinFormsUtil.Alert("Font loading failed...", e.ToString()); } catch (Exception e) { WinFormsUtil.Alert("Font loading failed...", e.ToString()); }
}
uint cc = SAV.FestaCoins; uint cc = SAV.FestaCoins;
uint cu = SAV.UsedFestaCoins; uint cu = SAV.UsedFestaCoins;
NUD_FC_Current.Value = Math.Min(cc, NUD_FC_Current.Maximum); NUD_FC_Current.Value = Math.Min(cc, NUD_FC_Current.Maximum);
@ -111,13 +119,17 @@ namespace PKHeX.WinForms
new[]{"Red","Yellow","Green","Blue","Orange","NavyBlue","Purple","Pink"}, new[]{"Red","Yellow","Green","Blue","Orange","NavyBlue","Purple","Pink"},
new[]{"Switcheroo"} new[]{"Switcheroo"}
}; };
CB_FacilityType.Items.Clear(); CB_FacilityType.Items.Clear();
for (int k = 0; k < RES_FacilityLevelType.Length - (SAV.USUM ? 0 : 1); k++) //Exchange is USUM only for (int k = 0; k < RES_FacilityLevelType.Length - (SAV.USUM ? 0 : 1); k++) //Exchange is USUM only
{
for (int j = 0; j < RES_FacilityLevelType[k].Length; j++) for (int j = 0; j < RES_FacilityLevelType[k].Length; j++)
{ {
if (RES_FacilityLevelType[k][j] != 4) if (RES_FacilityLevelType[k][j] != 4)
{
for (int i = 0; i < RES_FacilityLevelType[k][j]; i++) for (int i = 0; i < RES_FacilityLevelType[k][j]; i++)
CB_FacilityType.Items.Add($"{res6[k]} {res7[k][j]} {i + 1}"); CB_FacilityType.Items.Add($"{res6[k]} {res7[k][j]} {i + 1}");
}
else else
{ {
CB_FacilityType.Items.Add($"{res6[k]} {res7[k][j]} 1"); CB_FacilityType.Items.Add($"{res6[k]} {res7[k][j]} 1");
@ -125,13 +137,17 @@ namespace PKHeX.WinForms
CB_FacilityType.Items.Add($"{res6[k]} {res7[k][j]} 5"); CB_FacilityType.Items.Add($"{res6[k]} {res7[k][j]} 5");
} }
} }
string[] res8 = { "GTS", "Wonder Trade", "Battle Spot", "Festival Plaza", "mission", "lottery shop", "haunted house" }; }
string[] res9 = { "+", "++", "+++" };
string[] types = { "GTS", "Wonder Trade", "Battle Spot", "Festival Plaza", "mission", "lottery shop", "haunted house" };
string[] lvl = { "+", "++", "+++" };
CB_LuckyResult.Items.Clear(); CB_LuckyResult.Items.Clear();
CB_LuckyResult.Items.Add("none"); CB_LuckyResult.Items.Add("none");
for (int i = 0; i < res8.Length; i++) foreach (string type in types)
for (int j = 0; j < res9.Length; j++) {
CB_LuckyResult.Items.Add($"{res9[j]} {res8[i]}"); foreach (string lv in lvl)
CB_LuckyResult.Items.Add($"{lv} {type}");
}
NUD_Rank.Value = SAV.FestaRank; NUD_Rank.Value = SAV.FestaRank;
LoadRankLabel(SAV.FestaRank); LoadRankLabel(SAV.FestaRank);
@ -146,11 +162,13 @@ namespace PKHeX.WinForms
entry = 0; entry = 0;
LoadFacility(); LoadFacility();
} }
private bool editing; private bool editing;
private readonly byte[] r = { 0, 2, 1 }; // CheckState.Indeterminate <-> CheckState.Checked private readonly byte[] r = { 0, 2, 1 }; // CheckState.Indeterminate <-> CheckState.Checked
private readonly int typeMAX; private readonly int typeMAX;
private readonly FestaFacility[] f = new FestaFacility[7]; private readonly FestaFacility[] f = new FestaFacility[7];
private readonly string[] RES_Color = { "Red", "Blue", "Gold", "Black", "Purple", "Yellow", "Brown", "Green", "Orange", "NavyBlue", "Pink", "White" }; private readonly string[] RES_Color = { "Red", "Blue", "Gold", "Black", "Purple", "Yellow", "Brown", "Green", "Orange", "NavyBlue", "Pink", "White" };
private readonly byte[][] RES_FacilityColor = //facility appearance private readonly byte[][] RES_FacilityColor = //facility appearance
{ {
new byte[]{0,1,2,3},//Lottery new byte[]{0,1,2,3},//Lottery
@ -162,6 +180,7 @@ namespace PKHeX.WinForms
new byte[]{0,7,8,4,5,1,9,10},//Dye new byte[]{0,7,8,4,5,1,9,10},//Dye
new byte[]{11,1,5,3},//Exchange new byte[]{11,1,5,3},//Exchange
}; };
private readonly byte[][] RES_FacilityLevelType = //3:123 4:135 5:12345 private readonly byte[][] RES_FacilityLevelType = //3:123 4:135 5:12345
{ {
new byte[]{5,5,5}, new byte[]{5,5,5},
@ -173,6 +192,7 @@ namespace PKHeX.WinForms
new byte[]{4,4,4,4,4,4,4,4}, new byte[]{4,4,4,4,4,4,4,4},
new byte[]{3} new byte[]{3}
}; };
private int TypeIndexToType(int typeIndex) private int TypeIndexToType(int typeIndex)
{ {
if (typeIndex < 0 || typeIndex > typeMAX) return -1; if (typeIndex < 0 || typeIndex > typeMAX) return -1;
@ -185,12 +205,14 @@ namespace PKHeX.WinForms
if (typeIndex < 0x7D) return 6; if (typeIndex < 0x7D) return 6;
return 7; return 7;
} }
private int GetColorCount(int i) => private int GetColorCount(int i) =>
i >= 0 && i < RES_FacilityColor.Length - (SAV.USUM ? 0 : 1) i >= 0 && i < RES_FacilityColor.Length - (SAV.USUM ? 0 : 1)
? RES_FacilityColor[i].Length - 1 ? RES_FacilityColor[i].Length - 1
: 3; : 3;
private int entry = -1; private int entry = -1;
private void LoadFacility() private void LoadFacility()
{ {
editing = true; editing = true;
@ -208,7 +230,7 @@ namespace PKHeX.WinForms
switch (type) switch (type)
{ {
case 5: case 5:
int lucky = facility.UsedLuckyPlace * 3 + facility.UsedLuckyRank - 3; int lucky = (facility.UsedLuckyPlace * 3) + facility.UsedLuckyRank - 3;
if (lucky < 0 || lucky >= CB_LuckyResult.Items.Count) lucky = 0; if (lucky < 0 || lucky >= CB_LuckyResult.Items.Count) lucky = 0;
CB_LuckyResult.SelectedIndex = lucky; CB_LuckyResult.SelectedIndex = lucky;
break; break;
@ -231,6 +253,7 @@ namespace PKHeX.WinForms
TB_FacilityID.Text = str; TB_FacilityID.Text = str;
editing = false; editing = false;
} }
private void Save() private void Save()
{ {
SAV.SetFestaPhraseUnlocked(106, CLB_Phrases.GetItemChecked(0)); SAV.SetFestaPhraseUnlocked(106, CLB_Phrases.GetItemChecked(0));
@ -252,6 +275,7 @@ namespace PKHeX.WinForms
if (SAV.USUM) if (SAV.USUM)
SaveBattleAgency(); SaveBattleAgency();
} }
private void LoadBattleAgency() private void LoadBattleAgency()
{ {
p[0] = SAV.GetPKM(SAV.DecryptPKM(SAV.GetData(0x6C200, 0xE8))); p[0] = SAV.GetPKM(SAV.DecryptPKM(SAV.GetData(0x6C200, 0xE8)));
@ -264,30 +288,33 @@ namespace PKHeX.WinForms
ushort valus = BitConverter.ToUInt16(SAV.GetData(0x6C55C, 2), 0); ushort valus = BitConverter.ToUInt16(SAV.GetData(0x6C55C, 2), 0);
int grade = valus >> 6 & 0x3F; int grade = valus >> 6 & 0x3F;
NUD_Grade.Value = grade; NUD_Grade.Value = grade;
int max = Math.Min(49, grade) / 10 * 3 + 2; int max = (Math.Min(49, grade) / 10 * 3) + 2;
int defeated = valus >> 12; int defeated = valus >> 12;
NUD_Defeated.Value = defeated > max ? max : defeated; NUD_Defeated.Value = defeated > max ? max : defeated;
NUD_Defeated.Maximum = max; NUD_Defeated.Maximum = max;
NUD_DefeatMon.Value = BitConverter.ToUInt16(SAV.GetData(0x6C558, 2), 0); NUD_DefeatMon.Value = BitConverter.ToUInt16(SAV.GetData(0x6C558, 2), 0);
for (int i = 0; i < NUD_Trainers.Length; i++) for (int i = 0; i < NUD_Trainers.Length; i++)
{ {
int j = GetSavData16(0x6C56C + 0x14 * i); int j = GetSavData16(0x6C56C + (0x14 * i));
var m = (int)NUD_Trainers[i].Maximum; var m = (int)NUD_Trainers[i].Maximum;
NUD_Trainers[i].Value = j < 0 || j > m ? m : j; NUD_Trainers[i].Value = j < 0 || j > m ? m : j;
} }
B_AgentGlass.Enabled = (SAV.GetData(SAV.Fashion + 0xD0, 1)[0] & 1) == 0; B_AgentGlass.Enabled = (SAV.GetData(SAV.Fashion + 0xD0, 1)[0] & 1) == 0;
} }
private void LoadPictureBox() private void LoadPictureBox()
{ {
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
PBs[i].Image = p[i].Sprite(SAV, -1, -1, flagIllegal: true); PBs[i].Image = p[i].Sprite(SAV, -1, -1, flagIllegal: true);
} }
private readonly NumericUpDown[] NUD_Trainers = new NumericUpDown[3]; private readonly NumericUpDown[] NUD_Trainers = new NumericUpDown[3];
private ushort GetSavData16(int Offset) => BitConverter.ToUInt16(SAV.GetData(Offset, 2), 0); private ushort GetSavData16(int Offset) => BitConverter.ToUInt16(SAV.GetData(Offset, 2), 0);
private readonly ushort InvitedValue = 0x7DFF; private const ushort InvitedValue = 0x7DFF;
private readonly PKM[] p = new PKM[3]; private readonly PKM[] p = new PKM[3];
private readonly PictureBox[] PBs = new PictureBox[3]; private readonly PictureBox[] PBs = new PictureBox[3];
private bool IsTrainerInvited() => (GetSavData16(0x6C3EE) & InvitedValue) == InvitedValue && (GetSavData16(0x6C526) & InvitedValue) == InvitedValue; private bool IsTrainerInvited() => (GetSavData16(0x6C3EE) & InvitedValue) == InvitedValue && (GetSavData16(0x6C526) & InvitedValue) == InvitedValue;
private void SaveBattleAgency() private void SaveBattleAgency()
{ {
SAV.SetFlag(0x6C55E, 1, CHK_Choosed.Checked); SAV.SetFlag(0x6C55E, 1, CHK_Choosed.Checked);
@ -299,12 +326,13 @@ namespace PKHeX.WinForms
SAV.SetData(p[0].EncryptedBoxData, 0x6C200); SAV.SetData(p[0].EncryptedBoxData, 0x6C200);
SAV.SetData(p[1].EncryptedPartyData, 0x6C2E8); SAV.SetData(p[1].EncryptedPartyData, 0x6C2E8);
SAV.SetData(p[2].EncryptedPartyData, 0x6C420); SAV.SetData(p[2].EncryptedPartyData, 0x6C420);
SAV.SetData(BitConverter.GetBytes((ushort)(((int)NUD_Defeated.Value & 0xF) << 12 | ((int)NUD_Grade.Value & 0x3F) << 6 | SAV.Data[0x6C55C] & 0x3F)), 0x6C55C); SAV.SetData(BitConverter.GetBytes((ushort)(((int)NUD_Defeated.Value & 0xF) << 12 | ((int)NUD_Grade.Value & 0x3F) << 6 | (SAV.Data[0x6C55C] & 0x3F))), 0x6C55C);
SAV.SetData(BitConverter.GetBytes((ushort)NUD_DefeatMon.Value), 0x6C558); SAV.SetData(BitConverter.GetBytes((ushort)NUD_DefeatMon.Value), 0x6C558);
for (int i = 0; i < NUD_Trainers.Length; i++) for (int i = 0; i < NUD_Trainers.Length; i++)
SAV.SetData(BitConverter.GetBytes((ushort)NUD_Trainers[i].Value), 0x6C56C + 0x14 * i); SAV.SetData(BitConverter.GetBytes((ushort)NUD_Trainers[i].Value), 0x6C56C + (0x14 * i));
SAV.FestivalPlazaName = TB_PlazaName.Text; SAV.FestivalPlazaName = TB_PlazaName.Text;
} }
private void NUD_FC_ValueChanged(object sender, EventArgs e) private void NUD_FC_ValueChanged(object sender, EventArgs e)
{ {
if (editing) return; if (editing) return;
@ -352,12 +380,15 @@ namespace PKHeX.WinForms
d.ShowDialog(); d.ShowDialog();
tb.Text = d.FinalString; tb.Text = d.FinalString;
} }
private readonly string[] gendersymbols = { "♂", "♀" }; private readonly string[] gendersymbols = { "♂", "♀" };
private void LoadOTlabel(int b) private void LoadOTlabel(int b)
{ {
Label_OTGender.Text = gendersymbols[b & 1]; Label_OTGender.Text = gendersymbols[b & 1];
Label_OTGender.ForeColor = b == 1 ? Color.Red : Color.Blue; Label_OTGender.ForeColor = b == 1 ? Color.Red : Color.Blue;
} }
private void Label_OTGender_Click(object sender, EventArgs e) private void Label_OTGender_Click(object sender, EventArgs e)
{ {
if (entry < 0) return; if (entry < 0) return;
@ -366,7 +397,9 @@ namespace PKHeX.WinForms
f[entry].Gender = b; f[entry].Gender = b;
LoadOTlabel(b); LoadOTlabel(b);
} }
private void LoadFMessage(int fmIndex) => NUD_FacilityMessage.Value = f[entry].GetMessage(fmIndex); private void LoadFMessage(int fmIndex) => NUD_FacilityMessage.Value = f[entry].GetMessage(fmIndex);
private void CB_FacilityMessage_SelectedIndexChanged(object sender, EventArgs e) private void CB_FacilityMessage_SelectedIndexChanged(object sender, EventArgs e)
{ {
if (editing) return; if (editing) return;
@ -404,9 +437,13 @@ namespace PKHeX.WinForms
System.Media.SystemSounds.Beep.Play(); System.Media.SystemSounds.Beep.Play();
} }
if (sender == TB_UsedFlags) if (sender == TB_UsedFlags)
{
f[entry].UsedFlags = Convert.ToUInt32(t, 16); f[entry].UsedFlags = Convert.ToUInt32(t, 16);
}
else if (sender == TB_UsedStats) else if (sender == TB_UsedStats)
{
f[entry].UsedRandStat = Convert.ToUInt32(t, 16); f[entry].UsedRandStat = Convert.ToUInt32(t, 16);
}
else if (sender == TB_FacilityID) else if (sender == TB_FacilityID)
{ {
if (t.Length != 12 * 2) if (t.Length != 12 * 2)
@ -416,7 +453,9 @@ namespace PKHeX.WinForms
f[entry].TrainerFesID = bytes; f[entry].TrainerFesID = bytes;
} }
} }
private void LoadColorLabel(int type) => L_FacilityColorV.Text = RES_Color[RES_FacilityColor[type][(int)NUD_FacilityColor.Value]]; private void LoadColorLabel(int type) => L_FacilityColorV.Text = RES_Color[RES_FacilityColor[type][(int)NUD_FacilityColor.Value]];
private void NUD_FacilityColor_ValueChanged(object sender, EventArgs e) private void NUD_FacilityColor_ValueChanged(object sender, EventArgs e)
{ {
if (editing) return; if (editing) return;
@ -454,7 +493,7 @@ namespace PKHeX.WinForms
switch (type) switch (type)
{ {
case 5: case 5:
int lucky = facility.UsedLuckyPlace * 3 + facility.UsedLuckyRank - 3; int lucky = (facility.UsedLuckyPlace * 3) + facility.UsedLuckyRank - 3;
if (lucky < 0 || lucky >= CB_LuckyResult.Items.Count) lucky = 0; if (lucky < 0 || lucky >= CB_LuckyResult.Items.Count) lucky = 0;
CB_LuckyResult.SelectedIndex = lucky; CB_LuckyResult.SelectedIndex = lucky;
break; break;
@ -481,9 +520,10 @@ namespace PKHeX.WinForms
facility.ExchangeLeftCount = type == 7 ? (byte)NUD_Exchangable.Value : 0; facility.ExchangeLeftCount = type == 7 ? (byte)NUD_Exchangable.Value : 0;
int lucky = CB_LuckyResult.SelectedIndex - 1; int lucky = CB_LuckyResult.SelectedIndex - 1;
bool writeLucky = type == 5 && lucky >= 0; bool writeLucky = type == 5 && lucky >= 0;
facility.UsedLuckyRank = writeLucky ? lucky % 3 + 1 : 0; facility.UsedLuckyRank = writeLucky ? (lucky % 3) + 1 : 0;
facility.UsedLuckyPlace = writeLucky ? lucky / 3 + 1 : 0; facility.UsedLuckyPlace = writeLucky ? (lucky / 3) + 1 : 0;
} }
private void LoadRankLabel(int rank) => L_RankFC.Text = GetRankText(rank); private void LoadRankLabel(int rank) => L_RankFC.Text = GetRankText(rank);
private static string GetRankText(int rank) private static string GetRankText(int rank)
@ -494,28 +534,28 @@ namespace PKHeX.WinForms
if (rank == 3) return "16 - 30"; if (rank == 3) return "16 - 30";
if (rank <= 10) if (rank <= 10)
{ {
int i = (rank - 1) * (rank - 2) * 5 + 1; int i = ((rank - 1) * (rank - 2) * 5) + 1;
return $"{i} - {i + (rank - 1) * 10 - 1}"; return $"{i} - {i + ((rank - 1) * 10) - 1}";
} }
if (rank <= 20) if (rank <= 20)
{ {
int i = rank * 100 - 649; int i = (rank * 100) - 649;
return $"{i} - {i + 99}"; return $"{i} - {i + 99}";
} }
if (rank <= 70) if (rank <= 70)
{ {
int j = (rank - 1) / 10; int j = (rank - 1) / 10;
int i = rank * (j * 30 + 60) - (j * j * 150 + j * 180 + 109); // 30 * (rank - 5 * j + 4) * (j + 2) - 349; int i = (rank * ((j * 30) + 60)) - ((j * j * 150) + (j * 180) + 109); // 30 * (rank - 5 * j + 4) * (j + 2) - 349;
return $"{i} - {i + j * 30 + 59}"; return $"{i} - {i + (j * 30) + 59}";
} }
if (rank <= 100) if (rank <= 100)
{ {
int i = rank * 270 - 8719; int i = (rank * 270) - 8719;
return $"{i} - {i + 269}"; return $"{i} - {i + 269}";
} }
if (rank <= 998) if (rank <= 998)
{ {
int i = rank * 300 - 11749; int i = (rank * 300) - 11749;
return $"{i} - {i + 299}"; return $"{i} - {i + 299}";
} }
if (rank == 999) if (rank == 999)
@ -530,7 +570,9 @@ namespace PKHeX.WinForms
SAV.FestaRank = (ushort)rank; SAV.FestaRank = (ushort)rank;
LoadRankLabel(rank); LoadRankLabel(rank);
} }
private readonly NumericUpDown[] NUD_Messages; private readonly NumericUpDown[] NUD_Messages;
private void NUD_MyMessage_ValueChanged(object sender, EventArgs e) private void NUD_MyMessage_ValueChanged(object sender, EventArgs e)
{ {
if (editing) return; if (editing) return;
@ -583,7 +625,9 @@ namespace PKHeX.WinForms
facility.SetMessage(i, 0); facility.SetMessage(i, 0);
LoadFacility(); LoadFacility();
} }
private string GetSpeciesNameFromPKM(PKM pkm) => PKX.GetSpeciesName(pkm.Species, SAV.Language); private string GetSpeciesNameFromPKM(PKM pkm) => PKX.GetSpeciesName(pkm.Species, SAV.Language);
private void B_ImportParty_Click(object sender, EventArgs e) private void B_ImportParty_Click(object sender, EventArgs e)
{ {
if (!SAV.HasParty) return; if (!SAV.HasParty) return;
@ -604,7 +648,7 @@ namespace PKHeX.WinForms
LoadPictureBox(); LoadPictureBox();
} }
private void mnuSave_Click(object sender, EventArgs e) private void MnuSave_Click(object sender, EventArgs e)
{ {
sender = WinFormsUtil.GetUnderlyingControl(sender); sender = WinFormsUtil.GetUnderlyingControl(sender);
int i = Array.IndexOf(PBs, sender); int i = Array.IndexOf(PBs, sender);
@ -615,7 +659,7 @@ namespace PKHeX.WinForms
private void NUD_Grade_ValueChanged(object sender, EventArgs e) private void NUD_Grade_ValueChanged(object sender, EventArgs e)
{ {
if (editing) return; if (editing) return;
int max = Math.Min(49, (int)NUD_Grade.Value) / 10 * 3 + 2; int max = (Math.Min(49, (int)NUD_Grade.Value) / 10 * 3) + 2;
editing = true; editing = true;
if (NUD_Defeated.Value > max) if (NUD_Defeated.Value > max)
NUD_Defeated.Value = max; NUD_Defeated.Value = max;
@ -637,8 +681,8 @@ namespace PKHeX.WinForms
int lucky = CB_LuckyResult.SelectedIndex; int lucky = CB_LuckyResult.SelectedIndex;
if (lucky-- < 0) return; if (lucky-- < 0) return;
// both 0 if "none" // both 0 if "none"
f[entry].UsedLuckyRank = lucky < 0 ? 0 : lucky % 3 + 1; f[entry].UsedLuckyRank = lucky < 0 ? 0 : (lucky % 3) + 1;
f[entry].UsedLuckyPlace = lucky < 0 ? 0 : lucky / 3 + 1; f[entry].UsedLuckyPlace = lucky < 0 ? 0 : (lucky / 3) + 1;
} }
private void B_AgentGlass_Click(object sender, EventArgs e) private void B_AgentGlass_Click(object sender, EventArgs e)

View file

@ -9,6 +9,7 @@ namespace PKHeX.WinForms
{ {
private readonly SaveFile Origin; private readonly SaveFile Origin;
private readonly SAV7 SAV; private readonly SAV7 SAV;
public SAV_HallOfFame7(SaveFile sav) public SAV_HallOfFame7(SaveFile sav)
{ {
InitializeComponent(); InitializeComponent();
@ -21,6 +22,7 @@ namespace PKHeX.WinForms
}; };
Setup(); Setup();
} }
private readonly ComboBox[] entries; private readonly ComboBox[] entries;
private void Setup() private void Setup()
@ -33,7 +35,7 @@ namespace PKHeX.WinForms
var specList = GameInfo.SpeciesDataSource.Where(s => s.Value <= SAV.MaxSpeciesID).ToList(); var specList = GameInfo.SpeciesDataSource.Where(s => s.Value <= SAV.MaxSpeciesID).ToList();
for (int i = 0; i < entries.Length; i++) for (int i = 0; i < entries.Length; i++)
{ {
int o = ofs + 4 + i*2; int o = ofs + 4 + (i * 2);
var cb = entries[i]; var cb = entries[i];
cb.Items.Clear(); cb.Items.Clear();
@ -53,6 +55,7 @@ namespace PKHeX.WinForms
{ {
Close(); Close();
} }
private void B_Close_Click(object sender, EventArgs e) private void B_Close_Click(object sender, EventArgs e)
{ {
int ofs = SAV.HoF; int ofs = SAV.HoF;
@ -62,7 +65,7 @@ namespace PKHeX.WinForms
BitConverter.GetBytes((ushort)NUD_Count.Value).CopyTo(SAV.Data, ofs + 2); BitConverter.GetBytes((ushort)NUD_Count.Value).CopyTo(SAV.Data, ofs + 2);
for (int i = 0; i < entries.Length; i++) for (int i = 0; i < entries.Length; i++)
{ {
int o = ofs + 4 + i * 2; int o = ofs + 4 + (i * 2);
var cb = entries[i]; var cb = entries[i];
var val = WinFormsUtil.GetIndex(cb); var val = WinFormsUtil.GetIndex(cb);
BitConverter.GetBytes((ushort)val).CopyTo(SAV.Data, o); BitConverter.GetBytes((ushort)val).CopyTo(SAV.Data, o);

View file

@ -21,6 +21,7 @@ namespace PKHeX.WinForms
private readonly SaveFile Origin; private readonly SaveFile Origin;
private readonly SAV7 SAV; private readonly SAV7 SAV;
private void LoadValues() private void LoadValues()
{ {
dgv.Rows.Clear(); dgv.Rows.Clear();
@ -69,12 +70,14 @@ namespace PKHeX.WinForms
{ {
Close(); Close();
} }
private void B_All_Click(object sender, EventArgs e) private void B_All_Click(object sender, EventArgs e)
{ {
Pouch.SetCountAll(255); Pouch.SetCountAll(255);
LoadValues(); LoadValues();
System.Media.SystemSounds.Asterisk.Play(); System.Media.SystemSounds.Asterisk.Play();
} }
private void B_None_Click(object sender, EventArgs e) private void B_None_Click(object sender, EventArgs e)
{ {
Pouch.SetCountAll(0); Pouch.SetCountAll(0);

View file

@ -10,6 +10,7 @@ namespace PKHeX.WinForms
{ {
private readonly SaveFile Origin; private readonly SaveFile Origin;
private readonly SAV7 SAV; private readonly SAV7 SAV;
public SAV_PokedexSM(SaveFile sav) public SAV_PokedexSM(SaveFile sav)
{ {
InitializeComponent(); InitializeComponent();
@ -28,7 +29,6 @@ namespace PKHeX.WinForms
CB_Species.InitializeBinding(); CB_Species.InitializeBinding();
CB_Species.DataSource = new BindingSource(GameInfo.SpeciesDataSource.Skip(1).ToList(), null); CB_Species.DataSource = new BindingSource(GameInfo.SpeciesDataSource.Skip(1).ToList(), null);
Dex = new PokeDex7(SAV); Dex = new PokeDex7(SAV);
var Species = GameInfo.Strings.Species; var Species = GameInfo.Strings.Species;
var names = Dex.GetEntryNames(Species); var names = Dex.GetEntryNames(Species);
@ -46,7 +46,6 @@ namespace PKHeX.WinForms
private int species = -1; private int species = -1;
private readonly CheckBox[] CP, CL; private readonly CheckBox[] CP, CL;
private void ChangeCBSpecies(object sender, EventArgs e) private void ChangeCBSpecies(object sender, EventArgs e)
{ {
if (editing) return; if (editing) return;
@ -60,6 +59,7 @@ namespace PKHeX.WinForms
GetEntry(); GetEntry();
editing = false; editing = false;
} }
private void ChangeLBSpecies(object sender, EventArgs e) private void ChangeLBSpecies(object sender, EventArgs e)
{ {
if (editing) return; if (editing) return;
@ -72,6 +72,7 @@ namespace PKHeX.WinForms
GetEntry(); GetEntry();
editing = false; editing = false;
} }
private void ChangeLBForms(object sender, EventArgs e) private void ChangeLBForms(object sender, EventArgs e)
{ {
if (allModifying) return; if (allModifying) return;
@ -94,15 +95,22 @@ namespace PKHeX.WinForms
species = bspecies; species = bspecies;
} }
else else
{
species = bspecies; species = bspecies;
}
} }
else species = bspecies; else
{
species = bspecies;
}
CB_Species.SelectedValue = species; CB_Species.SelectedValue = species;
LB_Species.SelectedIndex = species - 1; LB_Species.SelectedIndex = species - 1;
LB_Species.TopIndex = LB_Species.SelectedIndex; LB_Species.TopIndex = LB_Species.SelectedIndex;
GetEntry(); GetEntry();
editing = false; editing = false;
} }
private bool FillLBForms() private bool FillLBForms()
{ {
if (allModifying) return false; if (allModifying) return false;
@ -129,7 +137,9 @@ namespace PKHeX.WinForms
LB_Forms.DataSource = ds; LB_Forms.DataSource = ds;
if (fspecies <= SAV.MaxSpeciesID) if (fspecies <= SAV.MaxSpeciesID)
{
LB_Forms.SelectedIndex = 0; LB_Forms.SelectedIndex = 0;
}
else else
{ {
int fc = SAV.Personal[bspecies].FormeCount; int fc = SAV.Personal[bspecies].FormeCount;
@ -163,10 +173,13 @@ namespace PKHeX.WinForms
CHK_P4.Checked |= CHK_P8.Checked; CHK_P4.Checked |= CHK_P8.Checked;
CHK_P5.Checked |= CHK_P9.Checked; CHK_P5.Checked |= CHK_P9.Checked;
} }
private void ChangeEncountered(object sender, EventArgs e) private void ChangeEncountered(object sender, EventArgs e)
{ {
if (!(CHK_P2.Checked || CHK_P3.Checked || CHK_P4.Checked || CHK_P5.Checked)) if (!(CHK_P2.Checked || CHK_P3.Checked || CHK_P4.Checked || CHK_P5.Checked))
{
CHK_P6.Checked = CHK_P7.Checked = CHK_P8.Checked = CHK_P9.Checked = false; CHK_P6.Checked = CHK_P7.Checked = CHK_P8.Checked = CHK_P9.Checked = false;
}
else if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked)) else if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked))
{ {
if (sender == CHK_P2 && CHK_P2.Checked) if (sender == CHK_P2 && CHK_P2.Checked)
@ -201,10 +214,11 @@ namespace PKHeX.WinForms
for (int i = 0; i < 9; i++) for (int i = 0; i < 9; i++)
{ {
CL[i].Enabled = species <= SAV.MaxSpeciesID; CL[i].Enabled = species <= SAV.MaxSpeciesID;
CL[i].Checked = CL[i].Enabled && Dex.LanguageFlags[pk*9 + i]; CL[i].Checked = CL[i].Enabled && Dex.LanguageFlags[(pk * 9) + i];
} }
editing = false; editing = false;
} }
private void SetEntry() private void SetEntry()
{ {
if (species <= 0) if (species <= 0)
@ -224,13 +238,14 @@ namespace PKHeX.WinForms
Dex.Owned[pk] = CHK_P1.Checked; Dex.Owned[pk] = CHK_P1.Checked;
for (int i = 0; i < 9; i++) for (int i = 0; i < 9; i++)
Dex.LanguageFlags[pk*9 + i] = CL[i].Checked; Dex.LanguageFlags[(pk * 9) + i] = CL[i].Checked;
} }
private void B_Cancel_Click(object sender, EventArgs e) private void B_Cancel_Click(object sender, EventArgs e)
{ {
Close(); Close();
} }
private void B_Save_Click(object sender, EventArgs e) private void B_Save_Click(object sender, EventArgs e)
{ {
SetEntry(); SetEntry();
@ -264,16 +279,22 @@ namespace PKHeX.WinForms
CHK_P3.Checked = CHK_P5.Checked = gt != 0 && gt != 255 && ModifierKeys != Keys.Control; CHK_P3.Checked = CHK_P5.Checked = gt != 0 && gt != 255 && ModifierKeys != Keys.Control;
if (ModifierKeys == Keys.Control) if (ModifierKeys == Keys.Control)
{
foreach (var chk in new[] { CHK_P6, CHK_P7, CHK_P8, CHK_P9 }) foreach (var chk in new[] { CHK_P6, CHK_P7, CHK_P8, CHK_P9 })
chk.Checked = false; chk.Checked = false;
}
else if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked)) else if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked))
{
(gt != 254 ? CHK_P6 : CHK_P7).Checked = true; (gt != 254 ? CHK_P6 : CHK_P7).Checked = true;
}
} }
private void B_Modify_Click(object sender, EventArgs e) private void B_Modify_Click(object sender, EventArgs e)
{ {
Button btn = (Button)sender; Button btn = (Button)sender;
modifyMenu.Show(btn.PointToScreen(new Point(0, btn.Height))); modifyMenu.Show(btn.PointToScreen(new Point(0, btn.Height)));
} }
private void ModifyAll(object sender, EventArgs e) private void ModifyAll(object sender, EventArgs e)
{ {
allModifying = true; allModifying = true;
@ -289,13 +310,14 @@ namespace PKHeX.WinForms
SetEntry(); SetEntry();
// Turn off zh2 Petilil // Turn off zh2 Petilil
Dex.LanguageFlags[548 * 9 + 8] = false; Dex.LanguageFlags[(548 * 9) + 8] = false;
GetEntry(); GetEntry();
allModifying = false; allModifying = false;
LB_Forms.Enabled = LB_Forms.Visible = true; LB_Forms.Enabled = LB_Forms.Visible = true;
LB_Species.SelectedIndex = 0; LB_Species.SelectedIndex = 0;
System.Media.SystemSounds.Asterisk.Play(); System.Media.SystemSounds.Asterisk.Play();
} }
private void ClearAll(object sender) private void ClearAll(object sender)
{ {
for (int i = 0; i < LB_Species.Items.Count; i++) for (int i = 0; i < LB_Species.Items.Count; i++)
@ -311,6 +333,7 @@ namespace PKHeX.WinForms
CHK_P6.Checked = CHK_P7.Checked = CHK_P8.Checked = CHK_P9.Checked = false; CHK_P6.Checked = CHK_P7.Checked = CHK_P8.Checked = CHK_P9.Checked = false;
} }
} }
private void SetAll(object sender, int lang) private void SetAll(object sender, int lang)
{ {
for (int i = 0; i < SAV.MaxSpeciesID; i++) for (int i = 0; i < SAV.MaxSpeciesID; i++)
@ -347,8 +370,10 @@ namespace PKHeX.WinForms
if (isForm) if (isForm)
return; return;
if (!(CHK_P2.Checked || CHK_P3.Checked || CHK_P4.Checked || CHK_P5.Checked)) // if seen if (!(CHK_P2.Checked || CHK_P3.Checked || CHK_P4.Checked || CHK_P5.Checked)) // if seen
{
if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked)) // not displayed if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked)) // not displayed
(gt != 254 ? CHK_P6 : CHK_P7).Checked = true; // check one (gt != 254 ? CHK_P6 : CHK_P7).Checked = true; // check one
}
return; return;
} }
@ -393,8 +418,10 @@ namespace PKHeX.WinForms
} }
if (!CHK_P1.Checked) if (!CHK_P1.Checked)
{
foreach (CheckBox t in CL) foreach (CheckBox t in CL)
t.Checked = false; t.Checked = false;
}
} }
} }
} }

View file

@ -10,6 +10,7 @@ namespace PKHeX.WinForms
{ {
private readonly SaveFile Origin; private readonly SaveFile Origin;
private readonly SAV7 SAV; private readonly SAV7 SAV;
public SAV_Trainer7(SaveFile sav) public SAV_Trainer7(SaveFile sav)
{ {
InitializeComponent(); InitializeComponent();
@ -17,8 +18,10 @@ namespace PKHeX.WinForms
SAV = (SAV7)(Origin = sav).Clone(); SAV = (SAV7)(Origin = sav).Clone();
Loading = true; Loading = true;
if (Main.Unicode) if (Main.Unicode)
try { TB_OTName.Font = FontUtil.GetPKXFont(11); } {
catch (Exception e) { WinFormsUtil.Alert("Font loading failed...", e.ToString()); } try { TB_OTName.Font = FontUtil.GetPKXFont(11); }
catch (Exception e) { WinFormsUtil.Alert("Font loading failed...", e.ToString()); }
}
B_MaxCash.Click += (sender, e) => MT_Money.Text = "9,999,999"; B_MaxCash.Click += (sender, e) => MT_Money.Text = "9,999,999";
@ -46,7 +49,7 @@ namespace PKHeX.WinForms
private static readonly string[] TrainerStampTitle = { "01:Official Pokemon Trainer", "02:Melemele Trial Completion", "03:Akala Trial Completion", "04:Ula'ula Trial Completion", "05:Poni Trial Completion", "06:Island Challenge Completion", "07:Melemele Pokedex Completion", "08:Akala Pokedex Completion", "09:Ula'ula Pokedex Completion", "10:Poni Pokedex Completion", "11:Alola Pokedex Completion", "12:50 Consecutive Single Battle Wins", "13:50 Consecutive Double Battle Wins", "14:50 Consecutive Multi Battle Wins", "15:Poke Finder Pro" }; private static readonly string[] TrainerStampTitle = { "01:Official Pokemon Trainer", "02:Melemele Trial Completion", "03:Akala Trial Completion", "04:Ula'ula Trial Completion", "05:Poni Trial Completion", "06:Island Challenge Completion", "07:Melemele Pokedex Completion", "08:Akala Pokedex Completion", "09:Ula'ula Pokedex Completion", "10:Poni Pokedex Completion", "11:Alola Pokedex Completion", "12:50 Consecutive Single Battle Wins", "13:50 Consecutive Double Battle Wins", "14:50 Consecutive Multi Battle Wins", "15:Poke Finder Pro" };
private static readonly string[] BattleStyles = { "Normal", "Elegant", "Girlish", "Reverent", "Smug", "Left-handed", "Passionate", "Idol" }; private static readonly string[] BattleStyles = { "Normal", "Elegant", "Girlish", "Reverent", "Smug", "Left-handed", "Passionate", "Idol" };
private int[] FlyDestFlagOfs, MapUnmaskFlagOfs; private int[] FlyDestFlagOfs, MapUnmaskFlagOfs;
private int skipFlag => SAV.USUM ? 4160 : 3200; // FlagMax - 768 private int SkipFlag => SAV.USUM ? 4160 : 3200; // FlagMax - 768
private void GetComboBoxes() private void GetComboBoxes()
{ {
@ -101,6 +104,7 @@ namespace PKHeX.WinForms
foreach (string t in TrainerStampTitle) foreach (string t in TrainerStampTitle)
LB_Stamps.Items.Add(t); LB_Stamps.Items.Add(t);
} }
private void GetTextBoxes() private void GetTextBoxes()
{ {
// Get Data // Get Data
@ -197,8 +201,7 @@ namespace PKHeX.WinForms
if (SAV.SM) if (SAV.SM)
LoadThrowTypeLists(); LoadThrowTypeLists();
else else
CB_BallThrowTypeListMode.Visible = LB_BallThrowTypeLearned.Visible = CB_BallThrowTypeListMode.Visible = LB_BallThrowTypeLearned.Visible = LB_BallThrowTypeUnlocked.Visible = false;
LB_BallThrowTypeUnlocked.Visible = false;
uint stampBits = SAV.Stamps; uint stampBits = SAV.Stamps;
for (int i = 0; i < LB_Stamps.Items.Count; i++) for (int i = 0; i < LB_Stamps.Items.Count; i++)
@ -262,7 +265,7 @@ namespace PKHeX.WinForms
FlyDestNameIndex[i] < 0 FlyDestNameIndex[i] < 0
? FlyDestAltName[u++] ? FlyDestAltName[u++]
: metLocationList.First(v => v.Value == FlyDestNameIndex[i]).Text : metLocationList.First(v => v.Value == FlyDestNameIndex[i]).Text
, SAV.GetEventFlag(skipFlag + FlyDestFlagOfs[i]) , SAV.GetEventFlag(SkipFlag + FlyDestFlagOfs[i])
); );
} }
int[] MapUnmaskNameIndex = { int[] MapUnmaskNameIndex = {
@ -289,10 +292,11 @@ namespace PKHeX.WinForms
MapUnmaskNameIndex[i] < 0 MapUnmaskNameIndex[i] < 0
? MapUnmaskAltName[u++] ? MapUnmaskAltName[u++]
: metLocationList.First(v => v.Value == MapUnmaskNameIndex[i]).Text : metLocationList.First(v => v.Value == MapUnmaskNameIndex[i]).Text
, SAV.GetEventFlag(skipFlag + MapUnmaskFlagOfs[i]) , SAV.GetEventFlag(SkipFlag + MapUnmaskFlagOfs[i])
); );
} }
} }
private void LoadUltraData() private void LoadUltraData()
{ {
NUD_Surf0.Value = SAV.GetSurfScore(0); NUD_Surf0.Value = SAV.GetSurfScore(0);
@ -302,6 +306,7 @@ namespace PKHeX.WinForms
TB_RotomOT.Font = TB_OTName.Font; TB_RotomOT.Font = TB_OTName.Font;
TB_RotomOT.Text = SAV.RotomOT; TB_RotomOT.Text = SAV.RotomOT;
} }
private void Save() private void Save()
{ {
SaveTrainerInfo(); SaveTrainerInfo();
@ -321,6 +326,7 @@ namespace PKHeX.WinForms
if (SAV.USUM) if (SAV.USUM)
SaveUltraData(); SaveUltraData();
} }
private void SaveTrainerInfo() private void SaveTrainerInfo()
{ {
SAV.Game = (byte)(CB_Game.SelectedIndex + 30); SAV.Game = (byte)(CB_Game.SelectedIndex + 30);
@ -367,6 +373,7 @@ namespace PKHeX.WinForms
SAV.BP = (uint)NUD_BP.Value; SAV.BP = (uint)NUD_BP.Value;
SAV.FestaCoins = (uint)NUD_FC.Value; SAV.FestaCoins = (uint)NUD_FC.Value;
} }
private void SavePokeFinder() private void SavePokeFinder()
{ {
SAV.PokeFinderSnapCount = (uint)NUD_SnapCount.Value; SAV.PokeFinderSnapCount = (uint)NUD_SnapCount.Value;
@ -376,6 +383,7 @@ namespace PKHeX.WinForms
SAV.PokeFinderCameraVersion = (ushort)CB_CameraVersion.SelectedIndex; SAV.PokeFinderCameraVersion = (ushort)CB_CameraVersion.SelectedIndex;
SAV.PokeFinderGyroFlag = CHK_Gyro.Checked; SAV.PokeFinderGyroFlag = CHK_Gyro.Checked;
} }
private void SaveBattleTree() private void SaveBattleTree()
{ {
SAV.SetTreeStreak((int)NUD_RCStreak0.Value, 0, super:false, max:false); SAV.SetTreeStreak((int)NUD_RCStreak0.Value, 0, super:false, max:false);
@ -392,6 +400,7 @@ namespace PKHeX.WinForms
SAV.SetTreeStreak((int)NUD_SMStreak1.Value, 1, super:true, max:true); SAV.SetTreeStreak((int)NUD_SMStreak1.Value, 1, super:true, max:true);
SAV.SetTreeStreak((int)NUD_SMStreak2.Value, 2, super:true, max:true); SAV.SetTreeStreak((int)NUD_SMStreak2.Value, 2, super:true, max:true);
} }
private void SaveTrainerAppearance() private void SaveTrainerAppearance()
{ {
// Skin changed && (gender matches || override) // Skin changed && (gender matches || override)
@ -400,10 +409,13 @@ namespace PKHeX.WinForms
string gStr = CB_Gender.Items[gender].ToString(); string gStr = CB_Gender.Items[gender].ToString();
string sStr = CB_Gender.Items[skin].ToString(); string sStr = CB_Gender.Items[skin].ToString();
if (SAV.DressUpSkinColor != CB_SkinColor.SelectedIndex && if (SAV.DressUpSkinColor == CB_SkinColor.SelectedIndex)
(SAV.Gender == skin || DialogResult.Yes == WinFormsUtil.Prompt(MessageBoxButtons.YesNo, $"Gender-Skin mismatch:{Environment.NewLine}Gender: {gStr}, Skin: {sStr}", "Save selected Skin Color?"))) return;
SAV.DressUpSkinColor = CB_SkinColor.SelectedIndex;
if (SAV.Gender == skin || DialogResult.Yes == WinFormsUtil.Prompt(MessageBoxButtons.YesNo, $"Gender-Skin mismatch:{Environment.NewLine}Gender: {gStr}, Skin: {sStr}", "Save selected Skin Color?"))
SAV.DressUpSkinColor = CB_SkinColor.SelectedIndex;
} }
private void SaveThrowType() private void SaveThrowType()
{ {
if (CB_BallThrowType.SelectedIndex >= 0) if (CB_BallThrowType.SelectedIndex >= 0)
@ -419,6 +431,7 @@ namespace PKHeX.WinForms
for (int i = 1; i < BattleStyles.Length; i++) for (int i = 1; i < BattleStyles.Length; i++)
SAV.SetEventFlag(learnedStart + i, LB_BallThrowTypeLearned.GetSelected(i)); SAV.SetEventFlag(learnedStart + i, LB_BallThrowTypeLearned.GetSelected(i));
} }
private void SaveFlags() private void SaveFlags()
{ {
SAV.Stamps = GetBits(LB_Stamps); SAV.Stamps = GetBits(LB_Stamps);
@ -431,10 +444,11 @@ namespace PKHeX.WinForms
SAV.ZMoveUnlocked = CHK_UnlockZMove.Checked; SAV.ZMoveUnlocked = CHK_UnlockZMove.Checked;
for (int i = 0; i < CLB_FlyDest.Items.Count; i++) for (int i = 0; i < CLB_FlyDest.Items.Count; i++)
SAV.SetEventFlag(skipFlag + FlyDestFlagOfs[i], CLB_FlyDest.GetItemChecked(i)); SAV.SetEventFlag(SkipFlag + FlyDestFlagOfs[i], CLB_FlyDest.GetItemChecked(i));
for (int i = 0; i < CLB_MapUnmask.Items.Count; i++) for (int i = 0; i < CLB_MapUnmask.Items.Count; i++)
SAV.SetEventFlag(skipFlag + MapUnmaskFlagOfs[i], CLB_MapUnmask.GetItemChecked(i)); SAV.SetEventFlag(SkipFlag + MapUnmaskFlagOfs[i], CLB_MapUnmask.GetItemChecked(i));
} }
private void SaveUltraData() private void SaveUltraData()
{ {
SAV.SetSurfScore(0, (int)NUD_Surf0.Value); SAV.SetSurfScore(0, (int)NUD_Surf0.Value);
@ -446,17 +460,23 @@ namespace PKHeX.WinForms
&& TB_OTName.Text != SAV.OT // manually changed && TB_OTName.Text != SAV.OT // manually changed
&& DialogResult.Yes == // wants to update && DialogResult.Yes == // wants to update
WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Rotom OT does not match OT name. Update Rotom OT name with OT name?")) WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Rotom OT does not match OT name. Update Rotom OT name with OT name?"))
{
SAV.RotomOT = TB_OTName.Text; SAV.RotomOT = TB_OTName.Text;
}
else else
{
SAV.RotomOT = TB_RotomOT.Text; SAV.RotomOT = TB_RotomOT.Text;
}
} }
private static uint GetBits(ListBox listbox) private static uint GetBits(ListBox listbox)
{ {
uint bits = 0; uint bits = 0;
for (int i = 0; i < listbox.Items.Count; i++) for (int i = 0; i < listbox.Items.Count; i++)
{
if (listbox.GetSelected(i)) if (listbox.GetSelected(i))
bits |= (uint)(1 << i); bits |= (uint)(1 << i);
}
return bits; return bits;
} }
@ -476,35 +496,41 @@ namespace PKHeX.WinForms
{ {
Close(); Close();
} }
private void B_Save_Click(object sender, EventArgs e) private void B_Save_Click(object sender, EventArgs e)
{ {
Save(); Save();
Origin.SetData(SAV.Data, 0); Origin.SetData(SAV.Data, 0);
Close(); Close();
} }
private void Change255(object sender, EventArgs e) private void Change255(object sender, EventArgs e)
{ {
MaskedTextBox box = (MaskedTextBox)sender; MaskedTextBox box = (MaskedTextBox)sender;
if (box.Text.Length == 0) box.Text = "0"; if (box.Text.Length == 0) box.Text = "0";
if (Util.ToInt32(box.Text) > 255) box.Text = "255"; if (Util.ToInt32(box.Text) > 255) box.Text = "255";
} }
private void ChangeFFFF(object sender, EventArgs e) private void ChangeFFFF(object sender, EventArgs e)
{ {
MaskedTextBox box = (MaskedTextBox)sender; MaskedTextBox box = (MaskedTextBox)sender;
if (box.Text.Length == 0) box.Text = "0"; if (box.Text.Length == 0) box.Text = "0";
if (Util.ToInt32(box.Text) > 65535) box.Text = "65535"; if (Util.ToInt32(box.Text) > 65535) box.Text = "65535";
} }
private void ChangeMapValue(object sender, EventArgs e) private void ChangeMapValue(object sender, EventArgs e)
{ {
if (!Loading) if (!Loading)
MapUpdated = true; MapUpdated = true;
} }
private void UpdateCountry(object sender, EventArgs e) private void UpdateCountry(object sender, EventArgs e)
{ {
int index; int index;
if (sender is ComboBox c && (index = WinFormsUtil.GetIndex(c)) > 0) if (sender is ComboBox c && (index = WinFormsUtil.GetIndex(c)) > 0)
Main.SetCountrySubRegion(CB_Region, $"sr_{index:000}"); Main.SetCountrySubRegion(CB_Region, $"sr_{index:000}");
} }
private void B_Fashion_Click(object sender, EventArgs e) private void B_Fashion_Click(object sender, EventArgs e)
{ {
var prompt = WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Modifying Fashion Items will clear existing fashion unlock data.", "Continue?"); var prompt = WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Modifying Fashion Items will clear existing fashion unlock data.", "Continue?");
@ -550,6 +576,7 @@ namespace PKHeX.WinForms
} }
System.Media.SystemSounds.Asterisk.Play(); System.Media.SystemSounds.Asterisk.Play();
} }
private string UpdateTip(int index) private string UpdateTip(int index)
{ {
switch (index) switch (index)
@ -563,6 +590,7 @@ namespace PKHeX.WinForms
return null; return null;
} }
} }
private static string ConvertDateValueToString(int value, int secondsBias = -1) private static string ConvertDateValueToString(int value, int secondsBias = -1)
{ {
const int spd = 86400; // seconds per day const int spd = 86400; // seconds per day
@ -588,12 +616,14 @@ namespace PKHeX.WinForms
LB_BallThrowTypeLearned.Visible = true; LB_BallThrowTypeLearned.Visible = true;
} }
} }
private void UpdateBallThrowTypeLearned(object sender, EventArgs e) private void UpdateBallThrowTypeLearned(object sender, EventArgs e)
{ {
if (Loading) return; if (Loading) return;
if (!LB_BallThrowTypeLearned.GetSelected(0)) if (!LB_BallThrowTypeLearned.GetSelected(0))
LB_BallThrowTypeLearned.SetSelected(0, true); LB_BallThrowTypeLearned.SetSelected(0, true);
} }
private void UpdateBallThrowTypeUnlocked(object sender, EventArgs e) private void UpdateBallThrowTypeUnlocked(object sender, EventArgs e)
{ {
if (Loading) return; if (Loading) return;
@ -603,11 +633,13 @@ namespace PKHeX.WinForms
LB_BallThrowTypeUnlocked.SetSelected(i, true); LB_BallThrowTypeUnlocked.SetSelected(i, true);
} }
} }
private void B_AllFlyDest_Click(object sender, EventArgs e) private void B_AllFlyDest_Click(object sender, EventArgs e)
{ {
for (int i = 0; i < CLB_FlyDest.Items.Count; i++) for (int i = 0; i < CLB_FlyDest.Items.Count; i++)
CLB_FlyDest.SetItemChecked(i, true); CLB_FlyDest.SetItemChecked(i, true);
} }
private void B_AllMapUnmask_Click(object sender, EventArgs e) private void B_AllMapUnmask_Click(object sender, EventArgs e)
{ {
for (int i = 0; i < CLB_MapUnmask.Items.Count; i++) for (int i = 0; i < CLB_MapUnmask.Items.Count; i++)

View file

@ -9,6 +9,7 @@ namespace PKHeX.WinForms
{ {
private readonly SaveFile Origin; private readonly SaveFile Origin;
private readonly SAV7 SAV; private readonly SAV7 SAV;
public SAV_ZygardeCell(SaveFile sav) public SAV_ZygardeCell(SaveFile sav)
{ {
InitializeComponent(); InitializeComponent();
@ -19,7 +20,7 @@ namespace PKHeX.WinForms
// Cell Data @ 0x1D8C // Cell Data @ 0x1D8C
// Use constants 0x18C/2 = 198 thru +95 // Use constants 0x18C/2 = 198 thru +95
ushort[] constants = SAV.EventConsts; ushort[] constants = SAV.EventConsts;
ushort[] cells = constants.Skip(celloffset).Take(cellcount).ToArray(); ushort[] cells = constants.Skip(celloffset).Take(CellCount).ToArray();
int cellCount = constants[cellstotal]; int cellCount = constants[cellstotal];
int cellCollected = constants[cellscollected]; int cellCollected = constants[cellscollected];
@ -32,9 +33,9 @@ namespace PKHeX.WinForms
combo.Items.Add(t); // add only the Names combo.Items.Add(t); // add only the Names
// Populate Grid // Populate Grid
dgv.Rows.Add(cellcount); dgv.Rows.Add(CellCount);
var locations = SAV.SM ? locationsSM : locationsUSUM; var locations = SAV.SM ? locationsSM : locationsUSUM;
for (int i = 0; i < cellcount; i++) for (int i = 0; i < CellCount; i++)
{ {
if (cells[i] > 2) if (cells[i] > 2)
throw new ArgumentException(); throw new ArgumentException();
@ -48,13 +49,13 @@ namespace PKHeX.WinForms
private const int cellstotal = 161; private const int cellstotal = 161;
private const int cellscollected = 169; private const int cellscollected = 169;
private const int celloffset = 0xC6; private const int celloffset = 0xC6;
private int cellcount => SAV.USUM ? 100 : 95; private int CellCount => SAV.USUM ? 100 : 95;
private readonly string[] states = {"None", "Available", "Received"}; private readonly string[] states = {"None", "Available", "Received"};
private void B_Save_Click(object sender, EventArgs e) private void B_Save_Click(object sender, EventArgs e)
{ {
ushort[] constants = SAV.EventConsts; ushort[] constants = SAV.EventConsts;
for (int i = 0; i < cellcount; i++) for (int i = 0; i < CellCount; i++)
{ {
string str = (string)dgv.Rows[i].Cells[2].Value; string str = (string)dgv.Rows[i].Cells[2].Value;
int val = Array.IndexOf(states, str); int val = Array.IndexOf(states, str);
@ -74,10 +75,12 @@ namespace PKHeX.WinForms
Close(); Close();
} }
private void B_Cancel_Click(object sender, EventArgs e) private void B_Cancel_Click(object sender, EventArgs e)
{ {
Close(); Close();
} }
private void B_GiveAll_Click(object sender, EventArgs e) private void B_GiveAll_Click(object sender, EventArgs e)
{ {
int added = 0; int added = 0;
@ -195,6 +198,7 @@ namespace PKHeX.WinForms
"Aether Foundation 1F - Entrance (Night)", "Aether Foundation 1F - Entrance (Night)",
"Aether Foundation 1F - Main Building", "Aether Foundation 1F - Main Building",
}; };
private readonly string[] locationsUSUM = private readonly string[] locationsUSUM =
{ {
"Hau'oli City (Shopping) - Salon (Outside)", "Hau'oli City (Shopping) - Salon (Outside)",

View file

@ -11,6 +11,7 @@ namespace PKHeX.WinForms
public sealed partial class SAV_BoxList : Form public sealed partial class SAV_BoxList : Form
{ {
private readonly List<BoxEditor> Boxes = new List<BoxEditor>(); private readonly List<BoxEditor> Boxes = new List<BoxEditor>();
public SAV_BoxList(SAVEditor p, SlotChangeManager m) public SAV_BoxList(SAVEditor p, SlotChangeManager m)
{ {
InitializeComponent(); InitializeComponent();
@ -86,11 +87,11 @@ namespace PKHeX.WinForms
Debug.Assert(height * width >= count); Debug.Assert(height * width >= count);
width = Math.Min(4, width); width = Math.Min(4, width);
var padWidth = Boxes[0].Margin.Horizontal * 2 + 1; var padWidth = (Boxes[0].Margin.Horizontal * 2) + 1;
Width = (Boxes[0].Width + padWidth) * width - padWidth/2 + 0x10; Width = ((Boxes[0].Width + padWidth) * width) - (padWidth / 2) + 0x10;
var padHeight = Boxes[0].Margin.Vertical * 2 + 1; var padHeight = (Boxes[0].Margin.Vertical * 2) + 1;
Height = (Boxes[0].Height + padHeight) * height - padHeight/2; Height = ((Boxes[0].Height + padHeight) * height) - (padHeight / 2);
} }
private static void Main_DragEnter(object sender, DragEventArgs e) private static void Main_DragEnter(object sender, DragEventArgs e)

View file

@ -14,6 +14,7 @@ namespace PKHeX.WinForms
{ {
private readonly SaveFile Origin; private readonly SaveFile Origin;
private readonly SaveFile SAV; private readonly SaveFile SAV;
public SAV_EventFlags(SaveFile sav) public SAV_EventFlags(SaveFile sav)
{ {
InitializeComponent(); InitializeComponent();
@ -47,7 +48,9 @@ namespace PKHeX.WinForms
Text = $"{Text} ({gamePrefix.ToUpper()})"; Text = $"{Text} ({gamePrefix.ToUpper()})";
if (CB_Stats.Items.Count > 0) if (CB_Stats.Items.Count > 0)
{
CB_Stats.SelectedIndex = 0; CB_Stats.SelectedIndex = 0;
}
else else
{ {
L_Stats.Visible = CB_Stats.Visible = MT_Stat.Visible = false; L_Stats.Visible = CB_Stats.Visible = MT_Stat.Visible = false;
@ -75,6 +78,7 @@ namespace PKHeX.WinForms
{ {
Close(); Close();
} }
private void B_Save_Click(object sender, EventArgs e) private void B_Save_Click(object sender, EventArgs e)
{ {
// Gather Updated Flags // Gather Updated Flags
@ -156,6 +160,7 @@ namespace PKHeX.WinForms
} }
return GameInfo.GetStrings(gamePrefix, GameInfo.CurrentLanguage, type); return GameInfo.GetStrings(gamePrefix, GameInfo.CurrentLanguage, type);
} }
private void AddFlagList(string[] list) private void AddFlagList(string[] list)
{ {
if (list == null || list.Length == 0) if (list == null || list.Length == 0)
@ -172,26 +177,19 @@ namespace PKHeX.WinForms
{ {
try try
{ {
var flag = split[0]; var flagIndex = split[0];
int n = TryParseHexDec(flagIndex);
int n;
if (flag.StartsWith("0x"))
{
flag = flag.Substring(2);
n = Convert.ToInt16(flag, 16);
}
else
n = Convert.ToInt16(flag);
if (num.Contains(n)) if (num.Contains(n))
continue; continue;
num.Add(n); num.Add(n);
desc.Add(split[1]); desc.Add(split[1]);
} catch { } }
catch { }
} }
if (num.Count == 0) if (num.Count == 0)
{ {
TLP_Flags.Controls.Add(new Label { Text = "Needs more research.", Name = "TLP_Flags_Research", ForeColor = Color.Red, AutoSize = true }, 0, 0); TLP_Flags.Controls.Add(new Label { Text = MsgResearchRequired, Name = "TLP_Flags_Research", ForeColor = Color.Red, AutoSize = true }, 0, 0);
return; return;
} }
@ -218,6 +216,15 @@ namespace PKHeX.WinForms
TLP_Flags.Controls.Add(lbl, 1, i); TLP_Flags.Controls.Add(lbl, 1, i);
} }
} }
private static int TryParseHexDec(string flag)
{
if (!flag.StartsWith("0x"))
return Convert.ToInt16(flag);
flag = flag.Substring(2);
return Convert.ToInt16(flag, 16);
}
private void AddConstList(string[] list) private void AddConstList(string[] list)
{ {
if (list == null || list.Length == 0) if (list == null || list.Length == 0)
@ -236,21 +243,15 @@ namespace PKHeX.WinForms
try try
{ {
var c = split[0]; var c = split[0];
int n; int n = TryParseHexDecConst(c);
if (c.StartsWith("0x40"))
{
c = c.Substring(4);
n = Convert.ToInt16(c, 16);
}
else
n = Convert.ToInt16(c);
if (num.Contains(n)) if (num.Contains(n))
continue; continue;
num.Add(n); num.Add(n);
desc.Add(split[1]); desc.Add(split[1]);
enums.Add(split.Length == 3 ? split[2] : ""); enums.Add(split.Length == 3 ? split[2] : "");
} catch { } }
catch { }
} }
if (num.Count == 0) if (num.Count == 0)
{ {
@ -312,6 +313,14 @@ namespace PKHeX.WinForms
} }
} }
private static int TryParseHexDecConst(string c)
{
if (!c.StartsWith("0x40"))
return Convert.ToInt16(c);
c = c.Substring(4);
return Convert.ToInt16(c, 16);
}
private static int GetControlNum(Control c) private static int GetControlNum(Control c)
{ {
try try
@ -321,6 +330,7 @@ namespace PKHeX.WinForms
} }
catch { return 0; } catch { return 0; }
} }
private void ChangeCustomBool(object sender, EventArgs e) private void ChangeCustomBool(object sender, EventArgs e)
{ {
if (editing) if (editing)
@ -332,6 +342,7 @@ namespace PKHeX.WinForms
c.Checked = c_CustomFlag.Checked; c.Checked = c_CustomFlag.Checked;
editing = false; editing = false;
} }
private void ChangeCustomFlag(object sender, EventArgs e) private void ChangeCustomFlag(object sender, EventArgs e)
{ {
int flag = (int)NUD_Flag.Value; int flag = (int)NUD_Flag.Value;
@ -348,10 +359,12 @@ namespace PKHeX.WinForms
c_CustomFlag.Checked = flags[flag]; c_CustomFlag.Checked = flags[flag];
} }
} }
private void ChangeCustomFlag(object sender, KeyEventArgs e) private void ChangeCustomFlag(object sender, KeyEventArgs e)
{ {
ChangeCustomFlag(null, (EventArgs)e); ChangeCustomFlag(null, (EventArgs)e);
} }
private void ToggleFlag(object sender, EventArgs e) private void ToggleFlag(object sender, EventArgs e)
{ {
if (editing) if (editing)
@ -377,6 +390,7 @@ namespace PKHeX.WinForms
editing = false; editing = false;
} }
private void ChangeConstantIndex(object sender, EventArgs e) private void ChangeConstantIndex(object sender, EventArgs e)
{ {
if (Constants.Length == 0) if (Constants.Length == 0)
@ -387,6 +401,7 @@ namespace PKHeX.WinForms
constEntry = CB_Stats.SelectedIndex; // Get Entry constEntry = CB_Stats.SelectedIndex; // Get Entry
MT_Stat.Text = Constants[constEntry].ToString(); MT_Stat.Text = Constants[constEntry].ToString();
} }
private void ToggleConst(object sender, EventArgs e) private void ToggleConst(object sender, EventArgs e)
{ {
if (editing) if (editing)
@ -419,12 +434,14 @@ namespace PKHeX.WinForms
if (TB_NewSAV.Text.Length > 0 && TB_OldSAV.Text.Length > 0) if (TB_NewSAV.Text.Length > 0 && TB_OldSAV.Text.Length > 0)
DiffSaves(); DiffSaves();
} }
private void OpenSAV(object sender, EventArgs e) private void OpenSAV(object sender, EventArgs e)
{ {
OpenFileDialog ofd = new OpenFileDialog(); OpenFileDialog ofd = new OpenFileDialog();
if (ofd.ShowDialog() == DialogResult.OK) if (ofd.ShowDialog() == DialogResult.OK)
LoadSAV(sender, ofd.FileName); LoadSAV(sender, ofd.FileName);
} }
private void LoadSAV(object sender, string path) private void LoadSAV(object sender, string path)
{ {
if (sender == B_LoadOld) if (sender == B_LoadOld)
@ -432,6 +449,7 @@ namespace PKHeX.WinForms
else else
TB_NewSAV.Text = path; TB_NewSAV.Text = path;
} }
private void DiffSaves() private void DiffSaves()
{ {
if (!File.Exists(TB_OldSAV.Text)) { WinFormsUtil.Alert(string.Format(MsgSaveNumberInvalid, 1)); return; } if (!File.Exists(TB_OldSAV.Text)) { WinFormsUtil.Alert(string.Format(MsgSaveNumberInvalid, 1)); return; }
@ -454,9 +472,11 @@ namespace PKHeX.WinForms
bool[] oldBits = s1.EventFlags; bool[] oldBits = s1.EventFlags;
bool[] newBits = s2.EventFlags; bool[] newBits = s2.EventFlags;
if (oldBits.Length != newBits.Length) if (oldBits.Length != newBits.Length)
{
throw new Exception("Event flag lengths for games are different." + throw new Exception("Event flag lengths for games are different." +
$"{Environment.NewLine}S1: {(GameVersion)s1.Game}" + $"{Environment.NewLine}S1: {(GameVersion)s1.Game}" +
$"{Environment.NewLine}S2: {(GameVersion)s2.Game}"); $"{Environment.NewLine}S2: {(GameVersion)s2.Game}");
}
for (int i = 0; i < oldBits.Length; i++) for (int i = 0; i < oldBits.Length; i++)
{ {
@ -484,8 +504,10 @@ namespace PKHeX.WinForms
{ WinFormsUtil.Alert("Event flag lengths for games are different.", $"S1: {(GameVersion)s1.Game}", $"S2: {(GameVersion)s2.Game}"); return; } { WinFormsUtil.Alert("Event flag lengths for games are different.", $"S1: {(GameVersion)s1.Game}", $"S2: {(GameVersion)s2.Game}"); return; }
for (int i = 0; i < newConst.Length; i++) for (int i = 0; i < newConst.Length; i++)
{
if (oldConst[i] != newConst[i]) if (oldConst[i] != newConst[i])
r += $"{i}: {oldConst[i]}->{newConst[i]}{Environment.NewLine}"; r += $"{i}: {oldConst[i]}->{newConst[i]}{Environment.NewLine}";
}
} }
catch (Exception e) catch (Exception e)
{ {
@ -508,6 +530,7 @@ namespace PKHeX.WinForms
{ {
if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Copy; if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Copy;
} }
private void Main_DragDrop(object sender, DragEventArgs e) private void Main_DragDrop(object sender, DragEventArgs e)
{ {
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);

View file

@ -9,6 +9,7 @@ namespace PKHeX.WinForms
public partial class SAV_GameSelect : Form public partial class SAV_GameSelect : Form
{ {
public GameVersion Result = GameVersion.Invalid; public GameVersion Result = GameVersion.Invalid;
public SAV_GameSelect(IEnumerable<ComboItem> items) public SAV_GameSelect(IEnumerable<ComboItem> items)
{ {
InitializeComponent(); InitializeComponent();
@ -18,12 +19,15 @@ namespace PKHeX.WinForms
CB_Game.SelectedIndex = 0; CB_Game.SelectedIndex = 0;
CB_Game.Focus(); CB_Game.Focus();
} }
private void B_Cancel_Click(object sender, EventArgs e) => Close(); private void B_Cancel_Click(object sender, EventArgs e) => Close();
private void B_OK_Click(object sender, EventArgs e) private void B_OK_Click(object sender, EventArgs e)
{ {
Result = (GameVersion)WinFormsUtil.GetIndex(CB_Game); Result = (GameVersion)WinFormsUtil.GetIndex(CB_Game);
Close(); Close();
} }
private void SAV_GameSelect_KeyDown(object sender, KeyEventArgs e) private void SAV_GameSelect_KeyDown(object sender, KeyEventArgs e)
{ {
if (e.KeyCode == Keys.Enter) if (e.KeyCode == Keys.Enter)

View file

@ -11,6 +11,7 @@ namespace PKHeX.WinForms
{ {
private readonly SaveFile Origin; private readonly SaveFile Origin;
private readonly SaveFile SAV; private readonly SaveFile SAV;
public SAV_Inventory(SaveFile sav) public SAV_Inventory(SaveFile sav)
{ {
InitializeComponent(); InitializeComponent();
@ -19,8 +20,10 @@ namespace PKHeX.WinForms
itemlist = GameInfo.Strings.GetItemStrings(SAV.Generation, SAV.Version).ToArray(); itemlist = GameInfo.Strings.GetItemStrings(SAV.Generation, SAV.Version).ToArray();
for (int i = 0; i < itemlist.Length; i++) for (int i = 0; i < itemlist.Length; i++)
{
if (itemlist[i]?.Length == 0) if (itemlist[i]?.Length == 0)
itemlist[i] = $"(Item #{i:000})"; itemlist[i] = $"(Item #{i:000})";
}
HasFreeSpace = SAV.Generation == 7; HasFreeSpace = SAV.Generation == 7;
HasNew = CHK_NEW.Visible = SAV.Generation == 7; HasNew = CHK_NEW.Visible = SAV.Generation == 7;
@ -40,6 +43,7 @@ namespace PKHeX.WinForms
{ {
Close(); Close();
} }
private void B_Save_Click(object sender, EventArgs e) private void B_Save_Click(object sender, EventArgs e)
{ {
SetBags(); SetBags();
@ -64,6 +68,7 @@ namespace PKHeX.WinForms
tabControl1.TabPages[i].Controls.Add(GetDGV(Pouches[i])); tabControl1.TabPages[i].Controls.Add(GetDGV(Pouches[i]));
} }
} }
private DataGridView GetDGV(InventoryPouch pouch) private DataGridView GetDGV(InventoryPouch pouch)
{ {
// Add DataGrid // Add DataGrid
@ -146,6 +151,7 @@ namespace PKHeX.WinForms
return dgv; return dgv;
} }
private void GetBags() private void GetBags()
{ {
foreach (InventoryPouch pouch in Pouches) foreach (InventoryPouch pouch in Pouches)
@ -166,6 +172,7 @@ namespace PKHeX.WinForms
GetBag(dgv, pouch); GetBag(dgv, pouch);
} }
} }
private void SetBags() private void SetBags()
{ {
foreach (InventoryPouch t in Pouches) foreach (InventoryPouch t in Pouches)
@ -174,6 +181,7 @@ namespace PKHeX.WinForms
SetBag(dgv, t); SetBag(dgv, t);
} }
} }
private void GetBag(DataGridView dgv, InventoryPouch pouch) private void GetBag(DataGridView dgv, InventoryPouch pouch)
{ {
for (int i = 0; i < dgv.Rows.Count; i++) for (int i = 0; i < dgv.Rows.Count; i++)
@ -187,6 +195,7 @@ namespace PKHeX.WinForms
dgv.Rows[i].Cells[c].Value = pouch.Items[i].New; dgv.Rows[i].Cells[c].Value = pouch.Items[i].New;
} }
} }
private void SetBag(DataGridView dgv, InventoryPouch pouch) private void SetBag(DataGridView dgv, InventoryPouch pouch)
{ {
int ctr = 0; int ctr = 0;
@ -217,7 +226,9 @@ namespace PKHeX.WinForms
itemcnt = pouch.MaxCount; // Cap at pouch maximum itemcnt = pouch.MaxCount; // Cap at pouch maximum
} }
else if (itemcnt <= 0 && !HasNew) else if (itemcnt <= 0 && !HasNew)
{
continue; // ignore item continue; // ignore item
}
pouch.Items[ctr] = new InventoryItem { Index = itemindex, Count = itemcnt }; pouch.Items[ctr] = new InventoryItem { Index = itemindex, Count = itemcnt };
if (HasFreeSpace) if (HasFreeSpace)
@ -234,18 +245,7 @@ namespace PKHeX.WinForms
{ {
int index = tabControl1.SelectedIndex; int index = tabControl1.SelectedIndex;
var pouch = Pouches[index]; var pouch = Pouches[index];
if (Main.HaX) NUD_Count.Maximum = GetMax(SAV, pouch, Main.HaX);
{
// Cap at absolute maximum
if (SAV.Generation <= 2)
NUD_Count.Maximum = byte.MaxValue;
else if (SAV.Generation >= 7)
NUD_Count.Maximum = pouch.MaxCount;
else // if (SAV.Generation >= 3)
NUD_Count.Maximum = ushort.MaxValue;
}
else
NUD_Count.Maximum = pouch.MaxCount;
bool disable = pouch.Type == InventoryType.PCItems || pouch.Type == InventoryType.FreeSpace; bool disable = pouch.Type == InventoryType.PCItems || pouch.Type == InventoryType.FreeSpace;
NUD_Count.Visible = L_Count.Visible = B_GiveAll.Visible = !disable; NUD_Count.Visible = L_Count.Visible = B_GiveAll.Visible = !disable;
@ -262,8 +262,23 @@ namespace PKHeX.WinForms
NUD_Count.Value = Math.Max(1, pouch.MaxCount - 4); NUD_Count.Value = Math.Max(1, pouch.MaxCount - 4);
} }
private static int GetMax(ITrainerInfo sav, InventoryPouch pouch, bool haX)
{
if (haX)
return pouch.MaxCount;
// Cap at absolute maximum
if (sav.Generation <= 2)
return byte.MaxValue;
if (sav.Generation >= 7)
return pouch.MaxCount;
// if (SAV.Generation >= 3)
return ushort.MaxValue;
}
// Initialize String Tables // Initialize String Tables
private readonly string[] itemlist; private readonly string[] itemlist;
private string[] GetItems(ushort[] items, bool sort = true) private string[] GetItems(ushort[] items, bool sort = true)
{ {
string[] res = new string[items.Length + 1]; string[] res = new string[items.Length + 1];
@ -277,11 +292,13 @@ namespace PKHeX.WinForms
// User Cheats // User Cheats
private int CurrentPouch => tabControl1.SelectedIndex; private int CurrentPouch => tabControl1.SelectedIndex;
private void B_GiveAll_Click(object sender, EventArgs e) private void B_GiveAll_Click(object sender, EventArgs e)
{ {
Button btn = (Button)sender; Button btn = (Button)sender;
giveMenu.Show(btn.PointToScreen(new Point(0, btn.Height))); giveMenu.Show(btn.PointToScreen(new Point(0, btn.Height)));
} }
private void GiveAllItems(object sender, EventArgs e) private void GiveAllItems(object sender, EventArgs e)
{ {
// Get Current Pouch // Get Current Pouch
@ -329,6 +346,7 @@ namespace PKHeX.WinForms
} }
System.Media.SystemSounds.Asterisk.Play(); System.Media.SystemSounds.Asterisk.Play();
} }
private static bool IsItemCount1(ushort item, SaveFile sav) private static bool IsItemCount1(ushort item, SaveFile sav)
{ {
switch (sav.Generation) switch (sav.Generation)
@ -343,6 +361,7 @@ namespace PKHeX.WinForms
return new[] {420, 421, 422, 423, 423, 424, 425, 426, 427, 737}.Contains(item); return new[] {420, 421, 422, 423, 423, 424, 425, 426, 427, 737}.Contains(item);
} }
} }
private void RemoveAllItems(object sender, EventArgs e) private void RemoveAllItems(object sender, EventArgs e)
{ {
// Get Current Pouch // Get Current Pouch
@ -364,6 +383,7 @@ namespace PKHeX.WinForms
} }
WinFormsUtil.Alert(MsgItemCleared); WinFormsUtil.Alert(MsgItemCleared);
} }
private void ModifyAllItems(object sender, EventArgs e) private void ModifyAllItems(object sender, EventArgs e)
{ {
// Get Current Pouch // Get Current Pouch
@ -382,11 +402,13 @@ namespace PKHeX.WinForms
} }
WinFormsUtil.Alert(MsgItemPouchCountUpdated); WinFormsUtil.Alert(MsgItemPouchCountUpdated);
} }
private void B_Sort_Click(object sender, EventArgs e) private void B_Sort_Click(object sender, EventArgs e)
{ {
Button btn = (Button)sender; Button btn = (Button)sender;
sortMenu.Show(btn.PointToScreen(new Point(0, btn.Height))); sortMenu.Show(btn.PointToScreen(new Point(0, btn.Height)));
} }
private void SortByName(object sender, EventArgs e) private void SortByName(object sender, EventArgs e)
{ {
int pouch = CurrentPouch; int pouch = CurrentPouch;
@ -399,6 +421,7 @@ namespace PKHeX.WinForms
p.SortByName(itemlist, reverse:true); p.SortByName(itemlist, reverse:true);
GetBag(dgv, p); GetBag(dgv, p);
} }
private void SortByCount(object sender, EventArgs e) private void SortByCount(object sender, EventArgs e)
{ {
int pouch = CurrentPouch; int pouch = CurrentPouch;
@ -411,6 +434,7 @@ namespace PKHeX.WinForms
p.SortByCount(reverse:true); p.SortByCount(reverse:true);
GetBag(dgv, p); GetBag(dgv, p);
} }
private void SortByIndex(object sender, EventArgs e) private void SortByIndex(object sender, EventArgs e)
{ {
int pouch = CurrentPouch; int pouch = CurrentPouch;

View file

@ -11,6 +11,7 @@ namespace PKHeX.WinForms
{ {
private readonly SaveFile Origin; private readonly SaveFile Origin;
private readonly SaveFile SAV; private readonly SaveFile SAV;
public SAV_MailBox(SaveFile sav) public SAV_MailBox(SaveFile sav)
{ {
InitializeComponent(); InitializeComponent();
@ -155,6 +156,7 @@ namespace PKHeX.WinForms
editing = false; editing = false;
LB_PartyHeld.SelectedIndex = 0; LB_PartyHeld.SelectedIndex = 0;
} }
private readonly int[] HoennListMixed = { private readonly int[] HoennListMixed = {
277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300, 277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,
304,305,309,310,392,393,394,311,312,306,307,364,365,366,301,302,303,370,371,372,335,336,350,320,315,316, 304,305,309,310,392,393,394,311,312,306,307,364,365,366,301,302,303,370,371,372,335,336,350,320,315,316,
@ -164,11 +166,13 @@ namespace PKHeX.WinForms
346,347,341,342,343,373,374,375,381,325,395,396,397,398,399,400, 346,347,341,342,343,373,374,375,381,325,395,396,397,398,399,400,
401,402,403,407,408,404,405,406,409,410 401,402,403,407,408,404,405,406,409,410
}; };
private void LoadList() private void LoadList()
{ {
if (entry < 6) MakePartyList(); if (entry < 6) MakePartyList();
else MakePCList(); else MakePCList();
} }
private void MakePartyList() private void MakePartyList()
{ {
LB_PartyHeld.BeginUpdate(); LB_PartyHeld.BeginUpdate();
@ -180,6 +184,7 @@ namespace PKHeX.WinForms
LB_PartyHeld.SelectedIndex = s; LB_PartyHeld.SelectedIndex = s;
LB_PartyHeld.EndUpdate(); LB_PartyHeld.EndUpdate();
} }
private void MakePCList() private void MakePCList()
{ {
LB_PCBOX.BeginUpdate(); LB_PCBOX.BeginUpdate();
@ -211,6 +216,7 @@ namespace PKHeX.WinForms
LB_PCBOX.SelectedIndex = s; LB_PCBOX.SelectedIndex = s;
LB_PCBOX.EndUpdate(); LB_PCBOX.EndUpdate();
} }
private void LoadPKM(bool isInit) private void LoadPKM(bool isInit)
{ {
for (int i = 0; i < p.Count; i++) for (int i = 0; i < p.Count; i++)
@ -226,6 +232,7 @@ namespace PKHeX.WinForms
PKMNUDs[i].Value = k >= -1 && k <= 5 ? k : -1; PKMNUDs[i].Value = k >= -1 && k <= 5 ? k : -1;
} }
} }
private readonly Mail[] m; private readonly Mail[] m;
private bool editing; private bool editing;
private int entry; private int entry;
@ -235,6 +242,7 @@ namespace PKHeX.WinForms
private readonly ComboBox[] AppearPKMs; private readonly ComboBox[] AppearPKMs;
private readonly int Gen; private readonly int Gen;
private readonly byte ResetVer, ResetLang; private readonly byte ResetVer, ResetLang;
private void Save() private void Save()
{ {
switch (Gen) switch (Gen)
@ -247,7 +255,7 @@ namespace PKHeX.WinForms
Array.Copy(SAV.Data, ofs, SAV.Data, ofs + len, len); Array.Copy(SAV.Data, ofs, SAV.Data, ofs + len, len);
ofs += len << 1; ofs += len << 1;
SAV.Data[ofs] = (byte)NUD_BoxSize.Value; SAV.Data[ofs] = (byte)NUD_BoxSize.Value;
len = 0x2F * 10 + 1; len = (0x2F * 10) + 1;
Array.Copy(SAV.Data, ofs, SAV.Data, ofs + len, len); Array.Copy(SAV.Data, ofs, SAV.Data, ofs + len, len);
break; break;
case 3: case 3:
@ -270,6 +278,7 @@ namespace PKHeX.WinForms
} }
SAV.PartyData = p; SAV.PartyData = p;
} }
private void TempSave() private void TempSave()
{ {
switch (m[entry]) switch (m[entry])
@ -288,8 +297,11 @@ namespace PKHeX.WinForms
m3.MailType = CBIndexToMailType(CB_MailType.SelectedIndex); m3.MailType = CBIndexToMailType(CB_MailType.SelectedIndex);
for (int y = 0; y < 3; y++) for (int y = 0; y < 3; y++)
{
for (int x = 0; x < 3; x++) for (int x = 0; x < 3; x++)
m3.SetMessage(y, x, (ushort)Messages[y][x].Value); m3.SetMessage(y, x, (ushort)Messages[y][x].Value);
}
m3.AuthorSID = (ushort)NUD_AuthorSID.Value; m3.AuthorSID = (ushort)NUD_AuthorSID.Value;
int v = CB_AppearPKM1.SelectedValue as int? ?? 0; int v = CB_AppearPKM1.SelectedValue as int? ?? 0;
m3.AppearPKM = v < 252 ? v : HoennListMixed[v - 252]; m3.AppearPKM = v < 252 ? v : HoennListMixed[v - 252];
@ -301,8 +313,11 @@ namespace PKHeX.WinForms
m4.MailType = v > 0 ? v - 1 : 0xFF; m4.MailType = v > 0 ? v - 1 : 0xFF;
for (int y = 0; y < 3; y++) for (int y = 0; y < 3; y++)
{
for (int x = 0; x < 4; x++) for (int x = 0; x < 4; x++)
m4.SetMessage(y, x, (ushort)Messages[y][x].Value); m4.SetMessage(y, x, (ushort)Messages[y][x].Value);
}
m4.AuthorSID = (ushort)NUD_AuthorSID.Value; m4.AuthorSID = (ushort)NUD_AuthorSID.Value;
for (int i = 0; i < AppearPKMs.Length; i++) for (int i = 0; i < AppearPKMs.Length; i++)
m4.SetAppearPKM(i, (AppearPKMs[i].SelectedValue as int?) + 7 ?? 0); m4.SetAppearPKM(i, (AppearPKMs[i].SelectedValue as int?) + 7 ?? 0);
@ -318,8 +333,11 @@ namespace PKHeX.WinForms
m5.MailType = v > 0 ? v - 1 : 0xFF; m5.MailType = v > 0 ? v - 1 : 0xFF;
for (int y = 0; y < 3; y++) for (int y = 0; y < 3; y++)
{
for (int x = 0; x < 4; x++) for (int x = 0; x < 4; x++)
m5.SetMessage(y, x, (ushort)Messages[y][x].Value); m5.SetMessage(y, x, (ushort)Messages[y][x].Value);
}
m5.AuthorSID = (ushort)NUD_AuthorSID.Value; m5.AuthorSID = (ushort)NUD_AuthorSID.Value;
for (int i = 0; i < Miscs.Length; i++) for (int i = 0; i < Miscs.Length; i++)
m5.SetMisc(i, (ushort)Miscs[i].Value); m5.SetMisc(i, (ushort)Miscs[i].Value);
@ -329,6 +347,7 @@ namespace PKHeX.WinForms
break; break;
} }
} }
private string CheckValid() private string CheckValid()
{ {
string ret = ""; string ret = "";
@ -353,7 +372,9 @@ namespace PKHeX.WinForms
ret += $"{Environment.NewLine}Party#{i + 1} MailID mismatch"; ret += $"{Environment.NewLine}Party#{i + 1} MailID mismatch";
} }
else if (h != -1) //C else if (h != -1) //C
{
ret += $"{Environment.NewLine}Party#{i + 1} MailID mismatch"; ret += $"{Environment.NewLine}Party#{i + 1} MailID mismatch";
}
} }
for (int i = 0; i < 6; i++) for (int i = 0; i < 6; i++)
{ {
@ -376,7 +397,9 @@ namespace PKHeX.WinForms
ret += $"{Environment.NewLine}MailID{i} MailType mismatch"; ret += $"{Environment.NewLine}MailID{i} MailType mismatch";
} }
else if (m[i].IsEmpty == false) //Q else if (m[i].IsEmpty == false) //Q
{
ret += $"{Environment.NewLine}MailID{i} MailType mismatch"; ret += $"{Environment.NewLine}MailID{i} MailType mismatch";
}
} }
} }
// Gen5 // Gen5
@ -396,8 +419,10 @@ namespace PKHeX.WinForms
// Gen* // Gen*
// Z: mail type is illegal // Z: mail type is illegal
for (int i = 0; i < m.Length; i++) for (int i = 0; i < m.Length; i++)
{
if (m[i].IsEmpty == null) // Z if (m[i].IsEmpty == null) // Z
ret += $"{Environment.NewLine}MailID{i} MailType mismatch"; ret += $"{Environment.NewLine}MailID{i} MailType mismatch";
}
return ret; return ret;
} }
@ -414,17 +439,20 @@ namespace PKHeX.WinForms
Origin.SetData(SAV.Data, 0); Origin.SetData(SAV.Data, 0);
Close(); Close();
} }
private bool ItemIsMail(int itemID) => Array.IndexOf(MailItemID, itemID) >= 0; private bool ItemIsMail(int itemID) => Array.IndexOf(MailItemID, itemID) >= 0;
private int MailTypeToCBIndex(int mailtype) => 1 + Array.IndexOf(MailItemID, mailtype); private int MailTypeToCBIndex(int mailtype) => 1 + Array.IndexOf(MailItemID, mailtype);
private int CBIndexToMailType(int cbindex) => cbindex <= 0 ? 0 : cbindex <= MailItemID.Length ? MailItemID[cbindex - 1] : MailItemID[0]; private int CBIndexToMailType(int cbindex) => cbindex <= 0 ? 0 : cbindex <= MailItemID.Length ? MailItemID[cbindex - 1] : MailItemID[0];
private readonly int[] MailItemID; private readonly int[] MailItemID;
private readonly IList<PKM> p; private readonly IList<PKM> p;
private string GetSpeciesNameFromCB(int index) private string GetSpeciesNameFromCB(int index)
{ {
foreach (ComboItem i in CB_AppearPKM1.Items) foreach (ComboItem i in CB_AppearPKM1.Items)
if (index == i.Value) return i.Text; if (index == i.Value) return i.Text;
return "PKM"; return "PKM";
} }
private DialogResult ModifyHeldItem() private DialogResult ModifyHeldItem()
{ {
DialogResult ret = DialogResult.Abort; DialogResult ret = DialogResult.Abort;
@ -438,6 +466,7 @@ namespace PKHeX.WinForms
LoadPKM(false); LoadPKM(false);
return ret; return ret;
} }
private void B_Delete_Click(object sender, EventArgs e) private void B_Delete_Click(object sender, EventArgs e)
{ {
if (entry < 0) return; if (entry < 0) return;
@ -457,6 +486,7 @@ namespace PKHeX.WinForms
LoadMail(); LoadMail();
editing = false; editing = false;
} }
private void EntryControl(object sender, EventArgs e) private void EntryControl(object sender, EventArgs e)
{ {
if (editing) return; if (editing) return;
@ -486,6 +516,7 @@ namespace PKHeX.WinForms
if (entry >= 0) LoadMail(); if (entry >= 0) LoadMail();
editing = false; editing = false;
} }
private void LoadMail() private void LoadMail()
{ {
switch (m[entry]) switch (m[entry])
@ -505,8 +536,11 @@ namespace PKHeX.WinForms
CB_MailType.SelectedIndex = MailTypeToCBIndex(m3.MailType); CB_MailType.SelectedIndex = MailTypeToCBIndex(m3.MailType);
for (int y = 0; y < 3; y++) for (int y = 0; y < 3; y++)
{
for (int x = 0; x < 3; x++) for (int x = 0; x < 3; x++)
Messages[y][x].Value = m3.GetMessage(y, x); Messages[y][x].Value = m3.GetMessage(y, x);
}
NUD_AuthorSID.Value = m3.AuthorSID; NUD_AuthorSID.Value = m3.AuthorSID;
int v = Array.IndexOf(HoennListMixed, m3.AppearPKM); int v = Array.IndexOf(HoennListMixed, m3.AppearPKM);
AppearPKMs[0].SelectedValue = m3.AppearPKM < 252 ? m3.AppearPKM : v >= 0 ? 252 + v : 0; AppearPKMs[0].SelectedValue = m3.AppearPKM < 252 ? m3.AppearPKM : v >= 0 ? 252 + v : 0;
@ -517,8 +551,11 @@ namespace PKHeX.WinForms
CB_MailType.SelectedIndex = m4.IsEmpty == false ? m4.MailType + 1 : 0; CB_MailType.SelectedIndex = m4.IsEmpty == false ? m4.MailType + 1 : 0;
for (int y = 0; y < 3; y++) for (int y = 0; y < 3; y++)
{
for (int x = 0; x < 4; x++) for (int x = 0; x < 4; x++)
Messages[y][x].Value = m4.GetMessage(y, x); Messages[y][x].Value = m4.GetMessage(y, x);
}
NUD_AuthorSID.Value = m4.AuthorSID; NUD_AuthorSID.Value = m4.AuthorSID;
for (int i = 0; i < AppearPKMs.Length; i++) for (int i = 0; i < AppearPKMs.Length; i++)
AppearPKMs[i].SelectedValue = Math.Max(0, m4.GetAppearPKM(i) - 7); AppearPKMs[i].SelectedValue = Math.Max(0, m4.GetAppearPKM(i) - 7);
@ -532,8 +569,11 @@ namespace PKHeX.WinForms
CB_MailType.SelectedIndex = m5.IsEmpty == false ? m5.MailType + 1 : 0; CB_MailType.SelectedIndex = m5.IsEmpty == false ? m5.MailType + 1 : 0;
for (int y = 0; y < 3; y++) for (int y = 0; y < 3; y++)
{
for (int x = 0; x < 4; x++) for (int x = 0; x < 4; x++)
Messages[y][x].Value = m5.GetMessage(y, x); Messages[y][x].Value = m5.GetMessage(y, x);
}
NUD_AuthorSID.Value = m5.AuthorSID; NUD_AuthorSID.Value = m5.AuthorSID;
for (int i = 0; i < Miscs.Length; i++) for (int i = 0; i < Miscs.Length; i++)
Miscs[i].Value = m5.GetMisc(i); Miscs[i].Value = m5.GetMisc(i);
@ -546,11 +586,13 @@ namespace PKHeX.WinForms
} }
private readonly string[] gendersymbols = { "♂", "♀" }; private readonly string[] gendersymbols = { "♂", "♀" };
private void LoadOTlabel(int b) private void LoadOTlabel(int b)
{ {
Label_OTGender.Text = gendersymbols[b & 1]; Label_OTGender.Text = gendersymbols[b & 1];
Label_OTGender.ForeColor = b == 1 ? Color.Red : Color.Blue; Label_OTGender.ForeColor = b == 1 ? Color.Red : Color.Blue;
} }
private void Label_OTGender_Click(object sender, EventArgs e) private void Label_OTGender_Click(object sender, EventArgs e)
{ {
if (entry < 0) return; if (entry < 0) return;

View file

@ -9,6 +9,7 @@ namespace PKHeX.WinForms
{ {
private readonly SaveFile Origin; private readonly SaveFile Origin;
private readonly SaveFile SAV; private readonly SaveFile SAV;
public SAV_SimpleTrainer(SaveFile sav) public SAV_SimpleTrainer(SaveFile sav)
{ {
InitializeComponent(); InitializeComponent();
@ -152,6 +153,7 @@ namespace PKHeX.WinForms
Loading = false; Loading = false;
} }
private readonly CheckBox[] cba; private readonly CheckBox[] cba;
private readonly bool Loading; private readonly bool Loading;
private bool MapUpdated; private bool MapUpdated;
@ -162,6 +164,7 @@ namespace PKHeX.WinForms
if (box.Text.Length == 0) box.Text = "0"; if (box.Text.Length == 0) box.Text = "0";
if (Util.ToInt32(box.Text) > 65535) box.Text = "65535"; if (Util.ToInt32(box.Text) > 65535) box.Text = "65535";
} }
private void Change255(object sender, EventArgs e) private void Change255(object sender, EventArgs e)
{ {
MaskedTextBox box = (MaskedTextBox)sender; MaskedTextBox box = (MaskedTextBox)sender;
@ -249,10 +252,12 @@ namespace PKHeX.WinForms
Origin.SetData(SAV.Data, 0); Origin.SetData(SAV.Data, 0);
Close(); Close();
} }
private void B_Cancel_Click(object sender, EventArgs e) private void B_Cancel_Click(object sender, EventArgs e)
{ {
Close(); Close();
} }
private static int GetSeconds(DateTimePicker date, DateTimePicker time) private static int GetSeconds(DateTimePicker date, DateTimePicker time)
{ {
int val = (int)(date.Value - new DateTime(2000, 1, 1)).TotalSeconds; int val = (int)(date.Value - new DateTime(2000, 1, 1)).TotalSeconds;
@ -260,6 +265,7 @@ namespace PKHeX.WinForms
val += (int)(time.Value - new DateTime(2000, 1, 1)).TotalSeconds; val += (int)(time.Value - new DateTime(2000, 1, 1)).TotalSeconds;
return val; return val;
} }
private void ChangeMapValue(object sender, EventArgs e) private void ChangeMapValue(object sender, EventArgs e)
{ {
if (!Loading) if (!Loading)

View file

@ -5,9 +5,11 @@ using System.Runtime.InteropServices;
namespace PKHeX.WinForms namespace PKHeX.WinForms
{ {
/// <summary>
/// Image Layering/Blending Utility
/// </summary>
public static class ImageUtil public static class ImageUtil
{ {
// Image Layering/Blending Utility
public static Bitmap LayerImage(Image baseLayer, Image overLayer, int x, int y, double transparency) public static Bitmap LayerImage(Image baseLayer, Image overLayer, int x, int y, double transparency)
{ {
if (baseLayer == null) if (baseLayer == null)
@ -109,8 +111,10 @@ namespace PKHeX.WinForms
public static void SetAllUsedPixelsOpaque(byte[] data) public static void SetAllUsedPixelsOpaque(byte[] data)
{ {
for (int i = 0; i < data.Length; i += 4) for (int i = 0; i < data.Length; i += 4)
{
if (data[i + 3] != 0) if (data[i + 3] != 0)
data[i + 3] = 0xFF; data[i + 3] = 0xFF;
}
} }
public static void RemovePixels(byte[] pixels, byte[] original) public static void RemovePixels(byte[] pixels, byte[] original)

View file

@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection;
using System.Windows.Forms; using System.Windows.Forms;
using static PKHeX.Core.MessageStrings; using static PKHeX.Core.MessageStrings;
@ -104,6 +105,13 @@ namespace PKHeX.WinForms
} }
} }
public static void DoubleBuffered(this DataGridView dgv, bool setting)
{
Type dgvType = dgv.GetType();
PropertyInfo pi = dgvType.GetProperty("DoubleBuffered", BindingFlags.Instance | BindingFlags.NonPublic);
pi.SetValue(dgv, setting, null);
}
/// <summary> /// <summary>
/// Initializes the <see cref="control"/> to be bound to a provided <see cref="ComboItem"/> list. /// Initializes the <see cref="control"/> to be bound to a provided <see cref="ComboItem"/> list.
/// </summary> /// </summary>