Enhance gen6 dex interactions

Uses the rewritten Gen5 object as the base rather than the old zukan abstraction
Adds National Dex unlocked flag for editing

probably best to extract an interface as there's no need to have a shared abstract Zukan class across generations.
This commit is contained in:
Kurt 2025-08-05 09:55:58 -05:00
parent ceff28210a
commit 28e20c4ea3
11 changed files with 917 additions and 744 deletions

View File

@ -86,7 +86,7 @@ public sealed class SaveBlockAccessor6AO(SAV6AO sav) : ISaveBlockAccessor<BlockI
public BattleBox6 BattleBox { get; } = new(sav, Block(sav, 13));
public MyStatus6 Status { get; } = new(sav, Block(sav, 17));
public EventWork6 EventWork { get; } = new(sav, Block(sav, 19));
public Zukan6AO Zukan { get; } = new(sav, Block(sav, 20), 0x400);
public Zukan6AO Zukan { get; } = new(Block(sav, 20));
public UnionPokemon6 Fused { get; } = new(sav, Block(sav, 22));
public ConfigSave6 Config { get; } = new(sav, Block(sav, 23));
public OPower6 OPower { get; } = new(sav, Block(sav, 25));

View File

@ -84,7 +84,7 @@ public sealed class SaveBlockAccessor6XY(SAV6XY sav) : ISaveBlockAccessor<BlockI
public BattleBox6 BattleBox { get; } = new(sav, Block(sav, 13));
public MyStatus6XY Status { get; } = new(sav, Block(sav, 17));
public EventWork6 EventWork { get; } = new(sav, Block(sav, 19));
public Zukan6XY Zukan { get; } = new(sav, Block(sav, 20), 0x3C8);
public Zukan6XY Zukan { get; } = new(Block(sav, 20));
public UnionPokemon6 Fused { get; } = new(sav, Block(sav, 22));
public ConfigSave6 Config { get; } = new(sav, Block(sav, 23));
public OPower6 OPower { get; } = new(sav, Block(sav, 25));

View File

@ -66,7 +66,7 @@ public int CaughtCount
}
/// <summary>
/// Base class for Pokédex operations, exposing the shared structure features used by Generations 5, 6, and 7.
/// Base class for Pokédex operations, exposing the shared structure features used by Generation 7.
/// </summary>
public abstract class Zukan<T>(T sav, Memory<byte> raw, int langflag) : ZukanBase<T>(sav, raw)
where T : SaveFile

View File

@ -83,6 +83,9 @@ public abstract class Zukan5(Memory<byte> raw)
public ushort InitialSpecies { get => (ushort)((Packed >> 12) & 0x3FF); set => Packed = (Packed & ~0x3FF000u) | ((uint)value << 12); } // bit 12-21
// remaining 10 bits are unused
private const ushort MaxSpecies = Legal.MaxSpeciesID_5;
private const ushort MaxSpeciesLanguage = Legal.MaxSpeciesID_4;
private const int OFS_CAUGHT = 0x8;
private const int OFS_SEEN = OFS_CAUGHT + BitSeenSize; // 0x5C
private const int OFS_DISP = OFS_SEEN + (BitSeenSize * 4); // 0x1AC
@ -111,7 +114,7 @@ public bool GetSeen(ushort species, byte gender, bool isShiny)
public bool GetSeen(ushort species, int region)
{
if (species is 0 or > Legal.MaxSpeciesID_5)
if (species is 0 or > MaxSpecies)
return false;
int bit = species - 1;
return GetFlag(OFS_SEEN + (region * BitSeenSize), bit);
@ -125,7 +128,7 @@ public void SetSeen(ushort species, byte gender, bool isShiny, bool value = true
public void SetSeen(ushort species, int region, bool value = true)
{
if (species is 0 or > Legal.MaxSpeciesID_5)
if (species is 0 or > MaxSpecies)
return;
int bit = species - 1;
SetFlag(OFS_SEEN + (region * BitSeenSize), bit, value);
@ -133,7 +136,7 @@ public void SetSeen(ushort species, int region, bool value = true)
public bool GetSeen(ushort species)
{
if (species is 0 or > Legal.MaxSpeciesID_5)
if (species is 0 or > MaxSpecies)
return false;
int bit = species - 1;
for (int i = 0; i < 4; i++)
@ -146,7 +149,7 @@ public bool GetSeen(ushort species)
public void ClearSeen(ushort species)
{
if (species is 0 or > Legal.MaxSpeciesID_5)
if (species is 0 or > MaxSpecies)
return;
int bit = species - 1;
for (int i = 0; i < 4; i++)
@ -155,7 +158,7 @@ public void ClearSeen(ushort species)
public bool GetCaught(ushort species)
{
if (species is 0 or > Legal.MaxSpeciesID_5)
if (species is 0 or > MaxSpecies)
return false;
int bit = species - 1;
return GetFlag(OFS_CAUGHT, bit);
@ -163,7 +166,7 @@ public bool GetCaught(ushort species)
public void SetCaught(ushort species, bool value = true)
{
if (species is 0 or > Legal.MaxSpeciesID_5)
if (species is 0 or > MaxSpecies)
return;
int bit = species - 1;
SetFlag(OFS_CAUGHT, bit, value);
@ -177,7 +180,7 @@ public bool GetDisplayed(ushort species, byte gender, bool isShiny)
public bool GetDisplayed(ushort species, int region)
{
if (species is 0 or > Legal.MaxSpeciesID_5)
if (species is 0 or > MaxSpecies)
return false;
int bit = species - 1;
return GetFlag(OFS_DISP + (region * BitSeenSize), bit);
@ -185,7 +188,7 @@ public bool GetDisplayed(ushort species, int region)
public bool GetDisplayedAny(ushort species)
{
if (species is 0 or > Legal.MaxSpeciesID_5)
if (species is 0 or > MaxSpecies)
return false;
// Check Displayed Status for base form
int bit = species - 1;
@ -205,7 +208,7 @@ public void SetDisplayed(ushort species, byte gender, bool isShiny, bool value =
public void SetDisplayed(ushort species, int region, bool value = true)
{
if (species is 0 or > Legal.MaxSpeciesID_5)
if (species is 0 or > MaxSpecies)
return;
int bit = species - 1;
SetFlag(OFS_DISP + (region * BitSeenSize), bit, value);
@ -213,7 +216,7 @@ public void SetDisplayed(ushort species, int region, bool value = true)
public void ClearDisplayed(ushort species)
{
if (species is 0 or > Legal.MaxSpeciesID_5)
if (species is 0 or > MaxSpecies)
return;
int bit = species - 1;
for (int i = 0; i < 4; i++)
@ -230,7 +233,7 @@ public bool GetLanguageFlag(ushort species, LanguageID language)
public bool GetLanguageFlag(ushort species, int langIndex)
{
if (species is 0 or > Legal.MaxSpeciesID_4) // no Gen5
if (species is 0 or > MaxSpeciesLanguage) // no Gen5
return false;
int bit = species - 1;
int lbit = (bit * DexLangIDCount) + langIndex;
@ -247,7 +250,7 @@ public void SetLanguageFlag(ushort species, LanguageID langIndex, bool isLanguag
public void SetLanguageFlag(ushort species, int index, bool isLanguageSet)
{
if (species is 0 or > Legal.MaxSpeciesID_4) // no Gen5
if (species is 0 or > MaxSpeciesLanguage) // no Gen5
return;
int bit = species - 1;
int lbit = (bit * DexLangIDCount) + index;
@ -256,7 +259,7 @@ public void SetLanguageFlag(ushort species, int index, bool isLanguageSet)
public void SetAllLanguage(ushort species, bool isLanguageSet = true)
{
if (species is 0 or > Legal.MaxSpeciesID_4) // no Gen5
if (species is 0 or > MaxSpeciesLanguage) // no Gen5
return;
int bit = species - 1;
for (int i = 0; i < DexLangIDCount; i++)
@ -317,7 +320,7 @@ public void SetFormDisplayed(int formIndex, bool isShiny, bool value = true)
public void SetDex(PKM pk)
{
if (pk.Species is 0 or > Legal.MaxSpeciesID_5)
if (pk.Species is 0 or > MaxSpecies)
return;
if (pk.IsEgg) // do not add
return;
@ -333,7 +336,7 @@ public void SetDex(PKM pk)
if (!GetDisplayedAny(species))
SetDisplayed(species, gender, isShiny);
if (species <= Legal.MaxSpeciesID_4)
if (species <= MaxSpeciesLanguage)
SetLanguageFlag(species, (LanguageID)pk.Language);
var (formIndex, count) = GetFormIndex(species);
@ -428,13 +431,13 @@ public void CompleteForms(ushort species, bool shinyToo, bool firstFormOnly = fa
public void SeenNone()
{
for (ushort species = 1; species <= Legal.MaxSpeciesID_5; species++)
for (ushort species = 1; species <= MaxSpecies; species++)
ClearSeen(species);
}
public void SeenAll(bool shinyToo)
{
for (ushort species = 1; species <= Legal.MaxSpeciesID_5; species++)
for (ushort species = 1; species <= MaxSpecies; species++)
{
var pi = PersonalTable.BW[species]; // only need for Gender info
CompleteSeen(species, shinyToo, pi);
@ -443,13 +446,13 @@ public void SeenAll(bool shinyToo)
public void CaughtAll(LanguageID language, bool allLanguages)
{
for (ushort species = 1; species <= Legal.MaxSpeciesID_5; species++)
for (ushort species = 1; species <= MaxSpecies; species++)
CompleteObtained(species, language, allLanguages);
}
public void CaughtNone()
{
for (ushort species = 1; species <= Legal.MaxSpeciesID_5; species++)
for (ushort species = 1; species <= MaxSpecies; species++)
{
SetCaught(species, false);
SetAllLanguage(species, false);
@ -462,7 +465,9 @@ public void CaughtNone()
public void SetFormsSeen(bool shinyToo, bool firstFormOnly = false)
{
for (ushort species = 1; species <= Legal.MaxSpeciesID_5; species++)
for (ushort species = 1; species <= MaxSpecies; species++)
CompleteForms(species, shinyToo, firstFormOnly);
}
public void Reset() => Data[4..].Clear(); // Clear all flags, except magic
}

View File

@ -7,204 +7,429 @@ namespace PKHeX.Core;
/// <summary>
/// Pokédex structure used for Generation 6 games.
/// </summary>
public abstract class Zukan6 : Zukan<SAV6>
public abstract class Zukan6(Memory<byte> raw)
{
protected override int OFS_SEEN => OFS_CAUGHT + BitSeenSize;
protected override int OFS_CAUGHT => 0x8;
protected override int BitSeenSize => 0x60;
protected override int DexLangFlagByteCount => 631; // 721 * 7, rounded up
protected override int DexLangIDCount => 7;
protected int SpindaOffset { get; init; }
// General structure: u32 magic, upgrade flags, 9*bitflags, form flags, language flags, u32 spinda
protected Zukan6(SAV6XY sav, Memory<byte> dex, int langflag) : base(sav, dex, langflag)
/* 9 BitRegions with 0x60*8 bits
* Region 0: Caught flags - has been captured/obtained via gift/trade/evolution.
* Seen flags: Only should set the genders that have been seen. Genderless acts as male.
* Region 1: Seen Male/Genderless
* Region 2: Seen Female
* Region 3: Seen Male/Genderless Shiny
* Region 4: Seen Female Shiny
* Displayed flags: only one should be set for a given species. Usually is the one first seen, or selected by the player.
* Region 5: Displayed Male/Genderless
* Region 6: Displayed Female
* Region 7: Displayed Male/Genderless Shiny
* Region 8: Displayed Female Shiny
* Next, 4*{bytes} for form flags
* Next, bitflag region for languages obtained
* Lastly, the Spinda spot pattern, which is the first seen Spinda's encryption constant.
*/
public Span<byte> Data => raw.Span;
private const int BitSeenSize = 0x60;
private const int DexLangIDCount = 7;
public uint Magic { get => ReadUInt32LittleEndian(Data); set => WriteUInt32LittleEndian(Data, value); }
public uint Packed { get => ReadUInt32LittleEndian(Data[4..]); set => WriteUInt32LittleEndian(Data[4..], value); }
public bool IsNationalDexUnlocked { get => (Packed & 1) == 1; set => Packed = (Packed & ~1u) | (value ? 1u : 0u); } // bit 0
public bool IsNationalDexMode { get => (Packed & 2) == 2; set => Packed = (Packed & ~2u) | (value ? 2u : 0u); } // bit 1
// flags??
public ushort InitialSpecies { get => (ushort)((Packed >> 6) & 0x3FF); set => Packed = (Packed & ~0xFFC0u) | ((uint)value << 6); } // bit 6-15
// remaining 16 bits are unused
private const ushort MaxSpecies = Legal.MaxSpeciesID_6;
private const ushort MaxSpeciesLanguage = Legal.MaxSpeciesID_6;
private const int OFS_CAUGHT = 0x8;
private const int OFS_SEEN = OFS_CAUGHT + BitSeenSize; // 0x68
private const int OFS_DISP = OFS_SEEN + (BitSeenSize * 4); // 0x1E8
private const int FormDex = OFS_DISP + (BitSeenSize * 4); // 0x368
protected abstract int FormLen { get; } // byte count
private int OFS_LANG => FormDex + (FormLen * 4); // 0x368 + (0x18 * 4) = 0x3C8 for X/Y, 0x368 + (0x26 * 4) = 0x400 for OR/AS
private int OFS_SPINDA => OFS_LANG + 640; // ((DexLangIDCount * Legal.MaxSpeciesID_6) / 8) = 630, rounded up to nearest multiple of 16 = 640
public uint Spinda // 0x680 for OR/AS, 0x648 for X/Y
{
DexFormIndexFetcher = DexFormUtil.GetDexFormIndexXY;
get => ReadUInt32LittleEndian(Data[OFS_SPINDA..]);
set => WriteUInt32LittleEndian(Data[OFS_SPINDA..], value);
}
private Func<ushort, byte, int> DexFormIndexFetcher { get; }
protected bool GetFlag(int ofs, int bitIndex) => FlagUtil.GetFlag(Data, ofs + (bitIndex >> 3), bitIndex);
protected void SetFlag(int ofs, int bitIndex, bool value = true) => FlagUtil.SetFlag(Data, ofs + (bitIndex >> 3), bitIndex, value);
private static int GetRegion(byte gender, bool isShiny) => (isShiny ? 2 : 0) | (gender & 1);
public abstract (ushort Index, byte Count) GetFormIndex(ushort species);
protected Zukan6(SAV6AO sav, Memory<byte> dex, int langflag) : base(sav, dex, langflag)
public bool GetSeen(ushort species, byte gender, bool isShiny)
{
DexFormIndexFetcher = DexFormUtil.GetDexFormIndexORAS;
var region = GetRegion(gender, isShiny);
return GetSeen(species, region);
}
protected override int GetDexLangFlag(int lang)
public bool GetSeen(ushort species, int region)
{
lang--;
if (lang > 5)
lang--; // 0-6 language values
if ((uint)lang > 5)
return -1;
return lang;
if (species is 0 or > MaxSpecies)
return false;
int bit = species - 1;
return GetFlag(OFS_SEEN + (region * BitSeenSize), bit);
}
protected override bool GetSaneFormsToIterate(ushort species, out int formStart, out int formEnd, int formIn)
public void SetSeen(ushort species, byte gender, bool isShiny, bool value = true)
{
formStart = 0;
formEnd = 0;
var region = GetRegion(gender, isShiny);
SetSeen(species, region, value);
}
public virtual void SetSeen(ushort species, int region, bool value = true)
{
if (species is 0 or > MaxSpecies)
return;
int bit = species - 1;
SetFlag(OFS_SEEN + (region * BitSeenSize), bit, value);
}
public bool GetSeen(ushort species)
{
if (species is 0 or > MaxSpecies)
return false;
int bit = species - 1;
for (int i = 0; i < 4; i++)
{
if (GetFlag(OFS_SEEN + (i * BitSeenSize), bit))
return true; // already seen in any region
}
return false;
}
protected override void SetSpindaDexData(PKM pk, bool alreadySeen)
public virtual void ClearSeen(ushort species)
{
}
protected override void SetAllDexFlagsLanguage(int bit, int lang, bool value = true)
{
lang = GetDexLangFlag(lang);
if (lang < 0)
if (species is 0 or > MaxSpecies)
return;
int lbit = (bit * DexLangIDCount) + lang;
if (lbit < DexLangFlagByteCount << 3) // Sanity check for max length of region
SetFlag(PokeDexLanguageFlags, lbit, value);
int bit = species - 1;
for (int i = 0; i < 4; i++)
SetFlag(OFS_SEEN + (i * BitSeenSize), bit, false);
}
protected override void SetAllDexSeenFlags(int baseBit, byte form, byte gender, bool isShiny, bool value = true)
public bool GetCaught(ushort species)
{
var shiny = isShiny ? 1 : 0;
SetDexFlags(baseBit, baseBit, gender, shiny);
SetFormFlags((ushort)(baseBit + 1), form, shiny, value);
if (species is 0 or > MaxSpecies)
return false;
int bit = species - 1;
return GetFlag(OFS_CAUGHT, bit);
}
public override void SetDex(PKM pk)
public abstract void SetCaughtFlag(ushort species, GameVersion origin);
public void SetCaught(ushort species, bool value = true)
{
if (pk.Species is 0 or > Legal.MaxSpeciesID_6)
if (species is 0 or > MaxSpecies)
return;
int bit = species - 1;
SetFlag(OFS_CAUGHT, bit, value);
}
public bool GetDisplayed(ushort species, byte gender, bool isShiny)
{
var region = GetRegion(gender, isShiny);
return GetDisplayed(species, region);
}
public bool GetDisplayed(ushort species, int region)
{
if (species is 0 or > MaxSpecies)
return false;
int bit = species - 1;
return GetFlag(OFS_DISP + (region * BitSeenSize), bit);
}
public bool GetDisplayedAny(ushort species)
{
if (species is 0 or > MaxSpecies)
return false;
// Check Displayed Status for base form
int bit = species - 1;
for (int i = 0; i < 4; i++)
{
if (GetFlag(OFS_DISP + (i * BitSeenSize), bit))
return true;
}
return false;
}
public void SetDisplayed(ushort species, byte gender, bool isShiny, bool value = true)
{
var region = GetRegion(gender, isShiny);
SetDisplayed(species, region, value);
}
public void SetDisplayed(ushort species, int region, bool value = true)
{
if (species is 0 or > MaxSpecies)
return;
int bit = species - 1;
SetFlag(OFS_DISP + (region * BitSeenSize), bit, value);
}
public void ClearDisplayed(ushort species)
{
if (species is 0 or > MaxSpecies)
return;
int bit = species - 1;
for (int i = 0; i < 4; i++)
SetFlag(OFS_DISP + (i * BitSeenSize), bit, false);
}
public bool GetLanguageFlag(ushort species, LanguageID language)
{
int langIndex = GetLanguageIndex(language);
if (langIndex < 0)
return false; // invalid language index
return GetLanguageFlag(species, langIndex);
}
public bool GetLanguageFlag(ushort species, int langIndex)
{
if (species is 0 or > MaxSpeciesLanguage) // no Gen5
return false;
int bit = species - 1;
int lbit = (bit * DexLangIDCount) + langIndex;
return GetFlag(OFS_LANG, lbit);
}
public void SetLanguageFlag(ushort species, LanguageID langIndex, bool isLanguageSet = true)
{
int index = GetLanguageIndex(langIndex);
if (index < 0)
return; // invalid language index
SetLanguageFlag(species, index, isLanguageSet);
}
public void SetLanguageFlag(ushort species, int index, bool isLanguageSet)
{
if (species is 0 or > MaxSpeciesLanguage) // no Gen5
return;
int bit = species - 1;
int lbit = (bit * DexLangIDCount) + index;
SetFlag(OFS_LANG, lbit, isLanguageSet);
}
public void SetAllLanguage(ushort species, bool isLanguageSet = true)
{
if (species is 0 or > MaxSpeciesLanguage) // no Gen5
return;
int bit = species - 1;
for (int i = 0; i < DexLangIDCount; i++)
{
int lbit = (bit * DexLangIDCount) + i;
SetFlag(OFS_LANG, lbit, isLanguageSet);
}
}
public bool GetFormSeen(int formIndex, bool isShiny)
{
int region = isShiny ? 1 : 0; // 0 = non-shiny, 1 = shiny
return GetFormFlag(formIndex, region);
}
public bool GetFormFlag(int formIndex, int region)
{
if (formIndex < 0 || formIndex >= FormLen * 8)
return false; // invalid form index
return GetFlag(FormDex + (region * FormLen), formIndex);
}
public void SetFormSeen(int formIndex, bool isShiny, bool value = true)
{
int region = isShiny ? 1 : 0; // 0 = non-shiny, 1 = shiny
SetFormFlag(formIndex, region, value);
}
public void SetFormFlag(int formIndex, int region, bool value)
{
if (formIndex < 0 || formIndex >= FormLen * 8)
return;
SetFlag(FormDex + (region * FormLen), formIndex, value);
}
public bool GetFormDisplayed(int formIndex0, int formCount)
{
if (formIndex0 < 0 || formCount <= 1 || formIndex0 + formCount >= FormLen * 8)
return false; // invalid form index or count
for (int i = 0; i < formCount; i++)
{
int formIndex = formIndex0 + i;
if (GetFlag(FormDex + (2 * FormLen), formIndex)) // Nonshiny
return true; // already set
if (GetFlag(FormDex + (2 * FormLen), formIndex)) // Shiny
return true; // already set
}
return false;
}
public void SetFormDisplayed(int formIndex, bool isShiny, bool value = true)
{
if (formIndex < 0 || formIndex >= FormLen * 8)
return; // invalid form index
int region = isShiny ? 1 : 0; // 0 = non-shiny, 1 = shiny
SetFlag(FormDex + (2 * FormLen) + (region * FormLen), formIndex, value);
}
public void SetDex(PKM pk)
{
if (pk.Species is 0 or > MaxSpecies)
return;
if (pk.IsEgg) // do not add
return;
int bit = pk.Species - 1;
SetCaughtFlag(bit, pk.Version);
// Set the [Species/Gender/Shiny] Seen Flag
SetAllDexSeenFlags(pk.Species - 1, pk.Form, pk.Gender, pk.IsShiny);
SetAllDexFlagsLanguage(bit, pk.Language);
SetFormFlags(pk);
}
protected abstract void SetCaughtFlag(int bit, GameVersion origin);
private int FormLen => SAV is SAV6XY ? 0x18 : 0x26;
private int FormDex => 0x8 + (BitSeenSize * 9);
public bool GetFormFlag(int formIndex, int flagRegion) => GetFlag(FormDex + (FormLen * flagRegion), formIndex);
public void SetFormFlag(int formIndex, int flagRegion, bool value = true) => SetFlag(FormDex + (FormLen * flagRegion), formIndex, value);
private void SetFormFlags(PKM pk)
{
var species = pk.Species;
if (species == (int)Species.Spinda && !GetSeen(species))
Spinda = pk.EncryptionConstant;
var gender = pk.Gender;
var isShiny = pk.IsShiny;
SetSeen(species, gender, isShiny);
SetCaughtFlag(species, pk.Version);
SetDexOther(pk);
if (!GetDisplayedAny(species))
SetDisplayed(species, gender, isShiny);
if (species <= MaxSpeciesLanguage)
SetLanguageFlag(species, (LanguageID)pk.Language);
var (formIndex, count) = GetFormIndex(species);
if (count == 0)
return; // no forms
// Set the Form Seen Flag
SetFormSeen(formIndex, isShiny);
if (GetFormDisplayed(formIndex, count))
return; // already displayed
var form = pk.Form;
var shiny = pk.IsShiny ? 1 : 0;
SetFormFlags(species, form, shiny);
if (form >= count)
return; // invalid form index
// Set the Form Displayed Flag
var index = formIndex + form;
SetFormDisplayed(index, isShiny);
}
private void SetFormFlags(ushort species, byte form, int shiny, bool value = true)
protected virtual void SetDexOther(PKM pk) { }
/// <summary>
/// Gets the bit index for the language.
/// </summary>
/// <param name="language">Entry language ID.</param>
private static int GetLanguageIndex(LanguageID language)
{
var fc = SAV.Personal[species].FormCount;
int f = DexFormIndexFetcher(species, fc);
if (f < 0)
var index = (int)language - 1; // LanguageID starts at 1
if (index > 5)
index--; // 0-6 language values
if ((uint)index > 5)
return -1; // Invalid language index
return index;
}
public void GiveAll(ushort species, bool state, bool shinyToo, LanguageID language, bool allLanguages)
{
if (!state)
{
ClearSeen(species);
return;
var bit = f + form;
// Set Form Seen Flag
SetFormFlag(bit, shiny, value);
// Set Displayed Flag if necessary, check all flags
if (!value || !GetIsFormDisplayed(f, fc))
SetFormFlag(bit, 2 + shiny, value);
}
private bool GetIsFormDisplayed(int form, byte formCount)
{
for (byte i = 0; i < formCount; i++)
{
var index = form + i;
if (GetFormFlag(index, 2)) // Nonshiny
return true; // already set
if (GetFormFlag(index, 3)) // Shiny
return true; // already set
}
return false;
var pi = PersonalTable.AO[species]; // only need for Gender info
CompleteSeen(species, shinyToo, pi);
CompleteObtained(species, language, allLanguages);
}
public uint SpindaPID
public virtual void CompleteObtained(ushort species, LanguageID language, bool allLanguages)
{
get => ReadUInt32LittleEndian(Data[SpindaOffset..]);
set => WriteUInt32LittleEndian(Data[SpindaOffset..], value);
SetCaught(species);
if (allLanguages)
SetAllLanguage(species);
else
SetLanguageFlag(species, language);
}
public bool[] GetLanguageBitflags(ushort species)
public void CompleteSeen<T>(ushort species, bool shinyToo, T pi) where T : IGenderDetail
{
var result = new bool[DexLangIDCount];
int bit = species - 1;
for (int i = 0; i < DexLangIDCount; i++)
if (!pi.OnlyFemale)
{
int lbit = (bit * DexLangIDCount) + i;
result[i] = GetFlag(PokeDexLanguageFlags, lbit);
SetSeen(species, 0); // non-shiny
if (shinyToo)
SetSeen(species, 2); // shiny
}
return result;
if (pi is { OnlyMale: false, Genderless: false })
{
SetSeen(species, 1); // non-shiny
if (shinyToo)
SetSeen(species, 3); // shiny
}
if (!GetDisplayedAny(species))
SetDisplayed(species, pi.OnlyFemale ? 1 : 0); // 0 = non-shiny, 1 = shiny
CompleteForms(species, shinyToo);
}
public void SetLanguageBitflags(ushort species, ReadOnlySpan<bool> value)
public void CompleteForms(ushort species, bool shinyToo, bool firstFormOnly = false)
{
int bit = species - 1;
for (int i = 0; i < DexLangIDCount; i++)
var (index, count) = GetFormIndex(species);
if (count == 0)
return; // no forms
if (firstFormOnly)
count = 1;
for (int i = 0; i < count; i++)
{
int lbit = (bit * DexLangIDCount) + i;
SetFlag(PokeDexLanguageFlags, lbit, value[i]);
int formIndex = index + i;
SetFormSeen(formIndex, false); // non-shiny
if (shinyToo)
SetFormSeen(formIndex, true); // shiny
}
if (!GetFormDisplayed(index, count))
SetFormDisplayed(index, false); // non-shiny
}
public void SeenNone()
{
for (ushort species = 1; species <= MaxSpecies; species++)
ClearSeen(species);
}
public void SeenAll(bool shinyToo)
{
for (ushort species = 1; species <= MaxSpecies; species++)
{
var pi = PersonalTable.BW[species]; // only need for Gender info
CompleteSeen(species, shinyToo, pi);
}
}
public void ToggleLanguageFlagsAll(bool value)
public void CaughtAll(LanguageID language, bool allLanguages)
{
var arr = GetBlankLanguageBits(value);
for (ushort i = 1; i <= SAV.MaxSpeciesID; i++)
SetLanguageBitflags(i, arr);
for (ushort species = 1; species <= MaxSpecies; species++)
CompleteObtained(species, language, allLanguages);
}
public void ToggleLanguageFlagsSingle(ushort species, bool value)
public void CaughtNone()
{
var arr = GetBlankLanguageBits(value);
SetLanguageBitflags(species, arr);
for (ushort species = 1; species <= MaxSpecies; species++)
{
SetCaught(species, false);
SetAllLanguage(species, false);
}
}
private bool[] GetBlankLanguageBits(bool value)
{
var result = new bool[DexLangIDCount];
for (int i = 0; i < DexLangIDCount; i++)
result[i] = value;
return result;
}
}
public void ClearFormSeen() => Data.Slice(FormDex, FormLen * 4).Clear();
/// <summary>
/// Pokédex structure used for <see cref="GameVersion.ORAS"/>.
/// </summary>
public sealed class Zukan6AO : Zukan6
{
public Zukan6AO(SAV6AO sav, Memory<byte> dex, int langflag) : base(sav, dex, langflag)
{
SpindaOffset = 0x680;
}
public void SetFormsSeen1(bool shinyToo) => SetFormsSeen(shinyToo, true);
protected override void SetCaughtFlag(int bit, GameVersion origin)
public void SetFormsSeen(bool shinyToo, bool firstFormOnly = false)
{
SetFlag(OFS_CAUGHT, bit);
if (GetEncounterCount(bit) == 0)
SetEncounterCount(bit, 1);
}
public ushort GetEncounterCount(int index)
{
var ofs = 0x686 + (index * 2);
return ReadUInt16LittleEndian(Data[ofs..]);
}
public void SetEncounterCount(int index, ushort value)
{
var ofs = 0x686 + (index * 2);
WriteUInt16LittleEndian(Data[ofs..], value);
for (ushort species = 1; species <= MaxSpecies; species++)
CompleteForms(species, shinyToo, firstFormOnly);
}
}
@ -213,29 +438,197 @@ public void SetEncounterCount(int index, ushort value)
/// </summary>
public sealed class Zukan6XY : Zukan6
{
public Zukan6XY(SAV6XY sav, Memory<byte> dex, int langflag) : base(sav, dex, langflag)
{
SpindaOffset = 0x648;
}
protected override int FormLen => 0x18;
public override (ushort Index, byte Count) GetFormIndex(ushort species) => GetFormIndexXY(species);
public Zukan6XY(Memory<byte> dex) : base(dex) { }
protected override void SetCaughtFlag(int bit, GameVersion origin)
// Spinda at 0x648
// Obtained a {species} from Gen3/4/5 flags at 0x64C, 0th index is species=1
// 0x54 bytes of flags
// total structure size: 0x6A0
public override void SetCaughtFlag(ushort species, GameVersion origin)
{
// Species: 1-649 for X/Y, and not for OR/AS; Set the Foreign Owned Flag
if (origin < GameVersion.X && bit < (int)Species.Genesect)
SetForeignFlag(bit);
if (origin < GameVersion.X && (uint)(species - 1) < (int)Species.Genesect)
SetForeignFlag(species);
else
SetFlag(OFS_CAUGHT, bit);
SetCaught(species);
}
public bool GetForeignFlag(int bit)
public override void CompleteObtained(ushort species, LanguageID language, bool allLanguages)
{
Debug.Assert(bit < (int)Species.Genesect);
base.CompleteObtained(species, language, allLanguages);
if ((uint)(species - 1) < (int)Species.Genesect)
SetForeignFlag(species);
}
public bool GetForeignFlag(ushort species)
{
int bit = species - 1;
Debug.Assert((uint)bit < (int)Species.Genesect);
return GetFlag(0x64C, bit);
}
public void SetForeignFlag(int bit, bool value = true)
public void SetForeignFlag(ushort species, bool value = true)
{
Debug.Assert(bit < (int)Species.Genesect);
int bit = species - 1;
Debug.Assert((uint)bit < (int)Species.Genesect);
SetFlag(0x64C, bit, value);
}
public static (byte Index, byte Count) GetFormIndexXY(ushort species) => species switch
{
666 => (083, 20), // 20 Vivillion
669 => (103, 5), // 5 Flabébé
670 => (108, 6), // 6 Floette
671 => (114, 5), // 5 Florges
710 => (119, 4), // 4 Pumpkaboo
711 => (123, 4), // 4 Gourgeist
681 => (127, 2), // 2 Aegislash
716 => (129, 2), // 2 Xerneas
003 => (131, 2), // 2 Venusaur
006 => (133, 3), // 3 Charizard
009 => (136, 2), // 2 Blastoise
065 => (138, 2), // 2 Alakazam
094 => (140, 2), // 2 Gengar
115 => (142, 2), // 2 Kangaskhan
127 => (144, 2), // 2 Pinsir
130 => (146, 2), // 2 Gyarados
142 => (148, 2), // 2 Aerodactyl
150 => (150, 3), // 3 Mewtwo
181 => (153, 2), // 2 Ampharos
212 => (155, 2), // 2 Scizor
214 => (157, 2), // 2 Heracros
229 => (159, 2), // 2 Houndoom
248 => (161, 2), // 2 Tyranitar
257 => (163, 2), // 2 Blaziken
282 => (165, 2), // 2 Gardevoir
303 => (167, 2), // 2 Mawile
306 => (169, 2), // 2 Aggron
308 => (171, 2), // 2 Medicham
310 => (173, 2), // 2 Manetric
354 => (175, 2), // 2 Banette
359 => (177, 2), // 2 Absol
380 => (179, 2), // 2 Latias
381 => (181, 2), // 2 Latios
445 => (183, 2), // 2 Garchomp
448 => (185, 2), // 2 Lucario
460 => (187, 2), // 2 Abomasnow
_ => Zukan5B2W2.GetFormIndexB2W2(species),
};
public override void ClearSeen(ushort species)
{
base.ClearSeen(species);
// Clear foreign flag as well
if ((uint)(species - 1) < (int)Species.Genesect)
SetForeignFlag(species, false);
}
public void SetSeen(ushort species, bool seen)
{
var pi = PersonalTable.XY[species];
var gender = pi.OnlyFemale ? (byte)1 : (byte)0;
SetSeen(species, gender, isShiny: false, value: seen);
}
public void Reset() => Data[4..].Clear(); // Clear all flags, except magic
}
/// <summary>
/// Pokédex structure used for <see cref="GameVersion.ORAS"/>.
/// </summary>
public sealed class Zukan6AO : Zukan6
{
protected override int FormLen => 0x26;
public override (ushort Index, byte Count) GetFormIndex(ushort species) => GetFormIndexAO(species);
public Zukan6AO(Memory<byte> dex) : base(dex) { }
public override void SetCaughtFlag(ushort species, GameVersion origin) => SetCaught(species); // no foreign flag in OR/AS, unlike X/Y
// Spinda at 0x680, counts at 0x684
private const int CountEncounter = Legal.MaxSpeciesID_6 + 1; // 722, 0x5A4 bytes
private static int GetOffsetCountSeen(ushort species)
{
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(species, CountEncounter);
return 0x684 + (species * 2);
}
private static int GetOffsetCountObtained(ushort species)
{
ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(species, CountEncounter);
return 0xC28 + (species * 2);
}
// 0x11CC total length.
public ushort GetCountSeen(ushort species) => ReadUInt16LittleEndian(Data[GetOffsetCountSeen(species)..]);
public void SetCountSeen(ushort species, ushort value) => WriteUInt16LittleEndian(Data[GetOffsetCountSeen(species)..], value);
// Turns out the game never actually calls these, but we can still display them to the user.
public ushort GetCountObtained(ushort species) => ReadUInt16LittleEndian(Data[GetOffsetCountObtained(species)..]);
public void SetCountObtained(ushort species, ushort value) => WriteUInt16LittleEndian(Data[GetOffsetCountObtained(species)..], value);
public static (ushort Index, byte Count) GetFormIndexAO(ushort species) => species switch
{
025 => (189, 7), // 7 Pikachu
720 => (196, 2), // 2 Hoopa
015 => (198, 2), // 2 Beedrill
018 => (200, 2), // 2 Pidgeot
080 => (202, 2), // 2 Slowbro
208 => (204, 2), // 2 Steelix
254 => (206, 2), // 2 Sceptile
260 => (208, 2), // 2 Swampert
302 => (210, 2), // 2 Sableye
319 => (212, 2), // 2 Sharpedo
323 => (214, 2), // 2 Camerupt
334 => (216, 2), // 2 Altaria
362 => (218, 2), // 2 Glalie
373 => (220, 2), // 2 Salamence
376 => (222, 2), // 2 Metagross
384 => (224, 2), // 2 Rayquaza
428 => (226, 2), // 2 Lopunny
475 => (228, 2), // 2 Gallade
531 => (230, 2), // 2 Audino
719 => (232, 2), // 2 Diancie
382 => (234, 2), // 2 Kyogre
383 => (236, 2), // 2 Groudon
493 => (238, 18), // 18 Arceus
649 => (256, 5), // 5 Genesect
676 => (261, 1), // 10 Furfrou
_ => Zukan6XY.GetFormIndexXY(species),
};
public void SetSeen(ushort species, bool seen)
{
var pi = PersonalTable.AO[species];
var gender = pi.OnlyFemale ? (byte)1 : (byte)0;
SetSeen(species, gender, isShiny: false, value: seen);
}
public override void SetSeen(ushort species, int region, bool value = true)
{
base.SetSeen(species, region, value);
if (value && GetCountSeen(species) == 0)
SetCountSeen(species, 1);
}
public void AddSeen(ushort species)
{
var current = GetCountSeen(species);
if (current != ushort.MaxValue)
SetCountSeen(species, (ushort)(current + 1));
}
public override void ClearSeen(ushort species)
{
base.ClearSeen(species);
SetCountSeen(species, 0); // reset seen count
SetCountObtained(species, 0); // reset obtained count
}
protected override void SetDexOther(PKM pk) => AddSeen(pk.Species);
}

View File

@ -114,126 +114,4 @@ private static int GetDexFormBitIndex(ushort species, byte formCount, ReadOnlySp
prior += p;
return prior;
}
public static int GetDexFormIndexBW(ushort species, byte formCount)
{
if (formCount < 1 || species > Legal.MaxSpeciesID_5)
return -1; // invalid
return species switch
{
201 => 000, // 28 Unown
386 => 028, // 4 Deoxys
492 => 032, // 2 Shaymin
487 => 034, // 2 Giratina
479 => 036, // 6 Rotom
422 => 042, // 2 Shellos
423 => 044, // 2 Gastrodon
412 => 046, // 3 Burmy
413 => 049, // 3 Wormadam
351 => 052, // 4 Castform
421 => 056, // 2 Cherrim
585 => 058, // 4 Deerling
586 => 062, // 4 Sawsbuck
648 => 066, // 2 Meloetta
555 => 068, // 2 Darmanitan
550 => 070, // 2 Basculin
_ => -1,
};
}
public static int GetDexFormIndexB2W2(ushort species, byte formCount)
{
if (formCount < 1 || species > Legal.MaxSpeciesID_5)
return -1; // invalid
return species switch
{
646 => 072, // 3 Kyurem
647 => 075, // 2 Keldeo
642 => 077, // 2 Thundurus
641 => 079, // 2 Tornadus
645 => 081, // 2 Landorus
_ => GetDexFormIndexBW(species, formCount),
};
}
public static int GetDexFormIndexXY(ushort species, byte formCount)
{
if (formCount < 1 || species > Legal.MaxSpeciesID_6)
return -1; // invalid
return species switch
{
666 => 083, // 20 Vivillion
669 => 103, // 5 Flabébé
670 => 108, // 6 Floette
671 => 114, // 5 Florges
710 => 119, // 4 Pumpkaboo
711 => 123, // 4 Gourgeist
681 => 127, // 2 Aegislash
716 => 129, // 2 Xerneas
003 => 131, // 2 Venusaur
006 => 133, // 3 Charizard
009 => 136, // 2 Blastoise
065 => 138, // 2 Alakazam
094 => 140, // 2 Gengar
115 => 142, // 2 Kangaskhan
127 => 144, // 2 Pinsir
130 => 146, // 2 Gyarados
142 => 148, // 2 Aerodactyl
150 => 150, // 3 Mewtwo
181 => 153, // 2 Ampharos
212 => 155, // 2 Scizor
214 => 157, // 2 Heracros
229 => 159, // 2 Houndoom
248 => 161, // 2 Tyranitar
257 => 163, // 2 Blaziken
282 => 165, // 2 Gardevoir
303 => 167, // 2 Mawile
306 => 169, // 2 Aggron
308 => 171, // 2 Medicham
310 => 173, // 2 Manetric
354 => 175, // 2 Banette
359 => 177, // 2 Absol
380 => 179, // 2 Latias
381 => 181, // 2 Latios
445 => 183, // 2 Garchomp
448 => 185, // 2 Lucario
460 => 187, // 2 Abomasnow
_ => GetDexFormIndexB2W2(species, formCount),
};
}
public static int GetDexFormIndexORAS(ushort species, byte formCount)
{
if (formCount < 1 || species > Legal.MaxSpeciesID_6)
return -1; // invalid
return species switch
{
025 => 189, // 7 Pikachu
720 => 196, // 2 Hoopa
015 => 198, // 2 Beedrill
018 => 200, // 2 Pidgeot
080 => 202, // 2 Slowbro
208 => 204, // 2 Steelix
254 => 206, // 2 Sceptile
260 => 208, // 2 Swampert
302 => 210, // 2 Sableye
319 => 212, // 2 Sharpedo
323 => 214, // 2 Camerupt
334 => 216, // 2 Altaria
362 => 218, // 2 Glalie
373 => 220, // 2 Salamence
376 => 222, // 2 Metagross
384 => 224, // 2 Rayquaza
428 => 226, // 2 Lopunny
475 => 228, // 2 Gallade
531 => 230, // 2 Audino
719 => 232, // 2 Diancie
382 => 234, // 2 Kyogre
383 => 236, // 2 Groudon
493 => 238, // 18 Arceus
649 => 256, // 5 Genesect
676 => 261, // 10 Furfrou
_ => GetDexFormIndexXY(species, formCount),
};
}
}

View File

@ -144,10 +144,10 @@ private void GetEntry(bool skipFormRepop = false)
CHK_P2.Enabled = CHK_P4.Enabled = CHK_P6.Enabled = CHK_P8.Enabled = !pi.OnlyFemale;
CHK_P3.Enabled = CHK_P5.Enabled = CHK_P7.Enabled = CHK_P9.Enabled = !(pi.OnlyMale || pi.Genderless);
var (index, count) = Dex.GetFormIndex(species);
if (skipFormRepop)
{
// Just re-load without changing the text.
var (index, count) = Dex.GetFormIndex(species);
if (count == 0)
return;
for (int i = 0; i < count; i++)
@ -163,23 +163,21 @@ private void GetEntry(bool skipFormRepop = false)
CLB_FormsSeen.Items.Clear();
CLB_FormDisplayed.Items.Clear();
var fc = pi.FormCount;
int f = SAV is SAV5B2W2 ? DexFormUtil.GetDexFormIndexB2W2(species, fc) : DexFormUtil.GetDexFormIndexBW(species, fc);
if (f < 0)
return;
string[] forms = FormConverter.GetFormList(species, GameInfo.Strings.types, GameInfo.Strings.forms, Main.GenderSymbols, SAV.Context);
if (count == 0)
return; // No forms to set.
var forms = FormConverter.GetFormList(species, GameInfo.Strings.types, GameInfo.Strings.forms, Main.GenderSymbols, SAV.Context);
if (forms.Length < 1)
return;
for (int i = 0; i < forms.Length; i++) // Seen
CLB_FormsSeen.Items.Add(forms[i], Dex.GetFormFlag(f + i, 0));
CLB_FormsSeen.Items.Add(forms[i], Dex.GetFormFlag(index + i, 0));
for (int i = 0; i < forms.Length; i++) // Seen Shiny
CLB_FormsSeen.Items.Add($"* {forms[i]}", Dex.GetFormFlag(f + i, 1));
CLB_FormsSeen.Items.Add($"* {forms[i]}", Dex.GetFormFlag(index + i, 1));
for (int i = 0; i < forms.Length; i++) // Displayed
CLB_FormDisplayed.Items.Add(forms[i], Dex.GetFormFlag(f + i, 2));
CLB_FormDisplayed.Items.Add(forms[i], Dex.GetFormFlag(index + i, 2));
for (int i = 0; i < forms.Length; i++) // Displayed Shiny
CLB_FormDisplayed.Items.Add($"* {forms[i]}", Dex.GetFormFlag(f + i, 3));
CLB_FormDisplayed.Items.Add($"* {forms[i]}", Dex.GetFormFlag(index + i, 3));
}
private void SetEntry()
@ -200,21 +198,20 @@ private void SetEntry()
Dex.SetLanguageFlag(species, i, CL[i].Checked);
}
var fc = SAV.Personal[species].FormCount;
int f = SAV is SAV5B2W2 ? DexFormUtil.GetDexFormIndexB2W2(species, fc) : DexFormUtil.GetDexFormIndexBW(species, fc);
if (f < 0)
var (index, count) = Dex.GetFormIndex(species);
if (count == 0)
return;
for (int i = 0; i < CLB_FormsSeen.Items.Count / 2; i++) // Seen
Dex.SetFormFlag(f + i, 0, CLB_FormsSeen.GetItemChecked(i));
Dex.SetFormFlag(index + i, 0, CLB_FormsSeen.GetItemChecked(i));
for (int i = 0; i < CLB_FormsSeen.Items.Count / 2; i++) // Seen Shiny
Dex.SetFormFlag(f + i, 1, CLB_FormsSeen.GetItemChecked(i + (CLB_FormsSeen.Items.Count / 2)));
Dex.SetFormFlag(index + i, 1, CLB_FormsSeen.GetItemChecked(i + (CLB_FormsSeen.Items.Count / 2)));
editing = true;
for (int i = 0; i < CLB_FormDisplayed.Items.Count / 2; i++) // Displayed
Dex.SetFormFlag(f + i, 2, CLB_FormDisplayed.GetItemChecked(i));
Dex.SetFormFlag(index + i, 2, CLB_FormDisplayed.GetItemChecked(i));
for (int i = 0; i < CLB_FormDisplayed.Items.Count / 2; i++) // Displayed Shiny
Dex.SetFormFlag(f + i, 3, CLB_FormDisplayed.GetItemChecked(i + (CLB_FormDisplayed.Items.Count / 2)));
Dex.SetFormFlag(index + i, 3, CLB_FormDisplayed.GetItemChecked(i + (CLB_FormDisplayed.Items.Count / 2)));
editing = false;
}

View File

@ -1,4 +1,4 @@
namespace PKHeX.WinForms
namespace PKHeX.WinForms
{
partial class SAV_PokedexORAS
{
@ -51,7 +51,7 @@ private void InitializeComponent()
GB_Language = new System.Windows.Forms.GroupBox();
GB_Displayed = new System.Windows.Forms.GroupBox();
L_DexNav = new System.Windows.Forms.Label();
MT_Count = new System.Windows.Forms.MaskedTextBox();
MT_Seen = new System.Windows.Forms.MaskedTextBox();
GB_Owned = new System.Windows.Forms.GroupBox();
TB_Spinda = new System.Windows.Forms.TextBox();
L_Spinda = new System.Windows.Forms.Label();
@ -77,6 +77,10 @@ private void InitializeComponent()
mnuFormNone = new System.Windows.Forms.ToolStripMenuItem();
mnuForm1 = new System.Windows.Forms.ToolStripMenuItem();
mnuFormAll = new System.Windows.Forms.ToolStripMenuItem();
label1 = new System.Windows.Forms.Label();
MT_Obtained = new System.Windows.Forms.MaskedTextBox();
CHK_NationalDexActive = new System.Windows.Forms.CheckBox();
CHK_NationalDexUnlocked = new System.Windows.Forms.CheckBox();
GB_Language.SuspendLayout();
GB_Displayed.SuspendLayout();
GB_Owned.SuspendLayout();
@ -101,7 +105,6 @@ private void InitializeComponent()
//
LB_Species.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left;
LB_Species.FormattingEnabled = true;
LB_Species.ItemHeight = 15;
LB_Species.Location = new System.Drawing.Point(14, 46);
LB_Species.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
LB_Species.Name = "LB_Species";
@ -115,7 +118,7 @@ private void InitializeComponent()
CHK_P1.Location = new System.Drawing.Point(7, 16);
CHK_P1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CHK_P1.Name = "CHK_P1";
CHK_P1.Size = new System.Drawing.Size(75, 19);
CHK_P1.Size = new System.Drawing.Size(81, 21);
CHK_P1.TabIndex = 3;
CHK_P1.Text = "Obtained";
CHK_P1.UseVisualStyleBackColor = true;
@ -126,7 +129,7 @@ private void InitializeComponent()
CHK_P6.Location = new System.Drawing.Point(6, 15);
CHK_P6.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CHK_P6.Name = "CHK_P6";
CHK_P6.Size = new System.Drawing.Size(52, 19);
CHK_P6.Size = new System.Drawing.Size(56, 21);
CHK_P6.TabIndex = 8;
CHK_P6.Text = "Male";
CHK_P6.UseVisualStyleBackColor = true;
@ -138,7 +141,7 @@ private void InitializeComponent()
CHK_P7.Location = new System.Drawing.Point(6, 31);
CHK_P7.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CHK_P7.Name = "CHK_P7";
CHK_P7.Size = new System.Drawing.Size(64, 19);
CHK_P7.Size = new System.Drawing.Size(68, 21);
CHK_P7.TabIndex = 9;
CHK_P7.Text = "Female";
CHK_P7.UseVisualStyleBackColor = true;
@ -150,7 +153,7 @@ private void InitializeComponent()
CHK_P8.Location = new System.Drawing.Point(6, 47);
CHK_P8.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CHK_P8.Name = "CHK_P8";
CHK_P8.Size = new System.Drawing.Size(84, 19);
CHK_P8.Size = new System.Drawing.Size(90, 21);
CHK_P8.TabIndex = 10;
CHK_P8.Text = "Shiny Male";
CHK_P8.UseVisualStyleBackColor = true;
@ -162,7 +165,7 @@ private void InitializeComponent()
CHK_P9.Location = new System.Drawing.Point(6, 63);
CHK_P9.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CHK_P9.Name = "CHK_P9";
CHK_P9.Size = new System.Drawing.Size(96, 19);
CHK_P9.Size = new System.Drawing.Size(102, 21);
CHK_P9.TabIndex = 11;
CHK_P9.Text = "Shiny Female";
CHK_P9.UseVisualStyleBackColor = true;
@ -174,7 +177,7 @@ private void InitializeComponent()
CHK_L7.Location = new System.Drawing.Point(21, 144);
CHK_L7.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CHK_L7.Name = "CHK_L7";
CHK_L7.Size = new System.Drawing.Size(63, 19);
CHK_L7.Size = new System.Drawing.Size(69, 21);
CHK_L7.TabIndex = 19;
CHK_L7.Text = "Korean";
CHK_L7.UseVisualStyleBackColor = true;
@ -185,7 +188,7 @@ private void InitializeComponent()
CHK_L6.Location = new System.Drawing.Point(21, 125);
CHK_L6.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CHK_L6.Name = "CHK_L6";
CHK_L6.Size = new System.Drawing.Size(67, 19);
CHK_L6.Size = new System.Drawing.Size(72, 21);
CHK_L6.TabIndex = 18;
CHK_L6.Text = "Spanish";
CHK_L6.UseVisualStyleBackColor = true;
@ -196,7 +199,7 @@ private void InitializeComponent()
CHK_L5.Location = new System.Drawing.Point(21, 105);
CHK_L5.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CHK_L5.Name = "CHK_L5";
CHK_L5.Size = new System.Drawing.Size(68, 19);
CHK_L5.Size = new System.Drawing.Size(73, 21);
CHK_L5.TabIndex = 17;
CHK_L5.Text = "German";
CHK_L5.UseVisualStyleBackColor = true;
@ -207,7 +210,7 @@ private void InitializeComponent()
CHK_L4.Location = new System.Drawing.Point(21, 85);
CHK_L4.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CHK_L4.Name = "CHK_L4";
CHK_L4.Size = new System.Drawing.Size(58, 19);
CHK_L4.Size = new System.Drawing.Size(61, 21);
CHK_L4.TabIndex = 16;
CHK_L4.Text = "Italian";
CHK_L4.UseVisualStyleBackColor = true;
@ -218,7 +221,7 @@ private void InitializeComponent()
CHK_L3.Location = new System.Drawing.Point(21, 66);
CHK_L3.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CHK_L3.Name = "CHK_L3";
CHK_L3.Size = new System.Drawing.Size(62, 19);
CHK_L3.Size = new System.Drawing.Size(65, 21);
CHK_L3.TabIndex = 15;
CHK_L3.Text = "French";
CHK_L3.UseVisualStyleBackColor = true;
@ -229,7 +232,7 @@ private void InitializeComponent()
CHK_L2.Location = new System.Drawing.Point(21, 46);
CHK_L2.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CHK_L2.Name = "CHK_L2";
CHK_L2.Size = new System.Drawing.Size(64, 19);
CHK_L2.Size = new System.Drawing.Size(68, 21);
CHK_L2.TabIndex = 14;
CHK_L2.Text = "English";
CHK_L2.UseVisualStyleBackColor = true;
@ -240,7 +243,7 @@ private void InitializeComponent()
CHK_L1.Location = new System.Drawing.Point(21, 27);
CHK_L1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CHK_L1.Name = "CHK_L1";
CHK_L1.Size = new System.Drawing.Size(73, 19);
CHK_L1.Size = new System.Drawing.Size(81, 21);
CHK_L1.TabIndex = 13;
CHK_L1.Text = "Japanese";
CHK_L1.UseVisualStyleBackColor = true;
@ -251,7 +254,7 @@ private void InitializeComponent()
L_goto.Location = new System.Drawing.Point(14, 18);
L_goto.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
L_goto.Name = "L_goto";
L_goto.Size = new System.Drawing.Size(35, 15);
L_goto.Size = new System.Drawing.Size(39, 17);
L_goto.TabIndex = 20;
L_goto.Text = "goto:";
//
@ -265,7 +268,7 @@ private void InitializeComponent()
CB_Species.Location = new System.Drawing.Point(58, 15);
CB_Species.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CB_Species.Name = "CB_Species";
CB_Species.Size = new System.Drawing.Size(107, 23);
CB_Species.Size = new System.Drawing.Size(107, 25);
CB_Species.TabIndex = 21;
CB_Species.SelectedIndexChanged += ChangeCBSpecies;
CB_Species.SelectedValueChanged += ChangeCBSpecies;
@ -339,23 +342,23 @@ private void InitializeComponent()
//
// L_DexNav
//
L_DexNav.Location = new System.Drawing.Point(215, 276);
L_DexNav.Location = new System.Drawing.Point(314, 253);
L_DexNav.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
L_DexNav.Name = "L_DexNav";
L_DexNav.Size = new System.Drawing.Size(121, 23);
L_DexNav.TabIndex = 32;
L_DexNav.Text = "DexNav Lv:";
L_DexNav.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
L_DexNav.Text = "Seen:";
L_DexNav.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// MT_Count
// MT_Seen
//
MT_Count.Location = new System.Drawing.Point(173, 276);
MT_Count.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
MT_Count.Mask = "0000";
MT_Count.Name = "MT_Count";
MT_Count.Size = new System.Drawing.Size(37, 23);
MT_Count.TabIndex = 31;
MT_Count.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
MT_Seen.Location = new System.Drawing.Point(447, 251);
MT_Seen.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
MT_Seen.Mask = "00000";
MT_Seen.Name = "MT_Seen";
MT_Seen.Size = new System.Drawing.Size(37, 25);
MT_Seen.TabIndex = 31;
MT_Seen.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// GB_Owned
//
@ -372,7 +375,7 @@ private void InitializeComponent()
// TB_Spinda
//
TB_Spinda.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
TB_Spinda.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
TB_Spinda.Font = new System.Drawing.Font("Courier New", 8.25F);
TB_Spinda.Location = new System.Drawing.Point(370, 225);
TB_Spinda.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
TB_Spinda.Name = "TB_Spinda";
@ -386,7 +389,7 @@ private void InitializeComponent()
L_Spinda.Location = new System.Drawing.Point(314, 228);
L_Spinda.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
L_Spinda.Name = "L_Spinda";
L_Spinda.Size = new System.Drawing.Size(46, 15);
L_Spinda.Size = new System.Drawing.Size(51, 17);
L_Spinda.TabIndex = 30;
L_Spinda.Text = "Spinda:";
//
@ -411,7 +414,7 @@ private void InitializeComponent()
CHK_P5.Location = new System.Drawing.Point(7, 66);
CHK_P5.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CHK_P5.Name = "CHK_P5";
CHK_P5.Size = new System.Drawing.Size(96, 19);
CHK_P5.Size = new System.Drawing.Size(102, 21);
CHK_P5.TabIndex = 7;
CHK_P5.Text = "Shiny Female";
CHK_P5.UseVisualStyleBackColor = true;
@ -423,7 +426,7 @@ private void InitializeComponent()
CHK_P4.Location = new System.Drawing.Point(7, 50);
CHK_P4.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CHK_P4.Name = "CHK_P4";
CHK_P4.Size = new System.Drawing.Size(84, 19);
CHK_P4.Size = new System.Drawing.Size(90, 21);
CHK_P4.TabIndex = 6;
CHK_P4.Text = "Shiny Male";
CHK_P4.UseVisualStyleBackColor = true;
@ -435,7 +438,7 @@ private void InitializeComponent()
CHK_P3.Location = new System.Drawing.Point(7, 33);
CHK_P3.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CHK_P3.Name = "CHK_P3";
CHK_P3.Size = new System.Drawing.Size(64, 19);
CHK_P3.Size = new System.Drawing.Size(68, 21);
CHK_P3.TabIndex = 5;
CHK_P3.Text = "Female";
CHK_P3.UseVisualStyleBackColor = true;
@ -447,7 +450,7 @@ private void InitializeComponent()
CHK_P2.Location = new System.Drawing.Point(7, 17);
CHK_P2.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CHK_P2.Name = "CHK_P2";
CHK_P2.Size = new System.Drawing.Size(52, 19);
CHK_P2.Size = new System.Drawing.Size(56, 21);
CHK_P2.TabIndex = 4;
CHK_P2.Text = "Male";
CHK_P2.UseVisualStyleBackColor = true;
@ -457,54 +460,54 @@ private void InitializeComponent()
//
modifyMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { mnuSeenNone, mnuSeenAll, mnuCaughtNone, mnuCaughtAll, mnuComplete, mnuResetNav, mnuDexNav });
modifyMenu.Name = "modifyMenu";
modifyMenu.Size = new System.Drawing.Size(150, 158);
modifyMenu.Size = new System.Drawing.Size(159, 158);
//
// mnuSeenNone
//
mnuSeenNone.Name = "mnuSeenNone";
mnuSeenNone.Size = new System.Drawing.Size(149, 22);
mnuSeenNone.Size = new System.Drawing.Size(158, 22);
mnuSeenNone.Text = "Seen none";
mnuSeenNone.Click += ModifyAll;
//
// mnuSeenAll
//
mnuSeenAll.Name = "mnuSeenAll";
mnuSeenAll.Size = new System.Drawing.Size(149, 22);
mnuSeenAll.Size = new System.Drawing.Size(158, 22);
mnuSeenAll.Text = "Seen all";
mnuSeenAll.Click += ModifyAll;
//
// mnuCaughtNone
//
mnuCaughtNone.Name = "mnuCaughtNone";
mnuCaughtNone.Size = new System.Drawing.Size(149, 22);
mnuCaughtNone.Size = new System.Drawing.Size(158, 22);
mnuCaughtNone.Text = "Caught none";
mnuCaughtNone.Click += ModifyAll;
//
// mnuCaughtAll
//
mnuCaughtAll.Name = "mnuCaughtAll";
mnuCaughtAll.Size = new System.Drawing.Size(149, 22);
mnuCaughtAll.Size = new System.Drawing.Size(158, 22);
mnuCaughtAll.Text = "Caught all";
mnuCaughtAll.Click += ModifyAll;
//
// mnuComplete
//
mnuComplete.Name = "mnuComplete";
mnuComplete.Size = new System.Drawing.Size(149, 22);
mnuComplete.Size = new System.Drawing.Size(158, 22);
mnuComplete.Text = "Complete Dex";
mnuComplete.Click += ModifyAll;
//
// mnuResetNav
//
mnuResetNav.Name = "mnuResetNav";
mnuResetNav.Size = new System.Drawing.Size(149, 22);
mnuResetNav.Size = new System.Drawing.Size(158, 22);
mnuResetNav.Text = "Reset DexNav";
mnuResetNav.Click += ModifyAll;
//
// mnuDexNav
//
mnuDexNav.Name = "mnuDexNav";
mnuDexNav.Size = new System.Drawing.Size(149, 22);
mnuDexNav.Size = new System.Drawing.Size(158, 22);
mnuDexNav.Text = "999 DexNav";
mnuDexNav.Click += ModifyAll;
//
@ -515,7 +518,7 @@ private void InitializeComponent()
CLB_FormsSeen.Location = new System.Drawing.Point(447, 70);
CLB_FormsSeen.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CLB_FormsSeen.Name = "CLB_FormsSeen";
CLB_FormsSeen.Size = new System.Drawing.Size(138, 166);
CLB_FormsSeen.Size = new System.Drawing.Size(138, 164);
CLB_FormsSeen.TabIndex = 34;
//
// L_FormsSeen
@ -535,7 +538,7 @@ private void InitializeComponent()
CLB_FormDisplayed.Location = new System.Drawing.Point(593, 70);
CLB_FormDisplayed.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CLB_FormDisplayed.Name = "CLB_FormDisplayed";
CLB_FormDisplayed.Size = new System.Drawing.Size(138, 166);
CLB_FormDisplayed.Size = new System.Drawing.Size(138, 164);
CLB_FormDisplayed.TabIndex = 36;
CLB_FormDisplayed.ItemCheck += UpdateDisplayedForm;
//
@ -564,42 +567,87 @@ private void InitializeComponent()
//
modifyMenuForms.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { mnuFormNone, mnuForm1, mnuFormAll });
modifyMenuForms.Name = "modifyMenu";
modifyMenuForms.Size = new System.Drawing.Size(130, 70);
modifyMenuForms.Size = new System.Drawing.Size(138, 70);
//
// mnuFormNone
//
mnuFormNone.Name = "mnuFormNone";
mnuFormNone.Size = new System.Drawing.Size(129, 22);
mnuFormNone.Size = new System.Drawing.Size(137, 22);
mnuFormNone.Text = "Seen none";
mnuFormNone.Click += ModifyAllForms;
//
// mnuForm1
//
mnuForm1.Name = "mnuForm1";
mnuForm1.Size = new System.Drawing.Size(129, 22);
mnuForm1.Size = new System.Drawing.Size(137, 22);
mnuForm1.Text = "Seen one";
mnuForm1.Click += ModifyAllForms;
//
// mnuFormAll
//
mnuFormAll.Name = "mnuFormAll";
mnuFormAll.Size = new System.Drawing.Size(129, 22);
mnuFormAll.Size = new System.Drawing.Size(137, 22);
mnuFormAll.Text = "Seen all";
mnuFormAll.Click += ModifyAllForms;
//
// label1
//
label1.Location = new System.Drawing.Point(314, 279);
label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
label1.Name = "label1";
label1.Size = new System.Drawing.Size(121, 23);
label1.TabIndex = 39;
label1.Text = "Obtained:";
label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// MT_Obtained
//
MT_Obtained.Location = new System.Drawing.Point(447, 277);
MT_Obtained.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
MT_Obtained.Mask = "00000";
MT_Obtained.Name = "MT_Obtained";
MT_Obtained.Size = new System.Drawing.Size(37, 25);
MT_Obtained.TabIndex = 40;
MT_Obtained.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// CHK_NationalDexActive
//
CHK_NationalDexActive.AutoSize = true;
CHK_NationalDexActive.Location = new System.Drawing.Point(179, 290);
CHK_NationalDexActive.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CHK_NationalDexActive.Name = "CHK_NationalDexActive";
CHK_NationalDexActive.Size = new System.Drawing.Size(153, 21);
CHK_NationalDexActive.TabIndex = 48;
CHK_NationalDexActive.Text = "National Mode Active";
CHK_NationalDexActive.UseVisualStyleBackColor = true;
//
// CHK_NationalDexUnlocked
//
CHK_NationalDexUnlocked.AutoSize = true;
CHK_NationalDexUnlocked.Location = new System.Drawing.Point(179, 271);
CHK_NationalDexUnlocked.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CHK_NationalDexUnlocked.Name = "CHK_NationalDexUnlocked";
CHK_NationalDexUnlocked.Size = new System.Drawing.Size(173, 21);
CHK_NationalDexUnlocked.TabIndex = 47;
CHK_NationalDexUnlocked.Text = "National Mode Unlocked";
CHK_NationalDexUnlocked.UseVisualStyleBackColor = true;
//
// SAV_PokedexORAS
//
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
ClientSize = new System.Drawing.Size(740, 314);
Controls.Add(CHK_NationalDexActive);
Controls.Add(CHK_NationalDexUnlocked);
Controls.Add(MT_Obtained);
Controls.Add(label1);
Controls.Add(B_ModifyForms);
Controls.Add(L_FormDisplayed);
Controls.Add(CLB_FormDisplayed);
Controls.Add(L_FormsSeen);
Controls.Add(CLB_FormsSeen);
Controls.Add(L_DexNav);
Controls.Add(GB_Encountered);
Controls.Add(L_Spinda);
Controls.Add(MT_Count);
Controls.Add(MT_Seen);
Controls.Add(TB_Spinda);
Controls.Add(GB_Owned);
Controls.Add(GB_Displayed);
@ -611,6 +659,7 @@ private void InitializeComponent()
Controls.Add(L_goto);
Controls.Add(LB_Species);
Controls.Add(B_Cancel);
Controls.Add(L_DexNav);
FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
Icon = Properties.Resources.Icon;
Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
@ -659,7 +708,7 @@ private void InitializeComponent()
private System.Windows.Forms.GroupBox GB_Owned;
private System.Windows.Forms.TextBox TB_Spinda;
private System.Windows.Forms.Label L_Spinda;
private System.Windows.Forms.MaskedTextBox MT_Count;
private System.Windows.Forms.MaskedTextBox MT_Seen;
private System.Windows.Forms.Label L_DexNav;
private System.Windows.Forms.GroupBox GB_Encountered;
private System.Windows.Forms.CheckBox CHK_P5;
@ -683,5 +732,9 @@ private void InitializeComponent()
private System.Windows.Forms.ToolStripMenuItem mnuFormNone;
private System.Windows.Forms.ToolStripMenuItem mnuFormAll;
private System.Windows.Forms.ToolStripMenuItem mnuForm1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.MaskedTextBox MT_Obtained;
private System.Windows.Forms.CheckBox CHK_NationalDexActive;
private System.Windows.Forms.CheckBox CHK_NationalDexUnlocked;
}
}

View File

@ -10,6 +10,7 @@ public partial class SAV_PokedexORAS : Form
{
private readonly SaveFile Origin;
private readonly SAV6AO SAV;
private readonly Zukan6AO Zukan;
public SAV_PokedexORAS(SAV6AO sav)
{
@ -33,14 +34,19 @@ public SAV_PokedexORAS(SAV6AO sav)
LB_Species.Items.Add($"{i:000} - {GameInfo.Strings.specieslist[i]}");
editing = false;
LB_Species.SelectedIndex = 0;
TB_Spinda.Text = Zukan.SpindaPID.ToString("X8");
if (Zukan.InitialSpecies is not (0 or > 721))
CB_Species.SelectedValue = (int)Zukan.InitialSpecies;
else
LB_Species.SelectedIndex = 0;
CHK_NationalDexUnlocked.Checked = Zukan.IsNationalDexUnlocked;
CHK_NationalDexActive.Checked = Zukan.IsNationalDexMode;
CHK_NationalDexUnlocked.CheckedChanged += (_, _) => CHK_NationalDexActive.Checked = CHK_NationalDexUnlocked.Checked;
TB_Spinda.Text = Zukan.Spinda.ToString("X8");
CB_Species.KeyDown += WinFormsUtil.RemoveDropCB;
}
private readonly CheckBox[] CP;
private readonly CheckBox[] CL;
private readonly Zukan6AO Zukan;
private bool editing;
private ushort species = ushort.MaxValue;
@ -106,7 +112,7 @@ private void ChangeEncountered(object sender, EventArgs e)
}
}
private void GetEntry()
private void GetEntry(bool skipFormRepop = false)
{
// Load Bools for the data
int pk = species;
@ -119,73 +125,91 @@ private void GetEntry()
CP[i + 1].Checked = Zukan.GetSeen(species, i);
for (int i = 0; i < 4; i++)
CP[i + 5].Checked = Zukan.GetDisplayed(species - 1, i);
CP[i + 5].Checked = Zukan.GetDisplayed(species, i);
for (int i = 0; i < CL.Length; i++)
CL[i].Checked = Zukan.GetLanguageFlag(species - 1, i);
CL[i].Checked = Zukan.GetLanguageFlag(species, i);
var pi = SAV.Personal[pk];
CHK_P2.Enabled = CHK_P4.Enabled = CHK_P6.Enabled = CHK_P8.Enabled = !pi.OnlyFemale;
CHK_P3.Enabled = CHK_P5.Enabled = CHK_P7.Enabled = CHK_P9.Enabled = !(pi.OnlyMale || pi.Genderless);
MT_Count.Text = Zukan.GetEncounterCount(species - 1).ToString();
MT_Seen.Text = Zukan.GetCountSeen(species).ToString();
MT_Obtained.Text = Zukan.GetCountObtained(species).ToString();
var (index, count) = Zukan.GetFormIndex(species);
if (skipFormRepop)
{
// Just re-load without changing the text.
if (count == 0)
return;
for (int i = 0; i < count; i++)
{
CLB_FormsSeen.SetItemChecked(i, Zukan.GetFormFlag(index + i, 0));
CLB_FormsSeen.SetItemChecked(i + count, Zukan.GetFormFlag(index + i, 1));
CLB_FormDisplayed.SetItemChecked(i, Zukan.GetFormFlag(index + i, 2));
CLB_FormDisplayed.SetItemChecked(i + count, Zukan.GetFormFlag(index + i, 3));
}
return;
}
CLB_FormsSeen.Items.Clear();
CLB_FormDisplayed.Items.Clear();
var fc = pi.FormCount;
int f = DexFormUtil.GetDexFormIndexORAS(species, fc);
if (f < 0)
return;
string[] forms = FormConverter.GetFormList(species, GameInfo.Strings.types, GameInfo.Strings.forms, Main.GenderSymbols, SAV.Context);
if (count == 0)
return; // No forms to set.
var forms = FormConverter.GetFormList(species, GameInfo.Strings.types, GameInfo.Strings.forms, Main.GenderSymbols, SAV.Context);
if (forms.Length < 1)
return;
for (int i = 0; i < forms.Length; i++) // Seen
CLB_FormsSeen.Items.Add(forms[i], Zukan.GetFormFlag(f + i, 0));
CLB_FormsSeen.Items.Add(forms[i], Zukan.GetFormFlag(index + i, 0));
for (int i = 0; i < forms.Length; i++) // Seen Shiny
CLB_FormsSeen.Items.Add($"* {forms[i]}", Zukan.GetFormFlag(f + i, 1));
CLB_FormsSeen.Items.Add($"* {forms[i]}", Zukan.GetFormFlag(index + i, 1));
for (int i = 0; i < forms.Length; i++) // Displayed
CLB_FormDisplayed.Items.Add(forms[i], Zukan.GetFormFlag(f + i, 2));
CLB_FormDisplayed.Items.Add(forms[i], Zukan.GetFormFlag(index + i, 2));
for (int i = 0; i < forms.Length; i++) // Displayed Shiny
CLB_FormDisplayed.Items.Add($"* {forms[i]}", Zukan.GetFormFlag(f + i, 3));
CLB_FormDisplayed.Items.Add($"* {forms[i]}", Zukan.GetFormFlag(index + i, 3));
}
private void SetEntry()
{
if ((short)species <= 0)
if (species is 0 or > 721)
return;
Zukan.SetCaught(species, CP[0].Checked);
for (int i = 0; i < 4; i++)
Zukan.SetSeen(species, i, CP[i + 1].Checked);
for (int i = 0; i < 4; i++)
Zukan.SetDisplayed(species - 1, i, CP[i + 5].Checked);
Zukan.SetDisplayed(species, i, CP[i + 5].Checked);
for (int i = 0; i < CL.Length; i++)
Zukan.SetLanguageFlag(species - 1, i, CL[i].Checked);
Zukan.SetLanguageFlag(species, i, CL[i].Checked);
ushort count = (ushort)Math.Min(0xFFFF, Util.ToUInt32(MT_Count.Text));
Zukan.SetEncounterCount(species - 1, count);
Zukan.SetCountSeen(species, Clamp(MT_Seen.Text));
Zukan.SetCountObtained(species, Clamp(MT_Obtained.Text));
var fc = SAV.Personal[species].FormCount;
int f = DexFormUtil.GetDexFormIndexORAS(species, fc);
if (f < 0)
return;
var (index, count) = Zukan.GetFormIndex(species);
if (count == 0)
return; // No forms to set.
var seen = CLB_FormsSeen;
for (int i = 0; i < seen.Items.Count / 2; i++) // Seen
Zukan.SetFormFlag(f + i, 0, seen.GetItemChecked(i));
Zukan.SetFormFlag(index + i, 0, seen.GetItemChecked(i));
for (int i = 0; i < seen.Items.Count / 2; i++) // Seen Shiny
Zukan.SetFormFlag(f + i, 1, seen.GetItemChecked(i + (seen.Items.Count / 2)));
Zukan.SetFormFlag(index + i, 1, seen.GetItemChecked(i + (seen.Items.Count / 2)));
var display = CLB_FormDisplayed;
for (int i = 0; i < display.Items.Count / 2; i++) // Displayed
Zukan.SetFormFlag(f + i, 2, display.GetItemChecked(i));
Zukan.SetFormFlag(index + i, 2, display.GetItemChecked(i));
for (int i = 0; i < display.Items.Count / 2; i++) // Displayed Shiny
Zukan.SetFormFlag(f + i, 3, display.GetItemChecked(i + (display.Items.Count / 2)));
Zukan.SetFormFlag(index + i, 3, display.GetItemChecked(i + (display.Items.Count / 2)));
return;
static ushort Clamp(ReadOnlySpan<char> text) => (ushort)Math.Clamp(Util.ToUInt32(text), 0, ushort.MaxValue);
}
private void B_Cancel_Click(object sender, EventArgs e)
@ -196,52 +220,25 @@ private void B_Cancel_Click(object sender, EventArgs e)
private void B_Save_Click(object sender, EventArgs e)
{
SetEntry();
Zukan.SpindaPID = Util.GetHexValue(TB_Spinda.Text);
Zukan.IsNationalDexUnlocked = CHK_NationalDexUnlocked.Checked;
Zukan.IsNationalDexMode = CHK_NationalDexActive.Checked;
Zukan.Spinda = Util.GetHexValue(TB_Spinda.Text);
if (species is not 0)
Zukan.InitialSpecies = species;
Origin.CopyChangesFrom(SAV);
Close();
}
private void B_GiveAll_Click(object sender, EventArgs e)
{
if (CHK_L1.Enabled)
{
CHK_L1.Checked =
CHK_L2.Checked =
CHK_L3.Checked =
CHK_L4.Checked =
CHK_L5.Checked =
CHK_L6.Checked =
CHK_L7.Checked = ModifierKeys != Keys.Control;
}
if (CHK_P1.Enabled)
{
CHK_P1.Checked = ModifierKeys != Keys.Control;
}
int index = LB_Species.SelectedIndex + 1;
byte gt = SAV.Personal[index].Gender;
SetEntry();
var language = (LanguageID)SAV.Language;
Zukan.GiveAll(species, ModifierKeys != Keys.Alt, ModifierKeys.HasFlag(Keys.Shift), language, ModifierKeys.HasFlag(Keys.Control));
GetEntry(skipFormRepop: true);
System.Media.SystemSounds.Asterisk.Play();
bool canBeMale = gt != PersonalInfo.RatioMagicFemale;
bool canBeFemale = gt is not (PersonalInfo.RatioMagicMale or PersonalInfo.RatioMagicGenderless);
CHK_P2.Checked = CHK_P4.Checked = canBeMale && ModifierKeys != Keys.Control;
CHK_P3.Checked = CHK_P5.Checked = canBeFemale && ModifierKeys != Keys.Control;
if (ModifierKeys == Keys.Control)
{
foreach (var chk in new[] { CHK_P6, CHK_P7, CHK_P8, CHK_P9 })
chk.Checked = false;
}
else if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked))
{
(gt != PersonalInfo.RatioMagicFemale ? CHK_P6 : CHK_P7).Checked = true;
}
for (int i = 0; i < CLB_FormsSeen.Items.Count; i++)
CLB_FormsSeen.SetItemChecked(i, ModifierKeys != Keys.Control);
if (CLB_FormsSeen.Items.Count > 0 && CLB_FormDisplayed.CheckedItems.Count == 0)
CLB_FormDisplayed.SetItemChecked(0, ModifierKeys != Keys.Control);
if (Util.ToInt32(MT_Count.Text) == 0)
MT_Count.Text = "1";
if (Zukan.GetCaught(species) && Zukan.GetCountSeen(species) == 0)
MT_Seen.Text = 1.ToString();
}
private void B_Modify_Click(object sender, EventArgs e)
@ -254,94 +251,29 @@ private void ModifyAll(object sender, EventArgs e)
{
if (mnuDexNav == sender)
{
for (int i = 0; i < SAV.MaxSpeciesID; i++)
Zukan.SetEncounterCount(i, 999);
for (ushort i = 0; i < SAV.MaxSpeciesID; i++)
Zukan.SetCountSeen(i, 999);
return;
}
if (mnuResetNav == sender)
{
for (int i = 0; i < SAV.MaxSpeciesID; i++)
Zukan.SetEncounterCount(i, 0);
for (ushort i = 0; i < SAV.MaxSpeciesID; i++)
Zukan.SetCountSeen(i, 0);
return;
}
int lang = SAV.Language;
if (lang > 5) lang--;
lang--;
if (sender == mnuSeenNone || sender == mnuSeenAll || sender == mnuComplete)
{
for (int i = 0; i < CB_Species.Items.Count; i++)
{
LB_Species.SelectedIndex = i;
foreach (CheckBox t in new[] { CHK_P2, CHK_P3, CHK_P4, CHK_P5 })
t.Checked = mnuSeenNone != sender && t.Enabled;
if (mnuSeenNone != sender)
{
// if seen ensure at least one Displayed
byte gt = SAV.Personal[i + 1].Gender;
if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked))
(gt != PersonalInfo.RatioMagicFemale ? CHK_P6 : CHK_P7).Checked = true;
}
else
{
foreach (CheckBox t in CP)
t.Checked = false;
}
if (!CHK_P1.Checked)
{
foreach (CheckBox t in CL)
t.Checked = false;
}
}
}
if (sender == mnuCaughtNone || sender == mnuCaughtAll || sender == mnuComplete)
{
for (int i = 0; i < LB_Species.Items.Count; i++)
{
byte gt = SAV.Personal[i + 1].Gender;
LB_Species.SelectedIndex = i;
foreach (CheckBox t in new[] { CHK_P1 })
t.Checked = mnuCaughtNone != sender;
for (int j = 0; j < CL.Length; j++)
CL[j].Checked = sender == mnuComplete || (mnuCaughtNone != sender && j == lang);
if (mnuCaughtNone == sender)
{
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
(gt != PersonalInfo.RatioMagicFemale ? CHK_P6 : CHK_P7).Checked = true; // check one
}
}
if (mnuCaughtNone != sender)
{
if (mnuComplete == sender)
{
bool canBeMale = gt != PersonalInfo.RatioMagicFemale;
bool canBeFemale = gt is not (PersonalInfo.RatioMagicMale or PersonalInfo.RatioMagicGenderless);
CHK_P2.Checked = CHK_P4.Checked = canBeMale;
CHK_P3.Checked = CHK_P5.Checked = canBeFemale;
}
else
{
// ensure at least one SEEN
if (!(CHK_P2.Checked || CHK_P3.Checked || CHK_P4.Checked || CHK_P5.Checked))
(gt != PersonalInfo.RatioMagicFemale ? CHK_P2 : CHK_P3).Checked = true;
}
// ensure at least one Displayed
if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked))
(gt != PersonalInfo.RatioMagicFemale ? CHK_P6 : CHK_P7).Checked = true;
}
}
}
SetEntry();
GetEntry();
var language = (LanguageID)SAV.Language;
if (sender == mnuSeenNone)
Zukan.SeenNone();
if (sender == mnuSeenAll || sender == mnuComplete)
Zukan.SeenAll(shinyToo: ModifierKeys.HasFlag(Keys.Shift));
if (sender == mnuCaughtNone)
Zukan.CaughtNone();
if (sender == mnuCaughtAll || sender == mnuComplete)
Zukan.CaughtAll(language, allLanguages: ModifierKeys.HasFlag(Keys.Control));
GetEntry(skipFormRepop: true);
System.Media.SystemSounds.Asterisk.Play();
}
private void UpdateDisplayedForm(object sender, ItemCheckEventArgs e)
@ -369,34 +301,14 @@ private void B_ModifyForms_Click(object sender, EventArgs e)
private void ModifyAllForms(object sender, EventArgs e)
{
for (int i = 0; i < CB_Species.Items.Count; i++)
{
LB_Species.SelectedIndex = i;
if (CLB_FormsSeen.Items.Count == 0)
continue;
if (sender == mnuForm1)
{
if (CLB_FormsSeen.CheckedItems.Count == 0)
CLB_FormsSeen.SetItemChecked(0, true);
if (CLB_FormDisplayed.CheckedItems.Count == 0)
CLB_FormDisplayed.SetItemChecked(0, true);
}
else if (sender == mnuFormAll)
{
for (int f = 0; f < CLB_FormsSeen.Items.Count; f++)
CLB_FormsSeen.SetItemChecked(f, true);
if (CLB_FormDisplayed.CheckedItems.Count == 0)
CLB_FormDisplayed.SetItemChecked(0, true);
}
else // none
{
for (int f = 0; f < CLB_FormsSeen.Items.Count; f++)
CLB_FormsSeen.SetItemChecked(f, false);
for (int f = 0; f < CLB_FormDisplayed.Items.Count; f++)
CLB_FormDisplayed.SetItemChecked(f, false);
}
}
SetEntry();
if (sender == mnuFormNone)
Zukan.ClearFormSeen();
else if (sender == mnuForm1)
Zukan.SetFormsSeen1(shinyToo: ModifierKeys.HasFlag(Keys.Shift));
else if (sender == mnuFormAll)
Zukan.SetFormsSeen(shinyToo: ModifierKeys.HasFlag(Keys.Shift));
GetEntry(skipFormRepop: true);
System.Media.SystemSounds.Asterisk.Play();
}
}

View File

@ -1,4 +1,4 @@
namespace PKHeX.WinForms
namespace PKHeX.WinForms
{
partial class SAV_PokedexXY
{
@ -74,6 +74,8 @@ private void InitializeComponent()
mnuFormNone = new System.Windows.Forms.ToolStripMenuItem();
mnuForm1 = new System.Windows.Forms.ToolStripMenuItem();
mnuFormAll = new System.Windows.Forms.ToolStripMenuItem();
CHK_NationalDexActive = new System.Windows.Forms.CheckBox();
CHK_NationalDexUnlocked = new System.Windows.Forms.CheckBox();
GB_Language.SuspendLayout();
GB_Encountered.SuspendLayout();
GB_Owned.SuspendLayout();
@ -96,7 +98,6 @@ private void InitializeComponent()
// LB_Species
//
LB_Species.FormattingEnabled = true;
LB_Species.ItemHeight = 15;
LB_Species.Location = new System.Drawing.Point(14, 46);
LB_Species.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
LB_Species.Name = "LB_Species";
@ -110,7 +111,7 @@ private void InitializeComponent()
CHK_P1.Location = new System.Drawing.Point(7, 16);
CHK_P1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CHK_P1.Name = "CHK_P1";
CHK_P1.Size = new System.Drawing.Size(99, 19);
CHK_P1.Size = new System.Drawing.Size(108, 21);
CHK_P1.TabIndex = 3;
CHK_P1.Text = "Native (Kalos)";
CHK_P1.UseVisualStyleBackColor = true;
@ -121,7 +122,7 @@ private void InitializeComponent()
CHK_P2.Location = new System.Drawing.Point(7, 17);
CHK_P2.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CHK_P2.Name = "CHK_P2";
CHK_P2.Size = new System.Drawing.Size(52, 19);
CHK_P2.Size = new System.Drawing.Size(56, 21);
CHK_P2.TabIndex = 4;
CHK_P2.Text = "Male";
CHK_P2.UseVisualStyleBackColor = true;
@ -133,7 +134,7 @@ private void InitializeComponent()
CHK_P3.Location = new System.Drawing.Point(7, 33);
CHK_P3.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CHK_P3.Name = "CHK_P3";
CHK_P3.Size = new System.Drawing.Size(64, 19);
CHK_P3.Size = new System.Drawing.Size(68, 21);
CHK_P3.TabIndex = 5;
CHK_P3.Text = "Female";
CHK_P3.UseVisualStyleBackColor = true;
@ -145,7 +146,7 @@ private void InitializeComponent()
CHK_P4.Location = new System.Drawing.Point(7, 50);
CHK_P4.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CHK_P4.Name = "CHK_P4";
CHK_P4.Size = new System.Drawing.Size(84, 19);
CHK_P4.Size = new System.Drawing.Size(90, 21);
CHK_P4.TabIndex = 6;
CHK_P4.Text = "Shiny Male";
CHK_P4.UseVisualStyleBackColor = true;
@ -157,7 +158,7 @@ private void InitializeComponent()
CHK_P5.Location = new System.Drawing.Point(7, 66);
CHK_P5.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CHK_P5.Name = "CHK_P5";
CHK_P5.Size = new System.Drawing.Size(96, 19);
CHK_P5.Size = new System.Drawing.Size(102, 21);
CHK_P5.TabIndex = 7;
CHK_P5.Text = "Shiny Female";
CHK_P5.UseVisualStyleBackColor = true;
@ -169,7 +170,7 @@ private void InitializeComponent()
CHK_P6.Location = new System.Drawing.Point(6, 16);
CHK_P6.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CHK_P6.Name = "CHK_P6";
CHK_P6.Size = new System.Drawing.Size(52, 19);
CHK_P6.Size = new System.Drawing.Size(56, 21);
CHK_P6.TabIndex = 8;
CHK_P6.Text = "Male";
CHK_P6.UseVisualStyleBackColor = true;
@ -181,7 +182,7 @@ private void InitializeComponent()
CHK_P7.Location = new System.Drawing.Point(6, 32);
CHK_P7.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CHK_P7.Name = "CHK_P7";
CHK_P7.Size = new System.Drawing.Size(64, 19);
CHK_P7.Size = new System.Drawing.Size(68, 21);
CHK_P7.TabIndex = 9;
CHK_P7.Text = "Female";
CHK_P7.UseVisualStyleBackColor = true;
@ -193,7 +194,7 @@ private void InitializeComponent()
CHK_P8.Location = new System.Drawing.Point(6, 48);
CHK_P8.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CHK_P8.Name = "CHK_P8";
CHK_P8.Size = new System.Drawing.Size(84, 19);
CHK_P8.Size = new System.Drawing.Size(90, 21);
CHK_P8.TabIndex = 10;
CHK_P8.Text = "Shiny Male";
CHK_P8.UseVisualStyleBackColor = true;
@ -205,7 +206,7 @@ private void InitializeComponent()
CHK_P9.Location = new System.Drawing.Point(6, 65);
CHK_P9.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CHK_P9.Name = "CHK_P9";
CHK_P9.Size = new System.Drawing.Size(96, 19);
CHK_P9.Size = new System.Drawing.Size(102, 21);
CHK_P9.TabIndex = 11;
CHK_P9.Text = "Shiny Female";
CHK_P9.UseVisualStyleBackColor = true;
@ -217,7 +218,7 @@ private void InitializeComponent()
CHK_L7.Location = new System.Drawing.Point(21, 144);
CHK_L7.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CHK_L7.Name = "CHK_L7";
CHK_L7.Size = new System.Drawing.Size(63, 19);
CHK_L7.Size = new System.Drawing.Size(69, 21);
CHK_L7.TabIndex = 19;
CHK_L7.Text = "Korean";
CHK_L7.UseVisualStyleBackColor = true;
@ -228,7 +229,7 @@ private void InitializeComponent()
CHK_L6.Location = new System.Drawing.Point(21, 125);
CHK_L6.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CHK_L6.Name = "CHK_L6";
CHK_L6.Size = new System.Drawing.Size(67, 19);
CHK_L6.Size = new System.Drawing.Size(72, 21);
CHK_L6.TabIndex = 18;
CHK_L6.Text = "Spanish";
CHK_L6.UseVisualStyleBackColor = true;
@ -239,7 +240,7 @@ private void InitializeComponent()
CHK_L5.Location = new System.Drawing.Point(21, 105);
CHK_L5.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CHK_L5.Name = "CHK_L5";
CHK_L5.Size = new System.Drawing.Size(68, 19);
CHK_L5.Size = new System.Drawing.Size(73, 21);
CHK_L5.TabIndex = 17;
CHK_L5.Text = "German";
CHK_L5.UseVisualStyleBackColor = true;
@ -250,7 +251,7 @@ private void InitializeComponent()
CHK_L4.Location = new System.Drawing.Point(21, 85);
CHK_L4.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CHK_L4.Name = "CHK_L4";
CHK_L4.Size = new System.Drawing.Size(58, 19);
CHK_L4.Size = new System.Drawing.Size(61, 21);
CHK_L4.TabIndex = 16;
CHK_L4.Text = "Italian";
CHK_L4.UseVisualStyleBackColor = true;
@ -261,7 +262,7 @@ private void InitializeComponent()
CHK_L3.Location = new System.Drawing.Point(21, 66);
CHK_L3.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CHK_L3.Name = "CHK_L3";
CHK_L3.Size = new System.Drawing.Size(62, 19);
CHK_L3.Size = new System.Drawing.Size(65, 21);
CHK_L3.TabIndex = 15;
CHK_L3.Text = "French";
CHK_L3.UseVisualStyleBackColor = true;
@ -272,7 +273,7 @@ private void InitializeComponent()
CHK_L2.Location = new System.Drawing.Point(21, 46);
CHK_L2.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CHK_L2.Name = "CHK_L2";
CHK_L2.Size = new System.Drawing.Size(64, 19);
CHK_L2.Size = new System.Drawing.Size(68, 21);
CHK_L2.TabIndex = 14;
CHK_L2.Text = "English";
CHK_L2.UseVisualStyleBackColor = true;
@ -283,7 +284,7 @@ private void InitializeComponent()
CHK_L1.Location = new System.Drawing.Point(21, 27);
CHK_L1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CHK_L1.Name = "CHK_L1";
CHK_L1.Size = new System.Drawing.Size(73, 19);
CHK_L1.Size = new System.Drawing.Size(81, 21);
CHK_L1.TabIndex = 13;
CHK_L1.Text = "Japanese";
CHK_L1.UseVisualStyleBackColor = true;
@ -294,7 +295,7 @@ private void InitializeComponent()
L_goto.Location = new System.Drawing.Point(14, 18);
L_goto.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
L_goto.Name = "L_goto";
L_goto.Size = new System.Drawing.Size(35, 15);
L_goto.Size = new System.Drawing.Size(39, 17);
L_goto.TabIndex = 20;
L_goto.Text = "goto:";
//
@ -308,7 +309,7 @@ private void InitializeComponent()
CB_Species.Location = new System.Drawing.Point(58, 15);
CB_Species.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CB_Species.Name = "CB_Species";
CB_Species.Size = new System.Drawing.Size(107, 23);
CB_Species.Size = new System.Drawing.Size(107, 25);
CB_Species.TabIndex = 21;
CB_Species.SelectedIndexChanged += ChangeCBSpecies;
CB_Species.SelectedValueChanged += ChangeCBSpecies;
@ -398,7 +399,7 @@ private void InitializeComponent()
CHK_F1.Location = new System.Drawing.Point(7, 32);
CHK_F1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CHK_F1.Name = "CHK_F1";
CHK_F1.Size = new System.Drawing.Size(94, 19);
CHK_F1.Size = new System.Drawing.Size(102, 21);
CHK_F1.TabIndex = 13;
CHK_F1.Text = "Foreign (Pre)";
CHK_F1.UseVisualStyleBackColor = true;
@ -406,7 +407,7 @@ private void InitializeComponent()
// TB_Spinda
//
TB_Spinda.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
TB_Spinda.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
TB_Spinda.Font = new System.Drawing.Font("Courier New", 8.25F);
TB_Spinda.Location = new System.Drawing.Point(370, 225);
TB_Spinda.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
TB_Spinda.Name = "TB_Spinda";
@ -420,7 +421,7 @@ private void InitializeComponent()
L_Spinda.Location = new System.Drawing.Point(314, 228);
L_Spinda.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
L_Spinda.Name = "L_Spinda";
L_Spinda.Size = new System.Drawing.Size(46, 15);
L_Spinda.Size = new System.Drawing.Size(51, 17);
L_Spinda.TabIndex = 30;
L_Spinda.Text = "Spinda:";
//
@ -443,40 +444,40 @@ private void InitializeComponent()
//
modifyMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { mnuSeenNone, mnuSeenAll, mnuCaughtNone, mnuCaughtAll, mnuComplete });
modifyMenu.Name = "modifyMenu";
modifyMenu.Size = new System.Drawing.Size(150, 114);
modifyMenu.Size = new System.Drawing.Size(159, 114);
//
// mnuSeenNone
//
mnuSeenNone.Name = "mnuSeenNone";
mnuSeenNone.Size = new System.Drawing.Size(149, 22);
mnuSeenNone.Size = new System.Drawing.Size(158, 22);
mnuSeenNone.Text = "Seen none";
mnuSeenNone.Click += ModifyAll;
//
// mnuSeenAll
//
mnuSeenAll.Name = "mnuSeenAll";
mnuSeenAll.Size = new System.Drawing.Size(149, 22);
mnuSeenAll.Size = new System.Drawing.Size(158, 22);
mnuSeenAll.Text = "Seen all";
mnuSeenAll.Click += ModifyAll;
//
// mnuCaughtNone
//
mnuCaughtNone.Name = "mnuCaughtNone";
mnuCaughtNone.Size = new System.Drawing.Size(149, 22);
mnuCaughtNone.Size = new System.Drawing.Size(158, 22);
mnuCaughtNone.Text = "Caught none";
mnuCaughtNone.Click += ModifyAll;
//
// mnuCaughtAll
//
mnuCaughtAll.Name = "mnuCaughtAll";
mnuCaughtAll.Size = new System.Drawing.Size(149, 22);
mnuCaughtAll.Size = new System.Drawing.Size(158, 22);
mnuCaughtAll.Text = "Caught all";
mnuCaughtAll.Click += ModifyAll;
//
// mnuComplete
//
mnuComplete.Name = "mnuComplete";
mnuComplete.Size = new System.Drawing.Size(149, 22);
mnuComplete.Size = new System.Drawing.Size(158, 22);
mnuComplete.Text = "Complete Dex";
mnuComplete.Click += ModifyAll;
//
@ -508,7 +509,7 @@ private void InitializeComponent()
CLB_FormDisplayed.Location = new System.Drawing.Point(593, 70);
CLB_FormDisplayed.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CLB_FormDisplayed.Name = "CLB_FormDisplayed";
CLB_FormDisplayed.Size = new System.Drawing.Size(138, 166);
CLB_FormDisplayed.Size = new System.Drawing.Size(138, 164);
CLB_FormDisplayed.TabIndex = 41;
CLB_FormDisplayed.ItemCheck += UpdateDisplayedForm;
//
@ -529,40 +530,64 @@ private void InitializeComponent()
CLB_FormsSeen.Location = new System.Drawing.Point(447, 70);
CLB_FormsSeen.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CLB_FormsSeen.Name = "CLB_FormsSeen";
CLB_FormsSeen.Size = new System.Drawing.Size(138, 166);
CLB_FormsSeen.Size = new System.Drawing.Size(138, 164);
CLB_FormsSeen.TabIndex = 39;
//
// modifyMenuForms
//
modifyMenuForms.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { mnuFormNone, mnuForm1, mnuFormAll });
modifyMenuForms.Name = "modifyMenu";
modifyMenuForms.Size = new System.Drawing.Size(130, 70);
modifyMenuForms.Size = new System.Drawing.Size(138, 70);
//
// mnuFormNone
//
mnuFormNone.Name = "mnuFormNone";
mnuFormNone.Size = new System.Drawing.Size(129, 22);
mnuFormNone.Size = new System.Drawing.Size(137, 22);
mnuFormNone.Text = "Seen none";
mnuFormNone.Click += ModifyAllForms;
//
// mnuForm1
//
mnuForm1.Name = "mnuForm1";
mnuForm1.Size = new System.Drawing.Size(129, 22);
mnuForm1.Size = new System.Drawing.Size(137, 22);
mnuForm1.Text = "Seen one";
mnuForm1.Click += ModifyAllForms;
//
// mnuFormAll
//
mnuFormAll.Name = "mnuFormAll";
mnuFormAll.Size = new System.Drawing.Size(129, 22);
mnuFormAll.Size = new System.Drawing.Size(137, 22);
mnuFormAll.Text = "Seen all";
mnuFormAll.Click += ModifyAllForms;
//
// CHK_NationalDexActive
//
CHK_NationalDexActive.AutoSize = true;
CHK_NationalDexActive.Location = new System.Drawing.Point(315, 282);
CHK_NationalDexActive.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CHK_NationalDexActive.Name = "CHK_NationalDexActive";
CHK_NationalDexActive.Size = new System.Drawing.Size(153, 21);
CHK_NationalDexActive.TabIndex = 50;
CHK_NationalDexActive.Text = "National Mode Active";
CHK_NationalDexActive.UseVisualStyleBackColor = true;
//
// CHK_NationalDexUnlocked
//
CHK_NationalDexUnlocked.AutoSize = true;
CHK_NationalDexUnlocked.Location = new System.Drawing.Point(315, 263);
CHK_NationalDexUnlocked.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
CHK_NationalDexUnlocked.Name = "CHK_NationalDexUnlocked";
CHK_NationalDexUnlocked.Size = new System.Drawing.Size(173, 21);
CHK_NationalDexUnlocked.TabIndex = 49;
CHK_NationalDexUnlocked.Text = "National Mode Unlocked";
CHK_NationalDexUnlocked.UseVisualStyleBackColor = true;
//
// SAV_PokedexXY
//
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
ClientSize = new System.Drawing.Size(740, 314);
Controls.Add(CHK_NationalDexActive);
Controls.Add(CHK_NationalDexUnlocked);
Controls.Add(B_ModifyForms);
Controls.Add(L_FormDisplayed);
Controls.Add(CLB_FormDisplayed);
@ -650,5 +675,7 @@ private void InitializeComponent()
private System.Windows.Forms.ToolStripMenuItem mnuFormNone;
private System.Windows.Forms.ToolStripMenuItem mnuForm1;
private System.Windows.Forms.ToolStripMenuItem mnuFormAll;
private System.Windows.Forms.CheckBox CHK_NationalDexActive;
private System.Windows.Forms.CheckBox CHK_NationalDexUnlocked;
}
}

View File

@ -33,8 +33,14 @@ public SAV_PokedexXY(SaveFile sav)
LB_Species.Items.Add($"{i:000} - {GameInfo.Strings.specieslist[i]}");
editing = false;
LB_Species.SelectedIndex = 0;
TB_Spinda.Text = Zukan.SpindaPID.ToString("X8");
if (Zukan.InitialSpecies is not (0 or > 721))
CB_Species.SelectedValue = (int)Zukan.InitialSpecies;
else
LB_Species.SelectedIndex = 0;
CHK_NationalDexUnlocked.Checked = Zukan.IsNationalDexUnlocked;
CHK_NationalDexActive.Checked = Zukan.IsNationalDexMode;
CHK_NationalDexUnlocked.CheckedChanged += (_, _) => CHK_NationalDexActive.Checked = CHK_NationalDexUnlocked.Checked;
TB_Spinda.Text = Zukan.Spinda.ToString("X8");
CB_Species.KeyDown += WinFormsUtil.RemoveDropCB;
}
@ -106,7 +112,7 @@ private void ChangeEncountered(object sender, EventArgs e)
}
}
private void GetEntry()
private void GetEntry(bool skipFormRepop = false)
{
// Load Bools for the data
int pk = species;
@ -119,15 +125,15 @@ private void GetEntry()
CP[i + 1].Checked = Zukan.GetSeen(species, i);
for (int i = 0; i < 4; i++)
CP[i + 5].Checked = Zukan.GetDisplayed(species - 1, i);
CP[i + 5].Checked = Zukan.GetDisplayed(species, i);
for (int i = 0; i < CL.Length; i++)
CL[i].Checked = Zukan.GetLanguageFlag(species - 1, i);
CL[i].Checked = Zukan.GetLanguageFlag(species, i);
if (pk <= (int)Species.Genesect)
{
CHK_F1.Enabled = true;
CHK_F1.Checked = Zukan.GetForeignFlag(species - 1);
CHK_F1.Checked = Zukan.GetForeignFlag(species);
}
else
{
@ -139,62 +145,75 @@ private void GetEntry()
CHK_P2.Enabled = CHK_P4.Enabled = CHK_P6.Enabled = CHK_P8.Enabled = !pi.OnlyFemale;
CHK_P3.Enabled = CHK_P5.Enabled = CHK_P7.Enabled = CHK_P9.Enabled = !(pi.OnlyMale || pi.Genderless);
var (index, count) = Zukan.GetFormIndex(species);
if (skipFormRepop)
{
// Just re-load without changing the text.
if (count == 0)
return;
for (int i = 0; i < count; i++)
{
CLB_FormsSeen.SetItemChecked(i, Zukan.GetFormFlag(index + i, 0));
CLB_FormsSeen.SetItemChecked(i + count, Zukan.GetFormFlag(index + i, 1));
CLB_FormDisplayed.SetItemChecked(i, Zukan.GetFormFlag(index + i, 2));
CLB_FormDisplayed.SetItemChecked(i + count, Zukan.GetFormFlag(index + i, 3));
}
return;
}
CLB_FormsSeen.Items.Clear();
CLB_FormDisplayed.Items.Clear();
var fc = pi.FormCount;
int f = DexFormUtil.GetDexFormIndexXY(species, fc);
if (f < 0)
return;
string[] forms = FormConverter.GetFormList(species, GameInfo.Strings.types, GameInfo.Strings.forms, Main.GenderSymbols, SAV.Context);
if (count == 0)
return; // No forms to set.
var forms = FormConverter.GetFormList(species, GameInfo.Strings.types, GameInfo.Strings.forms, Main.GenderSymbols, SAV.Context);
if (forms.Length < 1)
return;
// 0x26 packs of bools
for (int i = 0; i < forms.Length; i++) // Seen
CLB_FormsSeen.Items.Add(forms[i], Zukan.GetFormFlag(f + i, 0));
CLB_FormsSeen.Items.Add(forms[i], Zukan.GetFormFlag(TabIndex + i, 0));
for (int i = 0; i < forms.Length; i++) // Seen Shiny
CLB_FormsSeen.Items.Add($"* {forms[i]}", Zukan.GetFormFlag(f + i, 1));
CLB_FormsSeen.Items.Add($"* {forms[i]}", Zukan.GetFormFlag(TabIndex + i, 1));
for (int i = 0; i < forms.Length; i++) // Displayed
CLB_FormDisplayed.Items.Add(forms[i], Zukan.GetFormFlag(f + i, 2));
CLB_FormDisplayed.Items.Add(forms[i], Zukan.GetFormFlag(TabIndex + i, 2));
for (int i = 0; i < forms.Length; i++) // Displayed Shiny
CLB_FormDisplayed.Items.Add($"* {forms[i]}", Zukan.GetFormFlag(f + i, 3));
CLB_FormDisplayed.Items.Add($"* {forms[i]}", Zukan.GetFormFlag(TabIndex + i, 3));
}
private void SetEntry()
{
if (species > 721)
if (species is 0 or > 721)
return;
Zukan.SetCaught(species, CP[0].Checked);
for (int i = 0; i < 4; i++)
Zukan.SetSeen(species, i, CP[i + 1].Checked);
for (int i = 0; i < 4; i++)
Zukan.SetDisplayed(species - 1, i, CP[i + 5].Checked);
Zukan.SetDisplayed(species, i, CP[i + 5].Checked);
for (int i = 0; i < CL.Length; i++)
Zukan.SetLanguageFlag(species - 1, i, CL[i].Checked);
Zukan.SetLanguageFlag(species, i, CL[i].Checked);
if (CHK_F1.Enabled) // species < 650 // (1-649)
Zukan.SetForeignFlag(species - 1, CHK_F1.Checked);
Zukan.SetForeignFlag(species, CHK_F1.Checked);
var fc = SAV.Personal[species].FormCount;
int f = DexFormUtil.GetDexFormIndexORAS(species, fc);
if (f < 0)
return;
var (index, count) = Zukan.GetFormIndex(species);
if (count == 0)
return; // No forms to set.
var seen = CLB_FormsSeen;
for (int i = 0; i < seen.Items.Count / 2; i++) // Seen
Zukan.SetFormFlag(f + i, 0, seen.GetItemChecked(i));
Zukan.SetFormFlag(index + i, 0, seen.GetItemChecked(i));
for (int i = 0; i < seen.Items.Count / 2; i++) // Seen Shiny
Zukan.SetFormFlag(f + i, 1, seen.GetItemChecked(i + (seen.Items.Count / 2)));
Zukan.SetFormFlag(index + i, 1, seen.GetItemChecked(i + (seen.Items.Count / 2)));
var display = CLB_FormDisplayed;
for (int i = 0; i < display.Items.Count / 2; i++) // Displayed
Zukan.SetFormFlag(f + i, 2, display.GetItemChecked(i));
Zukan.SetFormFlag(index + i, 2, display.GetItemChecked(i));
for (int i = 0; i < display.Items.Count / 2; i++) // Displayed Shiny
Zukan.SetFormFlag(f + i, 3, display.GetItemChecked(i + (display.Items.Count / 2)));
Zukan.SetFormFlag(index + i, 3, display.GetItemChecked(i + (display.Items.Count / 2)));
}
private void B_Cancel_Click(object sender, EventArgs e)
@ -205,48 +224,22 @@ private void B_Cancel_Click(object sender, EventArgs e)
private void B_Save_Click(object sender, EventArgs e)
{
SetEntry();
Zukan.SpindaPID = Util.GetHexValue(TB_Spinda.Text);
Zukan.IsNationalDexUnlocked = CHK_NationalDexUnlocked.Checked;
Zukan.IsNationalDexMode = CHK_NationalDexActive.Checked;
Zukan.Spinda = Util.GetHexValue(TB_Spinda.Text);
if (species is not 0)
Zukan.InitialSpecies = species;
Origin.CopyChangesFrom(SAV);
Close();
}
private void B_GiveAll_Click(object sender, EventArgs e)
{
if (CHK_L1.Enabled)
{
CHK_L1.Checked =
CHK_L2.Checked =
CHK_L3.Checked =
CHK_L4.Checked =
CHK_L5.Checked =
CHK_L6.Checked =
CHK_L7.Checked = ModifierKeys != Keys.Control;
}
if (CHK_P1.Enabled)
{
CHK_P1.Checked = ModifierKeys != Keys.Control;
}
if (CHK_F1.Enabled)
{
CHK_F1.Checked = ModifierKeys != Keys.Control;
}
int index = LB_Species.SelectedIndex + 1;
byte gt = SAV.Personal[index].Gender;
bool canBeMale = gt != PersonalInfo.RatioMagicFemale;
bool canBeFemale = gt is not (PersonalInfo.RatioMagicMale or PersonalInfo.RatioMagicGenderless);
CHK_P2.Checked = CHK_P4.Checked = canBeMale && ModifierKeys != Keys.Control;
CHK_P3.Checked = CHK_P5.Checked = canBeFemale && ModifierKeys != Keys.Control;
if (ModifierKeys == Keys.Control)
{
foreach (var chk in new[] { CHK_P6, CHK_P7, CHK_P8, CHK_P9 })
chk.Checked = false;
}
else if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked))
{
(gt != PersonalInfo.RatioMagicFemale ? CHK_P6 : CHK_P7).Checked = true;
}
SetEntry();
var language = (LanguageID)SAV.Language;
Zukan.GiveAll(species, ModifierKeys != Keys.Alt, ModifierKeys.HasFlag(Keys.Shift), language, ModifierKeys.HasFlag(Keys.Control));
GetEntry(skipFormRepop: true);
System.Media.SystemSounds.Asterisk.Play();
}
private void B_Modify_Click(object sender, EventArgs e)
@ -257,83 +250,18 @@ private void B_Modify_Click(object sender, EventArgs e)
private void ModifyAll(object sender, EventArgs e)
{
int lang = SAV.Language;
if (lang > 5) lang--;
lang--;
if (sender == mnuSeenNone || sender == mnuSeenAll || sender == mnuComplete)
{
for (int i = 0; i < LB_Species.Items.Count; i++)
{
byte gt = SAV.Personal[i + 1].Gender;
LB_Species.SelectedIndex = i;
foreach (CheckBox t in new[] { CHK_P2, CHK_P3, CHK_P4, CHK_P5 })
t.Checked = mnuSeenNone != sender && t.Enabled;
if (mnuSeenNone != sender)
{
// if seen ensure at least one Displayed
if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked))
(gt != PersonalInfo.RatioMagicFemale ? CHK_P6 : CHK_P7).Checked = true;
}
else
{
foreach (CheckBox t in CP)
t.Checked = false;
}
if (!CHK_P1.Checked && !CHK_F1.Checked)
{
foreach (CheckBox t in CL)
t.Checked = false;
}
}
}
if (sender == mnuCaughtNone || sender == mnuCaughtAll || sender == mnuComplete)
{
for (int i = 0; i < CB_Species.Items.Count; i++)
{
byte gt = SAV.Personal[i + 1].Gender;
LB_Species.SelectedIndex = i;
foreach (CheckBox t in new[] { CHK_P1, CHK_F1 })
t.Checked = mnuCaughtNone != sender;
for (int j = 0; j < CL.Length; j++)
CL[j].Checked = sender == mnuComplete || (mnuCaughtNone != sender && j == lang);
if (mnuCaughtNone == sender)
{
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
(gt != PersonalInfo.RatioMagicFemale ? CHK_P6 : CHK_P7).Checked = true; // check one
}
}
if (mnuCaughtNone != sender)
{
if (mnuComplete == sender)
{
bool canBeMale = gt != PersonalInfo.RatioMagicFemale;
bool canBeFemale = gt is not (PersonalInfo.RatioMagicMale or PersonalInfo.RatioMagicGenderless);
CHK_P2.Checked = CHK_P4.Checked = canBeMale;
CHK_P3.Checked = CHK_P5.Checked = canBeFemale;
}
else
{
// ensure at least one SEEN
if (!(CHK_P2.Checked || CHK_P3.Checked || CHK_P4.Checked || CHK_P5.Checked))
(gt != PersonalInfo.RatioMagicFemale ? CHK_P2 : CHK_P3).Checked = true;
}
// ensure at least one Displayed
if (!(CHK_P6.Checked || CHK_P7.Checked || CHK_P8.Checked || CHK_P9.Checked))
(gt != PersonalInfo.RatioMagicFemale ? CHK_P6 : CHK_P7).Checked = true;
}
}
}
SetEntry();
GetEntry();
var language = (LanguageID)SAV.Language;
if (sender == mnuSeenNone)
Zukan.SeenNone();
if (sender == mnuSeenAll || sender == mnuComplete)
Zukan.SeenAll(shinyToo: ModifierKeys.HasFlag(Keys.Shift));
if (sender == mnuCaughtNone)
Zukan.CaughtNone();
if (sender == mnuCaughtAll || sender == mnuComplete)
Zukan.CaughtAll(language, allLanguages: ModifierKeys.HasFlag(Keys.Control));
GetEntry(skipFormRepop: true);
System.Media.SystemSounds.Asterisk.Play();
}
private void UpdateDisplayedForm(object sender, ItemCheckEventArgs e)
@ -362,34 +290,14 @@ private void B_ModifyForms_Click(object sender, EventArgs e)
private void ModifyAllForms(object sender, EventArgs e)
{
for (int i = 0; i < CB_Species.Items.Count; i++)
{
LB_Species.SelectedIndex = i;
if (CLB_FormsSeen.Items.Count == 0)
continue;
if (sender == mnuForm1)
{
if (CLB_FormsSeen.CheckedItems.Count == 0)
CLB_FormsSeen.SetItemChecked(0, true);
if (CLB_FormDisplayed.CheckedItems.Count == 0)
CLB_FormDisplayed.SetItemChecked(0, true);
}
else if (sender == mnuFormAll)
{
for (int f = 0; f < CLB_FormsSeen.Items.Count; f++)
CLB_FormsSeen.SetItemChecked(f, true);
if (CLB_FormDisplayed.CheckedItems.Count == 0)
CLB_FormDisplayed.SetItemChecked(0, true);
}
else // none
{
for (int f = 0; f < CLB_FormsSeen.Items.Count; f++)
CLB_FormsSeen.SetItemChecked(f, false);
for (int f = 0; f < CLB_FormDisplayed.Items.Count; f++)
CLB_FormDisplayed.SetItemChecked(f, false);
}
}
SetEntry();
if (sender == mnuFormNone)
Zukan.ClearFormSeen();
else if (sender == mnuForm1)
Zukan.SetFormsSeen1(shinyToo: ModifierKeys.HasFlag(Keys.Shift));
else if (sender == mnuFormAll)
Zukan.SetFormsSeen(shinyToo: ModifierKeys.HasFlag(Keys.Shift));
GetEntry(skipFormRepop: true);
System.Media.SystemSounds.Asterisk.Play();
}
}