Simplify minimap code (less options).

This commit is contained in:
Mari the Deer 2022-07-11 19:43:58 +02:00
commit 474b87d01b
6 changed files with 73 additions and 396 deletions

View file

@ -152,7 +152,7 @@ Class SWWMStatusBar : BaseStatusBar
// minimap colors (thats a lot of 'em)
int mm_colorset;
Color mm_backcolor, mm_cdwallcolor, mm_efwallcolor, mm_fdwallcolor, mm_gridcolor, mm_interlevelcolor, mm_intralevelcolor, mm_lockedcolor, mm_notseencolor, mm_portalcolor, mm_secretsectorcolor, mm_secretwallcolor, mm_specialwallcolor, mm_thingcolor, mm_thingcolor_citem, mm_thingcolor_friend, mm_thingcolor_item, mm_thingcolor_monster, mm_thingcolor_ncmonster, mm_thingcolor_shootable, mm_thingcolor_vipitem, mm_thingcolor_missile, mm_tswallcolor, mm_unexploredsecretcolor, mm_wallcolor, mm_xhaircolor, mm_yourcolor;
Color mm_backcolor, mm_cdwallcolor, mm_efwallcolor, mm_fdwallcolor, mm_interlevelcolor, mm_intralevelcolor, mm_lockedcolor, mm_notseencolor, mm_portalcolor, mm_secretsectorcolor, mm_secretwallcolor, mm_specialwallcolor, mm_thingcolor, mm_thingcolor_citem, mm_thingcolor_friend, mm_thingcolor_item, mm_thingcolor_monster, mm_thingcolor_ncmonster, mm_thingcolor_shootable, mm_thingcolor_vipitem, mm_thingcolor_missile, mm_tswallcolor, mm_unexploredsecretcolor, mm_wallcolor, mm_yourcolor;
bool mm_displaylocks;
// deathmatch stuff
@ -1903,7 +1903,6 @@ Class SWWMStatusBar : BaseStatusBar
mm_cdwallcolor = am_cdwallcolor;
mm_efwallcolor = am_efwallcolor;
mm_fdwallcolor = am_fdwallcolor;
mm_gridcolor = am_gridcolor;
mm_interlevelcolor = am_interlevelcolor;
mm_intralevelcolor = am_intralevelcolor;
mm_lockedcolor = am_lockedcolor;
@ -1924,7 +1923,6 @@ Class SWWMStatusBar : BaseStatusBar
mm_tswallcolor = am_tswallcolor;
mm_unexploredsecretcolor = am_unexploredsecretcolor;
mm_wallcolor = am_wallcolor;
mm_xhaircolor = am_xhaircolor;
mm_yourcolor = am_yourcolor;
mm_displaylocks = true;
break;
@ -1934,7 +1932,6 @@ Class SWWMStatusBar : BaseStatusBar
mm_cdwallcolor = "fc fc 00";
mm_efwallcolor = "bc 78 48";
mm_fdwallcolor = "bc 78 48";
mm_gridcolor = "4c 4c 4c";
mm_interlevelcolor = 0;
mm_intralevelcolor = 0;
mm_lockedcolor = "fc fc 00";
@ -1955,7 +1952,6 @@ Class SWWMStatusBar : BaseStatusBar
mm_tswallcolor = "80 80 80";
mm_unexploredsecretcolor = 0;
mm_wallcolor = "fc 00 00";
mm_xhaircolor = "80 80 80";
mm_yourcolor = "ff ff ff";
mm_displaylocks = false;
break;
@ -1965,7 +1961,6 @@ Class SWWMStatusBar : BaseStatusBar
mm_cdwallcolor = "77 73 73";
mm_efwallcolor = "37 3b 5b";
mm_fdwallcolor = "37 3b 5b";
mm_gridcolor = "4c 4c 4c";
mm_interlevelcolor = 0;
mm_intralevelcolor = 0;
mm_lockedcolor = "77 73 73";
@ -1986,7 +1981,6 @@ Class SWWMStatusBar : BaseStatusBar
mm_tswallcolor = "77 73 73";
mm_unexploredsecretcolor = 0;
mm_wallcolor = "c7 ce ce";
mm_xhaircolor = "80 80 80";
mm_yourcolor = "ef ef ef";
mm_displaylocks = false;
break;
@ -1996,7 +1990,6 @@ Class SWWMStatusBar : BaseStatusBar
mm_cdwallcolor = "67 3b 1f";
mm_efwallcolor = "d0 b0 85";
mm_fdwallcolor = "d0 b0 85";
mm_gridcolor = "46 32 10";
mm_interlevelcolor = 0;
mm_intralevelcolor = 0;
mm_lockedcolor = "67 3b 1f";
@ -2017,39 +2010,36 @@ Class SWWMStatusBar : BaseStatusBar
mm_tswallcolor = "58 5d 56";
mm_unexploredsecretcolor = 0;
mm_wallcolor = "4b 32 10";
mm_xhaircolor = "00 00 00";
mm_yourcolor = "ff ff ff";
mm_displaylocks = true;
break;
default:
// swwm
mm_backcolor = swwm_mm_backcolor;
mm_cdwallcolor = swwm_mm_cdwallcolor;
mm_efwallcolor = swwm_mm_efwallcolor;
mm_fdwallcolor = swwm_mm_fdwallcolor;
mm_gridcolor = swwm_mm_gridcolor;
mm_interlevelcolor = swwm_mm_interlevelcolor;
mm_intralevelcolor = swwm_mm_intralevelcolor;
mm_lockedcolor = swwm_mm_lockedcolor;
mm_notseencolor = swwm_mm_notseencolor;
mm_portalcolor = swwm_mm_portalcolor;
mm_secretsectorcolor = swwm_mm_secretsectorcolor;
mm_secretwallcolor = swwm_mm_secretwallcolor;
mm_specialwallcolor = swwm_mm_specialwallcolor;
mm_thingcolor = swwm_mm_thingcolor;
mm_thingcolor_citem = swwm_mm_thingcolor_citem;
mm_thingcolor_friend = swwm_mm_thingcolor_friend;
mm_thingcolor_item = swwm_mm_thingcolor_item;
mm_thingcolor_monster = swwm_mm_thingcolor_monster;
mm_thingcolor_ncmonster = swwm_mm_thingcolor_ncmonster;
mm_thingcolor_shootable = swwm_mm_thingcolor_shootable;
mm_thingcolor_vipitem = swwm_mm_thingcolor_vipitem;
mm_thingcolor_missile = swwm_mm_thingcolor_missile;
mm_tswallcolor = swwm_mm_tswallcolor;
mm_unexploredsecretcolor = swwm_mm_unexploredsecretcolor;
mm_wallcolor = swwm_mm_wallcolor;
mm_xhaircolor = swwm_mm_xhaircolor;
mm_yourcolor = swwm_mm_yourcolor;
mm_backcolor = "10 10 10";
mm_cdwallcolor = "30 50 70";
mm_efwallcolor = "80 a0 c0";
mm_fdwallcolor = "50 70 90";
mm_interlevelcolor = "ff 00 60";
mm_intralevelcolor = "00 60 ff";
mm_lockedcolor = "00 90 80";
mm_notseencolor = "20 20 30";
mm_portalcolor = "40 30 20";
mm_secretsectorcolor = "80 00 ff";
mm_secretwallcolor = "60 40 80";
mm_specialwallcolor = "ff a0 00";
mm_thingcolor = "ff ff ff";
mm_thingcolor_citem = "00 ff ff";
mm_thingcolor_friend = "80 ff a0";
mm_thingcolor_item = "ff c0 00";
mm_thingcolor_monster = "ff 60 40";
mm_thingcolor_ncmonster = "a0 40 20";
mm_thingcolor_shootable = "ff a0 a0";
mm_thingcolor_vipitem = "80 60 ff";
mm_thingcolor_missile = "ff a0 20";
mm_tswallcolor = "30 20 40";
mm_unexploredsecretcolor = "40 00 80";
mm_wallcolor = "c0 e0 ff";
mm_yourcolor = "80 ff 00";
mm_displaylocks = true;
break;
}
@ -2163,108 +2153,6 @@ Class SWWMStatusBar : BaseStatusBar
return true;
}
private void DrawMapGrid( Vector2 basepos )
{
double zoomlevel = SWWMUtility.Lerp(oldminimapzoom,minimapzoom,FracTic);
double zoomview = MAPVIEWDIST*zoomlevel, zoomclip = CLIPDIST*zoomlevel;
Vector2 cpos = SWWMUtility.LerpVector2(players[consoleplayer].Camera.prev.xy,players[consoleplayer].Camera.pos.xy,FracTic);
// find farthest visible southwest grid point from camera position
int maxlines = int(zoomview/64);
Vector2 gpt = (cpos-(zoomview,zoomview))/128;
gpt.x = int(gpt.x)*128;
gpt.y = int(gpt.y)*128;
for ( int i=0; i<maxlines; i++ )
{
Vector2 rv1 = (gpt+(i*128,0))-cpos;
Vector2 rv2 = (gpt+(i*128,maxlines*128))-cpos;
if ( min(min(abs(rv1.x),abs(rv2.x)),min(abs(rv1.y),abs(rv2.y))) > zoomview )
continue;
// flip Y
rv1.y *= -1;
rv2.y *= -1;
// rotate by view
if ( swwm_mm_rotate )
{
rv1 = Actor.RotateVector(rv1,ViewRot.x-90);
rv2 = Actor.RotateVector(rv2,ViewRot.x-90);
}
// clip to frame
bool visible;
[visible, rv1, rv2] = SWWMUtility.LiangBarsky((-1,-1)*zoomclip,(1,1)*zoomclip,rv1,rv2);
if ( !visible ) continue;
// scale to minimap frame
rv1 *= (HALFMAPSIZE/zoomclip)*hs;
rv2 *= (HALFMAPSIZE/zoomclip)*hs;
// offset to minimap center
rv1 += basepos;
rv2 += basepos;
// draw the line
Screen.DrawThickLine(int(rv1.x),int(rv1.y),int(rv2.x),int(rv2.y),max(1.,hs*.25),mm_gridcolor);
}
for ( int i=0; i<maxlines; i++ )
{
Vector2 rv1 = (gpt+(0,i*128))-cpos;
Vector2 rv2 = (gpt+(maxlines*128,i*128))-cpos;
if ( min(min(abs(rv1.x),abs(rv2.x)),min(abs(rv1.y),abs(rv2.y))) > zoomview )
continue;
// flip Y
rv1.y *= -1;
rv2.y *= -1;
// rotate by view
if ( swwm_mm_rotate )
{
rv1 = Actor.RotateVector(rv1,ViewRot.x-90);
rv2 = Actor.RotateVector(rv2,ViewRot.x-90);
}
// clip to frame
bool visible;
[visible, rv1, rv2] = SWWMUtility.LiangBarsky((-1,-1)*zoomclip,(1,1)*zoomclip,rv1,rv2);
if ( !visible ) continue;
// scale to minimap frame
rv1 *= (HALFMAPSIZE/zoomclip)*hs;
rv2 *= (HALFMAPSIZE/zoomclip)*hs;
// offset to minimap center
rv1 += basepos;
rv2 += basepos;
// draw the line
Screen.DrawThickLine(int(rv1.x),int(rv1.y),int(rv2.x),int(rv2.y),max(1.,hs*.25),mm_gridcolor);
}
// draw the origin crosshair
Vector2 tv[4];
tv[0] = (-16,0);
tv[1] = (16,0);
tv[2] = (0,-16);
tv[3] = (0,16);
for ( int i=0; i<4; i+=2 )
{
Vector2 rv1 = tv[i]-cpos;
Vector2 rv2 = tv[i+1]-cpos;
if ( min(min(abs(rv1.x),abs(rv2.x)),min(abs(rv1.y),abs(rv2.y))) > zoomview )
continue;
// flip Y
rv1.y *= -1;
rv2.y *= -1;
// rotate by view
if ( swwm_mm_rotate )
{
rv1 = Actor.RotateVector(rv1,ViewRot.x-90);
rv2 = Actor.RotateVector(rv2,ViewRot.x-90);
}
// clip to frame
bool visible;
[visible, rv1, rv2] = SWWMUtility.LiangBarsky((-1,-1)*zoomclip,(1,1)*zoomclip,rv1,rv2);
if ( !visible ) continue;
// scale to minimap frame
rv1 *= (HALFMAPSIZE/zoomclip)*hs;
rv2 *= (HALFMAPSIZE/zoomclip)*hs;
// offset to minimap center
rv1 += basepos;
rv2 += basepos;
// draw the line
Screen.DrawThickLine(int(rv1.x),int(rv1.y),int(rv2.x),int(rv2.y),max(1.,hs*.75),mm_xhaircolor);
}
}
private void DrawMapLines( Vector2 basepos )
{
double zoomlevel = SWWMUtility.Lerp(oldminimapzoom,minimapzoom,FracTic);
@ -2279,19 +2167,16 @@ Class SWWMStatusBar : BaseStatusBar
continue;
Vector2 rv1 = l.v1.p-cpos, rv2 = l.v2.p-cpos;
bool isportal = false;
if ( swwm_mm_portaloverlay )
Sector linesector;
if ( l.sidedef[0].flags&Side.WALLF_POLYOBJ ) linesector = level.PointInSector(l.v1.p+l.delta/2.);
else linesector = l.frontsector;
isportal = (linesector.portalgroup!=csec.portalgroup);
if ( isportal )
{
Sector linesector;
if ( l.sidedef[0].flags&Side.WALLF_POLYOBJ ) linesector = level.PointInSector(l.v1.p+l.delta/2.);
else linesector = l.frontsector;
isportal = (linesector.portalgroup!=csec.portalgroup);
if ( isportal )
{
// portal displacement
Vector2 pofs = SWWMUtility.PortalDisplacement(csec,linesector);
rv1 -= pofs;
rv2 -= pofs;
}
// portal displacement
Vector2 pofs = SWWMUtility.PortalDisplacement(csec,linesector);
rv1 -= pofs;
rv2 -= pofs;
}
Vector2 mid = (rv1+rv2)/2.;
Vector2 siz = (abs(rv1.x-rv2.x),abs(rv1.y-rv2.y))/2.;
@ -2301,11 +2186,8 @@ Class SWWMStatusBar : BaseStatusBar
rv1.y *= -1;
rv2.y *= -1;
// rotate by view
if ( swwm_mm_rotate )
{
rv1 = Actor.RotateVector(rv1,ViewRot.x-90);
rv2 = Actor.RotateVector(rv2,ViewRot.x-90);
}
rv1 = Actor.RotateVector(rv1,ViewRot.x-90);
rv2 = Actor.RotateVector(rv2,ViewRot.x-90);
// clip to frame
bool visible;
[visible, rv1, rv2] = SWWMUtility.LiangBarsky((-1,-1)*zoomclip,(1,1)*zoomclip,rv1,rv2);
@ -2408,15 +2290,12 @@ Class SWWMStatusBar : BaseStatusBar
{
Vector2 rv = a.pos.xy-cpos;
bool isportal = false;
if ( swwm_mm_portaloverlay )
Sector sec = level.PointInSector(a.pos.xy);
if ( sec.portalgroup != csec.portalgroup )
{
Sector sec = level.PointInSector(a.pos.xy);
if ( sec.portalgroup != csec.portalgroup )
{
isportal = true;
// portal displacement
rv -= SWWMUtility.PortalDisplacement(csec,sec);
}
isportal = true;
// portal displacement
rv -= SWWMUtility.PortalDisplacement(csec,sec);
}
if ( (((radius+zoomview)-abs(rv.x)) <= 0) || (((radius+zoomview)-abs(rv.y)) <= 0) )
continue;
@ -2436,15 +2315,12 @@ Class SWWMStatusBar : BaseStatusBar
}
Vector2 rv = m.pos.xy-cpos;
bool isportal = false;
if ( swwm_mm_portaloverlay )
Sector sec = level.PointInSector(m.pos.xy);
if ( sec.portalgroup != csec.portalgroup )
{
Sector sec = level.PointInSector(m.pos.xy);
if ( sec.portalgroup != csec.portalgroup )
{
isportal = true;
// portal displacement
rv -= SWWMUtility.PortalDisplacement(csec,sec);
}
isportal = true;
// portal displacement
rv -= SWWMUtility.PortalDisplacement(csec,sec);
}
if ( (((radius+zoomview)-abs(rv.x)) <= 0) || (((radius+zoomview)-abs(rv.y)) <= 0) )
continue;
@ -2466,9 +2342,10 @@ Class SWWMStatusBar : BaseStatusBar
double zoomview = MAPVIEWDIST*zoomlevel, zoomclip = CLIPDIST*zoomlevel;
Vector2 cpos = SWWMUtility.LerpVector2(players[consoleplayer].Camera.prev.xy,players[consoleplayer].Camera.pos.xy,FracTic);
Sector csec = players[consoleplayer].Camera.CurSector;
bool drawmissiles = swwm_mm_missiles;
for ( SWWMSimpleTracker t=hnd.strackers; t; t=t.next )
{
if ( !swwm_mm_missiles && t.ismissile ) continue;
if ( !drawmissiles && t.ismissile ) continue;
if ( level.allmap && (t.target is 'Key') ) continue; // don't draw keys over the actual markers they have
Color col = mm_thingcolor;
bool isitem = false;
@ -2510,17 +2387,14 @@ Class SWWMStatusBar : BaseStatusBar
if ( level.allmap && !t.expired && t.target ) mtime += 105;
Vector2 rv = pos-cpos;
bool isportal = false;
if ( swwm_mm_portaloverlay )
Sector sec = level.PointInSector(pos);
if ( sec.portalgroup != csec.portalgroup )
{
Sector sec = level.PointInSector(pos);
if ( sec.portalgroup != csec.portalgroup )
{
isportal = true;
// portal displacement
rv -= SWWMUtility.PortalDisplacement(csec,sec);
// and blend in the color too
col = Color((col.r+mm_portalcolor.r*7)/8,(col.g+mm_portalcolor.g*7)/8,(col.b+mm_portalcolor.b*7)/8);
}
isportal = true;
// portal displacement
rv -= SWWMUtility.PortalDisplacement(csec,sec);
// and blend in the color too
col = Color((col.r+mm_portalcolor.r*7)/8,(col.g+mm_portalcolor.g*7)/8,(col.b+mm_portalcolor.b*7)/8);
}
if ( (((radius+zoomview)-abs(rv.x)) <= 0) || (((radius+zoomview)-abs(rv.y)) <= 0) )
continue;
@ -2561,7 +2435,7 @@ Class SWWMStatusBar : BaseStatusBar
// flip Y
for ( int j=0; j<nidx; j++ ) tv[j].y *= -1;
// rotate by view
if ( swwm_mm_rotate ) for ( int j=0; j<nidx; j++ ) tv[j] = Actor.RotateVector(tv[j],ViewRot.x-90);
for ( int j=0; j<nidx; j++ ) tv[j] = Actor.RotateVector(tv[j],ViewRot.x-90);
bool visible, drawn;
Vector2 x0, x1;
// clip to frame
@ -2614,7 +2488,6 @@ Class SWWMStatusBar : BaseStatusBar
Screen.Dim(mm_backcolor,1.,int((basemappos.x-HALFMAPSIZE)*hs),int((basemappos.y-HALFMAPSIZE)*hs),int(HALFMAPSIZE*2*hs),int(HALFMAPSIZE*2*hs));
Screen.SetClipRect(int((basemappos.x-HALFMAPSIZE)*hs),int((basemappos.y-HALFMAPSIZE)*hs),int(HALFMAPSIZE*2*hs),int(HALFMAPSIZE*2*hs));
// draw dat stuff
if ( swwm_mm_grid ) DrawMapGrid(basemappos*hs);
DrawMapLines(basemappos*hs);
DrawMapThings(basemappos*hs);
DrawMapMarkers(basemappos*hs);
@ -2623,7 +2496,6 @@ Class SWWMStatusBar : BaseStatusBar
tv[0] = (0,-4);
tv[1] = (-3,2);
tv[2] = (3,2);
if ( !swwm_mm_rotate ) for ( int i=0; i<3; i++ ) tv[i] = Actor.RotateVector(tv[i],90-ViewRot.x);
for ( int i=0; i<3; i++ ) tv[i] = (tv[i]+basemappos)*hs;
for ( int i=0; i<3; i++ ) Screen.DrawThickLine(int(tv[i].x),int(tv[i].y),int(tv[(i+1)%3].x),int(tv[(i+1)%3].y),max(1.,hs*.5),mm_yourcolor);
Screen.ClearClipRect();
@ -3282,7 +3154,7 @@ Class SWWMStatusBar : BaseStatusBar
{
double alph = clamp(sin((PulsePhase-FracTic)*12.),0.,1.);
Screen.DrawTexture(HealthTex[6],false,margin+2+ox,ss.y-(margin+20+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowRightF,hw,DTA_Alpha,alph);
Screen.DrawText(MiniHUDFont,mhudfontcol[MCR_REDFLASH],margin+107,ss.y-(margin+20+oy),str,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,alph);
Screen.DrawText(MiniHUDFont,mhudfontcol[MCR_REDFLASH],margin+107+ox,ss.y-(margin+20+oy),str,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,alph);
}
ht = clamp(LagHealthInter.GetValue(fractic),0,1000);
double hwl = min(ht,100);