mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-18 07:22:28 +00:00
Updated captions to:
* be more efficient * fade away early if they stop playing * make their current max stick-around time longer * make the fade time/etc easier to modify
This commit is contained in:
parent
bdaa0aea9b
commit
94add11fab
3 changed files with 17 additions and 14 deletions
|
@ -586,7 +586,7 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume)
|
||||||
|
|
||||||
closedcaptions[set].c = &channels[cnum];
|
closedcaptions[set].c = &channels[cnum];
|
||||||
closedcaptions[set].s = sfx;
|
closedcaptions[set].s = sfx;
|
||||||
closedcaptions[set].t = TICRATE+2;
|
closedcaptions[set].t = MAXCAPTIONTICS+2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assigns the handle to one of the channels in the
|
// Assigns the handle to one of the channels in the
|
||||||
|
@ -694,7 +694,7 @@ dontplay:
|
||||||
|
|
||||||
closedcaptions[set].c = &channels[cnum];
|
closedcaptions[set].c = &channels[cnum];
|
||||||
closedcaptions[set].s = sfx;
|
closedcaptions[set].s = sfx;
|
||||||
closedcaptions[set].t = TICRATE+2;
|
closedcaptions[set].t = MAXCAPTIONTICS+2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assigns the handle to one of the channels in the
|
// Assigns the handle to one of the channels in the
|
||||||
|
@ -973,21 +973,22 @@ notinlevel:
|
||||||
|
|
||||||
for (i = 0; i < NUMCAPTIONS; i++) // update captions
|
for (i = 0; i < NUMCAPTIONS; i++) // update captions
|
||||||
{
|
{
|
||||||
boolean cond = (closedcaptions[i].c && I_SoundIsPlaying(closedcaptions[i].c->handle));
|
if (!closedcaptions[i].s)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (closedcaptions[i].t <= TICRATE)
|
if (closedcaptions[i].t <= MAXCAPTIONTICS)
|
||||||
closedcaptions[i].t--;
|
closedcaptions[i].t--;
|
||||||
if (cond || (closedcaptions[i].s && closedcaptions[i].t))
|
|
||||||
{
|
|
||||||
if (!cond)
|
|
||||||
closedcaptions[i].c = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!closedcaptions[i].t)
|
if (!closedcaptions[i].t)
|
||||||
{
|
{
|
||||||
closedcaptions[i].c = NULL;
|
closedcaptions[i].c = NULL;
|
||||||
closedcaptions[i].s = NULL;
|
closedcaptions[i].s = NULL;
|
||||||
closedcaptions[i].t = 0;
|
}
|
||||||
|
else if (closedcaptions[i].c && !I_SoundIsPlaying(closedcaptions[i].c->handle))
|
||||||
|
{
|
||||||
|
closedcaptions[i].c = NULL;
|
||||||
|
if (closedcaptions[i].t > CAPTIONFADETICS)
|
||||||
|
closedcaptions[i].t = CAPTIONFADETICS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,6 +86,8 @@ typedef struct {
|
||||||
} caption_t;
|
} caption_t;
|
||||||
|
|
||||||
#define NUMCAPTIONS 8
|
#define NUMCAPTIONS 8
|
||||||
|
#define MAXCAPTIONTICS (2*TICRATE)
|
||||||
|
#define CAPTIONFADETICS 20
|
||||||
|
|
||||||
extern caption_t closedcaptions[NUMCAPTIONS];
|
extern caption_t closedcaptions[NUMCAPTIONS];
|
||||||
|
|
||||||
|
|
|
@ -449,10 +449,10 @@ void SCR_ClosedCaptions(void)
|
||||||
INT32 flags = V_NOSCALESTART|V_ALLOWLOWERCASE;
|
INT32 flags = V_NOSCALESTART|V_ALLOWLOWERCASE;
|
||||||
INT32 y = vid.height-((i + 2)*10*vid.dupy);
|
INT32 y = vid.height-((i + 2)*10*vid.dupy);
|
||||||
char dir = ' ';
|
char dir = ' ';
|
||||||
if (closedcaptions[i].t < 20)
|
if (closedcaptions[i].t < CAPTIONFADETICS)
|
||||||
flags |= (((20-closedcaptions[i].t)/2)*V_10TRANS);
|
flags |= (((CAPTIONFADETICS-closedcaptions[i].t)/2)*V_10TRANS);
|
||||||
else if (closedcaptions[i].t > TICRATE)
|
else if (closedcaptions[i].t > MAXCAPTIONTICS)
|
||||||
y -= (closedcaptions[i].t-- - TICRATE)*vid.dupy;
|
y -= (closedcaptions[i].t-- - MAXCAPTIONTICS)*vid.dupy;
|
||||||
if (closedcaptions[i].c && closedcaptions[i].c->origin)
|
if (closedcaptions[i].c && closedcaptions[i].c->origin)
|
||||||
dir = '\x1E';
|
dir = '\x1E';
|
||||||
V_DrawRightAlignedString(vid.width-(20*vid.dupx), y,
|
V_DrawRightAlignedString(vid.width-(20*vid.dupx), y,
|
||||||
|
|
Loading…
Reference in a new issue