Start simplifying mouse inventory selection

This commit is contained in:
2024-10-24 11:47:51 +01:00
parent 9e3d8ae6b0
commit 5ca440ca67
9 changed files with 270 additions and 227 deletions
+19 -4
View File
@@ -35,8 +35,7 @@ import Dodge.SelectionSections.Draw
import Geometry
import qualified IntMapHelp as IM
import Justify
--import ListHelp
--import Padding
import Data.List (sort)
import Picture
import SDL (MouseButton (..))
@@ -64,6 +63,7 @@ drawInventory sss w cfig =
<> translateScreenPos cfig (ldp ^. ldpPos)
(drawDIMouseOver w)
<> drawDISelections w cfig
<> drawDISelections' w cfig
where
ldp = invDisplayParams w
iextra = fromMaybe mempty $ do
@@ -83,7 +83,13 @@ drawDIMouseOver w = fromMaybe mempty $ do
getMouseInvSel :: World -> Maybe ((Int,Int),(Int,Int))
getMouseInvSel w = case w ^? hud . hudElement . subInventory . nsSelected of
Just (MouseInvSelect s (Just e)) -> Just (s,e)
Just (MouseInvChosen s e) -> Just (s,e)
_ -> Nothing
getMouseInvSel' :: World -> Maybe ((Int,Int),(Int,Int))
getMouseInvSel' w = case w ^? hud . hudElement . subInventory . nsSelected of
Just (MouseInvChosen x) -> do
(i,j) <- w ^? hud . hudElement . diSections . sssExtra . sssSelPos . _Just
return ((i,j),(i,j+x))
_ -> Nothing
drawDISelections :: World -> Configuration -> Picture
@@ -93,7 +99,16 @@ drawDISelections w cfig = fromMaybe mempty $ do
let idp = invDisplayParams w
tp <- selNumPosCardinal NorthWest8 cfig idp sss i j
bp <- selNumPosCardinal SouthWest8 cfig idp sss a b
return . color red $ line [tp,bp]
return . color red . line $ sort [tp,bp]
drawDISelections' :: World -> Configuration -> Picture
drawDISelections' w cfig = fromMaybe mempty $ do
((i,j),(a,b)) <- getMouseInvSel' w
sss <- w ^? hud . hudElement . diSections
let idp = invDisplayParams w
tp <- selNumPosCardinal NorthEast8 cfig idp sss i j
bp <- selNumPosCardinal SouthEast8 cfig idp sss a b
return . color green . line $ sort [tp,bp]
drawSubInventory :: SubInventory -> Configuration -> World -> Picture