Added included snapshot and tzx option with roms
This commit is contained in:
@@ -344,6 +344,22 @@ namespace Desktop
|
||||
item.Click += IncludedTapMenuItem_Click;
|
||||
tAPToolStripMenuItem1.DropDownItems.Add(item);
|
||||
}
|
||||
if (resourceName.Contains("Desktop.ROMS.Snapshot.") && resourceName.EndsWith(".sna", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
string[] parts = resourceName.Split('.');
|
||||
string displayName = parts[parts.Length - 2];
|
||||
ToolStripMenuItem item = new ToolStripMenuItem(displayName) { Tag = resourceName };
|
||||
item.Click += IncludedTapMenuItem_Click;
|
||||
SNAPToolStripMenuItem1.DropDownItems.Add(item);
|
||||
}
|
||||
if (resourceName.Contains("Desktop.ROMS.TZX.") && resourceName.EndsWith(".tzx", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
string[] parts = resourceName.Split('.');
|
||||
string displayName = parts[parts.Length - 2];
|
||||
ToolStripMenuItem item = new ToolStripMenuItem(displayName) { Tag = resourceName };
|
||||
item.Click += IncludedTapMenuItem_Click;
|
||||
TZXToolStripMenuItem1.DropDownItems.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -355,19 +371,33 @@ namespace Desktop
|
||||
try
|
||||
{
|
||||
Assembly assembly = Assembly.GetExecutingAssembly();
|
||||
|
||||
// Open the embedded resource stream once
|
||||
using (Stream? stream = assembly.GetManifestResourceStream(resourceName))
|
||||
{
|
||||
if (stream == null) throw new Exception("Could not find embedded resource.");
|
||||
if (stream == null) throw new Exception($"Could not find embedded resource: {resourceName}");
|
||||
|
||||
// Copy the stream into a memory stream to extract the raw byte array
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
{
|
||||
stream.CopyTo(ms);
|
||||
_machine.TapeDeck.LoadTapData(ms.ToArray());
|
||||
byte[] fileBytes = ms.ToArray();
|
||||
|
||||
// Route the byte array to the correct emulator component
|
||||
if (resourceName.EndsWith(".tap", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
_machine.TapeDeck.LoadTapData(fileBytes);
|
||||
}
|
||||
else if (resourceName.EndsWith(".sna", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
_machine.LoadSnapshot(fileBytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"Failed to load built-in TAP:\n{ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
MessageBox.Show($"Failed to load built-in resource:\n{ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user