Not much progress, here's some info on sailing

This commit is contained in:
2023-11-21 09:55:37 -06:00
parent fe9dd562ec
commit 781c06a987
3 changed files with 18 additions and 3 deletions

View File

@@ -8,10 +8,13 @@
(def hardcoded-wind [0.1 3.0]) ;; A strong easternly wind!
(defonce ships (atom []))
(defn list-ships
(defn ship-names
"Gets the names from a list of ships"
[ships]
(map #(:name @%) ships))
(defn find-ship
"Finds a ship with the given name"
[ships name]
(some #(when (= name (:name @%)) %) ships))
@@ -97,8 +100,8 @@
(defn ship-chooser
[]
(let [name (combobox :model (list-ships @ships))]
(b/bind ships (b/transform list-ships) (b/property name :model))
(let [name (combobox :model (ship-names @ships))]
(b/bind ships (b/transform ship-names) (b/property name :model))
(b/bind (b/selection name) (b/transform #(find-ship @ships %)) tracked-ship)
(flow-panel :items ["Ship Name" name])))