tastudio/lua - implement tastudio.onqueryitemtext
This commit is contained in:
parent
f847e905d2
commit
c53cef6cf9
|
@ -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;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
public Func<int, string, Color?> QueryItemBgColorCallback { get; set; }
|
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)
|
if (QueryItemBgColorCallback != null)
|
||||||
{
|
{
|
||||||
|
@ -109,6 +109,18 @@ namespace BizHawk.Client.EmuHawk
|
||||||
return null;
|
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
|
#endregion
|
||||||
|
|
||||||
private void TasView_QueryItemBkColor(int index, InputRoll.RollColumn column, ref Color color)
|
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)
|
private void TasView_QueryItemText(int index, InputRoll.RollColumn column, out string text)
|
||||||
{
|
{
|
||||||
|
var overrideText = GetTextOverride(index, column);
|
||||||
|
if (overrideText != null)
|
||||||
|
{
|
||||||
|
text = overrideText;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
text = string.Empty;
|
text = string.Empty;
|
||||||
|
|
Loading…
Reference in New Issue