Make flags field of timers act like a bitfield and add new flags
This commit is contained in:
parent
cf1ac5f864
commit
e96b1bfdce
4 changed files with 78 additions and 34 deletions
|
|
@ -1824,7 +1824,22 @@ struct int_const_s const INT_CONST[] = {
|
|||
|
||||
// item timer stuff
|
||||
{"TIMER_COUNTER", TIMER_COUNTER},
|
||||
{"TIMER_BAD", TIMER_BAD},
|
||||
{"TIMER_NONUMBER",TIMER_NONUMBER},
|
||||
{"TIMER_PURPLE", TIMER_PURPLE},
|
||||
{"TIMER_YELLOW", TIMER_YELLOW},
|
||||
{"TIMER_GREEN", TIMER_GREEN},
|
||||
{"TIMER_BLUE", TIMER_BLUE},
|
||||
{"TIMER_RED", TIMER_RED},
|
||||
{"TIMER_GRAY", TIMER_GRAY},
|
||||
{"TIMER_ORANGE", TIMER_ORANGE},
|
||||
{"TIMER_SKY", TIMER_SKY},
|
||||
{"TIMER_LAVENDER", TIMER_LAVENDER},
|
||||
{"TIMER_GOLD", TIMER_GOLD},
|
||||
{"TIMER_AQUA", TIMER_AQUA},
|
||||
{"TIMER_MAGENTA", TIMER_MAGENTA},
|
||||
{"TIMER_PINK", TIMER_PINK},
|
||||
{"TIMER_BROWN", TIMER_BROWN},
|
||||
{"TIMER_TAN", TIMER_TAN},
|
||||
|
||||
{NULL,0}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ typedef struct itimer_s
|
|||
INT32 timer; // current time
|
||||
std::vector<patch_t*> patches; // timer graphics (small)
|
||||
INT32 anim_frames = 1; // tic duration for each graphic
|
||||
UINT8 flags = 0; // settings for timer
|
||||
UINT32 flags = 0; // settings for timer
|
||||
lua_Integer timer_func_ref = LUA_NOREF; // if set, calls a function from registry to get timer value
|
||||
boolean timer_func_error = false; // don't print error every frame
|
||||
} itimer_t;
|
||||
|
|
@ -143,7 +143,7 @@ void K_AddItemTimerEx(
|
|||
const char **patches,
|
||||
INT32 patches_size,
|
||||
INT32 anim_duration,
|
||||
UINT8 flags, boolean unsorted)
|
||||
UINT32 flags, boolean unsorted)
|
||||
{
|
||||
itimer_t t; // woo yeah baby
|
||||
|
||||
|
|
@ -307,7 +307,7 @@ void K_DisplayItemTimers(void)
|
|||
std::max<UINT16>(stplyr->spinouttimer, stplyr->wipeoutslow),
|
||||
{qche("K_TISPN1"), qche("K_TISPN2"), qche("K_TISPN3"), qche("K_TISPN4")},
|
||||
3,
|
||||
TIMER_BAD,
|
||||
TIMER_RED,
|
||||
}
|
||||
);
|
||||
timers.push_back(
|
||||
|
|
@ -316,7 +316,7 @@ void K_DisplayItemTimers(void)
|
|||
std::max<INT16>(0, -stplyr->growshrinktimer),
|
||||
{qche("K_TISHRK")},
|
||||
1,
|
||||
TIMER_BAD,
|
||||
static_cast<uint32_t>((K_IsAltShrunk(stplyr) ? 0 : TIMER_RED)),
|
||||
}
|
||||
);
|
||||
timers.push_back(
|
||||
|
|
@ -325,7 +325,7 @@ void K_DisplayItemTimers(void)
|
|||
(INT32)spbTimers[stplyr-players],
|
||||
{qche("K_TISPB")},
|
||||
1,
|
||||
(UINT8)((stplyr->position == K_GetBestRank()) ? TIMER_BAD : 0),
|
||||
static_cast<uint32_t>((stplyr->position == K_GetBestRank()) ? TIMER_RED : 0),
|
||||
}
|
||||
);
|
||||
// Same with boost stacks
|
||||
|
|
@ -335,7 +335,7 @@ void K_DisplayItemTimers(void)
|
|||
K_StackingActive() ? stplyr->numboosts : 0,
|
||||
{qche("K_TISRK1"), qche("K_TISRK2")},
|
||||
2,
|
||||
TIMER_BAD,
|
||||
TIMER_GREEN|TIMER_COUNTER,
|
||||
}
|
||||
);
|
||||
timers.push_back(
|
||||
|
|
@ -411,11 +411,6 @@ void K_DisplayItemTimers(void)
|
|||
textcmap = cmap;
|
||||
}
|
||||
|
||||
if (fastcmp(t.name, "boosts"))
|
||||
{
|
||||
flags |= V_GREENMAP;
|
||||
}
|
||||
|
||||
if (t.flags & TIMER_COUNTER) // don't show up as time
|
||||
{
|
||||
str = va("%d", timer);
|
||||
|
|
@ -423,27 +418,46 @@ void K_DisplayItemTimers(void)
|
|||
}
|
||||
INT32 width = V_StringScaledWidth(FRACUNIT, FRACUNIT, FRACUNIT, flags|V_MONOSPACE, font, str) >> FRACBITS;
|
||||
|
||||
// very bad!
|
||||
if (t.flags & TIMER_BAD)
|
||||
{
|
||||
flags |= V_REDMAP;
|
||||
//textcmap = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_CRIMSON, GTC_CACHE);
|
||||
}
|
||||
#define COLORTIMER(color) \
|
||||
if (t.flags & TIMER_##color) \
|
||||
flags |= V_##color##MAP\
|
||||
|
||||
// Color timers!
|
||||
COLORTIMER(RED);
|
||||
COLORTIMER(PURPLE);
|
||||
COLORTIMER(YELLOW);
|
||||
COLORTIMER(GREEN);
|
||||
COLORTIMER(BLUE);
|
||||
COLORTIMER(RED);
|
||||
COLORTIMER(GRAY);
|
||||
COLORTIMER(ORANGE);
|
||||
COLORTIMER(SKY);
|
||||
COLORTIMER(LAVENDER);
|
||||
COLORTIMER(GOLD);
|
||||
COLORTIMER(AQUA);
|
||||
COLORTIMER(MAGENTA);
|
||||
COLORTIMER(PINK);
|
||||
COLORTIMER(BROWN);
|
||||
COLORTIMER(TAN);
|
||||
|
||||
patch_t *item = t.patches[patchnum];
|
||||
V_DrawFixedPatch((itemx - (item->width/2))<<FRACBITS, (itemy - 2)<<FRACBITS, FRACUNIT, flags, t.patches[patchnum], cmap);
|
||||
V_DrawStringScaledEx(
|
||||
(itemx - (width/2) - item->leftoffset) << FRACBITS,
|
||||
(itemy + 12) << FRACBITS,
|
||||
FRACUNIT,
|
||||
FRACUNIT,
|
||||
FRACUNIT,
|
||||
FRACUNIT,
|
||||
flags|V_MONOSPACE,
|
||||
textcmap,
|
||||
font,
|
||||
str
|
||||
);
|
||||
|
||||
if (!(t.flags & TIMER_NONUMBER))
|
||||
{
|
||||
V_DrawStringScaledEx(
|
||||
(itemx - (width/2) - item->leftoffset) << FRACBITS,
|
||||
(itemy + 12) << FRACBITS,
|
||||
FRACUNIT,
|
||||
FRACUNIT,
|
||||
FRACUNIT,
|
||||
FRACUNIT,
|
||||
flags|V_MONOSPACE,
|
||||
textcmap,
|
||||
font,
|
||||
str
|
||||
);
|
||||
}
|
||||
|
||||
itemx += stepx;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,8 +24,23 @@ extern "C" {
|
|||
|
||||
typedef enum timerflags_e
|
||||
{
|
||||
TIMER_COUNTER = 0x1,
|
||||
TIMER_BAD = 0x2,
|
||||
TIMER_COUNTER = 1,
|
||||
TIMER_NONUMBER = 1<<1,
|
||||
TIMER_PURPLE = 1<<2,
|
||||
TIMER_YELLOW = 1<<3,
|
||||
TIMER_GREEN = 1<<4,
|
||||
TIMER_BLUE = 1<<5,
|
||||
TIMER_RED = 1<<6,
|
||||
TIMER_GRAY = 1<<7,
|
||||
TIMER_ORANGE = 1<<8,
|
||||
TIMER_SKY = 1<<9,
|
||||
TIMER_LAVENDER = 1<<10,
|
||||
TIMER_GOLD = 1<<11,
|
||||
TIMER_AQUA = 1<<12,
|
||||
TIMER_MAGENTA = 1<<13,
|
||||
TIMER_PINK = 1<<14,
|
||||
TIMER_BROWN = 1<<15,
|
||||
TIMER_TAN = 1<<16,
|
||||
} timerflags_t;
|
||||
|
||||
extern consvar_t cv_itemtimers;
|
||||
|
|
@ -39,7 +54,7 @@ void K_AddItemTimerEx(
|
|||
const char **patches,
|
||||
INT32 patches_size,
|
||||
INT32 anim_duration,
|
||||
UINT8 flags, boolean unsorted);
|
||||
UINT32 flags, boolean unsorted);
|
||||
void K_DisplayItemTimers(void);
|
||||
void K_getTimersDrawinfo(drawinfo_t *out);
|
||||
|
||||
|
|
|
|||
|
|
@ -1790,7 +1790,7 @@ static int lib_hudaddtimer(lua_State *L)
|
|||
|
||||
INT32 anim_duration = luaL_optinteger(L, 4, 1);
|
||||
|
||||
UINT8 flags = (UINT8)luaL_optinteger(L, 5, 0);
|
||||
UINT32 flags = luaL_optinteger(L, 5, 0);
|
||||
|
||||
boolean unsorted = lua_toboolean(L, 6);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue