misc cleanups

This commit is contained in:
adelikat 2019-11-15 15:15:13 -06:00
parent c4658c3e85
commit ab9c7699ec
9 changed files with 37 additions and 54 deletions

View File

@ -40,7 +40,7 @@ namespace BizHawk.Client.Common
},
Xml = x
};
string fullpath = "";
string fullPath = "";
var n = y.SelectSingleNode("./LoadAssets");
if (n != null)
@ -75,25 +75,23 @@ namespace BizHawk.Client.Common
else
{
// relative path
fullpath = Path.GetDirectoryName(f.CanonicalFullPath.Split('|').First()) ?? "";
fullpath = Path.Combine(fullpath, filename.Split('|').First());
fullPath = Path.GetDirectoryName(f.CanonicalFullPath.Split('|').First()) ?? "";
fullPath = Path.Combine(fullPath, filename.Split('|').First());
try
{
using (var hf = new HawkFile(fullpath))
using var hf = new HawkFile(fullPath);
if (hf.IsArchive)
{
if (hf.IsArchive)
{
var archiveItem = hf.ArchiveItems.First(ai => ai.Name == filename.Split('|').Skip(1).First());
hf.Unbind();
hf.BindArchiveMember(archiveItem);
data = hf.GetStream().ReadAllBytes();
var archiveItem = hf.ArchiveItems.First(ai => ai.Name == filename.Split('|').Skip(1).First());
hf.Unbind();
hf.BindArchiveMember(archiveItem);
data = hf.GetStream().ReadAllBytes();
filename = filename.Split('|').Skip(1).First();
}
else
{
data = File.ReadAllBytes(fullpath.Split('|').First());
}
filename = filename.Split('|').Skip(1).First();
}
else
{
data = File.ReadAllBytes(fullPath.Split('|').First());
}
}
catch
@ -103,12 +101,10 @@ namespace BizHawk.Client.Common
}
ret.Assets.Add(new KeyValuePair<string, byte[]>(filename, data));
ret.AssetFullPaths.Add(fullpath);
using (var sha1 = System.Security.Cryptography.SHA1.Create())
{
sha1.TransformFinalBlock(data, 0, data.Length);
hashStream.Write(sha1.Hash, 0, sha1.Hash.Length);
}
ret.AssetFullPaths.Add(fullPath);
using var sha1 = System.Security.Cryptography.SHA1.Create();
sha1.TransformFinalBlock(data, 0, data.Length);
hashStream.Write(sha1.Hash, 0, sha1.Hash.Length);
}
ret.GI.Hash = hashStream.GetBuffer().HashSHA1(0, (int)hashStream.Length);

View File

@ -13,7 +13,6 @@ namespace BizHawk.Client.Common
public const string STARTSFROMSAVESTATE = "StartsFromSavestate";
public const string STARTSFROMSAVERAM = "StartsFromSaveRam";
public const string SAVESTATEBINARYBASE64BLOB = "SavestateBinaryBase64Blob"; // this string will not contain base64: ; it's implicit (this is to avoid another big string op to dice off the base64: substring)
public const string FOURSCORE = "FourScore";
public const string SHA1 = "SHA1";
public const string FIRMWARESHA1 = "FirmwareSHA1";
public const string PAL = "PAL";
@ -24,9 +23,6 @@ namespace BizHawk.Client.Common
// Core Setting
public const string CORE = "Core";
// Plugin Settings
public const string VIDEOPLUGIN = "VideoPlugin";
public static bool Contains(string val)
{
return typeof(HeaderKeys)

View File

@ -324,10 +324,8 @@ namespace BizHawk.Client.Common
public bool HandleMovieLoadState(string path)
{
using (var sr = new StreamReader(path))
{
return HandleMovieLoadState(sr);
}
using var sr = new StreamReader(path);
return HandleMovieLoadState(sr);
}
// TODO: maybe someone who understands more about what's going on here could rename these step1 and step2 into something more descriptive

View File

@ -5,8 +5,8 @@ namespace BizHawk.Client.Common
{
public class PlatformFrameRates
{
// these are political numbers, designed to be in accord with tasvideos.org tradition. theyre not necessarily mathematical factualities (although they may be in some cases)
// it would be nice if we could turn this into a rational expression natively, and also, to write some comments about the derivation and ideal values (since this seems to be where theyre all collected)
// these are political numbers, designed to be in accord with tasvideos.org tradition. they're not necessarily mathematical factualities (although they may be in some cases)
// it would be nice if we could turn this into a rational expression natively, and also, to write some comments about the derivation and ideal values (since this seems to be where they're all collected)
// are we collecting them anywhere else? for avi-writing code perhaps?
// just some constants, according to specs
@ -66,7 +66,7 @@ namespace BizHawk.Client.Common
// according to ryphecha, using
// clocks[2] = { 53.693182e06, 53.203425e06 }; //ntsc console, pal console
// lpf[2][2] = { { 263, 262.5 }, { 314, 312.5 } }; //ntsc,pal; noninterlaced, interlaced
// lpf[2][2] = { { 263, 262.5 }, { 314, 312.5 } }; //ntsc,pal; non-interlaced, interlaced
// cpl[2] = { 3412.5, 3405 }; //ntsc mode, pal mode
// PAL PS1: 0, PAL Mode: 0, Interlaced: 0 --- 59.826106 (53.693182e06/(263*3412.5))
// PAL PS1: 0, PAL Mode: 0, Interlaced: 1 --- 59.940060 (53.693182e06/(262.5*3412.5))
@ -90,22 +90,22 @@ namespace BizHawk.Client.Common
public TimeSpan MovieTime(IMovie movie)
{
var dblseconds = GetSeconds(movie);
var seconds = (int)(dblseconds % 60);
var dblSeconds = GetSeconds(movie);
var seconds = (int)(dblSeconds % 60);
var days = seconds / 86400;
var hours = seconds / 3600;
var minutes = (seconds / 60) % 60;
var milliseconds = (int)((dblseconds - seconds) * 1000);
var milliseconds = (int)((dblSeconds - seconds) * 1000);
return new TimeSpan(days, hours, minutes, seconds, milliseconds);
}
private double Fps(IMovie movie)
{
var system = movie.HeaderEntries[HeaderKeys.PLATFORM];
var pal = movie.HeaderEntries.ContainsKey(HeaderKeys.PAL) &&
movie.HeaderEntries[HeaderKeys.PAL] == "1";
var pal = movie.HeaderEntries.ContainsKey(HeaderKeys.PAL)
&& movie.HeaderEntries[HeaderKeys.PAL] == "1";
return this[system, pal];
return this[system, pal];
}
private double GetSeconds(IMovie movie)

View File

@ -90,7 +90,7 @@ namespace BizHawk.Client.Common
sb.Append("\r\n");
// Seperator
// Separator
sb.Append("\r\n");
return sb.ToString();

View File

@ -416,7 +416,6 @@ namespace BizHawk.Client.Common
public void Undo(TasMovie movie)
{
bool wasRecording = movie.ChangeLog.IsRecording;
bool wasBinding = movie.BindMarkersToInput;
movie.ChangeLog.IsRecording = false;
movie.BindMarkersToInput = _bindMarkers;
@ -442,7 +441,6 @@ namespace BizHawk.Client.Common
public void Redo(TasMovie movie)
{
bool wasRecording = movie.ChangeLog.IsRecording;
bool wasBinding = movie.BindMarkersToInput;
movie.ChangeLog.IsRecording = false;
movie.BindMarkersToInput = _bindMarkers;

View File

@ -28,9 +28,9 @@ namespace BizHawk.Client.Common
Message = split[1];
}
public virtual int Frame { get; }
public int Frame { get; }
public virtual string Message { get; set; }
public string Message { get; set; }
public override string ToString()
{

View File

@ -57,15 +57,9 @@ namespace BizHawk.Client.Common
#region API
public IEnumerable<long> OutOfRangeAddress
{
get
{
return _watchList
.Where(watch => watch.Address >= Domain.Size)
.Select(watch => watch.Address);
}
}
public IEnumerable<long> OutOfRangeAddress => _watchList
.Where(watch => watch.Address >= Domain.Size)
.Select(watch => watch.Address);
public void Start()
{
@ -154,7 +148,7 @@ namespace BizHawk.Client.Common
"",
0,
_watchList[index].Previous,
(_watchList[index] as IMiniWatchDetails).ChangeCount);
((IMiniWatchDetails)_watchList[index]).ChangeCount);
}
return Watch.GenerateWatch(

View File

@ -291,6 +291,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=taseditor/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=tasproj/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Tastudio/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=tasvideos/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=tempfile/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=tkey/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=toolform/@EntryIndexedValue">True</s:Boolean>