add clicks-per-second counter

This commit is contained in:
kiefac 2024-04-25 09:08:12 -04:00
parent f16927e356
commit 0c50c59d75

View file

@ -19,6 +19,12 @@
[parent left-side]
[label (click-str)]
[auto-resize #t]))
(define cps 0)
(define (cps-str) (~a "Auto-clicks per second: " cps))
(define cps-msg (new message%
[parent left-side]
[label (cps-str)]
[auto-resize #t]))
; helper procedure
(define-syntax-rule (new-inc-button container name counter)
@ -57,10 +63,13 @@
(define timer (new timer% [interval 100]
[notify-callback
(λ ()
(when (= 0 (modulo timer-ctr 10))
(for ([cl all-clickers])
(set! clicks (+ clicks (* (clicker-multiplier cl) (clicker-count cl))))))
(set! cps 0)
(for ([cl all-clickers])
(when (= 0 (modulo timer-ctr 10))
(set! clicks (+ clicks (* (clicker-multiplier cl) (clicker-count cl)))))
(set! cps (+ cps (* (clicker-multiplier cl) (clicker-count cl)))))
(send click-msg set-label (click-str))
(send cps-msg set-label (cps-str))
(set! timer-ctr (add1 timer-ctr)))]))
; show frame