Refector xml game, it now has a List of keyvalue pairs instead of dictionary, and the schema is now LoadAssets with an array of Asset tags. MultiDiskBundler changes to account for this, also remove restriction of using current rom based on system type, isntead it will assume any system is ok

This commit is contained in:
adelikat 2015-05-10 18:58:00 +00:00
parent f6e9f79e71
commit ea72da9f89
4 changed files with 27 additions and 18 deletions

View File

@ -323,15 +323,20 @@ namespace BizHawk.Client.Common
switch (game.System)
{
case "GB":
case "DGB":
var left = Database.GetGameInfo(xmlGame.Assets["LeftRom"], "left.gb");
var right = Database.GetGameInfo(xmlGame.Assets["RightRom"], "right.gb");
// adelikat: remove need for tags to be hardcoded to left and right, we should clean this up, also maybe the DGB core should just take the xml file and handle it itself
var leftBytes = xmlGame.Assets.First().Value;
var rightBytes = xmlGame.Assets.Skip(1).First().Value;
var left = Database.GetGameInfo(leftBytes, "left.gb");
var right = Database.GetGameInfo(rightBytes, "right.gb");
nextEmulator = new GambatteLink(
nextComm,
left,
xmlGame.Assets["LeftRom"],
leftBytes,
right,
xmlGame.Assets["RightRom"],
rightBytes,
GetCoreSettings<GambatteLink>(),
GetCoreSyncSettings<GambatteLink>(),
Deterministic);

View File

@ -13,9 +13,15 @@ namespace BizHawk.Client.Common
{
public class XmlGame
{
public XmlGame()
{
Assets = new List<KeyValuePair<string, byte[]>>();
GI = new GameInfo();
}
public XmlDocument Xml { get; set; }
public GameInfo GI = new GameInfo();
public Dictionary<string, byte[]> Assets = new Dictionary<string, byte[]>();
public GameInfo GI { get; set; }
public IList<KeyValuePair<string, byte[]>> Assets { get; set; }
public static XmlGame Create(HawkFile f)
{
@ -48,7 +54,6 @@ namespace BizHawk.Client.Common
foreach (XmlNode a in n.ChildNodes)
{
string name = a.Name;
string filename = a.Attributes["FileName"].Value;
byte[] data;
if (filename[0] == '|')
@ -68,7 +73,7 @@ namespace BizHawk.Client.Common
}
else
{
throw new Exception("Couldn't load XMLGame LoadAsset \"" + name + "\"");
throw new Exception("Couldn't load XMLGame Asset \"" + filename + "\"");
}
}
else
@ -82,11 +87,11 @@ namespace BizHawk.Client.Common
}
catch
{
throw new Exception("Couldn't load XMLGame LoadAsset \"" + name + "\"");
throw new Exception("Couldn't load XMLGame LoadAsset \"" + filename + "\"");
}
}
ret.Assets[name] = data;
ret.Assets.Add(new KeyValuePair<string, byte[]>(filename, data));
using (var sha1 = System.Security.Cryptography.SHA1.Create())
{

View File

@ -27,7 +27,7 @@ namespace BizHawk.Client.EmuHawk
{
if (!Global.Game.IsNullInstance)
{
NameBox.Text = Path.ChangeExtension(PathManager.FilesystemSafeName(Global.Game), ".xml");
NameBox.Text = Path.ChangeExtension(GlobalWin.MainForm.CurrentlyOpenRom, ".xml");
}
AddButton_Click(null, null);
@ -92,6 +92,8 @@ namespace BizHawk.Client.EmuHawk
DialogResult = DialogResult.OK;
Close();
GlobalWin.MainForm.LoadRom(fileInfo.FullName);
}
}
@ -158,15 +160,13 @@ namespace BizHawk.Client.EmuHawk
string system = Global.Emulator.SystemId; // TODO: have the user pick this?
var tagNames = names.Select(n => Path.GetFileNameWithoutExtension(n));
_currentXml = new XElement("BizHawk-XMLGame",
new XAttribute("System", system),
new XAttribute("Name", Path.GetFileNameWithoutExtension(name)),
new XAttribute("Name", name),
new XElement("LoadAssets",
names.Select(n => new XElement(
ConvertToTag(Path.GetFileNameWithoutExtension(n)),
new XAttribute("FileName", n)
"Asset",
new XAttribute("FileName", n)
))
)
);

View File

@ -104,8 +104,7 @@ namespace BizHawk.Client.EmuHawk
{
UseCurrentRomButton.Enabled = Global.Emulator != null // For the designer
&& !string.IsNullOrEmpty(GlobalWin.MainForm.CurrentlyOpenRom)
&& !GlobalWin.MainForm.CurrentlyOpenRom.Contains('|') && // Can't be archive
!GlobalWin.MainForm.CurrentlyOpenRom.Contains(".xml"); // Can't already be an xml
&& !GlobalWin.MainForm.CurrentlyOpenRom.Contains(".xml"); // Can't already be an xml
}
private void PathBox_TextChanged(object sender, EventArgs e)