Refactor terminal prompt/maxlines into terminaltype

This commit is contained in:
2024-11-06 11:16:35 +00:00
parent 6168bf282e
commit bfd4649e1b
7 changed files with 39 additions and 27 deletions
+1 -1
View File
@@ -1 +1 @@
All good (593 modules, at 21:15:38)
All good (0 modules, at 11:16:28)
+4 -2
View File
@@ -37,7 +37,6 @@ data Terminal = Terminal
, _tmName :: String
, _tmDisplayedLines :: [(String, Color)]
, _tmFutureLines :: [TerminalLine]
, _tmMaxLines :: Int
, _tmTitle :: String
, _tmInput :: TerminalInput
, _tmScrollCommands :: [TerminalCommand]
@@ -47,11 +46,13 @@ data Terminal = Terminal
, _tmCommandHistory :: [String]
, _tmToggles :: M.Map String TerminalToggle
, _tmPartialCommand :: Maybe TerminalCommand
, _tmPromptString :: String
, _tmType :: TerminalType
}
--deriving (Eq, Show, Read) --, Generic)
--h--deriving (Eq, Show, Read) --Generic, Flat)
data TerminalType = DefaultTerminal
data TerminalLineString = TerminalLineConst String Color
--deriving (Eq, Ord, Show, Read) --Generic, Flat)
@@ -140,4 +141,5 @@ concat <$> mapM (deriveJSON defaultOptions)
, ''TerminalCommandEffect
, ''TerminalCommand
, ''Terminal
, ''TerminalType
]
+1 -2
View File
@@ -15,7 +15,6 @@ defaultTerminal =
, _tmName = "TESTTERMINAL"
, _tmDisplayedLines = []
, _tmFutureLines = []
, _tmMaxLines = 14
, _tmTitle = "TERMINAL IN LOCATION"
, _tmInput = defaultTerminalInput
, _tmScrollCommands = []
@@ -25,7 +24,7 @@ defaultTerminal =
, _tmCommandHistory = []
, _tmToggles = mempty
, _tmPartialCommand = Nothing
, _tmPromptString = "$ "
, _tmType = DefaultTerminal
}
defaultTerminalInput :: TerminalInput
+3 -2
View File
@@ -6,6 +6,7 @@ module Dodge.Render.HUD (
selNumPosCardinal, -- this shoud probably be pushed back here
) where
import Dodge.Terminal.Type
import Dodge.CharacterEnums
import Dodge.Creature.Test
import Dodge.DoubleTree
@@ -354,14 +355,14 @@ displayTerminal tid cfig w = fromMaybe mempty $ do
thelist tm =
map toselitm . displayTermInput tm
. reverse
. take (_tmMaxLines tm)
. take (getMaxLinesTM (tm ^. tmType))
$ _tmDisplayedLines tm
displayTermInput tm = case _tmInput tm of
TerminalInput{_tiText = s, _tiFocus = hasfoc} ->
(++ [(displayInputText tm s ++ displayBlinkCursor hasfoc, white)])
partcommand tm = maybe "" (++ " ") $ tm ^? tmPartialCommand . _Just . tcString
displayInputText tm s
| _tmStatus tm == TerminalReady = partcommand tm ++ _tmPromptString tm ++ s
| _tmStatus tm == TerminalReady = partcommand tm ++ getPromptTM (tm ^. tmType) ++ s
| otherwise = ""
displayBlinkCursor hasfoc
-- | hasfoc = clockCycle 10 (V.fromList [[cFilledRect] , "."]) w
+2 -2
View File
@@ -18,6 +18,7 @@ module Dodge.Terminal (
terminalReturnEffect,
) where
import Dodge.Terminal.Type
import Control.Monad
import Color
import Data.Char
@@ -37,7 +38,6 @@ basicTerminal =
defaultTerminal
{ _tmDisplayedLines = []
, _tmFutureLines = []
, _tmMaxLines = 14
, _tmTitle = "TERMINAL"
, _tmScrollCommands = [quitCommand]
, _tmWriteCommands = [helpCommand, commandsCommand]
@@ -283,7 +283,7 @@ terminalReturnEffect tm w = fromMaybe w $ do
w
& cWorld . lWorld . terminals . ix (_tmID tm) . tmPartialCommand .~ Nothing
& cWorld . lWorld . terminals . ix (_tmID tm) . tmFutureLines
.~ [makeTermLine (pc ++ _tmPromptString tm ++ s)]
.~ [makeTermLine (pc ++ getPromptTM (tm ^. tmType) ++ s)]
runTerminalString :: String -> Terminal -> World -> World
runTerminalString s tm w =
-1
View File
@@ -79,7 +79,6 @@ lineOutputTerminal tls =
defaultTerminal
{ _tmDisplayedLines = []
, _tmFutureLines = []
, _tmMaxLines = 14
, _tmTitle = "TERMINAL"
, _tmScrollCommands = [quitCommand]
, _tmWriteCommands = [helpCommand, commandsCommand]
+28 -17
View File
@@ -1050,6 +1050,7 @@ Lights src/Dodge/Render/Lights.hs 1;" m
LimitedBreathableAtmosphere src/Dodge/Data/Scenario.hs 38;" C
LimitedFood src/Dodge/Data/Scenario.hs 39;" C
LimitedWater src/Dodge/Data/Scenario.hs 40;" C
Line src/Dodge/Terminal/Line.hs 1;" m
LinearShockwave src/Dodge/Data/LinearShockwave.hs 13;" t
LinearShockwave src/Dodge/Data/LinearShockwave.hs 6;" m
Link src/Dodge/Room/Link.hs 6;" m
@@ -1979,6 +1980,7 @@ TwoHandFlat src/Dodge/Data/Item/Use.hs 177;" C
TwoHandOver src/Dodge/Data/Item/Use.hs 176;" C
TwoHandUnder src/Dodge/Data/Item/Use.hs 175;" C
Type src/Dodge/Data/Damage/Type.hs 6;" m
Type src/Dodge/Terminal/Type.hs 1;" m
Typical src/Shape/Data.hs 36;" C
UncomposableIsolateSF src/Dodge/Data/ComposedItem.hs 37;" C
Uncursed src/Dodge/Data/Item/CurseStatus.hs 12;" C
@@ -3673,6 +3675,7 @@ conEffects src/Dodge/Concurrent.hs 17;" f
concBall src/Dodge/WorldEvent/SpawnParticle.hs 27;" f
connectItemS src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 532;" f
connectionBlurb src/Dodge/Terminal.hs 103;" f
connectionBlurb src/Dodge/Terminal/Type.hs 20;" f
connectionBlurbLines src/Dodge/Terminal.hs 48;" f
constructEdges src/Polyhedra.hs 34;" f
constructEdgesList src/Polyhedra.hs 43;" f
@@ -4026,7 +4029,7 @@ doPropUpdates src/Dodge/Prop/Update.hs 36;" f
doQuickload src/Dodge/Save.hs 82;" f
doQuicksave src/Dodge/Save.hs 77;" f
doRandImpulse src/Dodge/RandImpulse.hs 7;" f
doRegexInput src/Dodge/Update/Input/InGame.hs 187;" f
doRegexInput src/Dodge/Update/Input/InGame.hs 188;" f
doRoomInPlacements src/Dodge/Layout.hs 97;" f
doRoomOutPlacements src/Dodge/Layout.hs 107;" f
doRoomPlacements src/Dodge/Layout.hs 122;" f
@@ -4362,6 +4365,7 @@ getAmmoLinks src/Dodge/Item/Grammar.hs 73;" f
getArguments src/Dodge/Update/Scroll.hs 154;" f
getArguments' src/Dodge/Update/Scroll.hs 142;" f
getAvailableListLines src/Dodge/SelectionList.hs 10;" f
getBootTM src/Dodge/Terminal/Type.hs 17;" f
getBulletTrajectory src/Dodge/HeldUse.hs 347;" f
getBulletType src/Dodge/HeldUse.hs 321;" f
getCommands src/Dodge/Terminal.hs 118;" f
@@ -4378,10 +4382,12 @@ getLaserColor src/Dodge/HeldUse.hs 196;" f
getLaserDamage src/Dodge/HeldUse.hs 193;" f
getLaserPhaseV src/Dodge/HeldUse.hs 190;" f
getLinksOfType src/Dodge/RoomLink.hs 39;" f
getMaxLinesTM src/Dodge/Terminal/Type.hs 14;" f
getMouseInvSel src/Dodge/Render/HUD.hs 124;" f
getNodePos src/Dodge/Path.hs 31;" f
getPretty src/AesonHelp.hs 7;" f
getPrettyShort src/AesonHelp.hs 10;" f
getPromptTM src/Dodge/Terminal/Type.hs 11;" f
getRootItemBounds src/Dodge/Render/HUD.hs 97;" f
getSensor src/Dodge/Terminal.hs 190;" f
getSmoothScrollValue src/Dodge/SmoothScroll.hs 17;" f
@@ -4811,7 +4817,9 @@ makeButton src/Dodge/LevelGen/Switch.hs 16;" f
makeByteStringShaderUsingVAO src/Shader/Compile.hs 128;" f
makeCloudAt src/Dodge/WorldEvent/Cloud.hs 18;" f
makeColorTermLine src/Dodge/Terminal.hs 130;" f
makeColorTermLine src/Dodge/Terminal/Line.hs 19;" f
makeColorTermPara src/Dodge/Terminal.hs 127;" f
makeColorTermPara src/Dodge/Terminal/Line.hs 16;" f
makeCorpse src/Dodge/Corpse/Make.hs 10;" f
makeDebris src/Dodge/Block/Debris.hs 42;" f
makeDebrisDirected src/Dodge/Block/Debris.hs 79;" f
@@ -4854,6 +4862,7 @@ makeSwitch src/Dodge/LevelGen/Switch.hs 52;" f
makeSwitchSPic src/Dodge/LevelGen/Switch.hs 40;" f
makeTermLine src/Dodge/Terminal.hs 121;" f
makeTermPara src/Dodge/Terminal.hs 124;" f
makeTermPara src/Dodge/Terminal/Line.hs 13;" f
makeTeslaArc src/Dodge/Tesla/Arc.hs 57;" f
makeTeslaBallAt src/Dodge/Tesla/Ball.hs 6;" f
makeTeslaExplosionAt src/Dodge/WorldEvent/Explosion.hs 41;" f
@@ -4875,7 +4884,7 @@ maybeClearPath src/Dodge/Block.hs 77;" f
maybeClearPaths src/Dodge/Block.hs 74;" f
maybeDestroyBlock src/Dodge/Wall/Damage.hs 26;" f
maybeDestroyDoor src/Dodge/Wall/Damage.hs 31;" f
maybeExitCombine src/Dodge/Update/Input/InGame.hs 350;" f
maybeExitCombine src/Dodge/Update/Input/InGame.hs 351;" f
maybeOpenTerminal src/Dodge/Update.hs 120;" f
maybeReadFile src/Dodge/LoadSeed.hs 10;" f
maybeTakeOne src/RandomHelp.hs 111;" f
@@ -5104,7 +5113,7 @@ parseNum src/Dodge/Debug/Terminal.hs 73;" f
pathConnected src/Dodge/Room/CheckConsistency.hs 14;" f
pathEdgeObstructed src/Dodge/Path.hs 43;" f
pauseAndFloatCam src/Dodge/Camera.hs 10;" f
pauseGame src/Dodge/Update/Input/InGame.hs 284;" f
pauseGame src/Dodge/Update/Input/InGame.hs 285;" f
pauseMenu src/Dodge/Menu.hs 53;" f
pauseMenuOptions src/Dodge/Menu.hs 58;" f
pauseSound src/Dodge/SoundLogic.hs 41;" f
@@ -5761,7 +5770,7 @@ soundToVol src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 4;" f
soundWithStatus src/Dodge/SoundLogic.hs 98;" f
soundWithStatusVolume src/Dodge/SoundLogic.hs 48;" f
southPillarsRoom src/Dodge/Room/LongDoor.hs 85;" f
spaceAction src/Dodge/Update/Input/InGame.hs 287;" f
spaceAction src/Dodge/Update/Input/InGame.hs 288;" f
spanColLightBlackI src/Dodge/Placement/Instance/LightSource.hs 186;" f
spanColLightI src/Dodge/Placement/Instance/LightSource.hs 179;" f
spanLS src/Dodge/Placement/Instance/LightSource.hs 171;" f
@@ -5888,7 +5897,9 @@ teleS src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 390;" f
teleportModule src/Dodge/Item/Craftable.hs 30;" f
termButton src/Dodge/Placement/Instance/Terminal.hs 51;" f
termSoundLine src/Dodge/Terminal.hs 112;" f
termSoundLine src/Dodge/Terminal/Line.hs 10;" f
termTextColor src/Dodge/Terminal.hs 115;" f
termTextColor src/Dodge/Terminal/Line.hs 22;" f
terminalColor src/Dodge/Placement/Instance/Terminal.hs 66;" f
terminalReturnEffect src/Dodge/Terminal.hs 276;" f
terminalSPic src/Dodge/Machine/Draw.hs 26;" f
@@ -5954,8 +5965,8 @@ toggleCombineInv src/Dodge/DisplayInventory.hs 31;" f
toggleCommand src/Dodge/Terminal.hs 197;" f
toggleEquipmentAt src/Dodge/Creature/Impulse/UseItem.hs 79;" f
toggleJust src/MaybeHelp.hs 41;" f
toggleMap src/Dodge/Update/Input/InGame.hs 311;" f
toggleTweakInv src/Dodge/Update/Input/InGame.hs 327;" f
toggleMap src/Dodge/Update/Input/InGame.hs 312;" f
toggleTweakInv src/Dodge/Update/Input/InGame.hs 328;" f
togglesToEffects src/Dodge/Terminal.hs 248;" f
tone440S src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 474;" f
tone440sawtoothS src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 444;" f
@@ -6026,7 +6037,7 @@ trunkDepth src/TreeHelp.hs 161;" f
tryAssignHotkey src/Dodge/Creature/YourControl.hs 85;" f
tryAttachBulletBelt src/Dodge/Euse.hs 40;" f
tryChargeBattery src/Dodge/Euse.hs 43;" f
tryCombine src/Dodge/Update/Input/InGame.hs 336;" f
tryCombine src/Dodge/Update/Input/InGame.hs 337;" f
tryGetChannel src/Sound.hs 96;" f
tryGetRootAttachedFromInvID src/Dodge/Inventory/Location.hs 20;" f
tryGetRootItemInvID src/Dodge/Inventory/Location.hs 29;" f
@@ -6072,7 +6083,7 @@ updateAllNodes src/TreeHelp.hs 85;" f
updateArc src/Dodge/Tesla/Arc.hs 86;" f
updateAttachedItems src/Dodge/Creature/State.hs 173;" f
updateAutoRecharge src/Dodge/Creature/State.hs 324;" f
updateBackspaceRegex src/Dodge/Update/Input/InGame.hs 222;" f
updateBackspaceRegex src/Dodge/Update/Input/InGame.hs 223;" f
updateBarrel src/Dodge/Barreloid.hs 45;" f
updateBarreloid src/Dodge/Barreloid.hs 13;" f
updateBounds src/Dodge/Update/Camera.hs 245;" f
@@ -6083,7 +6094,7 @@ updateCamera src/Dodge/Update/Camera.hs 31;" f
updateCloseObjects src/Dodge/Inventory.hs 124;" f
updateCloud src/Dodge/Update.hs 727;" f
updateClouds src/Dodge/Update.hs 571;" f
updateCombineInvClick src/Dodge/Update/Input/InGame.hs 90;" f
updateCombineInvClick src/Dodge/Update/Input/InGame.hs 91;" f
updateCombinePositioning src/Dodge/DisplayInventory.hs 38;" f
updateCombineSections src/Dodge/DisplayInventory.hs 44;" f
updateCreature src/Dodge/Creature/Update.hs 10;" f
@@ -6096,7 +6107,7 @@ updateDistortion src/Dodge/Distortion.hs 5;" f
updateDistortions src/Dodge/Update.hs 532;" f
updateEnergyBall src/Dodge/EnergyBall.hs 46;" f
updateEnergyBalls src/Dodge/Update.hs 559;" f
updateEnterRegex src/Dodge/Update/Input/InGame.hs 263;" f
updateEnterRegex src/Dodge/Update/Input/InGame.hs 264;" f
updateExpBarrel src/Dodge/Barreloid.hs 19;" f
updateFBOTO src/Framebuffer/Update.hs 97;" f
updateFBOTO3 src/Framebuffer/Update.hs 131;" f
@@ -6110,20 +6121,20 @@ updateHumanoid src/Dodge/Humanoid.hs 12;" f
updateIMl src/Dodge/Update.hs 501;" f
updateIMl' src/Dodge/Update.hs 506;" f
updateInGameCamera src/Dodge/Update/Camera.hs 70;" f
updateInitialPressInGame src/Dodge/Update/Input/InGame.hs 161;" f
updateInitialPressInGame src/Dodge/Update/Input/InGame.hs 162;" f
updateInstantBullets src/Dodge/Update.hs 648;" f
updateInv src/Dodge/Creature/State.hs 152;" f
updateInventoryPositioning src/Dodge/DisplayInventory.hs 85;" f
updateItemTargeting src/Dodge/Creature/State.hs 268;" f
updateItemWithOrientation src/Dodge/Creature/State.hs 194;" f
updateKeyInGame src/Dodge/Update/Input/InGame.hs 155;" f
updateKeysInTerminal src/Dodge/Update/Input/InGame.hs 144;" f
updateKeyInGame src/Dodge/Update/Input/InGame.hs 156;" f
updateKeysInTerminal src/Dodge/Update/Input/InGame.hs 145;" f
updateLampoid src/Dodge/Lampoid.hs 12;" f
updateLaser src/Dodge/Laser/Update.hs 13;" f
updateLasers src/Dodge/Update.hs 430;" f
updateLightSources src/Dodge/Update.hs 535;" f
updateLinearShockwave src/Dodge/LinearShockwave/Update.hs 8;" f
updateLongPressInGame src/Dodge/Update/Input/InGame.hs 181;" f
updateLongPressInGame src/Dodge/Update/Input/InGame.hs 182;" f
updateMIM src/Dodge/Update.hs 661;" f
updateMachine src/Dodge/Machine/Update.hs 16;" f
updateMouseInventorySelection src/Dodge/Update.hs 304;" f
@@ -6137,8 +6148,8 @@ updatePastWorlds src/Dodge/Update.hs 418;" f
updatePosEvent src/Dodge/PosEvent.hs 11;" f
updatePosEvents src/Dodge/Update.hs 568;" f
updatePreload src/Preload/Update.hs 20;" f
updatePressedButtonsCarte src/Dodge/Update/Input/InGame.hs 119;" f
updatePressedButtonsCarte' src/Dodge/Update/Input/InGame.hs 122;" f
updatePressedButtonsCarte src/Dodge/Update/Input/InGame.hs 120;" f
updatePressedButtonsCarte' src/Dodge/Update/Input/InGame.hs 123;" f
updateProjectile src/Dodge/Projectile/Update.hs 23;" f
updateProp src/Dodge/Prop/Update.hs 11;" f
updateRBList src/Dodge/Inventory/RBList.hs 16;" f
@@ -6172,7 +6183,7 @@ updateUniverse src/Dodge/Update.hs 69;" f
updateUniverseFirst src/Dodge/Update.hs 80;" f
updateUniverseLast src/Dodge/Update.hs 130;" f
updateUniverseMid src/Dodge/Update.hs 151;" f
updateUseInputInGame src/Dodge/Update/Input/InGame.hs 33;" f
updateUseInputInGame src/Dodge/Update/Input/InGame.hs 34;" f
updateUseInputOnScreen src/Dodge/Update/Input/ScreenLayer.hs 20;" f
updateWalkCycle src/Dodge/Creature/State/WalkCycle.hs 12;" f
updateWallDamages src/Dodge/Update/WallDamage.hs 10;" f