parent
542e043261
commit
aeb80e5810
|
@ -111,6 +111,7 @@
|
||||||
//
|
//
|
||||||
// FileSelectorPanel
|
// FileSelectorPanel
|
||||||
//
|
//
|
||||||
|
this.FileSelectorPanel.AllowDrop = true;
|
||||||
this.FileSelectorPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
this.FileSelectorPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||||
| System.Windows.Forms.AnchorStyles.Left)
|
| System.Windows.Forms.AnchorStyles.Left)
|
||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
@ -120,6 +121,8 @@
|
||||||
this.FileSelectorPanel.Name = "FileSelectorPanel";
|
this.FileSelectorPanel.Name = "FileSelectorPanel";
|
||||||
this.FileSelectorPanel.Size = new System.Drawing.Size(486, 214);
|
this.FileSelectorPanel.Size = new System.Drawing.Size(486, 214);
|
||||||
this.FileSelectorPanel.TabIndex = 12;
|
this.FileSelectorPanel.TabIndex = 12;
|
||||||
|
this.FileSelectorPanel.DragDrop += new System.Windows.Forms.DragEventHandler(this.OnDragDrop);
|
||||||
|
this.FileSelectorPanel.DragEnter += new System.Windows.Forms.DragEventHandler(this.OnDragEnter);
|
||||||
//
|
//
|
||||||
// AddButton
|
// AddButton
|
||||||
//
|
//
|
||||||
|
|
|
@ -33,8 +33,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
Icon = ToolIcon;
|
Icon = ToolIcon;
|
||||||
SystemDropDown.Items.AddRange(new[]
|
SystemDropDown.Items.AddRange([
|
||||||
{
|
|
||||||
VSystemID.Raw.Amiga,
|
VSystemID.Raw.Amiga,
|
||||||
VSystemID.Raw.AmstradCPC,
|
VSystemID.Raw.AmstradCPC,
|
||||||
VSystemID.Raw.AppleII,
|
VSystemID.Raw.AppleII,
|
||||||
|
@ -51,7 +50,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
VSystemID.Raw.SAT,
|
VSystemID.Raw.SAT,
|
||||||
VSystemID.Raw.TI83,
|
VSystemID.Raw.TI83,
|
||||||
VSystemID.Raw.ZXSpectrum,
|
VSystemID.Raw.ZXSpectrum,
|
||||||
});
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Restart()
|
public override void Restart()
|
||||||
|
@ -101,20 +100,29 @@ namespace BizHawk.Client.EmuHawk
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var xmlGame = XmlGame.Create(new HawkFile(xmlPath));
|
var xmlGame = XmlGame.Create(new HawkFile(xmlPath));
|
||||||
for (int i = FileSelectorPanel.Controls.Count; i < xmlGame.AssetFullPaths.Count; i++)
|
AddFiles(xmlGame.AssetFullPaths);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// something went wrong while parsing the given xml path... just don't populate anything then
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddFiles(IList<string> filePaths)
|
||||||
|
{
|
||||||
|
var existingEmptyControls = FileSelectors.Count(fileSelector => string.IsNullOrEmpty(fileSelector.Path));
|
||||||
|
for (int i = existingEmptyControls; i < filePaths.Count; i++)
|
||||||
{
|
{
|
||||||
AddButton_Click(null, null);
|
AddButton_Click(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
var fileSelectors = FileSelectors.ToArray();
|
var fileSelectors = FileSelectors.ToArray();
|
||||||
for (int i = 0; i < xmlGame.AssetFullPaths.Count; i++)
|
int currentFileSelector = 0;
|
||||||
|
foreach (string filePath in filePaths)
|
||||||
{
|
{
|
||||||
fileSelectors[i].Path = xmlGame.AssetFullPaths[i];
|
while (currentFileSelector < fileSelectors.Length && !string.IsNullOrEmpty(fileSelectors[currentFileSelector].Path))
|
||||||
}
|
currentFileSelector++;
|
||||||
}
|
fileSelectors[currentFileSelector].Path = filePath;
|
||||||
catch
|
|
||||||
{
|
|
||||||
// something went wrong while parsing the given xml path... just don't populate anything then
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,5 +319,26 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
Recalculate();
|
Recalculate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnDragDrop(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
string[] droppedFiles = (string[])e.Data.GetData(DataFormats.FileDrop);
|
||||||
|
if (droppedFiles is null) return;
|
||||||
|
|
||||||
|
string xmlPath = droppedFiles.FirstOrDefault(path => path.EndsWith(".xml", StringComparison.OrdinalIgnoreCase));
|
||||||
|
if (xmlPath is not null)
|
||||||
|
{
|
||||||
|
PopulateFromXmlFile(xmlPath);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddFiles(droppedFiles);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDragEnter(object sender, DragEventArgs e)
|
||||||
|
{
|
||||||
|
e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop) ? DragDropEffects.Copy : DragDropEffects.None;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue