From 4cff29ab73b3d081ba03b2b22a13b86ea67baee1 Mon Sep 17 00:00:00 2001 From: Marisa Kirisame Date: Tue, 22 Dec 2020 16:13:54 +0100 Subject: [PATCH] Add option to always show map stats in HUD. Fix broken propagation of cvars in combat trackers if some are dormant. --- cvarinfo.txt | 1 + language.def_menu | 5 +++++ language.es_menu | 5 +++++ language.version | 2 +- menudef.txt | 7 +++++++ zscript/swwm_hud.zsc | 28 +++++++++++++++++----------- zscript/swwm_thinkers.zsc | 26 +++++++++++++------------- 7 files changed, 49 insertions(+), 25 deletions(-) diff --git a/cvarinfo.txt b/cvarinfo.txt index bbd64c8a6..453dce846 100644 --- a/cvarinfo.txt +++ b/cvarinfo.txt @@ -91,6 +91,7 @@ server int swwm_strictuntouchable = 0; // untouchable bonus ends... (1 - even i server int swwm_silencemap = 0; // silences the map when all kills/items/secrets are achieved (2 - play calm music) user int swwm_shadowdist = 2000; // max distance beyond which blob shadows are no longer rendered, helps performance server bool swwm_swapweapons = true; // [DLC1] allows carrying only one weapon in each slot (excluding starter melee and pistol) +user int swwm_forcestats = 0; // always shows level stats on the HUD, not just when the automap is open (2 - also show map name, otherwise only stats) server noarchive bool swwm_iseriouslywanttoplaythiswithbd = false; // self-explanatory diff --git a/language.def_menu b/language.def_menu index 8fc5f3996..d8a0bd345 100644 --- a/language.def_menu +++ b/language.def_menu @@ -175,6 +175,10 @@ SWWM_SILENCE_SILENT = "Silence"; SWWM_SILENCE_CALM = "Calm Track"; SWWM_SHADOWDIST = "Shadow Distance"; SWWM_SWAPWEAPONS = "Weapon Swapping"; +SWWM_FORCESTATS = "Always Show Map Stats"; +SWWM_STATS_DISABLED = "Disabled"; +SWWM_STATS_ALWAYS = "Stats Only"; +SWWM_STATS_MAPNAME = "Stats + Map Name"; TOOLTIP_SWWM_VOICETYPE = "Sets the voice pack for the player."; TOOLTIP_SWWM_MUTEVOICE = "Control what gets muted, if you'd rather have a more silent protagonist."; TOOLTIP_SWWM_FLASHSTRENGTH = "Screen flashes usually happen when firing some weapons, you can lower this if these effects are harmful for you."; @@ -256,6 +260,7 @@ TOOLTIP_SWWM_STRICTUNTOUCHABLE = "By default, the \"Untouchable\" bonus is activ TOOLTIP_SWWM_SILENCEMAP = "Chooses whether you want music to stop when you 100% a map. A third option is available which switches to a soothing calm track from a game you may recognize if you know me well."; TOOLTIP_SWWM_SHADOWDISTANCE = "Maximum distance at which to show blob shadows. May help performance."; TOOLTIP_SWWM_SWAPWEAPONS = "Allow only one weapon per slot (excluding Deep Impact and Explodium Gun). Disable if you'd rather ignore this puny attempt at balance."; +TOOLTIP_SWWM_FORCESTATS = "Shows map statistics in the HUD even when the automap isn't open."; // knowledge base SWWM_COMINGSOON = "(coming soon)"; SWWM_MISSTAB = "Mission"; diff --git a/language.es_menu b/language.es_menu index 81271f545..a32961abb 100644 --- a/language.es_menu +++ b/language.es_menu @@ -172,6 +172,10 @@ SWWM_SILENCE_KEEP = "No Cambiar"; SWWM_SILENCE_SILENT = "Silencio"; SWWM_SILENCE_CALM = "Tema Tranquilo"; SWWM_SHADOWDIST = "Distancia de Sombras"; +SWWM_FORCESTATS = "Mostrar Siempre Estadísticas de Mapa"; +SWWM_STATS_DISABLED = "Desactivado"; +SWWM_STATS_ALWAYS = "Solo Estadísticas"; +SWWM_STATS_MAPNAME = "Estadísticas + Nombre de Mapa"; TOOLTIP_SWWM_VOICETYPE = "Selecciona el pack de voz para el jugador."; TOOLTIP_SWWM_MUTEVOICE = "Controla lo que se mutea, si prefieres tener un protagonista más silencioso."; TOOLTIP_SWWM_FLASHSTRENGTH = "Los destellos en pantalla suelen ocurrir al disparar algunas armas, puedes reducirlo si este tipo de efectos te causan malestar."; @@ -253,6 +257,7 @@ TOOLTIP_SWWM_STRICTUNTOUCHABLE = "Por defecto, el bonus \"Intocable\" permanece TOOLTIP_SWWM_SILENCEMAP = "Elige si quieres que la música se detenga cuando completas un mapa al 100%. Hay una tercera opción disponible que cambiará a un relajante tema tranquilo de un juego que podrás reconocer si me conoces bien."; TOOLTIP_SWWM_SHADOWDISTANCE = "Distancia máxima a la que mostrar sombras. Puede ayudar al rendimiento."; TOOLTIP_SWWM_SWAPWEAPONS = "Permitir solo un arma por puesto (excluyendo Deep Impact y Pistola de Explodium). Desactiva si prefieres ignorar este intento inútil de balance."; +TOOLTIP_SWWM_FORCESTATS = "Muestra estadísticas de mapa en el HUD incluso cuando el automapa no está abierto."; // knowledge base SWWM_COMINGSOON = "(próximamente)"; SWWM_MISSTAB = "Misión"; diff --git a/language.version b/language.version index c56efbf93..c64053775 100644 --- a/language.version +++ b/language.version @@ -1,2 +1,2 @@ [default] -SWWM_MODVER="\chSWWM \czGZ\c- \cw0.9.11b-pre r699 \cu(Tue 22 Dec 08:13:24 CET 2020)"; +SWWM_MODVER="\chSWWM \czGZ\c- \cw0.9.11b-pre r700 \cu(Tue 22 Dec 16:13:54 CET 2020)"; diff --git a/menudef.txt b/menudef.txt index 49b167cdf..c319ecc8b 100644 --- a/menudef.txt +++ b/menudef.txt @@ -42,6 +42,12 @@ OptionValue "SWWMSilenceMap" 1, "$SWWM_SILENCE_SILENT" 2, "$SWWM_SILENCE_CALM" } +OptionValue "SWWMForceStats" +{ + 0, "$SWWM_STATS_DISABLED" + 1, "$SWWM_STATS_ALWAYS" + 2, "$SWWM_STATS_MAPNAME" +} OptionMenu "SWWMOptionMenu" { Class "SWWMOptionMenu" @@ -61,6 +67,7 @@ OptionMenu "SWWMOptionMenu" Option "$SWWM_RAGESHADER", "swwm_rageshader", "YesNo" Slider "$SWWM_FLASH", "swwm_flashstrength", 0.0, 1.0, 0.1, 1 Option "$SWWM_CAMHUD", "swwm_camhud", "YesNo" + Option "$SWWM_FORCESTATS", "swwm_forcestats", "SWWMForceStats" Slider "$SWWM_HUDMARGIN", "swwm_hudmargin", 0, 40, 1, 0 Slider "$SWWM_MAXMSG", "swwm_maxshown", 1, 10, 1, 0 Slider "$SWWM_MAXMSGBIG", "swwm_maxshownbig", 1, 20, 1, 0 diff --git a/zscript/swwm_hud.zsc b/zscript/swwm_hud.zsc index c53e85b76..7fcab4e16 100644 --- a/zscript/swwm_hud.zsc +++ b/zscript/swwm_hud.zsc @@ -26,7 +26,7 @@ Class SWWMStatusBar : BaseStatusBar SWWMHandler hnd; // client cvars - transient CVar safezone, maxchat[2], maxpick, chatduration, msgduration, pickduration, chatcol, teamcol, obitcol, critcol, pickcol, targetter, healthnums, scorenums, scorebonus, pois, targettag, lang, maxtarg, maxscore, maxdamns, hscale, bscale, nscale, sscale, iscale, dscale, midcol, midbcol, midduration, bigtags, showitems, showmaplabel, showmonsters, showsecrets, showtime, showtotaltime, legspoil, camhud; + transient CVar safezone, maxchat[2], maxpick, chatduration, msgduration, pickduration, chatcol, teamcol, obitcol, critcol, pickcol, targetter, healthnums, scorenums, scorebonus, pois, targettag, lang, maxtarg, maxscore, maxdamns, hscale, bscale, nscale, sscale, iscale, dscale, midcol, midbcol, midduration, bigtags, showitems, showmaplabel, showmonsters, showsecrets, showtime, showtotaltime, legspoil, camhud, forcestats; // shared stuff Vector2 ss, hs; @@ -858,8 +858,10 @@ Class SWWMStatusBar : BaseStatusBar Screen.DrawTexture(ScoreTex[2],false,ss.x-(margin+xx),margin,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true); Screen.DrawText(mTewiFont.mFont,Font.CR_FIRE,ss.x-(margin+4+6*digits),margin+1,sstr,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true); // draw stats and timer when automap is open + if ( !forcestats ) forcestats = CVar.GetCVar('swwm_forcestats',players[consoleplayer]); + int fstats = forcestats.GetInt(); int yy = margin+19; - if ( automapactive ) + if ( automapactive || (fstats > 0) ) { if ( !showitems ) showitems = CVar.GetCVar('am_showitems',players[consoleplayer]); if ( !showmaplabel ) showmaplabel = CVar.GetCVar('am_showmaplabel',players[consoleplayer]); @@ -869,15 +871,19 @@ Class SWWMStatusBar : BaseStatusBar if ( !showtotaltime ) showtotaltime = CVar.GetCVar('am_showtotaltime',players[consoleplayer]); int xx = int(ss.x-(margin+2)); String str; - int label = showmaplabel.GetInt(); - String ln = level.levelname; - int iof = ln.IndexOf(" - by: "); - if ( iof != -1 ) ln.Truncate(iof); - if ( !label || ((level.clusterflags&level.CLUSTER_HUB) && (label == 2)) ) str = ln; - else str = String.Format("%s - %s",level.mapname.MakeUpper(),ln); - let fnt = LangFont(mTewiFont); - Screen.DrawText(fnt,Font.CR_FIRE,xx-fnt.StringWidth(str),yy,str,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true); - yy += fnt.GetHeight(); + Font fnt; + if ( automapactive || (fstats > 1) ) + { + int label = showmaplabel.GetInt(); + String ln = level.levelname; + int iof = ln.IndexOf(" - by: "); + if ( iof != -1 ) ln.Truncate(iof); + if ( !label || ((level.clusterflags&level.CLUSTER_HUB) && (label == 2)) ) str = ln; + else str = String.Format("%s - %s",level.mapname.MakeUpper(),ln); + fnt = LangFont(mTewiFont); + Screen.DrawText(fnt,Font.CR_FIRE,xx-fnt.StringWidth(str),yy,str,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true); + yy += fnt.GetHeight(); + } fnt = LangFont(mMiniwiFont); if ( (level.total_monsters > 0) && showmonsters.GetBool() ) { diff --git a/zscript/swwm_thinkers.zsc b/zscript/swwm_thinkers.zsc index 827ca15ad..b94df7983 100644 --- a/zscript/swwm_thinkers.zsc +++ b/zscript/swwm_thinkers.zsc @@ -900,6 +900,19 @@ Class SWWMCombatTracker : Thinker override void Tick() { + // only the first tracker accesses the CVars, saves on perf + if ( !prev ) + { + if ( !damagebars ) damagebars = CVar.GetCVar('swwm_damagetarget',players[consoleplayer]); + if ( !maxdist ) maxdist = CVar.GetCVar('swwm_maxtargetdist',players[consoleplayer]); + dbar = damagebars.GetInt(); + mxdist = maxdist.GetInt(); + } + if ( next ) + { + next.dbar = dbar; + next.mxdist = mxdist; + } // is target gone or dead? if ( !mytarget || (mytarget.Health <= 0) ) { @@ -972,19 +985,6 @@ Class SWWMCombatTracker : Thinker lasthealth = mytarget.Health; intp.Update(lasthealth); // special update conditions - // only the first tracker accesses the CVars, saves on perf - if ( !prev ) - { - if ( !damagebars ) damagebars = CVar.GetCVar('swwm_damagetarget',players[consoleplayer]); - if ( !maxdist ) maxdist = CVar.GetCVar('swwm_maxtargetdist',players[consoleplayer]); - dbar = damagebars.GetInt(); - mxdist = maxdist.GetInt(); - } - if ( next ) - { - next.dbar = dbar; - next.mxdist = mxdist; - } if ( dbar ) { if ( (dbar == 2) && (lasthealth >= maxhealth) )