Fix equipping bug, select sensible equipment position
This commit is contained in:
+16
-5
@@ -40,9 +40,9 @@ import LensHelp
|
||||
|
||||
--import qualified Data.IntSet as IS
|
||||
import qualified Data.Map.Strict as M
|
||||
import qualified Data.Set as S
|
||||
--import qualified Data.Set as S
|
||||
import Data.Maybe
|
||||
import SDL
|
||||
--import SDL
|
||||
--import Data.List
|
||||
--import System.Random
|
||||
|
||||
@@ -175,10 +175,11 @@ updateCloseObjects w = w & closeObjects .~ unionBy closeObjEq oldCloseFiltered c
|
||||
|
||||
updateRBList :: World -> World
|
||||
updateRBList w
|
||||
| ButtonRight `S.member` _mouseButtons w && w ^? rbOptions . opCurInvPos == Just curinvid
|
||||
| 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
|
||||
| otherwise = case cr ^? crInv . ix (_crInvSel cr) . itUse . eqSite of
|
||||
Just esite -> w
|
||||
& rbOptions .~ EquipOptions (equipSiteToPositions esite) (chooseEquipmentPosition cr (equipSiteToPositions esite)) curinvid DoNotMoveEquipment NoChangeActivateEquipment
|
||||
& setEquipAllocation & setEquipActivation
|
||||
Nothing -> w & rbOptions .~ NoRightButtonOptions
|
||||
| otherwise = w & rbOptions .~ NoRightButtonOptions
|
||||
@@ -186,6 +187,16 @@ updateRBList w
|
||||
curinvid = _crInvSel cr
|
||||
cr = you w
|
||||
|
||||
chooseEquipmentPosition :: Creature -> [EquipPosition] -> Int
|
||||
chooseEquipmentPosition cr eps = fromMaybe (chooseFreeSite cr eps) $ do
|
||||
ep <- cr ^? crInvEquipped . ix (_crInvSel cr)
|
||||
findIndex (==ep) eps
|
||||
|
||||
chooseFreeSite :: Creature -> [EquipPosition] -> Int
|
||||
chooseFreeSite cr = fromMaybe 0 . findIndex hasnoequipment
|
||||
where
|
||||
hasnoequipment ep = isNothing $ cr ^? crEquipment . ix ep
|
||||
|
||||
setEquipAllocation :: World -> World
|
||||
setEquipAllocation w = case _rbOptions w of
|
||||
EquipOptions {_opEquip = es,_opSel=i} ->
|
||||
|
||||
@@ -136,7 +136,9 @@ subInventoryDisplay subinv cfig w = case subinv of
|
||||
-- = 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)
|
||||
rboptions = if ButtonRight `S.member` _mouseButtons w
|
||||
then drawRBOptions cfig w (_rbOptions w)
|
||||
else mempty
|
||||
|
||||
drawRBOptions :: Configuration -> World -> RightButtonOptions -> Picture
|
||||
drawRBOptions cfig w EquipOptions{_opEquip = es,_opSel=i, _opAllocateEquipment=ae} =
|
||||
@@ -225,8 +227,10 @@ topCursorTypeWidth ctype width cfig w i
|
||||
|
||||
determineInvSelCursorWidth :: World -> Int
|
||||
determineInvSelCursorWidth w = case _rbOptions w of
|
||||
NoRightButtonOptions -> topInvW
|
||||
EquipOptions {} -> 47
|
||||
NoRightButtonOptions -> topInvW
|
||||
EquipOptions {} -> if ButtonRight `S.member` _mouseButtons w
|
||||
then 47
|
||||
else topInvW
|
||||
|
||||
--listSelHeight :: Configuration -> World -> Int -> Float
|
||||
--listSelHeight
|
||||
|
||||
Reference in New Issue
Block a user