Cleanup
This commit is contained in:
+17
-17
@@ -2,7 +2,6 @@ module Dodge.Update.Scroll (
|
||||
updateWheelEvent,
|
||||
) where
|
||||
|
||||
import Dodge.SelectionSections
|
||||
import qualified Data.Map.Strict as M
|
||||
import Data.Maybe
|
||||
import Dodge.Base
|
||||
@@ -10,6 +9,7 @@ import Dodge.Data.Universe
|
||||
import Dodge.HeldScroll
|
||||
import Dodge.InputFocus
|
||||
import Dodge.Inventory
|
||||
import Dodge.SelectionSections
|
||||
import Dodge.SoundLogic
|
||||
import Dodge.Terminal
|
||||
import Dodge.Tweak
|
||||
@@ -22,7 +22,7 @@ updateWheelEvent yi w = case w ^. hud . hudElement of
|
||||
DisplayCarte
|
||||
| rbDown -> w & hud . carteZoom %~ min 0.75 . max 0.05 . ((1 + y * 0.1) *)
|
||||
| otherwise -> w & cWorld . lWorld . selLocation %~ (`mod` numLocs) . (+ yi)
|
||||
DisplayInventory {_subInventory = NoSubInventory}
|
||||
DisplayInventory{_subInventory = NoSubInventory}
|
||||
-- functions that modify the inventory should be centralised so that
|
||||
-- this lock can be sensibly applied, perhaps
|
||||
| w ^?! cWorld . lWorld . creatures . ix 0 . crInvLock -> w
|
||||
@@ -33,13 +33,13 @@ updateWheelEvent yi w = case w ^. hud . hudElement of
|
||||
| lbDown -> w & wCam . camZoom +~ y
|
||||
| invKeyDown -> changeSwapSel yi w
|
||||
| otherwise -> stopSoundFrom (CrReloadSound 0) $ scrollAugInvSel yi w
|
||||
DisplayInventory {_subInventory = ExamineInventory mi}
|
||||
DisplayInventory{_subInventory = ExamineInventory mi}
|
||||
| invKeyDown && rbDown -> w & moveTweakSel yi
|
||||
| invKeyDown -> stopSoundFrom (CrReloadSound 0) $ scrollAugInvSel yi w
|
||||
| rbDown -> w & changeTweakParam mi yi
|
||||
| otherwise -> w & moveTweakSel yi
|
||||
DisplayInventory {_subInventory = CombineInventory {}} -> w & moveCombineSel yi
|
||||
DisplayInventory {_subInventory = DisplayTerminal tmid} -> terminalWheelEvent yi tmid w
|
||||
DisplayInventory{_subInventory = CombineInventory{}} -> w & moveCombineSel yi
|
||||
DisplayInventory{_subInventory = DisplayTerminal tmid} -> terminalWheelEvent yi tmid w
|
||||
_ -> w
|
||||
where
|
||||
y = fromIntegral yi
|
||||
@@ -49,9 +49,11 @@ updateWheelEvent yi w = case w ^. hud . hudElement of
|
||||
invKeyDown = ScancodeCapsLock `M.member` _pressedKeys (_input w)
|
||||
|
||||
moveCombineSel :: Int -> World -> World
|
||||
moveCombineSel yi = (hud . hudElement . subInventory . ciSections
|
||||
%~ scrollSelectionSections yi)
|
||||
. (worldEventFlags . at CombineInventoryChange ?~ ())
|
||||
moveCombineSel yi =
|
||||
( hud . hudElement . subInventory . ciSections
|
||||
%~ scrollSelectionSections yi
|
||||
)
|
||||
. (worldEventFlags . at CombineInventoryChange ?~ ())
|
||||
|
||||
moveSubSel :: Int -> Int -> World -> World
|
||||
moveSubSel yi maxyi =
|
||||
@@ -65,14 +67,14 @@ guardDisconnectedID tmid w w' = case w ^? cWorld . lWorld . terminals . ix tmid
|
||||
|
||||
terminalWheelEvent :: Int -> Int -> World -> World
|
||||
terminalWheelEvent yi tmid w
|
||||
-- | isJust $ w ^? cWorld . lWorld . terminals . ix tmid . tmPartialCommand . _Just = w
|
||||
| rbDown && inTermFocus w =
|
||||
guardDisconnectedID tmid w $
|
||||
w
|
||||
& cWorld . lWorld . terminals . ix tmid %~ updatetermsubsel
|
||||
| inTermFocus w = guardDisconnectedID tmid w $
|
||||
w
|
||||
& cWorld . lWorld . terminals . ix tmid %~ updatetermsel
|
||||
| inTermFocus w =
|
||||
guardDisconnectedID tmid w $
|
||||
w
|
||||
& cWorld . lWorld . terminals . ix tmid %~ updatetermsel
|
||||
| otherwise = w
|
||||
where
|
||||
rbDown = ButtonRight `M.member` _mouseButtons (_input w)
|
||||
@@ -119,14 +121,12 @@ changeTweakParam mi i w = fromMaybe w $ do
|
||||
)
|
||||
|
||||
scrollCommands :: Terminal -> [TerminalCommand]
|
||||
scrollCommands tm = (nullCommand :) $ _tmScrollCommands tm
|
||||
-- | null $ _tmPartialCommand tm = (nullCommand :) $ _tmScrollCommands tm
|
||||
-- | otherwise = [nullCommand]
|
||||
scrollCommands = (nullCommand :) . _tmScrollCommands
|
||||
|
||||
scrollCommandStrings :: World -> Terminal -> [String]
|
||||
scrollCommandStrings w tm = case tm ^? tmPartialCommand . _Just of
|
||||
Nothing -> map _tcString $ scrollCommands tm
|
||||
Just tc -> "": map tail (getArguments tc tm w)
|
||||
Just tc -> "" : map tail (getArguments tc tm w)
|
||||
|
||||
getArguments' :: TerminalCommand -> Terminal -> World -> [String]
|
||||
getArguments' tc tm = ("" :) . getArguments tc tm
|
||||
@@ -143,4 +143,4 @@ nullCommand =
|
||||
getArguments :: TerminalCommand -> Terminal -> World -> [String]
|
||||
getArguments tc tm w = case doTerminalCommandEffect (_tcEffect tc) tm w of
|
||||
NoArguments{} -> []
|
||||
OneArgument _ m -> map (' ':) $ M.keys m
|
||||
OneArgument _ m -> map (' ' :) $ M.keys m
|
||||
|
||||
Reference in New Issue
Block a user