Allow for selection of equipment position
This commit is contained in:
@@ -12,6 +12,7 @@ module Dodge.Inventory
|
||||
, augmentedInvSizes
|
||||
, rmInvItem
|
||||
, updateCloseObjects
|
||||
, updateRBList
|
||||
, updateTerminal
|
||||
, closeObjScrollDir
|
||||
, closeObjectCol
|
||||
@@ -38,7 +39,10 @@ import ListHelp
|
||||
import LensHelp
|
||||
|
||||
--import qualified Data.IntSet as IS
|
||||
import qualified Data.Map.Strict as M
|
||||
import qualified Data.Set as S
|
||||
import Data.Maybe
|
||||
import SDL
|
||||
--import Data.List
|
||||
--import System.Random
|
||||
|
||||
@@ -169,6 +173,81 @@ updateCloseObjects w = w & closeObjects .~ unionBy closeObjEq oldCloseFiltered c
|
||||
oldClose = filt $ _closeObjects w
|
||||
oldCloseFiltered = intersectBy closeObjEq oldClose currentClose
|
||||
|
||||
updateRBList :: World -> World
|
||||
updateRBList w
|
||||
| ButtonRight `S.member` _mouseButtons w && w ^? rbOptions . opCurInvPos == Just curinvid
|
||||
= w & setEquipAllocation & setEquipActivation
|
||||
| ButtonRight `S.member` _mouseButtons w = case cr ^? crInv . ix (_crInvSel cr) . itUse . eqSite of
|
||||
Just esite -> w & rbOptions .~ EquipOptions (equipSiteToPositions esite) 0 curinvid DoNotMoveEquipment NoChangeActivateEquipment
|
||||
& setEquipAllocation & setEquipActivation
|
||||
Nothing -> w & rbOptions .~ NoRightButtonOptions
|
||||
| otherwise = w & rbOptions .~ NoRightButtonOptions
|
||||
where
|
||||
curinvid = _crInvSel cr
|
||||
cr = you w
|
||||
|
||||
setEquipAllocation :: World -> World
|
||||
setEquipAllocation w = case _rbOptions w of
|
||||
EquipOptions {_opEquip = es,_opSel=i} ->
|
||||
case you w ^? crInvEquipped . ix (_crInvSel (you w)) of
|
||||
Just epos | es !! i == epos
|
||||
-> w & rbOptions . opAllocateEquipment .~ RemoveEquipment
|
||||
{_allocOldPos = epos}
|
||||
Just epos | isJust (you w ^? crEquipment . ix (es !! i))
|
||||
-> w & rbOptions . opAllocateEquipment .~ SwapEquipment
|
||||
{_allocOldPos = epos
|
||||
,_allocNewPos = es !! i
|
||||
,_allocSwapID = _crEquipment (you w) M.! (es !! i)
|
||||
}
|
||||
Just epos -> w & rbOptions . opAllocateEquipment .~ MoveEquipment
|
||||
{_allocOldPos = epos
|
||||
,_allocNewPos = es !! i
|
||||
}
|
||||
Nothing | isJust (you w ^? crEquipment . ix (es !! i))
|
||||
-> w & rbOptions . opAllocateEquipment .~ ReplaceEquipment
|
||||
{_allocNewPos = es !! i
|
||||
,_allocRemoveID = _crEquipment (you w) M.! (es !! i)
|
||||
}
|
||||
Nothing -> w & rbOptions . opAllocateEquipment .~ PutOnEquipment
|
||||
{_allocNewPos = es !! i}
|
||||
_ -> w
|
||||
-- where
|
||||
-- curpos = invSelPos w
|
||||
|
||||
setEquipActivation :: World -> World
|
||||
setEquipActivation w = case w ^? rbOptions . opAllocateEquipment of
|
||||
Just DoNotMoveEquipment -> w
|
||||
Just RemoveEquipment { }
|
||||
-> case _crLeftInvSel (you w) of
|
||||
Just i | i == invsel -> w & rbOptions . opActivateEquipment .~ DeactivateEquipment
|
||||
{_deactivateEquipment = i}
|
||||
_ -> w & rbOptions . opActivateEquipment .~ NoChangeActivateEquipment
|
||||
Just rbos
|
||||
-> case _crLeftInvSel (you w) of
|
||||
Just i | i == invsel -> w & rbOptions . opActivateEquipment .~ NoChangeActivateEquipment
|
||||
Just i | invselcanactivate -> w & rbOptions . opActivateEquipment .~ ActivateDeactivateEquipment
|
||||
{_activateEquipment = invsel,_deactivateEquipment = i}
|
||||
Just i | Just i == rbos ^? allocSwapID || Just i == rbos ^? allocRemoveID
|
||||
-> w & rbOptions . opActivateEquipment .~ DeactivateEquipment i
|
||||
Just _ -> w & rbOptions . opActivateEquipment .~ NoChangeActivateEquipment
|
||||
Nothing | invselcanactivate -> w & rbOptions . opActivateEquipment .~ ActivateEquipment
|
||||
{_activateEquipment = invsel}
|
||||
Nothing -> w & rbOptions . opActivateEquipment .~ NoChangeActivateEquipment
|
||||
Nothing -> w & rbOptions . opActivateEquipment .~ NoChangeActivateEquipment
|
||||
where
|
||||
invsel = _crInvSel (you w)
|
||||
invselcanactivate = isJust (you w ^? crInv . ix invsel . itUse . lUse)
|
||||
|
||||
equipSiteToPositions :: EquipSite -> [EquipPosition]
|
||||
equipSiteToPositions es = case es of
|
||||
GoesOnHead -> [OnHead]
|
||||
GoesOnChest -> [OnChest]
|
||||
GoesOnBack -> [OnBack]
|
||||
GoesOnWrist -> [OnLeftWrist,OnRightWrist]
|
||||
GoesOnLegs -> [OnLegs]
|
||||
GoesOnSpecial -> [OnSpecial]
|
||||
|
||||
|
||||
closeObjScrollDir :: Float -> World -> World
|
||||
closeObjScrollDir x
|
||||
| x > 0 = over closeObjects rotU
|
||||
|
||||
Reference in New Issue
Block a user