Backported map marker drawing from common library.
This commit is contained in:
parent
aa881b5cde
commit
b22be796bd
3 changed files with 101 additions and 2 deletions
|
|
@ -1,3 +1,3 @@
|
|||
[default]
|
||||
SWWM_MODVER="\chSWWM \czGZ\c- \cw1.2pre r99 \cu(Wed 29 Dec 13:57:43 CET 2021)\c-";
|
||||
SWWM_SHORTVER="\cw1.2pre r99 \cu(2021-12-29 13:57:43)\c-";
|
||||
SWWM_MODVER="\chSWWM \czGZ\c- \cw1.2pre r100 \cu(Wed 29 Dec 21:41:34 CET 2021)\c-";
|
||||
SWWM_SHORTVER="\cw1.2pre r100 \cu(2021-12-29 21:41:34)\c-";
|
||||
|
|
|
|||
|
|
@ -36,6 +36,10 @@ float[](
|
|||
3.
|
||||
);
|
||||
|
||||
#ifndef BASE_RES
|
||||
#define BASE_RES vec2(640.,400.)
|
||||
#endif
|
||||
|
||||
void SetupMaterial( inout Material mat )
|
||||
{
|
||||
vec2 coord;
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ Class SWWMStatusBar : BaseStatusBar
|
|||
|
||||
SWWMWeaponTooltip ctip;
|
||||
|
||||
transient ThinkerIterator mi; // for map markers
|
||||
double minimapzoom, oldminimapzoom;
|
||||
// minimap constants
|
||||
const CLIPDIST = 800; // clip distance for minimap view, with rotation accounted
|
||||
|
|
@ -1881,6 +1882,99 @@ Class SWWMStatusBar : BaseStatusBar
|
|||
else Screen.DrawThickLine(int(rv1.x),int(rv1.y),int(rv2.x),int(rv2.y),max(1.,hs*.5),col);
|
||||
}
|
||||
}
|
||||
private void DrawMapMarkers( Vector2 basepos )
|
||||
{
|
||||
double zoomlevel = oldminimapzoom*(1.-FracTic)+minimapzoom*FracTic;
|
||||
double zoomview = MAPVIEWDIST*zoomlevel, zoomclip = CLIPDIST*zoomlevel;
|
||||
Vector2 cpos = players[consoleplayer].Camera.prev.xy*(1.-FracTic)+players[consoleplayer].Camera.pos.xy*FracTic;
|
||||
Sector csec = players[consoleplayer].Camera.CurSector;
|
||||
if ( !mi ) mi = ThinkerIterator.Create("MapMarker",Thinker.STAT_MAPMARKER);
|
||||
else mi.Reinit();
|
||||
MapMarker m;
|
||||
while ( m = MapMarker(mi.Next()) )
|
||||
{
|
||||
if ( m.bDORMANT ) continue;
|
||||
if ( m.args[1] && !(m.CurSector.moreflags&Sector.SECMF_DRAWN) ) continue;
|
||||
TextureID tx;
|
||||
if ( m.picnum.IsValid() ) tx = m.picnum;
|
||||
else tx = m.CurState.GetSpriteTexture(1);
|
||||
Vector2 sz = TexMan.GetScaledSize(tx);
|
||||
Vector2 scl;
|
||||
// seems to match automap scaling somewhat
|
||||
if ( m.Args[2] ) scl = (m.Scale/zoomlevel)*.15;
|
||||
else scl = m.Scale*.5;
|
||||
sz.x *= scl.x;
|
||||
sz.y *= scl.y;
|
||||
double radius = max(sz.x,sz.y); // naive, I know
|
||||
if ( m.args[0] )
|
||||
{
|
||||
// oh bother, this will be dicks
|
||||
let ai = level.CreateActorIterator(m.args[0]);
|
||||
Actor a;
|
||||
while ( a = ai.Next() )
|
||||
{
|
||||
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 )
|
||||
{
|
||||
isportal = true;
|
||||
// portal displacement
|
||||
rv -= SWWMUtility.PortalDisplacement(csec,sec);
|
||||
}
|
||||
}
|
||||
if ( min(abs(rv.x)-radius,abs(rv.y)-radius) > zoomview )
|
||||
continue;
|
||||
// flip Y
|
||||
rv.y *= -1;
|
||||
// rotate by view
|
||||
rv = Actor.RotateVector(rv,ViewRot.x-90);
|
||||
// scale to minimap frame
|
||||
rv *= (HALFMAPSIZE/zoomclip)*hs;
|
||||
// offset to minimap center
|
||||
rv += basepos;
|
||||
// draw
|
||||
int clipleft = int((basepos.x-HALFMAPSIZE)*hs);
|
||||
int cliptop = int((basepos.y-HALFMAPSIZE)*hs);
|
||||
int clipright = int(clipleft+HALFMAPSIZE*2*hs);
|
||||
int clipbottom = int(cliptop+HALFMAPSIZE*2*hs);
|
||||
Screen.DrawTexture(tx,false,rv.x,rv.y,DTA_ColorOverlay,isportal?Color(128,mm_portalcolor.r,mm_portalcolor.g,mm_portalcolor.b):Color(0,0,0,0),DTA_ScaleX,hs*scl.x,DTA_ScaleY,hs*scl.y,DTA_LegacyRenderStyle,m.GetRenderStyle(),DTA_Alpha,m.Alpha,DTA_FillColor,m.FillColor,DTA_TranslationIndex,m.Translation,DTA_ClipLeft,clipleft,DTA_ClipTop,cliptop,DTA_ClipRight,clipright,DTA_ClipBottom,clipbottom);
|
||||
}
|
||||
ai.Destroy();
|
||||
continue;
|
||||
}
|
||||
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 )
|
||||
{
|
||||
isportal = true;
|
||||
// portal displacement
|
||||
rv -= SWWMUtility.PortalDisplacement(csec,sec);
|
||||
}
|
||||
}
|
||||
if ( min(abs(rv.x)-radius,abs(rv.y)-radius) > zoomview )
|
||||
continue;
|
||||
// flip Y
|
||||
rv.y *= -1;
|
||||
// rotate by view
|
||||
rv = Actor.RotateVector(rv,ViewRot.x-90);
|
||||
// scale to minimap frame
|
||||
rv *= (HALFMAPSIZE/zoomclip)*hs;
|
||||
// offset to minimap center
|
||||
rv += basepos;
|
||||
// draw
|
||||
int clipleft = int(basepos.x-HALFMAPSIZE*hs);
|
||||
int cliptop = int(basepos.y-HALFMAPSIZE*hs);
|
||||
int clipright = int(clipleft+HALFMAPSIZE*2*hs);
|
||||
int clipbottom = int(cliptop+HALFMAPSIZE*2*hs);
|
||||
Screen.DrawTexture(tx,false,rv.x,rv.y,DTA_ColorOverlay,isportal?Color(128,mm_portalcolor.r,mm_portalcolor.g,mm_portalcolor.b):Color(0,0,0,0),DTA_ScaleX,hs*scl.x,DTA_ScaleY,hs*scl.y,DTA_LegacyRenderStyle,m.GetRenderStyle(),DTA_Alpha,m.Alpha,DTA_FillColor,m.FillColor,DTA_TranslationIndex,m.Translation,DTA_ClipLeft,clipleft,DTA_ClipTop,cliptop,DTA_ClipRight,clipright,DTA_ClipBottom,clipbottom);
|
||||
}
|
||||
}
|
||||
private void DrawMapThings( Vector2 basepos )
|
||||
{
|
||||
bool thesight = !!CPlayer.mo.FindInventory("Omnisight");
|
||||
|
|
@ -2052,6 +2146,7 @@ Class SWWMStatusBar : BaseStatusBar
|
|||
if ( swwm_mm_grid ) DrawMapGrid(basemappos*hs);
|
||||
DrawMapLines(basemappos*hs);
|
||||
DrawMapThings(basemappos*hs);
|
||||
DrawMapMarkers(basemappos*hs);
|
||||
// finally, draw the player arrow
|
||||
Vector2 tv[3];
|
||||
tv[0] = (0,-4);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue