Skip to content

Commit

Permalink
Small fixes that somehow crop up on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
Deon Moolman committed Oct 18, 2021
1 parent 6139e10 commit 628d32f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 25 deletions.
4 changes: 2 additions & 2 deletions src/igoki/game.clj
Original file line number Diff line number Diff line change
Expand Up @@ -294,15 +294,15 @@
board-size (* cellsize (dec size))
extent (+ grid-start board-size)
tx (+ (lq/height) (/ cellsize 2))
visiblepath (take movenumber (mapcat identity (:current-branch-path game)))
visiblepath (take (or movenumber 0) (mapcat identity (:current-branch-path game)))
actionlist (sgf/current-branch-node-list [visiblepath] (:moves game))
lastmove (last actionlist)
canvas-size (max 250 (min (lq/width) (lq/height)))]

(lq/shadow-text (str "Recording: Img #" (:camidx game)) tx 25)
(when (:filename game)
(lq/shadow-text (:filename game) tx 50))
(lq/shadow-text (str "Move " (inc movenumber) ", " (if (= (:player-turn constructed) :black) "Black" "White") " to play") tx 75)
(lq/shadow-text (str "Move " (inc (or movenumber 0)) ", " (if (= (:player-turn constructed) :black) "Black" "White") " to play") tx 75)
(lq/shadow-text "<P> Pass" tx 225)


Expand Down
26 changes: 15 additions & 11 deletions src/igoki/simulated.clj
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,23 @@

(defn simulate []
(let [context @simctx]

(if (= (:mode context) :replay)
(swap! simctx
update :camera assoc
:raw (-> context :camera :raw)
:pimg (util/mat-to-pimage (-> context :camera :raw)
(-> context :camera :pimg :bufimg)))
(let [m (.clone (-> context :sim :background))]
(draw-board m)
(when (-> context :camera :raw)
(swap! simctx
update :camera assoc
:raw m
:pimg (util/mat-to-pimage m
(-> context :camera :pimg :bufimg)))))))
update :camera assoc
:raw (-> context :camera :raw)
:pimg (util/mat-to-pimage (-> context :camera :raw)
(-> context :camera :pimg :bufimg))))
(when (-> context :sim :background)
(let [m (.clone (-> context :sim :background))]
(draw-board m)
(swap! simctx
update :camera assoc
:raw m
:pimg
(util/mat-to-pimage m
(-> context :camera :pimg :bufimg))))))))


(defn next-stone [{:keys [next mode]}]
Expand Down
25 changes: 13 additions & 12 deletions src/igoki/ui.clj
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,19 @@
(doseq [l (:pre-read-listeners camera)]
(l ctx))

(.read video frame)

(doseq [l (:post-read-listeners camera)]
(l ctx))

(swap!
ctx update :camera
#(assoc %
:raw frame
;; TODO: this chows memory - better to have a hook on update for each specific
;; view - this will only be needed on the first screen.
:pimg (util/mat-to-pimage frame (get-in % [:pimg :bufimg])))))
(when
(.read video frame)

(doseq [l (:post-read-listeners camera)]
(l ctx))

(swap!
ctx update :camera
#(assoc %
:raw frame
;; TODO: this chows memory - better to have a hook on update for each specific
;; view - this will only be needed on the first screen.
:pimg (util/mat-to-pimage frame (get-in % [:pimg :bufimg]))))))
(Thread/sleep (or (-> @ctx :camera :read-delay) 1000))
(catch Exception e
(println "exception thrown")
Expand Down

0 comments on commit 628d32f

Please sign in to comment.