From ce66ee40fb27173341304e334ace370b359dd912 Mon Sep 17 00:00:00 2001 From: Noah Yorgey Date: Sat, 20 Jul 2024 16:34:52 -0400 Subject: [PATCH 1/2] Testing --- src/swarm-tui/Swarm/TUI/View.hs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/swarm-tui/Swarm/TUI/View.hs b/src/swarm-tui/Swarm/TUI/View.hs index 775c088724..58883e844b 100644 --- a/src/swarm-tui/Swarm/TUI/View.hs +++ b/src/swarm-tui/Swarm/TUI/View.hs @@ -591,14 +591,14 @@ drawTPS :: AppState -> Widget Name drawTPS s = hBox (tpsInfo : rateInfo) where tpsInfo - | l >= 0 = hBox [str (show n), txt " ", txt (number n "tick"), txt " / s"] + | l >= 0 = hBox [str (show n), txt " ", tpsIndicator s, txt (number n "tick"), txt " / s"] + -- | l >= 0 = hBox [str (show n), txt " ", txt (number n "tick"), txt " / s"] | otherwise = hBox [txt "1 tick / ", str (show n), txt " s"] rateInfo | s ^. uiState . uiGameplay . uiTiming . uiShowFPS = [ txt " (" - , let tpf = s ^. uiState . uiGameplay . uiTiming . uiTPF - in (if tpf >= fromIntegral ticksPerFrameCap then withAttr redAttr else id) + , (if tpf >= fromIntegral ticksPerFrameCap then withAttr redAttr else id) (str (printf "%0.1f" tpf)) , txt " tpf, " , str (printf "%0.1f" (s ^. uiState . uiGameplay . uiTiming . uiFPS)) @@ -606,9 +606,24 @@ drawTPS s = hBox (tpsInfo : rateInfo) ] | otherwise = [] + tpf = s ^. uiState . uiGameplay . uiTiming . uiTPF l = s ^. uiState . uiGameplay . uiTiming . lgTicksPerSecond n = 2 ^ abs l +tpsIndicator :: AppState -> Widget Name +tpsIndicator s + = hBox [txt "(", str $ show tps, txt ") "] + -- = str (show $ round tps ) + + -- | (tps / target) < 0.9 = str (show $ round tps ) + -- | otherwise = emptyWidget + where + tpf = s ^. uiState . uiGameplay . uiTiming . uiTPF + fps = s ^. uiState . uiGameplay . uiTiming . uiFPS + tps = fps / tpf + -- l = s ^. uiState . uiGameplay . uiTiming . lgTicksPerSecond + -- target = 2 ^^ l + -- | The height of the REPL box. Perhaps in the future this should be -- configurable. replHeight :: Int From 40c88d74ac1c7a6cbda3d793947283bd5106d57b Mon Sep 17 00:00:00 2001 From: Noah Yorgey Date: Fri, 26 Jul 2024 20:12:30 -0400 Subject: [PATCH 2/2] Fix math --- src/swarm-tui/Swarm/TUI/View.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/swarm-tui/Swarm/TUI/View.hs b/src/swarm-tui/Swarm/TUI/View.hs index 58883e844b..d258be21e2 100644 --- a/src/swarm-tui/Swarm/TUI/View.hs +++ b/src/swarm-tui/Swarm/TUI/View.hs @@ -620,7 +620,7 @@ tpsIndicator s where tpf = s ^. uiState . uiGameplay . uiTiming . uiTPF fps = s ^. uiState . uiGameplay . uiTiming . uiFPS - tps = fps / tpf + tps = tpf * fps -- l = s ^. uiState . uiGameplay . uiTiming . lgTicksPerSecond -- target = 2 ^^ l