diff --git a/src/Dodge/Combine.hs b/src/Dodge/Combine.hs index e648254e7..dcbce0144 100644 --- a/src/Dodge/Combine.hs +++ b/src/Dodge/Combine.hs @@ -148,12 +148,21 @@ enterCombineInv cfig w = w & hud . hudElement . subInventory .~ CombineInventory cm | null cm' = IM.singleton 0 $ SelectionInfo ["No possible combinations"] 1 False white 0 | otherwise = cm' sss = SelectionSections - { _sssSections = IM.singleton 0 combsection + { _sssSections = IM.fromDistinctAscList [(-1,filtsection),(0,combsection)] , _sssSelPos = selpos } selpos | null cm' = Nothing | otherwise = Just (0,0) availablelines = getAvailableListLines secondColumnParams cfig + filtsection = SelectionSection + { _ssItems = mempty + , _ssCursor = Nothing + , _ssMinSize = 0 + , _ssOffset = 0 + , _ssShownItems = mempty + , _ssIndent = 0 + , _ssDescriptor = "COMB FILTER" + } combsection = updateSection cm (Just 0) availablelines combinationssection' combinationssection' = SelectionSection { _ssItems = cm diff --git a/src/Dodge/Data/HUD.hs b/src/Dodge/Data/HUD.hs index 05f39cc19..efae69cf9 100644 --- a/src/Dodge/Data/HUD.hs +++ b/src/Dodge/Data/HUD.hs @@ -17,6 +17,8 @@ data HUDElement = DisplayInventory { _subInventory :: SubInventory , _diSections :: SelectionSections () + , _invRegex :: Maybe String + , _closeRegex :: Maybe String } | DisplayCarte -- deriving (Eq, Ord, Show, Read) --Generic, Flat) diff --git a/src/Dodge/Data/Item/Use/Consumption/LoadAction.hs b/src/Dodge/Data/Item/Use/Consumption/LoadAction.hs index c4c743df6..3bbf2f9db 100644 --- a/src/Dodge/Data/Item/Use/Consumption/LoadAction.hs +++ b/src/Dodge/Data/Item/Use/Consumption/LoadAction.hs @@ -20,8 +20,6 @@ data LoadAction data Manipulation -- should be ManipulatedObject? -- = InvSel {_isel :: SelPos} = Manipulator {_manObject :: ManipulatedObject - , _invRegex :: Maybe String - , _closeRegex :: Maybe String } | Brute deriving (Eq, Ord, Show, Read) --Generic, Flat) diff --git a/src/Dodge/Default/Creature.hs b/src/Dodge/Default/Creature.hs index 954326c55..928b6e316 100644 --- a/src/Dodge/Default/Creature.hs +++ b/src/Dodge/Default/Creature.hs @@ -26,7 +26,7 @@ defaultCreature = , _crHP = 100 , _crMaxHP = 150 , _crInv = IM.empty - , _crManipulation = Manipulator SelNothing Nothing Nothing + , _crManipulation = Manipulator SelNothing , _crInvCapacity = 25 , _crInvLock = False , _crInvEquipped = mempty diff --git a/src/Dodge/Default/World.hs b/src/Dodge/Default/World.hs index 7cf68e4b2..f4bf3edff 100644 --- a/src/Dodge/Default/World.hs +++ b/src/Dodge/Default/World.hs @@ -152,13 +152,20 @@ defaultDisplaySections = SelectionSections defaultHUD :: HUD defaultHUD = HUD - { _hudElement = DisplayInventory {_subInventory =NoSubInventory, _diSections = defaultInvSections} + { _hudElement = defaultDisplayInventory , _carteCenter = V2 0 0 , _carteZoom = 0.5 , _carteRot = 0 , _closeObjects = [] } +defaultDisplayInventory :: HUDElement +defaultDisplayInventory = DisplayInventory + {_subInventory =NoSubInventory + , _diSections = defaultInvSections + , _invRegex = Nothing + , _closeRegex = Nothing + } --youLight :: TempLightSource --youLight = TLS -- { _tlsParam = LSParam diff --git a/src/Dodge/DisplayInventory.hs b/src/Dodge/DisplayInventory.hs index 550015871..2a693e493 100644 --- a/src/Dodge/DisplayInventory.hs +++ b/src/Dodge/DisplayInventory.hs @@ -38,8 +38,8 @@ updateDisplayInventory w cfig sss = case cr ^? crManipulation . manObject of SelNothing -> reverse [filtinv,filtclose,invx ,youx, closex] InNearby SortNearby -> reverse [filtinv,filtclose,closex, invx ,youx] InNearby SelCloseObject {} -> reverse [filtinv,filtclose,closex, invx ,youx] - (filtinv,invx) = filtpair (-1) (crManipulation . invRegex . _Just) invitems' "INV. " - (filtclose,closex) = filtpair 2 (crManipulation . closeRegex . _Just) coitems' "NEARBY " + (filtinv,invx) = filtpair (-1) (hud . hudElement . invRegex . _Just) invitems' "INV. " + (filtclose,closex) = filtpair 2 (hud . hudElement . closeRegex . _Just) coitems' "NEARBY " youx = (1, youitems) youitems = IM.singleton 0 $ SelectionItem [thetext] 1 True invDimColor 2 () thetext = displayFreeSlots nfreeslots @@ -55,7 +55,7 @@ updateDisplayInventory w cfig sss = case cr ^? crManipulation . manObject of , ( i+1, itms') ) where - mstr = cr ^? regpointer + mstr = w ^? regpointer filtsis = fromMaybe mempty $ do str <- mstr return $ IM.singleton 0 diff --git a/src/Dodge/Render/HUD.hs b/src/Dodge/Render/HUD.hs index ed513f485..600205973 100644 --- a/src/Dodge/Render/HUD.hs +++ b/src/Dodge/Render/HUD.hs @@ -176,7 +176,6 @@ examineInventoryExtra mtweaki mitm cfig = fromMaybe mempty $ do return $ listCursorNSW subInvX 60 cfig tweaki 0 white (length $ showTweak tparam) 15 -- , drawSelectionList thirdColumnParams cfig (thirdColumnPara (itmInfo mitm)) ---combineInventoryExtra :: SelectionIntMap CombinableItem -> Maybe Int -> Configuration -> World -> Picture combineInventoryExtra :: SelectionSections CombinableItem -> Configuration -> World -> Picture combineInventoryExtra sss cfig w = fromMaybe mempty $ do (i,j) <- sss ^? sssSelPos . _Just @@ -192,7 +191,6 @@ combineInventoryExtra sss cfig w = fromMaybe mempty $ do lnks <- si ^? siPayload . ciInvIDs return $ lnkMidPosInvSelsCol cfig w cpos col lnks - -- <> foldMap (topCursorTypeWidth listCursorNESW (topInvW + 2) cfig w) lnks <> foldMap invcursor lnks <> combineCounts cfig w lnks ] diff --git a/src/Dodge/Update.hs b/src/Dodge/Update.hs index b959c4398..da5a10764 100644 --- a/src/Dodge/Update.hs +++ b/src/Dodge/Update.hs @@ -6,7 +6,7 @@ Description : Simulation update -} module Dodge.Update (updateUniverse) where -import Dodge.InputFocus +--import Dodge.InputFocus import Dodge.DisplayInventory import Dodge.ScrollValue import Color @@ -19,7 +19,7 @@ import Dodge.Beam import Dodge.Bullet import Dodge.CrGroupUpdate import Dodge.Creature.Update -import Dodge.Data.SelectionList +--import Dodge.Data.SelectionList import Dodge.Data.Universe import Dodge.Distortion import Dodge.DrWdWd @@ -35,7 +35,7 @@ import Dodge.LinearShockwave.Update import Dodge.Machine.Update import Dodge.Magnet.Update import Dodge.Menu -import Dodge.Menu.Option +--import Dodge.Menu.Option import Dodge.ModificationEffect import Dodge.PosEvent import Dodge.PressPlate @@ -43,7 +43,6 @@ import Dodge.Projectile.Update import Dodge.Prop.Update import Dodge.RadarBlip import Dodge.RadarSweep -import Dodge.SelectionList import Dodge.Shockwave.Update import Dodge.SoundLogic import Dodge.Spark diff --git a/src/Dodge/Update/Input.hs b/src/Dodge/Update/Input.hs index e66e1a329..fe8761911 100644 --- a/src/Dodge/Update/Input.hs +++ b/src/Dodge/Update/Input.hs @@ -48,7 +48,7 @@ updateUseInputOnScreen sl = case sl of updateUseInputInGame :: HUDElement -> Universe -> Universe updateUseInputInGame h u = case h of DisplayCarte -> over uvWorld updatePressedButtonsCarte u - DisplayInventory si _ -> case si of + DisplayInventory si _ _ _ -> case si of DisplayTerminal tmid | lbinitialpress && inTermFocus w -> over uvWorld (doTerminalEffectLB (w ^?! cWorld . lWorld . terminals . ix tmid)) u @@ -121,31 +121,39 @@ doSubInvRegexInput u && ScancodeBackspace `M.lookup` pkeys == Just InitialPress pkeys = u ^. uvWorld . input . pressedKeys -doRegexInput :: - Int -> - ( (Maybe String -> Identity (Maybe String)) -> - Manipulation -> - Identity Manipulation - ) -> - ( ( Maybe String -> - Const (First String) (Maybe String) - ) -> - Manipulation -> - Const (First String) Manipulation - ) -> - Universe -> - Universe +--doRegexInput :: +-- Int -> +-- ( (Maybe String -> Identity (Maybe String)) -> +-- Manipulation -> +-- Identity Manipulation +-- ) -> +-- ( ( Maybe String -> +-- Const (First String) (Maybe String) +-- ) -> +-- Manipulation -> +-- Const (First String) Manipulation +-- ) -> +-- Universe -> +-- Universe +doRegexInput :: Int + -> ((Maybe String -> Identity (Maybe String)) + -> HUDElement -> Identity HUDElement) + -> ((Maybe String + -> Const (Data.Monoid.First String) (Maybe String)) + -> HUDElement -> Const (Data.Monoid.First String) HUDElement) + -> Universe + -> Universe doRegexInput i crregex crregex' u | backspacetonothing || escapekey = closeregex i 0 | endkeys || endmouse = closeregex (i + 1) (j -1) | otherwise = u & doTextInputOver - (uvWorld . cWorld . lWorld . creatures . ix 0 . crManipulation . crregex . _Just) + (uvWorld . hud . hudElement . crregex . _Just) where closeregex a b = u - & uvWorld . cWorld . lWorld . creatures . ix 0 . crManipulation . crregex .~ Nothing + & uvWorld . hud . hudElement . crregex .~ Nothing & uvWorld . hud . hudElement . diSections %~ ( ssSetCursor (ssLookupDown a b) . overSection (ssItems . at i .~ Nothing) @@ -161,7 +169,7 @@ doRegexInput i crregex crregex' u [ScancodeReturn, ScancodeSlash] endmouse = Just True == (u ^? uvWorld . input . mouseButtons . ix ButtonLeft) backspacetonothing = - u ^? uvWorld . cWorld . lWorld . creatures . ix 0 . crManipulation . crregex' . _Just == Just "" + u ^? uvWorld . hud . hudElement . crregex' . _Just == Just "" && ScancodeBackspace `M.lookup` pkeys == Just InitialPress pkeys = u ^. uvWorld . input . pressedKeys @@ -220,57 +228,49 @@ updateLongPressInGame uv sc = case sc of ScancodeSpace -> over uvWorld spaceAction uv _ -> uv +-- doesn't seem to set cursor positioning updateBackspaceRegex :: World -> World updateBackspaceRegex w = case di ^? subInventory of - Just NoSubInventory | secfocus (-1) 0 -> w & cWorld . lWorld . creatures . ix 0 . crManipulation %~ trybackspace - Just NoSubInventory | secfocus 2 3 -> w & cWorld . lWorld . creatures . ix 0 . crManipulation %~ trybackspaceclose --- Just CombineInventory{} -> --- w & hud . hudElement . subInventory . subInvMap --- %~ ( (smRegex %~ enternonzeroregex) --- . (smSelPos ?~ 0) --- . setShownIntMap --- ) + Just NoSubInventory | secfocus (-1) 0 -> w & trybackspace + Just NoSubInventory | secfocus 2 3 -> w & trybackspaceclose + Just CombineInventory{} -> w & hud . hudElement . subInventory %~ trybackspacecomb _ -> w where secfocus a b = fromMaybe False $ do i <- di ^? diSections . sssSelPos . _Just . _1 return $ i == a || i == b - trybackspace cm = case cm ^? invRegex . _Just of + trybackspacecomb ci = case ci ^? ciRegex . _Just of Just (_ : _) -> - cm & invRegex . _Just %~ init - & manObject .~ InInventory SortInventory - Just [] -> cm & invRegex .~ Nothing - Nothing -> cm - trybackspaceclose cm = case cm ^? closeRegex . _Just of + ci & ciRegex . _Just %~ init + Just [] -> ci & ciRegex .~ Nothing + Nothing -> ci + trybackspace w' = case w' ^? hud . hudElement . invRegex . _Just of Just (_ : _) -> - cm & closeRegex . _Just %~ init - & manObject .~ InNearby SortNearby - Just [] -> cm & closeRegex .~ Nothing - Nothing -> cm + w' & hud . hudElement . invRegex . _Just %~ init + & cWorld . lWorld . creatures . ix 0 . crManipulation . manObject .~ InInventory SortInventory + Just [] -> w' & hud . hudElement . invRegex .~ Nothing + Nothing -> w' + trybackspaceclose w' = case w' ^? hud . hudElement . closeRegex . _Just of + Just (_ : _) -> + w' & hud . hudElement . closeRegex . _Just %~ init + & cWorld . lWorld . creatures . ix 0 . crManipulation . manObject .~ InNearby SortNearby + Just [] -> w' & hud . hudElement . closeRegex .~ Nothing + Nothing -> w' di = w ^. hud . hudElement - enternonzeroregex (Just (x : xs)) = Just (init (x : xs)) - enternonzeroregex smr = smr updateEnterRegex :: World -> World updateEnterRegex w = case w ^? hud . hudElement . subInventory of Just NoSubInventory | secfocus (-1) 0 -> - w & cWorld . lWorld . creatures . ix 0 . crManipulation - %~ ( (invRegex %~ enterregex) - . (manObject .~ InInventory SortInventory) - ) + w & cWorld . lWorld . creatures . ix 0 . crManipulation . manObject + .~ InInventory SortInventory + & hud . hudElement . invRegex %~ enterregex Just NoSubInventory | secfocus 2 3 -> - w & cWorld . lWorld . creatures . ix 0 . crManipulation - %~ ( (closeRegex %~ enterregex) - . (manObject .~ InNearby SortNearby) - ) - Just CombineInventory{} -> w --- w & hud . hudElement . subInventory . subInvMap --- %~ ( setShownIntMap --- . (smSelPos ?~ 0) --- . (smRegex %~ enterregex) --- ) + w & cWorld . lWorld . creatures . ix 0 . crManipulation . manObject .~ InNearby SortNearby + & hud . hudElement . closeRegex %~ enterregex + Just CombineInventory{} -> w & hud . hudElement . subInventory + %~ ( ciRegex %~ enterregex ) _ -> w where di = w ^. hud . hudElement @@ -306,7 +306,8 @@ spaceAction w = case w ^?! hud . hudElement of toggleMap :: Universe -> Universe toggleMap u = case u ^?! uvWorld . hud . hudElement of DisplayCarte -> u & uvWorld . hud . hudElement - .~ DisplayInventory{_subInventory = NoSubInventory, _diSections = defaultInvSections} + .~ DisplayInventory{_subInventory = NoSubInventory, _diSections = defaultInvSections + , _invRegex = Nothing, _closeRegex = Nothing} _ -> u & uvWorld . hud . hudElement .~ DisplayCarte toggleTweakInv :: World -> World @@ -400,6 +401,7 @@ setSelectionListRestriction cfig screen = fromMaybe screen $ do ldps <- screen ^? scListDisplayParams return $ screen & scAvailableLines %~ const (getAvailableListLines ldps cfig) +updatePressedButtonsCarte :: World -> World updatePressedButtonsCarte w = updatePressedButtonsCarte' (_mouseButtons (_input w)) w updatePressedButtonsCarte' :: M.Map MouseButton Bool -> World -> World