Change first param of `{Save,Load}QuickSave` from string to int

also swapped bool params of `SaveQuickSave`
This commit is contained in:
YoshiRulz 2022-12-17 14:54:03 +10:00
parent 22ba0d5c25
commit fcf7ac1fab
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
9 changed files with 24 additions and 47 deletions

View File

@ -1,8 +1,6 @@
using System;
using System.IO;
using BizHawk.Common;
namespace BizHawk.Client.Common
{
public sealed class SaveStateApi : ISaveStateApi
@ -30,14 +28,14 @@ namespace BizHawk.Client.Common
public void LoadSlot(int slotNum, bool suppressOSD)
{
if (0.RangeTo(9).Contains(slotNum)) _mainForm.LoadQuickSave($"QuickSave{slotNum}", suppressOSD);
if (slotNum is >= 0 and <= 9) _mainForm.LoadQuickSave(slotNum, suppressOSD: suppressOSD);
}
public void Save(string path, bool suppressOSD) => _mainForm.SaveState(path, path, true, suppressOSD);
public void SaveSlot(int slotNum, bool suppressOSD)
{
if (0.RangeTo(9).Contains(slotNum)) _mainForm.SaveQuickSave($"QuickSave{slotNum}", true, suppressOSD);
if (slotNum is >= 0 and <= 9) _mainForm.SaveQuickSave(slotNum, suppressOSD: suppressOSD, fromLua: true);
}
}
}

View File

@ -181,7 +181,7 @@ namespace BizHawk.Client.Common
}
parsed = new ParsedCLIFlags(
cmdLoadSlot: cmdLoadSlot,
cmdLoadSlot: cmdLoadSlot is null ? null : int.Parse(cmdLoadSlot),
cmdLoadState: cmdLoadState,
cmdConfigFile: cmdConfigFile,
cmdMovie: cmdMovie,

View File

@ -69,7 +69,7 @@ namespace BizHawk.Client.Common
bool LoadMovie(string filename, string archive = null);
/// <remarks>only referenced from <see cref="SaveStateApi"/></remarks>
void LoadQuickSave(string quickSlotName, bool suppressOSD = false);
void LoadQuickSave(int slot, bool suppressOSD = false);
/// <remarks>only referenced from <c>EmuClientApi</c></remarks>
bool LoadRom(string path, LoadRomArgs args);
@ -89,7 +89,7 @@ namespace BizHawk.Client.Common
bool RestartMovie();
/// <remarks>only referenced from <see cref="SaveStateApi"/></remarks>
void SaveQuickSave(string quickSlotName, bool fromLua = false, bool suppressOSD = false);
void SaveQuickSave(int slot, bool suppressOSD = false, bool fromLua = false);
void SaveState(string path, string userFriendlyStateName, bool fromLua = false, bool suppressOSD = false);

View File

@ -6,7 +6,7 @@ namespace BizHawk.Client.Common
{
public readonly struct ParsedCLIFlags
{
public readonly string? cmdLoadSlot;
public readonly int? cmdLoadSlot;
public readonly string? cmdLoadState;
@ -46,7 +46,8 @@ namespace BizHawk.Client.Common
public readonly string? cmdRom;
public ParsedCLIFlags(string? cmdLoadSlot,
public ParsedCLIFlags(
int? cmdLoadSlot,
string? cmdLoadState,
string? cmdConfigFile,
string? cmdMovie,

View File

@ -65,7 +65,7 @@ namespace BizHawk.Client.EmuHawk
void FrameBufferResized();
/// <remarks>only referenced from <see cref="BasicBot"/></remarks>
void LoadQuickSave(string quickSlotName, bool suppressOSD = false);
void LoadQuickSave(int slot, bool suppressOSD = false);
/// <remarks>only referenced from <see cref="MultiDiskBundler"/></remarks>
bool LoadRom(string path, LoadRomArgs args);

View File

@ -352,12 +352,12 @@ namespace BizHawk.Client.EmuHawk
}
private void QuickSavestateMenuItem_Click(object sender, EventArgs e)
=> SaveQuickSave($"QuickSave{((MenuItem) sender).Text}");
=> SaveQuickSave(int.Parse(((MenuItem) sender).Text));
private void SaveNamedStateMenuItem_Click(object sender, EventArgs e) => SaveStateAs();
private void QuickLoadstateMenuItem_Click(object sender, EventArgs e)
=> LoadQuickSave($"QuickSave{((MenuItem) sender).Text}");
=> LoadQuickSave(int.Parse(((MenuItem) sender).Text));
private void LoadNamedStateMenuItem_Click(object sender, EventArgs e) => LoadStateAs();
@ -401,17 +401,13 @@ namespace BizHawk.Client.EmuHawk
=> SavestateCurrentSlot();
private void SavestateCurrentSlot()
{
SaveQuickSave($"QuickSave{Config.SaveSlot}");
}
=> SaveQuickSave(Config.SaveSlot);
private void LoadCurrentSlotMenuItem_Click(object sender, EventArgs e)
=> LoadstateCurrentSlot();
private void LoadstateCurrentSlot()
{
LoadQuickSave($"QuickSave{Config.SaveSlot}");
}
=> LoadQuickSave(Config.SaveSlot);
private void FlushSaveRAMMenuItem_Click(object sender, EventArgs e)
{
@ -2525,17 +2521,8 @@ namespace BizHawk.Client.EmuHawk
if (sender == Slot9StatusButton) slot = 9;
if (sender == Slot0StatusButton) slot = 0;
if (e.Button == MouseButtons.Left)
{
if (HasSlot(slot))
{
LoadQuickSave($"QuickSave{slot}");
}
}
else if (e.Button == MouseButtons.Right)
{
SaveQuickSave($"QuickSave{slot}");
}
if (e.Button is MouseButtons.Right) SaveQuickSave(slot);
else if (e.Button is MouseButtons.Left && HasSlot(slot)) LoadQuickSave(slot);
}
private void KeyPriorityStatusLabel_Click(object sender, EventArgs e)

View File

@ -12,13 +12,13 @@ namespace BizHawk.Client.EmuHawk
{
void SelectAndSaveToSlot(int slot)
{
SaveQuickSave($"QuickSave{slot}");
SaveQuickSave(slot);
Config.SaveSlot = slot;
UpdateStatusSlots();
}
void SelectAndLoadFromSlot(int slot)
{
LoadQuickSave($"QuickSave{slot}");
LoadQuickSave(slot);
Config.SaveSlot = slot;
UpdateStatusSlots();
}

View File

@ -662,7 +662,7 @@ namespace BizHawk.Client.EmuHawk
}
else if (_argParser.cmdLoadSlot != null)
{
LoadQuickSave($"QuickSave{_argParser.cmdLoadSlot}");
LoadQuickSave(_argParser.cmdLoadSlot.Value);
}
else if (Config.AutoLoadLastSaveSlot)
{
@ -4249,13 +4249,13 @@ namespace BizHawk.Client.EmuHawk
}
}
public void LoadQuickSave(string quickSlotName, bool suppressOSD = false)
public void LoadQuickSave(int slot, bool suppressOSD = false)
{
if (!Emulator.HasSavestates())
{
return;
}
var quickSlotName = $"QuickSave{slot}";
EmuClient.OnBeforeQuickLoad(this, quickSlotName, out var handled);
if (handled)
{
@ -4316,13 +4316,13 @@ namespace BizHawk.Client.EmuHawk
}
// TODO: should backup logic be stuffed in into Client.Common.SaveStateManager?
public void SaveQuickSave(string quickSlotName, bool fromLua = false, bool suppressOSD = false)
public void SaveQuickSave(int slot, bool suppressOSD = false, bool fromLua = false)
{
if (!Emulator.HasSavestates())
{
return;
}
var quickSlotName = $"QuickSave{slot}";
EmuClient.OnBeforeQuickSave(this, quickSlotName, out var handled);
if (handled)
{

View File

@ -152,17 +152,8 @@ namespace BizHawk.Client.EmuHawk
.OfType<BotControlsRow>()
.ToDictionary(tkey => tkey.ButtonName, tvalue => tvalue.Probability);
private string SelectedSlot
{
get
{
char num = StartFromSlotBox.SelectedItem
.ToString()
.Last();
return $"QuickSave{num}";
}
}
private int SelectedSlot
=> (1 + StartFromSlotBox.SelectedIndex) % 10;
private long Attempts
{