Menu stuff!

* Bar of levels.
* Colourisation!
* New V_SKYMAP, which hasn't been put in dehacked lists but is otherwise valid!
* New single page statistics screen!
* V_DrawFixedPatch now works at the edge of the screen!

Ghost fixes!
* On minimaps!
* Free memory after use!
* Don't spawn in midair on slopes!
This commit is contained in:
toaster 2018-07-01 19:29:13 +01:00
parent cf6f85a72a
commit 776c66514d
10 changed files with 561 additions and 400 deletions

View file

@ -1487,12 +1487,12 @@ void CV_AddValue(consvar_t *var, INT32 increment)
}
if (newvalue == oldvalue)
gt = -1; // don't loop forever if there's none of a certain gametype
break; // don't loop forever if there's none of a certain gametype
if(!mapheaderinfo[newvalue])
continue; // Don't allocate the header. That just makes memory usage skyrocket.
} while (newvalue != oldvalue && !M_CanShowLevelInList(newvalue, gt));
} while (!M_CanShowLevelInList(newvalue, gt));
var->value = newvalue + 1;
var->func();

View file

@ -139,6 +139,21 @@ static CV_PossibleValue_t backcolor_cons_t[] = {{0, "White"}, {1, "Gray"}, {2,
{0, NULL}};
consvar_t cons_backcolor = {"con_backcolor", "Green", CV_CALL|CV_SAVE, backcolor_cons_t, CONS_backcolor_Change, 0, NULL, NULL, 0, 0, NULL};
static CV_PossibleValue_t menuhighlight_cons_t[] =
{
{0, "Default"},
{V_YELLOWMAP, "Always yellow"},
{V_PURPLEMAP, "Always purple"},
{V_GREENMAP, "Always green"},
{V_BLUEMAP, "Always blue"},
{V_REDMAP, "Always red"},
{V_GRAYMAP, "Always gray"},
{V_ORANGEMAP, "Always orange"},
{V_SKYMAP, "Always sky-blue"},
{0, NULL}
};
consvar_t cons_menuhighlight = {"menuhighlight", "Default", CV_SAVE, menuhighlight_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
static void CON_Print(char *msg);
//
@ -227,13 +242,7 @@ static void CONS_Bind_f(void)
// Font colormap colors
// TODO: This could probably be improved somehow...
// These colormaps are 99% identical, with just a few changed bytes
UINT8 *yellowmap;
UINT8 *purplemap;
UINT8 *lgreenmap;
UINT8 *bluemap;
UINT8 *graymap;
UINT8 *redmap;
UINT8 *orangemap;
UINT8 *yellowmap, *purplemap, *lgreenmap, *bluemap, *graymap, *redmap, *orangemap, *skymap;
// Console BG color
UINT8 *consolebgmap = NULL;
@ -278,39 +287,34 @@ static void CONS_backcolor_Change(void)
static void CON_SetupColormaps(void)
{
INT32 i;
UINT8 *memorysrc = (UINT8 *)Z_Malloc((256*8), PU_STATIC, NULL);
yellowmap = (UINT8 *)Z_Malloc(256, PU_STATIC, NULL);
graymap = (UINT8 *)Z_Malloc(256, PU_STATIC, NULL);
purplemap = (UINT8 *)Z_Malloc(256, PU_STATIC, NULL);
lgreenmap = (UINT8 *)Z_Malloc(256, PU_STATIC, NULL);
bluemap = (UINT8 *)Z_Malloc(256, PU_STATIC, NULL);
redmap = (UINT8 *)Z_Malloc(256, PU_STATIC, NULL);
orangemap = (UINT8 *)Z_Malloc(256, PU_STATIC, NULL);
purplemap = memorysrc;
yellowmap = (purplemap+256);
lgreenmap = (yellowmap+256);
bluemap = (lgreenmap+256);
redmap = (bluemap+256);
graymap = (redmap+256);
orangemap = (graymap+256);
skymap = (orangemap+256);
// setup the other colormaps, for console text
// these don't need to be aligned, unless you convert the
// V_DrawMappedPatch() into optimised asm.
for (i = 0; i < 256; i++)
{
yellowmap[i] = (UINT8)i; // remap each color to itself...
graymap[i] = (UINT8)i;
purplemap[i] = (UINT8)i;
lgreenmap[i] = (UINT8)i;
bluemap[i] = (UINT8)i;
redmap[i] = (UINT8)i;
orangemap[i] = (UINT8)i;
}
for (i = 0; i < (256*8); i++, ++memorysrc)
*memorysrc = (UINT8)(i & 0xFF); // remap each color to itself...
// SRB2Kart: Different console font, new colors
yellowmap[120] = (UINT8)103;
purplemap[120] = (UINT8)194;
yellowmap[120] = (UINT8)103;
lgreenmap[120] = (UINT8)162;
bluemap[120] = (UINT8)228;
graymap[120] = (UINT8)10;
redmap[120] = (UINT8)126;
orangemap[120] = (UINT8)85;
redmap[120] = (UINT8)126; // battle
orangemap[120] = (UINT8)85; // record attack
skymap[120] = (UINT8)215; // race
// Init back colormap
CON_SetupBackColormap();
@ -367,6 +371,7 @@ void CON_Init(void)
CV_RegisterVar(&cons_height);
CV_RegisterVar(&cons_backpic);
CV_RegisterVar(&cons_backcolor);
CV_RegisterVar(&cons_menuhighlight);
COM_AddCommand("bind", CONS_Bind_f);
}
else

View file

@ -36,9 +36,9 @@ extern INT32 con_clearlines; // lines of top of screen to refresh
extern boolean con_hudupdate; // hud messages have changed, need refresh
extern UINT32 con_scalefactor; // console text scale factor
extern consvar_t cons_backcolor;
extern consvar_t cons_backcolor, cons_menuhighlight;
extern UINT8 *yellowmap, *purplemap, *lgreenmap, *bluemap, *graymap, *redmap, *orangemap;
extern UINT8 *yellowmap, *purplemap, *lgreenmap, *bluemap, *graymap, *redmap, *orangemap, *skymap;
// Console bg color (auto updated to match)
extern UINT8 *consolebgmap;

View file

@ -309,13 +309,6 @@ static struct {
// Your naming conventions are stupid and useless.
// There is no conflict here.
typedef struct demoghost {
UINT8 checksum[16];
UINT8 *buffer, *p, color;
UINT16 version;
mobj_t oldmo, *mo;
struct demoghost *next;
} demoghost;
demoghost *ghosts = NULL;
boolean precache = true; // if true, load all graphics at start
@ -3044,6 +3037,7 @@ boolean G_BattleGametype(void)
// G_SometimesGetDifferentGametype
//
// I pity the fool who adds more gametypes later, because it'll require some element of randomisation which needs to be synched...
// Although given this only gets called for the host, you could probably get away with M_Random.
//
INT16 G_SometimesGetDifferentGametype(void)
{
@ -3061,13 +3055,16 @@ INT16 G_SometimesGetDifferentGametype(void)
// G_GetGametypeColor
//
// Pretty and consistent ^u^
// See also M_GetGametypeColor.
//
UINT8 G_GetGametypeColor(INT16 gt)
{
if (modeattacking) // == ATTACKING_RECORD)
return orangemap[120];
if (gt == GT_MATCH)
return 128; // red
return redmap[120];
if (gt == GT_RACE)
return 215; // sky blue
return skymap[120];
return 247; // FALLBACK
}
@ -3980,6 +3977,13 @@ void G_DeferedInitNew(boolean pultmode, const char *mapname, INT32 pickedchar, U
if (demoplayback)
COM_BufAddText("stopdemo\n");
while (ghosts)
{
demoghost *next = ghosts->next;
Z_Free(ghosts);
ghosts = next;
}
ghosts = NULL;
for (i = 0; i < NUMMAPS+1; i++)
@ -4879,6 +4883,7 @@ void G_GhostTicker(void)
p->next = g->next;
else
ghosts = g->next;
Z_Free(g);
continue;
}
p = g;
@ -5821,29 +5826,27 @@ void G_AddGhost(char *defdemoname)
mthing = playerstarts[0];
I_Assert(mthing);
{ // A bit more complex than P_SpawnPlayer because ghosts aren't solid and won't just push themselves out of the ceiling.
fixed_t x,y,z;
sector_t *sector;
x = mthing->x << FRACBITS;
y = mthing->y << FRACBITS;
sector = R_PointInSubsector(x, y)->sector;
fixed_t z,f,c;
gh->mo = P_SpawnMobj(mthing->x << FRACBITS, mthing->y << FRACBITS, 0, MT_GHOST);
gh->mo->angle = FixedAngle(mthing->angle*FRACUNIT);
f = gh->mo->floorz;
c = gh->mo->ceilingz - mobjinfo[MT_PLAYER].height;
if (!!(mthing->options & MTF_AMBUSH) ^ !!(mthing->options & MTF_OBJECTFLIP))
{
z = sector->ceilingheight - mobjinfo[MT_PLAYER].height;
z = c;
if (mthing->options >> ZSHIFT)
z -= ((mthing->options >> ZSHIFT) << FRACBITS);
if (z < sector->floorheight)
z = sector->floorheight;
if (z < f)
z = f;
}
else
{
z = sector->floorheight;
z = f;
if (mthing->options >> ZSHIFT)
z += ((mthing->options >> ZSHIFT) << FRACBITS);
if (z > sector->ceilingheight - mobjinfo[MT_PLAYER].height)
z = sector->ceilingheight - mobjinfo[MT_PLAYER].height;
if (z > c)
z = c;
}
gh->mo = P_SpawnMobj(x, y, z, MT_GHOST);
gh->mo->angle = FixedAngle(mthing->angle*FRACUNIT);
}
gh->mo->state = states+S_KART_STND1; // SRB2kart - was S_PLAY_STND
gh->mo->sprite = gh->mo->state->sprite;
@ -6041,8 +6044,13 @@ boolean G_CheckDemoStatus(void)
{
boolean saved;
if(ghosts) // ... ... ...
ghosts = NULL; // :)
while (ghosts)
{
demoghost *next = ghosts->next;
Z_Free(ghosts);
ghosts = next;
}
ghosts = NULL;
// DO NOT end metal sonic demos here

View file

@ -167,6 +167,17 @@ void G_WriteMetalTic(mobj_t *metal);
void G_SaveMetal(UINT8 **buffer);
void G_LoadMetal(UINT8 **buffer);
// Your naming conventions are stupid and useless.
// There is no conflict here.
typedef struct demoghost {
UINT8 checksum[16];
UINT8 *buffer, *p, color;
UINT16 version;
mobj_t oldmo, *mo;
struct demoghost *next;
} demoghost;
extern demoghost *ghosts;
void G_DoPlayDemo(char *defdemoname);
void G_TimeDemo(const char *name);
void G_AddGhost(char *defdemoname);

View file

@ -4809,7 +4809,7 @@ void K_ReloadSkinIconGraphics(void)
K_LoadIconGraphics(skins[i].iconprefix, i);
}
static void K_drawKartMinimapHead(player_t *player, INT32 x, INT32 y, INT32 flags, patch_t *AutomapPic)
static void K_drawKartMinimapHead(mobj_t *mo, INT32 x, INT32 y, INT32 flags, patch_t *AutomapPic)
{
// amnum xpos & ypos are the icon's speed around the HUD.
// The number being divided by is for how fast it moves.
@ -4818,6 +4818,11 @@ static void K_drawKartMinimapHead(player_t *player, INT32 x, INT32 y, INT32 flag
// am xpos & ypos are the icon's starting position. Withouht
// it, they wouldn't 'spawn' on the top-right side of the HUD.
UINT8 skin = 0;
if (mo->skin)
skin = ((skin_t*)mo->skin)-skins;
fixed_t amnumxpos;
fixed_t amnumypos;
INT32 amxpos;
@ -4861,32 +4866,28 @@ static void K_drawKartMinimapHead(player_t *player, INT32 x, INT32 y, INT32 flag
fixed_t yscale = FixedDiv(AutomapPic->height, mapheight);
fixed_t zoom = FixedMul(min(xscale, yscale), FRACUNIT-FRACUNIT/20);
amnumxpos = (FixedMul(player->mo->x, zoom) - FixedMul(xoffset, zoom));
amnumypos = -(FixedMul(player->mo->y, zoom) - FixedMul(yoffset, zoom));
amnumxpos = (FixedMul(mo->x, zoom) - FixedMul(xoffset, zoom));
amnumypos = -(FixedMul(mo->y, zoom) - FixedMul(yoffset, zoom));
amxpos = amnumxpos + ((x + AutomapPic->width/2 - (iconprefix[player->skin]->width/2))<<FRACBITS);
amypos = amnumypos + ((y + AutomapPic->height/2 - (iconprefix[player->skin]->height/2))<<FRACBITS);
amxpos = amnumxpos + ((x + AutomapPic->width/2 - (iconprefix[skin]->width/2))<<FRACBITS);
amypos = amnumypos + ((y + AutomapPic->height/2 - (iconprefix[skin]->height/2))<<FRACBITS);
if (mirrormode)
{
flags |= V_FLIP;
amxpos = -amnumxpos + ((x + AutomapPic->width/2 + (iconprefix[player->skin]->width/2))<<FRACBITS);
amxpos = -amnumxpos + ((x + AutomapPic->width/2 + (iconprefix[skin]->width/2))<<FRACBITS);
}
if (!player->skincolor) // 'default' color
V_DrawSciencePatch(amxpos, amypos, flags, iconprefix[player->skin], FRACUNIT);
if (!mo->color) // 'default' color
V_DrawSciencePatch(amxpos, amypos, flags, iconprefix[skin], FRACUNIT);
else
{
UINT8 *colormap;
if (player->mo->colorized)
{
colormap = R_GetTranslationColormap(TC_RAINBOW, player->mo->color, 0);
}
if (mo->colorized)
colormap = R_GetTranslationColormap(TC_RAINBOW, mo->color, 0);
else
{
colormap = R_GetTranslationColormap(player->skin, player->mo->color, 0);
}
V_DrawFixedPatch(amxpos, amypos, FRACUNIT, flags, iconprefix[player->skin], colormap);
colormap = R_GetTranslationColormap(skin, mo->color, 0);
V_DrawFixedPatch(amxpos, amypos, FRACUNIT, flags, iconprefix[skin], colormap);
}
}
@ -4950,30 +4951,45 @@ static void K_drawKartMinimap(void)
y -= SHORT(AutomapPic->topoffset);
// Player's tiny icons on the Automap. (drawn opposite direction so player 1 is drawn last in splitscreen)
for (i = MAXPLAYERS-1; i >= 0; i--)
if (ghosts)
{
if (!playeringame[i])
continue;
if (!players[i].mo || players[i].spectator)
continue;
if (!splitscreen && i == displayplayer)
demoghost *g = ghosts;
while (g)
{
dop1later = true; // Do displayplayer later
continue;
K_drawKartMinimapHead(g->mo, x, y, splitflags, AutomapPic);
g = g->next;
}
if (G_BattleGametype() && players[i].kartstuff[k_balloon] <= 0)
continue;
if (players[i].kartstuff[k_hyudorotimer] > 0)
if (!stplyr->mo || stplyr->spectator) // do we need the latter..?
return;
dop1later = true;
}
else
{
for (i = MAXPLAYERS-1; i >= 0; i--)
{
if (!((players[i].kartstuff[k_hyudorotimer] < 1*TICRATE/2
|| players[i].kartstuff[k_hyudorotimer] > hyudorotime-(1*TICRATE/2))
&& !(leveltime & 1)))
if (!playeringame[i])
continue;
if (!players[i].mo || players[i].spectator)
continue;
}
K_drawKartMinimapHead(&players[i], x, y, splitflags, AutomapPic);
if (!splitscreen && i == displayplayer)
{
dop1later = true; // Do displayplayer later
continue;
}
if (G_BattleGametype() && players[i].kartstuff[k_balloon] <= 0)
continue;
if (players[i].kartstuff[k_hyudorotimer] > 0)
{
if (!((players[i].kartstuff[k_hyudorotimer] < 1*TICRATE/2
|| players[i].kartstuff[k_hyudorotimer] > hyudorotime-(1*TICRATE/2))
&& !(leveltime & 1)))
continue;
}
K_drawKartMinimapHead(players[i].mo, x, y, splitflags, AutomapPic);
}
}
if (!dop1later)
@ -4981,7 +4997,7 @@ static void K_drawKartMinimap(void)
splitflags &= ~V_HUDTRANSHALF;
splitflags |= V_HUDTRANS;
K_drawKartMinimapHead(stplyr, x, y, splitflags, AutomapPic);
K_drawKartMinimapHead(stplyr->mo, x, y, splitflags, AutomapPic);
}
static void K_drawBattleFullscreen(void)

File diff suppressed because it is too large Load diff

View file

@ -819,7 +819,7 @@ static void ST_drawLevelTitle(void)
else if (!(mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE))
V_DrawLevelTitle(zonexpos, bary+6, 0, M_GetText("ZONE"));
if (strlen(actnum) > 0)
if (actnum[0])
V_DrawLevelTitle(ttlnumxpos+12, bary+6, 0, actnum);
}

View file

@ -450,21 +450,29 @@ void V_DrawFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_t
y = FixedMul(y,dupy<<FRACBITS);
x >>= FRACBITS;
y >>= FRACBITS;
desttop += (y*vid.width) + x;
// Center it if necessary
if (!(scrn & V_SCALEPATCHMASK))
{
// if it's meant to cover the whole screen, black out the rest
if (x == 0 && FixedMul(SHORT(patch->width)<<FRACBITS, pscale)>>FRACBITS == BASEVIDWIDTH
&& y == 0 && FixedMul(SHORT(patch->height)<<FRACBITS, pscale)>>FRACBITS == BASEVIDHEIGHT)
{
column = (const column_t *)((const UINT8 *)(patch) + LONG(patch->columnofs[0]));
source = (const UINT8 *)(column) + 3;
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, (column->topdelta == 0xff ? 31 : source[0]));
}
if (vid.width != BASEVIDWIDTH * dupx)
{
// dupx adjustments pretend that screen width is BASEVIDWIDTH * dupx,
// so center this imaginary screen
if ((scrn & (V_HORZSCREEN|V_SNAPTOLEFT)) == (V_HORZSCREEN|V_SNAPTOLEFT))
desttop += (vid.width/2 - (BASEVIDWIDTH/2 * dupx));
x += (vid.width/2 - (BASEVIDWIDTH/2 * dupx));
else if (scrn & V_SNAPTORIGHT)
desttop += (vid.width - (BASEVIDWIDTH * dupx));
x += (vid.width - (BASEVIDWIDTH * dupx));
else if (!(scrn & V_SNAPTOLEFT))
desttop += (vid.width - (BASEVIDWIDTH * dupx)) / 2;
x += (vid.width - (BASEVIDWIDTH * dupx)) / 2;
}
if (vid.height != BASEVIDHEIGHT * dupy)
{
@ -476,15 +484,9 @@ void V_DrawFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_t
else if (!(scrn & V_SNAPTOTOP))
desttop += (vid.height - (BASEVIDHEIGHT * dupy)) * vid.width / 2;
}
// if it's meant to cover the whole screen, black out the rest
if (x == 0 && FixedMul(SHORT(patch->width)<<FRACBITS, pscale)>>FRACBITS == BASEVIDWIDTH
&& y == 0 && FixedMul(SHORT(patch->height)<<FRACBITS, pscale)>>FRACBITS == BASEVIDHEIGHT)
{
column = (const column_t *)((const UINT8 *)(patch) + LONG(patch->columnofs[0]));
source = (const UINT8 *)(column) + 3;
V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, (column->topdelta == 0xff ? 31 : source[0]));
}
}
desttop += (y*vid.width) + x;
}
if (pscale != FRACUNIT) // scale width properly
@ -1118,7 +1120,7 @@ void V_DrawFadeConsBack(INT32 plines)
// Gets string colormap, used for 0x80 color codes
//
static const UINT8 *V_GetStringColormap(INT32 colorflags)
const UINT8 *V_GetStringColormap(INT32 colorflags)
{
switch ((colorflags & V_CHARCOLORMASK) >> V_CHARCOLORSHIFT)
{
@ -1136,6 +1138,8 @@ static const UINT8 *V_GetStringColormap(INT32 colorflags)
return graymap;
case 7: // 0x87, orange
return orangemap;
case 8: // 0x88, sky
return skymap;
default: // reset
return NULL;
}

View file

@ -78,6 +78,7 @@ extern UINT8 hudtrans;
#define V_REDMAP 0x00005000
#define V_GRAYMAP 0x00006000
#define V_ORANGEMAP 0x00007000
#define V_SKYMAP 0x00008000
// use bits 17-20 for alpha transparency
#define V_ALPHASHIFT 16
@ -153,6 +154,7 @@ void V_DrawFadeConsBack(INT32 plines);
// draw a single character
void V_DrawCharacter(INT32 x, INT32 y, INT32 c, boolean lowercaseallowed);
const UINT8 *V_GetStringColormap(INT32 colorflags);
void V_DrawLevelTitle(INT32 x, INT32 y, INT32 option, const char *string);