Not much done, and, to be honest, I'm not even sure it's an improvement.
This commit is contained in:
parent
f9043c9572
commit
aed59ad8ad
5 changed files with 114 additions and 47 deletions
|
|
@ -1,17 +1,45 @@
|
|||
(ns ^:figwheel-always mw3.core
|
||||
(:require-macros [cljs.core.async.macros :refer [go]])
|
||||
(:require [om.core :as om :include-macros true]
|
||||
[om.dom :as dom :include-macros true]
|
||||
[cljs.core.async :refer [put! chan <!]]
|
||||
[clojure.string :as string]
|
||||
[secretary.core :as sec :include-macros true]
|
||||
[goog.events :as events]
|
||||
[goog.history.EventType :as EventType]
|
||||
[dommy.core :as dommy :refer-macros [sel sel1]])
|
||||
(:import goog.History))
|
||||
(:require
|
||||
[mw3.rulesets :as rulesets]
|
||||
[dommy.core :as dommy :refer-macros [sel sel1]]
|
||||
[dommy.template :as temp]))
|
||||
|
||||
(def pages [:#home-content :#params-content :#rules-content :#world-content :#docs-content])
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Data declarations
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;; Tiles supplied in the standard distribution. Obviously this isn't all the states you can have.
|
||||
(def tiles ["abandoned"
|
||||
"black"
|
||||
"camp"
|
||||
"climax"
|
||||
"crop"
|
||||
"error"
|
||||
"fire"
|
||||
"forest"
|
||||
"grassland"
|
||||
"heath"
|
||||
"house"
|
||||
"ice"
|
||||
"inn"
|
||||
"market"
|
||||
"meadow"
|
||||
"pasture"
|
||||
"plague"
|
||||
"ploughland"
|
||||
"scrub"
|
||||
"snow"
|
||||
"waste"
|
||||
"water"
|
||||
"white"])
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Navigation
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;; Tabs in the single-page app.
|
||||
(def available-tabs {:#home-tab {:content :#home-content :text "Home"}
|
||||
:#params-tab {:content :#params-content :text "Parameters"}
|
||||
:#rules-tab {:content :#rules-content :text "Rules"}
|
||||
|
|
@ -31,11 +59,34 @@
|
|||
(defn tab-click-listener
|
||||
"Set up a click listener on the tab with this `tab-id`"
|
||||
[tab-id]
|
||||
(dommy/set-text! (sel1 tab-id) (:text (tab-id available-tabs)))
|
||||
(dommy/listen! (sel1 tab-id) :click (fn [e] (tab-handler e tab-id))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Rules page
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn load-ruleset
|
||||
[name]
|
||||
)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Set up the screen on loading
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;; listeners for the tab bar
|
||||
(tab-click-listener :#home-tab)
|
||||
(tab-click-listener :#params-tab)
|
||||
(tab-click-listener :#rules-tab)
|
||||
(tab-click-listener :#world-tab)
|
||||
(tab-click-listener :#docs-tab)
|
||||
|
||||
;; hide controls which aren't needed if we're doing things client side
|
||||
(doseq [to-hide (sel :.hide-if-active)]
|
||||
(dommy/set-style! to-hide :display "none"))
|
||||
|
||||
;; hide all pages except home-tab
|
||||
(tab-handler nil :#home-tab)
|
||||
|
||||
;; put the default ruleset into the rulesets pages
|
||||
(dommy/set-text! (sel1 :#rules-src) (rulesets/ruleset-as-single-string "ice-age"))
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
;; Map of available rulesets. Key is a string name of the ruleset; value is a sequence of strings
|
||||
;; of rule text.
|
||||
|
||||
(def rulesets
|
||||
{"ice-age" [
|
||||
"# Ice Age"
|
||||
|
|
@ -30,3 +31,10 @@
|
|||
;; and, again, so on.
|
||||
]
|
||||
})
|
||||
|
||||
|
||||
(defn ruleset-as-single-string
|
||||
"Return the ruleset with this `name` as a single string."
|
||||
[name]
|
||||
(str (interleave (rulesets name) (repeat "\n"))))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue