Cleanup, add a slight border to ideal camera zoom
This commit is contained in:
@@ -19,7 +19,8 @@ import Dodge.Item.Location
|
||||
useItem :: Int -> Int -> World -> Maybe World
|
||||
useItem invid pt w = fmap (worldEventFlags . at InventoryChange ?~ ()) $ do
|
||||
cr <- w ^? cWorld . lWorld . creatures . ix 0
|
||||
itmloc <- invIndents ((\k -> w ^?! cWorld . lWorld . items . ix k) <$> _crInv cr) ^? ix invid . _2
|
||||
itmloc <- invIndents ((\k -> w ^?! cWorld . lWorld . items . ix k) <$> _crInv cr)
|
||||
^? ix invid . _2
|
||||
useItemLoc cr itmloc pt w
|
||||
|
||||
useItemLoc :: Creature -> LocationDT OItem -> Int -> World -> Maybe World
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
{-# LANGUAGE TupleSections #-}
|
||||
|
||||
module Dodge.Debug.Terminal where
|
||||
|
||||
import Dodge.Inventory
|
||||
import Data.Foldable
|
||||
--import Dodge.Item.Location.Initialize
|
||||
import Control.Applicative
|
||||
@@ -13,14 +15,12 @@ import Dodge.Creature
|
||||
import Dodge.Data.Universe
|
||||
import Dodge.Inventory.Add
|
||||
import Dodge.Item
|
||||
--import Dodge.Menu.PushPop
|
||||
--import qualified IntMapHelp as IM
|
||||
import LensHelp
|
||||
import MaybeHelp
|
||||
import Text.Read (readMaybe)
|
||||
|
||||
applyTerminalString :: [String] -> Universe -> Universe
|
||||
applyTerminalString ss = case ss of
|
||||
applyTerminalString = \case
|
||||
[] -> id
|
||||
[s] -> applyTerminalCommand s
|
||||
(s : ss') -> applyTerminalCommandArguments s ss'
|
||||
@@ -28,11 +28,16 @@ applyTerminalString ss = case ss of
|
||||
applyTerminalCommand :: String -> Universe -> Universe
|
||||
applyTerminalCommand s = case s of
|
||||
"NOCLIP" -> uvConfig . debug_booleans . at Noclip %~ toggleJust
|
||||
"GODON" -> uvWorld . cWorld . lWorld . creatures . ix 0 . crType . avatarMaterial .~ Crystal
|
||||
"GODOFF" -> uvWorld . cWorld . lWorld . creatures . ix 0 . crType . avatarMaterial .~ Flesh
|
||||
"GODON" -> uvWorld . cWorld . lWorld . creatures . ix 0 . crType . avatarMaterial
|
||||
.~ Crystal
|
||||
"GODOFF" -> uvWorld . cWorld . lWorld . creatures . ix 0 . crType . avatarMaterial
|
||||
.~ Flesh
|
||||
"CLEAR" -> \uv -> uv & uvWorld %~ destroyAllInvItems
|
||||
(uv ^?! uvWorld . cWorld . lWorld . creatures . ix 0)
|
||||
x -> fromMaybe (g x) $ do
|
||||
(ibt, n) <- parseItem [x]
|
||||
return $ uvWorld %~ flip (foldl' (&)) (replicate n ( createItemYou (itemFromBase ibt)))
|
||||
return $ uvWorld
|
||||
%~ flip (foldl' (&)) (replicate n ( createItemYou (itemFromBase ibt)))
|
||||
where
|
||||
g xs = uvWorld %~ \w -> foldl' (flip createItemYou) w (inventoryX xs)
|
||||
|
||||
|
||||
@@ -127,7 +127,9 @@ moveZoomCamera cfig theinput cr w campos =
|
||||
| curZoom > idealZoom + 0.01 = ((zoomOutSpeed -1) * curZoom + idealZoom) / zoomOutSpeed
|
||||
| curZoom < idealZoom - 0.01 = ((zoomInSpeed -1) * curZoom + idealZoom) / zoomInSpeed
|
||||
| otherwise = idealZoom
|
||||
wallZoom = min4 (campos ^. camBoundDist)
|
||||
wallZoom = min4 (f (campos ^. camBoundDist))
|
||||
f (a,b,c,d) = (a+bordersize,b-bordersize,c+bordersize,d-bordersize)
|
||||
bordersize = 20
|
||||
min4 (a, b, c, d) = minimum [hh / maxd a, hh / maxd (- b), hw / maxd c, hw / maxd (- d)]
|
||||
maxd = max distFromEqmnt
|
||||
distFromEqmnt = viewDistanceFromItems cr
|
||||
|
||||
Reference in New Issue
Block a user