Improve drag inventory selection
This commit is contained in:
@@ -190,16 +190,24 @@ inverseSelSecYint yint sss
|
|||||||
return $ NonInf (i, j)
|
return $ NonInf (i, j)
|
||||||
|
|
||||||
inverseSelSecYintXPosCheck ::
|
inverseSelSecYintXPosCheck ::
|
||||||
Config -> LDParams -> Float -> Int -> IMSS a -> Maybe (Int, Int)
|
Config -> LDParams -> Float -> Int -> IMSS a -> Maybe (XInfinity (Int, Int))
|
||||||
inverseSelSecYintXPosCheck cfig ldp x yint sss = do
|
inverseSelSecYintXPosCheck cfig ldp x yint sss = do
|
||||||
(i, j) <- inverseSelSecYint yint sss ^? nonInf
|
let sel = inverseSelSecYint yint sss
|
||||||
|
(i,j) <- case sel of
|
||||||
|
NonInf v -> Just v
|
||||||
|
NegInf -> do
|
||||||
|
(i',j',_) <- ssLookupMin sss
|
||||||
|
return (i',j')
|
||||||
|
PosInf -> do
|
||||||
|
(i',j',_) <- ssLookupMax sss
|
||||||
|
return (i',j')
|
||||||
let V2 x0 _ = screenPosAbs cfig (ldp ^. ldpPos)
|
let V2 x0 _ = screenPosAbs cfig (ldp ^. ldpPos)
|
||||||
sindent <- sss ^? ix i . ssIndent
|
sindent <- sss ^? ix i . ssIndent
|
||||||
itindent <- sss ^? ix i . ssItems . ix j . siOffX
|
itindent <- sss ^? ix i . ssItems . ix j . siOffX
|
||||||
let x1 = x0 + _ldpScale ldp * 10 * (fromIntegral (sindent + itindent) - 0.5)
|
let x1 = x0 + _ldpScale ldp * 10 * (fromIntegral (sindent + itindent) - 0.5)
|
||||||
guard $ x - x1 < 160 && x > x1
|
guard $ x - x1 < 160 && x > x1
|
||||||
return (i, j)
|
return sel
|
||||||
|
|
||||||
inverseSelNumPos :: Config -> LDParams -> Point2 -> IMSS a -> Maybe (Int, Int)
|
inverseSelNumPos :: Config -> LDParams -> Point2 -> IMSS a -> Maybe (XInfinity (Int, Int))
|
||||||
inverseSelNumPos cfig ldp (V2 x y) =
|
inverseSelNumPos cfig ldp (V2 x y) =
|
||||||
inverseSelSecYintXPosCheck cfig ldp x (posSelSecYint cfig ldp y)
|
inverseSelSecYintXPosCheck cfig ldp x (posSelSecYint cfig ldp y)
|
||||||
|
|||||||
@@ -41,8 +41,14 @@ tocrs :: (IM.IntMap Creature
|
|||||||
tocrs = uvWorld . cWorld . lWorld . creatures
|
tocrs = uvWorld . cWorld . lWorld . creatures
|
||||||
|
|
||||||
testStringInit :: Universe -> [String]
|
testStringInit :: Universe -> [String]
|
||||||
testStringInit u = u ^.. tocrs . each . crStance . carriage . to show
|
testStringInit u =
|
||||||
<> u ^.. tocrs . each . crPos . _z . to show
|
[ show $ inverseSelNumPos (u ^. uvConfig) invDP
|
||||||
|
(u ^. uvWorld . input . mousePos) (u ^. uvWorld . hud . diSections)
|
||||||
|
, show $ do
|
||||||
|
(i',xs) <- IM.lookupMax (u ^. uvWorld . hud . diSections)
|
||||||
|
(j',_) <- xs ^. ssItems . to IM.lookupMax
|
||||||
|
return (i',j')
|
||||||
|
]
|
||||||
|
|
||||||
-- where
|
-- where
|
||||||
-- tocr = uvWorld . cWorld . lWorld . creatures . ix 0
|
-- tocr = uvWorld . cWorld . lWorld . creatures . ix 0
|
||||||
|
|||||||
+4
-3
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
module Dodge.Update (updateUniverse) where
|
module Dodge.Update (updateUniverse) where
|
||||||
|
|
||||||
|
import Dodge.Data.CardinalPoint
|
||||||
import Dodge.Data.ScreenPos
|
import Dodge.Data.ScreenPos
|
||||||
import Bound
|
import Bound
|
||||||
import Color
|
import Color
|
||||||
@@ -409,7 +410,7 @@ updateMouseContext cfig u = case u ^? uvScreenLayers . ix 0 of
|
|||||||
|
|
||||||
updateMouseContextGame :: Config -> Universe -> MouseContext -> MouseContext
|
updateMouseContextGame :: Config -> Universe -> MouseContext -> MouseContext
|
||||||
updateMouseContextGame cfig u = \case
|
updateMouseContextGame cfig u = \case
|
||||||
OverInvDrag i _ -> OverInvDrag i (inverseSelNumPos cfig invDP mpos disss)
|
OverInvDrag i _ -> OverInvDrag i (inverseSelNumPos cfig invDP mpos disss ^? _Just . nonInf)
|
||||||
x@OverInvDragSelect{} -> x
|
x@OverInvDragSelect{} -> x
|
||||||
MouseGameRotate x
|
MouseGameRotate x
|
||||||
| ButtonRight `M.member` (w ^. input . mouseButtons) -> MouseGameRotate x
|
| ButtonRight `M.member` (w ^. input . mouseButtons) -> MouseGameRotate x
|
||||||
@@ -424,7 +425,7 @@ updateMouseContextGame cfig u = \case
|
|||||||
mpos = w ^. input . mousePos
|
mpos = w ^. input . mousePos
|
||||||
disss = w ^. hud . diSections
|
disss = w ^. hud . diSections
|
||||||
overinv = do
|
overinv = do
|
||||||
selpos@(i, j) <- inverseSelNumPos cfig invDP mpos disss
|
selpos@(i, j) <- inverseSelNumPos cfig invDP mpos disss ^? _Just . nonInf
|
||||||
case w ^? hud . subInventory . ciSelection of
|
case w ^? hud . subInventory . ciSelection of
|
||||||
Just _ | i == 0 -> return $ OverCombFiltInv selpos
|
Just _ | i == 0 -> return $ OverCombFiltInv selpos
|
||||||
Just _ -> Nothing
|
Just _ -> Nothing
|
||||||
@@ -436,7 +437,7 @@ updateMouseContextGame cfig u = \case
|
|||||||
sss <- w ^? hud . subInventory . ciSections
|
sss <- w ^? hud . subInventory . ciSections
|
||||||
Sel xl xr _ <- w ^? hud . subInventory . ciSelection . _Just
|
Sel xl xr _ <- w ^? hud . subInventory . ciSelection . _Just
|
||||||
let msel = (xl, xr)
|
let msel = (xl, xr)
|
||||||
let mpossel = inverseSelNumPos cfig secondColumnLDP (w ^. input . mousePos) sss
|
let mpossel = inverseSelNumPos cfig secondColumnLDP (w ^. input . mousePos) sss ^? _Just . nonInf
|
||||||
return $ case mpossel of
|
return $ case mpossel of
|
||||||
Nothing -> OverCombEscape
|
Nothing -> OverCombEscape
|
||||||
Just (-1, i) | (-1, i) == msel -> OverCombFilter
|
Just (-1, i) | (-1, i) == msel -> OverCombFilter
|
||||||
|
|||||||
@@ -106,10 +106,16 @@ updateMouseHeldInGame cfig w = case w ^. input . mouseContext of
|
|||||||
let sss = w ^. hud . diSections
|
let sss = w ^. hud . diSections
|
||||||
in case inverseSelNumPos cfig invDP (w ^. input . mousePos) sss of
|
in case inverseSelNumPos cfig invDP (w ^. input . mousePos) sss of
|
||||||
Nothing -> w & input . mouseContext . mcoSelEnd .~ Nothing
|
Nothing -> w & input . mouseContext . mcoSelEnd .~ Nothing
|
||||||
Just (i, j)
|
Just (NonInf (i, j))
|
||||||
| i == fst sstart -> w & input . mouseContext . mcoSelEnd ?~ j
|
| i == fst sstart -> w & input . mouseContext . mcoSelEnd ?~ j
|
||||||
| i < fst sstart -> w & input . mouseContext . mcoSelEnd ?~ 0
|
| i < fst sstart -> w & input . mouseContext . mcoSelEnd ?~ 0
|
||||||
| otherwise ->
|
| otherwise -> w
|
||||||
|
& input . mouseContext . mcoSelEnd
|
||||||
|
.~ fmap
|
||||||
|
fst
|
||||||
|
(IM.lookupMax =<< sss ^? ix (fst sstart) . ssItems)
|
||||||
|
Just NegInf -> w & input . mouseContext . mcoSelEnd ?~ 0
|
||||||
|
Just PosInf ->
|
||||||
w & input . mouseContext . mcoSelEnd
|
w & input . mouseContext . mcoSelEnd
|
||||||
.~ fmap
|
.~ fmap
|
||||||
fst
|
fst
|
||||||
|
|||||||
Reference in New Issue
Block a user