From 0b435410805aae254a64612eef79643445c6df10 Mon Sep 17 00:00:00 2001 From: justin Date: Mon, 4 Nov 2024 10:00:10 +0000 Subject: [PATCH] Tweak combine inventory display/click events --- ghcidOutput | 2 +- src/Dodge/Render/Picture.hs | 39 ++++++++++++++++++++------------ src/Dodge/Update/Input/InGame.hs | 3 +++ 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/ghcidOutput b/ghcidOutput index 89b6f305c..244eb6a7f 100644 --- a/ghcidOutput +++ b/ghcidOutput @@ -1 +1 @@ -All good (594 modules, at 09:31:25) +All good (594 modules, at 10:00:00) diff --git a/src/Dodge/Render/Picture.hs b/src/Dodge/Render/Picture.hs index ead292b14..494f16814 100644 --- a/src/Dodge/Render/Picture.hs +++ b/src/Dodge/Render/Picture.hs @@ -79,17 +79,20 @@ drawMouseCursor u = mouseCursorType :: Universe -> Picture mouseCursorType u | isselect = drawPlus 5 - | Just csel <- u ^? uvWorld . hud . hudElement . subInventory . ciSelection - = if (csel == u ^? uvWorld . hud . hudElement . subInventory . ciMouseOver . _Just - || null (u ^? uvWorld . hud . hudElement . subInventory . ciMouseOver . _Just)) + | Just csel <- u ^? uvWorld . hud . hudElement . subInventory . ciSelection = + if ( csel == u ^? uvWorld . hud . hudElement . subInventory . ciMouseOver . _Just + || null (u ^? uvWorld . hud . hudElement . subInventory . ciMouseOver . _Just) + ) && null (u ^? uvWorld . hud . hudElement . diMouseOver . _Just) && fmap fst csel /= Just (-1) - then drawDoublePlus 5 - else drawPlus 5 + && fromMaybe True (u ^? uvWorld . hud . hudElement . subInventory . ciSections . ix 0 . ssItems . ix 0 . siIsSelectable) --HACK to check there is something creatable + then drawGapPlus 5 + else drawPlus 5 | otherwise = rotate a (drawPlus 5) where - isselect = not (null $ u ^. uvScreenLayers) - || not (null $ u ^? uvWorld . hud . hudElement . diMouseOver . _Just) + isselect = + not (null $ u ^. uvScreenLayers) + || not (null $ u ^? uvWorld . hud . hudElement . diMouseOver . _Just) w = u ^. uvWorld a = fromMaybe 0 $ do cpos <- w ^? cWorld . lWorld . creatures . ix 0 . crPos @@ -100,12 +103,20 @@ mouseCursorType u drawPlus :: Float -> Picture drawPlus x = fold [line [V2 (- x) 0, V2 x 0], line [V2 0 (- x), V2 0 x]] -drawDoublePlus :: Float -> Picture -drawDoublePlus x = fold [line [V2 (- (1.5*x)) 0, V2 (1.5*x) 0] - , line [V2 (0.5 * x) (- x), V2 (0.5 * x) x] - , line [V2 (negate 0.5 * x) (- x), V2 (negate 0.5 * x) x] - ] +--drawDoublePlus :: Float -> Picture +--drawDoublePlus x = fold [line [V2 (- (1.5*x)) 0, V2 (1.5*x) 0] +-- , line [V2 (0.5 * x) (- x), V2 (0.5 * x) x] +-- , line [V2 (negate 0.5 * x) (- x), V2 (negate 0.5 * x) x] +-- ] +drawGapPlus :: Float -> Picture +drawGapPlus x = + fold + [ line [V2 (-1.5 * x) 0, V2 (-0.5 * x) 0] + , line [V2 (0.5 * x) 0, V2 (1.5 * x) 0] + , line [V2 (0.5 * x) (- x), V2 (0.5 * x) x] + , line [V2 (-0.5 * x) (- x), V2 (-0.5 * x) x] + ] aimDelaySweep :: World -> Picture aimDelaySweep w = fromMaybe mempty $ do @@ -122,8 +133,8 @@ drawSweep cr w = fromMaybe mempty $ do | a - cdir < - pi = cdir - 2 * pi | otherwise = cdir return $ - uncurryV translate (worldPosToScreen campos p) $ - arcFull (a - rot) 10 white (a' - rot) 1 white (5 + dist mwp p * campos ^. camZoom) white + uncurryV translate (worldPosToScreen campos p) $ + arcFull (a - rot) 10 white (a' - rot) 1 white (5 + dist mwp p * campos ^. camZoom) white where cdir = _crDir cr rot = campos ^. camRot diff --git a/src/Dodge/Update/Input/InGame.hs b/src/Dodge/Update/Input/InGame.hs index d710729eb..546cdf2dc 100644 --- a/src/Dodge/Update/Input/InGame.hs +++ b/src/Dodge/Update/Input/InGame.hs @@ -113,6 +113,9 @@ updateCombineInvClick msel sss w = fromMaybe trydocombination $ do & worldEventFlags . at CombineInventoryChange ?~ () | i == -1 -> w & hud . hudElement . subInventory . ciFilter .~ Nothing & worldEventFlags . at CombineInventoryChange ?~ () + _ | (w ^? hud . hudElement . subInventory . ciSelection . _Just . _1) == Just (-1) + -> w & hud . hudElement . subInventory . ciFilter .~ Nothing + & worldEventFlags . at CombineInventoryChange ?~ () _ -> (worldEventFlags . at InventoryChange ?~ ()) . maybeExitCombine $ tryCombine sss msel w & worldEventFlags . at CombineInventoryChange ?~ ()