Allow for terminals to be deactivated

This commit is contained in:
2025-08-19 13:58:57 +01:00
parent b8581a7862
commit 2f9cea1b69
9 changed files with 16 additions and 16 deletions
+1 -2
View File
@@ -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
+1 -1
View File
@@ -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 =
+2 -2
View File
@@ -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
+1 -1
View File
@@ -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
+1 -1
View File
@@ -53,7 +53,7 @@ defaultButton =
, _btEvent = ButtonPress False NoWorldEffect (dark red)
, _btID = 0
-- , _btState = BtOff
, _btTermMID = Nothing
-- , _btTermMID = Nothing
-- , _btName = ""
-- , _btColor = red
}
+3
View File
@@ -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
+1 -1
View File
@@ -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)
+2 -3
View File
@@ -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
+4 -5
View File
@@ -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