Commit before making hotkeys attach to item ids, not inv ids
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -312,6 +312,9 @@ stackedInventory =
|
|||||||
, megaShellMag
|
, megaShellMag
|
||||||
, burstRifle
|
, burstRifle
|
||||||
, megaTinMag 100
|
, megaTinMag 100
|
||||||
|
, underBarrelSlot
|
||||||
|
, gLauncher
|
||||||
|
, megaShellMag
|
||||||
, laser
|
, laser
|
||||||
, makeTypeCraft TRANSFORMER
|
, makeTypeCraft TRANSFORMER
|
||||||
, teslaGun
|
, teslaGun
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import Dodge.Data.World
|
|||||||
import Dodge.DoubleTree
|
import Dodge.DoubleTree
|
||||||
import Dodge.Euse
|
import Dodge.Euse
|
||||||
import Dodge.HeldUse
|
import Dodge.HeldUse
|
||||||
import Dodge.Hotkey
|
--import Dodge.Hotkey
|
||||||
import Dodge.Inventory
|
import Dodge.Inventory
|
||||||
import Dodge.Item.Grammar
|
import Dodge.Item.Grammar
|
||||||
import Dodge.Item.Location
|
import Dodge.Item.Location
|
||||||
@@ -71,7 +71,7 @@ toggleEquipmentAt invid cr w = case getEquipmentAllocation w of
|
|||||||
& crpoint . crEquipment . at newp ?~ invid
|
& crpoint . crEquipment . at newp ?~ invid
|
||||||
& crpoint . crInv . ix invid . itLocation . ilEquipSite ?~ newp
|
& crpoint . crInv . ix invid . itLocation . ilEquipSite ?~ newp
|
||||||
& onequip itm cr
|
& onequip itm cr
|
||||||
& cWorld . lWorld %~ assignNewHotkey invid
|
-- & cWorld . lWorld %~ assignNewHotkey invid
|
||||||
MoveEquipment{_allocNewPos = newp, _allocOldPos = oldp} ->
|
MoveEquipment{_allocNewPos = newp, _allocOldPos = oldp} ->
|
||||||
w
|
w
|
||||||
& crpoint . crEquipment . at newp ?~ invid
|
& crpoint . crEquipment . at newp ?~ invid
|
||||||
@@ -90,14 +90,14 @@ toggleEquipmentAt invid cr w = case getEquipmentAllocation w of
|
|||||||
& crpoint . crInv . ix rid . itLocation . ilEquipSite .~ Nothing
|
& crpoint . crInv . ix rid . itLocation . ilEquipSite .~ Nothing
|
||||||
& onremove (itmat rid) cr
|
& onremove (itmat rid) cr
|
||||||
& onequip itm cr
|
& onequip itm cr
|
||||||
& cWorld . lWorld %~ removeHotkey rid
|
-- & cWorld . lWorld %~ removeHotkey rid
|
||||||
& cWorld . lWorld %~ assignNewHotkey invid
|
-- & cWorld . lWorld %~ assignNewHotkey invid
|
||||||
RemoveEquipment{_allocOldPos = oldp} ->
|
RemoveEquipment{_allocOldPos = oldp} ->
|
||||||
w
|
w
|
||||||
& crpoint . crEquipment . at oldp .~ Nothing
|
& crpoint . crEquipment . at oldp .~ Nothing
|
||||||
& crpoint . crInv . ix invid . itLocation . ilEquipSite .~ Nothing
|
& crpoint . crInv . ix invid . itLocation . ilEquipSite .~ Nothing
|
||||||
& onremove itm cr
|
& onremove itm cr
|
||||||
& cWorld . lWorld %~ removeHotkey invid
|
-- & cWorld . lWorld %~ removeHotkey invid
|
||||||
where
|
where
|
||||||
crpoint = cWorld . lWorld . creatures . ix (_crID cr)
|
crpoint = cWorld . lWorld . creatures . ix (_crID cr)
|
||||||
itmat i = _crInv cr IM.! i
|
itmat i = _crInv cr IM.! i
|
||||||
|
|||||||
@@ -30,11 +30,15 @@ data ComposeLinkType
|
|||||||
| FunctionChangeLink
|
| FunctionChangeLink
|
||||||
| MakeAutoLink
|
| MakeAutoLink
|
||||||
| ProjectileStabiliserLink
|
| ProjectileStabiliserLink
|
||||||
|
| UnderBarrelSlotLink
|
||||||
|
| UnderBarrelPlatformLink
|
||||||
deriving (Eq, Ord, Show, Read)
|
deriving (Eq, Ord, Show, Read)
|
||||||
|
|
||||||
data ItemStructuralFunction
|
data ItemStructuralFunction
|
||||||
= UnloadedWeaponSF
|
= UnloadedWeaponSF
|
||||||
| HeldPlatformSF
|
| HeldPlatformSF
|
||||||
|
| UnderBarrelSlotSF
|
||||||
|
| UnderBarrelPlatformSF
|
||||||
| EquipmentPlatformSF
|
| EquipmentPlatformSF
|
||||||
| GadgetPlatformSF
|
| GadgetPlatformSF
|
||||||
| WeaponScopeSF
|
| WeaponScopeSF
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ data AttachType
|
|||||||
| JOYSTICK
|
| JOYSTICK
|
||||||
| GIMBAL
|
| GIMBAL
|
||||||
| GYROSCOPE
|
| GYROSCOPE
|
||||||
|
| UNDERBARRELSLOT
|
||||||
| REMOTEDETONATOR
|
| REMOTEDETONATOR
|
||||||
| SMOKEREDUCER
|
| SMOKEREDUCER
|
||||||
| HOMINGMODULE
|
| HOMINGMODULE
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ data UseFocus
|
|||||||
deriving (Eq, Show, Read)
|
deriving (Eq, Show, Read)
|
||||||
|
|
||||||
data UseCondition
|
data UseCondition
|
||||||
= MustBeHeld
|
= UseableWhenAimed
|
||||||
| UseableAnytime
|
| UseableAnytime
|
||||||
deriving (Eq, Show, Read)
|
deriving (Eq, Show, Read)
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ defaultHeldItem =
|
|||||||
, _itLocation = InVoid
|
, _itLocation = InVoid
|
||||||
, _itUse = defaultHeldUse
|
, _itUse = defaultHeldUse
|
||||||
, _itParams = NoParams
|
, _itParams = NoParams
|
||||||
, _itUseCondition = MustBeHeld
|
, _itUseCondition = UseableWhenAimed
|
||||||
}
|
}
|
||||||
|
|
||||||
--defaultLeftItem :: Item
|
--defaultLeftItem :: Item
|
||||||
|
|||||||
+16
-13
@@ -1,31 +1,34 @@
|
|||||||
module Dodge.Hotkey (
|
module Dodge.Hotkey (
|
||||||
assignHotkey,
|
assignHotkey,
|
||||||
assignNewHotkey,
|
-- assignNewHotkey,
|
||||||
removeHotkey,
|
removeHotkey,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import Data.List
|
--import Data.List
|
||||||
import qualified Data.Map.Strict as M
|
--import qualified Data.Map.Strict as M
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import Dodge.Data.World
|
import Dodge.Data.World
|
||||||
import Control.Monad
|
--import Control.Monad
|
||||||
|
|
||||||
assignNewHotkey :: Int -> LWorld -> LWorld
|
--assignNewHotkey :: Int -> LWorld -> LWorld
|
||||||
assignNewHotkey invid w = assignHotkey invid (newHotkey w) w
|
--assignNewHotkey invid w = assignHotkey invid (newHotkey w) w
|
||||||
|
--
|
||||||
|
--newHotkey :: LWorld -> Hotkey
|
||||||
|
--newHotkey lw = fromMaybe maxBound $
|
||||||
|
-- find
|
||||||
|
-- (not . (`M.member` (lw ^. hotkeys)))
|
||||||
|
-- [minBound .. maxBound]
|
||||||
|
|
||||||
newHotkey :: LWorld -> Hotkey
|
-- it is not obvious to me whether hotkeys should belong to LWorld, CWorld or
|
||||||
newHotkey lw = fromMaybe maxBound $
|
-- World
|
||||||
find
|
|
||||||
(not . (`M.member` (lw ^. hotkeys)))
|
|
||||||
[minBound .. maxBound]
|
|
||||||
|
|
||||||
-- this will not remove the hotkey from its old slot, assumes there is a hotkey
|
-- this will not remove the hotkey from its old slot, assumes there is a hotkey
|
||||||
-- to swap with instead
|
-- to swap with instead
|
||||||
assignHotkey :: Int -> Hotkey -> LWorld -> LWorld
|
assignHotkey :: Int -> Hotkey -> LWorld -> LWorld
|
||||||
assignHotkey invid hk lw = fromMaybe lw $ do
|
assignHotkey invid hk lw = fromMaybe lw $ do
|
||||||
guard $ lw ^? creatures . ix 0 . crInv . ix invid . itUseCondition
|
-- guard $ lw ^? creatures . ix 0 . crInv . ix invid . itUseCondition
|
||||||
== Just UseableAnytime
|
-- == Just UseableAnytime
|
||||||
return $ (setHotkey invid hk . moveOldHotkey invid hk) lw
|
return $ (setHotkey invid hk . moveOldHotkey invid hk) lw
|
||||||
|
|
||||||
moveOldHotkey :: Int -> Hotkey -> LWorld -> LWorld
|
moveOldHotkey :: Int -> Hotkey -> LWorld -> LWorld
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ itemFromAmmoMag at = case at of
|
|||||||
|
|
||||||
itemFromAttachType :: AttachType -> Item
|
itemFromAttachType :: AttachType -> Item
|
||||||
itemFromAttachType at = case at of
|
itemFromAttachType at = case at of
|
||||||
|
UNDERBARRELSLOT -> underBarrelSlot
|
||||||
ZOOMSCOPE -> zoomScope
|
ZOOMSCOPE -> zoomScope
|
||||||
BULLETSYNTH -> bulletSynthesizer
|
BULLETSYNTH -> bulletSynthesizer
|
||||||
REMOTESCREEN -> remoteScreen
|
REMOTESCREEN -> remoteScreen
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ itemBaseName = \case
|
|||||||
|
|
||||||
showAttachItem :: AttachType -> String
|
showAttachItem :: AttachType -> String
|
||||||
showAttachItem t = case t of
|
showAttachItem t = case t of
|
||||||
|
UNDERBARRELSLOT -> "UNDERBARRELSLOT"
|
||||||
ZOOMSCOPE -> "ZOOMSCOPE"
|
ZOOMSCOPE -> "ZOOMSCOPE"
|
||||||
BULLETSYNTH -> "BSYNTH"
|
BULLETSYNTH -> "BSYNTH"
|
||||||
REMOTESCREEN -> "REM.SCREEN"
|
REMOTESCREEN -> "REM.SCREEN"
|
||||||
|
|||||||
@@ -62,8 +62,12 @@ itemToBreakLists ::
|
|||||||
([(ItemStructuralFunction, ComposeLinkType)], [(ItemStructuralFunction, ComposeLinkType)])
|
([(ItemStructuralFunction, ComposeLinkType)], [(ItemStructuralFunction, ComposeLinkType)])
|
||||||
itemToBreakLists itm itmf = case (itm ^. itType, itmf) of
|
itemToBreakLists itm itmf = case (itm ^. itType, itmf) of
|
||||||
(HELD TORCH, _) -> (getAmmoLinks itm, [])
|
(HELD TORCH, _) -> (getAmmoLinks itm, [])
|
||||||
|
(ATTACH UNDERBARRELSLOT, _) -> ([(UnderBarrelPlatformSF, UnderBarrelPlatformLink)], [])
|
||||||
(_, HeldPlatformSF) ->
|
(_, HeldPlatformSF) ->
|
||||||
( getAmmoLinks itm
|
( getAmmoLinks itm
|
||||||
|
<> extraWeaponLinksBelow itm
|
||||||
|
--( extraWeaponLinksBelow itm
|
||||||
|
-- <>getAmmoLinks itm
|
||||||
, [(WeaponTargetingSF, WeaponTargetingLink), (WeaponScopeSF, WeaponScopeLink)]
|
, [(WeaponTargetingSF, WeaponTargetingLink), (WeaponScopeSF, WeaponScopeLink)]
|
||||||
<> getAutoSpringLinks itm
|
<> getAutoSpringLinks itm
|
||||||
<> extraWeaponLinks itm
|
<> extraWeaponLinks itm
|
||||||
@@ -113,6 +117,12 @@ extraWeaponLinks itm = case itm ^. itType of
|
|||||||
where
|
where
|
||||||
launcherlinks = [(ProjectileStabiliserSF,ProjectileStabiliserLink)]
|
launcherlinks = [(ProjectileStabiliserSF,ProjectileStabiliserLink)]
|
||||||
|
|
||||||
|
extraWeaponLinksBelow :: Item -> [(ItemStructuralFunction, ComposeLinkType)]
|
||||||
|
extraWeaponLinksBelow itm
|
||||||
|
| Just TwoHandUnder <- itm ^? itUse . heldAim . aimStance
|
||||||
|
= [(UnderBarrelSlotSF,UnderBarrelSlotLink)]
|
||||||
|
| otherwise = []
|
||||||
|
|
||||||
getAmmoLinks :: Item -> [(ItemStructuralFunction, ComposeLinkType)]
|
getAmmoLinks :: Item -> [(ItemStructuralFunction, ComposeLinkType)]
|
||||||
getAmmoLinks itm =
|
getAmmoLinks itm =
|
||||||
map
|
map
|
||||||
@@ -123,7 +133,7 @@ itemToFunction :: Item -> ItemStructuralFunction
|
|||||||
itemToFunction itm = case itm ^. itType of
|
itemToFunction itm = case itm ^. itType of
|
||||||
HELD LASER -> WeaponTargetingSF
|
HELD LASER -> WeaponTargetingSF
|
||||||
HELD{} -> case itm ^? itUseCondition of
|
HELD{} -> case itm ^? itUseCondition of
|
||||||
Just MustBeHeld -> HeldPlatformSF
|
Just UseableWhenAimed -> HeldPlatformSF
|
||||||
--Just MustBeHeld -> UnloadedWeaponSF
|
--Just MustBeHeld -> UnloadedWeaponSF
|
||||||
_ -> GadgetPlatformSF
|
_ -> GadgetPlatformSF
|
||||||
_
|
_
|
||||||
@@ -139,7 +149,7 @@ itemToFunction itm = case itm ^. itType of
|
|||||||
ATTACH ZOOMSCOPE -> WeaponScopeSF
|
ATTACH ZOOMSCOPE -> WeaponScopeSF
|
||||||
ATTACH HOMINGMODULE -> AmmoTargetingSF LauncherAmmo
|
ATTACH HOMINGMODULE -> AmmoTargetingSF LauncherAmmo
|
||||||
ATTACH AUGMENTEDHUD -> AugmentedHUDSF
|
ATTACH AUGMENTEDHUD -> AugmentedHUDSF
|
||||||
-- BULLETMOD BulletModTrajectory{} -> AmmoTargetingSF BulletAmmo
|
ATTACH UNDERBARRELSLOT -> UnderBarrelSlotSF
|
||||||
BULLETMOD BulletModPayload{} -> AmmoPayloadSF BulletAmmo
|
BULLETMOD BulletModPayload{} -> AmmoPayloadSF BulletAmmo
|
||||||
BULLETMOD BulletModEffect{} -> AmmoEffectSF BulletAmmo
|
BULLETMOD BulletModEffect{} -> AmmoEffectSF BulletAmmo
|
||||||
TARGETING{} -> WeaponTargetingSF
|
TARGETING{} -> WeaponTargetingSF
|
||||||
@@ -154,6 +164,7 @@ structureToPotentialFunction ::
|
|||||||
structureToPotentialFunction ldt = case ldt ^. ldtValue . _1 . itType of
|
structureToPotentialFunction ldt = case ldt ^. ldtValue . _1 . itType of
|
||||||
ATTACH GIMBAL -> S.singleton ProjectileStabiliserSF
|
ATTACH GIMBAL -> S.singleton ProjectileStabiliserSF
|
||||||
ATTACH GYROSCOPE -> S.singleton ProjectileStabiliserSF
|
ATTACH GYROSCOPE -> S.singleton ProjectileStabiliserSF
|
||||||
|
HELD GLAUNCHER -> S.singleton UnderBarrelPlatformSF
|
||||||
_ -> S.singleton (ldt ^. ldtValue . _2)
|
_ -> S.singleton (ldt ^. ldtValue . _2)
|
||||||
|
|
||||||
baseCI :: Item -> ComposedItem
|
baseCI :: Item -> ComposedItem
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ itemInvColor ci = case ci ^. _2 of
|
|||||||
AmmoEffectSF{} -> aquamarine
|
AmmoEffectSF{} -> aquamarine
|
||||||
FunctionChangeSF -> yellow
|
FunctionChangeSF -> yellow
|
||||||
ProjectileStabiliserSF -> white
|
ProjectileStabiliserSF -> white
|
||||||
|
UnderBarrelPlatformSF -> white
|
||||||
|
UnderBarrelSlotSF -> white
|
||||||
|
|
||||||
--ammoTypeColor :: AmmoType -> Color
|
--ammoTypeColor :: AmmoType -> Color
|
||||||
--ammoTypeColor = \case
|
--ammoTypeColor = \case
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
module Dodge.Item.Scope (
|
module Dodge.Item.Scope (
|
||||||
|
underBarrelSlot,
|
||||||
gimbal,
|
gimbal,
|
||||||
gyroscope,
|
gyroscope,
|
||||||
stickyMod,
|
stickyMod,
|
||||||
@@ -84,5 +85,8 @@ gimbal = makeAttach GIMBAL
|
|||||||
gyroscope :: Item
|
gyroscope :: Item
|
||||||
gyroscope = makeAttach GYROSCOPE
|
gyroscope = makeAttach GYROSCOPE
|
||||||
|
|
||||||
|
underBarrelSlot :: Item
|
||||||
|
underBarrelSlot = makeAttach UNDERBARRELSLOT
|
||||||
|
|
||||||
smokeReducer :: Item
|
smokeReducer :: Item
|
||||||
smokeReducer = makeAttach SMOKEREDUCER
|
smokeReducer = makeAttach SMOKEREDUCER
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import Dodge.Creature.Test
|
|||||||
import Dodge.Data.Config
|
import Dodge.Data.Config
|
||||||
import Dodge.Data.World
|
import Dodge.Data.World
|
||||||
--import Dodge.Equipment
|
--import Dodge.Equipment
|
||||||
import Dodge.InputFocus
|
--import Dodge.InputFocus
|
||||||
import Dodge.SmoothScroll
|
import Dodge.SmoothScroll
|
||||||
import Dodge.Viewpoints
|
import Dodge.Viewpoints
|
||||||
import Dodge.WASD
|
import Dodge.WASD
|
||||||
@@ -24,7 +24,7 @@ import Geometry
|
|||||||
--import qualified IntMapHelp as IM
|
--import qualified IntMapHelp as IM
|
||||||
import LensHelp
|
import LensHelp
|
||||||
import SDL (MouseButton (..))
|
import SDL (MouseButton (..))
|
||||||
import qualified SDL
|
--import qualified SDL
|
||||||
|
|
||||||
{- Update the screen camera rotation and position, including any in rold scope/remote camera modifiers;
|
{- Update the screen camera rotation and position, including any in rold scope/remote camera modifiers;
|
||||||
update where your avatar's view is from. -}
|
update where your avatar's view is from. -}
|
||||||
@@ -157,17 +157,17 @@ doWallRotate wl w = rotateUsing $ (argV . uncurry (-.-) $ _wlLine wl) - (w ^. wC
|
|||||||
b = a * (4 / pi)
|
b = a * (4 / pi)
|
||||||
b' = fromIntegral (round b :: Int)
|
b' = fromIntegral (round b :: Int)
|
||||||
|
|
||||||
rotateCameraBy :: Float -> World -> World
|
--rotateCameraBy :: Float -> World -> World
|
||||||
rotateCameraBy x = wCam . camRot +~ x
|
--rotateCameraBy x = wCam . camRot +~ x
|
||||||
|
|
||||||
rotateCamera :: Configuration -> World -> World
|
rotateCamera :: Configuration -> World -> World
|
||||||
rotateCamera cfig w
|
rotateCamera cfig w
|
||||||
| keydown SDL.ScancodeQ && keydown SDL.ScancodeE = w
|
-- | keydown SDL.ScancodeQ && keydown SDL.ScancodeE = w
|
||||||
| keydown SDL.ScancodeQ = rotateCameraBy 0.025 w
|
-- | keydown SDL.ScancodeQ = rotateCameraBy 0.025 w
|
||||||
| keydown SDL.ScancodeE = rotateCameraBy (-0.025) w
|
-- | keydown SDL.ScancodeE = rotateCameraBy (-0.025) w
|
||||||
| otherwise = ifConfigWallRotate cfig (w ^. input . mouseButtons) w
|
| otherwise = ifConfigWallRotate cfig (w ^. input . mouseButtons) w
|
||||||
where
|
-- where
|
||||||
keydown scode = scode `M.member` _pressedKeys (_input w) && not (inTextInputFocus w)
|
-- keydown scode = scode `M.member` _pressedKeys (_input w) && not (inTextInputFocus w)
|
||||||
|
|
||||||
zoomFromItem :: ItZoom -> Float
|
zoomFromItem :: ItZoom -> Float
|
||||||
zoomFromItem ItZoom{_izMax = zMax, _izMin = zMin, _izFac = zFac} =
|
zoomFromItem ItZoom{_izMax = zMax, _izMin = zMin, _izFac = zFac} =
|
||||||
|
|||||||
Reference in New Issue
Block a user