Allow for selection of equipment position

This commit is contained in:
2022-05-24 14:03:18 +01:00
parent fa82923a12
commit 7f55ba117f
14 changed files with 221 additions and 37 deletions
+38 -5
View File
@@ -62,8 +62,9 @@ subInventoryDisplay subinv cfig w = case subinv of
NoSubInventory -> pictures
[ selcursor
, closeobjectcursor
, equipcursor
, equipcursors
, equipcursor -- the order is important, this should go on top of the other equipcursors
, rboptions
]
TweakInventory -> pictures
--[ mCurs it cfig w
@@ -126,11 +127,43 @@ subInventoryDisplay subinv cfig w = case subinv of
curpos = invSelPos w
cury = fromMaybe 1 $ augmentedInvSizes w IM.!? _crInvSel (you w)
equipcursor = case _crLeftInvSel cr of
Nothing -> mempty
Just invid -> f' cyan invid
Just invid | _crInvSel cr /= invid || not (ButtonRight `S.member` _mouseButtons w)
-> f cyan invid (_crInvEquipped cr IM.! invid)
_ -> mempty
equipcursors = IM.foldMapWithKey (f yellow) (_crInvEquipped cr)
f' col invid = listTextPictureAt 144 0 cfig (selNumPos invid w) . color col $ text "EQUIPPED"
f col invid epos = listTextPictureAt 144 0 cfig (selNumPos invid w) . color col $ text $ eqPosText epos
f col invid epos
| _crInvSel cr /= invid || not (ButtonRight `S.member` _mouseButtons w)
= listTextPictureAt 144 0 cfig (selNumPos invid w) . color col $ text $ eqPosText epos
| otherwise = mempty
--rboptions = listTextPicturesAtOffset 200 0 cfig (selNumPos invid w) ["TEST","ME"]
rboptions = drawRBOptions cfig w (_rbOptions w)
drawRBOptions :: Configuration -> World -> RightButtonOptions -> Picture
drawRBOptions cfig w EquipOptions{_opEquip = es,_opSel=i, _opAllocateEquipment=ae} =
listTextPicturesAtOffset 252 0 cfig (curpos-i) (map (text . eqPosText) es)
<> case ae of
DoNotMoveEquipment -> mempty
PutOnEquipment {}
-> putontext
MoveEquipment {_allocOldPos = oldp }
-> putontext <> extratext ("MOVES FROM "++eqPosText oldp)
SwapEquipment { _allocOldPos = oldp, _allocSwapID = sid }
-> putontext <> extratext ("SWAPS "++otheritem sid ++ " ONTO " ++eqPosText oldp)
ReplaceEquipment { _allocRemoveID = rid }
-> putontext <> extratext ("REMOVES " ++ otheritem rid)
RemoveEquipment { }
-> takeofftext
where
takeofftext = listTextPictureAt 144 0 cfig curpos (text " TAKE OFF")
putontext = listTextPictureAt 144 0 cfig curpos (text " PUT ONTO")
extratext str = listTextPictureAt 350 0 cfig curpos (text (str ++ deactivatetext))
deactivatetext = case w ^? rbOptions . opActivateEquipment . deactivateEquipment of
Just k -> " DEACTIVATES " ++ _itName (_crInv (you w) IM.! k)
Nothing -> ""
curpos = invSelPos w
otheritem j = _itName (_crInv (you w) IM.! j)
drawRBOptions _ _ _ = mempty
eqPosText :: EquipPosition -> String
eqPosText ep = case ep of