Start adding mouse control of inventory
This commit is contained in:
@@ -40,7 +40,8 @@ updateUseInputInGame u = case u ^. uvWorld . hud . hudElement of
|
||||
u & uvWorld . cWorld . lWorld . terminals . ix tmid . tmInput . tiFocus %~ const True
|
||||
CombineInventory{_ciSections = sss}
|
||||
| inSubInvRegex (u ^. uvWorld) ->
|
||||
u & uvWorld . hud . hudElement . subInventory . ciSections
|
||||
u
|
||||
& uvWorld . hud . hudElement . subInventory . ciSections
|
||||
%~ doRegexInput (u ^. uvWorld . input) (-1)
|
||||
& uvWorld . worldEventFlags . at CombineInventoryChange ?~ ()
|
||||
| lbinitialpress ->
|
||||
@@ -116,7 +117,7 @@ updateInitialPressInGame uv sc = case sc of
|
||||
ScancodeP -> pauseGame uv
|
||||
ScancodeF -> over uvWorld youDropItem uv
|
||||
ScancodeM -> toggleMap uv
|
||||
-- ScancodeR -> over (uvWorld . cWorld . lWorld . creatures . ix 0) crReloadToggle uv
|
||||
-- ScancodeR -> over (uvWorld . cWorld . lWorld . creatures . ix 0) crReloadToggle uv
|
||||
ScancodeT -> over uvWorld testEvent uv
|
||||
ScancodeX -> uv & uvWorld %~ toggleTweakInv
|
||||
ScancodeC -> toggleCombineInv uv
|
||||
@@ -158,11 +159,11 @@ doRegexInput inp i sss
|
||||
|
||||
updateBackspaceRegex :: World -> World
|
||||
updateBackspaceRegex w = case di ^? subInventory of
|
||||
Just NoSubInventory
|
||||
Just NoSubInventory{}
|
||||
| secfocus (-1) 0 ->
|
||||
w & hud . hudElement . diSections %~ trybackspace (-1)
|
||||
& worldEventFlags . at InventoryChange ?~ ()
|
||||
Just NoSubInventory
|
||||
Just NoSubInventory{}
|
||||
| secfocus 2 3 ->
|
||||
w & hud . hudElement . diSections %~ trybackspace 2
|
||||
& worldEventFlags . at InventoryChange ?~ ()
|
||||
@@ -187,11 +188,11 @@ updateBackspaceRegex w = case di ^? subInventory of
|
||||
|
||||
updateEnterRegex :: World -> World
|
||||
updateEnterRegex w = case w ^? hud . hudElement . subInventory of
|
||||
Just NoSubInventory
|
||||
Just NoSubInventory{}
|
||||
| secfocus (-1) 0 ->
|
||||
w & hud . hudElement . diSections . sssExtra . sssSelPos ?~ (-1, 0)
|
||||
& hud . hudElement . diSections %~ enterregex (-1)
|
||||
Just NoSubInventory
|
||||
Just NoSubInventory{}
|
||||
| secfocus 2 3 ->
|
||||
w & hud . hudElement . diSections . sssExtra . sssSelPos ?~ (2, 0)
|
||||
& hud . hudElement . diSections %~ enterregex 2
|
||||
@@ -216,7 +217,7 @@ pauseGame u = u & uvScreenLayers .~ [pauseMenu u]
|
||||
spaceAction :: World -> World
|
||||
spaceAction w = case w ^. hud . hudElement of
|
||||
DisplayCarte -> w & hud . carteCenter .~ theLoc
|
||||
DisplayInventory{_subInventory = NoSubInventory} -> case selectedCloseObject w of
|
||||
DisplayInventory{_subInventory = NoSubInventory{}} -> case selectedCloseObject w of
|
||||
Just (Left flit) ->
|
||||
pickUpItem 0 flit w
|
||||
& worldEventFlags . at InventoryChange ?~ ()
|
||||
@@ -225,9 +226,9 @@ spaceAction w = case w ^. hud . hudElement of
|
||||
& worldEventFlags . at InventoryChange ?~ ()
|
||||
_ -> w
|
||||
DisplayInventory{_subInventory = DisplayTerminal{}} ->
|
||||
w & hud . hudElement . subInventory .~ NoSubInventory
|
||||
w & hud . hudElement . subInventory .~ NoSubInventory Nothing Nothing
|
||||
& worldEventFlags . at InventoryChange ?~ ()
|
||||
_ -> w & hud . hudElement . subInventory .~ NoSubInventory
|
||||
_ -> w & hud . hudElement . subInventory .~ NoSubInventory Nothing Nothing
|
||||
where
|
||||
theLoc =
|
||||
doWorldPos
|
||||
@@ -238,25 +239,30 @@ toggleMap :: Universe -> Universe
|
||||
toggleMap u = case u ^. uvWorld . hud . hudElement of
|
||||
DisplayCarte ->
|
||||
u & uvWorld . hud . hudElement
|
||||
.~ DisplayInventory{_subInventory = NoSubInventory, _diSections = defaultInvSections}
|
||||
.~ DisplayInventory
|
||||
{ _subInventory = NoSubInventory Nothing Nothing
|
||||
, _diSections = defaultInvSections
|
||||
}
|
||||
_ -> u & uvWorld . hud . hudElement .~ DisplayCarte
|
||||
|
||||
toggleTweakInv :: World -> World
|
||||
toggleTweakInv w = case w ^? hud . hudElement . subInventory of
|
||||
Just ExamineInventory{} -> w & thepointer .~ NoSubInventory
|
||||
Just ExamineInventory{} -> w & thepointer .~ NoSubInventory Nothing Nothing
|
||||
_ -> w & thepointer .~ ExamineInventory -- mi
|
||||
where
|
||||
thepointer = hud . hudElement . subInventory
|
||||
|
||||
-- mi = 0 <$ (yourSelectedItem w >>= (^? itTweaks . tweakParams . ix 0))
|
||||
|
||||
tryCombine :: SelectionSections CombinableItem -> World -> World
|
||||
tryCombine sss w = fromMaybe w $ do
|
||||
(i, j) <- sss ^? sssExtra . sssSelPos . _Just
|
||||
CombinableItem is it _ <- sss ^? sssSections . ix i . ssItems . ix j . siPayload
|
||||
return $ snd (createItemYou it (foldr (destroyInvItem 0) w (sort is)))
|
||||
& cWorld . lWorld . creatures . ix 0 . crHammerPosition .~ HammerDown
|
||||
return $
|
||||
snd (createItemYou it (foldr (destroyInvItem 0) w (sort is)))
|
||||
& cWorld . lWorld . creatures . ix 0 . crHammerPosition .~ HammerDown
|
||||
|
||||
maybeExitCombine :: Universe -> Universe
|
||||
maybeExitCombine u
|
||||
| ButtonRight `M.member` (u ^. uvWorld . input . mouseButtons) = u
|
||||
| otherwise = u & uvWorld . hud . hudElement . subInventory .~ NoSubInventory
|
||||
| otherwise = u & uvWorld . hud . hudElement . subInventory .~ NoSubInventory Nothing Nothing
|
||||
|
||||
Reference in New Issue
Block a user