Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;;;;;;; project.clj
- (defproject AF "1.0.0-SNAPSHOT"
- :description "TODO"
- :dependencies [
- [org.clojure/clojure "1.3.0"]
- [seesaw "1.4.1"]
- [com.github.insubstantial/substance "7.1"]
- ]
- :dev-dependencies [
- [lein-eclipse "1.0.0"]
- ]
- :main AF.core
- )
- ;;;;;;; end of project.cj
- ;;;;;;; core.clj
- (ns AF.core
- (:use seesaw.core)
- (:import org.pushingpixels.substance.api.SubstanceLookAndFeel)
- (:import org.pushingpixels.substance.api.SubstanceConstants$FocusKind)
- (:gen-class))
- (native!)
- (def f (frame :title "Ascendant Force" :on-close :exit :size [600 :by 600]))
- (defn display [content]
- (config! f :content content)
- content)
- (def shades ["#000" "#333" "#666" "#999" "#CCC"])
- (def lightest "#fff")
- (def dimen [90 :by 90])
- (defn make-box
- ([shade-index] (button :background (shades shade-index) :size dimen))
- ([shade-index phrase] (button
- :id (keyword phrase)
- :background (shades shade-index)
- :foreground lightest
- :listen [
- ; :mouse-pressed #(config! % :background "#66F" :foreground "#000")
- :mouse-entered #(config! % :foreground (shades shade-index))
- :mouse-exited #(config! % :foreground lightest)]
- :action (action :handler (fn [e] (config! (.getSource e) :background "#00F" :foreground lightest) (alert (str "Clicked " phrase)))
- :name @phrase))))
- (def dodge (ref (str "<html>" "Dodge" "<br>")))
- (def control (ref (str "<html>" "Control" "<br>")))
- (def shield (ref (str "<html>" "Shield" "<br>")))
- (def endure (ref (str "<html>" "Endure" "<br>")))
- (defn rename-button ([btn txtref] (config! btn :text @txtref))
- ([btn txtref txt2] (dosync (ref-set txtref (str @txtref txt2))(config! btn :text @txtref))))
- (defn shaded-boxes []
- [
- (make-box 0 dodge) (make-box 1) (make-box 2) (make-box 2) (make-box 1) (make-box 0 control)
- (make-box 1) (make-box 2) (make-box 3) (make-box 3) (make-box 2) (make-box 1)
- (make-box 2) (make-box 3) (make-box 4) (make-box 4) (make-box 3) (make-box 2)
- (make-box 2) (make-box 3) (make-box 4) (make-box 4) (make-box 3) (make-box 2)
- (make-box 1) (make-box 2) (make-box 3) (make-box 3) (make-box 2) (make-box 1)
- (make-box 0 shield) (make-box 1) (make-box 2) (make-box 2) (make-box 1) (make-box 0 endure)
- ])
- (defn griddy []
- (let [boxes (shaded-boxes)]
- (config! (boxes 0) :action (action :handler (fn [e] (config! (.getSource e) :background "#00F" :foreground "#fff"); (alert (str "Clicked " "Dodge"))
- (config! (boxes 5) :background (shades 0)); (boxes 5))
- (config! (boxes 30) :background (shades 0)); (boxes 30))
- (config! (boxes 35) :background (shades 0))); (boxes 35)))
- :name "Dodge"))
- (config! (boxes 5) :action (action :handler (fn [e] (config! (.getSource e) :background "#00F" :foreground "#fff"); (alert (str "Clicked " "Control"))
- (config! (boxes 0) :background (shades 0)); (boxes 0))
- (config! (boxes 30) :background (shades 0)); (boxes 30))
- (config! (boxes 35) :background (shades 0))); (boxes 35)))
- :name "Control"))
- (config! (boxes 30) :action (action :handler (fn [e] (config! (.getSource e) :background "#00F" :foreground "#fff"); (alert (str "Clicked " "Shield"))
- (config! (boxes 0) :background (shades 0)); (boxes 0))
- (config! (boxes 5) :background (shades 0)); (boxes 5))
- (config! (boxes 35) :background (shades 0))); (boxes 35)))
- :name "Shield"))
- (config! (boxes 35) :action (action :handler (fn [e] (config! (.getSource e) :background "#00F" :foreground "#fff"); (alert (str "Clicked " "Endure"))
- (config! (boxes 0) :background (shades 0)); (boxes 0))
- (config! (boxes 5) :background (shades 0)); (boxes 5))
- (config! (boxes 30) :background (shades 0))); (boxes 30)))
- :name "Endure"))
- (grid-panel
- :id :the-grid
- :border [10 10]
- :hgap 1
- :vgap 1
- :columns 6
- :items boxes )))
- (def skills {"Fiery Barrage" {:desc "An artillery-like bombardment by explosive shells." :target 21}
- "Freezing Shot" {:desc "A shot that encases anyone it hits in ice." :target 29}})
- (def defenders {"John" {:desc "A boy who's much stronger than he looks; can control the wind." :dodge 3 :control 4 :shield 2 :endure 5}
- "Rose" {:desc "A nimble magician who dabbles in dangerous studies." :dodge 4 :control 5 :shield 3 :endure 2}
- "Dave" {:desc "A talented swordsman with amazing agility." :dodge 5 :control 2 :shield 4 :endure 3}
- "Jade" {:desc "A canny sniper whose camouflage is aided by her endurance." :dodge 2 :control 3 :shield 5 :endure 4}})
- (defn prime []
- (display (border-panel
- :id :brdr
- :vgap 5 :hgap 5 :border 5
- :center (griddy)
- :east (vertical-panel :items [(combobox :id :skill-combo :size [200 :by 32] :model (keys skills)
- :listen [:selection (fn [e] (config! (select (to-root f) [:#skill-desc]) :text ((skills (selection e)) :desc))
- (remove! (select (to-root f) [:#brdr]) (select (to-root f) [:#the-grid]))
- (config! (select (to-root f) [:#brdr]) :center (griddy))
- (config! (nth (config (select (to-root f) [:#the-grid]) :items) ((skills (selection e)) :target)) :background "#f33"))])
- (separator :orientation :horizontal :size [200 :by 10])
- (text :id :skill-desc :size [200 :by 500] :editable? false :multi-line? true :wrap-lines? true :text "")
- ]
- )
- :west (vertical-panel :items [(combobox :id :char-combo :size [200 :by 32] :model (keys defenders)
- :listen [:selection (fn [e] (config! (select (to-root f) [:#defender-desc]) :text ((defenders (selection e)) :desc))
- (rename-button (select (to-root f) [:#Dodge]) dodge ((defenders (selection e)) :dodge))
- (rename-button (select (to-root f) [:#Control]) control ((defenders (selection e)) :control))
- (rename-button (select (to-root f) [:#Shield]) shield ((defenders (selection e)) :shield))
- (rename-button (select (to-root f) [:#Endure]) endure ((defenders (selection e)) :endure)))])
- (separator :orientation :horizontal :size [200 :by 10])
- (text :id :defender-desc :size [200 :by 500] :editable? false :multi-line? true :wrap-lines? true :text "")
- ]
- )
- ))
- (-> f pack! show!))
- (defn -main [& args]
- (invoke-later
- (javax.swing.UIManager/setLookAndFeel "org.pushingpixels.substance.api.skin.SubstanceGraphiteLookAndFeel")
- (javax.swing.UIManager/put SubstanceLookAndFeel/FOCUS_KIND SubstanceConstants$FocusKind/NONE)
- (prime)
- ))
- ;;;;;;;end of core.clj
Advertisement
Add Comment
Please, Sign In to add comment