Refactor close objects hud display

This commit is contained in:
2024-11-24 16:12:35 +00:00
parent e6c2b659fd
commit 81fcfea1be
11 changed files with 205 additions and 220 deletions
-18
View File
@@ -1,18 +0,0 @@
module Dodge.Inventory.CloseObject (
closeObjPos,
closeObjEq,
) where
import Dodge.Data.Button
import Dodge.Data.FloorItem
import Geometry
closeObjPos :: Either FloorItem Button -> Point2
closeObjPos e = case e of
Right x -> _btPos x
Left x -> _flItPos x
closeObjEq :: Either FloorItem Button -> Either FloorItem Button -> Bool
closeObjEq (Right x) (Right y) = _btID x == _btID y
closeObjEq (Left x) (Left y) = _flItID x == _flItID y
closeObjEq _ _ = False
+9 -9
View File
@@ -1,9 +1,9 @@
{-# LANGUAGE LambdaCase #-}
--{-# LANGUAGE LambdaCase #-}
module Dodge.Inventory.SelectionList (
invSelectionItem,
invSelectionItem',
closeObjectToSelectionItem,
closeItemToSelectionItem,
) where
import Dodge.Data.ComposedItem
@@ -51,8 +51,8 @@ hotkeyToString x = case x of
Hotkey9 -> "[9]"
Hotkey0 -> "[0]"
closeObjectToSelectionItem :: Either FloorItem Button -> SelectionItem ()
closeObjectToSelectionItem e =
closeItemToSelectionItem :: FloorItem -> SelectionItem ()
closeItemToSelectionItem e =
SelectionItem
{ _siPictures = pics
, _siHeight = length pics
@@ -63,11 +63,11 @@ closeObjectToSelectionItem e =
, _siPayload = ()
}
where
(pics, col) = closeObjectToTextPictures e
(pics, col) = closeItemToTextPictures e
closeObjectToTextPictures :: Either FloorItem Button -> ([String], Color)
closeObjectToTextPictures = \case
Left flit ->
closeItemToTextPictures :: FloorItem -> ([String], Color)
closeItemToTextPictures flit =
let it = _flIt flit
in (basicItemDisplay it, itemInvColor . pciToCI $ basePCI it)
Right bt -> ([_btText bt], yellow)
-- Right bt -> ([_btText bt], yellow)