NextTag implementation
* Adjust named tag implementation to be more portable * Next page adjustments
This commit is contained in:
parent
f4ad5ebfba
commit
75c4a96e69
|
@ -1838,6 +1838,8 @@ static void readtextpromptpage(MYFILE *f, INT32 num, INT32 pagenum)
|
||||||
textprompts[num]->page[pagenum].nextprompt = usi;
|
textprompts[num]->page[pagenum].nextprompt = usi;
|
||||||
else if (fastcmp(word, "NEXTPAGE"))
|
else if (fastcmp(word, "NEXTPAGE"))
|
||||||
textprompts[num]->page[pagenum].nextpage = usi;
|
textprompts[num]->page[pagenum].nextpage = usi;
|
||||||
|
else if (fastcmp(word, "NEXTTAG"))
|
||||||
|
strncpy(textprompts[num]->page[pagenum].nexttag, word2, 33);
|
||||||
else if (fastcmp(word, "TIMETONEXT"))
|
else if (fastcmp(word, "TIMETONEXT"))
|
||||||
textprompts[num]->page[pagenum].timetonext = get_number(word2);
|
textprompts[num]->page[pagenum].timetonext = get_number(word2);
|
||||||
else
|
else
|
||||||
|
|
|
@ -211,6 +211,7 @@ typedef struct
|
||||||
sfxenum_t textsfx; // sfx_ id for printing text
|
sfxenum_t textsfx; // sfx_ id for printing text
|
||||||
UINT8 nextprompt; // next prompt to jump to, one-based. 0 = current prompt
|
UINT8 nextprompt; // next prompt to jump to, one-based. 0 = current prompt
|
||||||
UINT8 nextpage; // next page to jump to, one-based. 0 = next page within prompt->numpages
|
UINT8 nextpage; // next page to jump to, one-based. 0 = next page within prompt->numpages
|
||||||
|
char nexttag[33]; // next tag to jump to. If set, this overrides nextprompt and nextpage.
|
||||||
INT32 timetonext; // time in tics to jump to next page automatically. 0 = don't jump automatically
|
INT32 timetonext; // time in tics to jump to next page automatically. 0 = don't jump automatically
|
||||||
char *text;
|
char *text;
|
||||||
} textpage_t;
|
} textpage_t;
|
||||||
|
|
|
@ -2137,26 +2137,32 @@ static void F_PreparePageText(char *pagetext)
|
||||||
|
|
||||||
static void F_AdvanceToNextPage(void)
|
static void F_AdvanceToNextPage(void)
|
||||||
{
|
{
|
||||||
INT32 nextprompt = textprompts[cutnum]->page[scenenum].nextprompt,
|
INT32 nextprompt = textprompts[cutnum]->page[scenenum].nextprompt ? textprompts[cutnum]->page[scenenum].nextprompt - 1 : INT32_MAX,
|
||||||
nextpage = textprompts[cutnum]->page[scenenum].nextpage,
|
nextpage = textprompts[cutnum]->page[scenenum].nextpage ? textprompts[cutnum]->page[scenenum].nextpage - 1 : INT32_MAX,
|
||||||
oldcutnum = cutnum;
|
oldcutnum = cutnum;
|
||||||
|
|
||||||
|
if (textprompts[cutnum]->page[scenenum].nexttag[0])
|
||||||
|
F_GetPromptPageByNamedTag(textprompts[cutnum]->page[scenenum].nexttag, &nextprompt, &nextpage);
|
||||||
|
|
||||||
// determine next prompt
|
// determine next prompt
|
||||||
if (nextprompt)
|
if (nextprompt != INT32_MAX)
|
||||||
{
|
{
|
||||||
if (nextprompt <= MAX_PROMPTS && textprompts[nextprompt-1])
|
if (nextprompt <= MAX_PROMPTS && textprompts[nextprompt])
|
||||||
cutnum = nextprompt-1;
|
cutnum = nextprompt;
|
||||||
else
|
else
|
||||||
cutnum = INT32_MAX;
|
cutnum = INT32_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
// determine next page
|
// determine next page
|
||||||
if (nextpage)
|
if (nextpage != INT32_MAX)
|
||||||
{
|
{
|
||||||
scenenum = nextpage-1;
|
if (nextprompt != INT32_MAX)
|
||||||
|
{
|
||||||
|
scenenum = nextpage;
|
||||||
if (scenenum >= MAX_PAGES || scenenum > textprompts[cutnum]->numpages-1)
|
if (scenenum >= MAX_PAGES || scenenum > textprompts[cutnum]->numpages-1)
|
||||||
scenenum = INT32_MAX;
|
scenenum = INT32_MAX;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (cutnum != oldcutnum)
|
if (cutnum != oldcutnum)
|
||||||
|
@ -2345,41 +2351,43 @@ static boolean F_GetTextPromptTutorialTag(char *tag, INT32 length)
|
||||||
return suffixed;
|
return suffixed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void F_StartTextPromptByNamedTag(char *tag, mobj_t *mo, UINT16 postexectag, boolean blockcontrols, boolean freezerealtime)
|
void F_GetPromptPageByNamedTag(const char *tag, INT32 *promptnum, INT32 *pagenum)
|
||||||
{
|
{
|
||||||
INT32 promptnum, pagenum, nosuffixpromptnum = INT32_MAX, nosuffixpagenum = INT32_MAX;
|
INT32 nosuffixpromptnum = INT32_MAX, nosuffixpagenum = INT32_MAX;
|
||||||
INT32 tutorialpromptnum = (tutorialmode) ? TUTORIAL_PROMPT-1 : 0;
|
INT32 tutorialpromptnum = (tutorialmode) ? TUTORIAL_PROMPT-1 : 0;
|
||||||
boolean suffixed = false, found = false;
|
boolean suffixed = false, found = false;
|
||||||
char suffixedtag[33];
|
char suffixedtag[33];
|
||||||
|
|
||||||
|
*promptnum = *pagenum = INT32_MAX;
|
||||||
|
|
||||||
if (!tag || !tag[0])
|
if (!tag || !tag[0])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
strncpy(suffixedtag, tag, 33);
|
strncpy(suffixedtag, tag, 33);
|
||||||
suffixedtag[32] = 0;
|
suffixedtag[32] = 0;
|
||||||
|
tutorialmode = true;
|
||||||
if (tutorialmode)
|
if (tutorialmode)
|
||||||
suffixed = F_GetTextPromptTutorialTag(suffixedtag, 33);
|
suffixed = F_GetTextPromptTutorialTag(suffixedtag, 33); tutorialmode = false;
|
||||||
|
|
||||||
for (promptnum = 0 + tutorialpromptnum; promptnum < MAX_PROMPTS; promptnum++)
|
for (*promptnum = 0 + tutorialpromptnum; *promptnum < MAX_PROMPTS; (*promptnum)++)
|
||||||
{
|
{
|
||||||
if (!textprompts[promptnum])
|
if (!textprompts[*promptnum])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (pagenum = 0; pagenum < textprompts[promptnum]->numpages && pagenum < MAX_PAGES; pagenum++)
|
for (*pagenum = 0; *pagenum < textprompts[*promptnum]->numpages && *pagenum < MAX_PAGES; (*pagenum)++)
|
||||||
{
|
{
|
||||||
if (suffixed && fastcmp(suffixedtag, textprompts[promptnum]->page[pagenum].tag))
|
if (suffixed && fastcmp(suffixedtag, textprompts[*promptnum]->page[*pagenum].tag))
|
||||||
{
|
{
|
||||||
// this goes first because fastcmp ends early if first string is shorter
|
// this goes first because fastcmp ends early if first string is shorter
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (nosuffixpromptnum == INT32_MAX && nosuffixpagenum == INT32_MAX && fastcmp(tag, textprompts[promptnum]->page[pagenum].tag))
|
else if (nosuffixpromptnum == INT32_MAX && nosuffixpagenum == INT32_MAX && fastcmp(tag, textprompts[*promptnum]->page[*pagenum].tag))
|
||||||
{
|
{
|
||||||
if (suffixed)
|
if (suffixed)
|
||||||
{
|
{
|
||||||
nosuffixpromptnum = promptnum;
|
nosuffixpromptnum = *promptnum;
|
||||||
nosuffixpagenum = pagenum;
|
nosuffixpagenum = *pagenum;
|
||||||
// continue searching for the suffixed tag
|
// continue searching for the suffixed tag
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2397,13 +2405,11 @@ void F_StartTextPromptByNamedTag(char *tag, mobj_t *mo, UINT16 postexectag, bool
|
||||||
if (suffixed && !found && nosuffixpromptnum != INT32_MAX && nosuffixpagenum != INT32_MAX)
|
if (suffixed && !found && nosuffixpromptnum != INT32_MAX && nosuffixpagenum != INT32_MAX)
|
||||||
{
|
{
|
||||||
found = true;
|
found = true;
|
||||||
promptnum = nosuffixpromptnum;
|
*promptnum = nosuffixpromptnum;
|
||||||
pagenum = nosuffixpagenum;
|
*pagenum = nosuffixpagenum;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found)
|
if (!found)
|
||||||
F_StartTextPrompt(promptnum, pagenum, mo, postexectag, blockcontrols, freezerealtime);
|
|
||||||
else
|
|
||||||
CONS_Debug(DBG_GAMELOGIC, "Text prompt: Can't find a page with named tag %s or suffixed tag %s\n", tag, suffixedtag);
|
CONS_Debug(DBG_GAMELOGIC, "Text prompt: Can't find a page with named tag %s or suffixed tag %s\n", tag, suffixedtag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ void F_CutsceneDrawer(void);
|
||||||
void F_EndCutScene(void);
|
void F_EndCutScene(void);
|
||||||
|
|
||||||
void F_StartTextPrompt(INT32 promptnum, INT32 pagenum, mobj_t *mo, UINT16 postexectag, boolean blockcontrols, boolean freezerealtime);
|
void F_StartTextPrompt(INT32 promptnum, INT32 pagenum, mobj_t *mo, UINT16 postexectag, boolean blockcontrols, boolean freezerealtime);
|
||||||
void F_StartTextPromptByNamedTag(char *tag, mobj_t *mo, UINT16 postexectag, boolean blockcontrols, boolean freezerealtime);
|
void F_GetPromptPageByNamedTag(const char *tag, INT32 *promptnum, INT32 *pagenum);
|
||||||
void F_TextPromptDrawer(void);
|
void F_TextPromptDrawer(void);
|
||||||
void F_EndTextPrompt(boolean forceexec, boolean noexec);
|
void F_EndTextPrompt(boolean forceexec, boolean noexec);
|
||||||
boolean F_GetPromptHideHudAll(void);
|
boolean F_GetPromptHideHudAll(void);
|
||||||
|
|
|
@ -3776,11 +3776,13 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
|
||||||
|
|
||||||
if (closetextprompt)
|
if (closetextprompt)
|
||||||
F_EndTextPrompt(false, false);
|
F_EndTextPrompt(false, false);
|
||||||
else if (callbynamedtag && sides[line->sidenum[0]].text && sides[line->sidenum[0]].text[0])
|
|
||||||
F_StartTextPromptByNamedTag(sides[line->sidenum[0]].text, mo, runpostexec ? postexectag : 0, blockcontrols, freezerealtime);
|
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (callbynamedtag && sides[line->sidenum[0]].text && sides[line->sidenum[0]].text[0])
|
||||||
|
F_GetPromptPageByNamedTag(sides[line->sidenum[0]].text, &promptnum, &pagenum);
|
||||||
F_StartTextPrompt(promptnum, pagenum, mo, runpostexec ? postexectag : 0, blockcontrols, freezerealtime);
|
F_StartTextPrompt(promptnum, pagenum, mo, runpostexec ? postexectag : 0, blockcontrols, freezerealtime);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef POLYOBJECTS
|
#ifdef POLYOBJECTS
|
||||||
|
|
Loading…
Reference in New Issue