Lua - implement gui.drawText() - updates at the same time as other draw functions and is in emulator space instead of client space
This commit is contained in:
parent
2a845ebc3b
commit
619a36fb4c
|
@ -285,8 +285,8 @@ namespace BizHawk.MultiClient
|
||||||
{
|
{
|
||||||
public string FPS { get; set; }
|
public string FPS { get; set; }
|
||||||
public string MT { get; set; }
|
public string MT { get; set; }
|
||||||
IBlitterFont MessageFont;
|
public IBlitterFont MessageFont;
|
||||||
IBlitterFont AlertFont;
|
public IBlitterFont AlertFont;
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -362,6 +362,8 @@ namespace BizHawk.MultiClient
|
||||||
"drawIcon",
|
"drawIcon",
|
||||||
"drawImage",
|
"drawImage",
|
||||||
"addmessage",
|
"addmessage",
|
||||||
|
"drawText",
|
||||||
|
"drawString",
|
||||||
};
|
};
|
||||||
|
|
||||||
public static string[] EmuFunctions = new string[]
|
public static string[] EmuFunctions = new string[]
|
||||||
|
@ -792,6 +794,65 @@ namespace BizHawk.MultiClient
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void gui_drawString(object message, object X, object Y, object color = null, object fontsize = null, object fontfamily = null, object fontstyle = null)
|
||||||
|
{
|
||||||
|
gui_drawString(message, X, Y, color, fontsize, fontfamily, fontstyle);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void gui_drawText(object message, object X, object Y, object color = null, object fontsize = null, object fontfamily = null, object fontstyle = null)
|
||||||
|
{
|
||||||
|
using (var g = GetGraphics())
|
||||||
|
{
|
||||||
|
float x = LuaInt(X) + 0.1F;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int fsize = 12;
|
||||||
|
if (fontsize != null)
|
||||||
|
{
|
||||||
|
fsize = LuaInt(fontsize);
|
||||||
|
}
|
||||||
|
|
||||||
|
FontFamily family = FontFamily.GenericMonospace;
|
||||||
|
if (fontfamily != null)
|
||||||
|
{
|
||||||
|
family = new FontFamily(fontfamily.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
FontStyle fstyle = FontStyle.Regular;
|
||||||
|
if (fontstyle != null)
|
||||||
|
{
|
||||||
|
string tmp = fontstyle.ToString().ToLower();
|
||||||
|
switch (tmp)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case "regular":
|
||||||
|
break;
|
||||||
|
case "bold":
|
||||||
|
fstyle = FontStyle.Bold;
|
||||||
|
break;
|
||||||
|
case "italic":
|
||||||
|
fstyle = FontStyle.Italic;
|
||||||
|
break;
|
||||||
|
case "strikethrough":
|
||||||
|
fstyle = FontStyle.Strikeout;
|
||||||
|
break;
|
||||||
|
case "underline":
|
||||||
|
fstyle = FontStyle.Underline;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Font font = new System.Drawing.Font(family, fsize, fstyle, GraphicsUnit.Pixel);
|
||||||
|
g.DrawString(message.ToString(), font, GetBrush(color ?? "white"), LuaInt(X), LuaInt(Y));
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void gui_drawPixel(object X, object Y, object color = null)
|
public void gui_drawPixel(object X, object Y, object color = null)
|
||||||
{
|
{
|
||||||
using (var g = GetGraphics())
|
using (var g = GetGraphics())
|
||||||
|
|
Loading…
Reference in New Issue