Linux: Made open/save dialogs case insensitive
This commit is contained in:
parent
d4ba601e0c
commit
b916332264
9 changed files with 61 additions and 23 deletions
|
@ -555,7 +555,7 @@ namespace Mesen.GUI.Debugger
|
|||
private void mnuLoadCdlFile_Click(object sender, EventArgs e)
|
||||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.Filter = "CDL files (*.cdl)|*.cdl";
|
||||
ofd.SetFilter("CDL files (*.cdl)|*.cdl");
|
||||
if(ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
|
||||
if(!InteropEmu.DebugLoadCdlFile(ofd.FileName)) {
|
||||
MessageBox.Show("Could not load CDL file. The file selected file is invalid.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
|
@ -566,7 +566,7 @@ namespace Mesen.GUI.Debugger
|
|||
private void mnuSaveAsCdlFile_Click(object sender, EventArgs e)
|
||||
{
|
||||
SaveFileDialog sfd = new SaveFileDialog();
|
||||
sfd.Filter = "CDL files (*.cdl)|*.cdl";
|
||||
sfd.SetFilter("CDL files (*.cdl)|*.cdl");
|
||||
sfd.AddExtension = true;
|
||||
if(sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
|
||||
if(!InteropEmu.DebugSaveCdlFile(sfd.FileName)) {
|
||||
|
@ -711,7 +711,7 @@ namespace Mesen.GUI.Debugger
|
|||
private void mnuImportLabels_Click(object sender, EventArgs e)
|
||||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.Filter = "All supported files (*.dbg)|*.dbg";
|
||||
ofd.SetFilter("All supported files (*.dbg)|*.dbg");
|
||||
if(ofd.ShowDialog() == DialogResult.OK) {
|
||||
Ld65DbgImporter dbgImporter = new Ld65DbgImporter();
|
||||
dbgImporter.Import(ofd.FileName);
|
||||
|
|
|
@ -150,7 +150,7 @@ namespace Mesen.GUI.Debugger
|
|||
private void mnuImport_Click(object sender, EventArgs e)
|
||||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.Filter = "Memory dump files (*.dmp)|*.dmp|All files (*.*)|*.*";
|
||||
ofd.SetFilter("Memory dump files (*.dmp)|*.dmp|All files (*.*)|*.*");
|
||||
ofd.InitialDirectory = ConfigManager.DebuggerFolder;
|
||||
if(ofd.ShowDialog() == DialogResult.OK) {
|
||||
InteropEmu.DebugSetMemoryState(_memoryType, File.ReadAllBytes(ofd.FileName));
|
||||
|
@ -161,7 +161,7 @@ namespace Mesen.GUI.Debugger
|
|||
private void mnuExport_Click(object sender, EventArgs e)
|
||||
{
|
||||
SaveFileDialog sfd = new SaveFileDialog();
|
||||
sfd.Filter = "Memory dump files (*.dmp)|*.dmp|All files (*.*)|*.*";
|
||||
sfd.SetFilter("Memory dump files (*.dmp)|*.dmp|All files (*.*)|*.*");
|
||||
sfd.InitialDirectory = ConfigManager.DebuggerFolder;
|
||||
sfd.FileName = InteropEmu.GetRomInfo().GetRomName() + " - " + cboMemoryType.SelectedItem.ToString() + ".dmp";
|
||||
if(sfd.ShowDialog() == DialogResult.OK) {
|
||||
|
|
|
@ -81,7 +81,7 @@ namespace Mesen.GUI.Forms.Cheats
|
|||
private void btnBrowse_Click(object sender, EventArgs e)
|
||||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.Filter = ResourceHelper.GetMessage("FilterRom");
|
||||
ofd.SetFilter(ResourceHelper.GetMessage("FilterRom"));
|
||||
if(ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
|
||||
LoadGame(ofd.FileName);
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace Mesen.GUI.Forms.Cheats
|
|||
private void btnBrowseGame_Click(object sender, EventArgs e)
|
||||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.Filter = ResourceHelper.GetMessage("FilterRom");
|
||||
ofd.SetFilter(ResourceHelper.GetMessage("FilterRom"));
|
||||
if(ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
|
||||
LoadGame(ofd.FileName);
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ namespace Mesen.GUI.Forms.Cheats
|
|||
private void btnBrowseCheat_Click(object sender, EventArgs e)
|
||||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.Filter = ResourceHelper.GetMessage("FilterCheat");
|
||||
ofd.SetFilter(ResourceHelper.GetMessage("FilterCheat"));
|
||||
if(ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
|
||||
_cheatFile = ofd.FileName;
|
||||
_isMesenCheatFile = NestopiaCheatLoader.IsMesenCheatFile(_cheatFile);
|
||||
|
|
|
@ -259,7 +259,7 @@ namespace Mesen.GUI.Forms.Cheats
|
|||
SaveFileDialog sfd = new SaveFileDialog();
|
||||
sfd.AddExtension = true;
|
||||
sfd.FileName = defaultFilename;
|
||||
sfd.Filter = "XML (*.xml)|*.xml";
|
||||
sfd.SetFilter("XML (*.xml)|*.xml");
|
||||
|
||||
if(sfd.ShowDialog() == DialogResult.OK) {
|
||||
MesenCheatExporter.Export(sfd.FileName, cheats);
|
||||
|
|
|
@ -128,7 +128,7 @@ namespace Mesen.GUI.Forms.Config
|
|||
private void btnLoadPalFile_Click(object sender, EventArgs e)
|
||||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.Filter = "Palette Files (*.pal)|*.pal|All Files (*.*)|*.*";
|
||||
ofd.SetFilter("Palette Files (*.pal)|*.pal|All Files (*.*)|*.*");
|
||||
if(ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
|
||||
using(FileStream paletteFile = File.OpenRead(ofd.FileName)) {
|
||||
byte[] paletteFileData = new byte[64*3];
|
||||
|
@ -419,7 +419,7 @@ namespace Mesen.GUI.Forms.Config
|
|||
private void btnExportPalette_Click(object sender, EventArgs e)
|
||||
{
|
||||
SaveFileDialog sfd = new SaveFileDialog();
|
||||
sfd.Filter = "Palette Files (*.pal)|*.pal";
|
||||
sfd.SetFilter("Palette Files (*.pal)|*.pal");
|
||||
if(sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
|
||||
List<byte>bytePalette = new List<byte>();
|
||||
foreach(int value in _paletteData) {
|
||||
|
|
37
GUI.NET/Forms/OpenSaveFileDialogExtensions.cs
Normal file
37
GUI.NET/Forms/OpenSaveFileDialogExtensions.cs
Normal file
|
@ -0,0 +1,37 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Mesen.GUI.Forms
|
||||
{
|
||||
public static class OpenFileDialogExtensions
|
||||
{
|
||||
private static string ToCaseInsensitiveFilter(string filter)
|
||||
{
|
||||
if(Program.IsMono) {
|
||||
string[] filterData = filter.Split('|');
|
||||
for(int i = 0; i < filterData.Length; i+=2) {
|
||||
List<string> fileTypes = new List<string>(filterData[i+1].Split(';'));
|
||||
for(int j = 0, len = fileTypes.Count; j < len; j++) {
|
||||
fileTypes[j] = fileTypes[j].ToUpper();
|
||||
fileTypes.Add(fileTypes[j].ToLower());
|
||||
}
|
||||
filterData[i+1] = string.Join(";", fileTypes.ToArray());
|
||||
}
|
||||
return string.Join("|", filterData);
|
||||
} else {
|
||||
return filter;
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetFilter(this OpenFileDialog ofd, string filter)
|
||||
{
|
||||
ofd.Filter = ToCaseInsensitiveFilter(filter);
|
||||
}
|
||||
|
||||
public static void SetFilter(this SaveFileDialog ofd, string filter)
|
||||
{
|
||||
ofd.Filter = ToCaseInsensitiveFilter(filter);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -437,7 +437,7 @@ namespace Mesen.GUI.Forms
|
|||
private void mnuOpen_Click(object sender, EventArgs e)
|
||||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.Filter = ResourceHelper.GetMessage("FilterRomIps");
|
||||
ofd.SetFilter(ResourceHelper.GetMessage("FilterRomIps"));
|
||||
if(ConfigManager.Config.RecentFiles.Count > 0) {
|
||||
ofd.InitialDirectory = Path.GetDirectoryName(ConfigManager.Config.RecentFiles[0].Path);
|
||||
}
|
||||
|
@ -464,7 +464,7 @@ namespace Mesen.GUI.Forms
|
|||
if(_emuThread == null) {
|
||||
if(MesenMsgBox.Show("SelectRomIps", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK) {
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.Filter = ResourceHelper.GetMessage("FilterRom");
|
||||
ofd.SetFilter(ResourceHelper.GetMessage("FilterRom"));
|
||||
if(ConfigManager.Config.RecentFiles.Count > 0) {
|
||||
ofd.InitialDirectory = Path.GetDirectoryName(ConfigManager.Config.RecentFiles[0].Path);
|
||||
}
|
||||
|
@ -895,7 +895,7 @@ namespace Mesen.GUI.Forms
|
|||
private void RecordMovie(bool resetEmu)
|
||||
{
|
||||
SaveFileDialog sfd = new SaveFileDialog();
|
||||
sfd.Filter = ResourceHelper.GetMessage("FilterMovie");
|
||||
sfd.SetFilter(ResourceHelper.GetMessage("FilterMovie"));
|
||||
sfd.InitialDirectory = ConfigManager.MovieFolder;
|
||||
sfd.FileName = InteropEmu.GetRomInfo().GetRomName() + ".mmo";
|
||||
if(sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
|
||||
|
@ -906,7 +906,7 @@ namespace Mesen.GUI.Forms
|
|||
private void mnuPlayMovie_Click(object sender, EventArgs e)
|
||||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.Filter = ResourceHelper.GetMessage("FilterMovie");
|
||||
ofd.SetFilter(ResourceHelper.GetMessage("FilterMovie"));
|
||||
ofd.InitialDirectory = ConfigManager.MovieFolder;
|
||||
if(ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
|
||||
InteropEmu.MoviePlay(ofd.FileName);
|
||||
|
@ -932,7 +932,7 @@ namespace Mesen.GUI.Forms
|
|||
private void mnuWaveRecord_Click(object sender, EventArgs e)
|
||||
{
|
||||
SaveFileDialog sfd = new SaveFileDialog();
|
||||
sfd.Filter = ResourceHelper.GetMessage("FilterWave");
|
||||
sfd.SetFilter(ResourceHelper.GetMessage("FilterWave"));
|
||||
sfd.InitialDirectory = ConfigManager.WaveFolder;
|
||||
sfd.FileName = InteropEmu.GetRomInfo().GetRomName() + ".wav";
|
||||
if(sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
|
||||
|
@ -948,7 +948,7 @@ namespace Mesen.GUI.Forms
|
|||
private void mnuTestRun_Click(object sender, EventArgs e)
|
||||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.Filter = ResourceHelper.GetMessage("FilterTest");
|
||||
ofd.SetFilter(ResourceHelper.GetMessage("FilterTest"));
|
||||
ofd.InitialDirectory = ConfigManager.TestFolder;
|
||||
ofd.Multiselect = true;
|
||||
if(ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
|
||||
|
@ -1008,7 +1008,7 @@ namespace Mesen.GUI.Forms
|
|||
private void RecordTest(bool resetEmu)
|
||||
{
|
||||
SaveFileDialog sfd = new SaveFileDialog();
|
||||
sfd.Filter = ResourceHelper.GetMessage("FilterTest");
|
||||
sfd.SetFilter(ResourceHelper.GetMessage("FilterTest"));
|
||||
sfd.InitialDirectory = ConfigManager.TestFolder;
|
||||
sfd.FileName = InteropEmu.GetRomInfo().GetRomName() + ".mtp";
|
||||
if(sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
|
||||
|
@ -1019,11 +1019,11 @@ namespace Mesen.GUI.Forms
|
|||
private void mnuTestRecordMovie_Click(object sender, EventArgs e)
|
||||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.Filter = ResourceHelper.GetMessage("FilterMovie");
|
||||
ofd.SetFilter(ResourceHelper.GetMessage("FilterMovie"));
|
||||
ofd.InitialDirectory = ConfigManager.MovieFolder;
|
||||
if(ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
|
||||
SaveFileDialog sfd = new SaveFileDialog();
|
||||
sfd.Filter = ResourceHelper.GetMessage("FilterTest");
|
||||
sfd.SetFilter(ResourceHelper.GetMessage("FilterTest"));
|
||||
sfd.InitialDirectory = ConfigManager.TestFolder;
|
||||
sfd.FileName = Path.GetFileNameWithoutExtension(ofd.FileName) + ".mtp";
|
||||
if(sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
|
||||
|
@ -1035,12 +1035,12 @@ namespace Mesen.GUI.Forms
|
|||
private void mnuTestRecordTest_Click(object sender, EventArgs e)
|
||||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.Filter = ResourceHelper.GetMessage("FilterTest");
|
||||
ofd.SetFilter(ResourceHelper.GetMessage("FilterTest"));
|
||||
ofd.InitialDirectory = ConfigManager.TestFolder;
|
||||
|
||||
if(ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
|
||||
SaveFileDialog sfd = new SaveFileDialog();
|
||||
sfd.Filter = ResourceHelper.GetMessage("FilterTest");
|
||||
sfd.SetFilter(ResourceHelper.GetMessage("FilterTest"));
|
||||
sfd.InitialDirectory = ConfigManager.TestFolder;
|
||||
sfd.FileName = Path.GetFileNameWithoutExtension(ofd.FileName) + ".mtp";
|
||||
if(sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
|
||||
|
@ -1326,7 +1326,7 @@ namespace Mesen.GUI.Forms
|
|||
{
|
||||
if(MesenMsgBox.Show("FdsBiosNotFound", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) {
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.Filter = ResourceHelper.GetMessage("FilterAll");
|
||||
ofd.SetFilter(ResourceHelper.GetMessage("FilterAll"));
|
||||
if(ofd.ShowDialog() == DialogResult.OK) {
|
||||
if(MD5Helper.GetMD5Hash(ofd.FileName).ToLowerInvariant() == "ca30b50f880eb660a320674ed365ef7a") {
|
||||
File.Copy(ofd.FileName, Path.Combine(ConfigManager.HomeFolder, "FdsBios.bin"));
|
||||
|
|
|
@ -598,6 +598,7 @@
|
|||
<Compile Include="Forms\NetPlay\frmServerConfig.Designer.cs">
|
||||
<DependentUpon>frmServerConfig.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\OpenSaveFileDialogExtensions.cs" />
|
||||
<Compile Include="Forms\ResourceHelper.cs" />
|
||||
<Compile Include="GoogleDriveIntegration\CloudSyncHelper.cs" />
|
||||
<Compile Include="GoogleDriveIntegration\GoogleDriveAccessor.cs" />
|
||||
|
|
Loading…
Add table
Reference in a new issue