mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-05-09 12:35:20 -05:00
Rework batrev current slot handling
Show all slots even if they're uninitialized. Empty first slots but present second slots caused errors on init.
This commit is contained in:
parent
4c49d489a8
commit
803b8675fe
|
|
@ -41,20 +41,21 @@ private void InitializeData(byte[] data)
|
|||
tempData.CopyTo(Data, 0x1C0000);
|
||||
}
|
||||
|
||||
var names = (string[]) SaveNames;
|
||||
for (int i = 0; i < SAVE_COUNT; i++)
|
||||
{
|
||||
if (!IsOTNamePresent(i))
|
||||
continue;
|
||||
SaveSlots.Add(i);
|
||||
SaveNames.Add(GetOTName(i));
|
||||
var name = GetOTName(i);
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
name = $"Empty {i + 1}";
|
||||
else if (_currentSlot == -1)
|
||||
_currentSlot = i;
|
||||
names[i] = name;
|
||||
}
|
||||
|
||||
CurrentSlot = SaveSlots[0];
|
||||
}
|
||||
if (_currentSlot == -1)
|
||||
_currentSlot = 0;
|
||||
|
||||
private bool IsOTNamePresent(int i)
|
||||
{
|
||||
return BitConverter.ToUInt16(Data, 0x390 + (0x6FF00 * i)) != 0;
|
||||
CurrentSlot = _currentSlot;
|
||||
}
|
||||
|
||||
private uint SaveCount;
|
||||
|
|
@ -68,18 +69,17 @@ protected override byte[] GetFinalData()
|
|||
// Configuration
|
||||
protected override SaveFile CloneInternal() => new SAV4BR(Write());
|
||||
|
||||
public readonly List<int> SaveSlots = new(SAVE_COUNT);
|
||||
public readonly List<string> SaveNames = new(SAVE_COUNT);
|
||||
public readonly IReadOnlyList<string> SaveNames = new string[SAVE_COUNT];
|
||||
|
||||
private int _currentSlot;
|
||||
private int _currentSlot = -1;
|
||||
|
||||
public int CurrentSlot
|
||||
{
|
||||
get => SaveSlots.IndexOf(_currentSlot);
|
||||
get => _currentSlot;
|
||||
// 4 save slots, data reading depends on current slot
|
||||
set
|
||||
{
|
||||
_currentSlot = SaveSlots[value];
|
||||
_currentSlot = value;
|
||||
var ofs = 0x6FF00 * _currentSlot;
|
||||
Box = ofs + 0x978;
|
||||
Party = ofs + 0x13A54; // first team slot after boxes
|
||||
|
|
|
|||
|
|
@ -1101,10 +1101,11 @@ private void ToggleViewMisc(SaveFile sav)
|
|||
if (sav is SAV4BR br)
|
||||
{
|
||||
L_SaveSlot.Visible = CB_SaveSlot.Visible = true;
|
||||
var current = br.CurrentSlot;
|
||||
var list = br.SaveNames.Select((z, i) => new ComboItem(z, i)).ToList();
|
||||
CB_SaveSlot.InitializeBinding();
|
||||
CB_SaveSlot.DataSource = new BindingSource(list, null);
|
||||
CB_SaveSlot.SelectedValue = br.CurrentSlot;
|
||||
CB_SaveSlot.SelectedValue = current;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user