2022-01-03 05:35:59 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2019-06-22 17:50:32 +00:00
|
|
|
|
|
|
|
|
|
namespace PKHeX.Core
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Bundles raw string inputs into lists that can be used in data binding.
|
|
|
|
|
/// </summary>
|
2019-10-04 02:09:02 +00:00
|
|
|
|
public sealed class GameDataSource
|
2019-06-22 17:50:32 +00:00
|
|
|
|
{
|
2021-05-09 22:47:21 +00:00
|
|
|
|
public static readonly IReadOnlyList<ComboItem> Regions = new List<ComboItem>
|
|
|
|
|
{
|
2021-05-19 16:11:54 +00:00
|
|
|
|
new ("Japan (日本)", 0),
|
|
|
|
|
new ("Americas (NA/SA)", 1),
|
|
|
|
|
new ("Europe (EU/AU)", 2),
|
|
|
|
|
new ("China (中国大陆)", 4),
|
|
|
|
|
new ("Korea (한국)", 5),
|
|
|
|
|
new ("Taiwan (香港/台灣)", 6),
|
2021-05-09 22:47:21 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private static readonly List<ComboItem> LanguageList = new()
|
|
|
|
|
{
|
|
|
|
|
new ComboItem("JPN (日本語)", (int)LanguageID.Japanese),
|
|
|
|
|
new ComboItem("ENG (English)", (int)LanguageID.English),
|
|
|
|
|
new ComboItem("FRE (Français)", (int)LanguageID.French),
|
|
|
|
|
new ComboItem("ITA (Italiano)", (int)LanguageID.Italian),
|
|
|
|
|
new ComboItem("GER (Deutsch)", (int)LanguageID.German),
|
|
|
|
|
new ComboItem("ESP (Español)", (int)LanguageID.Spanish),
|
|
|
|
|
new ComboItem("KOR (한국어)", (int)LanguageID.Korean),
|
|
|
|
|
new ComboItem("CHS (简体中文)", (int)LanguageID.ChineseS),
|
|
|
|
|
new ComboItem("CHT (繁體中文)", (int)LanguageID.ChineseT),
|
|
|
|
|
};
|
2019-06-22 17:50:32 +00:00
|
|
|
|
|
|
|
|
|
public GameDataSource(GameStrings s)
|
|
|
|
|
{
|
2020-12-29 05:12:46 +00:00
|
|
|
|
Strings = s;
|
2022-01-03 05:35:59 +00:00
|
|
|
|
BallDataSource = GetBalls(s.itemlist);
|
2019-06-22 17:50:32 +00:00
|
|
|
|
SpeciesDataSource = Util.GetCBList(s.specieslist);
|
|
|
|
|
NatureDataSource = Util.GetCBList(s.natures);
|
|
|
|
|
AbilityDataSource = Util.GetCBList(s.abilitylist);
|
2021-07-04 06:25:09 +00:00
|
|
|
|
GroundTileDataSource = Util.GetUnsortedCBList(s.groundtiletypes, GroundTileTypeExtensions.ValidTileTypes);
|
2019-06-22 17:50:32 +00:00
|
|
|
|
|
2020-12-29 05:12:46 +00:00
|
|
|
|
var moves = Util.GetCBList(s.movelist);
|
|
|
|
|
HaXMoveDataSource = moves;
|
|
|
|
|
var legal = new List<ComboItem>(moves);
|
|
|
|
|
legal.RemoveAll(m => Legal.Z_Moves.Contains(m.Value));
|
|
|
|
|
LegalMoveDataSource = legal;
|
2019-06-22 17:50:32 +00:00
|
|
|
|
|
|
|
|
|
VersionDataSource = GetVersionList(s);
|
PKHeX.Core Nullable cleanup (#2401)
* Handle some nullable cases
Refactor MysteryGift into a second abstract class (backed by a byte array, or fake data)
Make some classes have explicit constructors instead of { } initialization
* Handle bits more obviously without null
* Make SaveFile.BAK explicitly readonly again
* merge constructor methods to have readonly fields
* Inline some properties
* More nullable handling
* Rearrange box actions
define straightforward classes to not have any null properties
* Make extrabyte reference array immutable
* Move tooltip creation to designer
* Rearrange some logic to reduce nesting
* Cache generated fonts
* Split mystery gift album purpose
* Handle more tooltips
* Disallow null setters
* Don't capture RNG object, only type enum
* Unify learnset objects
Now have readonly properties which are never null
don't new() empty learnsets (>800 Learnset objects no longer created,
total of 2400 objects since we also new() a move & level array)
optimize g1/2 reader for early abort case
* Access rewrite
Initialize blocks in a separate object, and get via that object
removes a couple hundred "might be null" warnings since blocks are now readonly getters
some block references have been relocated, but interfaces should expose all that's needed
put HoF6 controls in a groupbox, and disable
* Readonly personal data
* IVs non nullable for mystery gift
* Explicitly initialize forced encounter moves
* Make shadow objects readonly & non-null
Put murkrow fix in binary data resource, instead of on startup
* Assign dex form fetch on constructor
Fixes legality parsing edge cases
also handle cxd parse for valid; exit before exception is thrown in FrameGenerator
* Remove unnecessary null checks
* Keep empty value until init
SetPouch sets the value to an actual one during load, but whatever
* Readonly team lock data
* Readonly locks
Put locked encounters at bottom (favor unlocked)
* Mail readonly data / offset
Rearrange some call flow and pass defaults
Add fake classes for SaveDataEditor mocking
Always party size, no need to check twice in stat editor
use a fake save file as initial data for savedata editor, and for
gamedata (wow i found a usage)
constrain eventwork editor to struct variable types (uint, int, etc),
thus preventing null assignment errors
2019-10-17 01:47:31 +00:00
|
|
|
|
|
2020-12-29 05:12:46 +00:00
|
|
|
|
Met = new MetDataSource(s);
|
PKHeX.Core Nullable cleanup (#2401)
* Handle some nullable cases
Refactor MysteryGift into a second abstract class (backed by a byte array, or fake data)
Make some classes have explicit constructors instead of { } initialization
* Handle bits more obviously without null
* Make SaveFile.BAK explicitly readonly again
* merge constructor methods to have readonly fields
* Inline some properties
* More nullable handling
* Rearrange box actions
define straightforward classes to not have any null properties
* Make extrabyte reference array immutable
* Move tooltip creation to designer
* Rearrange some logic to reduce nesting
* Cache generated fonts
* Split mystery gift album purpose
* Handle more tooltips
* Disallow null setters
* Don't capture RNG object, only type enum
* Unify learnset objects
Now have readonly properties which are never null
don't new() empty learnsets (>800 Learnset objects no longer created,
total of 2400 objects since we also new() a move & level array)
optimize g1/2 reader for early abort case
* Access rewrite
Initialize blocks in a separate object, and get via that object
removes a couple hundred "might be null" warnings since blocks are now readonly getters
some block references have been relocated, but interfaces should expose all that's needed
put HoF6 controls in a groupbox, and disable
* Readonly personal data
* IVs non nullable for mystery gift
* Explicitly initialize forced encounter moves
* Make shadow objects readonly & non-null
Put murkrow fix in binary data resource, instead of on startup
* Assign dex form fetch on constructor
Fixes legality parsing edge cases
also handle cxd parse for valid; exit before exception is thrown in FrameGenerator
* Remove unnecessary null checks
* Keep empty value until init
SetPouch sets the value to an actual one during load, but whatever
* Readonly team lock data
* Readonly locks
Put locked encounters at bottom (favor unlocked)
* Mail readonly data / offset
Rearrange some call flow and pass defaults
Add fake classes for SaveDataEditor mocking
Always party size, no need to check twice in stat editor
use a fake save file as initial data for savedata editor, and for
gamedata (wow i found a usage)
constrain eventwork editor to struct variable types (uint, int, etc),
thus preventing null assignment errors
2019-10-17 01:47:31 +00:00
|
|
|
|
|
2019-11-16 01:34:18 +00:00
|
|
|
|
Empty = new ComboItem(s.Species[0], 0);
|
2019-06-22 17:50:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-29 05:12:46 +00:00
|
|
|
|
/// <summary> Strings that this object's lists were generated with. </summary>
|
|
|
|
|
public readonly GameStrings Strings;
|
|
|
|
|
|
|
|
|
|
/// <summary> Contains Met Data lists to source lists from. </summary>
|
|
|
|
|
public readonly MetDataSource Met;
|
|
|
|
|
|
|
|
|
|
/// <summary> Represents "(None)", localized to this object's language strings. </summary>
|
|
|
|
|
public readonly ComboItem Empty;
|
2019-06-22 17:50:32 +00:00
|
|
|
|
|
|
|
|
|
public readonly IReadOnlyList<ComboItem> SpeciesDataSource;
|
|
|
|
|
public readonly IReadOnlyList<ComboItem> BallDataSource;
|
|
|
|
|
public readonly IReadOnlyList<ComboItem> NatureDataSource;
|
|
|
|
|
public readonly IReadOnlyList<ComboItem> AbilityDataSource;
|
|
|
|
|
public readonly IReadOnlyList<ComboItem> VersionDataSource;
|
|
|
|
|
public readonly IReadOnlyList<ComboItem> LegalMoveDataSource;
|
|
|
|
|
public readonly IReadOnlyList<ComboItem> HaXMoveDataSource;
|
2021-07-04 06:25:09 +00:00
|
|
|
|
public readonly IReadOnlyList<ComboItem> GroundTileDataSource;
|
2019-06-22 17:50:32 +00:00
|
|
|
|
|
2022-01-03 05:35:59 +00:00
|
|
|
|
private static IReadOnlyList<ComboItem> GetBalls(string[] itemList)
|
|
|
|
|
{
|
|
|
|
|
// ignores Poke/Great/Ultra
|
2022-02-05 01:35:15 +00:00
|
|
|
|
ReadOnlySpan<ushort> ball_nums = stackalloc ushort[] { 007, 576, 013, 492, 497, 014, 495, 493, 496, 494, 011, 498, 008, 006, 012, 015, 009, 005, 499, 010, 001, 016, 851, 1785, 1710, 1711, 1712, 1713, 1746, 1747, 1748, 1749, 1750, 1771 };
|
|
|
|
|
ReadOnlySpan<byte> ball_vals = stackalloc byte[] { 007, 025, 013, 017, 022, 014, 020, 018, 021, 019, 011, 023, 008, 006, 012, 015, 009, 005, 024, 010, 001, 016, 026, 0027, 0028, 0029, 0030, 0031, 0032, 0033, 0034, 0035, 0036, 0037 };
|
2022-01-03 05:35:59 +00:00
|
|
|
|
return Util.GetVariedCBListBall(itemList, ball_nums, ball_vals);
|
|
|
|
|
}
|
|
|
|
|
|
PKHeX.Core Nullable cleanup (#2401)
* Handle some nullable cases
Refactor MysteryGift into a second abstract class (backed by a byte array, or fake data)
Make some classes have explicit constructors instead of { } initialization
* Handle bits more obviously without null
* Make SaveFile.BAK explicitly readonly again
* merge constructor methods to have readonly fields
* Inline some properties
* More nullable handling
* Rearrange box actions
define straightforward classes to not have any null properties
* Make extrabyte reference array immutable
* Move tooltip creation to designer
* Rearrange some logic to reduce nesting
* Cache generated fonts
* Split mystery gift album purpose
* Handle more tooltips
* Disallow null setters
* Don't capture RNG object, only type enum
* Unify learnset objects
Now have readonly properties which are never null
don't new() empty learnsets (>800 Learnset objects no longer created,
total of 2400 objects since we also new() a move & level array)
optimize g1/2 reader for early abort case
* Access rewrite
Initialize blocks in a separate object, and get via that object
removes a couple hundred "might be null" warnings since blocks are now readonly getters
some block references have been relocated, but interfaces should expose all that's needed
put HoF6 controls in a groupbox, and disable
* Readonly personal data
* IVs non nullable for mystery gift
* Explicitly initialize forced encounter moves
* Make shadow objects readonly & non-null
Put murkrow fix in binary data resource, instead of on startup
* Assign dex form fetch on constructor
Fixes legality parsing edge cases
also handle cxd parse for valid; exit before exception is thrown in FrameGenerator
* Remove unnecessary null checks
* Keep empty value until init
SetPouch sets the value to an actual one during load, but whatever
* Readonly team lock data
* Readonly locks
Put locked encounters at bottom (favor unlocked)
* Mail readonly data / offset
Rearrange some call flow and pass defaults
Add fake classes for SaveDataEditor mocking
Always party size, no need to check twice in stat editor
use a fake save file as initial data for savedata editor, and for
gamedata (wow i found a usage)
constrain eventwork editor to struct variable types (uint, int, etc),
thus preventing null assignment errors
2019-10-17 01:47:31 +00:00
|
|
|
|
private static IReadOnlyList<ComboItem> GetVersionList(GameStrings s)
|
2019-06-22 17:50:32 +00:00
|
|
|
|
{
|
|
|
|
|
var list = s.gamelist;
|
2022-01-03 05:35:59 +00:00
|
|
|
|
ReadOnlySpan<byte> games = stackalloc byte[]
|
2020-12-28 21:32:36 +00:00
|
|
|
|
{
|
2022-02-05 01:35:15 +00:00
|
|
|
|
47, // 8 legends arceus
|
2021-11-20 02:23:49 +00:00
|
|
|
|
48, 49, // 8 bdsp
|
2020-12-28 21:32:36 +00:00
|
|
|
|
44, 45, // 8 swsh
|
|
|
|
|
42, 43, // 7 gg
|
|
|
|
|
30, 31, // 7 sm
|
|
|
|
|
32, 33, // 7 usum
|
|
|
|
|
24, 25, // 6 xy
|
|
|
|
|
27, 26, // 6 oras
|
|
|
|
|
21, 20, // 5 bw
|
|
|
|
|
23, 22, // 5 b2w2
|
|
|
|
|
10, 11, 12, // 4 dppt
|
|
|
|
|
07, 08, // 4 hgss
|
|
|
|
|
02, 01, 03, // 3 rse
|
|
|
|
|
04, 05, // 3 frlg
|
|
|
|
|
15, // 3 cxd
|
|
|
|
|
|
|
|
|
|
39, 40, 41, // 7vc2
|
|
|
|
|
35, 36, 37, 38, // 7vc1
|
|
|
|
|
34, // 7go
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return Util.GetUnsortedCBList(list, games);
|
2019-06-22 17:50:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-01-25 07:29:45 +00:00
|
|
|
|
public List<ComboItem> GetItemDataSource(GameVersion game, int generation, IReadOnlyList<ushort> allowed, bool HaX = false)
|
2019-06-22 17:50:32 +00:00
|
|
|
|
{
|
2020-12-29 05:12:46 +00:00
|
|
|
|
var items = Strings.GetItemStrings(generation, game);
|
2020-01-25 07:29:45 +00:00
|
|
|
|
return HaX ? Util.GetCBList(items) : Util.GetCBList(items, allowed);
|
2019-06-22 17:50:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static IReadOnlyList<ComboItem> LanguageDataSource(int gen)
|
|
|
|
|
{
|
2022-01-03 05:35:59 +00:00
|
|
|
|
var languages = new List<ComboItem>(LanguageList);
|
2019-06-22 17:50:32 +00:00
|
|
|
|
if (gen == 3)
|
|
|
|
|
languages.RemoveAll(l => l.Value >= (int)LanguageID.Korean);
|
|
|
|
|
else if (gen < 7)
|
|
|
|
|
languages.RemoveAll(l => l.Value > (int)LanguageID.Korean);
|
|
|
|
|
return languages;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-10-24 18:11:05 +00:00
|
|
|
|
}
|