Move hotkeys out of Creature into LWorld
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -56,7 +56,7 @@ data Creature = Creature
|
|||||||
, _crInvLock :: Bool
|
, _crInvLock :: Bool
|
||||||
-- , _crInvEquipped :: IM.IntMap EquipPosition
|
-- , _crInvEquipped :: IM.IntMap EquipPosition
|
||||||
, _crEquipment :: M.Map EquipPosition Int
|
, _crEquipment :: M.Map EquipPosition Int
|
||||||
, _crInvHotkeys :: IM.IntMap Hotkey
|
-- , _crInvHotkeys :: IM.IntMap Hotkey
|
||||||
-- , _crHotkeys :: M.Map Hotkey Int
|
-- , _crHotkeys :: M.Map Hotkey Int
|
||||||
, _crState :: CreatureState
|
, _crState :: CreatureState
|
||||||
, _crCorpse :: CreatureCorpse --Creature -> Corpse -> SPic
|
, _crCorpse :: CreatureCorpse --Creature -> Corpse -> SPic
|
||||||
|
|||||||
@@ -143,6 +143,7 @@ data LWorld = LWorld
|
|||||||
, _lTestString :: [String]
|
, _lTestString :: [String]
|
||||||
, _lTestInt :: Int
|
, _lTestInt :: Int
|
||||||
, _hotkeys :: M.Map Hotkey Int
|
, _hotkeys :: M.Map Hotkey Int
|
||||||
|
, _imHotkeys :: IM.IntMap Hotkey
|
||||||
}
|
}
|
||||||
--data WorldBeams = WorldBeams
|
--data WorldBeams = WorldBeams
|
||||||
-- { _blockingBeams :: [Beam]
|
-- { _blockingBeams :: [Beam]
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ defaultCreature =
|
|||||||
, _crPastDamage = 0
|
, _crPastDamage = 0
|
||||||
-- , _crInvEquipped = mempty
|
-- , _crInvEquipped = mempty
|
||||||
, _crEquipment = M.empty
|
, _crEquipment = M.empty
|
||||||
, _crInvHotkeys = mempty
|
-- , _crInvHotkeys = mempty
|
||||||
-- , _crHotkeys = M.empty
|
-- , _crHotkeys = M.empty
|
||||||
, _crStance =
|
, _crStance =
|
||||||
Stance
|
Stance
|
||||||
|
|||||||
@@ -149,6 +149,7 @@ defaultLWorld =
|
|||||||
, _lTestString = []
|
, _lTestString = []
|
||||||
, _lTestInt = 0
|
, _lTestInt = 0
|
||||||
, _hotkeys = mempty
|
, _hotkeys = mempty
|
||||||
|
, _imHotkeys = mempty
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultHUD :: HUD
|
defaultHUD :: HUD
|
||||||
|
|||||||
@@ -181,7 +181,8 @@ updateDisplaySections w cfig =
|
|||||||
mapMaybe (closeItemToSelectionItem w) (w ^. hud . closeItems)
|
mapMaybe (closeItemToSelectionItem w) (w ^. hud . closeItems)
|
||||||
invitems =
|
invitems =
|
||||||
IM.mapWithKey
|
IM.mapWithKey
|
||||||
(\k (indent, x) -> invSelectionItem indent cr k (x ^. locLDT . ldtValue))
|
(\k (indent, x) -> invSelectionItem indent (w ^. cWorld . lWorld)
|
||||||
|
k (x ^. locLDT . ldtValue))
|
||||||
(fmap (first removeindentiffiltering) . allInvLocs $ _crInv cr)
|
(fmap (first removeindentiffiltering) . allInvLocs $ _crInv cr)
|
||||||
removeindentiffiltering =
|
removeindentiffiltering =
|
||||||
if maybe False (not . null) (w ^? hud . hudElement . diInvFilter . _Just)
|
if maybe False (not . null) (w ^? hud . hudElement . diInvFilter . _Just)
|
||||||
|
|||||||
+4
-4
@@ -41,16 +41,16 @@ assignHotkey invid hk lw = fromMaybe lw $ do
|
|||||||
|
|
||||||
moveOldHotkey :: Int -> Hotkey -> LWorld -> LWorld
|
moveOldHotkey :: Int -> Hotkey -> LWorld -> LWorld
|
||||||
moveOldHotkey invid hk w = fromMaybe w $ do
|
moveOldHotkey invid hk w = fromMaybe w $ do
|
||||||
oldhk <- w ^? creatures . ix 0 . crInvHotkeys . ix invid
|
oldhk <- w ^? imHotkeys . ix invid
|
||||||
oldid <- w ^? hotkeys . ix hk
|
oldid <- w ^? hotkeys . ix hk
|
||||||
return $ w & setHotkey oldid oldhk
|
return $ w & setHotkey oldid oldhk
|
||||||
|
|
||||||
setHotkey :: Int -> Hotkey -> LWorld -> LWorld
|
setHotkey :: Int -> Hotkey -> LWorld -> LWorld
|
||||||
setHotkey i hk = (creatures . ix 0 . crInvHotkeys . at i ?~ hk) . (hotkeys . at hk ?~ i)
|
setHotkey i hk = (imHotkeys . at i ?~ hk) . (hotkeys . at hk ?~ i)
|
||||||
|
|
||||||
removeHotkey :: Int -> LWorld -> LWorld
|
removeHotkey :: Int -> LWorld -> LWorld
|
||||||
removeHotkey invid w = w & creatures . ix 0 . crInvHotkeys . at invid .~ Nothing
|
removeHotkey invid w = w & imHotkeys . at invid .~ Nothing
|
||||||
& fromMaybe id (do
|
& fromMaybe id (do
|
||||||
hk <- w ^? creatures . ix 0 . crInvHotkeys . ix invid
|
hk <- w ^? imHotkeys . ix invid
|
||||||
return (hotkeys . at hk .~ Nothing)
|
return (hotkeys . at hk .~ Nothing)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -71,8 +71,8 @@ rmInvItem cid invid w =
|
|||||||
& removeanyactivation
|
& removeanyactivation
|
||||||
-- & pointcid . crHotkeys . each %~ g
|
-- & pointcid . crHotkeys . each %~ g
|
||||||
& cWorld . lWorld . hotkeys . each %~ g
|
& cWorld . lWorld . hotkeys . each %~ g
|
||||||
& pointcid . crInvHotkeys %~ IM.delete invid
|
& cWorld . lWorld . imHotkeys %~ IM.delete invid
|
||||||
& pointcid . crInvHotkeys %~ IM.mapKeys g
|
& cWorld . lWorld . imHotkeys %~ IM.mapKeys g
|
||||||
& updateselection
|
& updateselection
|
||||||
& updateselectionextra
|
& updateselectionextra
|
||||||
& pointcid %~ updateRootItemID
|
& pointcid %~ updateRootItemID
|
||||||
@@ -101,7 +101,7 @@ rmInvItem cid invid w =
|
|||||||
. itLocation . ilEquipPosition . _Just
|
. itLocation . ilEquipPosition . _Just
|
||||||
return $ pointcid . crEquipment . at epos .~ Nothing
|
return $ pointcid . crEquipment . at epos .~ Nothing
|
||||||
removeanyactivation = fromMaybe id $ do
|
removeanyactivation = fromMaybe id $ do
|
||||||
epos <- w ^? cWorld . lWorld . creatures . ix cid . crInvHotkeys . ix invid
|
epos <- w ^? cWorld . lWorld . imHotkeys . ix invid
|
||||||
--return $ pointcid . crHotkeys . at epos .~ Nothing
|
--return $ pointcid . crHotkeys . at epos .~ Nothing
|
||||||
return $ cWorld . lWorld . hotkeys . at epos .~ Nothing
|
return $ cWorld . lWorld . hotkeys . at epos .~ Nothing
|
||||||
maxk = fmap fst $ IM.lookupMax $ cr ^. crInv
|
maxk = fmap fst $ IM.lookupMax $ cr ^. crInv
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ import NewInt
|
|||||||
import Padding
|
import Padding
|
||||||
import Picture.Base
|
import Picture.Base
|
||||||
|
|
||||||
invSelectionItem :: Int -> Creature -> Int -> ComposedItem -> SelectionItem ()
|
invSelectionItem :: Int -> LWorld -> Int -> ComposedItem -> SelectionItem ()
|
||||||
invSelectionItem indent cr i ci =
|
invSelectionItem indent lw i ci =
|
||||||
SelectionItem
|
SelectionItem
|
||||||
{ _siPictures = pics & ix 0 %~ (++ anyequippos ++ anyhotkey)
|
{ _siPictures = pics & ix 0 %~ (++ anyequippos ++ anyhotkey)
|
||||||
, _siHeight = itInvHeight $ ci ^. _1
|
, _siHeight = itInvHeight $ ci ^. _1
|
||||||
@@ -31,7 +31,8 @@ invSelectionItem indent cr i ci =
|
|||||||
, _siPayload = ()
|
, _siPayload = ()
|
||||||
}
|
}
|
||||||
where
|
where
|
||||||
anyhotkey = maybe [] ((' ' :) . hotkeyToString) (cr ^? crInvHotkeys . ix i)
|
cr = lw ^?! creatures . ix 0
|
||||||
|
anyhotkey = maybe [] ((' ' :) . hotkeyToString) (lw ^? imHotkeys . ix i)
|
||||||
anyequippos = maybe [] (rightPad 8 ' ' . (' ' :) . eqPosText)
|
anyequippos = maybe [] (rightPad 8 ' ' . (' ' :) . eqPosText)
|
||||||
(ci ^? _1 . itLocation . ilEquipPosition . _Just)
|
(ci ^? _1 . itLocation . ilEquipPosition . _Just)
|
||||||
col = itemInvColor ci
|
col = itemInvColor ci
|
||||||
|
|||||||
@@ -58,17 +58,18 @@ swapInvItems f i w = fromMaybe w $ do
|
|||||||
-- . (crInvEquipped %~ IM.safeSwapKeys i k)
|
-- . (crInvEquipped %~ IM.safeSwapKeys i k)
|
||||||
. swapSite i k
|
. swapSite i k
|
||||||
. swapSite k i
|
. swapSite k i
|
||||||
. (crInvHotkeys %~ IM.safeSwapKeys i k)
|
-- . (crInvHotkeys %~ IM.safeSwapKeys i k)
|
||||||
swaphotkeys k =
|
swaphotkeys k =
|
||||||
swapSite' i k
|
swapSite' i k
|
||||||
. swapSite' k i
|
. swapSite' k i
|
||||||
|
. (cWorld . lWorld . imHotkeys %~ IM.safeSwapKeys i k)
|
||||||
cr = you w
|
cr = you w
|
||||||
--swapSite a b = case cr ^? crInvEquipped . ix a of
|
--swapSite a b = case cr ^? crInvEquipped . ix a of
|
||||||
swapSite a b = case cr ^? crInv . ix a . itLocation . ilEquipPosition . _Just of
|
swapSite a b = case cr ^? crInv . ix a . itLocation . ilEquipPosition . _Just of
|
||||||
Just epos -> crEquipment . ix epos .~ b
|
Just epos -> crEquipment . ix epos .~ b
|
||||||
Nothing -> id
|
Nothing -> id
|
||||||
--swapSite' a b = case cr ^? crInvHotkeys . ix a of
|
--swapSite' a b = case cr ^? crInvHotkeys . ix a of
|
||||||
swapSite' a b = case w ^? cWorld . lWorld . creatures . ix 0 . crInvHotkeys . ix a of
|
swapSite' a b = case w ^? cWorld . lWorld . imHotkeys . ix a of
|
||||||
Just epos -> cWorld . lWorld . hotkeys . ix epos .~ b
|
Just epos -> cWorld . lWorld . hotkeys . ix epos .~ b
|
||||||
Nothing -> id
|
Nothing -> id
|
||||||
|
|
||||||
|
|||||||
@@ -52,10 +52,10 @@ chargeIfInInventory itm cr w =
|
|||||||
maxcharge = itm ^?! itUse . leftConsumption . wpMaxCharge
|
maxcharge = itm ^?! itUse . leftConsumption . wpMaxCharge
|
||||||
|
|
||||||
chargeIfEquipped :: Item -> Creature -> World -> World
|
chargeIfEquipped :: Item -> Creature -> World -> World
|
||||||
chargeIfEquipped itm cr
|
chargeIfEquipped itm cr w
|
||||||
| invid `IM.member` (cr ^. crInvHotkeys) =
|
| invid `IM.member` (w ^. cWorld . lWorld . imHotkeys) = w &
|
||||||
ptrWpCharge %~ (min maxcharge . (+ 1))
|
ptrWpCharge %~ (min maxcharge . (+ 1))
|
||||||
| otherwise = ptrWpCharge .~ 0
|
| otherwise = w & ptrWpCharge .~ 0
|
||||||
where
|
where
|
||||||
invid = _ilInvID $ _itLocation itm
|
invid = _ilInvID $ _itLocation itm
|
||||||
ptrWpCharge = cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix invid . itUse . leftConsumption . wpCharge
|
ptrWpCharge = cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix invid . itUse . leftConsumption . wpCharge
|
||||||
|
|||||||
Reference in New Issue
Block a user