From d22f9609e09599dafa2a9cbd88c227edfba44b4c Mon Sep 17 00:00:00 2001 From: Marisa Kirisame Date: Thu, 29 Apr 2021 23:25:24 +0200 Subject: [PATCH] Show play time in options menu. Store unlock date for achievements. --- cvarinfo.txt | 75 +++++++++++++++++++ language.def_menu | 6 ++ language.es_menu | 6 ++ language.version | 4 +- menudef.txt | 2 + .../swwm_statichandler_achievements.zsc | 1 + zscript/menu/swwm_menus.zsc | 60 +++++++++++++++ zscript/swwm_statichandler.zsc | 11 ++- zscript/utility/swwm_utility.zsc | 11 +-- 9 files changed, 163 insertions(+), 13 deletions(-) diff --git a/cvarinfo.txt b/cvarinfo.txt index da41410d6..1aee2ac28 100644 --- a/cvarinfo.txt +++ b/cvarinfo.txt @@ -105,6 +105,7 @@ server bool swwm_singlefirst = false; // single weapons are selected before dua nosave bool swwm_uniqstats = false; // only list stats from the same map once, rather than for each single visit nosave int swwm_filterachievements = 1; // filter for achievements at 0%: 0 - no filter, 1 - obscure text, 2 - don't show server noarchive bool swwm_debugview = false; // debug visual aid for various things, such as actor collision, trajectories, relationships, etc. +nosave noarchive bool swwm_oldcheat = false; // set to true if you used a SWWM Platinum cheat, so the easter egg only appears once per session // minimap settings nosave bool swwm_mm_enable = true; // show a minimap below the score counter @@ -220,6 +221,80 @@ nosave int swwm_achievement_thruwall = 0; nosave int swwm_achievement_wantdie = 0; nosave int swwm_achievement_wave = 0; nosave int swwm_achievement_yeet = 0; +// date of completion +nosave int swwm_unlockdate_acid = 0; +nosave int swwm_unlockdate_allcoll = 0; +nosave int swwm_unlockdate_allitems = 0; +nosave int swwm_unlockdate_allkills = 0; +nosave int swwm_unlockdate_allsecrets = 0; +nosave int swwm_unlockdate_anom = 0; +nosave int swwm_unlockdate_anone = 0; +nosave int swwm_unlockdate_balls = 0; +nosave int swwm_unlockdate_barrier = 0; +nosave int swwm_unlockdate_bonk = 0; +nosave int swwm_unlockdate_bossdash = 0; +nosave int swwm_unlockdate_brake = 0; +nosave int swwm_unlockdate_bune = 0; +nosave int swwm_unlockdate_bustin = 0; +nosave int swwm_unlockdate_butts = 0; +nosave int swwm_unlockdate_cliffyb = 0; +nosave int swwm_unlockdate_clonk = 0; +nosave int swwm_unlockdate_conga = 0; +nosave int swwm_unlockdate_dab = 0; +nosave int swwm_unlockdate_dakka = 0; +nosave int swwm_unlockdate_dime = 0; +nosave int swwm_unlockdate_dosh = 0; +nosave int swwm_unlockdate_everything = 0; +nosave int swwm_unlockdate_ezkill = 0; +nosave int swwm_unlockdate_flight = 0; +nosave int swwm_unlockdate_friend = 0; +nosave int swwm_unlockdate_fuel = 0; +nosave int swwm_unlockdate_fuller = 0; +nosave int swwm_unlockdate_gcsandwich = 0; +nosave int swwm_unlockdate_gepgun = 0; +nosave int swwm_unlockdate_ghost = 0; +nosave int swwm_unlockdate_gib = 0; +nosave int swwm_unlockdate_golden = 0; +nosave int swwm_unlockdate_gravity = 0; +nosave int swwm_unlockdate_hnd = 0; +nosave int swwm_unlockdate_jump = 0; +nosave int swwm_unlockdate_lead = 0; +nosave int swwm_unlockdate_lightning = 0; +nosave int swwm_unlockdate_ligma = 0; +nosave int swwm_unlockdate_love = 0; +nosave int swwm_unlockdate_mashiro = 0; +nosave int swwm_unlockdate_mbf = 0; +nosave int swwm_unlockdate_mega = 0; +nosave int swwm_unlockdate_moth = 0; +nosave int swwm_unlockdate_nice = 0; +nosave int swwm_unlockdate_oneguy = 0; +nosave int swwm_unlockdate_onestanding = 0; +nosave int swwm_unlockdate_oopsie = 0; +nosave int swwm_unlockdate_par = 0; +nosave int swwm_unlockdate_parry = 0; +nosave int swwm_unlockdate_pene = 0; +nosave int swwm_unlockdate_plush = 0; +nosave int swwm_unlockdate_rage = 0; +nosave int swwm_unlockdate_reflect = 0; +nosave int swwm_unlockdate_refresh = 0; +nosave int swwm_unlockdate_roast = 0; +nosave int swwm_unlockdate_salt = 0; +nosave int swwm_unlockdate_sanic = 0; +nosave int swwm_unlockdate_sekiro = 0; +nosave int swwm_unlockdate_shame = 0; +nosave int swwm_unlockdate_shock = 0; +nosave int swwm_unlockdate_slayer = 0; +nosave int swwm_unlockdate_slemg = 0; +nosave int swwm_unlockdate_sneeze = 0; +nosave int swwm_unlockdate_step = 0; +nosave int swwm_unlockdate_stomp = 0; +nosave int swwm_unlockdate_sunny = 0; +nosave int swwm_unlockdate_tele = 0; +nosave int swwm_unlockdate_thicc = 0; +nosave int swwm_unlockdate_thruwall = 0; +nosave int swwm_unlockdate_wantdie = 0; +nosave int swwm_unlockdate_wave = 0; +nosave int swwm_unlockdate_yeet = 0; // cross-session progress cvars nosave int swwm_progress_acid = 0; nosave int swwm_progress_allcoll = 0; diff --git a/language.def_menu b/language.def_menu index d47eb2fcf..225758821 100644 --- a/language.def_menu +++ b/language.def_menu @@ -177,6 +177,11 @@ SWWM_FILTERACHIEVEMENTS = "Achievement Filtering"; SWWM_FILTER_NONE = "No Filter"; SWWM_FILTER_OBFUSCATE = "Obfuscate"; SWWM_FILTER_HIDE = "Hide"; +SWWM_PLAYTIME = "Total Play Time"; +SWWM_TIME_DAYS = "days"; +SWWM_TIME_HOURS = "hours"; +SWWM_TIME_MINUTES = "minutes"; +SWWM_TIME_SECONDS = "seconds"; SWWM_MMTITLE = "Minimap Settings"; SWWM_MM_ENABLE = "Show Minimap"; SWWM_MM_ROTATE = "Rotate Minimap"; @@ -311,6 +316,7 @@ TOOLTIP_SWWM_ITEMSPARKLES = "Nearby items will have particles around them, as a TOOLTIP_SWWM_SINGLEFIRST = "For weapons that have dual-wield variants, enabling this will always select the single weapon first."; TOOLTIP_SWWM_UNIQSTATS = "Clears duplicate map entries in the mission stats tab, useful to unclutter the list when moving back and forth in hubs."; TOOLTIP_SWWM_FILTERACHIEVEMENTS = "Filters out achievements at 0% in the Demolitionist Menu, if you'd rather avoid spoiling the fun. The 'Obfuscate' option is recommended, as it will at least leave a hint of things to be discovered."; +TOOLTIP_SWWM_PLAYTIME = "Your total play time with this mod loaded."; TOOLTIP_SWWM_MM_ENABLE = "Displays a minimap under the score counter."; TOOLTIP_SWWM_MM_ROTATE = "Rotates the minimap view."; TOOLTIP_SWWM_MM_GRID = "Shows a 128x128 grid on the minimap."; diff --git a/language.es_menu b/language.es_menu index 0583df400..0636f3d94 100644 --- a/language.es_menu +++ b/language.es_menu @@ -176,6 +176,11 @@ SWWM_FILTERACHIEVEMENTS = "Filtro de Logros"; SWWM_FILTER_NONE = "Sin Filtro"; SWWM_FILTER_OBFUSCATE = "Ofuscar"; SWWM_FILTER_HIDE = "Ocultar"; +SWWM_PLAYTIME = "Tiempo de Juego Total"; +SWWM_TIME_DAYS = "días"; +SWWM_TIME_HOURS = "horas"; +SWWM_TIME_MINUTES = "minutos"; +SWWM_TIME_SECONDS = "segundos"; SWWM_MMTITLE = "Opciones de Minimapa"; SWWM_MM_ENABLE = "Mostrar Minimapa"; SWWM_MM_ROTATE = "Rotar Minimapa"; @@ -310,6 +315,7 @@ TOOLTIP_SWWM_ITEMSPARKLES = "Los ítems cercanos tendrán partículas alrededor, TOOLTIP_SWWM_SINGLEFIRST = "Para armas que tienen variantes duales, activando esto selecionará siempre primero el arma singular."; TOOLTIP_SWWM_UNIQSTATS = "Elimina entradas duplicadas de mapa en la pestaña de estadísticas de misión, útil para despejar la lista al moverse por hubs."; TOOLTIP_SWWM_FILTERACHIEVEMENTS = "Filtra logros al 0% en el Menú de Demolicionista, si prefieres no estropear la sorpresa. La opción de 'Ofuscar' es la recomendada, ya que al menos dejará pistas de cosas que quedan por descubrir."; +TOOLTIP_SWWM_PLAYTIME = "Tu tiempo de juego total con este mod cargado."; TOOLTIP_SWWM_MM_ENABLE = "Muestra un minimapa bajo el contador de puntuación."; TOOLTIP_SWWM_MM_ROTATE = "Gira la vista del minimapa."; TOOLTIP_SWWM_MM_GRID = "Muestra una cuadrícula de 128x128 en el minimapa."; diff --git a/language.version b/language.version index e7fd419da..fbf71feb6 100644 --- a/language.version +++ b/language.version @@ -1,3 +1,3 @@ [default] -SWWM_MODVER="\chSWWM \czGZ\c- \cw0.9.11b-pre r457 \cu(Thu 29 Apr 22:57:23 CEST 2021)\c-"; -SWWM_SHORTVER="\cw0.9.11b-pre r457 \cu(2021-04-29 22:57:23)\c-"; +SWWM_MODVER="\chSWWM \czGZ\c- \cw0.9.11b-pre r458 \cu(Thu 29 Apr 23:25:24 CEST 2021)\c-"; +SWWM_SHORTVER="\cw0.9.11b-pre r458 \cu(2021-04-29 23:25:24)\c-"; diff --git a/menudef.txt b/menudef.txt index f1b140356..c27fffd53 100644 --- a/menudef.txt +++ b/menudef.txt @@ -81,6 +81,7 @@ OptionMenu "SWWMOptionMenu" StaticText " " StaticText "$SWWM_PTITLE", "Blue" + SWWMPlayTime "$SWWM_PLAYTIME", "swwm_playtime" SWWMVoiceOption "$SWWM_VOICETYPE", "swwm_voicetype" Option "$SWWM_MUTELEVEL", "swwm_mutevoice", "SWWMVoice" Option "$SWWM_6DOF", "swwm_fly6dof", "YesNo" @@ -88,6 +89,7 @@ OptionMenu "SWWMOptionMenu" ScaleSliderFix "$SWWM_REVIVECOOLDOWN", "swwm_revivecooldown", -1, 300, 30, "$SWWM_UNLIMITED", "$SWWM_ONERETRY" Option "$SWWM_MENUPAUSE", "swwm_menupause", "YesNo" Option "$SWWM_PRECISECROSSHAIR", "swwm_precisecrosshair", "YesNo" + //Submenu "$SWWM_ATITLE", "SWWMAchievementMenu" StaticText " " StaticText "$SWWM_OTITLE", "Blue" Option "$SWWM_SHADERS", "swwm_shaders", "YesNo" diff --git a/zscript/handler/swwm_statichandler_achievements.zsc b/zscript/handler/swwm_statichandler_achievements.zsc index f0fc8d018..fa75d8ae4 100644 --- a/zscript/handler/swwm_statichandler_achievements.zsc +++ b/zscript/handler/swwm_statichandler_achievements.zsc @@ -27,6 +27,7 @@ extend Class SWWMStaticHandler if ( (val == 1) && (gametic > lastachievementnotify) ) { a.state.SetInt(2); + a.date.SetInt(SystemTime.Now()); EventHandler.SendNetworkEvent("swwmachievement."..a.basename,consoleplayer); let notif = new("SWWMAchievementNotification").Init(a.basename,a.icon,a.hasformat?a.maxval:0); StatusBar.AttachMessage(notif,-3478); diff --git a/zscript/menu/swwm_menus.zsc b/zscript/menu/swwm_menus.zsc index 51ee6ff1b..9364f4200 100644 --- a/zscript/menu/swwm_menus.zsc +++ b/zscript/menu/swwm_menus.zsc @@ -112,6 +112,66 @@ Class OptionMenuItemSWWMVoiceOption : OptionMenuItemOptionBase } } +Class OptionMenuItemSWWMPlayTime : OptionMenuItem +{ + CVar mCVar; + bool dformat; // switch between short form and long form time display + + OptionMenuItemSWWMPlayTime Init( String label, Name command ) + { + Super.Init(label,command); + return self; + } + + override bool MenuEvent( int mkey, bool fromcontroller ) + { + if ( (mkey == Menu.MKEY_Left) || (mkey == Menu.MKEY_Right) || (mkey == Menu.MKEY_Enter) ) + dformat = !dformat; + else return Super.MenuEvent(mkey,fromcontroller); + Menu.MenuSound("menu/change"); + return true; + } + + override int Draw( OptionMenuDescriptor desc, int y, int indent, bool selected ) + { + drawLabel(indent,y,selected?OptionMenuSettings.mFontColorSelection:OptionMenuSettings.mFontColor); + int val = swwm_playtime; + int sec = (val%60); + int min = ((val/60)%60); + int hour = ((val/3600)%24); + int day = val/86400; + String str = ""; + if ( dformat ) + { + if ( day ) str.AppendFormat("%d %s",day,StringTable.Localize("$SWWM_TIME_DAYS")); + if ( hour ) + { + if ( str != "" ) str = str..", "; + str.AppendFormat("%d %s",hour,StringTable.Localize("$SWWM_TIME_HOURS")); + } + if ( min ) + { + if ( str != "" ) str = str..", "; + str.AppendFormat("%d %s",min,StringTable.Localize("$SWWM_TIME_MINUTES")); + } + if ( sec ) + { + if ( str != "" ) str = str..", "; + str.AppendFormat("%d %s",sec,StringTable.Localize("$SWWM_TIME_SECONDS")); + } + if ( str == "" ) str.AppendFormat("0 %s",StringTable.Localize("$SWWM_TIME_SECONDS")); + } + else + { + if ( day ) str = String.Format("%d:%02d:%02d:%02d",day,hour,min,sec); + else if ( hour ) str = String.Format("%d:%02d:%02d",hour,min,sec); + else str = String.Format("%d:%02d",min,sec); + } + drawValue(indent,y,OptionMenuSettings.mFontColorValue,str); + return indent; + } +} + // option menu /w tooltips Class SWWMOptionMenu : OptionMenu { diff --git a/zscript/swwm_statichandler.zsc b/zscript/swwm_statichandler.zsc index 20200c787..423e6da66 100644 --- a/zscript/swwm_statichandler.zsc +++ b/zscript/swwm_statichandler.zsc @@ -205,11 +205,7 @@ Class SWWMStaticHandler : StaticEventHandler Console.Printf("swwm_progress_"..achievements[i].basename.."="..achievements[i].progress.GetString()); } } - } - - override void NetworkProcess( ConsoleEvent e ) - { - if ( e.Name ~== "swwmgetversion" ) + else if ( e.Name ~== "swwmgetversion" ) { let ti = ThinkerIterator.Create("SWWMSaveVerData",Thinker.STAT_STATIC); let svd = SWWMSaveVerData(ti.Next()); @@ -217,8 +213,11 @@ Class SWWMStaticHandler : StaticEventHandler else Console.Printf("\cg(no version data)\c-"); if ( tainted ) Console.Printf("\cgversion mismatched\c-"); else Console.Printf("\cdversion not mismatched\c-"); - return; } + } + + override void NetworkProcess( ConsoleEvent e ) + { if ( e.IsManual ) return; if ( e.Name.Left(12) ~== "swwmversion." ) { diff --git a/zscript/utility/swwm_utility.zsc b/zscript/utility/swwm_utility.zsc index 939538da4..7da8df5be 100644 --- a/zscript/utility/swwm_utility.zsc +++ b/zscript/utility/swwm_utility.zsc @@ -16,7 +16,7 @@ enum EDoExplosionFlags Class SWWMAchievement { String basename; - transient CVar state, progress; + transient CVar state, progress, date; TextureID icon; int maxval; bool hasformat; @@ -57,7 +57,6 @@ Class SWWMUtility let ac = new("SWWMAchievement"); ac.basename = ln[0]; ac.maxval = ln[1].ToInt(); - ac.hasformat = (ln[2]~=="yes"); ac.state = CVar.FindCVar("swwm_achievement_"..ac.basename); // if filtering, always hide the full completion achievement until it's unlocked if ( filter && (ac.basename == "everything") && (ac.state.GetInt() <= 0) ) @@ -87,15 +86,17 @@ Class SWWMUtility } } else ac.progress = null; - ac.icon = TexMan.CheckForTexture("graphics/Achievements/Achievement"..ac.basename..".png",TexMan.Type_Any); - // fallback icon if one is not found - if ( !ac.icon.IsValid() ) ac.icon = TexMan.CheckForTexture("graphics/Achievements/DefaultAchievement.png",TexMan.Type_Any); // hide away achievements at 0% if ( hide && (ac.state.GetInt() <= 0) && (!ac.progress || (ac.progress.GetInt() <= 0)) ) { ac.Destroy(); continue; } + ac.hasformat = (ln[2]~=="yes"); + ac.icon = TexMan.CheckForTexture("graphics/Achievements/Achievement"..ac.basename..".png",TexMan.Type_Any); + // fallback icon if one is not found + if ( !ac.icon.IsValid() ) ac.icon = TexMan.CheckForTexture("graphics/Achievements/DefaultAchievement.png",TexMan.Type_Any); + ac.date = CVar.FindCVar("swwm_unlockdate_"..ac.basename); achievements.Push(ac); } }