Unify regex/filtering code
This commit is contained in:
@@ -1,38 +1,38 @@
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
|
||||
module Dodge.Inventory.SelectionList (
|
||||
invSelectionItem,
|
||||
invSelectionItem',
|
||||
closeObjectToSelectionItem,
|
||||
) where
|
||||
|
||||
import Dodge.Item.Grammar
|
||||
import Dodge.Data.ComposedItem
|
||||
import Padding
|
||||
import Dodge.Equipment.Text
|
||||
import Dodge.Data.SelectionList
|
||||
import Dodge.Data.World
|
||||
import Dodge.Equipment.Text
|
||||
import Dodge.Item.Display
|
||||
import Dodge.Item.Grammar
|
||||
import Dodge.Item.InventoryColor
|
||||
import LensHelp
|
||||
import Padding
|
||||
import Picture.Base
|
||||
|
||||
invSelectionItem' :: Creature -> Int -> ComposedItem -> SelectionItem ()
|
||||
invSelectionItem' cr i it = invSelectionItem cr i it 0
|
||||
invSelectionItem' = invSelectionItem 0
|
||||
|
||||
invSelectionItem :: Creature -> Int -> ComposedItem -> Int -> SelectionItem ()
|
||||
invSelectionItem cr i ci indent =
|
||||
invSelectionItem :: Int -> Creature -> Int -> ComposedItem -> SelectionItem ()
|
||||
invSelectionItem indent cr i ci =
|
||||
SelectionItem
|
||||
{ _siPictures = pics & ix 0 %~ (++ anyequippos ++ anyhotkey)
|
||||
, _siHeight = _itInvSize itm
|
||||
, _siHeight = _itInvSize $ _cItem ci
|
||||
, _siIsSelectable = True
|
||||
, _siColor = col
|
||||
, _siOffX = indent
|
||||
, _siPayload = ()
|
||||
}
|
||||
where
|
||||
itm = _cItem ci
|
||||
anyhotkey = maybe [] ((' ':) .hotkeyToString) (cr ^? crInvHotkeys . ix i)
|
||||
anyequippos = maybe [] (rightPad 8 ' ' . (' ':) . eqPosText) (cr ^? crInvEquipped . ix i)
|
||||
anyhotkey = maybe [] ((' ' :) . hotkeyToString) (cr ^? crInvHotkeys . ix i)
|
||||
anyequippos = maybe [] (rightPad 8 ' ' . (' ' :) . eqPosText) (cr ^? crInvEquipped . ix i)
|
||||
col = itemInvColor ci
|
||||
pics = itemDisplay cr ci
|
||||
|
||||
@@ -65,8 +65,9 @@ closeObjectToSelectionItem e =
|
||||
where
|
||||
(pics, col) = closeObjectToTextPictures e
|
||||
|
||||
--
|
||||
closeObjectToTextPictures :: Either FloorItem Button -> ([String], Color)
|
||||
closeObjectToTextPictures = \case
|
||||
Left flit -> let it = _flIt flit in (basicItemDisplay it, itemInvColor . pciToCI $ basePCI it)
|
||||
Left flit ->
|
||||
let it = _flIt flit
|
||||
in (basicItemDisplay it, itemInvColor . pciToCI $ basePCI it)
|
||||
Right bt -> ([_btText bt], yellow)
|
||||
|
||||
Reference in New Issue
Block a user