Move prop GlobalWin.UserBag to global MovieSession

and weaken to IDict<K, V>
This commit is contained in:
YoshiRulz 2020-11-28 22:39:13 +10:00
parent 56df80bb5a
commit c203edba17
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
6 changed files with 13 additions and 12 deletions

View File

@ -46,6 +46,8 @@ namespace BizHawk.Client.Common
public bool NewMovieQueued => _queuedMovie != null;
public string QueuedSyncSettings => _queuedMovie.SyncSettingsJson;
public IDictionary<string, object> UserBag { get; set; } = new Dictionary<string, object>();
public IInputAdapter MovieIn { private get; set; }
public IInputAdapter MovieOut { get; } = new CopyControllerAdapter();
public IStickyAdapter StickySource { get; set; }

View File

@ -20,6 +20,8 @@ namespace BizHawk.Client.Common
/// </summary>
string QueuedSyncSettings { get; }
IDictionary<string, object> UserBag { get; set; }
IMovieController MovieController { get; }
/// <summary>

View File

@ -17,9 +17,9 @@ namespace BizHawk.Client.Common
private readonly IStatable _statable;
private readonly IVideoProvider _videoProvider;
private readonly IMovieSession _movieSession;
private readonly Dictionary<string, object> _userBag;
private readonly IDictionary<string, object> _userBag;
public SavestateFile(IEmulator emulator, IMovieSession movieSession, Dictionary<string, object> userBag)
public SavestateFile(IEmulator emulator, IMovieSession movieSession, IDictionary<string, object> userBag)
{
if (!emulator.HasSavestates())
{

View File

@ -13,15 +13,15 @@ namespace BizHawk.Client.EmuHawk
var t = value.GetType();
if (!t.IsPrimitive && t != typeof(string)) throw new InvalidOperationException("Invalid type for userdata");
}
GlobalWin.UserBag[name] = value;
GlobalWin.MovieSession.UserBag[name] = value;
}
public object Get(string key) => GlobalWin.UserBag.TryGetValue(key, out var value) ? value : null;
public object Get(string key) => GlobalWin.MovieSession.UserBag.TryGetValue(key, out var value) ? value : null;
public void Clear() => GlobalWin.UserBag.Clear();
public void Clear() => GlobalWin.MovieSession.UserBag.Clear();
public bool Remove(string key) => GlobalWin.UserBag.Remove(key);
public bool Remove(string key) => GlobalWin.MovieSession.UserBag.Remove(key);
public bool ContainsKey(string key) => GlobalWin.UserBag.ContainsKey(key);
public bool ContainsKey(string key) => GlobalWin.MovieSession.UserBag.ContainsKey(key);
}
}

View File

@ -1,7 +1,6 @@
using BizHawk.Bizware.BizwareGL;
using BizHawk.Client.Common;
using BizHawk.Emulation.Common;
using System.Collections.Generic;
// ReSharper disable StyleCop.SA1401
namespace BizHawk.Client.EmuHawk
@ -22,8 +21,6 @@ namespace BizHawk.Client.EmuHawk
public static Sound Sound;
public static Dictionary<string, object> UserBag { get; set; } = new Dictionary<string, object>();
public static Config Config { get; set; }
public static GameInfo Game { get; set; }
public static IMovieSession MovieSession { get; set; }

View File

@ -4012,7 +4012,7 @@ namespace BizHawk.Client.EmuHawk
return;
}
if (new SavestateFile(Emulator, MovieSession, GlobalWin.UserBag).Load(path))
if (new SavestateFile(Emulator, MovieSession, MovieSession.UserBag).Load(path))
{
OSD.ClearGuiText();
EmuClient.OnStateLoaded(this, userFriendlyStateName);
@ -4091,7 +4091,7 @@ namespace BizHawk.Client.EmuHawk
try
{
new SavestateFile(Emulator, MovieSession, GlobalWin.UserBag).Create(path, Config.Savestates);
new SavestateFile(Emulator, MovieSession, MovieSession.UserBag).Create(path, Config.Savestates);
EmuClient.OnStateSaved(this, userFriendlyStateName);