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/Resource.hs | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) (limited to 'src/Xanthous/Resource.hs') diff --git a/src/Xanthous/Resource.hs b/src/Xanthous/Resource.hs index 5350e7646e38..cc2fc97a1464 100644 --- a/src/Xanthous/Resource.hs +++ b/src/Xanthous/Resource.hs @@ -1,24 +1,31 @@ -------------------------------------------------------------------------------- module Xanthous.Resource - ( Name(..) + ( Panel(..) + , Name(..) ) where -------------------------------------------------------------------------------- import Xanthous.Prelude -------------------------------------------------------------------------------- import Test.QuickCheck -import Test.QuickCheck.Arbitrary.Generic +import Data.Aeson (ToJSON, FromJSON) +-------------------------------------------------------------------------------- +import Xanthous.Util.QuickCheck -------------------------------------------------------------------------------- -data Name = MapViewport - -- ^ The main viewport where we display the game content - | Character - -- ^ The character - | MessageBox - -- ^ The box where we display messages to the user - | Prompt - -- ^ The game's prompt - deriving stock (Show, Eq, Ord, Generic) - deriving anyclass (NFData, CoArbitrary, Function) +-- | Enum for "panels" displayed in the game's UI. +data Panel + = InventoryPanel -- ^ A panel displaying the character's inventory + deriving stock (Show, Eq, Ord, Generic, Enum, Bounded) + deriving anyclass (NFData, CoArbitrary, Function, ToJSON, FromJSON) + deriving Arbitrary via GenericArbitrary Panel -instance Arbitrary Name where - arbitrary = genericArbitrary + +data Name + = MapViewport -- ^ The main viewport where we display the game content + | Character -- ^ The character + | MessageBox -- ^ The box where we display messages to the user + | Prompt -- ^ The game's prompt + | Panel Panel -- ^ A panel in the game + deriving stock (Show, Eq, Ord, Generic) + deriving anyclass (NFData, CoArbitrary, Function, ToJSON, FromJSON) + deriving Arbitrary via GenericArbitrary Name -- cgit 1.4.1