Cache and reuse `FilesystemFilterSet`s
This commit is contained in:
parent
1232157cc1
commit
2db5235319
src
BizHawk.Client.Common
BizHawk.Client.EmuHawk
MainForm.Events.csMainForm.cs
config
movie
tools
|
@ -61,8 +61,6 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public static readonly FilesystemFilter LuaScripts = new FilesystemFilter("Lua Scripts", new[] { "lua" });
|
||||
|
||||
public static readonly FilesystemFilter Palettes = new FilesystemFilter("Palette Files", new[] { "pal" });
|
||||
|
||||
public static readonly FilesystemFilter PNGs = new FilesystemFilter("PNG Files", new[] { "png" });
|
||||
|
||||
public static readonly FilesystemFilter TAStudioProjects = new FilesystemFilter("TAS Project Files", new[] { MovieService.TasMovieExtension });
|
||||
|
|
|
@ -35,6 +35,8 @@ namespace BizHawk.Client.Common
|
|||
return _ser;
|
||||
}
|
||||
|
||||
public static readonly FilesystemFilterSet Palettes = new(new FilesystemFilter("Palette Files", new[] { "pal" }));
|
||||
|
||||
public static readonly FilesystemFilterSet Screenshots = new FilesystemFilterSet(FilesystemFilter.PNGs, new FilesystemFilter(".bmp Files", new[] { "bmp" }));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -255,6 +255,9 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public static class MovieExtensions
|
||||
{
|
||||
public static FilesystemFilterSet GetFSFilterSet(this IMovie/*?*/ movie)
|
||||
=> new(new FilesystemFilter("Movie Files", new[] { movie?.PreferredExtension ?? MovieService.StandardMovieExtension }));
|
||||
|
||||
public static bool IsActive(this IMovie movie) => movie != null && movie.Mode != MovieMode.Inactive;
|
||||
public static bool NotActive(this IMovie movie) => movie == null || movie.Mode == MovieMode.Inactive;
|
||||
public static bool IsPlaying(this IMovie movie) => movie?.Mode == MovieMode.Play;
|
||||
|
|
|
@ -72,6 +72,23 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public partial class MainForm
|
||||
{
|
||||
private static readonly FilesystemFilterSet MAMERomsFSFilterSet = new(new FilesystemFilter("MAME Arcade ROMs", new[] { "zip" }))
|
||||
{
|
||||
AppendAllFilesEntry = false,
|
||||
};
|
||||
|
||||
private static readonly FilesystemFilterSet ScreenshotsFSFilterSet = new(FilesystemFilter.PNGs)
|
||||
{
|
||||
AppendAllFilesEntry = false,
|
||||
};
|
||||
|
||||
private static readonly FilesystemFilterSet TI83ProgramFilesFSFilterSet = new(new FilesystemFilter("TI-83 Program Files", new[] { "83p", "8xp" }));
|
||||
|
||||
private static readonly FilesystemFilterSet ZXStateFilesFSFilterSet = new(new FilesystemFilter("ZX-State files", new[] { "szx" }))
|
||||
{
|
||||
AppendAllFilesEntry = false,
|
||||
};
|
||||
|
||||
private void FileSubMenu_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
SaveStateSubMenu.Enabled =
|
||||
|
@ -316,7 +333,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
else if (oac.Result == AdvancedRomLoaderType.MameLaunchGame)
|
||||
{
|
||||
args.OpenAdvanced = new OpenAdvanced_MAME();
|
||||
filter = new FilesystemFilter("MAME Arcade ROMs", new[] { "zip" }).ToString();
|
||||
filter = MAMERomsFSFilterSet.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -521,10 +538,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
var file = ToolFormBase.SaveFileDialog(
|
||||
filename,
|
||||
Config.PathEntries.MovieAbsolutePath(),
|
||||
"Movie Files",
|
||||
MovieSession.Movie.PreferredExtension,
|
||||
currentFile: filename,
|
||||
path: Config.PathEntries.MovieAbsolutePath(),
|
||||
MovieSession.Movie.GetFSFilterSet(),
|
||||
this);
|
||||
|
||||
if (file != null)
|
||||
|
@ -619,7 +635,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
InitialDirectory = dir,
|
||||
FileName = file,
|
||||
Filter = FilesystemFilter.PNGs.ToString()
|
||||
Filter = ScreenshotsFSFilterSet.ToString(),
|
||||
};
|
||||
|
||||
if (this.ShowDialogWithTempMute(sfd).IsOk())
|
||||
|
@ -1547,7 +1563,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
if (Emulator is not TI83 ti83) return;
|
||||
using var ofd = new OpenFileDialog
|
||||
{
|
||||
Filter = new FilesystemFilterSet(new FilesystemFilter("TI-83 Program Files", new[] { "83p", "8xp" })).ToString(),
|
||||
Filter = TI83ProgramFilesFSFilterSet.ToString(),
|
||||
InitialDirectory = Config.PathEntries.RomAbsolutePath(Emulator.SystemId),
|
||||
RestoreDirectory = true
|
||||
};
|
||||
|
@ -2166,7 +2182,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
using var zxSnapExpDialog = new SaveFileDialog
|
||||
{
|
||||
DefaultExt = "szx",
|
||||
Filter = new FilesystemFilter("ZX-State files", new[] { "szx" }).ToString(),
|
||||
Filter = ZXStateFilesFSFilterSet.ToString(),
|
||||
RestoreDirectory = true,
|
||||
SupportMultiDottedExtensions = true,
|
||||
Title = "EXPERIMENTAL - Export 3rd party snapshot formats"
|
||||
|
|
|
@ -48,6 +48,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public partial class MainForm : FormBase, IDialogParent, IMainFormForApi, IMainFormForTools
|
||||
{
|
||||
private static readonly FilesystemFilterSet EmuHawkSaveStatesFSFilterSet = new(FilesystemFilter.EmuHawkSaveStates);
|
||||
|
||||
private static readonly FilesystemFilterSet LibretroCoresFSFilterSet = new(new FilesystemFilter("Libretro Cores", new[] { OSTailoredCode.IsUnixHost ? "so" : "dll" }))
|
||||
{
|
||||
AppendAllFilesEntry = false,
|
||||
};
|
||||
|
||||
private void MainForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
UpdateWindowTitle();
|
||||
|
@ -1616,7 +1623,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
ofd.RestoreDirectory = true;
|
||||
ofd.Filter = new FilesystemFilter("Libretro Cores", new[] { OSTailoredCode.IsUnixHost ? "so" : "dll" }).ToString();
|
||||
ofd.Filter = LibretroCoresFSFilterSet.ToString();
|
||||
|
||||
if (ofd.ShowDialog() == DialogResult.Cancel)
|
||||
{
|
||||
|
@ -4410,7 +4417,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
AddExtension = true,
|
||||
DefaultExt = "State",
|
||||
Filter = new FilesystemFilterSet(FilesystemFilter.EmuHawkSaveStates).ToString(),
|
||||
Filter = EmuHawkSaveStatesFSFilterSet.ToString(),
|
||||
InitialDirectory = path,
|
||||
FileName = $"{SaveStatePrefix()}.QuickSave0.State"
|
||||
};
|
||||
|
@ -4442,7 +4449,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
using var ofd = new OpenFileDialog
|
||||
{
|
||||
InitialDirectory = Config.PathEntries.SaveStateAbsolutePath(Game.System),
|
||||
Filter = new FilesystemFilterSet(FilesystemFilter.EmuHawkSaveStates).ToString(),
|
||||
Filter = EmuHawkSaveStatesFSFilterSet.ToString(),
|
||||
RestoreDirectory = true
|
||||
};
|
||||
|
||||
|
|
|
@ -11,6 +11,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public partial class DisplayConfig : Form, IDialogParent
|
||||
{
|
||||
private static readonly FilesystemFilterSet CgShaderPresetsFSFilterSet = new(new FilesystemFilter(".CGP Files", new[] { "cgp" }))
|
||||
{
|
||||
AppendAllFilesEntry = false,
|
||||
};
|
||||
|
||||
private readonly Config _config;
|
||||
|
||||
private readonly IGL _gl;
|
||||
|
@ -265,7 +270,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
using var ofd = new OpenFileDialog
|
||||
{
|
||||
Filter = new FilesystemFilter(".CGP Files", new[] { "cgp" }).ToString(),
|
||||
Filter = CgShaderPresetsFSFilterSet.ToString(),
|
||||
FileName = _pathSelection
|
||||
};
|
||||
if (!this.ShowDialogAsChild(ofd).IsOk()) return;
|
||||
|
|
|
@ -305,7 +305,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
using var ofd = new OpenFileDialog
|
||||
{
|
||||
InitialDirectory = _config.PathEntries.ScreenshotAbsolutePathFor(VSystemID.Raw.GB),
|
||||
Filter = new FilesystemFilterSet(FilesystemFilter.Palettes).ToString(),
|
||||
Filter = FilesystemFilterSet.Palettes.ToString(),
|
||||
RestoreDirectory = true
|
||||
};
|
||||
|
||||
|
@ -342,7 +342,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
InitialDirectory = _config.PathEntries.PalettesAbsolutePathFor(VSystemID.Raw.GB),
|
||||
FileName = $"{_game.Name}.pal",
|
||||
Filter = new FilesystemFilterSet(FilesystemFilter.Palettes).ToString(),
|
||||
Filter = FilesystemFilterSet.Palettes.ToString(),
|
||||
RestoreDirectory = true
|
||||
};
|
||||
|
||||
|
|
|
@ -267,7 +267,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
using var ofd = new OpenFileDialog
|
||||
{
|
||||
InitialDirectory = _config.PathEntries.ScreenshotAbsolutePathFor(VSystemID.Raw.GB),
|
||||
Filter = new FilesystemFilterSet(FilesystemFilter.Palettes).ToString(),
|
||||
Filter = FilesystemFilterSet.Palettes.ToString(),
|
||||
RestoreDirectory = true
|
||||
};
|
||||
|
||||
|
@ -304,7 +304,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
InitialDirectory = _config.PathEntries.PalettesAbsolutePathFor(VSystemID.Raw.GB),
|
||||
FileName = $"{_game.Name}.pal",
|
||||
Filter = new FilesystemFilterSet(FilesystemFilter.Palettes).ToString(),
|
||||
Filter = FilesystemFilterSet.Palettes.ToString(),
|
||||
RestoreDirectory = true
|
||||
};
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
using var ofd = new OpenFileDialog
|
||||
{
|
||||
InitialDirectory = _config.PathEntries.PalettesAbsolutePathFor(VSystemID.Raw.NES),
|
||||
Filter = new FilesystemFilterSet(FilesystemFilter.Palettes).ToString(),
|
||||
Filter = FilesystemFilterSet.Palettes.ToString(),
|
||||
RestoreDirectory = true
|
||||
};
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
using var ofd = new OpenFileDialog
|
||||
{
|
||||
InitialDirectory = _config.PathEntries.PalettesAbsolutePathFor(VSystemID.Raw.NES),
|
||||
Filter = new FilesystemFilterSet(FilesystemFilter.Palettes).ToString(),
|
||||
Filter = FilesystemFilterSet.Palettes.ToString(),
|
||||
RestoreDirectory = true
|
||||
};
|
||||
|
||||
|
|
|
@ -11,7 +11,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public partial class EditSubtitlesForm : Form, IDialogParent
|
||||
{
|
||||
|
||||
private static readonly FilesystemFilterSet SubRipFilesFSFilterSet = new(new FilesystemFilter("SubRip Files", new[] { "srt" }));
|
||||
|
||||
private readonly IMovie _selectedMovie;
|
||||
private readonly bool _readOnly;
|
||||
|
||||
|
@ -204,7 +205,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
using var form = new SaveFileDialog
|
||||
{
|
||||
AddExtension = true,
|
||||
Filter = new FilesystemFilterSet(new FilesystemFilter("SubRip Files", new[] { "srt" })).ToString()
|
||||
Filter = SubRipFilesFSFilterSet.ToString(),
|
||||
};
|
||||
|
||||
var result = form.ShowDialog();
|
||||
|
|
|
@ -16,6 +16,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public partial class PlayMovie : Form, IDialogParent
|
||||
{
|
||||
private static readonly FilesystemFilterSet MoviesFSFilterSet = new(FilesystemFilter.BizHawkMovies, FilesystemFilter.TAStudioProjects);
|
||||
|
||||
private readonly Func<FirmwareID, string, string> _canProvideFirmware;
|
||||
|
||||
private readonly IMainFormForTools _mainForm;
|
||||
|
@ -508,7 +510,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
using var ofd = new OpenFileDialog
|
||||
{
|
||||
Filter = new FilesystemFilterSet(FilesystemFilter.BizHawkMovies, FilesystemFilter.TAStudioProjects).ToString(),
|
||||
Filter = MoviesFSFilterSet.ToString(),
|
||||
InitialDirectory = _config.PathEntries.MovieAbsolutePath()
|
||||
};
|
||||
if (!this.ShowDialogWithTempMute(ofd).IsOk()) return;
|
||||
|
|
|
@ -197,14 +197,14 @@ namespace BizHawk.Client.EmuHawk
|
|||
else throw;
|
||||
}
|
||||
|
||||
var preferredExt = _movieSession.Movie?.PreferredExtension ?? "bk2";
|
||||
var filterset = _movieSession.Movie.GetFSFilterSet();
|
||||
using var sfd = new SaveFileDialog
|
||||
{
|
||||
InitialDirectory = movieFolderPath,
|
||||
DefaultExt = $".{preferredExt}",
|
||||
DefaultExt = $".{filterset.Filters[0].Extensions.First()}",
|
||||
FileName = RecordBox.Text,
|
||||
OverwritePrompt = false,
|
||||
Filter = new FilesystemFilterSet(new FilesystemFilter("Movie Files", new[] { preferredExt })).ToString()
|
||||
Filter = filterset.ToString(),
|
||||
};
|
||||
|
||||
var result = this.ShowDialogWithTempMute(sfd);
|
||||
|
|
|
@ -17,6 +17,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public sealed partial class BasicBot : ToolFormBase, IToolFormAutoConfig
|
||||
{
|
||||
private static readonly FilesystemFilterSet BotFilesFSFilterSet = new(new FilesystemFilter("Bot files", new[] { "bot" }));
|
||||
|
||||
private string _currentFileName = "";
|
||||
|
||||
private string CurrentFileName
|
||||
|
@ -346,10 +348,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
private void OpenMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var file = OpenFileDialog(
|
||||
CurrentFileName,
|
||||
Config.PathEntries.ToolsAbsolutePath(),
|
||||
"Bot files",
|
||||
"bot");
|
||||
currentFile: CurrentFileName,
|
||||
path: Config!.PathEntries.ToolsAbsolutePath(),
|
||||
BotFilesFSFilterSet);
|
||||
|
||||
if (file != null)
|
||||
{
|
||||
|
@ -374,10 +375,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
var file = SaveFileDialog(
|
||||
fileName,
|
||||
Config.PathEntries.ToolsAbsolutePath(),
|
||||
"Bot files",
|
||||
"bot",
|
||||
currentFile: fileName,
|
||||
path: Config!.PathEntries.ToolsAbsolutePath(),
|
||||
BotFilesFSFilterSet,
|
||||
this);
|
||||
|
||||
if (file != null)
|
||||
|
|
|
@ -20,6 +20,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public partial class CDL : ToolFormBase, IToolFormAutoConfig
|
||||
{
|
||||
private static readonly FilesystemFilterSet CDLFilesFSFilterSet = new(new FilesystemFilter("Code Data Logger Files", new[] { "cdl" }));
|
||||
|
||||
private RecentFiles _recentFld = new RecentFiles();
|
||||
|
||||
[ConfigPersist]
|
||||
|
@ -320,10 +322,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
private void OpenMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var file = OpenFileDialog(
|
||||
_currentFilename,
|
||||
Config.PathEntries.LogAbsolutePath(),
|
||||
"Code Data Logger Files",
|
||||
"cdl");
|
||||
currentFile: _currentFilename,
|
||||
path: Config!.PathEntries.LogAbsolutePath(),
|
||||
CDLFilesFSFilterSet);
|
||||
|
||||
if (file == null)
|
||||
return;
|
||||
|
@ -374,10 +375,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
var file = SaveFileDialog(
|
||||
fileName,
|
||||
Config.PathEntries.LogAbsolutePath(),
|
||||
"Code Data Logger Files",
|
||||
"cdl",
|
||||
currentFile: fileName,
|
||||
path: Config!.PathEntries.LogAbsolutePath(),
|
||||
CDLFilesFSFilterSet,
|
||||
this);
|
||||
|
||||
if (file == null)
|
||||
|
@ -402,10 +402,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
else
|
||||
{
|
||||
var file = OpenFileDialog(
|
||||
_currentFilename,
|
||||
Config.PathEntries.LogAbsolutePath(),
|
||||
"Code Data Logger Files",
|
||||
"cdl");
|
||||
currentFile: _currentFilename,
|
||||
path: Config!.PathEntries.LogAbsolutePath(),
|
||||
CDLFilesFSFilterSet);
|
||||
|
||||
if (file != null)
|
||||
{
|
||||
|
|
|
@ -27,6 +27,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
private const string TypeColumn = "DisplayTypeColumn";
|
||||
private const string ComparisonTypeColumn = "ComparisonTypeColumn";
|
||||
|
||||
private static readonly FilesystemFilterSet CheatsFSFilterSet = new(new FilesystemFilter("Cheat Files", new[] { "cht" }));
|
||||
|
||||
private string _sortedColumn;
|
||||
private bool _sortReverse;
|
||||
|
||||
|
@ -147,10 +149,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
var file = SaveFileDialog(
|
||||
fileName,
|
||||
Config.PathEntries.CheatsAbsolutePath(Game.System),
|
||||
"Cheat Files",
|
||||
"cht",
|
||||
currentFile: fileName,
|
||||
path: Config!.PathEntries.CheatsAbsolutePath(Game.System),
|
||||
CheatsFSFilterSet,
|
||||
this);
|
||||
|
||||
return file != null && MainForm.CheatList.SaveFile(file.FullName);
|
||||
|
@ -356,10 +357,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
private void OpenMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var file = OpenFileDialog(
|
||||
MainForm.CheatList.CurrentFileName,
|
||||
Config.PathEntries.CheatsAbsolutePath(Game.System),
|
||||
"Cheat Files",
|
||||
"cht");
|
||||
currentFile: MainForm.CheatList.CurrentFileName,
|
||||
path: Config!.PathEntries.CheatsAbsolutePath(Game.System),
|
||||
CheatsFSFilterSet);
|
||||
|
||||
LoadFile(file, append: sender == AppendMenuItem);
|
||||
}
|
||||
|
|
|
@ -41,6 +41,21 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
private const string ROM_DOMAIN_NAME = "File on Disk";
|
||||
|
||||
private static readonly FilesystemFilterSet BinFilesFSFilterSet = CreateBinaryDumpFSFilterSet("bin");
|
||||
|
||||
private static readonly FilesystemFilterSet HexDumpsFSFilterSet = new(FilesystemFilter.TextFiles);
|
||||
|
||||
private static readonly FilesystemFilterSet ImportableFSFilterSet = new(
|
||||
BinFilesFSFilterSet.Filters[0],
|
||||
new FilesystemFilter("Save Files", new[] { "sav" }));
|
||||
|
||||
private static readonly FilesystemFilterSet TextTablesFSFilterSet = new(new FilesystemFilter("Text Table Files", new[] { "tbl" }));
|
||||
|
||||
private static FilesystemFilterSet CreateBinaryDumpFSFilterSet(string ext)
|
||||
=> new(new FilesystemFilter("Binary", new[] { ext }));
|
||||
|
||||
[RequiredService]
|
||||
private IMemoryDomains MemoryDomains { get; set; }
|
||||
|
||||
|
@ -193,7 +208,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
if (!(MainForm.CurrentlyOpenRomArgs.OpenAdvanced is OpenAdvanced_MAME))
|
||||
{
|
||||
_rom = GetRomBytes();
|
||||
_romDomain = new MemoryDomainByteArray("File on Disk", MemoryDomain.Endian.Little, _rom, true, 1);
|
||||
_romDomain = new MemoryDomainByteArray(ROM_DOMAIN_NAME, MemoryDomain.Endian.Little, _rom, writable: true, wordSize: 1);
|
||||
|
||||
if (_domain.Name == _romDomain.Name)
|
||||
{
|
||||
|
@ -878,17 +893,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
private string GetSaveFileFilter()
|
||||
{
|
||||
if (_domain.Name == "File on Disk")
|
||||
{
|
||||
var extension = Path.GetExtension(RomName);
|
||||
return $"Binary (*{extension})|*{extension}|All Files|*.*";
|
||||
}
|
||||
|
||||
return "Binary (*.bin)|*.bin|All Files|*.*";
|
||||
}
|
||||
|
||||
private string RomDirectory
|
||||
{
|
||||
get
|
||||
|
@ -921,13 +925,14 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
using var sfd = new SaveFileDialog
|
||||
{
|
||||
Filter = GetSaveFileFilter()
|
||||
, RestoreDirectory = true
|
||||
, InitialDirectory = RomDirectory
|
||||
, FileName =
|
||||
_domain.Name == "File on Disk"
|
||||
? RomName
|
||||
: Game.FilesystemSafeName()
|
||||
Filter = (_domain.Name is ROM_DOMAIN_NAME
|
||||
? CreateBinaryDumpFSFilterSet(Path.GetExtension(RomName).RemovePrefix('.'))
|
||||
: BinFilesFSFilterSet).ToString(),
|
||||
RestoreDirectory = true,
|
||||
InitialDirectory = RomDirectory,
|
||||
FileName = _domain.Name is ROM_DOMAIN_NAME
|
||||
? RomName
|
||||
: Game.FilesystemSafeName(),
|
||||
};
|
||||
|
||||
var result = this.ShowDialogWithTempMute(sfd);
|
||||
|
@ -938,10 +943,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
using var sfd = new SaveFileDialog
|
||||
{
|
||||
FileName = _domain.Name == "File on Disk"
|
||||
FileName = _domain.Name is ROM_DOMAIN_NAME
|
||||
? $"{Path.GetFileNameWithoutExtension(RomName)}.txt"
|
||||
: Game.FilesystemSafeName(),
|
||||
Filter = new FilesystemFilterSet(FilesystemFilter.TextFiles).ToString(),
|
||||
Filter = HexDumpsFSFilterSet.ToString(),
|
||||
InitialDirectory = RomDirectory,
|
||||
RestoreDirectory = true
|
||||
};
|
||||
|
@ -1232,7 +1237,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void FileSubMenu_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
if (_domain.Name == "File on Disk")
|
||||
if (_domain.Name is ROM_DOMAIN_NAME)
|
||||
{
|
||||
SaveMenuItem.Visible = !CurrentRomIsArchive();
|
||||
SaveAsBinaryMenuItem.Text = "Save as ROM...";
|
||||
|
@ -1272,10 +1277,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
using var sfd = new OpenFileDialog
|
||||
{
|
||||
Filter = new FilesystemFilterSet(
|
||||
new FilesystemFilter("Binary", new[] { "bin" }),
|
||||
new FilesystemFilter("Save Files", new[] { "sav" })
|
||||
).ToString(),
|
||||
Filter = ImportableFSFilterSet.ToString(),
|
||||
RestoreDirectory = true
|
||||
};
|
||||
|
||||
|
@ -1323,7 +1325,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
FileName = $"{Path.GetFileNameWithoutExtension(romName)}.tbl",
|
||||
InitialDirectory = initialDirectory,
|
||||
Filter = new FilesystemFilterSet(new FilesystemFilter("Text Table Files", new[] { "tbl" })).ToString(),
|
||||
Filter = TextTablesFSFilterSet.ToString(),
|
||||
RestoreDirectory = false
|
||||
};
|
||||
if (!this.ShowDialogWithTempMute(ofd).IsOk()) return;
|
||||
|
|
|
@ -24,6 +24,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
private const string ScriptColumnName = "Script";
|
||||
private const string PathColumnName = "PathName";
|
||||
|
||||
private static readonly FilesystemFilterSet JustScriptsFSFilterSet = new(FilesystemFilter.LuaScripts);
|
||||
|
||||
private static readonly FilesystemFilterSet ScriptsAndTextFilesFSFilterSet = new(FilesystemFilter.LuaScripts, FilesystemFilter.TextFiles);
|
||||
|
||||
private static readonly FilesystemFilterSet SessionsFSFilterSet = new FilesystemFilterSet(new FilesystemFilter("Lua Session Files", new[] { "luases" }));
|
||||
|
||||
private readonly LuaAutocompleteInstaller _luaAutoInstaller = new LuaAutocompleteInstaller();
|
||||
|
@ -852,7 +856,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
DefaultExt = ".lua",
|
||||
FileName = ext,
|
||||
OverwritePrompt = true,
|
||||
Filter = new FilesystemFilterSet(FilesystemFilter.LuaScripts).ToString()
|
||||
Filter = JustScriptsFSFilterSet.ToString(),
|
||||
};
|
||||
|
||||
var result = this.ShowDialogWithTempMute(sfd);
|
||||
|
@ -877,7 +881,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
var ofd = new OpenFileDialog
|
||||
{
|
||||
InitialDirectory = initDir,
|
||||
Filter = new FilesystemFilterSet(FilesystemFilter.LuaScripts, FilesystemFilter.TextFiles).ToString(),
|
||||
Filter = ScriptsAndTextFilesFSFilterSet.ToString(),
|
||||
RestoreDirectory = true,
|
||||
Multiselect = true
|
||||
};
|
||||
|
@ -1000,7 +1004,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
DefaultExt = ".lua",
|
||||
FileName = $"{fileNoExt} (1)",
|
||||
OverwritePrompt = true,
|
||||
Filter = new FilesystemFilterSet(FilesystemFilter.LuaScripts).ToString()
|
||||
Filter = JustScriptsFSFilterSet.ToString(),
|
||||
};
|
||||
if (!sfd.ShowDialog().IsOk()) return;
|
||||
string text = File.ReadAllText(script.Path);
|
||||
|
|
|
@ -18,6 +18,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public partial class MultiDiskBundler : ToolFormBase, IToolFormAutoConfig
|
||||
{
|
||||
private static readonly FilesystemFilterSet BundlesFSFilterSet = new(new FilesystemFilter("XML Files", new[] { "xml" }));
|
||||
|
||||
private XElement _currentXml;
|
||||
|
||||
[RequiredService]
|
||||
|
@ -259,7 +261,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
FileName = filename,
|
||||
InitialDirectory = initialDirectory,
|
||||
Filter = new FilesystemFilterSet(new FilesystemFilter("XML Files", new[] { "xml" })).ToString()
|
||||
Filter = BundlesFSFilterSet.ToString(),
|
||||
};
|
||||
|
||||
if (this.ShowDialogWithTempMute(sfd) != DialogResult.Cancel)
|
||||
|
|
|
@ -17,6 +17,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public partial class NESMusicRipper : ToolFormBase, IToolFormAutoConfig
|
||||
{
|
||||
private static readonly FilesystemFilterSet RenoiseFilesFSFilterSet = new(new FilesystemFilter("Renoise Song Files", new[] { "xrns" }))
|
||||
{
|
||||
AppendAllFilesEntry = false,
|
||||
};
|
||||
|
||||
[RequiredService]
|
||||
private NES Nes { get; set; }
|
||||
|
||||
|
@ -100,7 +105,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
//acquire target
|
||||
using var sfd = new SaveFileDialog
|
||||
{
|
||||
Filter = new FilesystemFilter("Renoise Song Files", new[] { "xrns" }).ToString()
|
||||
Filter = RenoiseFilesFSFilterSet.ToString(),
|
||||
};
|
||||
if (sfd.ShowDialog().IsOk())
|
||||
{
|
||||
|
|
|
@ -14,6 +14,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public partial class TAStudio
|
||||
{
|
||||
private static readonly FilesystemFilterSet MoviesFSFilterSet = new(
|
||||
new FilesystemFilter("All Available Files", MovieService.MovieExtensions.Reverse().ToArray()),
|
||||
FilesystemFilter.TAStudioProjects,
|
||||
FilesystemFilter.BizHawkMovies);
|
||||
|
||||
private void FileSubMenu_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
ToBk2MenuItem.Enabled =
|
||||
|
@ -89,11 +94,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
FileName = filename,
|
||||
InitialDirectory = Config.PathEntries.MovieAbsolutePath(),
|
||||
Filter = new FilesystemFilterSet(
|
||||
new FilesystemFilter("All Available Files", MovieService.MovieExtensions.Reverse().ToArray()),
|
||||
FilesystemFilter.TAStudioProjects,
|
||||
FilesystemFilter.BizHawkMovies
|
||||
).ToString()
|
||||
Filter = MoviesFSFilterSet.ToString(),
|
||||
};
|
||||
|
||||
if (this.ShowDialogWithTempMute(ofd).IsOk())
|
||||
|
|
|
@ -16,6 +16,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public partial class TAStudio : ToolFormBase, IToolFormAutoConfig, IControlMainform
|
||||
{
|
||||
public static readonly FilesystemFilterSet TAStudioProjectsFSFilterSet = new(FilesystemFilter.TAStudioProjects);
|
||||
|
||||
public override bool BlocksInputWhenFocused => IsInMenuLoop;
|
||||
|
||||
public new IMainFormForTools MainForm => base.MainForm;
|
||||
|
@ -779,12 +781,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
var file = SaveFileDialog(
|
||||
filename,
|
||||
Config.PathEntries.MovieAbsolutePath(),
|
||||
"Tas Project Files",
|
||||
"tasproj",
|
||||
this
|
||||
);
|
||||
currentFile: filename,
|
||||
path: Config!.PathEntries.MovieAbsolutePath(),
|
||||
TAStudioProjectsFSFilterSet,
|
||||
this);
|
||||
|
||||
if (file != null)
|
||||
{
|
||||
|
|
|
@ -11,6 +11,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public class ToolFormBase : FormBase, IToolForm, IDialogParent
|
||||
{
|
||||
private static readonly FilesystemFilterSet WatchFilesFSFilterSet = new(new FilesystemFilter("Watch Files", new[] { "wch" }));
|
||||
|
||||
protected ToolManager Tools { get; private set; }
|
||||
|
||||
protected DisplayManager DisplayManager { get; private set; }
|
||||
|
@ -76,10 +78,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
protected virtual void FastUpdateBefore() { }
|
||||
protected virtual void FastUpdateAfter() { }
|
||||
|
||||
public FileInfo OpenFileDialog(string currentFile, string path, string fileType, string fileExt)
|
||||
{
|
||||
return OpenFileDialog(currentFile, path, new FilesystemFilterSet(new FilesystemFilter(fileType, new[] { fileExt })));
|
||||
}
|
||||
public FileInfo OpenFileDialog(string currentFile, string path, FilesystemFilterSet filterSet)
|
||||
{
|
||||
Directory.CreateDirectory(path);
|
||||
|
@ -97,10 +95,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
return result.IsOk() ? new FileInfo(ofd.FileName) : null;
|
||||
}
|
||||
|
||||
public static FileInfo SaveFileDialog(string currentFile, string path, string fileType, string fileExt, IDialogParent parent)
|
||||
{
|
||||
return SaveFileDialog(currentFile, path, new FilesystemFilterSet(new FilesystemFilter(fileType, new[] { fileExt })), parent);
|
||||
}
|
||||
public static FileInfo SaveFileDialog(string currentFile, string path, FilesystemFilterSet filterSet, IDialogParent parent)
|
||||
{
|
||||
Directory.CreateDirectory(path);
|
||||
|
@ -117,14 +111,17 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
|
||||
public FileInfo GetWatchFileFromUser(string currentFile)
|
||||
{
|
||||
return OpenFileDialog(currentFile, Config.PathEntries.WatchAbsolutePath(), "Watch Files", "wch");
|
||||
}
|
||||
=> OpenFileDialog(
|
||||
currentFile: currentFile,
|
||||
path: Config!.PathEntries.WatchAbsolutePath(),
|
||||
WatchFilesFSFilterSet);
|
||||
|
||||
public FileInfo GetWatchSaveFileFromUser(string currentFile)
|
||||
{
|
||||
return SaveFileDialog(currentFile, Config.PathEntries.WatchAbsolutePath(), "Watch Files", "wch", this);
|
||||
}
|
||||
=> SaveFileDialog(
|
||||
currentFile: currentFile,
|
||||
path: Config!.PathEntries.WatchAbsolutePath(),
|
||||
WatchFilesFSFilterSet,
|
||||
this);
|
||||
|
||||
public void ViewInHexEditor(MemoryDomain domain, IEnumerable<long> addresses, WatchSize size)
|
||||
{
|
||||
|
|
|
@ -13,6 +13,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public partial class TraceLogger : ToolFormBase, IToolFormAutoConfig
|
||||
{
|
||||
private static readonly FilesystemFilterSet LogFilesFSFilterSet = new(
|
||||
new FilesystemFilter("Log Files", new[] { "log" }),
|
||||
FilesystemFilter.TextFiles);
|
||||
|
||||
[RequiredService]
|
||||
private ITraceable Tracer { get; set; }
|
||||
|
||||
|
@ -298,10 +302,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
sfd.InitialDirectory = Config.PathEntries.LogAbsolutePath();
|
||||
}
|
||||
|
||||
sfd.Filter = new FilesystemFilterSet(
|
||||
new FilesystemFilter("Log Files", new[] { "log" }),
|
||||
FilesystemFilter.TextFiles
|
||||
).ToString();
|
||||
sfd.Filter = LogFilesFSFilterSet.ToString();
|
||||
sfd.RestoreDirectory = true;
|
||||
var result = this.ShowDialogWithTempMute(sfd);
|
||||
return result.IsOk() ? new FileInfo(sfd.FileName) : null;
|
||||
|
|
Loading…
Reference in New Issue