Implement terminals
This commit is contained in:
+31
-3
@@ -12,6 +12,7 @@ module Dodge.Inventory
|
||||
, augmentedInvSizes
|
||||
, rmInvItem
|
||||
, updateCloseObjects
|
||||
, updateTerminal
|
||||
, closeObjScrollDir
|
||||
, closeObjectCol
|
||||
-- , swapInvDir
|
||||
@@ -33,15 +34,15 @@ import Dodge.Base.Collide
|
||||
import Geometry
|
||||
--import FoldableHelp
|
||||
import Padding
|
||||
import Color
|
||||
import qualified IntMapHelp as IM
|
||||
import ListHelp
|
||||
import Color
|
||||
import LensHelp
|
||||
|
||||
import qualified Data.IntSet as IS
|
||||
import Data.Maybe
|
||||
--import Data.List
|
||||
--import System.Random
|
||||
import Control.Lens
|
||||
|
||||
-- | after this the item at the inventory position will no longer exist
|
||||
rmInvItem :: Int -- ^ Creature id
|
||||
@@ -120,6 +121,33 @@ invSelPos w = splitgap + (foldl' (+) 0 . fst $ IM.split invsel (augmentedInvSize
|
||||
| yourInvSel w < length (yourInv w) = 0
|
||||
| otherwise = 1
|
||||
|
||||
updateTerminal :: World -> World
|
||||
updateTerminal w = case _hudElement $ _hud w of
|
||||
DisplayInventory dt@DisplayTerminal{} -> w & hud . hudElement %~ updateDisplayTerminal dt w
|
||||
_ -> w
|
||||
|
||||
updateDisplayTerminal :: SubInventory -> World -> HUDElement -> HUDElement
|
||||
updateDisplayTerminal sub w inv
|
||||
| closetest == Just True = inv & subInventory %~ tickDisplayTerminal
|
||||
| otherwise = DisplayInventory NoSubInventory
|
||||
where
|
||||
closetest = do
|
||||
btpos <- w ^? buttons . ix (_termID sub) . btPos
|
||||
return $ dist btpos (_crPos $ you w) < 40
|
||||
|
||||
tickDisplayTerminal :: SubInventory -> SubInventory
|
||||
tickDisplayTerminal dt = case dt of
|
||||
DisplayTerminal{} -> dt & termParams . termDisplayedLines .++~ maybeToList ml
|
||||
& termParams . termFutureLines .~ newtfl
|
||||
where
|
||||
tfl = _termFutureLines $ _termParams dt
|
||||
(ml,newtfl) = tickFutureLines tfl
|
||||
tickFutureLines ((0,sc):xs) = (Just sc,xs)
|
||||
tickFutureLines ((i,sc):xs) = (Nothing,(i-1,sc):xs)
|
||||
tickFutureLines [] = (Nothing,[])
|
||||
_ -> dt
|
||||
|
||||
|
||||
-- this looks ugly...
|
||||
updateCloseObjects :: World -> World
|
||||
updateCloseObjects w = w & closeObjects .~ unionBy closeObjEq oldCloseFiltered currentClose
|
||||
@@ -128,7 +156,7 @@ updateCloseObjects w = w & closeObjects .~ unionBy closeObjEq oldCloseFiltered c
|
||||
updateinvsel curinvsel
|
||||
| length (augmentedInvSizes w) <= curinvsel = max 0 $ length (augmentedInvSizes w) - 1
|
||||
| otherwise = curinvsel
|
||||
filt = filter $ \obj -> dist ypos (closeObjPos obj) < 40 && hasLOS ypos (closeObjPos obj) w
|
||||
filt = filter $ \obj -> dist ypos (closeObjPos obj) < 40 && hasButtonLOS ypos (closeObjPos obj) w
|
||||
ypos = _crPos $ you w
|
||||
activeButtons = map Right
|
||||
. filter ( (/=) BtNoLabel . _btState)
|
||||
|
||||
Reference in New Issue
Block a user