From f5694bc630bca7e277c6383ed41a2812f449f3f1 Mon Sep 17 00:00:00 2001 From: Marisa the Magician Date: Thu, 25 Jan 2024 15:53:57 +0100 Subject: [PATCH] Attach auxiliary HUD elements (centered text, pickups, oneliners, etc.) to hudscale zero. --- language.def_menu | 2 +- language.es_menu | 2 +- language.version | 4 +-- zscript/hud/swwm_hud.zsc | 55 ++++++++++++++++--------------- zscript/hud/swwm_hud_messages.zsc | 34 +++++++++---------- zscript/hud/swwm_hudextra.zsc | 18 +++++----- 6 files changed, 59 insertions(+), 56 deletions(-) diff --git a/language.def_menu b/language.def_menu index fa2ec3957..2b22c4984 100644 --- a/language.def_menu +++ b/language.def_menu @@ -281,7 +281,7 @@ TOOLTIP_SWWM_USEWEAPONBAR = "Enables an alternate method for scrolling through w TOOLTIP_SWWM_PERCENTSTATS = "Shows kills/items/secrets in the HUD as percentages, rather than counters."; TOOLTIP_SWWM_TARGETVALS = "Healthbars will show the current and maximum health values of the target."; TOOLTIP_SWWM_HUDSCALE = "If higher than zero, manually set the scale of the HUD. Keep in mind that HUD elements may overlap if set too high."; -TOOLTIP_SWWM_HUDSCALE0 = "If higher than zero, manually set the scale of Damage Numbers. Usually, this is equal to the primary HUD scale."; +TOOLTIP_SWWM_HUDSCALE0 = "If higher than zero, manually set the scale of auxiliary HUD elements (centered text, pickup messages, etc.) and Damage Numbers. Usually, this is equal to the primary HUD scale."; TOOLTIP_SWWM_HUDSCALE1 = "If higher than zero, manually set the scale of Healthbars, Score Numbers and Item Sense. Usually, this is one less than the primary HUD scale."; TOOLTIP_SWWM_HUDSCALE2 = "If higher than zero, manually set the scale of Interest Points. Usually, this is two less than the primary HUD scale."; TOOLTIP_SWWM_ALTCLEAR = "Use an alternate, less visually intense effect for getting 100% completion on a level."; diff --git a/language.es_menu b/language.es_menu index 03bd022c5..c375297bf 100644 --- a/language.es_menu +++ b/language.es_menu @@ -276,7 +276,7 @@ TOOLTIP_SWWM_USEWEAPONBAR = "Habilita un método alternativo para hacer scroll p TOOLTIP_SWWM_PERCENTSTATS = "Muestra las estadísticas de bajas/ítems/secretos en el HUD como porcentajes, en lugar de contadores."; TOOLTIP_SWWM_TARGETVALS = "Las barras de salud mostrarán los valores de salud actual y máximo del objetivo."; TOOLTIP_SWWM_HUDSCALE = "Si es mayor que cero, especifica manualmente la escala del HUD. Ten en cuenta que los elementos del HUD pueden solaparse si es muy alta."; -TOOLTIP_SWWM_HUDSCALE0 = "Si es mayor que cero, especifica manualmente la escala de los Números de Daño. Normalmente, es igual a la escala primaria del HUD."; +TOOLTIP_SWWM_HUDSCALE0 = "Si es mayor que cero, especifica manualmente la escala de los elementos de HUD auxiliares (texto centrado, ítems recogidos, etc.) y Números de Daño. Normalmente, es igual a la escala primaria del HUD."; TOOLTIP_SWWM_HUDSCALE1 = "Si es mayor que cero, especifica manualmente la escala de las Barras de Salud, Números de Puntuación y Sensor de Ítems. Normalmente, es igual a dos menos que la escala primaria del HUD."; TOOLTIP_SWWM_HUDSCALE2 = "Si es mayor que cero, especifica manualmente la escala de los Puntos de Interés. Normalmente, es igual a tres menos que la escala primaria del HUD."; TOOLTIP_SWWM_ALTCLEAR = "Usa un efecto alternativo de menor intensidad visual al completar un nivel al 100%."; diff --git a/language.version b/language.version index 159e335aa..be8e0d3d0 100644 --- a/language.version +++ b/language.version @@ -1,3 +1,3 @@ [default] -SWWM_MODVER="\cyDEMOLITIONIST \cw1.3pre r1098 \cu(Wed 24 Jan 13:32:24 CET 2024)\c-"; -SWWM_SHORTVER="\cw1.3pre r1098 \cu(2024-01-24 13:32:24)\c-"; +SWWM_MODVER="\cyDEMOLITIONIST \cw1.3pre r1099 \cu(Thu 25 Jan 15:53:57 CET 2024)\c-"; +SWWM_SHORTVER="\cw1.3pre r1099 \cu(2024-01-25 15:53:57)\c-"; diff --git a/zscript/hud/swwm_hud.zsc b/zscript/hud/swwm_hud.zsc index 0f723ec70..8d7864f56 100644 --- a/zscript/hud/swwm_hud.zsc +++ b/zscript/hud/swwm_hud.zsc @@ -105,6 +105,7 @@ Class SWWMStatusBar : BaseStatusBar double hs, hs0, hs1, hs2; Vector2 ss, ss0, ss1, ss2; int ymargin, xmargin; + int ymargin0; // for pickups/oneliners double FracTic; double FrameTime; double PrevFrame; @@ -434,7 +435,7 @@ Class SWWMStatusBar : BaseStatusBar override void DrawMyPos() { String str = String.Format("(%d,%d,%d)",CPlayer.mo.pos.X,CPlayer.mo.pos.Y,CPlayer.mo.pos.Z); - Screen.DrawText(mTinyFontOutline,Font.CR_GREEN,(ss.x-mTinyFontOutline.StringWidth(str))/2,4,str,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true); + Screen.DrawText(mTinyFontOutline,Font.CR_GREEN,(ss0.x-mTinyFontOutline.StringWidth(str))/2,4,str,DTA_VirtualWidthF,ss0.x,DTA_VirtualHeightF,ss0.y,DTA_KeepRatio,true); } override bool DrawChat( String txt ) @@ -443,24 +444,24 @@ Class SWWMStatusBar : BaseStatusBar if ( gamestate != GS_LEVEL ) return false; chatopen = gametic+1; // have to add 1 because DrawChat is called after everything else double xx = 2; - double yy = ss.y-14; - Screen.Dim("Black",.8,0,Screen.GetHeight()-int(15*hs),Screen.GetWidth(),int(15*hs)); + double yy = ss0.y-14; + Screen.Dim("Black",.8,0,Screen.GetHeight()-int(15*hs0),Screen.GetWidth(),int(15*hs0)); String pname = players[consoleplayer].GetUserName(); // strip colors SWWMUtility.StripColor(pname); String fullstr = String.Format("\cq%s\cd@\cqdemolitionist%d\cn ~ \cd% \c-wall %s_",pname,consoleplayer+1,txt); // cut out to fit int w = mSmallFont.StringWidth(fullstr); - if ( w > ss.x-4 ) + if ( w > ss0.x-4 ) { // draw trailing dots - Screen.DrawText(mSmallFont,Font.CR_WHITE,xx,yy,"...",DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true); + Screen.DrawText(mSmallFont,Font.CR_WHITE,xx,yy,"...",DTA_VirtualWidthF,ss0.x,DTA_VirtualHeightF,ss0.y,DTA_KeepRatio,true); // shift back - xx -= w-(ss.x-4); + xx -= w-(ss0.x-4); // draw trimmed - Screen.DrawText(mSmallFont,Font.CR_WHITE,xx,yy,fullstr,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_ClipLeft,int(26*hs)); + Screen.DrawText(mSmallFont,Font.CR_WHITE,xx,yy,fullstr,DTA_VirtualWidthF,ss0.x,DTA_VirtualHeightF,ss0.y,DTA_KeepRatio,true,DTA_ClipLeft,int(26*hs0)); } - else Screen.DrawText(mSmallFont,Font.CR_WHITE,xx,yy,fullstr,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true); + else Screen.DrawText(mSmallFont,Font.CR_WHITE,xx,yy,fullstr,DTA_VirtualWidthF,ss0.x,DTA_VirtualHeightF,ss0.y,DTA_KeepRatio,true); return true; } @@ -553,50 +554,50 @@ Class SWWMStatusBar : BaseStatusBar Screen.Dim("Red",clamp((demo.revivefail-(level.maptime+fractic))/60.,0.,.2),0,0,Screen.GetWidth(),Screen.GetHeight()); str = StringTable.Localize("$SWWM_REFAIL"); len = mSmallFont.StringWidth(str); - xx = int((ss.x-len)/2.); - yy = ss.y-48; + xx = int((ss0.x-len)/2.); + yy = ss0.y-48; if ( ((demo.revivefail-level.maptime)%16) < 8 ) - Screen.DrawText(mSmallFont,Font.CR_RED,xx,yy,str,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true); + Screen.DrawText(mSmallFont,Font.CR_RED,xx,yy,str,DTA_VirtualWidthF,ss0.x,DTA_VirtualHeightF,ss0.y,DTA_KeepRatio,true); } alph = clamp((deadtimer-60)/60.,0.,1.); String nam = CPlayer.GetUserName(); if ( !multiplayer || (nam == "Player") ) str = StringTable.Localize("$SWWM_URDED_GEN"); else str = String.Format(StringTable.Localize("$SWWM_URDED"),nam); len = mSmallFont.StringWidth(str); - xx = int((ss.x-len)/2.); - yy = (ss.y-mSmallFont.GetHeight()*4)/2.; + xx = int((ss0.x-len)/2.); + yy = (ss0.y-mSmallFont.GetHeight()*4)/2.; // shift down if scoreboard is shown if ( (deathmatch && sb_deathmatch_enable && (!teamplay || sb_teamdeathmatch_enable)) || (multiplayer && sb_cooperative_enable) ) - yy += ss.y/3.+mSmallFont.GetHeight(); - Screen.DrawText(mSmallFont,Font.CR_RED,xx,yy,str,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,alph); + yy += ss0.y/3.+mSmallFont.GetHeight(); + Screen.DrawText(mSmallFont,Font.CR_RED,xx,yy,str,DTA_VirtualWidthF,ss0.x,DTA_VirtualHeightF,ss0.y,DTA_KeepRatio,true,DTA_Alpha,alph); if ( multiplayer || level.AllowRespawn || sv_singleplayerrespawn || G_SkillPropertyInt(SKILLP_PlayerRespawn) ) { if ( sv_norespawn ) return (1.-dimalph); alph = clamp((deadtimer-90)/60.,0.,1.); str = String.Format(StringTable.Localize("$SWWM_URDEDMP")); len = mSmallFont.StringWidth(str); - xx = int((ss.x-len)/2.); - yy = ss.y/2.; + xx = int((ss0.x-len)/2.); + yy = ss0.y/2.; // shift down if scoreboard is shown if ( (deathmatch && sb_deathmatch_enable && (!teamplay || sb_teamdeathmatch_enable)) || (multiplayer && sb_cooperative_enable) ) - yy += ss.y/3.; - Screen.DrawText(mSmallFont,Font.CR_WHITE,xx,yy,str,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,alph); + yy += ss0.y/3.; + Screen.DrawText(mSmallFont,Font.CR_WHITE,xx,yy,str,DTA_VirtualWidthF,ss0.x,DTA_VirtualHeightF,ss0.y,DTA_KeepRatio,true,DTA_Alpha,alph); return (1.-dimalph); } alph = clamp((deadtimer-140)/60.,0.,1.); str = String.Format(StringTable.Localize("$SWWM_URDED2")); len = mSmallFont.StringWidth(str); - xx = int((ss.x-len)/2.); - yy = ss.y/2.; - Screen.DrawText(mSmallFont,Font.CR_WHITE,xx,yy,str,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,alph); + xx = int((ss0.x-len)/2.); + yy = ss0.y/2.; + Screen.DrawText(mSmallFont,Font.CR_WHITE,xx,yy,str,DTA_VirtualWidthF,ss0.x,DTA_VirtualHeightF,ss0.y,DTA_KeepRatio,true,DTA_Alpha,alph); if ( goner || hnd.gdat.disablerevive || !swwm_revive ) return (1.-dimalph); alph = clamp((deadtimer-160)/60.,0.,1.); str = String.Format(StringTable.Localize("$SWWM_URDED3")); len = mSmallFont.StringWidth(str); - xx = int((ss.x-len)/2.); - yy = (ss.y+mSmallFont.GetHeight()*2)/2.; - Screen.DrawText(mSmallFont,Font.CR_WHITE,xx,yy,str,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,alph); + xx = int((ss0.x-len)/2.); + yy = (ss0.y+mSmallFont.GetHeight()*2)/2.; + Screen.DrawText(mSmallFont,Font.CR_WHITE,xx,yy,str,DTA_VirtualWidthF,ss0.x,DTA_VirtualHeightF,ss0.y,DTA_KeepRatio,true,DTA_Alpha,alph); return (1.-dimalph); } return 1.; @@ -656,6 +657,8 @@ Class SWWMStatusBar : BaseStatusBar // 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); + // calculate vertical margin for hudscale0 (relative to base hudscale) + ymargin0 = int(ymargin*(hs/hs0)); FracTic = TicFrac; if ( (players[consoleplayer].Camera is 'Demolitionist') && (state <= HUD_Fullscreen) ) { @@ -672,7 +675,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,ymargin,str,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true); + Screen.DrawText(NewSmallFont,Font.CR_RED,(ss0.x-NewSmallFont.StringWidth(str))/2,ymargin0,str,DTA_VirtualWidthF,ss0.x,DTA_VirtualHeightF,ss0.y,DTA_KeepRatio,true); } PrevFrame = CurFrame; } diff --git a/zscript/hud/swwm_hud_messages.zsc b/zscript/hud/swwm_hud_messages.zsc index 9470c01fb..a230569c5 100644 --- a/zscript/hud/swwm_hud_messages.zsc +++ b/zscript/hud/swwm_hud_messages.zsc @@ -288,21 +288,21 @@ extend Class SWWMStatusBar if ( (ntagstr != "") && (tagtime > 0) ) { nalph = clamp(tagtime/20.,0.,1.); - yy = ss.y-(ymargin+50); + yy = ss0.y-(ymargin0+50); int len = mSmallFont.StringWidth(ntagstr); - double xx = (ss.x-len)/2.; - Screen.Dim("Black",.8*nalph,int((xx-6)*hs),int(yy*hs),int((len+12)*hs),int((h+4)*hs)); - Screen.DrawText(mSmallFont,ntagcol,int(xx),yy+2,ntagstr,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,nalph); + double xx = (ss0.x-len)/2.; + Screen.Dim("Black",.8*nalph,int((xx-6)*hs0),int(yy*hs0),int((len+12)*hs0),int((h+4)*hs0)); + Screen.DrawText(mSmallFont,ntagcol,int(xx),yy+2,ntagstr,DTA_VirtualWidthF,ss0.x,DTA_VirtualHeightF,ss0.y,DTA_KeepRatio,true,DTA_Alpha,nalph); } if ( PickupQueue.Size() <= 0 ) return; // reverse order since they're drawn bottom to top int mend = max(0,PickupQueue.Size()-MAXPICKUP); - yy = ss.y-(ymargin+50); + yy = ss0.y-(ymargin0+50); // shift up 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(min(ss.x,ss.y/.5625)*.75)); + PickupQueue[i].UpdateText(int(min(ss0.x,ss0.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; @@ -312,13 +312,13 @@ extend Class SWWMStatusBar int len = mSmallFont.StringWidth(l.StringAt(j)); if ( len > maxlen ) maxlen = len; } - double xx = (ss.x-maxlen)/2.; - Screen.Dim("Black",.8*alph,int((xx-6)*hs),int((yy-h*(l.Count()-1))*hs),int((maxlen+12)*hs),int((h*l.Count()+4)*hs)); + double xx = (ss0.x-maxlen)/2.; + Screen.Dim("Black",.8*alph,int((xx-6)*hs0),int((yy-h*(l.Count()-1))*hs0),int((maxlen+12)*hs0),int((h*l.Count()+4)*hs0)); for ( int j=l.Count()-1; j>=0; j-- ) { int len = mSmallFont.StringWidth(l.StringAt(j)); - xx = int((ss.x-len)/2.); - Screen.DrawText(mSmallFont,msg0color,xx,yy+2,l.StringAt(j),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,alph); + xx = int((ss0.x-len)/2.); + Screen.DrawText(mSmallFont,msg0color,xx,yy+2,l.StringAt(j),DTA_VirtualWidthF,ss0.x,DTA_VirtualHeightF,ss0.y,DTA_KeepRatio,true,DTA_Alpha,alph); yy -= h; } yy -= 6; @@ -335,23 +335,23 @@ extend Class SWWMStatusBar int col = (midtype&2)?msgmidcolor2:msgmidcolor; double curtime = (midtic+int(GameTicRate*con_midtime))-(level.totaltime+fractic); double alph = clamp(curtime/20.,0.,1.); - if ( !midl || (midsz != int(ss.x*ssp)) ) + if ( !midl || (midsz != int(ss0.x*ssp)) ) { if ( midl ) midl.Destroy(); - midl = mSmallFont.BreakLines(midstr,int(min(ss.x,ss.y/.5625)*ssp)); + midl = mSmallFont.BreakLines(midstr,int(min(ss0.x,ss0.y/.5625)*ssp)); } int h = mSmallFont.GetHeight(); int maxlen = 0; for ( int i=0; i