Files
loop/src/Dodge/ListDisplayParams.hs
T
2024-11-04 09:32:36 +00:00

76 lines
2.1 KiB
Haskell

module Dodge.ListDisplayParams (
invDisplayParams,
invCursorParams,
secondColumnParams,
subInvX,
defaultListDisplayParams,
optionListDisplayParams,
) where
import Control.Lens
import qualified Data.Map.Strict as M
import Dodge.Data.CardinalPoint
import Dodge.Data.ScreenPos
import Dodge.Data.SelectionList
import Dodge.Data.World
import Linear
import SDL (MouseButton (..))
defaultListDisplayParams :: ListDisplayParams
defaultListDisplayParams =
ListDisplayParams
{ _ldpVerticalGap = 0
, _ldpScale = 1
, _ldpPos =
ScreenPos
{ _spScreenOff = V2 (-0.5) 0.5 -- top left
, _spPixelOff = 0
}
, _ldpWidth = FixedSelectionWidth 15
}
invDisplayParams :: World -> ListDisplayParams
invDisplayParams w =
defaultListDisplayParams
& ldpWidth .~ FixedSelectionWidth (determineInvSelCursorWidth w)
& ldpPos . spPixelOff .~ V2 6 (-1)
invCursorParams :: World -> CursorDisplay
invCursorParams w = BoundaryCursor $ case w ^? hud . hudElement . subInventory of
Just ExamineInventory{} -> [North, South, East, West]
Just CombineInventory{} -> []
_ | ButtonRight `M.member` _mouseButtons (_input w) -> [North, South, East, West]
_ -> [North, South, West]
secondColumnParams :: ListDisplayParams
secondColumnParams =
defaultListDisplayParams
& ldpPos . spPixelOff .~ V2 subInvX (-81)
subInvX :: Float
subInvX = 10 * fromIntegral topInvW + 70
topInvW :: Int
topInvW = 15
determineInvSelCursorWidth :: World -> Int
determineInvSelCursorWidth w = case _rbOptions w of
NoRightButtonOptions -> topInvW
EquipOptions{}
| ButtonRight `M.member` _mouseButtons (_input w)
&& hasnosubinv ->
47
| otherwise -> topInvW
where
hasnosubinv = case w ^? hud . hudElement . subInventory of
Just NoSubInventory{} -> True
_ -> False
optionListDisplayParams :: ListDisplayParams
optionListDisplayParams =
defaultListDisplayParams
& ldpPos . spPixelOff .~ V2 11 (-70)
& ldpScale .~ 2
& ldpVerticalGap .~ 0
& ldpWidth .~ FixedSelectionWidth 50