Implemented GFX for text prompts

* PicMode SOC
* PicToLoop SOC
This commit is contained in:
mazmazz 2018-11-10 12:42:13 -05:00
parent 631c6f93f5
commit 9a038b28e1
3 changed files with 87 additions and 11 deletions

View File

@ -1640,10 +1640,19 @@ static void readtextpromptpage(MYFILE *f, INT32 num, INT32 pagenum)
{
textprompts[num]->page[pagenum].numpics = (UINT8)i;
}
else if (fastcmp(word, "PICMODE"))
{
UINT8 picmode = 0; // PROMPT_PIC_PERSIST
if (usi == 1 || word2[0] == 'L') picmode = PROMPT_PIC_LOOP;
else if (usi == 2 || word2[0] == 'D' || word2[0] == 'H') picmode = PROMPT_PIC_DESTROY;
textprompts[num]->page[pagenum].picmode = picmode;
}
else if (fastcmp(word, "PICTOLOOP"))
textprompts[num]->page[pagenum].pictoloop = (UINT8)i;
else if (fastncmp(word, "PIC", 3))
{
picid = (UINT8)atoi(word + 3);
if (picid > 8 || picid == 0)
if (picid > MAX_PROMPT_PICS || picid == 0)
{
deh_warning("textpromptscene %d: unknown word '%s'", num, word);
continue;
@ -1802,9 +1811,12 @@ static void readtextpromptpage(MYFILE *f, INT32 num, INT32 pagenum)
UINT8 metapagenum = usi - 1;
UINT8 picid;
for (picid = 0; picid < 8; picid++)
textprompts[num]->page[pagenum].numpics = textprompts[num]->page[metapagenum].numpics;
textprompts[num]->page[pagenum].picmode = textprompts[num]->page[metapagenum].picmode;
textprompts[num]->page[pagenum].pictoloop = textprompts[num]->page[metapagenum].pictoloop;
for (picid = 0; picid < MAX_PROMPT_PICS; picid++)
{
textprompts[num]->page[pagenum].numpics = textprompts[num]->page[metapagenum].numpics;
strncpy(textprompts[num]->page[pagenum].picname[picid], textprompts[num]->page[metapagenum].picname[picid], 8);
textprompts[num]->page[pagenum].pichires[picid] = textprompts[num]->page[metapagenum].pichires[picid];
textprompts[num]->page[pagenum].picduration[picid] = textprompts[num]->page[metapagenum].picduration[picid];

View File

@ -176,14 +176,20 @@ extern cutscene_t *cutscenes[128];
#define MAX_PROMPTS (TUTORIAL_PROMPT+TUTORIAL_AREAS*TUTORIAL_AREA_PROMPTS*3) // 3 control modes
#define MAX_PAGES 128
#define PROMPT_PIC_PERSIST 0
#define PROMPT_PIC_LOOP 1
#define PROMPT_PIC_DESTROY 2
#define MAX_PROMPT_PICS 8
typedef struct
{
UINT8 numpics;
char picname[8][8];
UINT8 pichires[8];
UINT16 xcoord[8]; // gfx
UINT16 ycoord[8]; // gfx
UINT16 picduration[8];
UINT8 picmode; // sequence mode after displaying last pic, 0 = persist, 1 = loop, 2 = destroy
UINT8 pictoloop; // if picmode == loop, which pic to loop to?
char picname[MAX_PROMPT_PICS][8];
UINT8 pichires[MAX_PROMPT_PICS];
UINT16 xcoord[MAX_PROMPT_PICS]; // gfx
UINT16 ycoord[MAX_PROMPT_PICS]; // gfx
UINT16 picduration[MAX_PROMPT_PICS];
char musswitch[7];
UINT16 musswitchflags;

View File

@ -1819,7 +1819,7 @@ boolean F_ContinueResponder(event_t *event)
// CUSTOM CUTSCENES
// ==================
static INT32 scenenum, cutnum;
static INT32 picxpos, picypos, picnum, pictime;
static INT32 picxpos, picypos, picnum, pictime, picmode, numpics, pictoloop;
static INT32 textxpos, textypos;
static boolean dofadenow = false, cutsceneover = false;
static boolean runningprecutscene = false, precutresetplayer = false;
@ -2173,6 +2173,16 @@ static void F_AdvanceToNextPage(void)
timetonext = textprompts[cutnum]->page[scenenum].timetonext ? textprompts[cutnum]->page[scenenum].timetonext : TICRATE/10;
F_PreparePageText(textprompts[cutnum]->page[scenenum].text);
// gfx
picnum = 0;
numpics = textprompts[cutnum]->page[scenenum].numpics;
picmode = textprompts[cutnum]->page[scenenum].picmode;
pictoloop = textprompts[cutnum]->page[scenenum].pictoloop - 1;
picxpos = textprompts[cutnum]->page[scenenum].xcoord[picnum];
picypos = textprompts[cutnum]->page[scenenum].ycoord[picnum];
animtimer = pictime = textprompts[cutnum]->page[scenenum].picduration[picnum];
// music change
if (textprompts[cutnum]->page[scenenum].musswitch[0])
S_ChangeMusic(textprompts[cutnum]->page[scenenum].musswitch,
textprompts[cutnum]->page[scenenum].musswitchflags,
@ -2234,6 +2244,16 @@ void F_StartTextPrompt(INT32 promptnum, INT32 pagenum, mobj_t *mo, UINT16 postex
timetonext = textprompts[cutnum]->page[scenenum].timetonext ? textprompts[cutnum]->page[scenenum].timetonext : TICRATE/10;
F_PreparePageText(textprompts[cutnum]->page[scenenum].text);
// gfx
picnum = 0;
numpics = textprompts[cutnum]->page[scenenum].numpics;
picmode = textprompts[cutnum]->page[scenenum].picmode;
pictoloop = textprompts[cutnum]->page[scenenum].pictoloop - 1;
picxpos = textprompts[cutnum]->page[scenenum].xcoord[picnum];
picypos = textprompts[cutnum]->page[scenenum].ycoord[picnum];
animtimer = pictime = textprompts[cutnum]->page[scenenum].picduration[picnum];
// music change
if (textprompts[cutnum]->page[scenenum].musswitch[0])
S_ChangeMusic(textprompts[cutnum]->page[scenenum].musswitch,
textprompts[cutnum]->page[scenenum].musswitchflags,
@ -2297,6 +2317,17 @@ void F_TextPromptDrawer(void)
iconlump = W_CheckNumForName(textprompts[cutnum]->page[scenenum].iconname);
F_GetPageTextGeometry(&pagelines, &rightside, &boxh, &texth, &texty, &namey, &chevrony, &textx, &textr);
// Draw gfx first
if (picnum >= 0 && picnum < numpics && textprompts[cutnum]->page[scenenum].picname[picnum][0] != '\0')
{
if (textprompts[cutnum]->page[scenenum].pichires[picnum])
V_DrawSmallScaledPatch(picxpos, picypos, 0,
W_CachePatchName(textprompts[cutnum]->page[scenenum].picname[picnum], PU_CACHE));
else
V_DrawScaledPatch(picxpos,picypos, 0,
W_CachePatchName(textprompts[cutnum]->page[scenenum].picname[picnum], PU_CACHE));
}
// Draw background
V_DrawPromptBack(boxh, textprompts[cutnum]->page[scenenum].backcolor);
@ -2337,7 +2368,6 @@ void F_TextPromptDrawer(void)
}
// Draw text
// \todo Char-by-char printing, see f_finale.c F_WriteText
V_DrawString(textx, texty, (V_SNAPTOBOTTOM|V_ALLOWLOWERCASE), cutscene_disptext);
// Draw name
@ -2346,7 +2376,7 @@ void F_TextPromptDrawer(void)
V_DrawString(textx, namey, (V_SNAPTOBOTTOM|V_ALLOWLOWERCASE), textprompts[cutnum]->page[scenenum].name);
// Draw chevron
if (promptblockcontrols && !timetonext) // \todo if !CloseTimer
if (promptblockcontrols && !timetonext)
V_DrawString(textr-8, chevrony + (skullAnimCounter/5), (V_SNAPTOBOTTOM|V_YELLOWMAP), "\x1B"); // down arrow
}
@ -2431,4 +2461,32 @@ void F_TextPromptTicker(void)
!F_WriteText())
timetonext = !promptblockcontrols; // never show the chevron if we can't toggle pages
}
// gfx
if (picnum >= 0 && picnum < numpics)
{
if (animtimer <= 0)
{
boolean persistanimtimer = false;
if (picnum < numpics-1 && textprompts[cutnum]->page[scenenum].picname[picnum+1][0] != '\0')
picnum++;
else if (picmode == PROMPT_PIC_LOOP)
picnum = pictoloop;
else if (picmode == PROMPT_PIC_DESTROY)
picnum = -1;
else // if (picmode == PROMPT_PIC_PERSIST)
persistanimtimer = true;
if (!persistanimtimer && picnum >= 0)
{
picxpos = textprompts[cutnum]->page[scenenum].xcoord[picnum];
picypos = textprompts[cutnum]->page[scenenum].ycoord[picnum];
pictime = textprompts[cutnum]->page[scenenum].picduration[picnum];
animtimer = pictime;
}
}
else
animtimer--;
}
}