Clean up `MainForm.AddOnScreenMessage` usage

This commit is contained in:
YoshiRulz 2021-11-20 04:39:23 +10:00
parent e56b3abd37
commit ed5128343f
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
11 changed files with 16 additions and 33 deletions

View File

@ -198,7 +198,7 @@ namespace BizHawk.Client.Common
{
_config.TargetZoomFactors[Emulator.SystemId] = size;
_mainForm.FrameBufferResized();
_mainForm.AddOnScreenMessage($"Window size set to {size}x");
_displayManager.OSD.AddMessage($"Window size set to {size}x");
}
else
{

View File

@ -4,6 +4,8 @@ namespace BizHawk.Client.Common
{
public interface IDialogController
{
void AddOnScreenMessage(string message);
/// <summary>
/// Creates and shows a <c>System.Windows.Forms.MessageBox</c> or equivalent with the given <paramref name="text"/>,
/// and with the given <paramref name="owner"/>, <paramref name="caption"/>, and <paramref name="icon"/> if they're specified.

View File

@ -32,8 +32,6 @@ namespace BizHawk.Client.Common
/// <remarks>only referenced from <c>EmuClientApi</c></remarks>
bool PauseAvi { set; }
void AddOnScreenMessage(string message);
/// <remarks>only referenced from <c>EmuClientApi</c></remarks>
void ClearHolds();

View File

@ -18,7 +18,6 @@ namespace BizHawk.Client.Common
private readonly Action _pauseCallback;
private readonly Action _modeChangedCallback;
private readonly Action<string> _messageCallback;
private IMovie _queuedMovie;
@ -29,13 +28,11 @@ namespace BizHawk.Client.Common
string backDirectory,
IDialogParent dialogParent,
IQuickBmpFile quickBmpFile,
Action<string> messageCallback,
Action pauseCallback,
Action modeChangedCallback)
{
Settings = settings;
BackupDirectory = backDirectory;
_messageCallback = messageCallback;
_dialogParent = dialogParent;
_quickBmpFile = quickBmpFile;
_pauseCallback = pauseCallback
@ -326,9 +323,7 @@ namespace BizHawk.Client.Common
public void PopupMessage(string message) => _dialogParent.ModalMessageBox(message, "Warning", EMsgBoxIcon.Warning);
private void Output(string message)
{
_messageCallback?.Invoke(message);
}
=> _dialogParent.DialogController.AddOnScreenMessage(message);
private void LatchInputToUser()
{

View File

@ -10,8 +10,6 @@ namespace BizHawk.Client.EmuHawk
IMovieSession MovieSession { get; }
void AddOnScreenMessage(string message);
void PutCoreSettings(object o);
void PutCoreSyncSettings(object o);

View File

@ -47,8 +47,6 @@ namespace BizHawk.Client.EmuHawk
/// <remarks>only referenced from <see cref="GenericDebugger"/></remarks>
event Action<bool> OnPauseChanged;
void AddOnScreenMessage(string message);
BitmapBuffer CaptureOSD();
/// <remarks>only referenced from <see cref="TAStudio"/></remarks>

View File

@ -889,7 +889,7 @@ namespace BizHawk.Client.EmuHawk
private void PathsMenuItem_Click(object sender, EventArgs e)
{
using var form = new PathConfig(this, Config.PathEntries, Game.System);
form.ShowDialog();
if (form.ShowDialog().IsOk()) AddOnScreenMessage("Path settings saved");
}
private void SoundMenuItem_Click(object sender, EventArgs e)
@ -950,8 +950,11 @@ namespace BizHawk.Client.EmuHawk
private void CustomizeMenuItem_Click(object sender, EventArgs e)
{
using var form = new EmuHawkOptions(BumpAutoFlushSaveRamTimer, Config, this.AddOnScreenMessage);
form.ShowDialog();
var prevLuaEngine = Config.LuaEngine;
using var form = new EmuHawkOptions(Config, BumpAutoFlushSaveRamTimer);
if (!form.ShowDialog().IsOk()) return;
AddOnScreenMessage("Custom configurations saved.");
if (Config.LuaEngine != prevLuaEngine) AddOnScreenMessage("Restart EmuHawk for Lua change to take effect");
}
private void ProfilesMenuItem_Click(object sender, EventArgs e)

View File

@ -172,6 +172,7 @@ namespace BizHawk.Client.EmuHawk
if (Config.SkipWaterboxIntegrityChecks)
prefs = CoreComm.CorePreferencesFlags.WaterboxMemoryConsistencyCheck;
// can't pass self as IDialogParent :(
return new CoreComm(
message => this.ModalMessageBox(message, "Warning", EMsgBoxIcon.Warning),
AddOnScreenMessage,
@ -334,7 +335,6 @@ namespace BizHawk.Client.EmuHawk
Config.PathEntries.MovieBackupsAbsolutePath(),
this,
QuickBmpFile,
AddOnScreenMessage,
PauseEmulator,
SetMainformMovieInfo);
@ -2150,7 +2150,7 @@ namespace BizHawk.Client.EmuHawk
if (!LoadRom(romPath, args, out var failureIsFromAskSave))
{
if (failureIsFromAskSave) OSD.AddMessage("ROM loading cancelled; a tool had unsaved changes");
if (failureIsFromAskSave) AddOnScreenMessage("ROM loading cancelled; a tool had unsaved changes");
else Config.RecentRoms.HandleLoadError(this, romPath, rom);
}
}
@ -3728,7 +3728,7 @@ namespace BizHawk.Client.EmuHawk
ChooseArchive = LoadArchiveChooser,
ChoosePlatform = ChoosePlatformForRom,
Deterministic = deterministic,
MessageCallback = OSD.AddMessage,
MessageCallback = AddOnScreenMessage,
OpenAdvanced = args.OpenAdvanced
};
FirmwareManager.RecentlyServed.Clear();

View File

@ -11,13 +11,10 @@ namespace BizHawk.Client.EmuHawk
private readonly Config _config;
private readonly Action<string> _osdMessageCallback;
public EmuHawkOptions(Action autoFlushSaveRamTimerBumpCallback, Config config, Action<string> osdMessageCallback)
public EmuHawkOptions(Config config, Action autoFlushSaveRamTimerBumpCallback)
{
_autoFlushSaveRamTimerBumpCallback = autoFlushSaveRamTimerBumpCallback;
_config = config;
_osdMessageCallback = osdMessageCallback;
InitializeComponent();
}
@ -138,7 +135,6 @@ namespace BizHawk.Client.EmuHawk
_config.SkipWaterboxIntegrityChecks = cbSkipWaterboxIntegrityChecks.Checked;
_config.NoMixedInputHokeyOverride = NoMixedKeyPriorityCheckBox.Checked;
var prevLuaEngine = _config.LuaEngine;
if (LuaInterfaceRadio.Checked)
{
_config.LuaEngine = ELuaEngine.LuaPlusLuaInterface;
@ -148,12 +144,6 @@ namespace BizHawk.Client.EmuHawk
_config.LuaEngine = ELuaEngine.NLuaPlusKopiLua;
}
_osdMessageCallback("Custom configurations saved.");
if (prevLuaEngine != _config.LuaEngine)
{
_osdMessageCallback("Restart emulator for Lua change to take effect");
}
Close();
DialogResult = DialogResult.OK;
}

View File

@ -108,7 +108,7 @@ namespace BizHawk.Client.EmuHawk
var data = Palettes.Load_FCEUX_Palette(palette.ReadAllBytes());
if (showMsg)
{
_mainForm.AddOnScreenMessage($"Palette file loaded: {palette.Name}");
_mainForm.DialogController.AddOnScreenMessage($"Palette file loaded: {palette.Name}");
}
return data;
@ -120,7 +120,7 @@ namespace BizHawk.Client.EmuHawk
// no filename: interpret this as "reset to default"
if (showMsg)
{
_mainForm.AddOnScreenMessage("Standard Palette set");
_mainForm.DialogController.AddOnScreenMessage("Standard Palette set");
}
return (byte[,])Palettes.QuickNESPalette.Clone();

View File

@ -261,7 +261,6 @@ namespace BizHawk.Client.EmuHawk
SaveSettings();
_pathEntries.RefreshTempPath();
_mainForm.AddOnScreenMessage("Path settings saved");
Close();
}