Moved some display stuff to engine. Not certain this was the right decision,
but it may be wanted for MicroWorld projects which are not simply the education-oriented rule engine.
This commit is contained in:
parent
7dbaebb6aa
commit
2d2b3b4f0d
|
@ -28,7 +28,7 @@
|
||||||
[cell]
|
[cell]
|
||||||
(let [state (:state cell)]
|
(let [state (:state cell)]
|
||||||
[:td {:class (format-css-class state) :title (format-mouseover cell)}
|
[:td {:class (format-css-class state) :title (format-mouseover cell)}
|
||||||
[:a {:href (format "inspect?x=%d&y=%d" (:x cell) (:y cell))}
|
[:a {:href (format "inspect?x=%d&y=%d" (:x cell) (:y cell))}
|
||||||
[:img {:alt (:state cell) :src (format-image-path state)}]]]))
|
[:img {:alt (:state cell) :src (format-image-path state)}]]]))
|
||||||
|
|
||||||
(defn render-world-row
|
(defn render-world-row
|
||||||
|
@ -40,11 +40,11 @@
|
||||||
"Render the world implied by the current session as a complete HTML table in a DIV."
|
"Render the world implied by the current session as a complete HTML table in a DIV."
|
||||||
[]
|
[]
|
||||||
(let [world (or (session/get :world)
|
(let [world (or (session/get :world)
|
||||||
(heightmap/apply-heightmap
|
(heightmap/apply-heightmap
|
||||||
(io/get-resource "/img/heightmaps/small_hill.png")))
|
(io/get-resource "/img/heightmaps/small_hill.png")))
|
||||||
rules (or (session/get :rules)
|
rules (or (session/get :rules)
|
||||||
(do (session/put! :rules
|
(do (session/put! :rules
|
||||||
(compiler/compile-file
|
(compiler/compile-file
|
||||||
(io/get-resource "/rulesets/basic.txt")))
|
(io/get-resource "/rulesets/basic.txt")))
|
||||||
(session/get :rules)))
|
(session/get :rules)))
|
||||||
generation (+ (or (session/get :generation) 0) 1)
|
generation (+ (or (session/get :generation) 0) 1)
|
||||||
|
@ -56,14 +56,15 @@
|
||||||
(apply vector
|
(apply vector
|
||||||
(cons :table
|
(cons :table
|
||||||
(map render-world-row w2)))
|
(map render-world-row w2)))
|
||||||
[:p
|
[:p
|
||||||
(str "Generation " generation)]]))
|
(str "Generation " generation)]]))
|
||||||
|
|
||||||
(defn render-inspector
|
(defn render-inspector
|
||||||
|
"Render in Hiccup format the HTML content of an inspector on this cell."
|
||||||
[cell table]
|
[cell table]
|
||||||
[:table {:class "music-ruled"}
|
[:table {:class "music-ruled"}
|
||||||
[:tr
|
[:tr
|
||||||
[:td {:colspan 2 :style "text-align: center;"}
|
[:td {:colspan 2 :style "text-align: center;"}
|
||||||
[:img {:src (str "img/tiles/" (name (:state cell)) ".png")
|
[:img {:src (str "img/tiles/" (name (:state cell)) ".png")
|
||||||
:width 64
|
:width 64
|
||||||
:height 64}]]]
|
:height 64}]]]
|
||||||
|
@ -71,4 +72,3 @@
|
||||||
(map #(vector :tr (vector :th %)(vector :td (cell %))) (keys cell))])
|
(map #(vector :tr (vector :th %)(vector :td (cell %))) (keys cell))])
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue