Merge branch 'map-names-everywhere' into 'master'

Map name on pause menu and intermission; current song credit on pause menu; server name in medium font

Closes #769 and #402

See merge request KartKrew/Kart!1892
This commit is contained in:
Oni 2024-02-10 02:14:49 +00:00
commit 0e8f35a5ce
8 changed files with 186 additions and 27 deletions

View file

@ -883,7 +883,7 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum)
void HU_TickSongCredits(void)
{
if (cursongcredit.def == NULL) // No def
if (cursongcredit.text == NULL) // No def
{
cursongcredit.x = cursongcredit.old_x = 0;
cursongcredit.anim = 0;
@ -1991,7 +1991,7 @@ static void HU_DrawDemoInfo(void)
//
void HU_DrawSongCredits(void)
{
if (!cursongcredit.def || cursongcredit.trans >= NUMTRANSMAPS) // No def
if (!cursongcredit.text || cursongcredit.trans >= NUMTRANSMAPS) // No def
{
return;
}

View file

@ -53,6 +53,7 @@
#include "k_grandprix.h" // K_CanChangeRules
#include "k_rank.h" // K_GetGradeColor
#include "k_zvote.h" // K_GetMidVoteLabel
#include "k_boss.h"
#include "y_inter.h" // Y_RoundQueueDrawer
@ -912,8 +913,10 @@ static void M_DrawPausedText(INT32 x)
patch_t *pausebg = W_CachePatchName("M_STRIPU", PU_CACHE);
patch_t *pausetext = W_CachePatchName("M_PAUSET", PU_CACHE);
V_DrawFixedPatch(x, 0, FRACUNIT, V_SNAPTOLEFT|V_SNAPTOTOP|V_ADD, pausebg, NULL);
V_DrawFixedPatch(x, 0, FRACUNIT, V_SNAPTOLEFT|V_SNAPTOTOP, pausetext, NULL);
INT32 snapFlags = menuactive ? 0 : (V_SNAPTOLEFT|V_SNAPTOTOP);
V_DrawFixedPatch(x, -5*FRACUNIT, FRACUNIT, snapFlags|V_ADD, pausebg, NULL);
V_DrawFixedPatch(x, -5*FRACUNIT, FRACUNIT, snapFlags, pausetext, NULL);
}
//
@ -5328,9 +5331,12 @@ void M_DrawPause(void)
INT16 ypos = -50; // Draw 3 items from selected item (y=100 - 3 items spaced by 50 px each... you get the idea.)
INT16 dypos;
fixed_t t = M_DueFrac(pausemenu.openoffset.start, 6);
INT16 offset = menutransition.tics ? floor(pow(2, (double)menutransition.tics)) :
(pausemenu.openoffset.dist ? Easing_InQuad(t, 0, 256) : Easing_OutQuad(t, 256, 0));
fixed_t mt = M_DueFrac(pausemenu.openoffset.start, 6);
if (pausemenu.openoffset.dist)
mt = FRACUNIT - mt;
INT16 offset = menutransition.tics ? floor(pow(2, (double)menutransition.tics)) : Easing_OutQuad(mt, 256, 0);
INT16 arrxpos = 150 + 2*offset; // To draw the background arrow.
INT16 j = 0;
@ -5339,10 +5345,69 @@ void M_DrawPause(void)
patch_t *arrstart = W_CachePatchName("M_PTIP", PU_CACHE);
patch_t *arrfill = W_CachePatchName("M_PFILL", PU_CACHE);
t = M_DueFrac(pausemenu.offset.start, 3);
fixed_t t = M_DueFrac(pausemenu.offset.start, 3);
//V_DrawFadeScreen(0xFF00, 16);
{
INT32 x = Easing_OutQuad(mt, -BASEVIDWIDTH, 0);
INT32 y = 56;
if (g_realsongcredit)
{
V_DrawThinString(x + 2, y, 0, g_realsongcredit);
}
if (gamestate == GS_LEVEL)
{
const char *name = bossinfo.valid && bossinfo.enemyname ?
bossinfo.enemyname : mapheaderinfo[gamemap-1]->menuttl;
char *buf = NULL;
if (!name[0])
{
buf = G_BuildMapTitle(gamemap);
name = buf;
}
INT32 width = V_StringScaledWidth(
FRACUNIT,
FRACUNIT,
FRACUNIT,
0,
MED_FONT,
name
) / FRACUNIT;
y += 11;
V_DrawFill(x + 1, y + 8, width + 20, 3, 31);
V_DrawStringScaled(
(x + 19) * FRACUNIT,
y * FRACUNIT,
FRACUNIT,
FRACUNIT,
FRACUNIT,
V_AQUAMAP,
NULL,
MED_FONT,
name
);
K_DrawMapThumbnail(
(x + 1) * FRACUNIT,
(y - 1) * FRACUNIT,
16 * FRACUNIT,
0,
gamemap - 1,
NULL
);
Z_Free(buf);
}
}
// "PAUSED"
if (!paused && !demo.playback && !modeattacking && !netgame) // as close to possible as P_AutoPause, but not dependent on menuactive
{

View file

@ -60,6 +60,7 @@ void TuneManager::tick()
// Only stop the music credit if the song actually
// changed.
S_StopMusicCredit();
S_UnloadMusicCredit();
}
stop_credit_ = false;
@ -91,6 +92,8 @@ void TuneManager::tick()
adjust_volume();
I_SetSongSpeed(tune->speed());
S_LoadMusicCredit();
if (tune->credit && !tune->resume)
{
S_ShowMusicCredit();

View file

@ -7629,8 +7629,7 @@ static void P_InitLevelSettings(void)
g_quakes = NULL;
// song credit init
Z_Free(cursongcredit.text);
memset(&cursongcredit,0,sizeof(struct cursongcredit));
S_StopMusicCredit();
cursongcredit.trans = NUMTRANSMAPS;
for (i = 0; i < MAXPLAYERS; i++)

View file

@ -1244,6 +1244,7 @@ void S_AttemptToRestoreMusic(void)
musicdef_t *musicdefstart = NULL;
struct cursongcredit cursongcredit; // Currently displayed song credit info
char *g_realsongcredit;
struct soundtest soundtest; // Sound Test (sound test)
static void S_InsertMusicAtSoundTestSequenceTail(const char *musname, UINT16 map, UINT8 altref, musicdef_t ***tail)
@ -2093,11 +2094,11 @@ void S_InitMusicDefs(void)
}
//
// S_ShowMusicCredit
// S_LoadMusicCredit
//
// Display current song's credit on screen
// Load the current song's credit into memory
//
void S_ShowMusicCredit(void)
void S_LoadMusicCredit(void)
{
UINT8 i = 0;
musicdef_t *def = S_FindMusicDef(Music_CurrentSong(), &i);
@ -2107,18 +2108,13 @@ void S_ShowMusicCredit(void)
size_t len = 128, worklen;
INT32 widthused = (3*BASEVIDWIDTH/4) - 7, workwidth;
if (!cv_songcredits.value)
return;
S_UnloadMusicCredit();
if (!def) // No definitions
return;
if (!def->title)
{
// Like showing a blank credit.
S_StopMusicCredit();
return;
}
work = va("\x1F %s", def->title);
worklen = strlen(work);
@ -2166,9 +2162,34 @@ void S_ShowMusicCredit(void)
if (credittext[0] == '\0')
return;
cursongcredit.def = def;
g_realsongcredit = Z_StrDup(credittext);
}
void S_UnloadMusicCredit(void)
{
Z_Free(g_realsongcredit);
g_realsongcredit = NULL;
}
//
// S_ShowMusicCredit
//
// Display current song's credit on screen
//
void S_ShowMusicCredit(void)
{
if (!cv_songcredits.value)
return;
if (!g_realsongcredit)
{
// Like showing a blank credit.
S_StopMusicCredit();
return;
}
Z_Free(cursongcredit.text);
cursongcredit.text = Z_StrDup(credittext);
cursongcredit.text = Z_StrDup(g_realsongcredit);
cursongcredit.anim = 5*TICRATE;
cursongcredit.x = cursongcredit.old_x = 0;
cursongcredit.trans = NUMTRANSMAPS;
@ -2176,7 +2197,8 @@ void S_ShowMusicCredit(void)
void S_StopMusicCredit(void)
{
cursongcredit.def = NULL;
Z_Free(cursongcredit.text);
memset(&cursongcredit,0,sizeof(struct cursongcredit));
}
/// ------------------------

View file

@ -174,9 +174,9 @@ struct musicdef_t
soundtestsequence_t sequence;
};
// For HUD, doesn't always appear
extern struct cursongcredit
{
musicdef_t *def;
char *text;
UINT16 anim;
UINT8 trans;
@ -184,6 +184,9 @@ extern struct cursongcredit
fixed_t old_x;
} cursongcredit;
// For menu, always appears
extern char *g_realsongcredit;
extern struct soundtest
{
UINT8 tune; // Tune used for music system
@ -216,6 +219,8 @@ extern musicdef_t *musicdefstart;
void S_LoadMusicDefs(UINT16 wadnum);
void S_InitMusicDefs(void);
musicdef_t *S_FindMusicDef(const char *name, UINT8 *i);
void S_LoadMusicCredit(void);
void S_UnloadMusicCredit(void);
void S_ShowMusicCredit(void);
void S_StopMusicCredit(void);

View file

@ -1459,10 +1459,19 @@ void ST_DrawServerSplash(boolean timelimited)
fixed_t textX = (BASEVIDWIDTH - 16 - 36) * FRACUNIT;
fixed_t textY = (24 - 8) * FRACUNIT;
V_DrawRightAlignedStringAtFixed(
textX, textY,
fixed_t textW = V_StringScaledWidth(
FRACUNIT, FRACUNIT, FRACUNIT,
(V_SNAPTORIGHT|V_SNAPTOTOP) | opacityFlag,
MED_FONT,
connectedservername
);
V_DrawStringScaled(
textX - textW, textY,
FRACUNIT, FRACUNIT, FRACUNIT,
(V_SNAPTORIGHT|V_SNAPTOTOP) | opacityFlag,
NULL,
MED_FONT,
connectedservername
);

View file

@ -82,6 +82,7 @@ static INT32 replayprompttic;
static fixed_t mqscroll = 0;
static fixed_t chkscroll = 0;
static fixed_t ttlscroll = 0;
intertype_t intertype = int_none;
@ -1523,6 +1524,55 @@ void Y_DrawIntermissionHeader(fixed_t x, fixed_t y, boolean gotthrough, const ch
V_ClearClipRect();
}
static void Y_DrawMapTitleString(fixed_t x, const char *name)
{
V_DrawStringScaled(
x - ttlscroll,
(BASEVIDHEIGHT - 73) * FRACUNIT,
FRACUNIT,
FRACUNIT,
FRACUNIT,
V_SUBTRACT | V_60TRANS,
NULL,
LSHI_FONT,
name
);
}
static fixed_t Y_DrawMapTitle(void)
{
const char *name = bossinfo.valid && bossinfo.enemyname ?
bossinfo.enemyname : mapheaderinfo[prevmap]->menuttl;
char *buf = NULL;
if (!name[0])
{
buf = G_BuildMapTitle(prevmap + 1);
name = buf;
}
fixed_t w = V_StringScaledWidth(
FRACUNIT,
FRACUNIT,
FRACUNIT,
0,
LSHI_FONT,
name
) + (16 * FRACUNIT);
fixed_t x = BASEVIDWIDTH * FRACUNIT;
while (x > -w)
{
Y_DrawMapTitleString(x, name);
x -= w;
}
Z_Free(buf);
return w;
}
//
// Y_IntermissionDrawer
//
@ -1565,6 +1615,8 @@ void Y_IntermissionDrawer(void)
V_DrawFixedPatch(chkscroll, 0, FRACUNIT, V_SUBTRACT, rbgchk, NULL);
V_DrawFixedPatch(chkscroll - chkloop, 0, FRACUNIT, V_SUBTRACT, rbgchk, NULL);
fixed_t ttlloop = Y_DrawMapTitle();
// Animate scrolling elements if relevant
if (!paused && !P_AutoPause())
{
@ -1575,6 +1627,10 @@ void Y_IntermissionDrawer(void)
chkscroll += renderdeltatics;
if (chkscroll > chkloop)
chkscroll %= chkloop;
ttlscroll += renderdeltatics * 2;
if (ttlscroll > ttlloop)
ttlscroll %= ttlloop;
}
if (renderisnewtic)
@ -1618,7 +1674,7 @@ skiptallydrawer:
{
if (speedscramble != -1 && speedscramble != gamespeed)
{
V_DrawCenteredThinString(BASEVIDWIDTH/2, 154, highlightflags|V_SNAPTOBOTTOM,
V_DrawCenteredThinString(BASEVIDWIDTH/2, 154, highlightflags,
va(M_GetText("Next race will be %s Speed!"), kartspeed_cons_t[1+speedscramble].strvalue));
}
}