Improve drawRBOptions positioning
This commit is contained in:
@@ -10,17 +10,17 @@ module Dodge.SelectionSections (
|
||||
inverseSelNumPos,
|
||||
) where
|
||||
|
||||
import Dodge.Data.HUD
|
||||
import Dodge.Data.CardinalPoint
|
||||
import qualified Data.IntSet as IS
|
||||
import Control.Applicative
|
||||
import qualified Control.Foldl as L
|
||||
import Control.Lens
|
||||
import Control.Monad
|
||||
import Data.Foldable
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
import qualified Data.IntSet as IS
|
||||
import Data.Maybe
|
||||
import Dodge.Data.CardinalPoint
|
||||
import Dodge.Data.Config
|
||||
import Dodge.Data.HUD
|
||||
import Dodge.Data.SelectionList
|
||||
import Dodge.ScreenPos
|
||||
import Geometry.Data
|
||||
@@ -86,14 +86,14 @@ ssLookupDown i j sss = case ssLookupGT i j sss of
|
||||
|
||||
ssLookupNextMax :: Int -> Int -> IMSS a -> Maybe (Int, Int, SelectionItem a)
|
||||
ssLookupNextMax i j sss = case ssLookupGT i j sss of
|
||||
Just x@(i',j',_) | i' == i && j' > j -> Just x
|
||||
Just x@(i', j', _) | i' == i && j' > j -> Just x
|
||||
_ -> ssLookupMaxInSection i sss <|> ssLookupDown i j sss
|
||||
|
||||
ssLookupMaxInSection :: Int -> IMSS a -> Maybe (Int, Int, SelectionItem a)
|
||||
ssLookupMaxInSection i sss = do
|
||||
ss <- sss ^? ix i . ssItems
|
||||
(j,s) <- IM.lookupMax ss
|
||||
return (i,j,s)
|
||||
(j, s) <- IM.lookupMax ss
|
||||
return (i, j, s)
|
||||
|
||||
ssLookupLT :: Int -> Int -> IMSS a -> Maybe (Int, Int, SelectionItem a)
|
||||
ssLookupLT i j sss = fromMaybe (ssLookupLT' i sss) $ do
|
||||
@@ -152,7 +152,8 @@ posSelSecYint cfig ldp y = floor $ (y0 - y) / (20 / ldp ^. ldpScale + ldp ^. ldp
|
||||
selSecYint :: Int -> Int -> IMSS a -> Maybe Int
|
||||
selSecYint i j sss = do
|
||||
ss <- sss ^? ix i
|
||||
return . (secpos +)
|
||||
return
|
||||
. (secpos +)
|
||||
. subtract (ss ^. ssOffset)
|
||||
. sum
|
||||
. fmap _siHeight
|
||||
@@ -162,7 +163,7 @@ selSecYint i j sss = do
|
||||
secpos = sum . fmap _ssShownLength . fst $ IM.split i sss
|
||||
|
||||
inverseSelSecYint :: Int -> IMSS a -> XInfinity (Int, Int)
|
||||
inverseSelSecYint yint sss
|
||||
inverseSelSecYint yint sss
|
||||
| yint < 0 = NegInf
|
||||
| otherwise = fromMaybe PosInf $ do
|
||||
((i, ss), othersss) <- IM.minViewWithKey sss
|
||||
@@ -171,19 +172,19 @@ inverseSelSecYint yint sss
|
||||
then return $ inverseSelSecYint (yint - l) othersss
|
||||
else do
|
||||
let ls = L.postscan (L.premap _siHeight L.sum) (_ssItems ss)
|
||||
(j,_) <- L.fold (L.find (\(_,x) -> x - _ssOffset ss > yint)) $ IM.toList ls
|
||||
(j, _) <- L.fold (L.find (\(_, x) -> x - _ssOffset ss > yint)) $ IM.toList ls
|
||||
return $ NonInf (i, j)
|
||||
|
||||
inverseSelSecYintXPosCheck ::
|
||||
Config -> LDParams -> Float -> Int -> IMSS a -> Maybe (Int,Int)
|
||||
inverseSelSecYintXPosCheck ::
|
||||
Config -> LDParams -> Float -> Int -> IMSS a -> Maybe (Int, Int)
|
||||
inverseSelSecYintXPosCheck cfig ldp x yint sss = do
|
||||
(i,j) <- inverseSelSecYint yint sss ^? nonInf
|
||||
(i, j) <- inverseSelSecYint yint sss ^? nonInf
|
||||
let V2 x0 _ = screenPosAbs cfig (ldp ^. ldpPos)
|
||||
sindent <- sss ^? ix i . ssIndent
|
||||
itindent <- sss ^? ix i . ssItems . ix j . siOffX
|
||||
let x1 = x0 + _ldpScale ldp * 10 * (fromIntegral (sindent + itindent) - 0.5)
|
||||
guard $ x - x1 < 160 && x > x1
|
||||
return (i,j)
|
||||
return (i, j)
|
||||
|
||||
inverseSelNumPos :: Config -> LDParams -> Point2 -> IMSS a -> Maybe (Int, Int)
|
||||
inverseSelNumPos cfig ldp (V2 x y) =
|
||||
|
||||
Reference in New Issue
Block a user