feat(gs/xanthous): Default to the current save file
When saving, default to the save file that was loaded for the game if any. To support this, this also makes text prompts support a default, which will be used if no value is input. Change-Id: I72a826499d6e987b939e3465a2d29167e53416be Reviewed-on: https://cl.tvl.fyi/c/depot/+/3801 Reviewed-by: grfn <grfn@gws.fyi> Tested-by: BuildkiteCI
This commit is contained in:
parent
099f36e5ee
commit
ff6c008d78
8 changed files with 93 additions and 31 deletions
|
|
@ -5,6 +5,8 @@ module Xanthous.App.Prompt
|
|||
, clearPrompt
|
||||
, prompt
|
||||
, prompt_
|
||||
, stringPromptWithDefault
|
||||
, stringPromptWithDefault_
|
||||
, confirm_
|
||||
, confirm
|
||||
, menu
|
||||
|
|
@ -123,7 +125,7 @@ prompt msgPath params cancellable cb = do
|
|||
SPointOnMap -> do
|
||||
charPos <- use characterPosition
|
||||
pure . Just $ mkPointOnMapPrompt cancellable charPos cb
|
||||
SStringPrompt -> pure . Just $ mkPrompt cancellable pt cb
|
||||
SStringPrompt -> pure . Just $ mkStringPrompt cancellable cb
|
||||
SConfirm -> pure . Just $ mkPrompt cancellable pt cb
|
||||
SDirectionPrompt -> pure . Just $ mkPrompt cancellable pt cb
|
||||
SContinue -> pure . Just $ mkPrompt cancellable pt cb
|
||||
|
|
@ -138,6 +140,27 @@ prompt_
|
|||
-> AppM ()
|
||||
prompt_ msg = prompt msg $ object []
|
||||
|
||||
stringPromptWithDefault
|
||||
:: forall (params :: Type). (ToJSON params)
|
||||
=> [Text] -- ^ Message key
|
||||
-> params -- ^ Message params
|
||||
-> PromptCancellable
|
||||
-> Text -- ^ Prompt default
|
||||
-> (PromptResult 'StringPrompt -> AppM ()) -- ^ Prompt promise handler
|
||||
-> AppM ()
|
||||
stringPromptWithDefault msgPath params cancellable def cb = do
|
||||
msg <- Messages.message msgPath params
|
||||
let p = mkStringPromptWithDefault cancellable def cb
|
||||
promptState .= WaitingPrompt msg p
|
||||
|
||||
stringPromptWithDefault_
|
||||
:: [Text] -- ^ Message key
|
||||
-> PromptCancellable
|
||||
-> Text -- ^ Prompt default
|
||||
-> (PromptResult 'StringPrompt -> AppM ()) -- ^ Prompt promise handler
|
||||
-> AppM ()
|
||||
stringPromptWithDefault_ msg = stringPromptWithDefault msg $ object []
|
||||
|
||||
confirm
|
||||
:: ToJSON params
|
||||
=> [Text] -- ^ Message key
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue