MultiDiskBundler: Address request in ticket #764 (#1275)

This commit is contained in:
Asnivor 2018-08-16 15:58:48 +01:00 committed by feos
parent a471206d6a
commit c4167555ae
3 changed files with 63 additions and 10 deletions

View File

@ -82,11 +82,13 @@ namespace BizHawk.Client.Common
using (var hf = new HawkFile(fullpath))
{
if (hf.IsArchive)
{
var archiveItem = hf.ArchiveItems.First(ai => ai.Name == filename.Split('|').Skip(1).First());
{
var archiveItem = hf.ArchiveItems.First(ai => ai.Name == filename.Split('|').Skip(1).First());
hf.Unbind();
hf.BindArchiveMember(archiveItem);
data = hf.GetStream().ReadAllBytes();
filename = filename.Split('|').Skip(1).First();
}
else
{

View File

@ -114,7 +114,8 @@ namespace BizHawk.Client.EmuHawk
DialogResult = DialogResult.OK;
Close();
GlobalWin.MainForm.LoadRom(fileInfo.FullName, new MainForm.LoadRomArgs() { OpenAdvanced = new OpenAdvanced_OpenRom() });
var lra = new MainForm.LoadRomArgs { OpenAdvanced = new OpenAdvanced_OpenRom { Path = fileInfo.FullName } };
GlobalWin.MainForm.LoadRom(fileInfo.FullName, lra);
}
}
@ -130,16 +131,18 @@ namespace BizHawk.Client.EmuHawk
Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top
};
var mdf = new MultiDiskFileSelector
{
Location = UIHelper.Scale(new Point(7, 12)),
Width = groupBox.ClientSize.Width - UIHelper.ScaleX(13),
Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top
var mdf = new MultiDiskFileSelector
{
Location = UIHelper.Scale(new Point(7, 12)),
Width = groupBox.ClientSize.Width - UIHelper.ScaleX(13),
Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top
};
mdf.NameChanged += FileSelector_NameChanged;
mdf.SystemString = SystemDropDown.SelectedText;
groupBox.Controls.Add(mdf);
groupBox.Controls.Add(mdf);
FileSelectorPanel.Controls.Add(groupBox);
}

View File

@ -3,11 +3,14 @@ using System.Windows.Forms;
using BizHawk.Client.Common;
using BizHawk.Client.EmuHawk.WinFormExtensions;
using System.IO;
namespace BizHawk.Client.EmuHawk
{
public partial class MultiDiskFileSelector : UserControl
{
public string SystemString = "";
public string GetName()
{
return PathBox.Text;
@ -74,11 +77,56 @@ namespace BizHawk.Client.EmuHawk
RestoreDirectory = true
})
{
string _path = "";
var result = ofd.ShowHawkDialog();
if (result == DialogResult.OK)
{
PathBox.Text = ofd.FileName;
_path = ofd.FileName;
}
else
{
return;
}
try
{
var file = new FileInfo(ofd.FileName);
var path = BizHawk.Common.HawkFile.Util_ResolveLink(file.FullName);
using (var hf = new BizHawk.Common.HawkFile(path))
{
if (hf.IsArchive)
{
// archive - run the archive chooser
if (SystemString == "PSX" || SystemString == "PCFX" || SystemString == "SAT")
{
MessageBox.Show("Using archives with PSX, PCFX or SATURN is not currently recommended/supported.");
return;
}
var ac = new ArchiveChooser(new BizHawk.Common.HawkFile(_path));
int memIdx = -1;
if (ac.ShowDialog(this) == DialogResult.OK)
{
memIdx = ac.SelectedMemberIndex;
}
var intName = hf.ArchiveItems[memIdx];
PathBox.Text = _path + "|" + intName.Name;
}
else
{
// file is not an archive
PathBox.Text = _path;
}
}
}
catch
{
return;
}
}
}