diff --git a/data/gen-scrfile.scm b/data/gen-scrfile.scm deleted file mode 100755 index e72ab7e19..000000000 --- a/data/gen-scrfile.scm +++ /dev/null @@ -1,120 +0,0 @@ -#!/usr/bin/guile \ ---debug -e main -s -!# - -(define (get-keyword-value args keyword default) - (let ((kv (memq keyword args))) - (if (and kv (>= (length kv) 2)) - (cadr kv) - default))) - -;; Return a list containing all the objects which match 'pred?' -(define (filter pred? objects) - (let loop ((objs objects) - (result '())) - (cond ((null? objs) (reverse! result)) - ((pred? (car objs)) (loop (cdr objs) (cons (car objs) result))) - (else (loop (cdr objs) result))))) - -;; Return a list of the strings which match the regex 'rx' -(define (grep rx strings) - (let ((r (make-regexp rx))) - (filter (lambda (x) (regexp-exec r x)) strings))) - -(define (print . str) - (for-each (lambda (x) (display x)) str) - (force-output)) - -(define (println-sep . str) - (for-each (lambda (x) - (display "\"") - (display x) - (display "\"")) str) - (newline)) - -;; Print the given strings and a newline -(define (println . str) - (apply print str) (newline)) - -(define (println-port port . strs) - (for-each (lambda (el) - (display el port)) - strs) - (newline port)) - -(define (directory->list path) - (let* ((dir (opendir path)) - (lst '())) - (let loop ((fobj (readdir dir))) - (cond ((not (eof-object? fobj)) - (set! lst (cons fobj lst)) - (loop (readdir dir))))) - (closedir dir) - (reverse lst))) - -;; End: Helper functions - -(define (directory? file) - (equal? (stat:type (stat file)) 'directory)) - -(define (indent level) - (make-string (* 2 level) #\space)) - -(define (cut-extension filename) - (substring filename 0 (- (string-length filename) 4))) - -(define (dirtree2scr port level path) - (let* ((lst (sort (directory->list path) string<=?)) - (images (grep "\.png$\|\.jpg$" (filter (lambda (x) - (not (directory? (string-append path "/" x)))) - lst))) - (directories (filter (lambda (el) - (and (directory? (string-append path "/" el)) - (not (equal? el "CVS")) - (not (equal? el "old")) - (not (equal? (string-ref el 0) #\.)))) - lst))) - (for-each (lambda (el) - (println-port port - (indent (1+ level)) - "\n" - (indent (+ 2 level)) - "\n" - (indent (1+ level))"\n" - )) - images) - (for-each (lambda (el) - (println-port port (indent level) "
") - (dirtree2scr port (1+ level) (string-append path "/" el)) - (println-port port (indent level) "
")) - directories))) - -(define (create-scr-file filename directory . sections) - (let ((port (open-output-file filename))) - (println-port port "\n") - (println-port port "\n") - (println-port port"") - (for-each (lambda (el) - (println-port port "
")) - sections) - (dirtree2scr port (length sections) directory) - (for-each (lambda (el) - (println-port port "
")) - sections) - (println-port port"
") - (close port))) - -(define (main args) - (create-scr-file "data/groundpieces-ground.xml" "images/groundpieces/ground" - "groundpieces" "ground") - (create-scr-file "data/groundpieces-solid.xml" "images/groundpieces/solid" - "groundpieces" "solid") - (create-scr-file "data/groundpieces-remove.xml" "images/groundpieces/remove" - "groundpieces" "remove") - (create-scr-file "data/groundpieces-transparent.xml" "images/groundpieces/transparent" - "groundpieces" "transparent") - (create-scr-file "data/groundpieces-bridge.xml" "images/groundpieces/bridge" "groundpieces" "bridge") - (create-scr-file "data/hotspots.xml" "images/hotspots" "hotspots")) - - -;; EOF ;;