75 lines
2.2 KiB
Haskell
75 lines
2.2 KiB
Haskell
module Dodge.ListDisplayParams
|
|
( invDisplayParams
|
|
, secondColumnParams
|
|
, subInvX
|
|
, defaultListDisplayParams
|
|
, optionListDisplayParams
|
|
) where
|
|
|
|
import Dodge.Data.ScreenPos
|
|
import Dodge.Data.CardinalPoint
|
|
import SDL (MouseButton (..))
|
|
import Dodge.Data.SelectionList
|
|
import Dodge.Data.World
|
|
import qualified Data.Map.Strict as M
|
|
import Control.Lens
|
|
import Linear
|
|
|
|
defaultListDisplayParams :: ListDisplayParams
|
|
defaultListDisplayParams =
|
|
ListDisplayParams
|
|
{ _ldpVerticalGap = 0
|
|
, _ldpScale = 1
|
|
, _ldpPos = ScreenPos {_spScreenOff = V2 (-0.5) 0.5 -- top left
|
|
, _spPixelOff = 0}
|
|
, _ldpCursorSides = mempty
|
|
, _ldpWidth = FixedSelectionWidth 15
|
|
}
|
|
|
|
invDisplayParams :: World -> ListDisplayParams
|
|
invDisplayParams w =
|
|
defaultListDisplayParams
|
|
& ldpCursorSides .~ selcursortype
|
|
& ldpWidth .~ FixedSelectionWidth (determineInvSelCursorWidth w)
|
|
& ldpPos . spPixelOff .~ V2 6 (-1)
|
|
where
|
|
selcursortype = case w ^? hud . hudElement . subInventory of
|
|
_ | ButtonRight `M.member` _mouseButtons (_input w) -> [North, South, East, West]
|
|
Just ExamineInventory{} -> [North, South, East, West]
|
|
Just CombineInventory{} -> []
|
|
_ -> [North, South, West]
|
|
|
|
secondColumnParams :: ListDisplayParams
|
|
secondColumnParams =
|
|
defaultListDisplayParams
|
|
& ldpPos . spPixelOff .~ V2 subInvX (-81)
|
|
& ldpCursorSides .~ [North, South, West]
|
|
|
|
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
|
|
& ldpCursorSides .~ [North, South, West]
|