Add "continue" and "playersetup" Lua HUD hooks & draw followitems in the Player Setup menu

This commit is contained in:
Lach 2023-11-29 19:27:52 +11:00
parent 8e7d8281bd
commit e412230ba9
4 changed files with 306 additions and 39 deletions

View file

@ -229,6 +229,7 @@ static UINT8 cutscene_boostspeed = 0;
char stjrintro[9] = "STJRI000"; char stjrintro[9] = "STJRI000";
static huddrawlist_h luahuddrawlist_title; static huddrawlist_h luahuddrawlist_title;
static huddrawlist_h luahuddrawlist_continue[2];
// //
// This alters the text string cutscene_disptext. // This alters the text string cutscene_disptext.
@ -3529,9 +3530,14 @@ void F_TitleDemoTicker(void)
static skin_t *contskins[2]; static skin_t *contskins[2];
static UINT8 cont_spr2[2][6]; static UINT8 cont_spr2[2][6];
static UINT8 *contcolormaps[2]; static UINT8 *contcolormaps[2];
static player_t *contPlayers[2];
static skincolornum_t contColors[2]; // it's possible to change your skincolor in the continue screen, so this is for Lua to identify the skincolor that was used to cache the colormap
static boolean contOverrides[2];
void F_StartContinue(void) void F_StartContinue(void)
{ {
UINT8 i;
I_Assert(!netgame && !multiplayer); I_Assert(!netgame && !multiplayer);
if (continuesInSession && players[consoleplayer].continues <= 0) if (continuesInSession && players[consoleplayer].continues <= 0)
@ -3554,9 +3560,11 @@ void F_StartContinue(void)
S_ChangeMusicInternal("_conti", false); S_ChangeMusicInternal("_conti", false);
S_StopSounds(); S_StopSounds();
contPlayers[0] = &players[consoleplayer];
contskins[0] = &skins[players[consoleplayer].skin]; contskins[0] = &skins[players[consoleplayer].skin];
cont_spr2[0][0] = P_GetSkinSprite2(contskins[0], SPR2_CNT1, NULL); cont_spr2[0][0] = P_GetSkinSprite2(contskins[0], SPR2_CNT1, NULL);
cont_spr2[0][2] = contskins[0]->contangle & 7; cont_spr2[0][2] = contskins[0]->contangle & 7;
contColors[0] = players[consoleplayer].skincolor;
contcolormaps[0] = R_GetTranslationColormap(players[consoleplayer].skin, players[consoleplayer].skincolor, GTC_CACHE); contcolormaps[0] = R_GetTranslationColormap(players[consoleplayer].skin, players[consoleplayer].skincolor, GTC_CACHE);
cont_spr2[0][4] = contskins[0]->sprites[cont_spr2[0][0]].numframes; cont_spr2[0][4] = contskins[0]->sprites[cont_spr2[0][0]].numframes;
cont_spr2[0][5] = max(1, contskins[0]->contspeed); cont_spr2[0][5] = max(1, contskins[0]->contspeed);
@ -3570,9 +3578,11 @@ void F_StartContinue(void)
else // HACK else // HACK
secondplaya = 1; secondplaya = 1;
contPlayers[1] = &players[secondplaya];
contskins[1] = &skins[players[secondplaya].skin]; contskins[1] = &skins[players[secondplaya].skin];
cont_spr2[1][0] = P_GetSkinSprite2(contskins[1], SPR2_CNT4, NULL); cont_spr2[1][0] = P_GetSkinSprite2(contskins[1], SPR2_CNT4, NULL);
cont_spr2[1][2] = (contskins[1]->contangle >> 3) & 7; cont_spr2[1][2] = (contskins[1]->contangle >> 3) & 7;
contColors[1] = players[secondplaya].skincolor;
contcolormaps[1] = R_GetTranslationColormap(players[secondplaya].skin, players[secondplaya].skincolor, GTC_CACHE); contcolormaps[1] = R_GetTranslationColormap(players[secondplaya].skin, players[secondplaya].skincolor, GTC_CACHE);
cont_spr2[1][4] = contskins[1]->sprites[cont_spr2[1][0]].numframes; cont_spr2[1][4] = contskins[1]->sprites[cont_spr2[1][0]].numframes;
if (cont_spr2[1][0] == SPR2_CNT4) if (cont_spr2[1][0] == SPR2_CNT4)
@ -3592,6 +3602,58 @@ void F_StartContinue(void)
timetonext = (11*TICRATE)+11; timetonext = (11*TICRATE)+11;
continuetime = 0; continuetime = 0;
// allocate and/or clear Lua continue screen draw lists
for (i = 0; i < 2; i++)
{
if (!LUA_HUD_IsDrawListValid(luahuddrawlist_continue[i]))
{
LUA_HUD_DestroyDrawList(luahuddrawlist_continue[i]);
luahuddrawlist_continue[i] = LUA_HUD_CreateDrawList();
}
LUA_HUD_ClearDrawList(luahuddrawlist_continue[i]);
contOverrides[i] = false;
}
}
static void F_DestroyContinueDrawLists(void)
{
UINT8 i;
for (i = 0; i < 2; i++)
{
LUA_HUD_DestroyDrawList(luahuddrawlist_continue[i]);
luahuddrawlist_continue[i] = NULL;
contOverrides[i] = false;
}
}
static void F_DrawContinueCharacter(INT32 dx, INT32 dy, UINT8 n)
{
spritedef_t *sprdef;
spriteframe_t *sprframe;
patch_t *patch;
if (renderisnewtic)
{
LUA_HUD_ClearDrawList(luahuddrawlist_continue[n]);
contOverrides[n] = LUA_HookCharacterHUD
(
HUD_HOOK(continue), luahuddrawlist_continue[n], contPlayers[n],
dx, dy, contskins[n]->highresscale,
(INT32)(contskins[n] - skins), cont_spr2[n][0], cont_spr2[n][1], cont_spr2[n][2] + 1, contColors[n], // add 1 to rotation to convert internal angle numbers (0-7) to WAD editor angle numbers (1-8)
imcontinuing ? continuetime : timetonext, imcontinuing
);
}
LUA_HUD_DrawList(luahuddrawlist_continue[n]);
if (contOverrides[n] == true)
return;
sprdef = &contskins[n]->sprites[cont_spr2[n][0]];
sprframe = &sprdef->spriteframes[cont_spr2[n][1]];
patch = W_CachePatchNum(sprframe->lumppat[cont_spr2[n][2]], PU_PATCH_LOWPRIORITY);
V_DrawFixedPatch((dx), (dy), contskins[n]->highresscale, (sprframe->flip & (1<<cont_spr2[n][2])) ? V_FLIP : 0, patch, contcolormaps[n]);
} }
// //
@ -3600,8 +3662,6 @@ void F_StartContinue(void)
// //
void F_ContinueDrawer(void) void F_ContinueDrawer(void)
{ {
spritedef_t *sprdef;
spriteframe_t *sprframe;
patch_t *patch; patch_t *patch;
INT32 i, x = (BASEVIDWIDTH>>1), ncontinues = players[consoleplayer].continues; INT32 i, x = (BASEVIDWIDTH>>1), ncontinues = players[consoleplayer].continues;
char numbuf[9] = "CONTNUM*"; char numbuf[9] = "CONTNUM*";
@ -3646,7 +3706,7 @@ void F_ContinueDrawer(void)
else if (ncontinues > 10) else if (ncontinues > 10)
{ {
if (!(continuetime & 1) || continuetime > 17) if (!(continuetime & 1) || continuetime > 17)
V_DrawContinueIcon(x, 68, 0, players[consoleplayer].skin, players[consoleplayer].skincolor); V_DrawContinueIcon(x, 68, 0, (INT32)(contskins[0] - skins), contColors[0]);
V_DrawScaledPatch(x+12, 66, 0, stlivex); V_DrawScaledPatch(x+12, 66, 0, stlivex);
V_DrawRightAlignedString(x+38, 64, 0, V_DrawRightAlignedString(x+38, 64, 0,
va("%d",(imcontinuing ? ncontinues-1 : ncontinues))); va("%d",(imcontinuing ? ncontinues-1 : ncontinues)));
@ -3660,7 +3720,7 @@ void F_ContinueDrawer(void)
{ {
if (i == (ncontinues/2) && ((continuetime & 1) || continuetime > 17)) if (i == (ncontinues/2) && ((continuetime & 1) || continuetime > 17))
continue; continue;
V_DrawContinueIcon(x - (i*30), 68, 0, players[consoleplayer].skin, players[consoleplayer].skincolor); V_DrawContinueIcon(x - (i*30), 68, 0, (INT32)(contskins[0] - skins), contColors[0]);
} }
x = BASEVIDWIDTH>>1; x = BASEVIDWIDTH>>1;
} }
@ -3700,21 +3760,12 @@ void F_ContinueDrawer(void)
else if (lift[0] > TICRATE+5) else if (lift[0] > TICRATE+5)
lift[0] = TICRATE+5; lift[0] = TICRATE+5;
#define drawchar(dx, dy, n) {\
sprdef = &contskins[n]->sprites[cont_spr2[n][0]];\
sprframe = &sprdef->spriteframes[cont_spr2[n][1]];\
patch = W_CachePatchNum(sprframe->lumppat[cont_spr2[n][2]], PU_PATCH_LOWPRIORITY);\
V_DrawFixedPatch((dx), (dy), contskins[n]->highresscale, (sprframe->flip & (1<<cont_spr2[n][2])) ? V_FLIP : 0, patch, contcolormaps[n]);\
}
if (offsy < 0) if (offsy < 0)
drawchar((BASEVIDWIDTH<<(FRACBITS-1))-offsx, ((140-lift[0])<<FRACBITS)-offsy, 0); F_DrawContinueCharacter((BASEVIDWIDTH<<(FRACBITS-1))-offsx, ((140-lift[0])<<FRACBITS)-offsy, 0);
if (contskins[1]) if (contskins[1])
drawchar((BASEVIDWIDTH<<(FRACBITS-1))+offsx, ((140-lift[1])<<FRACBITS)+offsy, 1); F_DrawContinueCharacter((BASEVIDWIDTH<<(FRACBITS-1))+offsx, ((140-lift[1])<<FRACBITS)+offsy, 1);
if (offsy >= 0) if (offsy >= 0)
drawchar((BASEVIDWIDTH<<(FRACBITS-1))-offsx, ((140-lift[0])<<FRACBITS)-offsy, 0); F_DrawContinueCharacter((BASEVIDWIDTH<<(FRACBITS-1))-offsx, ((140-lift[0])<<FRACBITS)-offsy, 0);
#undef drawchar
if (timetonext > (11*TICRATE)) if (timetonext > (11*TICRATE))
V_DrawFadeScreen(31, timetonext-(11*TICRATE)); V_DrawFadeScreen(31, timetonext-(11*TICRATE));
@ -3730,6 +3781,7 @@ void F_ContinueTicker(void)
{ {
if (!(--timetonext)) if (!(--timetonext))
{ {
F_DestroyContinueDrawLists();
Command_ExitGame_f(); Command_ExitGame_f();
return; return;
} }
@ -3739,6 +3791,7 @@ void F_ContinueTicker(void)
{ {
if (++continuetime == 3*TICRATE) if (++continuetime == 3*TICRATE)
{ {
F_DestroyContinueDrawLists();
G_Continue(); G_Continue();
return; return;
} }

View file

@ -86,6 +86,8 @@ automatically.
X (title),/* titlescreen */\ X (title),/* titlescreen */\
X (titlecard),\ X (titlecard),\
X (intermission),\ X (intermission),\
X (continue),\
X (playersetup),\
/* /*
I chose to access the hook enums through a macro as well. This could provide I chose to access the hook enums through a macro as well. This could provide
@ -117,6 +119,13 @@ extern boolean hook_cmd_running;
void LUA_HookVoid(int hook); void LUA_HookVoid(int hook);
void LUA_HookHUD(int hook, huddrawlist_h drawlist); void LUA_HookHUD(int hook, huddrawlist_h drawlist);
int LUA_HookCharacterHUD
(
int hook, huddrawlist_h drawlist, player_t *player,
fixed_t x, fixed_t y, fixed_t scale,
INT32 skinIndex, UINT8 sprite2, UINT8 frame, UINT8 rotation, skincolornum_t color,
INT32 ticker, boolean mode
);
int LUA_HookMobj(mobj_t *, int hook); int LUA_HookMobj(mobj_t *, int hook);
int LUA_Hook2Mobj(mobj_t *, mobj_t *, int hook); int LUA_Hook2Mobj(mobj_t *, mobj_t *, int hook);

View file

@ -375,6 +375,17 @@ static boolean prepare_string_hook
return false; return false;
} }
static boolean prepare_hud_hook
(
Hook_State * hook,
int default_status,
int hook_type
){
return init_hook_type(hook, default_status,
hook_type, 0, NULL,
hudHookIds[hook_type].numHooks);
}
static void init_hook_call static void init_hook_call
( (
Hook_State * hook, Hook_State * hook,
@ -490,6 +501,21 @@ static int call_mobj_type_hooks(Hook_State *hook, mobjtype_t mobj_type)
return call_mapped(hook, &mobjHookIds[mobj_type][hook->hook_type]); return call_mapped(hook, &mobjHookIds[mobj_type][hook->hook_type]);
} }
static void call_hud_hooks
(
Hook_State * hook,
int results,
Hook_Callback results_handler
){
hud_running = true; // local hook
init_hook_call(hook, results, results_handler);
call_mapped(hook, &hudHookIds[hook->hook_type]);
hud_running = false;
lua_pushnil(gL);
lua_setfield(gL, LUA_REGISTRYINDEX, "HUD_DRAW_LIST");
}
static int call_hooks static int call_hooks
( (
Hook_State * hook, Hook_State * hook,
@ -648,25 +674,41 @@ int LUA_HookKey(event_t *event, int hook_type)
void LUA_HookHUD(int hook_type, huddrawlist_h list) void LUA_HookHUD(int hook_type, huddrawlist_h list)
{ {
const hook_t * map = &hudHookIds[hook_type];
Hook_State hook; Hook_State hook;
if (map->numHooks > 0) if (prepare_hud_hook(&hook, 0, hook_type))
{ {
start_hook_stack();
begin_hook_values(&hook);
LUA_SetHudHook(hook_type, list); LUA_SetHudHook(hook_type, list);
call_hud_hooks(&hook, 0, res_none);
hud_running = true; // local hook
init_hook_call(&hook, 0, res_none);
call_mapped(&hook, map);
hud_running = false;
lua_pushnil(gL);
lua_setfield(gL, LUA_REGISTRYINDEX, "HUD_DRAW_LIST");
} }
} }
int LUA_HookCharacterHUD
(
int hook_type, huddrawlist_h list, player_t *player,
fixed_t x, fixed_t y, fixed_t scale,
INT32 skinIndex, UINT8 sprite2, UINT8 frame, UINT8 rotation, skincolornum_t color,
INT32 ticker, boolean mode
){
Hook_State hook;
if (prepare_hud_hook(&hook, false, hook_type))
{
LUA_SetHudHook(hook_type, list);
LUA_PushUserdata(gL, player, META_PLAYER);
lua_pushfixed(gL, x);
lua_pushfixed(gL, y);
lua_pushfixed(gL, scale);
lua_pushstring(gL, skins[skinIndex].name);
lua_pushinteger(gL, sprite2);
lua_pushinteger(gL, frame);
lua_pushinteger(gL, rotation);
lua_pushinteger(gL, color);
lua_pushinteger(gL, ticker);
lua_pushboolean(gL, mode);
call_hud_hooks(&hook, 1, res_true);
}
return hook.status;
}
/* ========================================================================= /* =========================================================================
SPECIALIZED HOOKS SPECIALIZED HOOKS
========================================================================= */ ========================================================================= */

View file

@ -182,6 +182,9 @@ static fixed_t char_scroll = 0;
static tic_t keydown = 0; static tic_t keydown = 0;
// Lua
static huddrawlist_h luahuddrawlist_playersetup;
// //
// PROTOTYPES // PROTOTYPES
// //
@ -11988,6 +11991,19 @@ static UINT8 multi_frame;
static UINT8 multi_spr2; static UINT8 multi_spr2;
static boolean multi_paused; static boolean multi_paused;
static boolean multi_invcolor; static boolean multi_invcolor;
static boolean multi_override;
static spritedef_t *multi_followitem_sprdef;
static INT32 multi_followitem_skinnum;
static UINT8 multi_followitem_numframes;
static UINT8 multi_followitem_startframe;
static UINT8 multi_followitem_frame;
static fixed_t multi_followitem_duration;
static fixed_t multi_followitem_tics;
static fixed_t multi_followitem_scale;
static fixed_t multi_followitem_yoffset;
#define MULTI_DURATION (4*FRACUNIT)
// this is set before entering the MultiPlayer setup menu, // this is set before entering the MultiPlayer setup menu,
// for either player 1 or 2 // for either player 1 or 2
@ -12132,9 +12148,92 @@ static menucolor_t *M_GridIndexToMenuColor(UINT16 index)
} }
} }
static void M_SetPlayerSetupFollowItem()
{
const mobjtype_t followitem = skins[setupm_fakeskin].followitem;
switch (followitem)
{
case MT_TAILSOVERLAY:
{
const state_t *state = &states[S_TAILSOVERLAY_MINUS30DEGREES];
const UINT8 sprite2 = P_GetSkinSprite2(&skins[setupm_fakeskin], state->frame & FF_FRAMEMASK, NULL);
if (state->sprite != SPR_PLAY)
break;
multi_followitem_sprdef = &skins[setupm_fakeskin].sprites[sprite2];
multi_followitem_skinnum = setupm_fakeskin;
multi_followitem_numframes = multi_followitem_sprdef->numframes;
multi_followitem_startframe = 0;
multi_followitem_frame = multi_frame;
multi_followitem_duration = MULTI_DURATION;
multi_followitem_tics = multi_tics;
multi_followitem_scale = FRACUNIT;
multi_followitem_yoffset = 0;
if ((state->frame & FF_SPR2MIDSTART) && (multi_followitem_numframes > 0) && M_RandomChance(FRACUNIT / 2))
{
multi_followitem_frame += multi_followitem_numframes / 2;
}
break;
}
case MT_METALJETFUME:
{
const state_t *state = &states[S_JETFUME1];
if (!(state->frame & FF_ANIMATE))
break;
multi_followitem_sprdef = &sprites[state->sprite];
multi_followitem_skinnum = TC_DEFAULT;
multi_followitem_numframes = state->var1 + 1;
multi_followitem_startframe = state->frame & FF_FRAMEMASK;
multi_followitem_frame = multi_followitem_startframe;
multi_followitem_duration = state->var2 * FRACUNIT;
multi_followitem_tics = multi_tics % multi_followitem_duration;
multi_followitem_scale = 2 * FRACUNIT / 3;
multi_followitem_yoffset = (skins[setupm_fakeskin].height - FixedMul(mobjinfo[followitem].height, multi_followitem_scale)) >> 1;
break;
}
default:
multi_followitem_sprdef = NULL;
break;
}
}
static void M_DrawPlayerSetupFollowItem(INT32 x, INT32 y, fixed_t scale, INT32 flags)
{
spriteframe_t *sprframe;
patch_t *patch;
UINT8 *colormap;
if (multi_followitem_sprdef == NULL)
return;
if (multi_followitem_frame >= multi_followitem_startframe + multi_followitem_numframes)
multi_followitem_frame = multi_followitem_startframe;
colormap = R_GetTranslationColormap(multi_followitem_skinnum, setupm_fakecolor->color, GTC_CACHE);
sprframe = &multi_followitem_sprdef->spriteframes[multi_followitem_frame];
patch = W_CachePatchNum(sprframe->lumppat[0], PU_PATCH);
if (sprframe->flip & 1) // Only for first sprite
flags |= V_FLIP; // This sprite is left/right flipped!
x <<= FRACBITS;
y <<= FRACBITS;
y -= FixedMul(multi_followitem_yoffset, scale);
scale = FixedMul(scale, multi_followitem_scale);
V_DrawFixedPatch(x, y, scale, flags, patch, colormap);
}
static void M_DrawSetupMultiPlayerMenu(void) static void M_DrawSetupMultiPlayerMenu(void)
{ {
INT32 x, y, cursory = 0, flags = 0; INT32 x, y, cursory = 0, flags = 0;
fixed_t scale;
spritedef_t *sprdef; spritedef_t *sprdef;
spriteframe_t *sprframe; spriteframe_t *sprframe;
patch_t *patch; patch_t *patch;
@ -12184,11 +12283,24 @@ static void M_DrawSetupMultiPlayerMenu(void)
y += 11; y += 11;
// anim the player in the box // anim the player in the box
if (!multi_paused)
{
multi_tics -= renderdeltatics; multi_tics -= renderdeltatics;
while (!multi_paused && multi_tics <= 0) while (multi_tics <= 0)
{ {
multi_frame++; multi_frame++;
multi_tics += 4*FRACUNIT; multi_tics += MULTI_DURATION;
}
if (multi_followitem_sprdef != NULL)
{
multi_followitem_tics -= renderdeltatics;
while (multi_followitem_tics <= 0)
{
multi_followitem_frame++;
multi_followitem_tics += multi_followitem_duration;
}
}
} }
#define charw 74 #define charw 74
@ -12203,22 +12315,43 @@ static void M_DrawSetupMultiPlayerMenu(void)
goto faildraw; goto faildraw;
// ok, draw player sprite for sure now // ok, draw player sprite for sure now
colormap = R_GetTranslationColormap(setupm_fakeskin, setupm_fakecolor->color, GTC_CACHE);
if (multi_frame >= sprdef->numframes) if (multi_frame >= sprdef->numframes)
multi_frame = 0; multi_frame = 0;
scale = FixedDiv(skins[setupm_fakeskin].highresscale, skins[setupm_fakeskin].shieldscale);
#define chary (y+64)
if (renderisnewtic)
{
LUA_HUD_ClearDrawList(luahuddrawlist_playersetup);
multi_override = LUA_HookCharacterHUD
(
HUD_HOOK(playersetup), luahuddrawlist_playersetup, setupm_player,
x << FRACBITS, chary << FRACBITS, scale,
setupm_fakeskin, multi_spr2, multi_frame, 1, setupm_fakecolor->color,
(multi_tics >> FRACBITS) + 1, multi_paused
);
}
LUA_HUD_DrawList(luahuddrawlist_playersetup);
if (multi_override == true)
goto colordraw;
colormap = R_GetTranslationColormap(setupm_fakeskin, setupm_fakecolor->color, GTC_CACHE);
sprframe = &sprdef->spriteframes[multi_frame]; sprframe = &sprdef->spriteframes[multi_frame];
patch = W_CachePatchNum(sprframe->lumppat[0], PU_PATCH); patch = W_CachePatchNum(sprframe->lumppat[0], PU_PATCH);
if (sprframe->flip & 1) // Only for first sprite if (sprframe->flip & 1) // Only for first sprite
flags |= V_FLIP; // This sprite is left/right flipped! flags |= V_FLIP; // This sprite is left/right flipped!
#define chary (y+64) M_DrawPlayerSetupFollowItem(x, chary, scale, flags & ~V_FLIP);
V_DrawFixedPatch( V_DrawFixedPatch(
x<<FRACBITS, x<<FRACBITS,
chary<<FRACBITS, chary<<FRACBITS,
FixedDiv(skins[setupm_fakeskin].highresscale, skins[setupm_fakeskin].shieldscale), scale,
flags, patch, colormap); flags, patch, colormap);
goto colordraw; goto colordraw;
@ -12406,6 +12539,20 @@ static void M_DrawColorRamp(INT32 x, INT32 y, INT32 w, INT32 h, skincolor_t colo
V_DrawFill(x, y+(i*h), w, h, color.ramp[i]); V_DrawFill(x, y+(i*h), w, h, color.ramp[i]);
} }
static void M_InitPlayerSetupLua(void)
{
// I'd really like to assume that the drawlist has been destroyed,
// but it appears M_ClearMenus has options not to call exit routines...
// so that doesn't seem safe to me??
if (!LUA_HUD_IsDrawListValid(luahuddrawlist_playersetup))
{
LUA_HUD_DestroyDrawList(luahuddrawlist_playersetup);
luahuddrawlist_playersetup = LUA_HUD_CreateDrawList();
}
LUA_HUD_ClearDrawList(luahuddrawlist_playersetup);
multi_override = false;
}
// Handle 1P/2P MP Setup // Handle 1P/2P MP Setup
static void M_HandleSetupMultiPlayer(INT32 choice) static void M_HandleSetupMultiPlayer(INT32 choice)
{ {
@ -12451,6 +12598,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice)
} }
while ((prev_setupm_fakeskin != setupm_fakeskin) && !(R_SkinUsable(-1, setupm_fakeskin))); while ((prev_setupm_fakeskin != setupm_fakeskin) && !(R_SkinUsable(-1, setupm_fakeskin)));
multi_spr2 = P_GetSkinSprite2(&skins[setupm_fakeskin], SPR2_WALK, NULL); multi_spr2 = P_GetSkinSprite2(&skins[setupm_fakeskin], SPR2_WALK, NULL);
M_SetPlayerSetupFollowItem();
} }
else if (itemOn == 2) // player color else if (itemOn == 2) // player color
{ {
@ -12491,6 +12639,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice)
} }
while ((prev_setupm_fakeskin != setupm_fakeskin) && !(R_SkinUsable(-1, setupm_fakeskin))); while ((prev_setupm_fakeskin != setupm_fakeskin) && !(R_SkinUsable(-1, setupm_fakeskin)));
multi_spr2 = P_GetSkinSprite2(&skins[setupm_fakeskin], SPR2_WALK, NULL); multi_spr2 = P_GetSkinSprite2(&skins[setupm_fakeskin], SPR2_WALK, NULL);
M_SetPlayerSetupFollowItem();
} }
else if (itemOn == 2) // player color else if (itemOn == 2) // player color
{ {
@ -12611,7 +12760,7 @@ static void M_SetupMultiPlayer(INT32 choice)
(void)choice; (void)choice;
multi_frame = 0; multi_frame = 0;
multi_tics = 4*FRACUNIT; multi_tics = MULTI_DURATION;
strcpy(setupm_name, cv_playername.string); strcpy(setupm_name, cv_playername.string);
@ -12641,6 +12790,10 @@ static void M_SetupMultiPlayer(INT32 choice)
MP_PlayerSetupMenu[2].status = (IT_KEYHANDLER|IT_STRING); MP_PlayerSetupMenu[2].status = (IT_KEYHANDLER|IT_STRING);
multi_spr2 = P_GetSkinSprite2(&skins[setupm_fakeskin], SPR2_WALK, NULL); multi_spr2 = P_GetSkinSprite2(&skins[setupm_fakeskin], SPR2_WALK, NULL);
M_SetPlayerSetupFollowItem();
// allocate and/or clear Lua player setup draw list
M_InitPlayerSetupLua();
MP_PlayerSetupDef.prevMenu = currentMenu; MP_PlayerSetupDef.prevMenu = currentMenu;
M_SetupNextMenu(&MP_PlayerSetupDef); M_SetupNextMenu(&MP_PlayerSetupDef);
@ -12652,7 +12805,7 @@ static void M_SetupMultiPlayer2(INT32 choice)
(void)choice; (void)choice;
multi_frame = 0; multi_frame = 0;
multi_tics = 4*FRACUNIT; multi_tics = MULTI_DURATION;
strcpy (setupm_name, cv_playername2.string); strcpy (setupm_name, cv_playername2.string);
@ -12682,6 +12835,10 @@ static void M_SetupMultiPlayer2(INT32 choice)
MP_PlayerSetupMenu[2].status = (IT_KEYHANDLER|IT_STRING); MP_PlayerSetupMenu[2].status = (IT_KEYHANDLER|IT_STRING);
multi_spr2 = P_GetSkinSprite2(&skins[setupm_fakeskin], SPR2_WALK, NULL); multi_spr2 = P_GetSkinSprite2(&skins[setupm_fakeskin], SPR2_WALK, NULL);
M_SetPlayerSetupFollowItem();
// allocate and/or clear Lua player setup draw list
M_InitPlayerSetupLua();
MP_PlayerSetupDef.prevMenu = currentMenu; MP_PlayerSetupDef.prevMenu = currentMenu;
M_SetupNextMenu(&MP_PlayerSetupDef); M_SetupNextMenu(&MP_PlayerSetupDef);
@ -12703,6 +12860,12 @@ static boolean M_QuitMultiPlayerMenu(void)
// send color if changed // send color if changed
if (setupm_fakecolor->color != setupm_cvcolor->value) if (setupm_fakecolor->color != setupm_cvcolor->value)
COM_BufAddText (va("%s %d\n",setupm_cvcolor->name,setupm_fakecolor->color)); COM_BufAddText (va("%s %d\n",setupm_cvcolor->name,setupm_fakecolor->color));
// de-allocate Lua player setup drawlist
LUA_HUD_DestroyDrawList(luahuddrawlist_playersetup);
luahuddrawlist_playersetup = NULL;
multi_override = false;
return true; return true;
} }