Improve mouse cursor on pickup

This commit is contained in:
2024-11-25 22:41:39 +00:00
parent 6658aa7a0a
commit 0fb6c3ec26
3 changed files with 92 additions and 90 deletions
+4 -2
View File
@@ -88,9 +88,11 @@ mouseCursorType u = case u ^. uvWorld . input . mouseContext of
OverInvDrag 0 Nothing _ _ -> drawDragDrop 5
OverInvDrag 0 (Just (0,_)) _ _ -> drawDrag 5
OverInvDrag 0 _ _ _ -> drawEmptySet 5
-- OverInvDrag 0 _ -> drawDragDrop 5
OverInvDrag 3 (Just (3,_)) _ _ -> drawDrag 5
OverInvDrag 3 _ _ _ -> drawDragPickup 5
OverInvDrag 3 (Just (0,_)) _ _ -> drawDragPickup 5
OverInvDrag 3 (Just (1,_)) _ _ -> drawDragPickup 5
OverInvDrag 3 Nothing _ _ -> drawDragPickup 5
OverInvDrag 3 _ _ _ -> drawEmptySet 5
OverInvDrag {} -> drawEmptySet 5
OverInvDragSelect {} -> drawDragSelect 5
OverInvSelect {} -> drawSelect 5
+6 -7
View File
@@ -115,7 +115,7 @@ tryDropSelected mpos w = do
tryPickupSelected :: Int -> Maybe (Int,Int) -> World -> Maybe World
tryPickupSelected k mpos w = do
guard $ k == 3
guard $ maybe True (\(i,_) -> i == 0) mpos
guard $ maybe True (\(i,_) -> i == 0 || i == 1) mpos
cr <- w ^? cWorld . lWorld . creatures . ix 0
let nfreeslots = crNumFreeSlots cr
xs <- w ^? hud . hudElement . diSelection . _Just . _3
@@ -123,11 +123,11 @@ tryPickupSelected k mpos w = do
let slotsneeded = alaf Sum foldMap (_itInvSize . _flIt) itmstopickup
guard $ nfreeslots >= slotsneeded
return $ case mpos of
Nothing -> foldl' (flip $ pickUpItem 0) w itmstopickup
& hud . hudElement . diSelection . _Just . _3 %~ const mempty
Just (_,j) -> foldr (pickUpItemAt j 0) w itmstopickup
Just (0,j) -> foldr (pickUpItemAt j 0) w itmstopickup
& hud . hudElement . diSelection ?~ (0,j
, IS.fromDistinctAscList [j..j+IS.size xs-1])
_ -> foldl' (flip $ pickUpItem 0) w itmstopickup
& hud . hudElement . diSelection . _Just . _3 %~ const mempty
where
g i = do
NInt j <- w ^? hud . closeItems . ix i
@@ -182,8 +182,7 @@ updateMouseClickInGame cfig w = case w ^. input . mouseContext of
OverInvSelect x -> startDrag x cfig w
OverTerminalReturn tmid -> terminalReturnEffect tmid w
OverTerminalEscape ->
w
& hud . hudElement . subInventory .~ NoSubInventory --MouseInvNothing
w & hud . hudElement . subInventory .~ NoSubInventory
OverCombSelect x ->
w & hud . hudElement . subInventory . ciSelection ?~ f x
& worldEventFlags . at CombineInventoryChange ?~ ()
@@ -199,7 +198,7 @@ updateMouseClickInGame cfig w = case w ^. input . mouseContext of
OverCombEscape ->
w
& worldEventFlags . at InventoryChange ?~ ()
& hud . hudElement . subInventory .~ NoSubInventory --MouseInvNothing
& hud . hudElement . subInventory .~ NoSubInventory
OverInvFilt (i, j) -> fromMaybe w $ do
guard $ i == 0
str <-