2018-05-19 17:04:07 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace PKHeX.Core
|
|
|
|
|
{
|
2021-06-06 18:56:54 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Localizing Memory strings
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <remarks>
|
|
|
|
|
/// <see cref="IMemoryOT"/> and <see cref="IMemoryHT"/> parameters build strings.
|
|
|
|
|
/// </remarks>
|
2019-10-04 02:09:02 +00:00
|
|
|
|
public sealed class MemoryStrings
|
2018-05-19 17:04:07 +00:00
|
|
|
|
{
|
|
|
|
|
private readonly GameStrings s;
|
2018-08-03 03:11:42 +00:00
|
|
|
|
|
2021-08-26 02:45:47 +00:00
|
|
|
|
public MemoryStrings(GameStrings strings)
|
2018-05-19 17:04:07 +00:00
|
|
|
|
{
|
|
|
|
|
s = strings;
|
|
|
|
|
memories = new Lazy<List<ComboItem>>(GetMemories);
|
2019-02-08 05:40:20 +00:00
|
|
|
|
none = new Lazy<List<ComboItem>>(() => Util.GetCBList(new[] {string.Empty}));
|
2019-11-25 06:34:51 +00:00
|
|
|
|
species = new Lazy<List<ComboItem>>(() => Util.GetCBList(s.specieslist));
|
2021-08-26 02:23:15 +00:00
|
|
|
|
item6 = new Lazy<List<ComboItem>>(() => GetItems(6));
|
|
|
|
|
item8 = new Lazy<List<ComboItem>>(() => GetItems(8));
|
2019-02-02 07:08:03 +00:00
|
|
|
|
genloc = new Lazy<List<ComboItem>>(() => Util.GetCBList(s.genloc));
|
2021-07-04 05:10:45 +00:00
|
|
|
|
moves = new Lazy<List<ComboItem>>(() => Util.GetCBList(s.movelist));
|
2018-05-19 17:04:07 +00:00
|
|
|
|
specific = new Lazy<List<ComboItem>>(() => Util.GetCBList(s.metXY_00000, Legal.Met_XY_0));
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-26 02:45:47 +00:00
|
|
|
|
private List<ComboItem> GetItems(int memoryGen)
|
2019-11-25 06:34:51 +00:00
|
|
|
|
{
|
2021-08-26 02:45:47 +00:00
|
|
|
|
var permit = Memories.GetMemoryItemParams(memoryGen);
|
2019-11-25 06:34:51 +00:00
|
|
|
|
var asInt = permit.Select(z => (int) z).ToArray();
|
|
|
|
|
return Util.GetCBList(s.itemlist, asInt);
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-19 17:04:07 +00:00
|
|
|
|
private readonly Lazy<List<ComboItem>> memories;
|
2021-08-26 02:23:15 +00:00
|
|
|
|
private readonly Lazy<List<ComboItem>> none, species, item6, item8, genloc, moves, specific;
|
2018-05-19 17:04:07 +00:00
|
|
|
|
|
|
|
|
|
public List<ComboItem> Memory => memories.Value;
|
|
|
|
|
public List<ComboItem> None => none.Value;
|
|
|
|
|
public List<ComboItem> Moves => moves.Value;
|
2021-08-26 02:23:15 +00:00
|
|
|
|
public List<ComboItem> Items6 => item6.Value;
|
|
|
|
|
public List<ComboItem> Items8 => item8.Value;
|
2018-05-19 17:04:07 +00:00
|
|
|
|
public List<ComboItem> GeneralLocations => genloc.Value;
|
|
|
|
|
public List<ComboItem> SpecificLocations => specific.Value;
|
|
|
|
|
public List<ComboItem> Species => species.Value;
|
|
|
|
|
|
|
|
|
|
private List<ComboItem> GetMemories()
|
|
|
|
|
{
|
2021-08-24 06:06:51 +00:00
|
|
|
|
var mems = s.memories.AsSpan(0);
|
2021-07-04 05:10:45 +00:00
|
|
|
|
var list = new List<ComboItem> {new(mems[0], 0)}; // none at top
|
|
|
|
|
Util.AddCBWithOffset(list, mems[1..], 1); // sorted the rest
|
|
|
|
|
return list;
|
2018-05-19 17:04:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-08-24 06:06:51 +00:00
|
|
|
|
public ReadOnlySpan<string> GetMemoryQualities() => s.intensity;
|
|
|
|
|
public ReadOnlySpan<string> GetMemoryFeelings(int memoryGen) => memoryGen >= 8 ? s.feeling.AsSpan(0, 25) : s.feeling.AsSpan(1, 24); // empty line for 0 in gen8+
|
2018-05-19 17:04:07 +00:00
|
|
|
|
|
2021-08-26 02:23:15 +00:00
|
|
|
|
public List<ComboItem> GetArgumentStrings(MemoryArgType type, int memoryGen) => type switch
|
2018-05-19 17:04:07 +00:00
|
|
|
|
{
|
2021-01-02 01:08:49 +00:00
|
|
|
|
MemoryArgType.Species => Species,
|
|
|
|
|
MemoryArgType.GeneralLocation => GeneralLocations,
|
2021-08-26 02:23:15 +00:00
|
|
|
|
MemoryArgType.Item => memoryGen == 6 ? Items6 : Items8,
|
2021-01-02 01:08:49 +00:00
|
|
|
|
MemoryArgType.Move => Moves,
|
|
|
|
|
MemoryArgType.SpecificLocation => SpecificLocations,
|
2021-08-20 20:49:20 +00:00
|
|
|
|
_ => None,
|
2021-01-02 01:08:49 +00:00
|
|
|
|
};
|
2018-05-19 17:04:07 +00:00
|
|
|
|
}
|
|
|
|
|
}
|