lua: ability to SetBranchText.

doesn't make much sense to add text to existing branches from lua, but highly useful to set some text to a new branch.
and we also have a default branch text variable now.
This commit is contained in:
feos 2015-11-26 00:12:25 +03:00
parent 796a62f883
commit 2ce108e310
3 changed files with 19 additions and 1 deletions

View File

@ -85,6 +85,7 @@ namespace BizHawk.Client.Common
public TasMovieMarkerList Markers { get; set; } public TasMovieMarkerList Markers { get; set; }
public bool BindMarkersToInput { get; set; } public bool BindMarkersToInput { get; set; }
public bool UseInputCache { get; set; } public bool UseInputCache { get; set; }
public string NewBranchText = "";
public int CurrentBranch { get; set; } public int CurrentBranch { get; set; }
public int BranchCount { get { return Branches.Count; } } public int BranchCount { get { return Branches.Count; } }
public TasBranch GetBranch(int index) public TasBranch GetBranch(int index)

View File

@ -37,6 +37,22 @@ namespace BizHawk.Client.EmuHawk
return GlobalWin.Tools.Has<TAStudio>(); // TODO: eventually tastudio should have an engaged flag return GlobalWin.Tools.Has<TAStudio>(); // TODO: eventually tastudio should have an engaged flag
} }
[LuaMethodAttributes(
"setbranchtext",
"adds the given message to the existing branch, or to the branch that will be created next if branch index is not specified"
)]
public void SetBranchText(string text, int? index = null)
{
if (index != null)
{
Tastudio.CurrentTasMovie.GetBranch(index.Value).UserText = text;
}
else
{
Tastudio.CurrentTasMovie.NewBranchText = text;
}
}
[LuaMethodAttributes( [LuaMethodAttributes(
"getmarker", "getmarker",
"returns the marker text at the given frame, or an empty string if there is no marker for the given frame" "returns the marker text at the given frame, or an empty string if there is no marker for the given frame"

View File

@ -116,6 +116,7 @@ namespace BizHawk.Client.EmuHawk
public void Branch() public void Branch()
{ {
TasBranch branch = CreateBranch(); TasBranch branch = CreateBranch();
Movie.NewBranchText = ""; // reset every time it's used
Movie.AddBranch(branch); Movie.AddBranch(branch);
BranchView.RowCount = Movie.BranchCount; BranchView.RowCount = Movie.BranchCount;
Movie.CurrentBranch = Movie.BranchCount - 1; Movie.CurrentBranch = Movie.BranchCount - 1;
@ -149,7 +150,7 @@ namespace BizHawk.Client.EmuHawk
ChangeLog = new TasMovieChangeLog(Movie), ChangeLog = new TasMovieChangeLog(Movie),
TimeStamp = DateTime.Now, TimeStamp = DateTime.Now,
Markers = Movie.Markers.DeepClone(), Markers = Movie.Markers.DeepClone(),
UserText = "" UserText = Movie.NewBranchText
}; };
} }