Skip to content

Commit

Permalink
warn the user when debugging options are on
Browse files Browse the repository at this point in the history
  • Loading branch information
byorgey committed Jan 9, 2025
1 parent 2193e84 commit 462b034
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/swarm-tui/Swarm/TUI/Model/Dialog/Popup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ data Popup
= AchievementPopup CategorizedAchievement
| RecipesPopup
| CommandsPopup [Const]
| DebugWarningPopup

-- | State to track pending popup queue as well as any
-- popup which is currently being displayed.
Expand Down
9 changes: 8 additions & 1 deletion src/swarm-tui/Swarm/TUI/Model/StateUpdate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import Control.Effect.Accum
import Control.Effect.Lift
import Control.Effect.Throw
import Control.Lens hiding (from, (<.>))
import Control.Monad (guard, void)
import Control.Monad (guard, unless, void)
import Control.Monad.Except (ExceptT (..))
import Control.Monad.IO.Class (MonadIO (liftIO))
import Control.Monad.State (MonadState, execStateT)
Expand Down Expand Up @@ -217,6 +217,13 @@ startGameWithSeed siPair@(_scene, si) lp = do
-- Beware: currentScenarioPath must be set so that progress/achievements can be saved.
-- It has just been cleared in scenarioToAppState.
gameState . currentScenarioPath .= Just p

-- Warn the user that the use of debugging options means progress
-- will not be saved.
debugging <- use $ uiState . uiDebugOptions
unless (null debugging) $
uiState . uiPopups %= addPopup DebugWarningPopup

where
prevBest t = case si ^. scenarioStatus of
NotStarted -> emptyBest t
Expand Down
5 changes: 5 additions & 0 deletions src/swarm-tui/Swarm/TUI/View/Popup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ drawPopup s = \case
]
, txt $ "Hit " <> bindingText s (SE.Main SE.ViewCommandsEvent) <> " to view all available commands."
]
DebugWarningPopup ->
hBox
[ withAttr notifAttr (txt "Warning: ")
, txt $ "No progress will be saved, since debugging flags are in use."

Check warning on line 62 in src/swarm-tui/Swarm/TUI/View/Popup.hs

View workflow job for this annotation

GitHub Actions / HLint

Warning in drawPopup in module Swarm.TUI.View.Popup: Redundant $ ▫︎ Found: "txt\n $ \"No progress will be saved, since debugging flags are in use.\"" ▫︎ Perhaps: "txt \"No progress will be saved, since debugging flags are in use.\""
]

-- | Compute the number of rows of the notification popup we should be
-- showing, based on the number of frames the popup has existed.
Expand Down

0 comments on commit 462b034

Please sign in to comment.