From aeefbd4c403ef5e55081371ef8254a9be51a40d9 Mon Sep 17 00:00:00 2001 From: justin Date: Wed, 3 May 2023 22:37:57 +0100 Subject: [PATCH] Start move towards using assignable hotkeys for active equipment --- src/Dodge/Creature/Impulse/UseItem.hs | 2 +- src/Dodge/Data/Creature.hs | 3 +++ src/Dodge/Data/Equipment/Misc.hs | 11 ++++++++++- src/Dodge/Data/Item/Use/Consumption/LoadAction.hs | 1 - src/Dodge/Default/Creature.hs | 6 ++++-- 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/Dodge/Creature/Impulse/UseItem.hs b/src/Dodge/Creature/Impulse/UseItem.hs index cc8fe6ebe..a85a1d40f 100644 --- a/src/Dodge/Creature/Impulse/UseItem.hs +++ b/src/Dodge/Creature/Impulse/UseItem.hs @@ -111,7 +111,7 @@ toggleEquipmentAt rbops invid cr w = case rbops ^? opAllocateEquipment of crpoint = cWorld . lWorld . creatures . ix (_crID cr) itmat i = _crInv cr IM.! i itm = itmat itRef - itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change + itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change? onequip itm' = useE ((_eeOnEquip . _equipEffect . _itUse) itm') itm' onremove itm' = useE ((_eeOnRemove . _equipEffect . _itUse) itm') itm' diff --git a/src/Dodge/Data/Creature.hs b/src/Dodge/Data/Creature.hs index c7d52e221..ec005f2de 100644 --- a/src/Dodge/Data/Creature.hs +++ b/src/Dodge/Data/Creature.hs @@ -32,6 +32,7 @@ import Dodge.Data.Item import Dodge.Data.Material import Geometry.Data import qualified IntMapHelp as IM + --import MaybeHelp data Creature = Creature @@ -56,6 +57,8 @@ data Creature = Creature , _crInvEquipped :: IM.IntMap EquipPosition , _crEquipment :: M.Map EquipPosition Int , _crLeftInvSel :: LeftInvSel + , _crInvHotkeys :: IM.IntMap Hotkey + , _crHotkeys :: M.Map Hotkey Int , _crState :: CreatureState , _crCorpse :: CreatureCorpse --Creature -> Corpse -> SPic , _crMaterial :: Material diff --git a/src/Dodge/Data/Equipment/Misc.hs b/src/Dodge/Data/Equipment/Misc.hs index 56a3f1461..dfeaf33fa 100644 --- a/src/Dodge/Data/Equipment/Misc.hs +++ b/src/Dodge/Data/Equipment/Misc.hs @@ -27,10 +27,19 @@ data EquipPosition | OnSpecial deriving (Eq, Ord) --deriving (Eq, Ord, Show, Read) --Generic, Flat) +data Hotkey = HotkeyQ + | HotkeyE + | Hotkey1 + | Hotkey2 + | Hotkey3 + | Hotkey4 + deriving (Eq, Show, Read, Ord, Bounded, Enum) --Generic, Flat) deriveJSON defaultOptions ''EquipSite deriveJSON defaultOptions ''EquipPosition +deriveJSON defaultOptions ''Hotkey instance ToJSONKey EquipPosition - instance FromJSONKey EquipPosition +instance ToJSONKey Hotkey +instance FromJSONKey Hotkey diff --git a/src/Dodge/Data/Item/Use/Consumption/LoadAction.hs b/src/Dodge/Data/Item/Use/Consumption/LoadAction.hs index 3bbf2f9db..5e76d00c6 100644 --- a/src/Dodge/Data/Item/Use/Consumption/LoadAction.hs +++ b/src/Dodge/Data/Item/Use/Consumption/LoadAction.hs @@ -48,7 +48,6 @@ data InvSelAction data LeftInvSel = LeftInvSel { _lisMPos :: Maybe Int - , _lisActive :: Bool } makeLenses ''LoadAction diff --git a/src/Dodge/Default/Creature.hs b/src/Dodge/Default/Creature.hs index 2aa64e8c2..bacab0dbf 100644 --- a/src/Dodge/Default/Creature.hs +++ b/src/Dodge/Default/Creature.hs @@ -30,13 +30,15 @@ defaultCreature = , _crManipulation = Manipulator SelNothing , _crInvCapacity = 25 , _crInvLock = False - , _crInvEquipped = mempty - , _crLeftInvSel = LeftInvSel Nothing False + , _crLeftInvSel = LeftInvSel Nothing , _crState = defaultState , _crCorpse = MakeDefaultCorpse , _crMaterial = Flesh , _crPastDamage = 0 + , _crInvEquipped = mempty , _crEquipment = M.empty + , _crInvHotkeys = mempty + , _crHotkeys = M.empty , _crStance = Stance { _carriage = Walking 0 WasLeftForward