;;; Catbird Game Engine ;;; Copyright © 2022 David Thompson ;;; ;;; Licensed under the Apache License, Version 2.0 (the "License"); ;;; you may not use this file except in compliance with the License. ;;; You may obtain a copy of the License at ;;; ;;; http://www.apache.org/licenses/LICENSE-2.0 ;;; ;;; Unless required by applicable law or agreed to in writing, software ;;; distributed under the License is distributed on an "AS IS" BASIS, ;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ;;; See the License for the specific language governing permissions and ;;; limitations under the License. ;;; Commentary: ;; ;; System overlay scene for notifications and developer tools. ;; ;;; Code: (define-module (catbird overlay) #:use-module (catbird kernel) #:use-module (catbird input-map) #:use-module (catbird minibuffer) #:use-module (catbird node) #:use-module (catbird node-2d) #:use-module (catbird region) #:use-module (catbird repl) #:use-module (catbird scene) #:use-module (catbird ui) #:use-module (chickadee graphics color) #:use-module (chickadee graphics path) #:use-module (chickadee graphics text) #:use-module (chickadee math vector) #:use-module (chickadee scripting) #:use-module (ice-9 format) #:use-module (oop goops) #:export (make-overlay)) (define %background-color (make-color 0.2 0.2 0.2 0.8)) (define-class ()) (define (make-overlay) (make #:name 'overlay)) (define-method (open-repl (overlay )) (unless (is-a? (major-mode overlay) ) (push-major-mode overlay (make ))) (open-repl (major-mode overlay))) (define-method (freeze-all-regions (overlay )) (for-each (lambda (region) ;; Freeze everything except the overlay. (unless (eq? (scene region) overlay) (freeze region))) (all-regions))) (define (unfreeze-all-regions) (for-each unfreeze (all-regions))) (define-method (handle-error (overlay ) exception stack) (freeze-all-regions overlay) (open-repl overlay) (let ((repl (& overlay repl))) (enter-debugger repl exception stack))) (define-method (on-enter (overlay )) (set! (error-handler (current-kernel)) (lambda (exception stack) (handle-error overlay exception stack)))) (define-method (notify (scene ) message) (run-script scene (let* ((padding 8.0) (label (make