mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Merge branch 'expose-clip-rect' into 'master'
Expose clip rect functions to lua See merge request KartKrew/RingRacers!39
This commit is contained in:
commit
6efa0d6d0f
4 changed files with 91 additions and 3 deletions
|
|
@ -688,11 +688,11 @@ void LUA_HookHUD(huddrawlist_h list, int hook_type)
|
|||
|
||||
hud_running = true; // local hook
|
||||
|
||||
// Catch runaway clipping rectangles.
|
||||
V_ClearClipRect();
|
||||
|
||||
init_hook_call(&hook, 0, res_none);
|
||||
call_mapped(&hook, &hudHookIds[hook_type]);
|
||||
|
||||
// Catch runaway clipping rectangles.
|
||||
V_ClearClipRect();
|
||||
|
||||
hud_running = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -893,6 +893,45 @@ static int libd_drawKartString(lua_State *L)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int libd_setClipRect(lua_State *L)
|
||||
{
|
||||
fixed_t x = luaL_checkinteger(L, 1);
|
||||
fixed_t y = luaL_checkinteger(L, 2);
|
||||
fixed_t w = luaL_checkinteger(L, 3);
|
||||
fixed_t h = luaL_checkinteger(L, 4);
|
||||
INT32 flags = luaL_optinteger(L, 5, 0);
|
||||
huddrawlist_h list;
|
||||
|
||||
flags &= ~V_PARAMMASK; // Don't let crashes happen.
|
||||
|
||||
HUDONLY
|
||||
lua_getfield(L, LUA_REGISTRYINDEX, "HUD_DRAW_LIST");
|
||||
list = (huddrawlist_h) lua_touserdata(L, -1);
|
||||
lua_pop(L, 1);
|
||||
|
||||
if (LUA_HUD_IsDrawListValid(list))
|
||||
LUA_HUD_AddSetClipRect(list, x, y, w, h, flags);
|
||||
else
|
||||
V_SetClipRect(x, y, w, h, flags);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int libd_clearClipRect(lua_State *L)
|
||||
{
|
||||
huddrawlist_h list;
|
||||
|
||||
HUDONLY
|
||||
lua_getfield(L, LUA_REGISTRYINDEX, "HUD_DRAW_LIST");
|
||||
list = (huddrawlist_h) lua_touserdata(L, -1);
|
||||
lua_pop(L, 1);
|
||||
|
||||
if (LUA_HUD_IsDrawListValid(list))
|
||||
LUA_HUD_AddClearClipRect(list);
|
||||
else
|
||||
V_ClearClipRect();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int libd_titleCardStringWidth(lua_State *L)
|
||||
{
|
||||
const char *str = luaL_checkstring(L, 1);
|
||||
|
|
@ -1111,6 +1150,8 @@ static luaL_Reg lib_draw[] = {
|
|||
{"drawString", libd_drawString},
|
||||
{"drawTitleCardString", libd_drawTitleCardString},
|
||||
{"drawKartString", libd_drawKartString},
|
||||
{"setClipRect", libd_setClipRect},
|
||||
{"clearClipRect", libd_clearClipRect},
|
||||
// misc
|
||||
{"stringWidth", libd_stringWidth},
|
||||
{"titleCardStringWidth", libd_titleCardStringWidth},
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ enum drawitem_e {
|
|||
DI_FadeScreen,
|
||||
DI_DrawTitleCardString,
|
||||
DI_DrawKartString,
|
||||
DI_SetClipRect,
|
||||
DI_ClearClipRect,
|
||||
DI_MAX,
|
||||
};
|
||||
|
||||
|
|
@ -394,6 +396,34 @@ void LUA_HUD_AddDrawKartString(
|
|||
item->flags = flags;
|
||||
}
|
||||
|
||||
void LUA_HUD_AddSetClipRect(
|
||||
huddrawlist_h list,
|
||||
fixed_t x,
|
||||
fixed_t y,
|
||||
fixed_t w,
|
||||
fixed_t h,
|
||||
INT32 flags
|
||||
)
|
||||
{
|
||||
size_t i = AllocateDrawItem(list);
|
||||
drawitem_t *item = &list->items[i];
|
||||
item->type = DI_SetClipRect;
|
||||
item->x = x;
|
||||
item->y = y;
|
||||
item->w = w;
|
||||
item->h = h;
|
||||
item->flags = flags;
|
||||
}
|
||||
|
||||
void LUA_HUD_AddClearClipRect(
|
||||
huddrawlist_h list
|
||||
)
|
||||
{
|
||||
size_t i = AllocateDrawItem(list);
|
||||
drawitem_t *item = &list->items[i];
|
||||
item->type = DI_ClearClipRect;
|
||||
}
|
||||
|
||||
void LUA_HUD_DrawList(huddrawlist_h list)
|
||||
{
|
||||
size_t i;
|
||||
|
|
@ -474,6 +504,12 @@ void LUA_HUD_DrawList(huddrawlist_h list)
|
|||
case DI_DrawKartString:
|
||||
V_DrawTimerString(item->x, item->y, item->flags, itemstr);
|
||||
break;
|
||||
case DI_SetClipRect:
|
||||
V_SetClipRect(item->x, item->y, item->w, item->h, item->flags);
|
||||
break;
|
||||
case DI_ClearClipRect:
|
||||
V_ClearClipRect();
|
||||
break;
|
||||
default:
|
||||
I_Error("can't draw draw list item: invalid draw list item type");
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -122,6 +122,17 @@ void LUA_HUD_AddDrawKartString(
|
|||
const char *str,
|
||||
INT32 flags
|
||||
);
|
||||
void LUA_HUD_AddSetClipRect(
|
||||
huddrawlist_h list,
|
||||
fixed_t x,
|
||||
fixed_t y,
|
||||
fixed_t w,
|
||||
fixed_t h,
|
||||
INT32 flags
|
||||
);
|
||||
void LUA_HUD_AddClearClipRect(
|
||||
huddrawlist_h list
|
||||
);
|
||||
|
||||
// Draws the given draw list
|
||||
void LUA_HUD_DrawList(huddrawlist_h list);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue