module Game.LambdaHack.Client.UI.MsgM
( msgAddDuplicate, msgAdd, promptAddDuplicate, promptAdd1, promptAdd0
, promptMainKeys, recordHistory
) where
import Prelude ()
import Game.LambdaHack.Common.Prelude
import qualified Game.LambdaHack.Client.UI.HumanCmd as HumanCmd
import qualified Game.LambdaHack.Client.UI.Key as K
import Game.LambdaHack.Client.UI.MonadClientUI
import Game.LambdaHack.Client.UI.Msg
import Game.LambdaHack.Client.UI.Overlay
import Game.LambdaHack.Client.UI.SessionUI
import Game.LambdaHack.Client.UI.UIOptions
import Game.LambdaHack.Common.Faction
import Game.LambdaHack.Common.MonadStateRead
import Game.LambdaHack.Common.State
msgAddDuplicate :: MonadClientUI m => Text -> m Bool
msgAddDuplicate msg = do
history <- getsSession shistory
let (nhistory, duplicate) = addToReport history (toMsg $ textToAL msg) 1
modifySession $ \sess -> sess {shistory = nhistory}
return duplicate
msgAdd :: MonadClientUI m => Text -> m ()
msgAdd = void <$> msgAddDuplicate
promptAddDuplicate :: MonadClientUI m => Text -> Int -> m Bool
promptAddDuplicate msg n = do
history <- getsSession shistory
let (nhistory, duplicate) = addToReport history (toPrompt $ textToAL msg) n
modifySession $ \sess -> sess {shistory = nhistory}
return duplicate
promptAdd1 :: MonadClientUI m => Text -> m ()
promptAdd1 = void <$> flip promptAddDuplicate 1
promptAdd0 :: MonadClientUI m => Text -> m ()
promptAdd0 = void <$> flip promptAddDuplicate 0
promptMainKeys :: MonadClientUI m => m ()
promptMainKeys = do
revCmd <- revCmdMap
let km = revCmd (K.mkChar '?') HumanCmd.Hint
saimMode <- getsSession saimMode
UIOptions{uVi, uLaptop} <- getsSession sUIOptions
xhair <- getsSession sxhair
let moveKeys | uVi = "keypad or hjklyubn"
| uLaptop = "keypad or uk8o79jl"
| otherwise = "keypad"
moreHelp = "Press" <+> tshow km <+> "for help."
keys | isNothing saimMode =
"Explore with" <+> moveKeys <+> "keys or mouse." <+> moreHelp
| otherwise =
"Aim" <+> tgtKindDescription xhair
<+> "with" <+> moveKeys <+> "keys or mouse." <+> moreHelp
void $ promptAdd0 keys
recordHistory :: MonadClientUI m => m ()
recordHistory = do
time <- getsState stime
history <- getsSession shistory
modifySession $ \sess -> sess {shistory = archiveReport history time}