This commit is contained in:
2024-10-25 12:43:18 +01:00
parent ec07e6b1a2
commit 90862b0c69
2 changed files with 12 additions and 43 deletions
+1 -5
View File
@@ -1,5 +1 @@
/home/justin/Haskell/loop/src/Dodge/Update.hs:366:5-9: warning: [-Wunused-local-binds]
Defined but not used: mysel
|
366 | mysel = inverseSelSecYint (posSelSecYint cfig ldp (mpos ^. _y)) sss
| ^^^^^
All good (596 modules, at 12:39:52)
+11 -38
View File
@@ -301,12 +301,11 @@ updateMouseInventorySelection cfig w = fromMaybe w $ do
sss <- w ^? hud . hudElement . diSections
return $ updateMouseInventorySelection' sss cfig w
-- check whether leftclickstart evaluates to True on very short left clicks
updateMouseInventorySelection' :: SelectionSections a -> Configuration -> World -> World
updateMouseInventorySelection' sss cfig w
| leftclickstart = case msel of
Nothing -> fromMaybe w $ do
ysel <- mysel
ysel <- inverseSelSecYint (posSelSecYint cfig ldp (mpos ^. _y)) sss
return $
w & hud . hudElement . subInventory . nsSelected
.~ MouseInvSelect ysel Nothing
@@ -316,7 +315,8 @@ updateMouseInventorySelection' sss cfig w
w & hud . hudElement . subInventory . nsSelected . misMaybeEnd .~ msel
Just MouseInvDrag -> fromMaybe w $ do
sel <- w ^? hud . hudElement . diSelection . _Just
return $ w & shiftInvItems sel cfig mpos ldp sss
x <- w ^? hud . hudElement . diSelectionExtra
return $ w & shiftInvItems sel x cfig mpos ldp sss
_ -> w
| otherwise = case w ^? hud . hudElement . subInventory . nsSelected of
Just (MouseInvSelect ssel (Just esel)) ->
@@ -324,8 +324,6 @@ updateMouseInventorySelection' sss cfig w
& hud . hudElement . diSelectionExtra
.~ (max (snd ssel) (snd esel) - min (snd ssel) (snd esel))
& augInvDirectSelect (min ssel esel)
Just (MouseInvSelect _ Nothing) ->
w & hud . hudElement . subInventory . nsSelected .~ MouseInvNothing
_ -> w & hud . hudElement . subInventory . nsSelected .~ MouseInvNothing
where
leftclickstart = w ^? input . mouseButtons . ix ButtonLeft == Just 0 && nobuttonright
@@ -334,7 +332,6 @@ updateMouseInventorySelection' sss cfig w
mpos = w ^. input . mousePos
ldp = invDisplayParams w
msel = inverseSelNumPos cfig ldp sss (w ^. input . mousePos)
mysel = inverseSelSecYint (posSelSecYint cfig ldp (mpos ^. _y)) sss
startDrag :: (Int, Int) -> World -> World
startDrag (a, b) w = fromMaybe (augInvDirectSelect (a, b) $ setmichosen 0 w) $ do
@@ -349,21 +346,18 @@ startDrag (a, b) w = fromMaybe (augInvDirectSelect (a, b) $ setmichosen 0 w) $ d
shiftInvItems ::
(Int, Int) ->
Int ->
Configuration ->
Point2 ->
ListDisplayParams ->
SelectionSections a ->
World ->
World
shiftInvItems topsel cfig mpos ldp sss w = fromMaybe w $ do
x <- w ^? hud . hudElement . diSelectionExtra
return $ case inverseSelBoundaryUp cfig ldp sss mpos of
Just p | p < topsel -> shiftInvItemsUp topsel x w
_ -> case inverseSelBoundaryDown cfig ldp sss mpos of
Just p | p > (topsel & _2 +~ x) -> shiftInvItemsDown topsel x w
_ -> w
where
mysel = inverseSelSecYint (posSelSecYint cfig ldp (mpos ^. _y)) sss
shiftInvItems topsel x cfig mpos ldp sss w = case inverseSelBoundaryUp cfig ldp sss mpos of
Just p | p < topsel -> shiftInvItemsUp topsel x w
_ -> case inverseSelBoundaryDown cfig ldp sss mpos of
Just p | p > (topsel & _2 +~ x) -> shiftInvItemsDown topsel x w
_ -> w
shiftInvItemsUp :: (Int, Int) -> Int -> World -> World
shiftInvItemsUp (_, i) x w = foldl' f w [i .. i + x]
@@ -373,34 +367,13 @@ shiftInvItemsUp (_, i) x w = foldl' f w [i .. i + x]
shiftInvItemsDown :: (Int, Int) -> Int -> World -> World
shiftInvItemsDown (_, i) x w = fromMaybe w $ do
guard $ isJust $ w ^? hud . hudElement . diSections . sssSections . ix 0 . ssItems . ix (i + x + 1)
guard . isJust $
w ^? hud . hudElement . diSections . sssSections . ix 0 . ssItems . ix (i + x + 1)
return $ foldl' f w $ reverse [i .. i + x]
where
f w' i' = swapInvItems g i' w'
g i' m = fmap fst $ IM.lookupGT i' m
--shiftInvItemsUp :: (Int, Int) -> (Int, Int) -> Maybe (Int, Int) -> World -> World
--shiftInvItemsUp (_, i) (_, j) Just{} w =
-- w
-- & flip (foldl' f) [i .. j]
-- & hud . hudElement . subInventory . nsSelected . misChosenStart . _2 -~ 1
-- & hud . hudElement . subInventory . nsSelected . misChosenEnd . _2 -~ 1
-- where
-- f w' i' = swapInvItems g i' w'
-- g i' m = fmap fst $ IM.cycleLT i' m
--shiftInvItemsUp _ _ Nothing w = w
--
--shiftInvItemsDown :: (Int, Int) -> (Int, Int) -> Maybe (Int, Int) -> World -> World
--shiftInvItemsDown (_, i) (_, j) Just{} w =
-- w
-- & flip (foldl' f) (reverse [i .. j])
-- & hud . hudElement . subInventory . nsSelected . misChosenStart . _2 +~ 1
-- & hud . hudElement . subInventory . nsSelected . misChosenEnd . _2 +~ 1
-- where
-- f w' i' = swapInvItems g i' w'
-- g i' m = fmap fst $ IM.cycleGT i' m
--shiftInvItemsDown _ _ Nothing w = w
updateMouseOverInventory :: Configuration -> World -> World
updateMouseOverInventory cfig w = fromMaybe w $ do
sss <- w ^? hud . hudElement . diSections