OSDN Git Service

correcting input and rulp main loop
[rulp/rulp.git] / data.lisp
index 2c3dd0a..c625c46 100644 (file)
--- a/data.lisp
+++ b/data.lisp
 ;;;; You should have received a copy of the GNU General Public License
 ;;;; along with this program. If not, see <https://www.gnu.org/licenses/>.
 
-(in-package :core)
+(in-package :rulp.core)
 
 (defun decode-from-json (json-file)
   "take a json file path and decode it"
   (with-open-file (json-stream json-file)
-    (json:decode-json json-stream)))
+    (values (json:decode-json json-stream)
+            (make-pathname :directory (pathname-directory json-file)))))
 
 ;; this definition is hard coded, when planes will change this
 ;; function needs to be edited alike. Look for a better and
   "take a parsed alist and create a plane on those specs"
   (let* ((json-position (make-pathname :directory (pathname-directory json-file)))
          (alist (decode-from-json json-file))
-         (img-path (if (assoc ':image-path alist)
-                       (merge-pathnames json-position (cdr (assoc ':image-path alist)))
-                       (error "Image-path missing from \"~A\", exits~%" json-file)))
          (img-path (merge-pathnames json-position (cdr (assoc ':image-path alist))))
-         (ret (make-instance 'layers:plane :image img-path)))
-    (when (assoc ':size alist) (setf (layers:size ret) (cdr (assoc ':size alist))))
-    (when (assoc ':grid-dimension alist) (setf (layers:grid-dimension ret) (cdr (assoc ':grid-dimension alist))))
+         (ret (make-instance 'rulp.layers:screen :image img-path)))
+    ;; (when (assoc ':size alist) (setf (layers:size ret) (cdr (assoc ':size alist))))
+    ;; (when (assoc ':grid-dimension alist) (setf (graphics:-dimension ret) (cdr (assoc ':grid-dimension alist))))
     ret))
 
+
 ;; posso usare le hash piuttosto che interpretarlo sul momento. Infatti creerò un metodo che
 ;; analizza json e lo traduce in una tabella hash e una funzione che prende la hash e crea
 ;; l'oggetto tramite i metodi standard.