Skip to content

Commit

Permalink
Allow drawing on LuaPictureBoxes on multiple windows (fixes #3778)
Browse files Browse the repository at this point in the history
fixes bb4ba21, though it wasn't working correctly before that either
this whole thing needs deduping
  • Loading branch information
YoshiRulz authored Oct 27, 2023
1 parent 14c00d0 commit 6725363
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/BizHawk.Client.EmuHawk/tools/Lua/Libraries/FormsLuaLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ public void Clear(long componentHandle, [LuaColorParam] object color)
return;
}
var match = form.Controls().FirstOrDefault(c => c.Handle == ptr);
if (match is null) return;
if (match is not LuaPictureBox control)
{
LogOutputCallback(ERR_MSG_CONTROL_NOT_LPB);
Expand Down Expand Up @@ -474,6 +475,7 @@ public void Refresh(long componentHandle)
return;
}
var match = form.Controls().FirstOrDefault(c => c.Handle == ptr);
if (match is null) return;
if (match is not LuaPictureBox control)
{
LogOutputCallback(ERR_MSG_CONTROL_NOT_LPB);
Expand Down Expand Up @@ -506,6 +508,7 @@ public void SetDefaultForegroundColor(long componentHandle, [LuaColorParam] obje
return;
}
var match = form.Controls().FirstOrDefault(c => c.Handle == ptr);
if (match is null) return;
if (match is not LuaPictureBox control)
{
LogOutputCallback(ERR_MSG_CONTROL_NOT_LPB);
Expand Down Expand Up @@ -538,6 +541,7 @@ public void SetDefaultBackgroundColor(long componentHandle, [LuaColorParam] obje
return;
}
var match = form.Controls().FirstOrDefault(c => c.Handle == ptr);
if (match is null) return;
if (match is not LuaPictureBox control)
{
LogOutputCallback(ERR_MSG_CONTROL_NOT_LPB);
Expand Down Expand Up @@ -570,6 +574,7 @@ public void SetDefaultTextBackground(long componentHandle, [LuaColorParam] objec
return;
}
var match = form.Controls().FirstOrDefault(c => c.Handle == ptr);
if (match is null) return;
if (match is not LuaPictureBox control)
{
LogOutputCallback(ERR_MSG_CONTROL_NOT_LPB);
Expand Down Expand Up @@ -602,6 +607,7 @@ public void DrawBezier(long componentHandle, LuaTable points, [LuaColorParam] ob
return;
}
var match = form.Controls().FirstOrDefault(c => c.Handle == ptr);
if (match is null) return;
if (match is not LuaPictureBox control)
{
LogOutputCallback(ERR_MSG_CONTROL_NOT_LPB);
Expand Down Expand Up @@ -642,6 +648,7 @@ public void DrawBox(
return;
}
var match = form.Controls().FirstOrDefault(c => c.Handle == ptr);
if (match is null) return;
if (match is not LuaPictureBox control)
{
LogOutputCallback(ERR_MSG_CONTROL_NOT_LPB);
Expand Down Expand Up @@ -682,6 +689,7 @@ public void DrawEllipse(
return;
}
var match = form.Controls().FirstOrDefault(c => c.Handle == ptr);
if (match is null) return;
if (match is not LuaPictureBox control)
{
LogOutputCallback(ERR_MSG_CONTROL_NOT_LPB);
Expand Down Expand Up @@ -724,6 +732,7 @@ public void DrawIcon(
return;
}
var match = form.Controls().FirstOrDefault(c => c.Handle == ptr);
if (match is null) return;
if (match is not LuaPictureBox control)
{
LogOutputCallback(ERR_MSG_CONTROL_NOT_LPB);
Expand Down Expand Up @@ -767,6 +776,7 @@ public void DrawImage(
return;
}
var match = form.Controls().FirstOrDefault(c => c.Handle == ptr);
if (match is null) return;
if (match is not LuaPictureBox control)
{
LogOutputCallback(ERR_MSG_CONTROL_NOT_LPB);
Expand Down Expand Up @@ -798,6 +808,7 @@ public void ClearImageCache(long componentHandle)
return;
}
var match = form.Controls().FirstOrDefault(c => c.Handle == ptr);
if (match is null) return;
if (match is not LuaPictureBox control)
{
LogOutputCallback(ERR_MSG_CONTROL_NOT_LPB);
Expand Down Expand Up @@ -844,6 +855,7 @@ public void DrawImageRegion(
return;
}
var match = form.Controls().FirstOrDefault(c => c.Handle == ptr);
if (match is null) return;
if (match is not LuaPictureBox control)
{
LogOutputCallback(ERR_MSG_CONTROL_NOT_LPB);
Expand Down Expand Up @@ -876,6 +888,7 @@ public void DrawLine(long componentHandle, int x1, int y1, int x2, int y2, [LuaC
return;
}
var match = form.Controls().FirstOrDefault(c => c.Handle == ptr);
if (match is null) return;
if (match is not LuaPictureBox control)
{
LogOutputCallback(ERR_MSG_CONTROL_NOT_LPB);
Expand Down Expand Up @@ -908,6 +921,7 @@ public void DrawAxis(long componentHandle, int x, int y, int size, [LuaColorPara
return;
}
var match = form.Controls().FirstOrDefault(c => c.Handle == ptr);
if (match is null) return;
if (match is not LuaPictureBox control)
{
LogOutputCallback(ERR_MSG_CONTROL_NOT_LPB);
Expand Down Expand Up @@ -949,6 +963,7 @@ public void DrawArc(
return;
}
var match = form.Controls().FirstOrDefault(c => c.Handle == ptr);
if (match is null) return;
if (match is not LuaPictureBox control)
{
LogOutputCallback(ERR_MSG_CONTROL_NOT_LPB);
Expand Down Expand Up @@ -991,6 +1006,7 @@ public void DrawPie(
return;
}
var match = form.Controls().FirstOrDefault(c => c.Handle == ptr);
if (match is null) return;
if (match is not LuaPictureBox control)
{
LogOutputCallback(ERR_MSG_CONTROL_NOT_LPB);
Expand Down Expand Up @@ -1023,6 +1039,7 @@ public void DrawPixel(long componentHandle, int x, int y, [LuaColorParam] object
return;
}
var match = form.Controls().FirstOrDefault(c => c.Handle == ptr);
if (match is null) return;
if (match is not LuaPictureBox control)
{
LogOutputCallback(ERR_MSG_CONTROL_NOT_LPB);
Expand Down Expand Up @@ -1062,6 +1079,7 @@ public void DrawPolygon(
return;
}
var match = form.Controls().FirstOrDefault(c => c.Handle == ptr);
if (match is null) return;
if (match is not LuaPictureBox control)
{
LogOutputCallback(ERR_MSG_CONTROL_NOT_LPB);
Expand Down Expand Up @@ -1103,6 +1121,7 @@ public void DrawRectangle(
return;
}
var match = form.Controls().FirstOrDefault(c => c.Handle == ptr);
if (match is null) return;
if (match is not LuaPictureBox control)
{
LogOutputCallback(ERR_MSG_CONTROL_NOT_LPB);
Expand Down Expand Up @@ -1147,6 +1166,7 @@ public void DrawString(
return;
}
var match = form.Controls().FirstOrDefault(c => c.Handle == ptr);
if (match is null) return;
if (match is not LuaPictureBox control)
{
LogOutputCallback(ERR_MSG_CONTROL_NOT_LPB);
Expand Down Expand Up @@ -1191,6 +1211,7 @@ public void DrawText(
return;
}
var match = form.Controls().FirstOrDefault(c => c.Handle == ptr);
if (match is null) return;
if (match is not LuaPictureBox control)
{
LogOutputCallback(ERR_MSG_CONTROL_NOT_LPB);
Expand Down Expand Up @@ -1223,6 +1244,7 @@ public int GetMouseX(long componentHandle)
return 0;
}
var match = form.Controls().FirstOrDefault(c => c.Handle == ptr);
if (match is null) return;
if (match is not LuaPictureBox control)
{
LogOutputCallback(ERR_MSG_CONTROL_NOT_LPB);
Expand Down Expand Up @@ -1256,6 +1278,7 @@ public int GetMouseY(long componentHandle)
return 0;
}
var match = form.Controls().FirstOrDefault(c => c.Handle == ptr);
if (match is null) return;
if (match is not LuaPictureBox control)
{
LogOutputCallback(ERR_MSG_CONTROL_NOT_LPB);
Expand Down

0 comments on commit 6725363

Please sign in to comment.