225 lines
6.8 KiB
Text
225 lines
6.8 KiB
Text
// additional hud things
|
|
|
|
// Press F to Pay Respects
|
|
Class PayRespects : HUDMessageBase
|
|
{
|
|
Vector2 basepos;
|
|
int lifespan, initialspan, starttic;
|
|
transient Font TewiFont;
|
|
double scale;
|
|
Vector2 hs, ss;
|
|
int seed, seed2;
|
|
|
|
static PayRespects PressF()
|
|
{
|
|
let f = new("PayRespects");
|
|
f.basepos = (FRandom[FInTheChat](0.,1.),FRandom[FInTheChat](1.02,1.05));
|
|
f.scale = FRandom[FInTheChat](.5,2.);
|
|
f.lifespan = f.initialspan = Random[FInTheChat](20,80);
|
|
f.starttic = level.maptime;
|
|
f.seed = Random[FInTheChat]();
|
|
f.seed2 = Random[FInTheChat]();
|
|
f.ScreenSizeChanged();
|
|
return f;
|
|
}
|
|
|
|
override bool Tick()
|
|
{
|
|
lifespan--;
|
|
return (lifespan<=0);
|
|
}
|
|
|
|
override void ScreenSizeChanged()
|
|
{
|
|
hs = StatusBar.GetHUDScale()*scale;
|
|
hs.y = hs.x;
|
|
ss = (Screen.GetWidth()/hs.x,Screen.GetHeight()/hs.y);
|
|
}
|
|
|
|
override void Draw( int bottom, int visibility )
|
|
{
|
|
Vector2 realpos = (basepos.x*ss.x,basepos.y*ss.y);
|
|
if ( !TewiFont ) TewiFont = Font.GetFont('TewiShaded');
|
|
Vector2 fo = (TewiFont.StringWidth("F")/2.,-TewiFont.GetHeight());
|
|
// F rise up
|
|
int initspd = (128-seed);
|
|
if ( (initspd >= 0) && (initspd < 32) ) initspd = 32;
|
|
if ( (initspd < 0) && (initspd > -32) ) initspd = -32;
|
|
int boostup = 32+(seed2/4);
|
|
double fractic = SWWMStatusBar(statusbar)?SWWMStatusBar(statusbar).fractic:0;
|
|
fo.x += (.15*initspd)*((initialspan-(lifespan-fractic))**.6);
|
|
fo.y += ((initialspan-(lifespan-fractic))**1.6)-boostup*sin((90./initialspan)*(level.maptime+fractic-starttic));
|
|
double alph = clamp((lifespan+fractic)/double(initialspan),0.,1.);
|
|
Screen.DrawText(TewiFont,Font.CR_GREEN,realpos.x-fo.x,realpos.y-fo.y,"F",DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,alph);
|
|
}
|
|
}
|
|
|
|
// One-liners
|
|
Class SWWMOneLiner : HUDMessageBase
|
|
{
|
|
String whichline;
|
|
int lifespan, curtime;
|
|
transient Font TewiFont, MPlusFont;
|
|
|
|
static SWWMOneLiner Make( String whichline, int lifespan )
|
|
{
|
|
let l = new("SWWMOneLiner");
|
|
l.whichline = whichline;
|
|
l.curtime = l.lifespan = lifespan;
|
|
return l;
|
|
}
|
|
|
|
override bool Tick()
|
|
{
|
|
if ( players[consoleplayer].Health <= 0 ) curtime = int.min;
|
|
curtime--;
|
|
return (curtime<-20);
|
|
}
|
|
|
|
override void Draw( int bottom, int visibility )
|
|
{
|
|
if ( !TewiFont ) TewiFont = Font.GetFont('TewiShaded');
|
|
if ( !MPlusFont ) MPlusFont = Font.GetFont('MPlusShaded');
|
|
int margin = swwm_hudmargin;
|
|
Vector2 hs;
|
|
if ( swwm_hudscale <= 0 ) hs = StatusBar.GetHUDScale();
|
|
else hs.x = swwm_hudscale;
|
|
hs.y = hs.x;
|
|
Vector2 ss = (Screen.GetWidth()/hs.x,Screen.GetHeight()/hs.y);
|
|
String loc = StringTable.Localize(whichline);
|
|
if ( loc.Length() <= 0 ) return; // don't draw empty strings
|
|
String locs = StringTable.Localize("$SWWM_LQUOTE")..loc..StringTable.Localize("$SWWM_RQUOTE");
|
|
Font fnt = TewiFont;
|
|
if ( language ~== "jp" ) fnt = MPlusFont;
|
|
// split so it can fit
|
|
BrokenLines l = fnt.BreakLines(locs,int(ss.x*.5));
|
|
int maxlen = 0;
|
|
for ( int i=0; i<l.Count(); i++ )
|
|
{
|
|
int len = fnt.StringWidth(l.StringAt(i));
|
|
if ( len > maxlen ) maxlen = len;
|
|
}
|
|
int h = fnt.GetHeight();
|
|
int fh = h*l.Count();
|
|
double alph = clamp((curtime/20.)+1.,0.,1.);
|
|
alph *= clamp((lifespan-curtime)/10.,0.,1.);
|
|
Screen.Dim("Black",alph*.8,int((Screen.GetWidth()-(maxlen+12)*hs.x)/2.),int(bottom-(margin+2+fh)*hs.y),int((maxlen+12)*hs.x),int((fh+4)*hs.y));
|
|
int yy = margin+fh;
|
|
for ( int i=0; i<l.Count(); i++ )
|
|
{
|
|
int len = fnt.StringWidth(l.StringAt(i));
|
|
Screen.DrawText(fnt,Font.CR_FIRE,int((ss.x-len)/2.),(bottom/hs.y)-yy,l.StringAt(i),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,alph);
|
|
yy -= h;
|
|
}
|
|
}
|
|
}
|
|
|
|
Class LastLine
|
|
{
|
|
String type;
|
|
int lineno;
|
|
}
|
|
|
|
// Screen flashes from DT
|
|
Class GenericFlash : HUDMessageBase
|
|
{
|
|
Color col;
|
|
int duration;
|
|
double alpha;
|
|
Actor cam;
|
|
|
|
GenericFlash Setup( Actor camera, Color c, int d )
|
|
{
|
|
alpha = 1.0;
|
|
col = c;
|
|
duration = d;
|
|
cam = camera;
|
|
return self;
|
|
}
|
|
override bool Tick()
|
|
{
|
|
if ( duration > 0 ) alpha -= 1./duration;
|
|
return (alpha<=0)||(!cam);
|
|
}
|
|
override void Draw( int bottom, int visibility )
|
|
{
|
|
if ( automapactive || (visibility != BaseStatusBar.HUDMSGLayer_UnderHUD) ) return;
|
|
if ( cam && (players[consoleplayer].camera != cam) ) return;
|
|
Screen.Dim(col,(col.a/255.)*alpha*swwm_flashstrength,0,0,Screen.GetWidth(),Screen.GetHeight());
|
|
}
|
|
}
|
|
|
|
Class QueuedFlash
|
|
{
|
|
Color c;
|
|
int duration;
|
|
int tic;
|
|
Actor cam;
|
|
}
|
|
|
|
// Achievement notification
|
|
Class SWWMAchievementNotification : HUDMessageBase
|
|
{
|
|
String tag, txt;
|
|
int num;
|
|
TextureID icon, frame;
|
|
double tics, holdtics, fadeintics, fadeouttics;
|
|
transient Font tewifont, mplusfont, miniwifont, k6x8font;
|
|
|
|
SWWMAchievementNotification Init( String bname, int bnum = 0 )
|
|
{
|
|
tag = bname.."_TAG";
|
|
txt = bname.."_TXT";
|
|
num = bnum;
|
|
icon = TexMan.CheckForTexture(StringTable.Localize(bname.."_PIC"),TexMan.Type_Any);
|
|
// fallback icon
|
|
if ( !icon.IsValid() ) icon = TexMan.CheckForTexture("graphics/Achievements/AchievementNone.png",TexMan.Type_Any);
|
|
frame = TexMan.CheckForTexture("graphics/HUD/AchievementNotification.png",TexMan.Type_Any);
|
|
holdtics = 150;
|
|
fadeintics = 20;
|
|
fadeouttics = 30;
|
|
tics = 0;
|
|
return self;
|
|
}
|
|
|
|
override bool Tick()
|
|
{
|
|
return (++tics > holdtics+fadeintics+fadeouttics);
|
|
}
|
|
|
|
override void Draw( int bottom, int visibility )
|
|
{
|
|
if ( !tewifont ) tewifont = Font.GetFont('TewiShaded');
|
|
if ( !mplusfont ) mplusfont = Font.GetFont('MPlusShaded');
|
|
if ( !miniwifont ) miniwifont = Font.GetFont('MiniwiShaded');
|
|
if ( !k6x8font ) k6x8font = Font.GetFont('k6x8Shaded');
|
|
let fnt = tewifont;
|
|
let fnt2 = miniwifont;
|
|
if ( language ~== "jp" )
|
|
{
|
|
fnt = mplusfont;
|
|
fnt2 = k6x8font;
|
|
}
|
|
double margin = swwm_hudmargin;
|
|
Vector2 hs;
|
|
if ( swwm_hudscale <= 0 ) hs = StatusBar.GetHUDScale();
|
|
else hs.x = swwm_hudscale;
|
|
Vector2 ss = (Screen.GetWidth()/hs.x,Screen.GetHeight()/hs.y);
|
|
double alpha = (tics<fadeintics)?(tics/fadeintics):(tics<(fadeintics+holdtics))?1.:(1.-(tics-(fadeintics+holdtics))/fadeouttics);
|
|
Vector2 pos = (int(ss.x-232)/2,(ss.y-(margin+36))+int(margin+40)*(1.-alpha));
|
|
String loctag = StringTable.Localize(tag);
|
|
String loctxt = num?String.Format(StringTable.Localize(txt),num):StringTable.Localize(txt);
|
|
BrokenLines l = fnt2.BreakLines(loctxt,176);
|
|
int th = 14+(9*l.Count());
|
|
Screen.DrawTexture(frame,false,pos.x,pos.y,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,alpha);
|
|
if ( icon.IsValid() ) Screen.DrawTexture(icon,false,pos.x+2,pos.y+2,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,alpha);
|
|
int yy = 2+(32-th)/2;
|
|
Screen.DrawText(fnt,Font.CR_GREEN,pos.x+40,pos.y+yy,loctag,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,alpha);
|
|
yy += 14;
|
|
for ( int i=0; i<l.Count(); i++ )
|
|
{
|
|
Screen.DrawText(fnt2,Font.CR_WHITE,pos.x+46,pos.y+yy,l.StringAt(i),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,alpha);
|
|
yy += 9;
|
|
}
|
|
}
|
|
}
|