Use System.Hclip instead of System.Clipboard

This commit is contained in:
2025-10-15 13:19:34 +01:00
parent e139499ed2
commit a0c4d62018
7 changed files with 263 additions and 270 deletions
+11 -4
View File
@@ -2,6 +2,8 @@
module Dodge.Debug (debugEvents,drawDebug) where
import qualified SDL
import System.Hclip
import Control.Lens
import Control.Monad
import qualified Data.IntMap.Strict as IM
@@ -27,8 +29,8 @@ debugEvents u = case dbools ^. at Display_debug of
overDebugEvent :: Universe -> Universe
overDebugEvent u = fromMaybe u $ do
OverDebug db i <- u ^? uvWorld . input . mouseContext
DebugItem s f <- u ^? uvDebug . ix db . ix i
return $ f s u
f <- u ^? uvDebug . ix db . ix i . debugFunction
return $ f u
debugEvent :: DebugBool -> Universe -> Universe
debugEvent db u = u & uvDebug . at db .~ debugItem db u
@@ -72,12 +74,14 @@ drawCrInfo :: Universe -> [DebugItem]
drawCrInfo u = foldMap f . IM.elems $ w ^. cWorld . lWorld . creatures
where
w = u ^. uvWorld
g h str = fmap $ ((rightPad 7 '.' str ++ "...") ++) . h
g h ls x = do
rs <- h <$> x
return $ DebugItem ((rightPad 7 '.' ls ++ "...") ++ rs) (setclip rs)
f cr = fromMaybe [] $ do
guard $
pointIsOnScreen (u ^. uvConfig) (w ^. wCam) (cr ^. crPos . _xy)
&& cr ^. crID /= 0
Just $ (\x -> DebugItem x (const id)) <$> catMaybes
Just $ catMaybes
[ g show "crID" $ cr ^? crID
, g show "crHP" $ cr ^? crHP . _HP
, g show "crStrategy" $ cr ^? crActionPlan . apStrategy
@@ -86,6 +90,9 @@ drawCrInfo u = foldMap f . IM.elems $ w ^. cWorld . lWorld . creatures
, g show "crAction" $ cr ^? crActionPlan . apAction
, g show "crImpulse" $ cr ^? crActionPlan . apImpulse
]
setclip s u'' = fromMaybe u'' $ do
guard (SDL.ButtonLeft `M.member` (u'' ^. uvWorld . input . mouseButtons))
return $ u'' & uvIOEffects %~ (\m u' -> setClipboard s >> m u')
--closestCreatureID :: Universe -> Maybe Int
--closestCreatureID u =