Clicking on button in inventory list activates button
This commit is contained in:
+11
-12
@@ -34,26 +34,25 @@ import Picture
|
||||
|
||||
drawSelectionList :: LDParams -> Config -> [SelectionItem a] -> Picture
|
||||
drawSelectionList ldps cfig sl =
|
||||
translateScreenPos cfig (ldps ^. ldpPos) $
|
||||
drawListYgapScaleYoff ygap sf 0 (makeSelectionListPictures sl)
|
||||
<> foldMap (g . f) (ldps ^. ldpBorder)
|
||||
translateScreenPos
|
||||
cfig
|
||||
(ldps ^. ldpPos)
|
||||
(drawListYgapScaleYoff ygap sf 0 (makeSelectionListPictures sl))
|
||||
<> foldMap (g . f) (ldpRect cfig ldps)
|
||||
where
|
||||
g xs = color white (polygonWire xs) <> setDepth 0.5 (polygon xs)
|
||||
ygap = ldps ^. ldpVerticalGap
|
||||
sf = ldps ^. ldpScale
|
||||
f (x, y) =
|
||||
rectNSWE
|
||||
5
|
||||
(negate $ (20 * sf + ygap) * fromIntegral y + 5)
|
||||
(-5)
|
||||
(10 * sf * fromIntegral x)
|
||||
f (V2 xmin ymax, V2 xmax ymin) = rectNSWE ymax ymin xmin xmax
|
||||
|
||||
ldpRect :: Config -> LDParams -> Maybe (Point2, Point2) -- (NW, SE)
|
||||
ldpRect cfig ldp = do
|
||||
(x,y) <- ldp ^? ldpBorder . _Just
|
||||
return $ ( V2 (-5) 5
|
||||
(x, y) <- ldp ^? ldpBorder . _Just
|
||||
return $
|
||||
( V2 (-5) 5
|
||||
, V2 (10 * sf * fromIntegral x) (negate $ (20 * sf + ygap) * fromIntegral y + 5)
|
||||
) & each +~ screenPosAbs cfig (ldp ^. ldpPos)
|
||||
)
|
||||
& each +~ screenPosAbs cfig (ldp ^. ldpPos)
|
||||
where
|
||||
sf = ldp ^. ldpScale
|
||||
ygap = ldp ^. ldpVerticalGap
|
||||
|
||||
@@ -41,7 +41,6 @@ import Dodge.Projectile.Update
|
||||
import Dodge.Prop.Moving
|
||||
import Dodge.RadarBlip
|
||||
import Dodge.RadarSweep
|
||||
import Dodge.ScreenPos
|
||||
import Dodge.ScrollValue
|
||||
import Dodge.SelectionSections
|
||||
import Dodge.Shockwave.Update
|
||||
@@ -403,13 +402,6 @@ isOverTerminalScreen :: Config -> Point2 -> Bool
|
||||
isOverTerminalScreen cfig (V2 x y) = fromMaybe False $ do
|
||||
(V2 xmin ymax, V2 xmax ymin) <- ldpRect cfig terminalLDP
|
||||
return $ x <= xmax && x >= xmin && y <= ymax && y >= ymin
|
||||
where
|
||||
-- ldp = terminalLDP
|
||||
-- V2 xmin ymax = screenPosAbs cfig (ldp ^. ldpPos)
|
||||
-- tsize = fromIntegral $ getMaxLinesTM + 1
|
||||
-- s = 5 + tsize * (20 * ldp ^. ldpScale + ldp ^. ldpVerticalGap)
|
||||
-- ymin = ymax - s
|
||||
-- xmax = xmin + 555 -- HACK drawSelectionListBackground
|
||||
|
||||
updateWheelEvents :: World -> World
|
||||
updateWheelEvents w = case w ^. input . scrollAmount of
|
||||
|
||||
@@ -5,6 +5,7 @@ module Dodge.Update.Input.InGame (
|
||||
updateMouseInGame,
|
||||
) where
|
||||
|
||||
import Dodge.Button.Event
|
||||
import Control.Applicative
|
||||
import Control.Monad
|
||||
import Data.Foldable
|
||||
@@ -219,6 +220,10 @@ updateMouseClickInGame cfig w = case w ^. input . mouseContext of
|
||||
| selsec == Just 2 ->
|
||||
w & hud . diSelection %~ endRegex 2 w
|
||||
& hud . diCloseFilter .~ Nothing
|
||||
OverInvSelect (5, j) -> fromMaybe w $ do
|
||||
k <- w ^? hud . closeButtons . ix j
|
||||
but <- w ^? cWorld . lWorld . buttons . ix k
|
||||
return $ doButtonEvent (but ^. btEvent) but w
|
||||
OverInvSelect x
|
||||
| ScancodeLShift `M.member` (w ^. input . pressedKeys)
|
||||
&& isGroupSelectableSection (fst x) ->
|
||||
|
||||
Reference in New Issue
Block a user