From 65b1352ef2e463393d0504c32b73bdcf7c99491a Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Sat, 30 Nov 2019 22:43:17 -0500 Subject: Add a very basic inventory panel Add a very basic inventory panel to the game opened by pressing `i`, which displays the contents of the player's inventory in a basic list. --- src/Xanthous/App.hs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/Xanthous/App.hs') diff --git a/src/Xanthous/App.hs b/src/Xanthous/App.hs index df76eadc3bbc..9d606bbef344 100644 --- a/src/Xanthous/App.hs +++ b/src/Xanthous/App.hs @@ -34,7 +34,7 @@ import Xanthous.Game.State import Xanthous.Game.Draw (drawGame) import Xanthous.Game.Prompt import Xanthous.Monad -import Xanthous.Resource (Name) +import Xanthous.Resource (Name, Panel(..)) import qualified Xanthous.Messages as Messages import Xanthous.Util.Inflection (toSentence) -------------------------------------------------------------------------------- @@ -231,6 +231,8 @@ handleCommand Read = do in readAndContinue msgs continue +handleCommand Inventory = showPanel InventoryPanel >> continue + handleCommand Save = do -- TODO default save locations / config file? prompt_ @'StringPrompt ["save", "location"] Cancellable @@ -439,4 +441,9 @@ entityMenu_ = mkMenuItems @[_] . map entityMenuItem -- entityMenu :: Entity entity => [entity] -> Map Char (MenuOption entity) -- entityMenu = map (map runIdentity) . entityMenu_ . fmap Identity --------------------------------------------------------------------------------- +showPanel :: Panel -> AppM () +showPanel panel = do + activePanel ?= panel + prompt_ @'Continue ["generic", "continue"] Uncancellable + . const + $ activePanel .= Nothing -- cgit 1.4.1