frontend tracks loaded firmware: proof of concept

This commit is contained in:
goyuken 2015-02-05 23:25:28 +00:00
parent 7017168ee3
commit 995f670d36
4 changed files with 40 additions and 22 deletions

View File

@ -17,17 +17,6 @@ namespace BizHawk.Client.Common
_showWarning = showWarning;
}
public Stream OpenFirmware(string sysId, string key)
{
var fn = PathFirmware(sysId, key);
return new FileStream(fn, FileMode.Open, FileAccess.Read, FileShare.Read);
}
public string PathFirmware(string sysId, string key)
{
return FirmwareManager.Request(sysId, key);
}
public string PathSubfile(string fname)
{
return Path.Combine(Path.GetDirectoryName(SubfileDirectory) ?? String.Empty, fname);

View File

@ -30,6 +30,18 @@ namespace BizHawk.Client.Common
private readonly Dictionary<FirmwareDatabase.FirmwareRecord, ResolutionInfo> _resolutionDictionary = new Dictionary<FirmwareDatabase.FirmwareRecord, ResolutionInfo>();
public class FirmwareEventArgs
{
public string Hash { get; set; }
public long Size { get; set; }
public string SystemId { get; set; }
public string FirmwareId { get; set; }
}
public delegate void FirmwareEventHandler(object sender, FirmwareEventArgs e);
public event FirmwareEventHandler OnFirmwareRequestSatisfied;
public ResolutionInfo Resolve(string sysId, string firmwareId)
{
return Resolve(FirmwareDatabase.LookupFirmwareRecord(sysId, firmwareId));
@ -63,6 +75,17 @@ namespace BizHawk.Client.Common
{
var resolved = Resolve(sysId, firmwareId);
if (resolved == null) return null;
if (OnFirmwareRequestSatisfied != null)
{
OnFirmwareRequestSatisfied(this,
new FirmwareEventArgs
{
SystemId = sysId,
FirmwareId = firmwareId,
Hash = resolved.Hash,
Size = resolved.Size
});
}
return resolved.FilePath;
}

View File

@ -101,6 +101,7 @@ namespace BizHawk.Client.EmuHawk
Global.ControllerInputCoalescer = new ControllerInputCoalescer();
Global.FirmwareManager = new FirmwareManager();
Global.FirmwareManager.OnFirmwareRequestSatisfied += (o, e) => ActiveFirmwares[e.FirmwareId] = e.Hash;
Global.MovieSession = new MovieSession
{
Movie = MovieService.DefaultInstance,
@ -565,6 +566,8 @@ namespace BizHawk.Client.EmuHawk
public bool RestoreReadWriteOnStop = false;
public bool UpdateFrame = false;
public Dictionary<string, string> ActiveFirmwares = new Dictionary<string, string>();
private int? _pauseOnFrame;
public int? PauseOnFrame // If set, upon completion of this frame, the client wil pause
{
@ -3308,6 +3311,7 @@ namespace BizHawk.Client.EmuHawk
Deterministic = deterministic,
MessageCallback = GlobalWin.OSD.AddMessage
};
ActiveFirmwares.Clear();
loader.OnLoadError += ShowLoadError;
loader.OnLoadSettings += CoreSettings;
@ -3421,6 +3425,15 @@ namespace BizHawk.Client.EmuHawk
{
LoadQuickSave("QuickSave" + Global.Config.SaveSlot);
}
if (ActiveFirmwares.Count > 0)
{
Console.WriteLine("Active Firmwares:");
foreach (var kvp in ActiveFirmwares)
{
Console.WriteLine(" {0} : {1}", kvp.Key, kvp.Value);
}
}
return true;
}
else

View File

@ -1,22 +1,14 @@
using System.IO;
using System;
using System.IO;
namespace BizHawk.Emulation.Common
{
public interface ICoreFileProvider
{
/// <summary>
/// Opens a firmware according to the specified firmware ID key
/// </summary>
Stream OpenFirmware(string sysId, string key);
/// <summary>
/// Returns the path to a firmware according to the specified firmware ID key. Use OpenFirmware instead
/// </summary>
string PathFirmware(string sysId, string key);
/// <summary>
/// Produces a path to the requested file, expected to be parallel to the running rom. for example: cue+bin files or sfc+pcm (MSU-1 games)
/// </summary>
[Obsolete]
string PathSubfile(string fname);
/// <summary>
@ -35,6 +27,7 @@ namespace BizHawk.Emulation.Common
/// <param name="required">if true, result is guaranteed to be valid; else null is possible if not foun</param>
/// <param name="msg">message to show if fail to get</param>
/// <returns></returns>
[Obsolete]
string GetFirmwarePath(string sysID, string firmwareID, bool required, string msg = null);
/// <summary>