Add debug to copy to clipboard any clicked-on creature
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
module Dodge.Debug (debugEvents, drawDebug) where
|
||||
|
||||
import Dodge.Base.Coordinate
|
||||
import Dodge.Zoning.Creature
|
||||
import Dodge.Creature.Radius
|
||||
import Geometry.Data
|
||||
import Dodge.Render.Label
|
||||
@@ -25,6 +27,7 @@ import Picture.Base
|
||||
import qualified SDL
|
||||
import System.Hclip
|
||||
import Text.Read
|
||||
import Data.List (sortOn)
|
||||
|
||||
debugEvents :: Universe -> Universe
|
||||
debugEvents u = case dbools ^. at Display_debug of
|
||||
@@ -83,6 +86,14 @@ debugEvent' = \case
|
||||
Debug_put -> id
|
||||
Muzzle_positions -> id
|
||||
Show_cr_hitboxes -> id
|
||||
Clipboard_cr -> clipboardCr
|
||||
|
||||
clipboardCr :: Universe -> Universe
|
||||
clipboardCr u = fromMaybe u $ do
|
||||
guard (u ^. uvWorld . input . mouseButtons . at SDL.ButtonLeft == Just 0)
|
||||
return $ u & uvIOEffects %~ (\m u' -> setClipboard s >> m u')
|
||||
where
|
||||
s = unlines . prettyShort $ closestCrToMouse $ u ^. uvWorld
|
||||
|
||||
debugItem :: DebugBool -> Universe -> Maybe [DebugItem]
|
||||
debugItem = \case
|
||||
@@ -120,6 +131,7 @@ debugItem = \case
|
||||
Debug_put -> debugPutItems
|
||||
Muzzle_positions -> mempty
|
||||
Show_cr_hitboxes -> mempty
|
||||
Clipboard_cr -> mempty
|
||||
|
||||
debugGet :: Universe -> [String]
|
||||
debugGet u = foldMap getPretty $ u ^. uvWorld . cWorld . lWorld . shockwaves
|
||||
@@ -291,6 +303,13 @@ drawDebug u = \case
|
||||
Show_mouse_click_pos -> mempty
|
||||
Muzzle_positions -> showMuzzlePositions u
|
||||
Show_cr_hitboxes -> foldMap drawCreatureRad (u ^. uvWorld . cWorld . lWorld . creatures)
|
||||
Clipboard_cr -> foldMap drawCreatureRad (closestCrToMouse $ u^.uvWorld)
|
||||
|
||||
closestCrToMouse :: World -> Maybe Creature
|
||||
closestCrToMouse w = listToMaybe . sortOn (distance mwp . (^. crPos . _xy))
|
||||
$ crsNearPoint mwp w
|
||||
where
|
||||
mwp = mouseWorldPos (w^.input) (w^.wCam)
|
||||
|
||||
drawCreatureRad :: Creature -> Picture
|
||||
drawCreatureRad cr = setLayer DebugLayer
|
||||
|
||||
Reference in New Issue
Block a user