Cleanup
This commit is contained in:
+1
-5
@@ -1,5 +1 @@
|
|||||||
/home/justin/Haskell/loop/src/Dodge/Update.hs:366:5-9: warning: [-Wunused-local-binds]
|
All good (596 modules, at 12:39:52)
|
||||||
Defined but not used: ‘mysel’
|
|
||||||
|
|
|
||||||
366 | mysel = inverseSelSecYint (posSelSecYint cfig ldp (mpos ^. _y)) sss
|
|
||||||
| ^^^^^
|
|
||||||
|
|||||||
+11
-38
@@ -301,12 +301,11 @@ updateMouseInventorySelection cfig w = fromMaybe w $ do
|
|||||||
sss <- w ^? hud . hudElement . diSections
|
sss <- w ^? hud . hudElement . diSections
|
||||||
return $ updateMouseInventorySelection' sss cfig w
|
return $ updateMouseInventorySelection' sss cfig w
|
||||||
|
|
||||||
-- check whether leftclickstart evaluates to True on very short left clicks
|
|
||||||
updateMouseInventorySelection' :: SelectionSections a -> Configuration -> World -> World
|
updateMouseInventorySelection' :: SelectionSections a -> Configuration -> World -> World
|
||||||
updateMouseInventorySelection' sss cfig w
|
updateMouseInventorySelection' sss cfig w
|
||||||
| leftclickstart = case msel of
|
| leftclickstart = case msel of
|
||||||
Nothing -> fromMaybe w $ do
|
Nothing -> fromMaybe w $ do
|
||||||
ysel <- mysel
|
ysel <- inverseSelSecYint (posSelSecYint cfig ldp (mpos ^. _y)) sss
|
||||||
return $
|
return $
|
||||||
w & hud . hudElement . subInventory . nsSelected
|
w & hud . hudElement . subInventory . nsSelected
|
||||||
.~ MouseInvSelect ysel Nothing
|
.~ MouseInvSelect ysel Nothing
|
||||||
@@ -316,7 +315,8 @@ updateMouseInventorySelection' sss cfig w
|
|||||||
w & hud . hudElement . subInventory . nsSelected . misMaybeEnd .~ msel
|
w & hud . hudElement . subInventory . nsSelected . misMaybeEnd .~ msel
|
||||||
Just MouseInvDrag -> fromMaybe w $ do
|
Just MouseInvDrag -> fromMaybe w $ do
|
||||||
sel <- w ^? hud . hudElement . diSelection . _Just
|
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
|
_ -> w
|
||||||
| otherwise = case w ^? hud . hudElement . subInventory . nsSelected of
|
| otherwise = case w ^? hud . hudElement . subInventory . nsSelected of
|
||||||
Just (MouseInvSelect ssel (Just esel)) ->
|
Just (MouseInvSelect ssel (Just esel)) ->
|
||||||
@@ -324,8 +324,6 @@ updateMouseInventorySelection' sss cfig w
|
|||||||
& hud . hudElement . diSelectionExtra
|
& hud . hudElement . diSelectionExtra
|
||||||
.~ (max (snd ssel) (snd esel) - min (snd ssel) (snd esel))
|
.~ (max (snd ssel) (snd esel) - min (snd ssel) (snd esel))
|
||||||
& augInvDirectSelect (min ssel esel)
|
& augInvDirectSelect (min ssel esel)
|
||||||
Just (MouseInvSelect _ Nothing) ->
|
|
||||||
w & hud . hudElement . subInventory . nsSelected .~ MouseInvNothing
|
|
||||||
_ -> w & hud . hudElement . subInventory . nsSelected .~ MouseInvNothing
|
_ -> w & hud . hudElement . subInventory . nsSelected .~ MouseInvNothing
|
||||||
where
|
where
|
||||||
leftclickstart = w ^? input . mouseButtons . ix ButtonLeft == Just 0 && nobuttonright
|
leftclickstart = w ^? input . mouseButtons . ix ButtonLeft == Just 0 && nobuttonright
|
||||||
@@ -334,7 +332,6 @@ updateMouseInventorySelection' sss cfig w
|
|||||||
mpos = w ^. input . mousePos
|
mpos = w ^. input . mousePos
|
||||||
ldp = invDisplayParams w
|
ldp = invDisplayParams w
|
||||||
msel = inverseSelNumPos cfig ldp sss (w ^. input . mousePos)
|
msel = inverseSelNumPos cfig ldp sss (w ^. input . mousePos)
|
||||||
mysel = inverseSelSecYint (posSelSecYint cfig ldp (mpos ^. _y)) sss
|
|
||||||
|
|
||||||
startDrag :: (Int, Int) -> World -> World
|
startDrag :: (Int, Int) -> World -> World
|
||||||
startDrag (a, b) w = fromMaybe (augInvDirectSelect (a, b) $ setmichosen 0 w) $ do
|
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 ::
|
shiftInvItems ::
|
||||||
(Int, Int) ->
|
(Int, Int) ->
|
||||||
|
Int ->
|
||||||
Configuration ->
|
Configuration ->
|
||||||
Point2 ->
|
Point2 ->
|
||||||
ListDisplayParams ->
|
ListDisplayParams ->
|
||||||
SelectionSections a ->
|
SelectionSections a ->
|
||||||
World ->
|
World ->
|
||||||
World
|
World
|
||||||
shiftInvItems topsel cfig mpos ldp sss w = fromMaybe w $ do
|
shiftInvItems topsel x cfig mpos ldp sss w = case inverseSelBoundaryUp cfig ldp sss mpos of
|
||||||
x <- w ^? hud . hudElement . diSelectionExtra
|
Just p | p < topsel -> shiftInvItemsUp topsel x w
|
||||||
return $ case inverseSelBoundaryUp cfig ldp sss mpos of
|
_ -> case inverseSelBoundaryDown cfig ldp sss mpos of
|
||||||
Just p | p < topsel -> shiftInvItemsUp topsel x w
|
Just p | p > (topsel & _2 +~ x) -> shiftInvItemsDown topsel x w
|
||||||
_ -> case inverseSelBoundaryDown cfig ldp sss mpos of
|
_ -> w
|
||||||
Just p | p > (topsel & _2 +~ x) -> shiftInvItemsDown topsel x w
|
|
||||||
_ -> w
|
|
||||||
where
|
|
||||||
mysel = inverseSelSecYint (posSelSecYint cfig ldp (mpos ^. _y)) sss
|
|
||||||
|
|
||||||
shiftInvItemsUp :: (Int, Int) -> Int -> World -> World
|
shiftInvItemsUp :: (Int, Int) -> Int -> World -> World
|
||||||
shiftInvItemsUp (_, i) x w = foldl' f w [i .. i + x]
|
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 :: (Int, Int) -> Int -> World -> World
|
||||||
shiftInvItemsDown (_, i) x w = fromMaybe w $ do
|
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]
|
return $ foldl' f w $ reverse [i .. i + x]
|
||||||
where
|
where
|
||||||
f w' i' = swapInvItems g i' w'
|
f w' i' = swapInvItems g i' w'
|
||||||
g i' m = fmap fst $ IM.lookupGT i' m
|
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 :: Configuration -> World -> World
|
||||||
updateMouseOverInventory cfig w = fromMaybe w $ do
|
updateMouseOverInventory cfig w = fromMaybe w $ do
|
||||||
sss <- w ^? hud . hudElement . diSections
|
sss <- w ^? hud . hudElement . diSections
|
||||||
|
|||||||
Reference in New Issue
Block a user