BK2 - auto convert input log to the system's log key on load, using the input log's key as reference to do so, don't use the file's input log key on the fly

This commit is contained in:
adelikat 2014-06-21 17:27:35 +00:00
parent e520b11552
commit 5e14df9f30
3 changed files with 29 additions and 4 deletions

View File

@ -12,6 +12,11 @@ namespace BizHawk.Client.Common
{
private string _logKey = string.Empty;
public Bk2ControllerAdapter()
{
}
public Bk2ControllerAdapter(string key)
{
_logKey = key;

View File

@ -77,7 +77,7 @@ namespace BizHawk.Client.Common
}
else if (line[0] == '|')
{
_log.Add(line);
_log.Add(ConvertLogEntryFromFile(line, _logKey));
}
}
}
@ -124,7 +124,7 @@ namespace BizHawk.Client.Common
}
else if (line.StartsWith("|"))
{
SetFrameAt(i, line);
SetFrameAt(i, ConvertLogEntryFromFile(line, _logKey));
i++;
}
}
@ -278,5 +278,22 @@ namespace BizHawk.Client.Common
return sb;
}
/// <summary>
/// Takes a log entry from a line in an input log,
/// If the log key differs from the system's, it will be coverted
/// </summary>
/// <param name="line">a log entry line of text from the input log</param>
/// /// <param name="logKey">a log entry line of text from the input log</param>
private string ConvertLogEntryFromFile(string line, string logKey)
{
var adapter = new Bk2LogEntryGenerator(logKey).MovieControllerAdapter;
adapter.Type = Global.MovieSession.MovieControllerAdapter.Type;
adapter.SetControllersAsMnemonic(line);
var lg = LogGeneratorInstance();
lg.SetSource(adapter);
return lg.GenerateLogEntry();
}
}
}

View File

@ -180,8 +180,11 @@ namespace BizHawk.Client.Common
getframe = frame;
}
var adapter = new Bk2ControllerAdapter(_logKey);
adapter.Type = Global.MovieSession.MovieControllerAdapter.Type;
var adapter = new Bk2ControllerAdapter
{
Type = Global.MovieSession.MovieControllerAdapter.Type
};
adapter.SetControllersAsMnemonic(_log[getframe]);
return adapter;
}