Add and use interface IDialogParent
This commit is contained in:
parent
f0657b358d
commit
f0664ce018
|
@ -243,9 +243,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
W.AddSamples(samples);
|
||||
}
|
||||
|
||||
public IDisposable AcquireVideoCodecToken(IDialogController dialogController, IWin32Window hwnd, Config config)
|
||||
public IDisposable AcquireVideoCodecToken(IDialogParent parent, Config config)
|
||||
{
|
||||
return W.AcquireVideoCodecToken(dialogController, hwnd, config);
|
||||
return W.AcquireVideoCodecToken(parent, config);
|
||||
}
|
||||
|
||||
public void SetMovieParameters(int fpsNum, int fpsDen)
|
||||
|
|
|
@ -261,7 +261,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
/// Acquires a video codec configuration from the user. you may save it for future use, but you must dispose of it when you're done with it.
|
||||
/// returns null if the user canceled the dialog
|
||||
/// </summary>
|
||||
public IDisposable AcquireVideoCodecToken(IDialogController dialogController, IWin32Window hwnd, Config config)
|
||||
public IDisposable AcquireVideoCodecToken(IDialogParent parent, Config config)
|
||||
{
|
||||
var tempParams = new Parameters
|
||||
{
|
||||
|
@ -278,7 +278,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
File.Delete(tempfile);
|
||||
tempfile = Path.ChangeExtension(tempfile, "avi");
|
||||
temp.OpenFile(tempfile, tempParams, null);
|
||||
var ret = temp.AcquireVideoCodecToken(hwnd.Handle, _currVideoCodecToken);
|
||||
var ret = temp.AcquireVideoCodecToken(parent.SelfAsHandle.Handle, _currVideoCodecToken);
|
||||
CodecToken token = (CodecToken)ret;
|
||||
config.AviCodecToken = token?.Serialize();
|
||||
temp.CloseFile();
|
||||
|
|
|
@ -110,10 +110,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
public static void Run(IDialogController dialogController, IWin32Window hwnd)
|
||||
public static void Run(IDialogParent parent)
|
||||
{
|
||||
var form = new FFmpegDownloaderForm();
|
||||
dialogController.DoWithTempMute(() => form.ShowDialog(hwnd));
|
||||
parent.DialogController.DoWithTempMute(() => form.ShowDialog(parent.SelfAsHandle));
|
||||
}
|
||||
|
||||
private void btnDownload_Click(object sender, EventArgs e)
|
||||
|
|
|
@ -207,17 +207,17 @@ namespace BizHawk.Client.EmuHawk
|
|||
//ffmpeg.StandardInput.BaseStream.Write(b, 0, b.Length);
|
||||
}
|
||||
|
||||
public IDisposable AcquireVideoCodecToken(IDialogController dialogController, IWin32Window hwnd, Config config)
|
||||
public IDisposable AcquireVideoCodecToken(IDialogParent parent, Config config)
|
||||
{
|
||||
if (new FFmpegService().QueryServiceAvailable())
|
||||
{
|
||||
return FFmpegWriterForm.DoFFmpegWriterDlg(hwnd, config);
|
||||
return FFmpegWriterForm.DoFFmpegWriterDlg(parent.SelfAsHandle, config);
|
||||
}
|
||||
|
||||
FFmpegDownloaderForm.Run(dialogController, hwnd);
|
||||
FFmpegDownloaderForm.Run(parent);
|
||||
if (new FFmpegService().QueryServiceAvailable())
|
||||
{
|
||||
return FFmpegWriterForm.DoFFmpegWriterDlg(hwnd, config);
|
||||
return FFmpegWriterForm.DoFFmpegWriterDlg(parent.SelfAsHandle, config);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -195,9 +195,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
// ignored
|
||||
}
|
||||
|
||||
public IDisposable AcquireVideoCodecToken(IDialogController dialogController, IWin32Window hwnd, Config config)
|
||||
public IDisposable AcquireVideoCodecToken(IDialogParent parent, Config config)
|
||||
{
|
||||
return GifWriterForm.DoTokenForm(hwnd, config);
|
||||
return GifWriterForm.DoTokenForm(parent.SelfAsHandle, config);
|
||||
}
|
||||
|
||||
private void CalcDelay()
|
||||
|
|
|
@ -62,9 +62,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
/// obtain a set of recording compression parameters
|
||||
/// return null on user cancel
|
||||
/// </summary>
|
||||
/// <param name="hwnd">hwnd to attach to if the user is shown config dialog</param>
|
||||
/// <param name="parent">parent for if the user is shown config dialog</param>
|
||||
/// <returns>codec token, dispose of it when you're done with it</returns>
|
||||
IDisposable AcquireVideoCodecToken(IDialogController dialogController, IWin32Window hwnd, Config config);
|
||||
IDisposable AcquireVideoCodecToken(IDialogParent parent, Config config);
|
||||
|
||||
/// <summary>
|
||||
/// set framerate to fpsNum/fpsDen (assumed to be unchanging over the life of the stream)
|
||||
|
|
|
@ -73,7 +73,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
public IDisposable AcquireVideoCodecToken(IDialogController dialogController, IWin32Window hwnd, Config config)
|
||||
public IDisposable AcquireVideoCodecToken(IDialogParent parent, Config config)
|
||||
{
|
||||
return new CodecToken();
|
||||
}
|
||||
|
|
|
@ -524,12 +524,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// obtain a set of recording compression parameters
|
||||
/// </summary>
|
||||
/// <param name="hwnd">hwnd to attach to if the user is shown config dialog</param>
|
||||
/// <returns>codec token, dispose of it when you're done with it</returns>
|
||||
public IDisposable AcquireVideoCodecToken(IDialogController dialogController, IWin32Window hwnd, Config config)
|
||||
public IDisposable AcquireVideoCodecToken(IDialogParent parent, Config config)
|
||||
{
|
||||
var ret = new CodecToken();
|
||||
|
||||
|
@ -538,7 +533,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
int c = Math.Min(Math.Max(config.JmdCompression, Deflater.NO_COMPRESSION), Deflater.BEST_COMPRESSION);
|
||||
|
||||
if (!JmdForm.DoCompressionDlg(ref t, ref c, 1, 6, Deflater.NO_COMPRESSION, Deflater.BEST_COMPRESSION, hwnd))
|
||||
if (!JmdForm.DoCompressionDlg(ref t, ref c, 1, 6, Deflater.NO_COMPRESSION, Deflater.BEST_COMPRESSION, parent.SelfAsHandle))
|
||||
return null;
|
||||
|
||||
config.JmdThreads = ret.NumThreads = t;
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
// ignored
|
||||
}
|
||||
public IDisposable AcquireVideoCodecToken(IDialogController dialogController, IWin32Window hwnd, Config config)
|
||||
public IDisposable AcquireVideoCodecToken(IDialogParent parent, Config config)
|
||||
{
|
||||
return new NutWriterToken();
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
public IDisposable AcquireVideoCodecToken(IDialogController dialogController, IWin32Window hwnd, Config config)
|
||||
public IDisposable AcquireVideoCodecToken(IDialogParent parent, Config config)
|
||||
{
|
||||
return new DummyDisposable();
|
||||
}
|
||||
|
|
|
@ -10,21 +10,23 @@ using BizHawk.Emulation.Common;
|
|||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
public partial class SynclessRecordingTools : Form
|
||||
public partial class SynclessRecordingTools : Form, IDialogParent
|
||||
{
|
||||
private readonly List<FrameInfo> _mFrameInfos = new List<FrameInfo>();
|
||||
private readonly Config _config;
|
||||
private readonly IGameInfo _game;
|
||||
|
||||
private readonly IDialogController _dialogController;
|
||||
|
||||
private string _mSynclessConfigFile;
|
||||
private string _mFramesDirectory;
|
||||
|
||||
public IDialogController DialogController { get; }
|
||||
|
||||
public IWin32Window SelfAsHandle => this;
|
||||
|
||||
public SynclessRecordingTools(Config config, IGameInfo game, IDialogController dialogController)
|
||||
{
|
||||
_config = config;
|
||||
_dialogController = dialogController;
|
||||
DialogController = dialogController;
|
||||
_game = game;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
@ -126,7 +128,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
avw.SetAudioParameters(44100, 2, 16); // hacky
|
||||
avw.SetMovieParameters(60, 1); // hacky
|
||||
avw.SetVideoParameters(width, height);
|
||||
var token = avw.AcquireVideoCodecToken(_dialogController, this, _config);
|
||||
var token = avw.AcquireVideoCodecToken(this, _config);
|
||||
avw.SetVideoCodecToken(token);
|
||||
avw.OpenFile(sfd.FileName);
|
||||
foreach (var fi in _mFrameInfos)
|
||||
|
|
|
@ -229,7 +229,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
public void Dispose() { }
|
||||
}
|
||||
|
||||
public IDisposable AcquireVideoCodecToken(IDialogController dialogController, IWin32Window hwnd, Config config)
|
||||
public IDisposable AcquireVideoCodecToken(IDialogParent parent, Config config)
|
||||
{
|
||||
// don't care
|
||||
return new WavWriterVToken();
|
||||
|
|
|
@ -259,7 +259,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
Clipboard.SetImage(img);
|
||||
}
|
||||
|
||||
public static void SaveAsFile(this Bitmap bitmap, IGameInfo game, string suffix, string systemId, PathEntryCollection paths, IDialogController dialogController, IWin32Window owner)
|
||||
public static void SaveAsFile(this Bitmap bitmap, IGameInfo game, string suffix, string systemId, PathEntryCollection paths, IDialogParent parent)
|
||||
{
|
||||
using var sfd = new SaveFileDialog
|
||||
{
|
||||
|
@ -269,7 +269,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
RestoreDirectory = true
|
||||
};
|
||||
|
||||
var result = dialogController.DoWithTempMute(() => sfd.ShowDialog(owner));
|
||||
var result = parent.DialogController.DoWithTempMute(() => sfd.ShowDialog(parent.SelfAsHandle));
|
||||
if (result != DialogResult.OK)
|
||||
{
|
||||
return;
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
#nullable enable
|
||||
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
public interface IDialogParent
|
||||
{
|
||||
IDialogController DialogController { get; }
|
||||
|
||||
IWin32Window SelfAsHandle { get; }
|
||||
}
|
||||
}
|
|
@ -471,7 +471,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
Config.PathEntries.MovieAbsolutePath(),
|
||||
"Movie Files",
|
||||
MovieSession.Movie.PreferredExtension,
|
||||
this,
|
||||
this);
|
||||
|
||||
if (file != null)
|
||||
|
|
|
@ -39,7 +39,7 @@ using BizHawk.Emulation.Cores.Consoles.Nintendo.Faust;
|
|||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
public partial class MainForm : FormBase, IMainFormForApi, IMainFormForConfig, IMainFormForTools
|
||||
public partial class MainForm : FormBase, IDialogParent, IMainFormForApi, IMainFormForConfig, IMainFormForTools
|
||||
{
|
||||
/// <remarks><c>AppliesTo[0]</c> is used as the group label, and <c>Config.PreferredCores[AppliesTo[0]]</c> determines the currently selected option</remarks>
|
||||
private static readonly IReadOnlyCollection<(string[] AppliesTo, string[] CoreNames)> CoreData = new List<(string[], string[])> {
|
||||
|
@ -3221,7 +3221,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
aw.SetDefaultVideoCodecToken(Config);
|
||||
}
|
||||
|
||||
var token = aw.AcquireVideoCodecToken(this, this, Config);
|
||||
var token = aw.AcquireVideoCodecToken(this, Config);
|
||||
if (token == null)
|
||||
{
|
||||
AddOnScreenMessage("A/V capture canceled.");
|
||||
|
@ -4491,6 +4491,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
return isRewinding;
|
||||
}
|
||||
|
||||
public IDialogController DialogController => this;
|
||||
|
||||
public IWin32Window SelfAsHandle => this;
|
||||
|
||||
public DialogResult ShowDialogAsChild(Form dialog) => dialog.ShowDialog(this);
|
||||
|
||||
public void StartSound() => Sound.StartSound();
|
||||
|
|
|
@ -370,7 +370,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
Config.PathEntries.ToolsAbsolutePath(),
|
||||
"Bot files",
|
||||
"bot",
|
||||
MainForm,
|
||||
this);
|
||||
|
||||
if (file != null)
|
||||
|
|
|
@ -392,7 +392,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
Config.PathEntries.LogAbsolutePath(),
|
||||
"Code Data Logger Files",
|
||||
"cdl",
|
||||
MainForm,
|
||||
this);
|
||||
|
||||
if (file == null)
|
||||
|
|
|
@ -29,6 +29,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
private string _sortedColumn;
|
||||
private bool _sortReverse;
|
||||
|
||||
public override IWin32Window SelfAsHandle => Owner ?? this; //TODO necessary? --yoshi
|
||||
|
||||
protected override string WindowTitleStatic => "Cheats";
|
||||
|
||||
public Cheats()
|
||||
|
@ -150,8 +152,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
Config.PathEntries.CheatsAbsolutePath(Game.System),
|
||||
"Cheat Files",
|
||||
"cht",
|
||||
MainForm,
|
||||
Owner ?? this);
|
||||
this);
|
||||
|
||||
return file != null && MainForm.CheatList.SaveFile(file.FullName);
|
||||
}
|
||||
|
|
|
@ -187,7 +187,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
g.Flush();
|
||||
}
|
||||
|
||||
toSave.Bmp.SaveAsFile(Game, "Print", Emulator.SystemId, Config.PathEntries, MainForm, this);
|
||||
toSave.Bmp.SaveAsFile(Game, "Print", Emulator.SystemId, Config.PathEntries, this);
|
||||
}
|
||||
|
||||
private void CopyToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
|
|
|
@ -179,7 +179,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void SaveAsFile(Bitmap bitmap, string suffix)
|
||||
{
|
||||
bitmap.SaveAsFile(Game, suffix, Emu.SystemId, Config.PathEntries, MainForm, this);
|
||||
bitmap.SaveAsFile(Game, suffix, Emu.SystemId, Config.PathEntries, this);
|
||||
}
|
||||
|
||||
private void SaveBGAScreenshotToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
|
|
|
@ -188,7 +188,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
NameTableView
|
||||
.ToBitMap()
|
||||
.SaveAsFile(Game, "Nametables", "NES", Config.PathEntries, MainForm, this);
|
||||
.SaveAsFile(Game, "Nametables", "NES", Config.PathEntries, this);
|
||||
}
|
||||
|
||||
private void ScreenshotToClipboardMenuItem_Click(object sender, EventArgs e)
|
||||
|
|
|
@ -314,7 +314,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void Screenshot(Bitmap b, string suffix)
|
||||
{
|
||||
b.SaveAsFile(Game, suffix, "NES", Config.PathEntries, MainForm, this);
|
||||
b.SaveAsFile(Game, suffix, "NES", Config.PathEntries, this);
|
||||
}
|
||||
|
||||
private void SavePaletteScreenshotMenuItem_Click(object sender, EventArgs e)
|
||||
|
|
|
@ -204,7 +204,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void SaveAsFile(Bitmap bmp, string suffix)
|
||||
{
|
||||
bmp.SaveAsFile(Game, suffix, Emulator.SystemId, Config.PathEntries, MainForm, this);
|
||||
bmp.SaveAsFile(Game, suffix, Emulator.SystemId, Config.PathEntries, this);
|
||||
}
|
||||
|
||||
private void SaveBackgroundScreenshotMenuItem_Click(object sender, EventArgs e)
|
||||
|
|
|
@ -197,7 +197,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void SaveAsFile(Bitmap bmp, string suffix)
|
||||
{
|
||||
bmp.SaveAsFile(Game, suffix, Emulator.SystemId, Config.PathEntries, MainForm, this);
|
||||
bmp.SaveAsFile(Game, suffix, Emulator.SystemId, Config.PathEntries, this);
|
||||
}
|
||||
|
||||
private void SaveTilesScreenshotToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
|
|
|
@ -826,7 +826,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
Config.PathEntries.MovieAbsolutePath(),
|
||||
"Tas Project Files",
|
||||
"tasproj",
|
||||
MainForm,
|
||||
this
|
||||
);
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ using BizHawk.Emulation.Common;
|
|||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
public class ToolFormBase : FormBase, IToolForm
|
||||
public class ToolFormBase : FormBase, IToolForm, IDialogParent
|
||||
{
|
||||
public ToolManager Tools { protected get; set; }
|
||||
|
||||
|
@ -22,6 +22,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public IGameInfo Game { protected get; set; }
|
||||
|
||||
public IDialogController DialogController => MainForm;
|
||||
|
||||
public virtual IWin32Window SelfAsHandle => this;
|
||||
|
||||
public virtual bool AskSaveChanges() => true;
|
||||
|
||||
public virtual void Restart() {}
|
||||
|
@ -80,7 +84,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
return new FileInfo(ofd.FileName);
|
||||
}
|
||||
|
||||
public static FileInfo SaveFileDialog(string currentFile, string path, string fileType, string fileExt, IDialogController dialogController, IWin32Window owner)
|
||||
public static FileInfo SaveFileDialog(string currentFile, string path, string fileType, string fileExt, IDialogParent parent)
|
||||
{
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
|
@ -95,7 +99,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
RestoreDirectory = true
|
||||
};
|
||||
|
||||
var result = dialogController.DoWithTempMute(() => sfd.ShowDialog(owner));
|
||||
var result = parent.DialogController.DoWithTempMute(() => sfd.ShowDialog(parent.SelfAsHandle));
|
||||
if (result != DialogResult.OK)
|
||||
{
|
||||
return null;
|
||||
|
@ -111,7 +115,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public FileInfo GetWatchSaveFileFromUser(string currentFile)
|
||||
{
|
||||
return SaveFileDialog(currentFile, Config.PathEntries.WatchAbsolutePath(), "Watch Files", "wch", MainForm, this);
|
||||
return SaveFileDialog(currentFile, Config.PathEntries.WatchAbsolutePath(), "Watch Files", "wch", this);
|
||||
}
|
||||
|
||||
public void ViewInHexEditor(MemoryDomain domain, IEnumerable<long> addresses, WatchSize size)
|
||||
|
|
Loading…
Reference in New Issue