Cleanup
This commit is contained in:
@@ -308,15 +308,14 @@ updateSection indent mcsel sis availablelines oldoffset =
|
||||
SelectionSection
|
||||
{ _ssItems = sis
|
||||
, _ssOffset = offset
|
||||
, _ssShownItems = tweakfirst shownitems
|
||||
-- , _ssShownItems = tweakfirst shownitems
|
||||
, _ssShownItems = tweakfirst . tweaklast . map snd
|
||||
$ take availablelines shownstrings
|
||||
, _ssIndent = indent
|
||||
}
|
||||
where
|
||||
nocursoroffset =
|
||||
if length allstrings - oldoffset <= availablelines
|
||||
then max 0 (length allstrings - availablelines)
|
||||
else oldoffset
|
||||
offset = fromMaybe nocursoroffset $ do
|
||||
oldoffsetbounded = max 0 . min oldoffset $ length allstrings - availablelines
|
||||
offset = fromMaybe oldoffsetbounded $ do
|
||||
csel <- mcsel
|
||||
maxcsel <- fst <$> IM.lookupMax sis
|
||||
si <- sis ^? ix csel
|
||||
@@ -331,19 +330,26 @@ updateSection indent mcsel sis availablelines oldoffset =
|
||||
_
|
||||
| length allstrings - oldoffset < availablelines ->
|
||||
length allstrings - availablelines
|
||||
_ -> oldoffset
|
||||
tweakfirst (x : xs)
|
||||
| offset > 0 =
|
||||
color moreupcolor (text (replicate 15 (toEnum 30))) :
|
||||
xs
|
||||
| otherwise = x : xs
|
||||
tweakfirst [] = []
|
||||
_ -> oldoffsetbounded
|
||||
tweakfirst
|
||||
| offset > 0 = ix 0 .~ color moreupcolor (text (replicate 15 (toEnum 30)))
|
||||
| otherwise = id
|
||||
-- tweakfirst (x : xs)
|
||||
-- | offset > 0 =
|
||||
-- color moreupcolor (text (replicate 15 (toEnum 30))) :
|
||||
-- xs
|
||||
-- | otherwise = x : xs
|
||||
-- tweakfirst [] = []
|
||||
moreupcolor = fromMaybe white $ allstrings ^? ix offset . _1
|
||||
shownitems
|
||||
| length shownstrings > availablelines =
|
||||
map snd (take (availablelines - 1) shownstrings)
|
||||
++ [color moredowncolor . text $ replicate 15 (toEnum 31)]
|
||||
| otherwise = map snd shownstrings
|
||||
tweaklast
|
||||
| length shownstrings > availablelines = ix (availablelines - 1)
|
||||
.~ color moredowncolor (text . replicate 15 $ toEnum 31)
|
||||
| otherwise = id
|
||||
-- shownitems
|
||||
-- | length shownstrings > availablelines =
|
||||
-- map snd (take (availablelines - 1) shownstrings)
|
||||
-- ++ [color moredowncolor . text $ replicate 15 (toEnum 31)]
|
||||
-- | otherwise = map snd shownstrings
|
||||
moredowncolor = fromMaybe white $ allstrings ^? ix (offset + availablelines - 1) . _1
|
||||
allstrings = listSelectionColorPicture sis
|
||||
shownstrings = drop offset allstrings
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
module Dodge.Item.Location (
|
||||
pointerToItemID,
|
||||
pointerToItemLocation,
|
||||
getItem,
|
||||
pointerToItem,
|
||||
pointerYourSelectedItem,
|
||||
pointerYourRootItem,
|
||||
@@ -12,16 +11,6 @@ import Control.Lens
|
||||
import Data.Maybe
|
||||
import Dodge.Data.World
|
||||
|
||||
getItem :: Int -> World -> Maybe Item
|
||||
getItem itid w = do
|
||||
itpos <- w ^? cWorld . lWorld . itemLocations . ix itid
|
||||
case itpos of
|
||||
OnFloor flitid -> w ^? cWorld . lWorld . floorItems . unNIntMap . ix (_unNInt flitid) . flIt
|
||||
InInv {_ilCrID = cid, _ilInvID = invid}
|
||||
-> w ^? cWorld . lWorld . creatures . ix cid . crInv . ix invid
|
||||
OnTurret mcid -> w ^? cWorld . lWorld . machines . ix mcid . mcType . _McTurret . tuWeapon
|
||||
InVoid -> Nothing
|
||||
|
||||
pointerToItemLocation ::
|
||||
Applicative f =>
|
||||
ItemLocation ->
|
||||
|
||||
@@ -4,11 +4,9 @@ module Dodge.Item.Weapon (
|
||||
module Dodge.Item.Weapon.ExtraEffect,
|
||||
module Dodge.Item.Weapon.Radar,
|
||||
module Dodge.Item.Weapon.Utility,
|
||||
-- module Dodge.Item.Weapon.BatteryGuns,
|
||||
module Dodge.Item.Weapon.Drone,
|
||||
) where
|
||||
|
||||
--import Dodge.Item.Weapon.BatteryGuns
|
||||
import Dodge.Item.Weapon.Drone
|
||||
import Dodge.Item.Weapon.ExtraEffect
|
||||
import Dodge.Item.Weapon.Radar
|
||||
|
||||
@@ -32,23 +32,15 @@ zConnectColMidX :: Point2 -> Point2 -> Float -> Color -> Color -> Color -> Color
|
||||
zConnectColMidX (V2 x y) (V2 a b) midx c1 c2 c3 c4 =
|
||||
lineCol $
|
||||
zip
|
||||
( map
|
||||
toV2
|
||||
[ (x, y)
|
||||
, (midx, y)
|
||||
, (midx, b)
|
||||
, (a, b)
|
||||
]
|
||||
)
|
||||
[ V2 x y
|
||||
, V2 midx y
|
||||
, V2 midx b
|
||||
, V2 a b
|
||||
]
|
||||
[c1, c2, c3, c4]
|
||||
|
||||
lConnect :: Point2 -> Point2 -> Picture
|
||||
lConnect sp@(V2 _ y) ep@(V2 x _) =
|
||||
line
|
||||
[ sp
|
||||
, V2 x y
|
||||
, ep
|
||||
]
|
||||
lConnect sp@(V2 _ y) ep@(V2 x _) = line [sp, V2 x y, ep]
|
||||
|
||||
-- this function is the reason for the incomplete-uni-patterns warning suppression
|
||||
lConnectMulti :: [Point2] -> Point2 -> Picture
|
||||
|
||||
Reference in New Issue
Block a user