2014-09-19 21:43:16 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
|
|
|
|
|
using BizHawk.Client.Common;
|
|
|
|
|
using LuaInterface;
|
|
|
|
|
|
|
|
|
|
namespace BizHawk.Client.EmuHawk
|
|
|
|
|
{
|
|
|
|
|
[Description("A library for manipulating the Tastudio dialog of the EmuHawk client")]
|
2014-11-19 16:17:40 +00:00
|
|
|
|
[LuaLibraryAttributes(released: true)]
|
2014-09-19 21:43:16 +00:00
|
|
|
|
public sealed class TastudioLuaLibrary : LuaLibraryBase
|
|
|
|
|
{
|
|
|
|
|
public TastudioLuaLibrary(Lua lua)
|
|
|
|
|
: base(lua) { }
|
|
|
|
|
|
|
|
|
|
public TastudioLuaLibrary(Lua lua, Action<string> logOutputCallback)
|
|
|
|
|
: base(lua, logOutputCallback) { }
|
|
|
|
|
|
|
|
|
|
public override string Name { get { return "tastudio"; } }
|
|
|
|
|
|
2014-09-21 15:17:29 +00:00
|
|
|
|
private TAStudio Tastudio
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return GlobalWin.Tools.Get<TAStudio>() as TAStudio;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-09-19 21:43:16 +00:00
|
|
|
|
[LuaMethodAttributes(
|
|
|
|
|
"engaged",
|
|
|
|
|
"returns whether or not tastudio is currently engaged (active)"
|
|
|
|
|
)]
|
|
|
|
|
public bool Engaged()
|
|
|
|
|
{
|
|
|
|
|
return GlobalWin.Tools.Has<TAStudio>(); // TODO: eventually tastudio should have an engaged flag
|
|
|
|
|
}
|
2014-09-21 15:17:29 +00:00
|
|
|
|
|
|
|
|
|
[LuaMethodAttributes(
|
|
|
|
|
"getmarker",
|
|
|
|
|
"returns the marker text at the given frame, or an empty string if there is no marker for the given frame"
|
|
|
|
|
)]
|
|
|
|
|
public string GetMarker(int frame)
|
|
|
|
|
{
|
|
|
|
|
if (Engaged())
|
|
|
|
|
{
|
2014-10-20 19:04:59 +00:00
|
|
|
|
var marker = Tastudio.CurrentTasMovie.Markers.Get(frame);
|
2014-09-21 15:17:29 +00:00
|
|
|
|
if (marker != null)
|
|
|
|
|
{
|
|
|
|
|
return marker.Message;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return string.Empty;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[LuaMethodAttributes(
|
|
|
|
|
"removemarker",
|
|
|
|
|
"if there is a marker for the given frame, it will be removed"
|
|
|
|
|
)]
|
|
|
|
|
public void RemoveMarker(int frame)
|
|
|
|
|
{
|
|
|
|
|
if (Engaged())
|
|
|
|
|
{
|
2014-10-20 19:04:59 +00:00
|
|
|
|
var marker = Tastudio.CurrentTasMovie.Markers.Get(frame);
|
2014-09-21 15:17:29 +00:00
|
|
|
|
if (marker != null)
|
|
|
|
|
{
|
2014-10-20 19:04:59 +00:00
|
|
|
|
Tastudio.CurrentTasMovie.Markers.Remove(marker);
|
2014-09-21 15:17:29 +00:00
|
|
|
|
Tastudio.UpdateValues();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[LuaMethodAttributes(
|
|
|
|
|
"setmarker",
|
|
|
|
|
"Adds or sets a marker at the given frame with the given message"
|
|
|
|
|
)]
|
|
|
|
|
public void SetMarker(int frame, string message)
|
|
|
|
|
{
|
|
|
|
|
if (Engaged())
|
|
|
|
|
{
|
2014-10-20 19:04:59 +00:00
|
|
|
|
var marker = Tastudio.CurrentTasMovie.Markers.Get(frame);
|
2014-09-21 15:17:29 +00:00
|
|
|
|
if (marker != null)
|
|
|
|
|
{
|
|
|
|
|
marker.Message = message;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-10-20 19:04:59 +00:00
|
|
|
|
Tastudio.CurrentTasMovie.Markers.Add(frame, message);
|
2014-09-21 15:17:29 +00:00
|
|
|
|
Tastudio.UpdateValues();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-09-22 21:58:45 +00:00
|
|
|
|
|
|
|
|
|
[LuaMethodAttributes(
|
|
|
|
|
"islag",
|
|
|
|
|
"Returns whether or not the given frame was a lag frame, null if unknown"
|
|
|
|
|
)]
|
|
|
|
|
public bool? IsLag(int frame)
|
|
|
|
|
{
|
|
|
|
|
if (Engaged())
|
|
|
|
|
{
|
2014-10-20 19:04:59 +00:00
|
|
|
|
if (frame < Tastudio.CurrentTasMovie.InputLogLength)
|
2014-09-22 21:58:45 +00:00
|
|
|
|
{
|
2014-10-20 19:04:59 +00:00
|
|
|
|
return Tastudio.CurrentTasMovie[frame].Lagged;
|
2014-09-22 21:58:45 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[LuaMethodAttributes(
|
|
|
|
|
"hasstate",
|
|
|
|
|
"Returns whether or not the given frame has a savestate associated with it"
|
|
|
|
|
)]
|
|
|
|
|
public bool HasState(int frame)
|
|
|
|
|
{
|
|
|
|
|
if (Engaged())
|
|
|
|
|
{
|
2014-10-20 19:04:59 +00:00
|
|
|
|
if (frame < Tastudio.CurrentTasMovie.InputLogLength)
|
2014-09-22 21:58:45 +00:00
|
|
|
|
{
|
2014-10-20 19:04:59 +00:00
|
|
|
|
return Tastudio.CurrentTasMovie[frame].HasState;
|
2014-09-22 21:58:45 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2015-07-01 23:01:29 +00:00
|
|
|
|
|
|
|
|
|
[LuaMethodAttributes(
|
|
|
|
|
"onqueryitembg",
|
|
|
|
|
"called during the background draw event of the tastudio listview"
|
|
|
|
|
)]
|
|
|
|
|
public void OnQueryItemBg(LuaFunction luaf)
|
|
|
|
|
{
|
|
|
|
|
if (Engaged())
|
|
|
|
|
{
|
|
|
|
|
Tastudio.QueryItemBgColorCallback = (int index, string name) =>
|
|
|
|
|
{
|
|
|
|
|
var result = luaf.Call(index, name);
|
|
|
|
|
|
|
|
|
|
if (result != null)
|
|
|
|
|
{
|
|
|
|
|
var color = ToColor(result[0]);
|
|
|
|
|
return color;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-09-19 21:43:16 +00:00
|
|
|
|
}
|
|
|
|
|
}
|