From aa2921e67e6d4ee935e6c497689dc15b2dc470f1 Mon Sep 17 00:00:00 2001 From: Marisa the Magician Date: Sat, 25 Nov 2023 22:56:24 +0100 Subject: [PATCH] Some ultrawide accommodations. --- language.version | 4 +- zscript/handler/swwm_handler_vanillaboss.zsc | 2 +- zscript/hud/swwm_hud.zsc | 9 ++- zscript/hud/swwm_hud_inventory.zsc | 10 +-- zscript/hud/swwm_hud_messages.zsc | 14 ++--- zscript/hud/swwm_hud_status.zsc | 64 ++++++++++---------- zscript/hud/swwm_hud_topstuff.zsc | 12 ++-- zscript/hud/swwm_hud_weapons.zsc | 18 +++--- zscript/hud/swwm_hudextra.zsc | 24 +++++--- 9 files changed, 83 insertions(+), 74 deletions(-) diff --git a/language.version b/language.version index 813b4fd00..e8f9ae059 100644 --- a/language.version +++ b/language.version @@ -1,3 +1,3 @@ [default] -SWWM_MODVER="\cyDEMOLITIONIST \cw1.3pre r1018 \cu(Sat 25 Nov 17:23:23 CET 2023)\c-"; -SWWM_SHORTVER="\cw1.3pre r1018 \cu(2023-11-25 17:23:23)\c-"; +SWWM_MODVER="\cyDEMOLITIONIST \cw1.3pre r1019 \cu(Sat 25 Nov 22:56:24 CET 2023)\c-"; +SWWM_SHORTVER="\cw1.3pre r1019 \cu(2023-11-25 22:56:24)\c-"; diff --git a/zscript/handler/swwm_handler_vanillaboss.zsc b/zscript/handler/swwm_handler_vanillaboss.zsc index 0d51555bb..fb663ce1e 100644 --- a/zscript/handler/swwm_handler_vanillaboss.zsc +++ b/zscript/handler/swwm_handler_vanillaboss.zsc @@ -564,7 +564,7 @@ extend Class SWWMHandler if ( !bbar_f ) bbar_f = TexMan.CheckForTexture("graphics/HUD/BossHealthBarBox.png"); if ( !bbar_r ) bbar_r = TexMan.CheckForTexture("graphics/HUD/BossHealthBar.png"); if ( !bbar_d ) bbar_d = TexMan.CheckForTexture("graphics/HUD/BossHealthBarDecay.png"); - Vector2 vpos = ((bar.ss.x-300)/2.,bar.ss.y-(bar.margin+50)); + Vector2 vpos = ((bar.ss.x-300)/2.,bar.ss.y-(bar.ymargin+50)); Screen.DrawTexture(bbar_f,false,vpos.x-2,vpos.y-2,DTA_VirtualWidthF,bar.ss.x,DTA_VirtualHeightF,bar.ss.y,DTA_KeepRatio,true,DTA_Alpha,bossalpha); if ( hmax ) { diff --git a/zscript/hud/swwm_hud.zsc b/zscript/hud/swwm_hud.zsc index b04cca798..c6d9d22c6 100644 --- a/zscript/hud/swwm_hud.zsc +++ b/zscript/hud/swwm_hud.zsc @@ -105,7 +105,7 @@ Class SWWMStatusBar : BaseStatusBar double hs0, hs1, hs2; Vector2 ss; Vector2 ss0, ss1, ss2; - int margin; + int ymargin, xmargin; double FracTic; double FrameTime; double PrevFrame; @@ -632,7 +632,7 @@ Class SWWMStatusBar : BaseStatusBar if ( swwm_hudscale < 0 ) hs = max(min(floor(Screen.GetWidth()/480.),floor(Screen.GetHeight()/270.)),1.); else hs = max(min(floor(Screen.GetWidth()/640.),floor(Screen.GetHeight()/360.)),1.); ss = (Screen.GetWidth()/hs,Screen.GetHeight()/hs); - margin = clamp(swwm_hudmargin,0,10); + ymargin = clamp(swwm_hudmargin,0,10); hs0 = hs; hs1 = max(hs-1.,1.); hs2 = max(hs-2.,1.); @@ -659,6 +659,9 @@ Class SWWMStatusBar : BaseStatusBar hs2 = swwm_hudscale2; ss2 = (Screen.GetWidth()/hs2,Screen.GetHeight()/hs2); } + // calculate margin for ultrawide screens, mostly so hud + // elements don't get too spread out + xmargin = ymargin+max(int(ss.x-ss.y/.5625)/2,0); FracTic = TicFrac; if ( (players[consoleplayer].Camera is 'Demolitionist') && (state <= HUD_Fullscreen) ) { @@ -675,7 +678,7 @@ Class SWWMStatusBar : BaseStatusBar if ( state == HUD_AltHud ) { String str = StringTable.Localize("$SWWM_WARNALTHUD"); - Screen.DrawText(NewSmallFont,Font.CR_RED,(ss.x-NewSmallFont.StringWidth(str))/2,margin,str,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true); + Screen.DrawText(NewSmallFont,Font.CR_RED,(ss.x-NewSmallFont.StringWidth(str))/2,ymargin,str,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true); } PrevFrame = CurFrame; } diff --git a/zscript/hud/swwm_hud_inventory.zsc b/zscript/hud/swwm_hud_inventory.zsc index 97bd254a3..928b25992 100644 --- a/zscript/hud/swwm_hud_inventory.zsc +++ b/zscript/hud/swwm_hud_inventory.zsc @@ -48,8 +48,8 @@ extend Class SWWMStatusBar { int invy = 61; // active items (armor / powerups) - double xx = margin+2; - double yy = ss.y-(margin+invy+9); + double xx = xmargin+2; + double yy = ss.y-(ymargin+invy+9); bool drewarmor = false; for ( Inventory i=CPlayer.mo.Inv; i; i=i.Inv ) { @@ -58,7 +58,7 @@ extend Class SWWMStatusBar yy -= 34; drewarmor = true; } - yy = ss.y-(margin+invy+9); + yy = ss.y-(ymargin+invy+9); if ( drewarmor ) { xx += 36; @@ -115,8 +115,8 @@ extend Class SWWMStatusBar DrawInvIcon(next[1],xx+70,yy+2,1./3.); return; } - Screen.DrawTexture(InventoryTex,false,margin+36,ss.y-(margin+invy+2),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true); - DrawInvIcon(CPlayer.mo.InvSel,margin+38,ss.y-(margin+invy),selected:true); + Screen.DrawTexture(InventoryTex,false,xmargin+36,ss.y-(ymargin+invy+2),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true); + DrawInvIcon(CPlayer.mo.InvSel,xmargin+38,ss.y-(ymargin+invy),selected:true); } override void DrawPowerups() diff --git a/zscript/hud/swwm_hud_messages.zsc b/zscript/hud/swwm_hud_messages.zsc index ee344fbd3..97b8f00ab 100644 --- a/zscript/hud/swwm_hud_messages.zsc +++ b/zscript/hud/swwm_hud_messages.zsc @@ -237,7 +237,7 @@ extend Class SWWMStatusBar PickupQueue.Delete(i); break; } - m.UpdateText(int(ss.x*.75)); + m.UpdateText(int(min(ss.x,ss.y/.5625)*.75)); PickupQueue.Push(m); } else @@ -285,7 +285,7 @@ extend Class SWWMStatusBar if ( (ntagstr != "") && (tagtime > 0) ) { nalph = clamp(tagtime/20.,0.,1.); - yy = ss.y-(margin+50); + yy = ss.y-(ymargin+50); // shift up if boss healthbar is present if ( hnd && (hnd.bossalpha > 0.) ) yy -= int(40*clamp(hnd.bossalpha*2.,0.,1.)); int len = mSmallFont.StringWidth(ntagstr); @@ -296,14 +296,14 @@ extend Class SWWMStatusBar if ( PickupQueue.Size() <= 0 ) return; // reverse order since they're drawn bottom to top int mend = max(0,PickupQueue.Size()-MAXPICKUP); - yy = ss.y-(margin+50); + yy = ss.y-(ymargin+50); // shift up if boss healthbar is present if ( hnd && (hnd.bossalpha > 0.) ) yy -= int(40*clamp(hnd.bossalpha*2.,0.,1.)); // shift up again if nametag is present if ( nalph > 0. ) yy -= int((mSmallFont.GetHeight()+6)*clamp(nalph*2.,0.,1.)); for ( int i=PickupQueue.Size()-1; i>=mend; i-- ) { - PickupQueue[i].UpdateText(int(ss.x*.75)); + PickupQueue[i].UpdateText(int(min(ss.x,ss.y/.5625)*.75)); double curtime = (PickupQueue[i].tic+GameTicRate*PICKDURATION)-(level.totaltime+fractic); double alph = clamp(curtime/20.,0.,1.); let l = PickupQueue[i].l; @@ -339,7 +339,7 @@ extend Class SWWMStatusBar if ( !midl || (midsz != int(ss.x*ssp)) ) { if ( midl ) midl.Destroy(); - midl = mSmallFont.BreakLines(midstr,int(ss.x*ssp)); + midl = mSmallFont.BreakLines(midstr,int(min(ss.x,ss.y/.5625)*ssp)); } int h = mSmallFont.GetHeight(); int maxlen = 0; @@ -358,8 +358,8 @@ extend Class SWWMStatusBar } if ( MainQueue.Size() <= 0 ) return; int mstart = max(0,MainQueue.Size()-((chatopen>=gametic)?MAXSHOWNBIG:MAXSHOWN)); - xx = margin; - yy = margin; + xx = xmargin; + yy = ymargin; bool smol = (ss.x<640); Screen.DrawTexture(ChatTex[smol?3:0],false,xx,yy,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,boxalph); yy += 2; diff --git a/zscript/hud/swwm_hud_status.zsc b/zscript/hud/swwm_hud_status.zsc index 060eb6a0a..d5fa6985e 100644 --- a/zscript/hud/swwm_hud_status.zsc +++ b/zscript/hud/swwm_hud_status.zsc @@ -115,23 +115,23 @@ extend Class SWWMStatusBar { int facecol = CVar.GetCVar('swwm_tagcolor',CPlayer).GetInt(); if ( (facecol < 0) || (facecol > 15) ) facecol = 0; - Screen.DrawTexture(FaceTex[0],false,margin+shake.x,ss.y-(margin+32)+shake.y,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_SrcWidth,32,DTA_SrcHeight,32,DTA_DestWidth,32,DTA_DestHeight,32,DTA_SrcX,32*(facecol%4),DTA_SrcY,32*(facecol/4)); + Screen.DrawTexture(FaceTex[0],false,xmargin+shake.x,ss.y-(ymargin+32)+shake.y,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_SrcWidth,32,DTA_SrcHeight,32,DTA_DestWidth,32,DTA_DestHeight,32,DTA_SrcX,32*(facecol%4),DTA_SrcY,32*(facecol/4)); bool raging = CPlayer.mo.FindInventory("RagekitPower"); bool angy = CPlayer.mo.FindInventory("AngeryPower"); - if ( raging && angy ) Screen.DrawTexture(FaceTex[16],false,margin+shake.x,ss.y-(margin+32)+shake.y,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true); - else if ( raging ) Screen.DrawTexture(FaceTex[15],false,margin+shake.x,ss.y-(margin+32)+shake.y,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true); - else if ( angy ) Screen.DrawTexture(FaceTex[13],false,margin+shake.x,ss.y-(margin+32)+shake.y,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true); - Screen.DrawTexture(FaceTex[1],false,margin+shake.x,ss.y-(margin+32)+shake.y,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Color,Color(255,255,0,0),DTA_Alpha,min(1.,noiz)); + if ( raging && angy ) Screen.DrawTexture(FaceTex[16],false,xmargin+shake.x,ss.y-(ymargin+32)+shake.y,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true); + else if ( raging ) Screen.DrawTexture(FaceTex[15],false,xmargin+shake.x,ss.y-(ymargin+32)+shake.y,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true); + else if ( angy ) Screen.DrawTexture(FaceTex[13],false,xmargin+shake.x,ss.y-(ymargin+32)+shake.y,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true); + Screen.DrawTexture(FaceTex[1],false,xmargin+shake.x,ss.y-(ymargin+32)+shake.y,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Color,Color(255,255,0,0),DTA_Alpha,min(1.,noiz)); if ( (CPlayer.Health > 0) && (isInvulnerable() || CPlayer.mo.FindInventory("InvinciballPower")) ) - Screen.DrawTexture(FaceTex[1],false,margin+shake.x,ss.y-(margin+32)+shake.y,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,.8+.1*sin(gametic+fractic)); + Screen.DrawTexture(FaceTex[1],false,xmargin+shake.x,ss.y-(ymargin+32)+shake.y,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,.8+.1*sin(gametic+fractic)); } else { - Screen.DrawTexture(FaceTex[0],false,margin+shake.x,ss.y-(margin+32)+shake.y,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_SrcWidth,32,DTA_SrcHeight,32,DTA_DestWidth,32,DTA_DestHeight,32,DTA_FillColor,Color(0,0,0),DTA_Alpha,.25*(1.-min(1.,noiz))); - Screen.DrawTexture(FaceTex[1],false,margin+shake.x,ss.y-(margin+32)+shake.y,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_FillColor,Color(255,0,0),DTA_Alpha,.25*min(1.,noiz)); + Screen.DrawTexture(FaceTex[0],false,xmargin+shake.x,ss.y-(ymargin+32)+shake.y,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_SrcWidth,32,DTA_SrcHeight,32,DTA_DestWidth,32,DTA_DestHeight,32,DTA_FillColor,Color(0,0,0),DTA_Alpha,.25*(1.-min(1.,noiz))); + Screen.DrawTexture(FaceTex[1],false,xmargin+shake.x,ss.y-(ymargin+32)+shake.y,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_FillColor,Color(255,0,0),DTA_Alpha,.25*min(1.,noiz)); } - Screen.DrawTexture(FaceTex[GetFaceTex(demo)],false,margin+shake.x,ss.y-(margin+32)+shake.y,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true); - if ( CPlayer.mo.FindInventory("BarrierPower") ) Screen.DrawTexture(FaceTex[14],false,margin+shake.x,ss.y-(margin+32)+shake.y,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,.5,DTA_LegacyRenderStyle,STYLE_Add); + Screen.DrawTexture(FaceTex[GetFaceTex(demo)],false,xmargin+shake.x,ss.y-(ymargin+32)+shake.y,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true); + if ( CPlayer.mo.FindInventory("BarrierPower") ) Screen.DrawTexture(FaceTex[14],false,xmargin+shake.x,ss.y-(ymargin+32)+shake.y,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,.5,DTA_LegacyRenderStyle,STYLE_Add); } private void DrawStatus() @@ -139,7 +139,7 @@ extend Class SWWMStatusBar DrawMugshot(); int ox = 36; int oy = 5; - Screen.DrawTexture(StatusTex,false,margin+ox,ss.y-(margin+22+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true); + Screen.DrawTexture(StatusTex,false,xmargin+ox,ss.y-(ymargin+22+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true); String str; double ht = clamp(HealthInter.GetValue(fractic),0,10000); str = String.Format("%3d",clamp(round(ht),0,999)); @@ -151,34 +151,34 @@ extend Class SWWMStatusBar else if ( round(ht) > 100 ) hcolor = MCR_AQUA; if ( isInvulnerable() || CPlayer.mo.FindInventory("InvinciballPower") ) { - Screen.DrawTexture(HealthTex[0],false,margin+3+ox,ss.y-(margin+19+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowRightF,hw,DTA_ColorOverlay,Color(255,0,0,0)); - Screen.DrawTexture(HealthTex[4],false,margin+2+ox,ss.y-(margin+20+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowRightF,hw); + Screen.DrawTexture(HealthTex[0],false,xmargin+3+ox,ss.y-(ymargin+19+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowRightF,hw,DTA_ColorOverlay,Color(255,0,0,0)); + Screen.DrawTexture(HealthTex[4],false,xmargin+2+ox,ss.y-(ymargin+20+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowRightF,hw); hcolor = MCR_WHITE; } else { - Screen.DrawTexture(HealthTex[0],false,margin+3+ox,ss.y-(margin+19+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowRightF,hw,DTA_ColorOverlay,Color(255,0,0,0)); - Screen.DrawTexture(HealthTex[0],false,margin+2+ox,ss.y-(margin+20+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowRightF,hw); + Screen.DrawTexture(HealthTex[0],false,xmargin+3+ox,ss.y-(ymargin+19+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowRightF,hw,DTA_ColorOverlay,Color(255,0,0,0)); + Screen.DrawTexture(HealthTex[0],false,xmargin+2+ox,ss.y-(ymargin+20+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowRightF,hw); if ( ht > 100 ) { hw = min(ht-100,100); - Screen.DrawTexture(HealthTex[1],false,margin+2+ox,ss.y-(margin+20+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowRightF,hw); + Screen.DrawTexture(HealthTex[1],false,xmargin+2+ox,ss.y-(ymargin+20+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowRightF,hw); } if ( ht > 200 ) { hw = min(ht-200,300)/3.; - Screen.DrawTexture(HealthTex[2],false,margin+2+ox,ss.y-(margin+20+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowRightF,hw); + Screen.DrawTexture(HealthTex[2],false,xmargin+2+ox,ss.y-(ymargin+20+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowRightF,hw); } if ( ht > 500 ) { hw = min(ht-500,500)/5.; - Screen.DrawTexture(HealthTex[3],false,margin+2+ox,ss.y-(margin+20+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowRightF,hw); + Screen.DrawTexture(HealthTex[3],false,xmargin+2+ox,ss.y-(ymargin+20+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowRightF,hw); } } if ( CPlayer.mo.FindInventory("DivineSpriteEffect") ) { double falph = clamp((ht-1000)/6000.,0.,1.); - Screen.DrawTexture(HealthTex[5],false,margin+2+ox,ss.y-(margin+20+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,falph,DTA_LegacyRenderStyle,STYLE_Add); + Screen.DrawTexture(HealthTex[5],false,xmargin+2+ox,ss.y-(ymargin+20+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,falph,DTA_LegacyRenderStyle,STYLE_Add); String tst; double alph = .1; int trl = 9; @@ -187,41 +187,41 @@ extend Class SWWMStatusBar tst = "AAA"; SWWMUtility.ObscureText(tst,(gametic-trl)/3,true); trl--; - Screen.DrawText(MiniHUDFont,mhudfontcol[MCR_WHITE],margin+107+ox,ss.y-(margin+20+oy),tst,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,falph*alph,DTA_LegacyRenderStyle,STYLE_Add); + Screen.DrawText(MiniHUDFont,mhudfontcol[MCR_WHITE],xmargin+107+ox,ss.y-(ymargin+20+oy),tst,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,falph*alph,DTA_LegacyRenderStyle,STYLE_Add); } - Screen.DrawText(MiniHUDFont,mhudfontcol[hcolor],margin+107+ox,ss.y-(margin+20+oy),String.Format("%3d",clamp(round(ht),0,999)),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,1.-falph); + Screen.DrawText(MiniHUDFont,mhudfontcol[hcolor],xmargin+107+ox,ss.y-(ymargin+20+oy),String.Format("%3d",clamp(round(ht),0,999)),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,1.-falph); } else { - Screen.DrawText(MiniHUDFont,mhudfontcol[hcolor],margin+107+ox,ss.y-(margin+20+oy),String.Format("%3d",clamp(round(ht),0,999)),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true); + Screen.DrawText(MiniHUDFont,mhudfontcol[hcolor],xmargin+107+ox,ss.y-(ymargin+20+oy),String.Format("%3d",clamp(round(ht),0,999)),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true); int f = HealthFlash; if ( f && (gametic < f) ) { double alph = max((f-(gametic+FracTic))/25.,0.)**1.5; - Screen.DrawTexture(HealthTex[7],false,margin+2+ox,ss.y-(margin+20+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowRightF,bhw,DTA_LegacyRenderStyle,STYLE_Add,DTA_Alpha,alph); - Screen.DrawText(MiniHUDFont,mhudfontcol[MCR_FLASH],margin+107+ox,ss.y-(margin+20+oy),str,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_LegacyRenderStyle,STYLE_Add,DTA_Alpha,alph); + Screen.DrawTexture(HealthTex[7],false,xmargin+2+ox,ss.y-(ymargin+20+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowRightF,bhw,DTA_LegacyRenderStyle,STYLE_Add,DTA_Alpha,alph); + Screen.DrawText(MiniHUDFont,mhudfontcol[MCR_FLASH],xmargin+107+ox,ss.y-(ymargin+20+oy),str,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_LegacyRenderStyle,STYLE_Add,DTA_Alpha,alph); } if ( (CPlayer.health > 0) && (CPlayer.health <= 25) && (PulsePhase <= 15) && (hcolor != MCR_WHITE) ) { 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+ox,ss.y-(margin+20+oy),str,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,alph); + Screen.DrawTexture(HealthTex[6],false,xmargin+2+ox,ss.y-(ymargin+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],xmargin+107+ox,ss.y-(ymargin+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); if ( hwl > bhw ) { - Screen.DrawTexture(HealthTex[8],false,margin+3+ox,ss.y-(margin+19+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowLeftF,bhw,DTA_WindowRightF,hwl,DTA_ColorOverlay,Color(255,0,0,0)); - Screen.DrawTexture(HealthTex[8],false,margin+2+ox,ss.y-(margin+20+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowLeftF,bhw,DTA_WindowRightF,hwl); + Screen.DrawTexture(HealthTex[8],false,xmargin+3+ox,ss.y-(ymargin+19+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowLeftF,bhw,DTA_WindowRightF,hwl,DTA_ColorOverlay,Color(255,0,0,0)); + Screen.DrawTexture(HealthTex[8],false,xmargin+2+ox,ss.y-(ymargin+20+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowLeftF,bhw,DTA_WindowRightF,hwl); } } double ft = clamp(FuelInter.GetValue(fractic),0,120); - Screen.DrawTexture(FuelTex[swwm_superfuel],false,margin+3+ox,ss.y-(margin+7+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowRightF,ft,DTA_ColorOverlay,Color(255,0,0,0)); - Screen.DrawTexture(FuelTex[swwm_superfuel],false,margin+2+ox,ss.y-(margin+8+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowRightF,ft); + Screen.DrawTexture(FuelTex[swwm_superfuel],false,xmargin+3+ox,ss.y-(ymargin+7+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowRightF,ft,DTA_ColorOverlay,Color(255,0,0,0)); + Screen.DrawTexture(FuelTex[swwm_superfuel],false,xmargin+2+ox,ss.y-(ymargin+8+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowRightF,ft); let d = Demolitionist(CPlayer.mo); bool blink = (!d || (d.dashfuel > 20) || ((gametic%10) < 5)); double dt = clamp(DashInter.GetValue(fractic),0,120); - Screen.DrawTexture(DashTex,false,margin+3+ox,ss.y-(margin+4+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowRightF,dt,DTA_ColorOverlay,Color(255,0,0,0)); - Screen.DrawTexture(DashTex,false,margin+2+ox,ss.y-(margin+5+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowRightF,dt,DTA_ColorOverlay,Color(blink?0:96,0,0,0)); + Screen.DrawTexture(DashTex,false,xmargin+3+ox,ss.y-(ymargin+4+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowRightF,dt,DTA_ColorOverlay,Color(255,0,0,0)); + Screen.DrawTexture(DashTex,false,xmargin+2+ox,ss.y-(ymargin+5+oy),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_WindowRightF,dt,DTA_ColorOverlay,Color(blink?0:96,0,0,0)); } } diff --git a/zscript/hud/swwm_hud_topstuff.zsc b/zscript/hud/swwm_hud_topstuff.zsc index 23f5a068f..3adb64b06 100644 --- a/zscript/hud/swwm_hud_topstuff.zsc +++ b/zscript/hud/swwm_hud_topstuff.zsc @@ -787,13 +787,13 @@ extend Class SWWMStatusBar private void DrawTopStuff() { - int xx, yy = margin; + int xx = xmargin, yy = ymargin; // obviously, don't draw the minimap if the automap is open if ( !automapactive && swwm_mm_enable ) { bool smol = (ss.x<480); int hsz = smol?HALFMAPSIZE_SMALL:HALFMAPSIZE; - xx = int(ss.x-(margin+(hsz+2)*2)); + xx = int(ss.x-(xmargin+(hsz+2)*2)); Screen.DrawTexture(MiniBox[smol],false,xx,yy,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true); DrawMinimap(xx,yy,smol); yy += ((hsz+2)*2)+5; @@ -803,7 +803,7 @@ extend Class SWWMStatusBar bool pstats = swwm_percentstats; if ( automapactive || (fstats > 0) ) { - xx = int(ss.x-(margin+2)); + xx = int(ss.x-(xmargin+2)); String str; if ( automapactive || (fstats > 1) ) { @@ -992,7 +992,7 @@ extend Class SWWMStatusBar { yy += 9; if ( playercount <= 1 ) return; - xx = int(ss.x-(margin+2)); + xx = int(ss.x-(xmargin+2)); String str; if ( teamplay ) { @@ -1028,7 +1028,7 @@ extend Class SWWMStatusBar return; } // draw key icons - Vector2 keypos = (ss.x-(margin+2),yy); + Vector2 keypos = (ss.x-(xmargin+2),yy); int colc = 0; double colh = 0; int n = Key.GetKeyTypeCount(); @@ -1058,7 +1058,7 @@ extend Class SWWMStatusBar colh = max(colh,siz.y); if ( ++colc == maxcolc ) { - keypos.x = ss.x-(margin+2); + keypos.x = ss.x-(xmargin+2); keypos.y += colh+2; colh = colc = 0; } diff --git a/zscript/hud/swwm_hud_weapons.zsc b/zscript/hud/swwm_hud_weapons.zsc index 6c2fcd856..0f0e27126 100644 --- a/zscript/hud/swwm_hud_weapons.zsc +++ b/zscript/hud/swwm_hud_weapons.zsc @@ -64,8 +64,8 @@ extend Class SWWMStatusBar private void DrawWeapons() { - Screen.DrawTexture(WeaponTex,false,ss.x-(margin+80),ss.y-(margin+10),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true); - double xx = ss.x-(margin+78), yy = ss.y-(margin+8); + Screen.DrawTexture(WeaponTex,false,ss.x-(xmargin+80),ss.y-(ymargin+10),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true); + double xx = ss.x-(xmargin+78), yy = ss.y-(ymargin+8); for ( int i=1; i<=10; i++,xx+=8 ) { int ncolor = mhudfontcol[MCR_WHITE]; @@ -129,8 +129,8 @@ extend Class SWWMStatusBar Screen.DrawText(MiniHUDFont,mhudfontcol[MCR_FLASH],xx,yy,String.Format("%d",(i%10)),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,alph,DTA_LegacyRenderStyle,STYLE_Add); } } - xx = ss.x-(margin+54); - yy = ss.y-(margin+14); + xx = ss.x-(xmargin+54); + yy = ss.y-(ymargin+14); bool bDrewAmmo = false; bool checkowned = !swwm_hudallammo; Array OwnedWeapons; @@ -248,9 +248,9 @@ extend Class SWWMStatusBar int scr = int(ScoreInter.GetValue()); int dcnt = 8-int(Log10(clamp(scr,1,999999999))); String sstr = String.Format("%9d",clamp(scr,0,999999999)); - xx = ss.x-(margin+48); + xx = ss.x-(xmargin+48); if ( bDrewAmmo ) yy -= 12; - else yy = ss.y-(margin+22); + else yy = ss.y-(ymargin+22); Screen.DrawTexture(ScoreTex,false,xx,yy,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true); xx += 10; yy += 2; @@ -258,11 +258,11 @@ extend Class SWWMStatusBar Screen.DrawText(MiniHUDFont,mhudfontcol[MCR_BRASS],xx,yy,sstr,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true); int bx = bDrewAmmo?56:50; // ammo display - if ( CPlayer.ReadyWeapon is 'SWWMWeapon' ) SWWMWeapon(CPlayer.ReadyWeapon).DrawWeapon(FracTic,ss.x-(margin+bx),ss.y-(margin+12),hs,ss); + if ( CPlayer.ReadyWeapon is 'SWWMWeapon' ) SWWMWeapon(CPlayer.ReadyWeapon).DrawWeapon(FracTic,ss.x-(xmargin+bx),ss.y-(ymargin+12),hs,ss); else if ( CPlayer.ReadyWeapon ) { // generic display - double xx = ss.x-(margin+bx+2), yy = ss.y-(margin+22); + double xx = ss.x-(xmargin+bx+2), yy = ss.y-(ymargin+22); String str; int len; if ( CPlayer.ReadyWeapon.Ammo2 && (CPlayer.ReadyWeapon.Ammo2 != CPlayer.ReadyWeapon.Ammo1) ) @@ -280,7 +280,7 @@ extend Class SWWMStatusBar Screen.DrawText(MiniHUDFont,mhudfontcol[(CPlayer.ReadyWeapon.Ammo2.Amount<=0)?MCR_RED:MCR_BRASS],xx,yy+2,str,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true); yy += 12; } - xx = ss.x-(margin+bx+2); + xx = ss.x-(xmargin+bx+2); if ( CPlayer.ReadyWeapon.Ammo1 ) { str = String.Format("%d",CPlayer.ReadyWeapon.Ammo1.Amount); diff --git a/zscript/hud/swwm_hudextra.zsc b/zscript/hud/swwm_hudextra.zsc index 7053ced73..20a33a6f4 100644 --- a/zscript/hud/swwm_hudextra.zsc +++ b/zscript/hud/swwm_hudextra.zsc @@ -86,7 +86,7 @@ Class SWWMOneLiner : HUDMessageBase override void Draw( int bottom, int visibility ) { - int margin = swwm_hudmargin; + int ymargin = clamp(swwm_hudmargin,0,10); double hs; Vector2 ss; if ( SWWMStatusBar(StatusBar) ) @@ -101,7 +101,7 @@ Class SWWMOneLiner : HUDMessageBase } if ( whichline == "" ) return; // don't draw empty strings // split so it can fit - if ( !l ) l = mSmallFont.BreakLines(whichline,int(ss.x*.5)); + if ( !l ) l = mSmallFont.BreakLines(whichline,int(min(ss.x,ss.y/.5625)*.5)); int maxlen = 0; for ( int i=0; i (seqcnt+1)) ) return; + int ymargin; double alph = 1.; double fractic = System.GetTimeFrac(); if ( seqnum == 0 ) alph = (fadein+fractic)/15.; else if ( seqnum == (seqcnt+1) ) alph = 1.-(fadeout+fractic)/30.; if ( SWWMStatusBar(StatusBar) ) { + ymargin = SWWMStatusBar(StatusBar).ymargin; hs = SWWMStatusBar(StatusBar).hs; ss = SWWMStatusBar(StatusBar).ss; } else { + ymargin = clamp(swwm_hudmargin,0,10); hs = max(min(floor(Screen.GetWidth()/640.),floor(Screen.GetHeight()/360.)),1.); ss = (Screen.GetWidth()/hs,Screen.GetHeight()/hs); } - origin = (int(ss.x-270)/2,swwm_hudmargin+70); + origin = (int(ss.x-270)/2,ymargin+70); Screen.DrawTexture(MessageBox,false,origin.x,origin.y,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,alph); if ( (seqnum < 1) || (seqnum > seqcnt) ) return; DrawAvatar(fractic); @@ -932,7 +938,7 @@ Class DSMapTitle : HUDMessageBase double wfact = clamp(ftics/double(ultics),0.,1.); int wsub = MySubStringWidth(txtsub); int w = MyStringWidth(txt); - int capw = int(ss.x-250); + int capw = int(min(ss.x,ss.y/.5625)-250); // limit to 16:9, avoids super-long text in ultrawide if ( (w < capw) && !hasnewline ) { DrawUnderline(xx,yy+1,ss,(w+32)*wfact,alpha);