Shuffle regexes
This commit is contained in:
+10
-1
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
]
|
||||
|
||||
+3
-4
@@ -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
|
||||
|
||||
+55
-53
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user