Cleanup
This commit is contained in:
@@ -107,16 +107,10 @@ updateMouseHeldInGame cfig w = case w ^. input . mouseContext of
|
||||
OverInvDrag k mmouseover ab bn -> doDrag 30 k mmouseover ab bn w
|
||||
_ -> w
|
||||
|
||||
doDrag ::
|
||||
Int ->
|
||||
Int ->
|
||||
Maybe (Int, Int) ->
|
||||
Maybe (Int, Int) ->
|
||||
Maybe (Int, Int) ->
|
||||
World ->
|
||||
World
|
||||
doDrag 0 _ _ _ _ w = w
|
||||
doDrag :: Int -> Int -> Maybe (Int, Int) -> Maybe (Int, Int) -> Maybe (Int, Int) -> World -> World
|
||||
--doDrag 0 _ _ _ _ w = w
|
||||
doDrag n k mmouseover ab bn w = fromMaybe w $ do
|
||||
guard (n /= 0) -- > 0 ?
|
||||
ss <- w ^? hud . hudElement . diSections . ix k . ssItems
|
||||
x <- mmouseover
|
||||
is <- w ^? hud . hudElement . diSelection . _Just . _3
|
||||
@@ -255,11 +249,7 @@ updateMouseClickInGame cfig w = case w ^. input . mouseContext of
|
||||
f (x, y) = (x, y, mempty)
|
||||
selsec = w ^? hud . hudElement . diSelection . _Just . _1
|
||||
|
||||
endRegex ::
|
||||
Int ->
|
||||
World ->
|
||||
Maybe (Int, Int, IS.IntSet) ->
|
||||
Maybe (Int, Int, IS.IntSet)
|
||||
endRegex :: Int -> World -> Maybe (Int, Int, IS.IntSet) -> Maybe (Int, Int, IS.IntSet)
|
||||
endRegex i w = fromMaybe id $ do
|
||||
sss <- w ^? hud . hudElement . diSections
|
||||
let j = fromMaybe 0 $ do
|
||||
@@ -268,10 +258,7 @@ endRegex i w = fromMaybe id $ do
|
||||
return k
|
||||
return $ ssSetCursor (ssLookupDown i j) sss
|
||||
|
||||
endCombineRegex ::
|
||||
World ->
|
||||
Maybe (Int, Int, IS.IntSet) ->
|
||||
Maybe (Int, Int, IS.IntSet)
|
||||
endCombineRegex :: World -> Maybe (Int, Int, IS.IntSet) -> Maybe (Int, Int, IS.IntSet)
|
||||
endCombineRegex w = fromMaybe id $ do
|
||||
sss <- w ^? hud . hudElement . subInventory . ciSections
|
||||
let j = fromMaybe 0 $ do
|
||||
@@ -424,13 +411,13 @@ updateKeysTextInputTerminal tmid u =
|
||||
| otherwise = id
|
||||
|
||||
updateKeyInGame :: Universe -> Scancode -> Int -> Universe
|
||||
updateKeyInGame uv sc pt = case pt of
|
||||
updateKeyInGame uv sc = \case
|
||||
0 -> updateInitialPressInGame uv sc
|
||||
x | x >= 30 -> updateLongPressInGame uv sc
|
||||
_ -> uv
|
||||
|
||||
updateInitialPressInGame :: Universe -> Scancode -> Universe
|
||||
updateInitialPressInGame uv sc = case sc of
|
||||
updateInitialPressInGame uv = \case
|
||||
ScancodeSpace -> over uvWorld spaceAction uv
|
||||
ScancodeP -> pauseGame uv
|
||||
ScancodeF -> over uvWorld youDropItem uv
|
||||
@@ -443,7 +430,7 @@ updateInitialPressInGame uv sc = case sc of
|
||||
_ -> uv
|
||||
|
||||
updateLongPressInGame :: Universe -> Scancode -> Universe
|
||||
updateLongPressInGame uv sc = case sc of
|
||||
updateLongPressInGame uv = \case
|
||||
ScancodeF -> over uvWorld youDropItem uv
|
||||
ScancodeSpace -> over uvWorld spaceAction uv
|
||||
_ -> uv
|
||||
@@ -484,12 +471,10 @@ doRegexInput inp i sss msel filts
|
||||
|
||||
updateBackspaceRegex :: World -> World
|
||||
updateBackspaceRegex w = case di ^? subInventory of
|
||||
Just NoSubInventory{}
|
||||
| secfocus (-1) 0 ->
|
||||
Just NoSubInventory{} | secfocus (-1) 0 ->
|
||||
w & hud . hudElement %~ trybackspace (-1) diInvFilter diInvFilter diSelection
|
||||
& worldEventFlags . at InventoryChange ?~ ()
|
||||
Just NoSubInventory{}
|
||||
| secfocus 2 3 ->
|
||||
Just NoSubInventory{} | secfocus 2 3 ->
|
||||
w & hud . hudElement %~ trybackspace 2 diCloseFilter diCloseFilter diSelection
|
||||
& worldEventFlags . at InventoryChange ?~ ()
|
||||
Just CombineInventory{} ->
|
||||
@@ -511,12 +496,10 @@ updateBackspaceRegex w = case di ^? subInventory of
|
||||
|
||||
updateEnterRegex :: World -> World
|
||||
updateEnterRegex w = case w ^? hud . hudElement . subInventory of
|
||||
Just NoSubInventory{}
|
||||
| secfocus [-1, 0, 1] ->
|
||||
Just NoSubInventory{} | secfocus [-1, 0, 1] ->
|
||||
w & hud . hudElement . diSelection ?~ (-1, 0, mempty)
|
||||
& hud . hudElement . diInvFilter %~ enterregex
|
||||
Just NoSubInventory{}
|
||||
| secfocus [2, 3] ->
|
||||
Just NoSubInventory{} | secfocus [2, 3] ->
|
||||
w & hud . hudElement . diSelection ?~ (2, 0, mempty)
|
||||
& hud . hudElement . diCloseFilter %~ enterregex
|
||||
Just CombineInventory{} ->
|
||||
@@ -524,9 +507,8 @@ updateEnterRegex w = case w ^? hud . hudElement . subInventory of
|
||||
& hud . hudElement . subInventory . ciSelection ?~ (-1, 0, mempty)
|
||||
_ -> w
|
||||
where
|
||||
di = w ^. hud . hudElement
|
||||
secfocus xs = fromMaybe False $ do
|
||||
i <- di ^? diSelection . _Just . _1
|
||||
i <- w ^? hud . hudElement . diSelection . _Just . _1
|
||||
return $ i `elem` xs
|
||||
enterregex = (<|> Just "")
|
||||
|
||||
@@ -545,15 +527,16 @@ spaceAction w = case w ^. hud . hudElement of
|
||||
_ -> w & hud . hudElement . subInventory .~ NoSubInventory
|
||||
|
||||
getCloseObj :: World -> Maybe (Either FloorItem Button)
|
||||
getCloseObj w = getSelectedCloseObj w <|> firstcitem <|> firstcbut
|
||||
getCloseObj w = getSelectedCloseObj w <|> topcitem <|> topcbut
|
||||
where
|
||||
firstcitem = do
|
||||
k' <- (w ^? hud . hudElement . diSections . ix 3 . ssItems) >>= (fmap fst . IM.lookupMin)
|
||||
topcitem = do
|
||||
k' <- (w ^? hud . hudElement . diSections . ix 3 . ssItems)
|
||||
>>= (fmap fst . IM.lookupMin)
|
||||
NInt k <- w ^? hud . closeItems . ix k'
|
||||
fmap Left $ w ^? cWorld . lWorld . floorItems . unNIntMap . ix k
|
||||
firstcbut = do
|
||||
Left <$> w ^? cWorld . lWorld . floorItems . unNIntMap . ix k
|
||||
topcbut = do
|
||||
k <- w ^? hud . closeButtons . ix 0
|
||||
fmap Right $ w ^? cWorld . lWorld . buttons . ix k
|
||||
Right <$> w ^? cWorld . lWorld . buttons . ix k
|
||||
|
||||
tryCombine :: (Int, Int) -> World -> World
|
||||
tryCombine (i, j) w = fromMaybe w $ do
|
||||
@@ -568,5 +551,4 @@ tryCombine (i, j) w = fromMaybe w $ do
|
||||
maybeExitCombine :: World -> World
|
||||
maybeExitCombine w
|
||||
| ButtonRight `M.member` (w ^. input . mouseButtons) = w
|
||||
| otherwise =
|
||||
w & hud . hudElement . subInventory .~ NoSubInventory
|
||||
| otherwise = w & hud . hudElement . subInventory .~ NoSubInventory
|
||||
|
||||
Reference in New Issue
Block a user