tastudio/lua - implement tastudio.onqueryitemtext

This commit is contained in:
adelikat 2015-07-01 19:46:14 -04:00
parent f847e905d2
commit c53cef6cf9
2 changed files with 45 additions and 1 deletions

View File

@ -148,5 +148,30 @@ namespace BizHawk.Client.EmuHawk
};
}
}
[LuaMethodAttributes(
"onqueryitemtext",
"called during the text draw event of the tastudio listview"
)]
public void OnQueryItemText(LuaFunction luaf)
{
if (Engaged())
{
Tastudio.QueryItemTextCallback = (int index, string name) =>
{
var result = luaf.Call(index, name);
if (result != null)
{
if (result[0] != null)
{
return result[0].ToString();
}
}
return (string)null;
};
}
}
}
}

View File

@ -99,7 +99,7 @@ namespace BizHawk.Client.EmuHawk
public Func<int, string, Color?> QueryItemBgColorCallback { get; set; }
public Color? GetColorOverride(int index, InputRoll.RollColumn column)
private Color? GetColorOverride(int index, InputRoll.RollColumn column)
{
if (QueryItemBgColorCallback != null)
{
@ -109,6 +109,18 @@ namespace BizHawk.Client.EmuHawk
return null;
}
public Func<int, string, string> QueryItemTextCallback { get; set; }
private string GetTextOverride(int index, InputRoll.RollColumn column)
{
if (QueryItemTextCallback != null)
{
return QueryItemTextCallback(index, column.Name);
}
return null;
}
#endregion
private void TasView_QueryItemBkColor(int index, InputRoll.RollColumn column, ref Color color)
@ -170,6 +182,13 @@ namespace BizHawk.Client.EmuHawk
private void TasView_QueryItemText(int index, InputRoll.RollColumn column, out string text)
{
var overrideText = GetTextOverride(index, column);
if (overrideText != null)
{
text = overrideText;
return;
}
try
{
text = string.Empty;