module Resource.Combined.Textures
  ( Collection(..)
  , attachDebugNames
  ) where

import RIO

import GHC.Stack (withFrozenCallStack)

import Engine.Vulkan.Types (MonadVulkan)
import Resource.Texture (Texture, debugNameCollection)

data Collection textures fonts a = Collection
  -- XXX: textures go first, as there should be a filler texture at [0]
  { forall {k} (textures :: k -> *) (fonts :: k -> *) (a :: k).
Collection textures fonts a -> textures a
textures :: textures a
  , forall {k} (textures :: k -> *) (fonts :: k -> *) (a :: k).
Collection textures fonts a -> fonts a
fonts    :: fonts a
  }
  deriving (Int -> Collection textures fonts a -> ShowS
[Collection textures fonts a] -> ShowS
Collection textures fonts a -> String
(Int -> Collection textures fonts a -> ShowS)
-> (Collection textures fonts a -> String)
-> ([Collection textures fonts a] -> ShowS)
-> Show (Collection textures fonts a)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall k (textures :: k -> *) (fonts :: k -> *) (a :: k).
(Show (textures a), Show (fonts a)) =>
Int -> Collection textures fonts a -> ShowS
forall k (textures :: k -> *) (fonts :: k -> *) (a :: k).
(Show (textures a), Show (fonts a)) =>
[Collection textures fonts a] -> ShowS
forall k (textures :: k -> *) (fonts :: k -> *) (a :: k).
(Show (textures a), Show (fonts a)) =>
Collection textures fonts a -> String
$cshowsPrec :: forall k (textures :: k -> *) (fonts :: k -> *) (a :: k).
(Show (textures a), Show (fonts a)) =>
Int -> Collection textures fonts a -> ShowS
showsPrec :: Int -> Collection textures fonts a -> ShowS
$cshow :: forall k (textures :: k -> *) (fonts :: k -> *) (a :: k).
(Show (textures a), Show (fonts a)) =>
Collection textures fonts a -> String
show :: Collection textures fonts a -> String
$cshowList :: forall k (textures :: k -> *) (fonts :: k -> *) (a :: k).
(Show (textures a), Show (fonts a)) =>
[Collection textures fonts a] -> ShowS
showList :: [Collection textures fonts a] -> ShowS
Show, (forall a b.
 (a -> b)
 -> Collection textures fonts a -> Collection textures fonts b)
-> (forall a b.
    a -> Collection textures fonts b -> Collection textures fonts a)
-> Functor (Collection textures fonts)
forall a b.
a -> Collection textures fonts b -> Collection textures fonts a
forall a b.
(a -> b)
-> Collection textures fonts a -> Collection textures fonts b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
forall (textures :: * -> *) (fonts :: * -> *) a b.
(Functor textures, Functor fonts) =>
a -> Collection textures fonts b -> Collection textures fonts a
forall (textures :: * -> *) (fonts :: * -> *) a b.
(Functor textures, Functor fonts) =>
(a -> b)
-> Collection textures fonts a -> Collection textures fonts b
$cfmap :: forall (textures :: * -> *) (fonts :: * -> *) a b.
(Functor textures, Functor fonts) =>
(a -> b)
-> Collection textures fonts a -> Collection textures fonts b
fmap :: forall a b.
(a -> b)
-> Collection textures fonts a -> Collection textures fonts b
$c<$ :: forall (textures :: * -> *) (fonts :: * -> *) a b.
(Functor textures, Functor fonts) =>
a -> Collection textures fonts b -> Collection textures fonts a
<$ :: forall a b.
a -> Collection textures fonts b -> Collection textures fonts a
Functor, (forall m. Monoid m => Collection textures fonts m -> m)
-> (forall m a.
    Monoid m =>
    (a -> m) -> Collection textures fonts a -> m)
-> (forall m a.
    Monoid m =>
    (a -> m) -> Collection textures fonts a -> m)
-> (forall a b.
    (a -> b -> b) -> b -> Collection textures fonts a -> b)
-> (forall a b.
    (a -> b -> b) -> b -> Collection textures fonts a -> b)
-> (forall b a.
    (b -> a -> b) -> b -> Collection textures fonts a -> b)
-> (forall b a.
    (b -> a -> b) -> b -> Collection textures fonts a -> b)
-> (forall a. (a -> a -> a) -> Collection textures fonts a -> a)
-> (forall a. (a -> a -> a) -> Collection textures fonts a -> a)
-> (forall a. Collection textures fonts a -> [a])
-> (forall a. Collection textures fonts a -> Bool)
-> (forall a. Collection textures fonts a -> Int)
-> (forall a. Eq a => a -> Collection textures fonts a -> Bool)
-> (forall a. Ord a => Collection textures fonts a -> a)
-> (forall a. Ord a => Collection textures fonts a -> a)
-> (forall a. Num a => Collection textures fonts a -> a)
-> (forall a. Num a => Collection textures fonts a -> a)
-> Foldable (Collection textures fonts)
forall a. Eq a => a -> Collection textures fonts a -> Bool
forall a. Num a => Collection textures fonts a -> a
forall a. Ord a => Collection textures fonts a -> a
forall m. Monoid m => Collection textures fonts m -> m
forall a. Collection textures fonts a -> Bool
forall a. Collection textures fonts a -> Int
forall a. Collection textures fonts a -> [a]
forall a. (a -> a -> a) -> Collection textures fonts a -> a
forall m a.
Monoid m =>
(a -> m) -> Collection textures fonts a -> m
forall b a. (b -> a -> b) -> b -> Collection textures fonts a -> b
forall a b. (a -> b -> b) -> b -> Collection textures fonts a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
forall (textures :: * -> *) (fonts :: * -> *) a.
(Foldable textures, Foldable fonts, Eq a) =>
a -> Collection textures fonts a -> Bool
forall (textures :: * -> *) (fonts :: * -> *) a.
(Foldable textures, Foldable fonts, Num a) =>
Collection textures fonts a -> a
forall (textures :: * -> *) (fonts :: * -> *) a.
(Foldable textures, Foldable fonts, Ord a) =>
Collection textures fonts a -> a
forall (textures :: * -> *) (fonts :: * -> *) m.
(Foldable textures, Foldable fonts, Monoid m) =>
Collection textures fonts m -> m
forall (textures :: * -> *) (fonts :: * -> *) a.
(Foldable textures, Foldable fonts) =>
Collection textures fonts a -> Bool
forall (textures :: * -> *) (fonts :: * -> *) a.
(Foldable textures, Foldable fonts) =>
Collection textures fonts a -> Int
forall (textures :: * -> *) (fonts :: * -> *) a.
(Foldable textures, Foldable fonts) =>
Collection textures fonts a -> [a]
forall (textures :: * -> *) (fonts :: * -> *) a.
(Foldable textures, Foldable fonts) =>
(a -> a -> a) -> Collection textures fonts a -> a
forall (textures :: * -> *) (fonts :: * -> *) m a.
(Foldable textures, Foldable fonts, Monoid m) =>
(a -> m) -> Collection textures fonts a -> m
forall (textures :: * -> *) (fonts :: * -> *) b a.
(Foldable textures, Foldable fonts) =>
(b -> a -> b) -> b -> Collection textures fonts a -> b
forall (textures :: * -> *) (fonts :: * -> *) a b.
(Foldable textures, Foldable fonts) =>
(a -> b -> b) -> b -> Collection textures fonts a -> b
$cfold :: forall (textures :: * -> *) (fonts :: * -> *) m.
(Foldable textures, Foldable fonts, Monoid m) =>
Collection textures fonts m -> m
fold :: forall m. Monoid m => Collection textures fonts m -> m
$cfoldMap :: forall (textures :: * -> *) (fonts :: * -> *) m a.
(Foldable textures, Foldable fonts, Monoid m) =>
(a -> m) -> Collection textures fonts a -> m
foldMap :: forall m a.
Monoid m =>
(a -> m) -> Collection textures fonts a -> m
$cfoldMap' :: forall (textures :: * -> *) (fonts :: * -> *) m a.
(Foldable textures, Foldable fonts, Monoid m) =>
(a -> m) -> Collection textures fonts a -> m
foldMap' :: forall m a.
Monoid m =>
(a -> m) -> Collection textures fonts a -> m
$cfoldr :: forall (textures :: * -> *) (fonts :: * -> *) a b.
(Foldable textures, Foldable fonts) =>
(a -> b -> b) -> b -> Collection textures fonts a -> b
foldr :: forall a b. (a -> b -> b) -> b -> Collection textures fonts a -> b
$cfoldr' :: forall (textures :: * -> *) (fonts :: * -> *) a b.
(Foldable textures, Foldable fonts) =>
(a -> b -> b) -> b -> Collection textures fonts a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> Collection textures fonts a -> b
$cfoldl :: forall (textures :: * -> *) (fonts :: * -> *) b a.
(Foldable textures, Foldable fonts) =>
(b -> a -> b) -> b -> Collection textures fonts a -> b
foldl :: forall b a. (b -> a -> b) -> b -> Collection textures fonts a -> b
$cfoldl' :: forall (textures :: * -> *) (fonts :: * -> *) b a.
(Foldable textures, Foldable fonts) =>
(b -> a -> b) -> b -> Collection textures fonts a -> b
foldl' :: forall b a. (b -> a -> b) -> b -> Collection textures fonts a -> b
$cfoldr1 :: forall (textures :: * -> *) (fonts :: * -> *) a.
(Foldable textures, Foldable fonts) =>
(a -> a -> a) -> Collection textures fonts a -> a
foldr1 :: forall a. (a -> a -> a) -> Collection textures fonts a -> a
$cfoldl1 :: forall (textures :: * -> *) (fonts :: * -> *) a.
(Foldable textures, Foldable fonts) =>
(a -> a -> a) -> Collection textures fonts a -> a
foldl1 :: forall a. (a -> a -> a) -> Collection textures fonts a -> a
$ctoList :: forall (textures :: * -> *) (fonts :: * -> *) a.
(Foldable textures, Foldable fonts) =>
Collection textures fonts a -> [a]
toList :: forall a. Collection textures fonts a -> [a]
$cnull :: forall (textures :: * -> *) (fonts :: * -> *) a.
(Foldable textures, Foldable fonts) =>
Collection textures fonts a -> Bool
null :: forall a. Collection textures fonts a -> Bool
$clength :: forall (textures :: * -> *) (fonts :: * -> *) a.
(Foldable textures, Foldable fonts) =>
Collection textures fonts a -> Int
length :: forall a. Collection textures fonts a -> Int
$celem :: forall (textures :: * -> *) (fonts :: * -> *) a.
(Foldable textures, Foldable fonts, Eq a) =>
a -> Collection textures fonts a -> Bool
elem :: forall a. Eq a => a -> Collection textures fonts a -> Bool
$cmaximum :: forall (textures :: * -> *) (fonts :: * -> *) a.
(Foldable textures, Foldable fonts, Ord a) =>
Collection textures fonts a -> a
maximum :: forall a. Ord a => Collection textures fonts a -> a
$cminimum :: forall (textures :: * -> *) (fonts :: * -> *) a.
(Foldable textures, Foldable fonts, Ord a) =>
Collection textures fonts a -> a
minimum :: forall a. Ord a => Collection textures fonts a -> a
$csum :: forall (textures :: * -> *) (fonts :: * -> *) a.
(Foldable textures, Foldable fonts, Num a) =>
Collection textures fonts a -> a
sum :: forall a. Num a => Collection textures fonts a -> a
$cproduct :: forall (textures :: * -> *) (fonts :: * -> *) a.
(Foldable textures, Foldable fonts, Num a) =>
Collection textures fonts a -> a
product :: forall a. Num a => Collection textures fonts a -> a
Foldable, Functor (Collection textures fonts)
Foldable (Collection textures fonts)
Functor (Collection textures fonts)
-> Foldable (Collection textures fonts)
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b)
    -> Collection textures fonts a -> f (Collection textures fonts b))
-> (forall (f :: * -> *) a.
    Applicative f =>
    Collection textures fonts (f a) -> f (Collection textures fonts a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b)
    -> Collection textures fonts a -> m (Collection textures fonts b))
-> (forall (m :: * -> *) a.
    Monad m =>
    Collection textures fonts (m a) -> m (Collection textures fonts a))
-> Traversable (Collection textures fonts)
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a.
Monad m =>
Collection textures fonts (m a) -> m (Collection textures fonts a)
forall (f :: * -> *) a.
Applicative f =>
Collection textures fonts (f a) -> f (Collection textures fonts a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b)
-> Collection textures fonts a -> m (Collection textures fonts b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b)
-> Collection textures fonts a -> f (Collection textures fonts b)
forall {textures :: * -> *} {fonts :: * -> *}.
(Traversable textures, Traversable fonts) =>
Functor (Collection textures fonts)
forall {textures :: * -> *} {fonts :: * -> *}.
(Traversable textures, Traversable fonts) =>
Foldable (Collection textures fonts)
forall (textures :: * -> *) (fonts :: * -> *) (m :: * -> *) a.
(Traversable textures, Traversable fonts, Monad m) =>
Collection textures fonts (m a) -> m (Collection textures fonts a)
forall (textures :: * -> *) (fonts :: * -> *) (f :: * -> *) a.
(Traversable textures, Traversable fonts, Applicative f) =>
Collection textures fonts (f a) -> f (Collection textures fonts a)
forall (textures :: * -> *) (fonts :: * -> *) (m :: * -> *) a b.
(Traversable textures, Traversable fonts, Monad m) =>
(a -> m b)
-> Collection textures fonts a -> m (Collection textures fonts b)
forall (textures :: * -> *) (fonts :: * -> *) (f :: * -> *) a b.
(Traversable textures, Traversable fonts, Applicative f) =>
(a -> f b)
-> Collection textures fonts a -> f (Collection textures fonts b)
$ctraverse :: forall (textures :: * -> *) (fonts :: * -> *) (f :: * -> *) a b.
(Traversable textures, Traversable fonts, Applicative f) =>
(a -> f b)
-> Collection textures fonts a -> f (Collection textures fonts b)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b)
-> Collection textures fonts a -> f (Collection textures fonts b)
$csequenceA :: forall (textures :: * -> *) (fonts :: * -> *) (f :: * -> *) a.
(Traversable textures, Traversable fonts, Applicative f) =>
Collection textures fonts (f a) -> f (Collection textures fonts a)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
Collection textures fonts (f a) -> f (Collection textures fonts a)
$cmapM :: forall (textures :: * -> *) (fonts :: * -> *) (m :: * -> *) a b.
(Traversable textures, Traversable fonts, Monad m) =>
(a -> m b)
-> Collection textures fonts a -> m (Collection textures fonts b)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b)
-> Collection textures fonts a -> m (Collection textures fonts b)
$csequence :: forall (textures :: * -> *) (fonts :: * -> *) (m :: * -> *) a.
(Traversable textures, Traversable fonts, Monad m) =>
Collection textures fonts (m a) -> m (Collection textures fonts a)
sequence :: forall (m :: * -> *) a.
Monad m =>
Collection textures fonts (m a) -> m (Collection textures fonts a)
Traversable, (forall x.
 Collection textures fonts a -> Rep (Collection textures fonts a) x)
-> (forall x.
    Rep (Collection textures fonts a) x -> Collection textures fonts a)
-> Generic (Collection textures fonts a)
forall x.
Rep (Collection textures fonts a) x -> Collection textures fonts a
forall x.
Collection textures fonts a -> Rep (Collection textures fonts a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall k (textures :: k -> *) (fonts :: k -> *) (a :: k) x.
Rep (Collection textures fonts a) x -> Collection textures fonts a
forall k (textures :: k -> *) (fonts :: k -> *) (a :: k) x.
Collection textures fonts a -> Rep (Collection textures fonts a) x
$cfrom :: forall k (textures :: k -> *) (fonts :: k -> *) (a :: k) x.
Collection textures fonts a -> Rep (Collection textures fonts a) x
from :: forall x.
Collection textures fonts a -> Rep (Collection textures fonts a) x
$cto :: forall k (textures :: k -> *) (fonts :: k -> *) (a :: k) x.
Rep (Collection textures fonts a) x -> Collection textures fonts a
to :: forall x.
Rep (Collection textures fonts a) x -> Collection textures fonts a
Generic)

instance
  ( Applicative t
  , Applicative f
  )
  => Applicative (Collection t f) where
  pure :: forall a. a -> Collection t f a
pure a
x = Collection
    { $sel:textures:Collection :: t a
textures = a -> t a
forall a. a -> t a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a
x
    , $sel:fonts:Collection :: f a
fonts    = a -> f a
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a
x
    }

  Collection t f (a -> b)
af <*> :: forall a b.
Collection t f (a -> b) -> Collection t f a -> Collection t f b
<*> Collection t f a
ax = Collection
    { $sel:textures:Collection :: t b
textures = Collection t f (a -> b) -> t (a -> b)
forall {k} (textures :: k -> *) (fonts :: k -> *) (a :: k).
Collection textures fonts a -> textures a
textures Collection t f (a -> b)
af t (a -> b) -> t a -> t b
forall a b. t (a -> b) -> t a -> t b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Collection t f a -> t a
forall {k} (textures :: k -> *) (fonts :: k -> *) (a :: k).
Collection textures fonts a -> textures a
textures Collection t f a
ax
    , $sel:fonts:Collection :: f b
fonts    = Collection t f (a -> b) -> f (a -> b)
forall {k} (textures :: k -> *) (fonts :: k -> *) (a :: k).
Collection textures fonts a -> fonts a
fonts Collection t f (a -> b)
af f (a -> b) -> f a -> f b
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Collection t f a -> f a
forall {k} (textures :: k -> *) (fonts :: k -> *) (a :: k).
Collection textures fonts a -> fonts a
fonts Collection t f a
ax
    }

attachDebugNames
  :: ( Traversable textures
     , Traversable fonts
     , MonadVulkan env m
     , HasLogFunc env
     , HasCallStack
     )
  => Collection textures fonts (Texture a)
  -> textures FilePath
  -> fonts FilePath
  -> m ()
attachDebugNames :: forall {k} (textures :: * -> *) (fonts :: * -> *) env (m :: * -> *)
       (a :: k).
(Traversable textures, Traversable fonts, MonadVulkan env m,
 HasLogFunc env, HasCallStack) =>
Collection textures fonts (Texture a)
-> textures String -> fonts String -> m ()
attachDebugNames Collection textures fonts (Texture a)
combined textures String
texturePaths fonts String
fontPaths =
  (HasCallStack => m ()) -> m ()
forall a. HasCallStack => (HasCallStack => a) -> a
withFrozenCallStack ((HasCallStack => m ()) -> m ()) -> (HasCallStack => m ()) -> m ()
forall a b. (a -> b) -> a -> b
$
    Collection textures fonts (Texture a)
-> Collection textures fonts String -> m ()
forall {k} (t :: * -> *) env (m :: * -> *) (layers :: k).
(Traversable t, MonadVulkan env m, HasLogFunc env, HasCallStack) =>
t (Texture layers) -> t String -> m ()
debugNameCollection Collection textures fonts (Texture a)
combined Collection
      { $sel:textures:Collection :: textures String
textures = textures String
texturePaths
      , $sel:fonts:Collection :: fonts String
fonts    = fonts String
fontPaths
      }