Allow lua to change vote background via hud.setVoteBackground
This commit is contained in:
1 parent
ca9277366c
commit
7f05d27f42
3 files changed
+54
-6
No files matched your search
@@ -15,6 +15,7 @@
|
||||
#include "r_defs.h"
|
||||
#include "r_local.h"
|
||||
#include "st_stuff.h" // hudinfo[]
|
||||
#include "y_inter.h"
|
||||
#include "g_game.h"
|
||||
#include "i_video.h" // rendermode
|
||||
#include "p_local.h" // camera_t
|
||||
@@ -966,11 +967,46 @@ static int lib_hudadd(lua_State *L)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lib_hudsetvotebackground(lua_State *L)
|
||||
{
|
||||
if (lua_isnoneornil(L, 1))
|
||||
{
|
||||
if (luaVoteScreen)
|
||||
{
|
||||
free(luaVoteScreen);
|
||||
}
|
||||
|
||||
luaVoteScreen = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *prefix = luaL_checkstring(L, 1);
|
||||
|
||||
if (strlen(prefix) != 4)
|
||||
{
|
||||
return luaL_argerror(L, 1, "prefix should 4 characters wide");
|
||||
}
|
||||
|
||||
if (!luaVoteScreen)
|
||||
{
|
||||
luaVoteScreen = (char*)malloc(5);
|
||||
luaVoteScreen[4] = 0;
|
||||
}
|
||||
|
||||
strncpy(luaVoteScreen, prefix, 4);
|
||||
|
||||
strupr(luaVoteScreen);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static luaL_Reg lib_hud[] = {
|
||||
{"enable", lib_hudenable},
|
||||
{"disable", lib_huddisable},
|
||||
{"enabled", lib_hudenabled},
|
||||
{"add", lib_hudadd},
|
||||
{"setVoteBackground", lib_hudsetvotebackground},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
|
||||
+17
-6
@@ -123,6 +123,7 @@ patch_t *animVoteFramesPatches = NULL;
|
||||
// VEXTRW - Vote (V) Extra (EXT) Race (R) Normal (W - Wide patch used in software)
|
||||
char animPrefix[] = "INTSC";
|
||||
char animWidePrefix[] = "INTSW";
|
||||
char *luaVoteScreen = NULL;
|
||||
|
||||
INT32 currentAnimFrame = 0;
|
||||
static INT32 foundAnimVoteFrames = 0;
|
||||
@@ -345,14 +346,24 @@ static void Y_CalculateMatchData(UINT8 rankingsmode, void (*comparison)(INT32))
|
||||
void Y_AnimatedVoteScreenCheck(void)
|
||||
{
|
||||
char tmpPrefix[] = "INTS";
|
||||
if(G_BattleGametype()) {
|
||||
strcpy(animPrefix, "BTLSC");
|
||||
strcpy(animWidePrefix, "BTLSW");
|
||||
|
||||
strcpy(tmpPrefix, "BTLS");
|
||||
}
|
||||
boolean stopSearching = false;
|
||||
|
||||
if (luaVoteScreen)
|
||||
{
|
||||
strncpy(tmpPrefix, luaVoteScreen, 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(G_BattleGametype()) {
|
||||
strcpy(tmpPrefix, "BTLS");
|
||||
}
|
||||
}
|
||||
|
||||
strncpy(animPrefix, tmpPrefix, 4);
|
||||
animPrefix[4] = 'C';
|
||||
strncpy(animWidePrefix, tmpPrefix, 4);
|
||||
animWidePrefix[4] = 'W';
|
||||
|
||||
foundAnimVoteFrames = 0;
|
||||
foundAnimVoteWideFrames = 0;
|
||||
currentAnimFrame = 0;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
/// \brief Tally screens, or "Intermissions" as they were formally called in Doom
|
||||
|
||||
extern boolean usebuffer;
|
||||
extern char *luaVoteScreen;
|
||||
|
||||
void Y_IntermissionDrawer(void);
|
||||
void Y_Ticker(void);
|
||||
|
||||
Reference in new issue
Block a user