From 005f13b85345225fd1d51bbbeec2437155a60acd Mon Sep 17 00:00:00 2001 From: Maarten Lensink Date: Sun, 30 Aug 2020 03:53:05 +0300 Subject: [PATCH 1/3] Time in coop tally --- .../zscript/ui/statscreen/statscreen.zs | 39 ++++++++++++++++ .../zscript/ui/statscreen/statscreen_coop.zs | 45 +++++++++++++++++-- 2 files changed, 80 insertions(+), 4 deletions(-) diff --git a/wadsrc/static/zscript/ui/statscreen/statscreen.zs b/wadsrc/static/zscript/ui/statscreen/statscreen.zs index 007b3a9e34..18a4f8d7dd 100644 --- a/wadsrc/static/zscript/ui/statscreen/statscreen.zs +++ b/wadsrc/static/zscript/ui/statscreen/statscreen.zs @@ -507,6 +507,45 @@ class StatusScreen abstract play version("2.5") drawTextScaled(fnt, x - fnt.StringWidth(s) * scale, y, s, scale, color); } + //==================================================================== + // + // Display the completed time scaled + // + //==================================================================== + + void drawTimeScaled (Font fnt, int x, int y, int t, double scale, int color = Font.CR_UNTRANSLATED) + { + int sec = Thinker.Tics2Seconds(Plrs[me].stime); + if (t < 0) + return; + + int hours = t / 3600; + t -= hours * 3600; + int minutes = t / 60; + t -= minutes * 60; + int seconds = t; + + String s = ""; + if (hours > 0) + { + s = String.Format("%d", hours) .. ":"; + } + + if (hours > 0 || minutes < 10) + { + s = s .. "0"; + } + s = s .. String.Format("%d", minutes) .. ":"; + + if (seconds < 10) + { + s = s .. "0"; + } + s = s .. String.Format("%d", seconds); + + drawTextScaled(fnt, x - fnt.StringWidth(s) * scale, y, s, scale, color); + } + //==================================================================== // // Display level completion time and par, or "sucks" message if overflow. diff --git a/wadsrc/static/zscript/ui/statscreen/statscreen_coop.zs b/wadsrc/static/zscript/ui/statscreen/statscreen_coop.zs index 48bf30d93b..9aab6a4e92 100644 --- a/wadsrc/static/zscript/ui/statscreen/statscreen_coop.zs +++ b/wadsrc/static/zscript/ui/statscreen/statscreen_coop.zs @@ -53,7 +53,7 @@ class CoopStatusScreen : StatusScreen bool stillticking; bool autoskip = autoSkip(); - if ((acceleratestage || autoskip) && ng_state != 10) + if ((acceleratestage || autoskip) && ng_state != 12) { acceleratestage = 0; @@ -70,7 +70,7 @@ class CoopStatusScreen : StatusScreen cnt_frags[i] = fragSum (i); } PlaySound("intermission/nextstage"); - ng_state = 10; + ng_state = 12; } if (ng_state == 2) @@ -146,7 +146,7 @@ class CoopStatusScreen : StatusScreen if (!stillticking) { PlaySound("intermission/nextstage"); - ng_state += 1 + 2*!dofrags; + ng_state ++; } } else if (ng_state == 8) @@ -156,6 +156,34 @@ class CoopStatusScreen : StatusScreen stillticking = false; + cnt_time += 3; + cnt_total_time += 3; + + int sec = Thinker.Tics2Seconds(Plrs[me].stime); + if (cnt_time > sec) + cnt_time = sec; + else + stillticking = true; + + int tsec = Thinker.Tics2Seconds(wbs.totaltime); + if (cnt_total_time > tsec) + cnt_total_time = tsec; + else + stillticking = true; + + if (!stillticking) + { + PlaySound("intermission/nextstage"); + ng_state += 1 + 2*!dofrags; + } + } + else if (ng_state == 10) + { + if (!(bcnt&3)) + PlaySound("intermission/tick"); + + stillticking = false; + for (i=0 ; i= 8) + { + drawTimeScaled(displayFont, kills_x, y, cnt_time, FontScale, textcolor); + drawTimeScaled(displayFont, secret_x, y, cnt_total_time, FontScale, textcolor); + } } } From 2e0289e501894c7c840a6a4e08dfbc031518709c Mon Sep 17 00:00:00 2001 From: Maarten Lensink Date: Sun, 30 Aug 2020 15:12:23 +0300 Subject: [PATCH 2/3] Making use of String.Format --- .../zscript/ui/statscreen/statscreen.zs | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/wadsrc/static/zscript/ui/statscreen/statscreen.zs b/wadsrc/static/zscript/ui/statscreen/statscreen.zs index 18a4f8d7dd..6b7daa205e 100644 --- a/wadsrc/static/zscript/ui/statscreen/statscreen.zs +++ b/wadsrc/static/zscript/ui/statscreen/statscreen.zs @@ -515,7 +515,6 @@ class StatusScreen abstract play version("2.5") void drawTimeScaled (Font fnt, int x, int y, int t, double scale, int color = Font.CR_UNTRANSLATED) { - int sec = Thinker.Tics2Seconds(Plrs[me].stime); if (t < 0) return; @@ -525,23 +524,7 @@ class StatusScreen abstract play version("2.5") t -= minutes * 60; int seconds = t; - String s = ""; - if (hours > 0) - { - s = String.Format("%d", hours) .. ":"; - } - - if (hours > 0 || minutes < 10) - { - s = s .. "0"; - } - s = s .. String.Format("%d", minutes) .. ":"; - - if (seconds < 10) - { - s = s .. "0"; - } - s = s .. String.Format("%d", seconds); + String s = (hours > 0 ? String.Format("%d:", hours) : "") .. String.Format("%02d:%02d", minutes, seconds); drawTextScaled(fnt, x - fnt.StringWidth(s) * scale, y, s, scale, color); } From c81370a9ecb38858ab384041bb2f10fac4747583 Mon Sep 17 00:00:00 2001 From: Maarten Lensink Date: Sun, 30 Aug 2020 15:40:26 +0300 Subject: [PATCH 3/3] Showing time when skipping counter --- wadsrc/static/zscript/ui/statscreen/statscreen_coop.zs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/wadsrc/static/zscript/ui/statscreen/statscreen_coop.zs b/wadsrc/static/zscript/ui/statscreen/statscreen_coop.zs index 9aab6a4e92..6e4c2f0b8c 100644 --- a/wadsrc/static/zscript/ui/statscreen/statscreen_coop.zs +++ b/wadsrc/static/zscript/ui/statscreen/statscreen_coop.zs @@ -69,6 +69,10 @@ class CoopStatusScreen : StatusScreen if (dofrags) cnt_frags[i] = fragSum (i); } + + cnt_time = Thinker.Tics2Seconds(Plrs[me].stime); + cnt_total_time = Thinker.Tics2Seconds(wbs.totaltime); + PlaySound("intermission/nextstage"); ng_state = 12; }