mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-02-17 01:21:18 +00:00
add in function g_setdisplayplayer
add in g_setdisplayplayer as an alternate way to call the F12 key press manually
This commit is contained in:
parent
11ab92783e
commit
bdda5e58ff
4 changed files with 64 additions and 2 deletions
45
src/g_game.c
45
src/g_game.c
|
@ -5670,3 +5670,48 @@ INT32 G_TicsToMilliseconds(tic_t tics)
|
|||
return (INT32)((tics%TICRATE) * (1000.00f/TICRATE));
|
||||
}
|
||||
|
||||
//miru: change the displayed player
|
||||
// player - player to forward the function to
|
||||
// displayNumber - the player number (node) to view
|
||||
// setAllDisplays - set all displays to the player number/node specified
|
||||
void G_SetDisplayPlayer(player_t *player, INT32 displayNumber, boolean setAllDisplays)
|
||||
{
|
||||
//TODO: fix black flashes when touching controls (this has to do with
|
||||
//((cmd->forwardmove || cmd->sidemove || cmd->buttons) && displayplayer != consoleplayer) )
|
||||
//TODO: proper implementation for using player node instead of -1 (unsure how)
|
||||
if (gamestate == GS_LEVEL)
|
||||
{
|
||||
// no, not for non-sp
|
||||
if (!netgame)
|
||||
displayplayer = consoleplayer;
|
||||
else
|
||||
{
|
||||
// the player has to exist or you just get a bleeding display
|
||||
if (playeringame[displayNumber] || players[displayplayer].spectator && player == &players[displayplayer])
|
||||
{
|
||||
// switch the display number locally
|
||||
if (P_IsLocalPlayer(player) && displayplayer == consoleplayer)
|
||||
{
|
||||
displayplayer = displayNumber;
|
||||
}
|
||||
// or force all
|
||||
else if (setAllDisplays == true)
|
||||
{
|
||||
displayplayer = displayNumber;
|
||||
}
|
||||
|
||||
// tell who's the view
|
||||
//CONS_Printf(M_GetText("Viewpoint: %s\n"), player_names[displayplayer]);
|
||||
}
|
||||
// Setting as -1 resets your view to normal
|
||||
else if (displayNumber == -1 && P_IsLocalPlayer(player)
|
||||
&& displayplayer != consoleplayer)
|
||||
displayplayer = consoleplayer;
|
||||
else
|
||||
{
|
||||
// or do...nothing
|
||||
//CONS_Printf("Player doesn't exist (or viewing self).\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -216,4 +216,6 @@ FUNCMATH INT32 G_TicsToMilliseconds(tic_t tics);
|
|||
// Don't split up TOL handling
|
||||
INT16 G_TOLFlag(INT32 pgametype);
|
||||
|
||||
void G_SetDisplayPlayer(player_t *player, INT32 displayNumber, boolean setAllDisplays);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1827,6 +1827,19 @@ static int lib_pSetActiveMotionBlur(lua_State *L)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int lib_gSetDisplayPlayer(lua_State *L)
|
||||
{
|
||||
// set args 1 2 & 3
|
||||
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
|
||||
INT32 dispnum = luaL_checkint(L, 2);
|
||||
boolean alldisps = luaL_checkboolean(L, 3);
|
||||
NOHUD
|
||||
if (!player)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
G_SetDisplayPlayer(player, dispnum, alldisps);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=====================================================================
|
||||
|
||||
|
||||
|
@ -2214,6 +2227,7 @@ static luaL_Reg lib[] = {
|
|||
{"S_GetMusicPosition",lib_sGetMusicPosition},
|
||||
{"S_FadeOutMusic",lib_sFadeOutMusic},
|
||||
{"P_SetActiveMotionBlur",lib_pSetActiveMotionBlur},
|
||||
{"G_SetDisplayPlayer",lib_gSetDisplayPlayer},
|
||||
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
|
|
@ -1829,8 +1829,9 @@ static void ST_overlayDrawer(void)
|
|||
strlcpy(name, player_names[stplyr-players], 13);
|
||||
|
||||
// Show name of player being displayed
|
||||
V_DrawCenteredString((BASEVIDWIDTH/6), BASEVIDHEIGHT-80, 0, M_GetText("Viewpoint:"));
|
||||
V_DrawCenteredString((BASEVIDWIDTH/6), BASEVIDHEIGHT-64, V_ALLOWLOWERCASE, name);
|
||||
// miru: do something about this "viewpoint:", make it optional or non-existent
|
||||
V_DrawCenteredString((BASEVIDWIDTH/6), BASEVIDHEIGHT-80, V_90TRANS, M_GetText("Viewpoint:"));
|
||||
V_DrawCenteredString((BASEVIDWIDTH/6), BASEVIDHEIGHT-64, V_90TRANS|V_ALLOWLOWERCASE, name);
|
||||
}
|
||||
|
||||
// This is where we draw all the fun cheese if you have the chasecam off!
|
||||
|
|
Loading…
Reference in a new issue