add tabs for builtin clickers and user-definable clickers [WIP]
This commit is contained in:
parent
0c50c59d75
commit
ca6b5dba77
61
clicket.rkt
61
clicket.rkt
|
@ -3,14 +3,30 @@
|
||||||
; setup main frame layout
|
; setup main frame layout
|
||||||
(define frame (new (class frame% (super-new)
|
(define frame (new (class frame% (super-new)
|
||||||
(define/augment (on-close)
|
(define/augment (on-close)
|
||||||
(send timer stop)))
|
(send timer stop))) ;on release - change to (exit)?
|
||||||
[label "Clicket"]
|
[label "Clicket"]
|
||||||
[border 5]))
|
[border 5]))
|
||||||
(define panel (new horizontal-panel%
|
(define panel (new horizontal-panel%
|
||||||
[parent frame]
|
[parent frame]
|
||||||
[spacing 15]))
|
[spacing 15]))
|
||||||
(define left-side (new vertical-pane% [parent panel]))
|
(define left-side (new vertical-pane% [parent panel]))
|
||||||
(define right-side (new vertical-pane% [parent panel]))
|
|
||||||
|
; janky terrible tab switcher, only works for two tabs, do not copy this
|
||||||
|
(define selected-tab #t)
|
||||||
|
(define (switch-tab tp e)
|
||||||
|
(send tp change-children
|
||||||
|
(λ (c)
|
||||||
|
(if selected-tab
|
||||||
|
(list builtins)
|
||||||
|
(list definitions))))
|
||||||
|
(set! selected-tab (not selected-tab)))
|
||||||
|
(define right-side (new tab-panel% [parent panel]
|
||||||
|
[choices '("Builtins" "Definitions")]
|
||||||
|
[callback switch-tab]))
|
||||||
|
(define builtins (new vertical-panel% [parent right-side]))
|
||||||
|
(define definitions (new vertical-panel% [parent right-side]))
|
||||||
|
(define tabs (list builtins definitions))
|
||||||
|
(switch-tab right-side #f)
|
||||||
|
|
||||||
; setup click var and associated display text
|
; setup click var and associated display text
|
||||||
(define clicks 0)
|
(define clicks 0)
|
||||||
|
@ -26,19 +42,18 @@
|
||||||
[label (cps-str)]
|
[label (cps-str)]
|
||||||
[auto-resize #t]))
|
[auto-resize #t]))
|
||||||
|
|
||||||
; helper procedure
|
; helper procedures
|
||||||
(define-syntax-rule (new-inc-button container name counter)
|
(define-syntax-rule (new-inc-button container name counter)
|
||||||
(new button% [parent container]
|
(new button% [parent container]
|
||||||
[label name]
|
[label name]
|
||||||
[callback (λ (b e) (set! counter (add1 counter)))]))
|
[callback (λ (b e) (set! counter (add1 counter)))]))
|
||||||
; assume we're placing all buy buttons in the right-side container
|
(define-syntax-rule (new-buy-button tab cl)
|
||||||
(define-syntax-rule (new-buy-button cl)
|
(let* ([button-panel (new horizontal-panel% [parent tab])]
|
||||||
(let* ([button-pane (new horizontal-pane% [parent right-side])]
|
|
||||||
[counter-msg (new message%
|
[counter-msg (new message%
|
||||||
[parent button-pane]
|
[parent button-panel]
|
||||||
[label "Owned: 0"]
|
[label "Owned: 0"]
|
||||||
[auto-resize #t])])
|
[auto-resize #t])])
|
||||||
(new button% [parent button-pane]
|
(new button% [parent button-panel]
|
||||||
[label (~a "Buy " (clicker-name cl) " (" (clicker-price cl) "¢)")]
|
[label (~a "Buy " (clicker-name cl) " (" (clicker-price cl) "¢)")]
|
||||||
[callback (λ (b e)
|
[callback (λ (b e)
|
||||||
(when (>= clicks (clicker-price cl))
|
(when (>= clicks (clicker-price cl))
|
||||||
|
@ -56,7 +71,35 @@
|
||||||
(clicker "mouse" 10 1 0)
|
(clicker "mouse" 10 1 0)
|
||||||
(clicker "coder" 150 5 0)
|
(clicker "coder" 150 5 0)
|
||||||
(clicker "paren farm" 1000 10 0)))
|
(clicker "paren farm" 1000 10 0)))
|
||||||
(for ([cl all-clickers]) (new-buy-button cl))
|
(for ([cl all-clickers]) (new-buy-button builtins cl))
|
||||||
|
|
||||||
|
; define your own clickers
|
||||||
|
(define definer-panel (new group-box-panel%
|
||||||
|
[parent definitions]
|
||||||
|
[label "Define custom clicker"]))
|
||||||
|
(define name-field (new text-field%
|
||||||
|
[parent definer-panel]
|
||||||
|
[label "Name"]
|
||||||
|
[style '(single vertical-label)]))
|
||||||
|
(define clicks-field (new text-field%
|
||||||
|
[parent definer-panel]
|
||||||
|
[label "Clicks per second"]
|
||||||
|
[style '(single vertical-label)]))
|
||||||
|
(define price-panel (new group-box-panel%
|
||||||
|
[parent definer-panel]
|
||||||
|
[label "Prices"]))
|
||||||
|
(define init-price (new message%
|
||||||
|
[parent price-panel]
|
||||||
|
[label "Init price: 0"]
|
||||||
|
[auto-resize #t]))
|
||||||
|
(define cl-price (new message%
|
||||||
|
[parent price-panel]
|
||||||
|
[label "Clicker price: 0"]
|
||||||
|
[auto-resize #t]))
|
||||||
|
(new button% [parent definer-panel]
|
||||||
|
[label "Define"])
|
||||||
|
; TODO implement callback
|
||||||
|
|
||||||
|
|
||||||
; setup timer
|
; setup timer
|
||||||
(define timer-ctr 0)
|
(define timer-ctr 0)
|
||||||
|
|
Loading…
Reference in a new issue