summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson@vistahigherlearning.com>2022-10-26 18:31:00 -0400
committerDavid Thompson <dthompson@vistahigherlearning.com>2022-10-26 18:31:00 -0400
commitb8a7baa18d69e6ac1e3e9119400eaffd3b194aa4 (patch)
tree1a2b7907e1266d67575c984154e92443623133f8
parente2f2e1b9389b846bcc1b8e3ac17602decb9ded9e (diff)
asset: Add convenience macros.
-rw-r--r--catbird/asset.scm25
1 files changed, 24 insertions, 1 deletions
diff --git a/catbird/asset.scm b/catbird/asset.scm
index 72f46df..71d9b6a 100644
--- a/catbird/asset.scm
+++ b/catbird/asset.scm
@@ -23,6 +23,9 @@
(define-module (catbird asset)
#:use-module (catbird config)
#:use-module (catbird inotify)
+ #:use-module (chickadee audio)
+ #:use-module (chickadee graphics text)
+ #:use-module (chickadee graphics texture)
#:use-module (ice-9 match)
#:use-module (oop goops)
#:export (<asset>
@@ -36,6 +39,10 @@
unsubscribe
on-asset-refresh
define-asset
+ define-font
+ define-image
+ define-tileset
+ define-audio
reload-modified-assets
<asset-container>))
@@ -168,7 +175,7 @@
;;; Syntax
;;;
-(define-syntax-rule (define-asset name ((var file-name) ...) body ...)
+(define-syntax-rule (define-asset (name (var file-name) ...) body ...)
(define name
(let ((file-names (list file-name ...))
(proc (lambda (var ...) body ...)))
@@ -182,6 +189,22 @@
#:file-names file-names
#:loader proc)))))
+(define-syntax-rule (define-font name file-name size args ...)
+ (define-asset (name (f file-name))
+ (load-font f size args ...)))
+
+(define-syntax-rule (define-image name file-name args ...)
+ (define-asset (name (f file-name))
+ (load-image f args ...)))
+
+(define-syntax-rule (define-tileset name file-name tw th args ...)
+ (define-asset (name (f file-name))
+ (load-tileset f tw th args ...)))
+
+(define-syntax-rule (define-audio name file-name args ...)
+ (define-asset (name (f file-name))
+ (load-audio f args ...)))
+
;;;
;;; Asset Metaclass