Implement downwards inventory drag, buggy
This commit is contained in:
+2
-7
@@ -1,10 +1,5 @@
|
|||||||
/home/justin/Haskell/loop/src/Dodge/Update.hs:356:5-9: warning: [-Wunused-local-binds]
|
/home/justin/Haskell/loop/src/Dodge/Update.hs:366:5-9: warning: [-Wunused-local-binds]
|
||||||
Defined but not used: ‘mysel’
|
Defined but not used: ‘mysel’
|
||||||
|
|
|
|
||||||
356 | mysel = inverseSelSecYint (posSelSecYint cfig ldp (mpos ^. _y)) sss
|
366 | mysel = inverseSelSecYint (posSelSecYint cfig ldp (mpos ^. _y)) sss
|
||||||
| ^^^^^
|
| ^^^^^
|
||||||
/home/justin/Haskell/loop/src/Dodge/Update.hs:359:17-19: warning: [-Wunused-matches]
|
|
||||||
Defined but not used: ‘sss’
|
|
||||||
|
|
|
||||||
359 | shiftInvItemsUp sss (_,i) w = fromMaybe w $ do
|
|
||||||
| ^^^
|
|
||||||
|
|||||||
+27
-11
@@ -292,7 +292,8 @@ checkTermDist w = fromMaybe w $ do
|
|||||||
btid <- w ^? cWorld . lWorld . terminals . ix tmid . tmButtonID
|
btid <- w ^? cWorld . lWorld . terminals . ix tmid . tmButtonID
|
||||||
btpos <- w ^? cWorld . lWorld . buttons . ix btid . btPos
|
btpos <- w ^? cWorld . lWorld . buttons . ix btid . btPos
|
||||||
guard $ dist btpos (_crPos $ you w) > 40
|
guard $ dist btpos (_crPos $ you w) > 40
|
||||||
return $ w & hud . hudElement . subInventory
|
return $
|
||||||
|
w & hud . hudElement . subInventory
|
||||||
.~ NoSubInventory MouseInvNothing Nothing
|
.~ NoSubInventory MouseInvNothing Nothing
|
||||||
|
|
||||||
updateMouseInventorySelection :: Configuration -> World -> World
|
updateMouseInventorySelection :: Configuration -> World -> World
|
||||||
@@ -306,7 +307,8 @@ updateMouseInventorySelection' sss cfig w
|
|||||||
| leftclickstart = case msel of
|
| leftclickstart = case msel of
|
||||||
Nothing -> fromMaybe w $ do
|
Nothing -> fromMaybe w $ do
|
||||||
ysel <- mysel
|
ysel <- mysel
|
||||||
return $ w & hud . hudElement . subInventory . nsSelected
|
return $
|
||||||
|
w & hud . hudElement . subInventory . nsSelected
|
||||||
.~ MouseInvSelect ysel Nothing
|
.~ MouseInvSelect ysel Nothing
|
||||||
Just p -> startDrag p w
|
Just p -> startDrag p w
|
||||||
| leftclickheld = case w ^? hud . hudElement . subInventory . nsSelected of
|
| leftclickheld = case w ^? hud . hudElement . subInventory . nsSelected of
|
||||||
@@ -341,28 +343,42 @@ startDrag (a,b) w = fromMaybe (augInvDirectSelect (a,b) $ setmichosen 0 w) $ do
|
|||||||
guard $ i == a && b >= j && b <= j + x
|
guard $ i == a && b >= j && b <= j + x
|
||||||
return $ setmichosen x w
|
return $ setmichosen x w
|
||||||
where
|
where
|
||||||
setmichosen x = (hud . hudElement . subInventory . nsSelected .~ MouseInvDrag)
|
setmichosen x =
|
||||||
|
(hud . hudElement . subInventory . nsSelected .~ MouseInvDrag)
|
||||||
. (hud . hudElement . diSelectionExtra .~ x)
|
. (hud . hudElement . diSelectionExtra .~ x)
|
||||||
|
|
||||||
shiftInvItems :: (Int,Int) -> Configuration -> Point2
|
shiftInvItems ::
|
||||||
-> ListDisplayParams
|
(Int, Int) ->
|
||||||
-> SelectionSections a
|
Configuration ->
|
||||||
-> World
|
Point2 ->
|
||||||
-> World
|
ListDisplayParams ->
|
||||||
|
SelectionSections a ->
|
||||||
|
World ->
|
||||||
|
World
|
||||||
shiftInvItems topsel cfig mpos ldp sss w = case inverseSelBoundaryUp cfig ldp sss mpos of
|
shiftInvItems topsel cfig mpos ldp sss w = case inverseSelBoundaryUp cfig ldp sss mpos of
|
||||||
Just p | p < topsel -> shiftInvItemsUp sss topsel w
|
Just p | p < topsel -> shiftInvItemsUp topsel w
|
||||||
|
_ -> fromMaybe w $ do
|
||||||
|
x <- w ^? hud . hudElement . diSelectionExtra
|
||||||
|
return $ case inverseSelBoundaryDown cfig ldp sss mpos of
|
||||||
|
Just p | p > (topsel & _2 +~ x) -> shiftInvItemsDown topsel x w
|
||||||
_ -> w
|
_ -> w
|
||||||
where
|
where
|
||||||
mysel = inverseSelSecYint (posSelSecYint cfig ldp (mpos ^. _y)) sss
|
mysel = inverseSelSecYint (posSelSecYint cfig ldp (mpos ^. _y)) sss
|
||||||
|
|
||||||
shiftInvItemsUp :: SelectionSections a -> (Int,Int) -> World -> World
|
shiftInvItemsUp :: (Int, Int) -> World -> World
|
||||||
shiftInvItemsUp sss (_,i) w = fromMaybe w $ do
|
shiftInvItemsUp (_, i) w = fromMaybe w $ do
|
||||||
x <- w ^? hud . hudElement . diSelectionExtra
|
x <- w ^? hud . hudElement . diSelectionExtra
|
||||||
return $ foldl' f w [i .. i + x]
|
return $ foldl' f w [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.cycleLT i' m
|
g i' m = fmap fst $ IM.cycleLT i' m
|
||||||
|
|
||||||
|
shiftInvItemsDown :: (Int, Int) -> Int -> World -> World
|
||||||
|
shiftInvItemsDown (_, i) x w = foldl' f w $ reverse [i .. i + x]
|
||||||
|
where
|
||||||
|
f w' i' = swapInvItems g i' w'
|
||||||
|
g i' m = fmap fst $ IM.cycleGT i' m
|
||||||
|
|
||||||
--shiftInvItemsUp :: (Int, Int) -> (Int, Int) -> Maybe (Int, Int) -> World -> World
|
--shiftInvItemsUp :: (Int, Int) -> (Int, Int) -> Maybe (Int, Int) -> World -> World
|
||||||
--shiftInvItemsUp (_, i) (_, j) Just{} w =
|
--shiftInvItemsUp (_, i) (_, j) Just{} w =
|
||||||
-- w
|
-- w
|
||||||
|
|||||||
Reference in New Issue
Block a user