diff --git a/src/Dodge/Button/Draw.hs b/src/Dodge/Button/Draw.hs index acf2da77c..f4875d777 100644 --- a/src/Dodge/Button/Draw.hs +++ b/src/Dodge/Button/Draw.hs @@ -11,8 +11,7 @@ drawButton :: Button -> SPic drawButton bt = case bt ^. btEvent of ButtonPress {_bpColor = col} -> defaultDrawButton col bt ButtonSwitch {_bsColor1 = col1, _bsColor2 = col2} -> drawSwitch col1 col2 bt - ButtonAccessTerminal -> mempty --- ButtonDoNothing -> mempty + ButtonAccessTerminal _ -> mempty drawSwitch :: Color -> Color -> Button -> SPic drawSwitch col1 col2 bt diff --git a/src/Dodge/Button/Event.hs b/src/Dodge/Button/Event.hs index fb319244d..130393372 100644 --- a/src/Dodge/Button/Event.hs +++ b/src/Dodge/Button/Event.hs @@ -13,7 +13,7 @@ doButtonEvent = \case ButtonPress False f _ -> buttonFlip f ButtonSwitch _ f _ _ True -> buttonFlip f ButtonSwitch f _ _ _ False -> buttonFlip f - ButtonAccessTerminal -> accessTerminal . _btTermMID + ButtonAccessTerminal tid -> const $ accessTerminal tid buttonFlip :: WdWd -> Button -> World -> World buttonFlip f bt = diff --git a/src/Dodge/Data/Button.hs b/src/Dodge/Data/Button.hs index 96ecb4362..8e51fd589 100644 --- a/src/Dodge/Data/Button.hs +++ b/src/Dodge/Data/Button.hs @@ -25,14 +25,14 @@ data ButtonEvent , _bsColor2 :: Color , _btOn :: Bool } - | ButtonAccessTerminal + | ButtonAccessTerminal {_btTermID :: Int} data Button = Button { _btPos :: Point2 , _btRot :: Float , _btEvent :: ButtonEvent , _btID :: Int - , _btTermMID :: Maybe Int +-- , _btTermMID :: Maybe Int } makeLenses ''Button diff --git a/src/Dodge/Data/WorldEffect.hs b/src/Dodge/Data/WorldEffect.hs index 616e37926..1ee279960 100644 --- a/src/Dodge/Data/WorldEffect.hs +++ b/src/Dodge/Data/WorldEffect.hs @@ -22,7 +22,7 @@ data WdWd | SetTrigger Bool Int | WorldEffects [WdWd] -- probably best to avoid recursive types if possible... | SetLSCol Point3 Int - | AccessTerminal (Maybe Int) + | AccessTerminal Int | UnlockInv | SoundStart SoundOrigin Point2 SoundID (Maybe Int) | MakeStartCloudAt Point3 diff --git a/src/Dodge/Default.hs b/src/Dodge/Default.hs index e8af56f78..f221ebb2f 100644 --- a/src/Dodge/Default.hs +++ b/src/Dodge/Default.hs @@ -53,7 +53,7 @@ defaultButton = , _btEvent = ButtonPress False NoWorldEffect (dark red) , _btID = 0 -- , _btState = BtOff - , _btTermMID = Nothing +-- , _btTermMID = Nothing -- , _btName = "" -- , _btColor = red } diff --git a/src/Dodge/Inventory.hs b/src/Dodge/Inventory.hs index 8e3a252eb..c5a581864 100644 --- a/src/Dodge/Inventory.hs +++ b/src/Dodge/Inventory.hs @@ -137,6 +137,9 @@ updateCloseObjects w = activeButtons = filter canpress . IM.elems $ w ^. cWorld . lWorld . buttons canpress bt = case bt ^. btEvent of ButtonPress {_btOn = t} -> not t + ButtonAccessTerminal tid -> fromMaybe False $ do + x <- w ^? cWorld . lWorld . terminals . ix tid . tmStatus + return (x /= TerminalDeactivated) _ -> True changeSwapSel :: Int -> World -> World diff --git a/src/Dodge/Inventory/SelectionList.hs b/src/Dodge/Inventory/SelectionList.hs index bb584f3cb..3cc7be508 100644 --- a/src/Dodge/Inventory/SelectionList.hs +++ b/src/Dodge/Inventory/SelectionList.hs @@ -235,7 +235,7 @@ btText :: Button -> String btText bt = case _btEvent bt of ButtonPress {} -> "BUTTON" ButtonSwitch {_btOn = t} -> if t then "SWITCH\\" else "SWITCH/" - ButtonAccessTerminal -> "TERMINAL" + ButtonAccessTerminal {} -> "TERMINAL" closeItemToTextPictures :: FloorItem -> ([String], Color) closeItemToTextPictures flit = (basicItemDisplay it, itemInvColor $ baseCI it) diff --git a/src/Dodge/Placement/Instance/Terminal.hs b/src/Dodge/Placement/Instance/Terminal.hs index 25a013635..85258ff28 100644 --- a/src/Dodge/Placement/Instance/Terminal.hs +++ b/src/Dodge/Placement/Instance/Terminal.hs @@ -34,7 +34,7 @@ putTerminal col mc tm = & cWorld . lWorld . terminals . ix tmid . tmButtonID .~ btid & cWorld . lWorld . terminals . ix tmid . tmMachineID .~ mcid & cWorld . lWorld . machines . ix mcid . mcMounts . at OTTerminal ?~ tmid - & cWorld . lWorld . buttons . ix btid . btTermMID ?~ tmid + & cWorld . lWorld . buttons . ix btid . btEvent .~ ButtonAccessTerminal tmid where tmid = fromJust (_plMID tmpl) btid = fromJust (_plMID btpl) @@ -53,9 +53,8 @@ termButton = Button { _btPos = 0 , _btRot = 0 - , _btEvent = ButtonAccessTerminal + , _btEvent = ButtonAccessTerminal 0 , _btID = 0 - , _btTermMID = Nothing } terminalColor :: Color diff --git a/src/Dodge/WorldEffect.hs b/src/Dodge/WorldEffect.hs index 32437461e..ae04a5af8 100644 --- a/src/Dodge/WorldEffect.hs +++ b/src/Dodge/WorldEffect.hs @@ -51,12 +51,11 @@ doWdWd we = case we of loc <- invIndents (cr ^. crInv) ^? ix invid . _2 return $ heldEffectMuzzles loc cr w -accessTerminal :: Maybe Int -> World -> World -accessTerminal mtmid w = fromMaybe w $ do - tmid <- mtmid +accessTerminal :: Int -> World -> World +accessTerminal tid w = fromMaybe w $ do -- should possibly check the terminal actually exists return $ - w & hud . hudElement . subInventory .~ DisplayTerminal tmid - & cWorld . lWorld . terminals . ix tmid %~ tryToBoot + w & hud . hudElement . subInventory .~ DisplayTerminal tid + & cWorld . lWorld . terminals . ix tid %~ tryToBoot where tryToBoot tm = case _tmStatus tm of TerminalTextInput{} -> tm