Continue inventory refactor
This commit is contained in:
@@ -95,6 +95,8 @@ setInvPosFromSS w =
|
||||
, _imAttachedItems = aset
|
||||
}
|
||||
1 -> Just SelNothing
|
||||
2 -> Just SortNearby
|
||||
3 -> Just $ SelCloseObject j
|
||||
2 -> Just SortCloseItem
|
||||
3 -> Just $ SelCloseItem j
|
||||
4 -> Just SortCloseButton
|
||||
5 -> Just $ SelCloseButton j
|
||||
_ -> error "selection out of bounds"
|
||||
|
||||
@@ -4,8 +4,10 @@ module Dodge.Inventory.SelectionList (
|
||||
invSelectionItem,
|
||||
invSelectionItem',
|
||||
closeItemToSelectionItem,
|
||||
closeButtonToSelectionItem,
|
||||
) where
|
||||
|
||||
import NewInt
|
||||
import Dodge.Data.ComposedItem
|
||||
import Dodge.Data.SelectionList
|
||||
import Dodge.Data.World
|
||||
@@ -51,23 +53,34 @@ hotkeyToString x = case x of
|
||||
Hotkey9 -> "[9]"
|
||||
Hotkey0 -> "[0]"
|
||||
|
||||
closeItemToSelectionItem :: FloorItem -> SelectionItem ()
|
||||
closeItemToSelectionItem e =
|
||||
SelectionItem
|
||||
closeItemToSelectionItem :: World -> NewInt FloorInt -> Maybe (SelectionItem ())
|
||||
closeItemToSelectionItem w (NInt i) = do
|
||||
e <- w ^? cWorld . lWorld . floorItems . unNIntMap . ix i
|
||||
let (pics, col) = closeItemToTextPictures e
|
||||
return SelectionItem
|
||||
{ _siPictures = pics
|
||||
, _siHeight = length pics
|
||||
, _siIsSelectable = True
|
||||
, --, _siWidth = 15
|
||||
_siColor = col
|
||||
, _siColor = col
|
||||
, _siOffX = 0
|
||||
, _siPayload = ()
|
||||
}
|
||||
|
||||
closeButtonToSelectionItem :: World -> Int -> Maybe (SelectionItem ())
|
||||
closeButtonToSelectionItem w i = do
|
||||
bt <- w ^? cWorld . lWorld . buttons . ix i
|
||||
return SelectionItem
|
||||
{ _siPictures = [_btText bt]
|
||||
, _siHeight = 1
|
||||
, _siIsSelectable = True
|
||||
, _siColor = yellow
|
||||
, _siOffX = 0
|
||||
, _siPayload = ()
|
||||
}
|
||||
where
|
||||
(pics, col) = closeItemToTextPictures e
|
||||
|
||||
closeItemToTextPictures :: FloorItem -> ([String], Color)
|
||||
closeItemToTextPictures flit =
|
||||
let it = _flIt flit
|
||||
in (basicItemDisplay it, itemInvColor . pciToCI $ basePCI it)
|
||||
|
||||
-- Right bt -> ([_btText bt], yellow)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user