Tastudio/lua - implement tastudio.onqueryitemicon()
This commit is contained in:
parent
b0ea42f5a7
commit
9455aec767
|
@ -3,6 +3,7 @@ using System.ComponentModel;
|
|||
|
||||
using BizHawk.Client.Common;
|
||||
using LuaInterface;
|
||||
using System.Drawing;
|
||||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
|
@ -174,6 +175,31 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
public void OnQueryItemIcon(LuaFunction luaf)
|
||||
{
|
||||
if (Engaged())
|
||||
{
|
||||
Tastudio.QueryItemIconCallback = (int index, string name) =>
|
||||
{
|
||||
var result = luaf.Call(index, name);
|
||||
if (result != null)
|
||||
{
|
||||
if (result[0] != null)
|
||||
{
|
||||
string path = result[0].ToString();
|
||||
Icon icon = new Icon(path);
|
||||
if (icon != null)
|
||||
{
|
||||
return icon.ToBitmap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (Bitmap)null;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
[LuaMethodAttributes(
|
||||
"ongreenzoneinvalidated",
|
||||
"called whenever the greenzone is invalidated and returns the first frame that was invalidated"
|
||||
|
|
|
@ -9,6 +9,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public Func<int, string, Color?> QueryItemBgColorCallback { get; set; }
|
||||
public Func<int, string, string> QueryItemTextCallback { get; set; }
|
||||
public Func<int, string, Bitmap> QueryItemIconCallback { get; set; }
|
||||
|
||||
public Action<int> GreenzoneInvalidatedCallback { get; set; }
|
||||
|
||||
private Color? GetColorOverride(int index, InputRoll.RollColumn column)
|
||||
|
@ -31,6 +33,16 @@ namespace BizHawk.Client.EmuHawk
|
|||
return null;
|
||||
}
|
||||
|
||||
private Bitmap GetIconOverride(int index, InputRoll.RollColumn column)
|
||||
{
|
||||
if (QueryItemIconCallback != null)
|
||||
{
|
||||
return QueryItemIconCallback(index, column.Name);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void GreenzoneInvalidated(int index)
|
||||
{
|
||||
if (GreenzoneInvalidatedCallback != null)
|
||||
|
|
|
@ -70,6 +70,14 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void TasView_QueryItemIcon(int index, InputRoll.RollColumn column, ref Bitmap bitmap)
|
||||
{
|
||||
var overrideIcon = GetIconOverride(index, column);
|
||||
|
||||
if (overrideIcon != null)
|
||||
{
|
||||
bitmap = overrideIcon;
|
||||
return;
|
||||
}
|
||||
|
||||
var columnName = column.Name;
|
||||
|
||||
if (columnName == MarkerColumnName)
|
||||
|
|
Loading…
Reference in New Issue