Skip to content

Commit

Permalink
highlight tpf rate in red when it hits the cap
Browse files Browse the repository at this point in the history
Closes #1348.
  • Loading branch information
byorgey committed Jul 20, 2023
1 parent f0078cd commit 8926350
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Swarm/TUI/Controller.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module Swarm.TUI.Controller (
-- ** Handling 'Frame' events
runFrameUI,
runFrame,
ticksPerFrameCap,
runFrameTicks,
runGameTickUI,
runGameTick,
Expand Down
5 changes: 4 additions & 1 deletion src/Swarm/TUI/View.hs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ import Swarm.Language.Syntax
import Swarm.Language.Typecheck (inferConst)
import Swarm.TUI.Attr
import Swarm.TUI.Border
import Swarm.TUI.Controller (ticksPerFrameCap)
import Swarm.TUI.Editor.Model
import Swarm.TUI.Editor.View qualified as EV
import Swarm.TUI.Inventory.Sorting (renderSortMethod)
Expand Down Expand Up @@ -534,7 +535,9 @@ drawTPS s = hBox (tpsInfo : rateInfo)
rateInfo
| s ^. uiState . uiShowFPS =
[ txt " ("
, str (printf "%0.1f" (s ^. uiState . uiTPF))
, let tpf = s ^. uiState . uiTPF
in (if tpf >= fromIntegral ticksPerFrameCap then withAttr redAttr else id)
(str (printf "%0.1f" tpf))
, txt " tpf, "
, str (printf "%0.1f" (s ^. uiState . uiFPS))
, txt " fps)"
Expand Down

0 comments on commit 8926350

Please sign in to comment.