Cleanup and fix selection section cursor position bug

This commit is contained in:
2023-05-19 19:29:37 +01:00
parent 03b793802f
commit 17c79e7cee
6 changed files with 35 additions and 37 deletions
+5 -9
View File
@@ -34,23 +34,19 @@ useItemRightClick cr' w = fromMaybe (f w) $ do
itemEffect :: Creature -> Item -> World -> World
itemEffect cr it w = case it ^. itUse of
HeldUse{_heldUse = eff, _heldMods = usemods} ->
hammerTest $ foldl' (&) (useHeld eff) (useMod usemods) it cr
foldl' (&) (useHeld eff) (useMod usemods) it cr w
LeftUse{} -> doequipmentchange
EquipUse{} -> doequipmentchange
-- ConsumeUse will cause problems if the item is not selected
(ConsumeUse eff _) -> setuhamdown $ hammerTest $ useC eff it cr . rmInvItem (_crID cr) itRef
CraftUse{} -> setuhamdown w
(ConsumeUse eff _) -> useC eff it cr $ rmInvItem (_crID cr) itRef w
CraftUse{} -> w
where
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
hammerTest f = case _crHammerPosition cr of
HammerUp -> f w
HammerUp -> f w & setuhamdown
_ -> w & setuhamdown
setuhamdown = cWorld . lWorld . creatures . ix (_crID cr) . crHammerPosition .~ HammerDown
doequipmentchange =
setuhamdown $
hammerTest
( toggleEquipmentAt itRef cr
)
doequipmentchange = hammerTest $ toggleEquipmentAt itRef cr
toggleEquipmentAt :: Int -> Creature -> World -> World
toggleEquipmentAt invid cr w = case getEquipmentAllocation w of