Attempt to simplify text positioning

This commit is contained in:
2023-05-05 02:37:18 +01:00
parent 031af611cd
commit 03c3d34ea1
4 changed files with 16 additions and 15 deletions
+2 -2
View File
@@ -77,7 +77,7 @@ toggleEquipmentAt rbops invid cr w = case rbops ^? opAllocateEquipment of
& crpoint . crEquipment . at newp ?~ invid
& crpoint . crInvEquipped . at invid ?~ newp
& onequip itm cr
& assignNewHotkey invid
& crpoint %~ assignNewHotkey invid
Just MoveEquipment{_allocNewPos = newp, _allocOldPos = oldp} ->
w
& crpoint . crEquipment . at newp ?~ invid
@@ -97,7 +97,7 @@ toggleEquipmentAt rbops invid cr w = case rbops ^? opAllocateEquipment of
& onremove (itmat rid) cr
& onequip itm cr
& crpoint %~ removeHotkey rid
& assignNewHotkey invid
& crpoint %~ assignNewHotkey invid
Just RemoveEquipment{_allocOldPos = oldp} ->
w
& crpoint . crEquipment . at oldp .~ Nothing
+1 -1
View File
@@ -90,7 +90,7 @@ tryAssignHotkey w sc = fromMaybe w $ do
guard (pt == InitialPress)
cr <- w ^? cWorld . lWorld . creatures . ix 0
itid <- cr ^? crManipulation . manObject . inInventory . ispItem
return $ assignHotkey itid (scancodeToHotkey sc) w
return $ w & cWorld . lWorld . creatures . ix 0 %~ assignHotkey itid (scancodeToHotkey sc)
-- | Turn key presses into creature movement.
-- | note the order of operation, setting the posture first--this prevents the twist fire bug
+9 -11
View File
@@ -119,13 +119,14 @@ listCursorChooseBorderScale ::
Picture
listCursorChooseBorderScale ygap s borders xoff yoff cfig yint xint col cursxsize cursysize =
translate
(15 + (9 * s * (fromIntegral xint - 1)) + xoff - halfWidth cfig)
(halfHeight cfig + s * 12.5 - (yoff + (s * 10 + ygap) * (fromIntegral yint + 1)))
--(15 + (9 * s * (fromIntegral xint - 1)) + xoff - halfWidth cfig)
(xoff - halfWidth cfig)
(halfHeight cfig - (yoff + (s * 10 + ygap) * (fromIntegral yint + 1)))
. color col
$ chooseCursorBorders (s * wth) (s * hgt) borders
where
x = 9
wth = x * fromIntegral cursxsize + 9
wth = x * fromIntegral cursxsize + 10
hgt = 20 * fromIntegral cursysize -- TODO this should be changed!
-- displays a cursor that should match up to list text pictures
@@ -137,15 +138,12 @@ listCursorChooseBorder = listCursorChooseBorderScale 10 1
-- note we cannot simply scale lines because they are drawn as solid rectangles
chooseCursorBorders :: Float -> Float -> [CardinalPoint] -> Picture
chooseCursorBorders wth hgt = foldMap (line . toLine)
chooseCursorBorders w h = foldMap (line . toLine)
where
top = 0
bot = - hgt
lef = 0
toLine North = [V2 lef top, V2 wth top]
toLine East = [V2 wth top, V2 wth bot]
toLine South = [V2 wth bot, V2 lef bot]
toLine West = [V2 lef bot, V2 lef top]
toLine North = [V2 0 h, V2 w h]
toLine East = [V2 w h, V2 w 0]
toLine South = [V2 w 0, V2 0 0]
toLine West = [V2 0 0, V2 0 h]
listCursorNS :: Float -> Float -> Configuration -> Int -> Int -> Color -> Int -> Int -> Picture
listCursorNS = listCursorChooseBorder [North, South]
+4 -1
View File
@@ -201,9 +201,12 @@ stackText = mconcat . zipWith (\y s -> translate 0 y $ centerText s) [0, 100 ..]
text :: String -> Picture
{-# INLINE text #-}
text = translate (-50) (-100) . drawText (-10)
--text = translate (-50) (-100) . drawText (-10)
text = drawText 0
--text = drawText (-10)
drawText :: Float -> String -> [Verx]
{-# INLINE drawText #-}
drawText gap = map f . stringToList gap
where
f (pos, col, V3 a b c) = Verx pos col [a, b, c, 1] BottomLayer textNum