mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-10 14:44:24 +00:00
Minor clean
Seal ComboItem Reorder methods for easier reading Fix BulkGenerator living dex setting CurrentLevel -- needs to be after species,form as EXPGrowth can vary for forms.
This commit is contained in:
parent
3c567c0c97
commit
9696da2eb3
6 changed files with 62 additions and 63 deletions
|
@ -1,7 +1,6 @@
|
|||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Key Value pair for a displayed <see cref="T:System.String" /> and underlying <see cref="T:System.Int32" /> value.
|
||||
/// </summary>
|
||||
public record ComboItem(string Text, int Value);
|
||||
}
|
||||
namespace PKHeX.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Key Value pair for a displayed <see cref="T:System.String" /> and underlying <see cref="T:System.Int32" /> value.
|
||||
/// </summary>
|
||||
public sealed record ComboItem(string Text, int Value);
|
||||
|
|
|
@ -2,17 +2,20 @@
|
|||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Geolocation Utility for Generation 6/7 (3DS) Earth location values.
|
||||
/// </summary>
|
||||
public static class GeoLocation
|
||||
{
|
||||
private static readonly string[]?[] CountryList = GetCountryList();
|
||||
internal static readonly string[] lang_geo = { "ja", "en", "fr", "de", "it", "es", "zh", "ko" };
|
||||
private static readonly string[]?[]?[] RegionList = new string[CountryList.Length][][];
|
||||
|
||||
public static string[]? GetCountryList(string language)
|
||||
{
|
||||
int index = GetLanguageIndex(language);
|
||||
return CountryList[index];
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns the index of which the <see cref="language"/> is in the country/region list.
|
||||
/// </summary>
|
||||
public static int GetLanguageIndex(string language) => Array.IndexOf(lang_geo, language);
|
||||
private static int GetLanguageIndex(LanguageID language) => GetLanguageIndex(language.GetLanguage2CharName());
|
||||
|
||||
private const string INVALID = nameof(INVALID);
|
||||
|
||||
|
@ -75,6 +78,15 @@ namespace PKHeX.Core
|
|||
return INVALID;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an array of all country names for the requested <see cref="language"/>.
|
||||
/// </summary>
|
||||
public static string[]? GetCountryList(string language)
|
||||
{
|
||||
int index = GetLanguageIndex(language);
|
||||
return CountryList[index];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Country string for a given Country ID
|
||||
/// </summary>
|
||||
|
@ -124,8 +136,5 @@ namespace PKHeX.Core
|
|||
var regionName = GetRegionName(country, region, lang);
|
||||
return (countryName, regionName);
|
||||
}
|
||||
|
||||
public static int GetLanguageIndex(string language) => Array.IndexOf(lang_geo, language);
|
||||
private static int GetLanguageIndex(LanguageID language) => GetLanguageIndex(language.GetLanguage2CharName());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,9 +57,9 @@ namespace PKHeX.Core
|
|||
if (result == null)
|
||||
return null;
|
||||
|
||||
result.CurrentLevel = 100;
|
||||
result.Species = species;
|
||||
result.Form = form;
|
||||
result.CurrentLevel = 100;
|
||||
|
||||
result.Heal();
|
||||
return result;
|
||||
|
|
|
@ -17,13 +17,11 @@ namespace PKHeX.Core
|
|||
/// <param name="maxSpecies">Highest species ID for the input game.</param>
|
||||
public static Learnset[] GetArray(ReadOnlySpan<byte> input, int maxSpecies)
|
||||
{
|
||||
var data = new Learnset[maxSpecies + 1];
|
||||
|
||||
int offset = 0;
|
||||
for (int s = 0; s < data.Length; s++)
|
||||
data[s] = ReadLearnset8(input, ref offset);
|
||||
|
||||
return data;
|
||||
var result = new Learnset[maxSpecies + 1];
|
||||
for (int i = 0; i < result.Length; i++)
|
||||
result[i] = ReadLearnset8(input, ref offset);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -32,10 +30,10 @@ namespace PKHeX.Core
|
|||
/// <param name="entries">Entry data</param>
|
||||
public static Learnset[] GetArray(BinLinkerAccessor entries)
|
||||
{
|
||||
Learnset[] data = new Learnset[entries.Length];
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
data[i] = ReadLearnset16(entries[i]);
|
||||
return data;
|
||||
var result = new Learnset[entries.Length];
|
||||
for (int i = 0; i < result.Length; i++)
|
||||
result[i] = ReadLearnset16(entries[i]);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -52,16 +50,16 @@ namespace PKHeX.Core
|
|||
}
|
||||
do { end += 2; } while (data[end] != 0);
|
||||
|
||||
var Count = (end - offset) / 2;
|
||||
var Moves = new int[Count];
|
||||
var Levels = new int[Count];
|
||||
for (int i = 0; i < Moves.Length; i++)
|
||||
var count = (end - offset) / 2;
|
||||
var moves = new int[count];
|
||||
var levels = new int[count];
|
||||
for (int i = 0; i < moves.Length; i++)
|
||||
{
|
||||
Levels[i] = data[offset++];
|
||||
Moves[i] = data[offset++];
|
||||
levels[i] = data[offset++];
|
||||
moves[i] = data[offset++];
|
||||
}
|
||||
++offset;
|
||||
return new Learnset(Moves, Levels);
|
||||
return new Learnset(moves, levels);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -72,16 +70,16 @@ namespace PKHeX.Core
|
|||
{
|
||||
if (data.Length == 0)
|
||||
return EMPTY;
|
||||
var Count = (data.Length / 4) - 1;
|
||||
var Moves = new int[Count];
|
||||
var Levels = new int[Count];
|
||||
for (int i = 0; i < Count; i++)
|
||||
var count = (data.Length / 4) - 1;
|
||||
var moves = new int[count];
|
||||
var levels = new int[count];
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
var move = data.Slice(i * 4, 4);
|
||||
Moves[i] = ReadInt16LittleEndian(move);
|
||||
Levels[i] = ReadInt16LittleEndian(move[2..]);
|
||||
levels[i] = ReadInt16LittleEndian(move[2..]);
|
||||
moves[i] = ReadInt16LittleEndian(move);
|
||||
}
|
||||
return new Learnset(Moves, Levels);
|
||||
return new Learnset(moves, levels);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ namespace PKHeX.Core
|
|||
public sealed class SaveFileMetadata
|
||||
{
|
||||
private readonly SaveFile SAV;
|
||||
public SaveFileMetadata(SaveFile sav) => SAV = sav;
|
||||
|
||||
/// <summary>
|
||||
/// Full path where the <see cref="SAV"/> originated from.
|
||||
|
@ -36,8 +37,6 @@ namespace PKHeX.Core
|
|||
/// </summary>
|
||||
public string BAKName => FileName + BAKSuffix;
|
||||
|
||||
public SaveFileMetadata(SaveFile sav) => SAV = sav;
|
||||
|
||||
public bool HasHeader => Header.Length != 0;
|
||||
public bool HasFooter => Footer.Length != 0;
|
||||
|
||||
|
|
|
@ -1,26 +1,20 @@
|
|||
namespace PKHeX.Core
|
||||
namespace PKHeX.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Tracks information about modifications made to a <see cref="SaveFile"/>
|
||||
/// </summary>
|
||||
public sealed record SaveFileState(bool Exportable = true)
|
||||
{
|
||||
/// <summary>
|
||||
/// Tracks information about modifications made to a <see cref="SaveFile"/>
|
||||
/// Mutable value tracking if the save file has been changed. This is set manually by modifications, and not for all modifications.
|
||||
/// </summary>
|
||||
public sealed class SaveFileState
|
||||
{
|
||||
/// <summary>
|
||||
/// Mutable value tracking if the save file has been changed. This is set manually by modifications, and not for all modifications.
|
||||
/// </summary>
|
||||
public bool Edited { get; set; }
|
||||
public bool Edited { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Toggle determining if the save file can be exported.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is always true, unless the save file is a "fake" save file with blank data. Blank Save Files are essentially zeroed out buffers.
|
||||
/// </remarks>
|
||||
public readonly bool Exportable;
|
||||
|
||||
public SaveFileState(bool exportable = true)
|
||||
{
|
||||
Exportable = exportable;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Toggle determining if the save file can be exported.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is always true, unless the save file is a "fake" save file with blank data. Blank Save Files are essentially zeroed out buffers.
|
||||
/// </remarks>
|
||||
public bool Exportable { get; } = Exportable;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue