Merge remote-tracking branch 'origin/Saturn-Next' into Saturn-Next

This commit is contained in:
Alug committed 2025-07-18 14:12:37 +02:00
commit 74255ce5d3
3 files changed
+74 -48

No files matched your search

+26 -48
View File
@@ -6295,6 +6295,8 @@ static boolean M_AddonsRefresh(void)
return false;
}
static tic_t addons_scrolltic = 0; // maybe not the best place but e
static void M_DrawAddons(void)
{
INT32 x, y;
@@ -6302,6 +6304,8 @@ static void M_DrawAddons(void)
const UINT8 *flashcol = NULL;
UINT8 hilicol;
if (renderisnewtic) addons_scrolltic++;
// hack - need to refresh at end of frame to handle addfile...
if (refreshdirmenu & M_AddonsRefresh())
{
@@ -6385,6 +6389,9 @@ static void M_DrawAddons(void)
for (; i < m; i++)
{
UINT32 flags = V_ALLOWLOWERCASE;
#define MAXADDONNAME 31
char scrollbuf[MAXADDONNAME+1] = {0};
if (y > BASEVIDHEIGHT) break;
if (dirmenu[i])
#define type (UINT8)(dirmenu[i][DIR_TYPE])
@@ -6405,11 +6412,22 @@ static void M_DrawAddons(void)
}
#define charsonside 14
if (dirmenu[i][DIR_LEN] > (charsonside*2 + 3))
V_DrawString(x, y+4, flags, va("%.*s...%s", charsonside, dirmenu[i]+DIR_STRING, dirmenu[i]+DIR_STRING+dirmenu[i][DIR_LEN]-(charsonside+1)));
if (dirmenu[i][DIR_LEN] > MAXADDONNAME)
{
if ((size_t)i == dir_on[menudepthleft])
{
M_ScrollString(dirmenu[i]+DIR_STRING, dirmenu[i][DIR_LEN]-1, scrollbuf, MAXADDONNAME, addons_scrolltic);
}
else
strncpy(scrollbuf, va("%.*s...%s", charsonside, dirmenu[i]+DIR_STRING, dirmenu[i]+DIR_STRING+dirmenu[i][DIR_LEN]-(charsonside+1)), MAXADDONNAME);
V_DrawString(x, y+4, flags, scrollbuf);
}
#undef charsonside
else
V_DrawString(x, y+4, flags, dirmenu[i]+DIR_STRING);
#undef MAXADDONNAME
}
#undef type
y += 16;
@@ -6534,11 +6552,13 @@ static void M_HandleAddons(INT32 choice)
case KEY_DOWNARROW:
if (dir_on[menudepthleft] < sizedirmenu-1)
dir_on[menudepthleft]++;
addons_scrolltic = 0;
S_StartSound(NULL, sfx_menu1);
break;
case KEY_UPARROW:
if (dir_on[menudepthleft])
dir_on[menudepthleft]--;
addons_scrolltic = 0;
S_StartSound(NULL, sfx_menu1);
break;
case KEY_PGDN:
@@ -6547,6 +6567,7 @@ static void M_HandleAddons(INT32 choice)
for (i = numaddonsshown; i && (dir_on[menudepthleft] < sizedirmenu-1); i--)
dir_on[menudepthleft]++;
}
addons_scrolltic = 0;
S_StartSound(NULL, sfx_menu1);
break;
case KEY_PGUP:
@@ -6555,6 +6576,7 @@ static void M_HandleAddons(INT32 choice)
for (i = numaddonsshown; i && (dir_on[menudepthleft]); i--)
dir_on[menudepthleft]--;
}
addons_scrolltic = 0;
S_StartSound(NULL, sfx_menu1);
break;
case KEY_ENTER:
@@ -6694,6 +6716,7 @@ static void M_HandleAddons(INT32 choice)
case KEY_ESCAPE:
exitmenu = true;
addons_scrolltic = 0;
break;
default:
@@ -8460,51 +8483,6 @@ static musicdef_t *curplaying = NULL;
static INT32 st_sel = 0;
static tic_t st_musictime = 0;
static void scrollMusicName(const char name[], size_t len, size_t maxlen, char result[])
{
// How much should we scroll. Not sure why +1 is needed, but without it this function skips 2
// characters at once sometimes
const size_t amount = len - maxlen + 1;
// Note: anything above 17 will cause zero division
const size_t MAXSPEED = 6;
const size_t t = st_musictime / (35/min(amount, MAXSPEED));
const size_t state = (t / amount) % 4;
switch (state)
{
// Show beginning of the name
case 0:
memcpy(result, name, maxlen-1);
break;
// Scroll towards end of the name
case 1:
{
const size_t advance = t % amount;
memcpy(result, name+advance, maxlen-1);
}
break;
// Show end of the name
case 2:
memcpy(result, name+len+1-maxlen, maxlen-1);
break;
// Scroll towards start of the name
case 3:
{
const size_t advance = t % amount;
memcpy(result, name+len+1-maxlen-advance, maxlen-1);
}
break;
}
// Technically not necessary, since it gets set again after function call, but just in case
result[maxlen] = 0;
}
static void M_MusicTest(INT32 choice)
{
(void)choice;
@@ -8646,7 +8624,7 @@ static void M_DrawMusicTest(void)
char buf[MAXLENGTH+1];
if (t == st_sel && namelength > MAXLENGTH)
scrollMusicName(songname, namelength, MAXLENGTH, buf);
M_ScrollString(songname, namelength, buf, MAXLENGTH, st_musictime);
else
strncpy(buf, songname, MAXLENGTH);
buf[MAXLENGTH] = 0;
+46
View File
@@ -1604,6 +1604,52 @@ boolean M_ScreenshotResponder(event_t *ev)
return true;
}
void M_ScrollString(const char name[], size_t len, char result[], size_t maxlen, tic_t timer)
{
// How much should we scroll. Not sure why +1 is needed, but without it this function skips 2
// characters at once sometimes
const size_t amount = len - maxlen + 1;
// Note: anything above 17 will cause zero division
const size_t MAXSPEED = 6;
const tic_t t = timer / (35/min(amount, MAXSPEED));
const size_t state = (t / amount) % 4;
switch (state)
{
// Show beginning of the name
case 0:
memcpy(result, name, maxlen-1);
break;
// Scroll towards end of the name
case 1:
{
const size_t advance = t % amount;
memcpy(result, name+advance, maxlen-1);
}
break;
// Show end of the name
case 2:
memcpy(result, name+len+1-maxlen, maxlen-1);
break;
// Scroll towards start of the name
case 3:
{
const size_t advance = t % amount;
memcpy(result, name+len+1-maxlen-advance, maxlen-1);
}
break;
}
// Technically not necessary, since it gets set again after function call, but just in case
result[maxlen] = 0;
}
void M_MinimapGenerate(void)
{
#ifdef USE_PNG
+2
View File
@@ -73,6 +73,8 @@ void M_ScreenShot(void);
void M_DoScreenShot(void);
boolean M_ScreenshotResponder(event_t *ev);
void M_ScrollString(const char name[], size_t len, char result[], size_t maxlen, tic_t timer);
void M_MinimapGenerate(void);
void Command_SaveConfig_f(void);