Skip to content

Commit

Permalink
use the new rich-text-display in a few places
Browse files Browse the repository at this point in the history
  • Loading branch information
benknoble committed Jan 7, 2024
1 parent 434d9e5 commit 1fffc00
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
5 changes: 3 additions & 2 deletions gui/manager.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
frosthaven-manager/gui/monsters
frosthaven-manager/gui/render
frosthaven-manager/gui/rewards
frosthaven-manager/gui/round-prompts)
frosthaven-manager/gui/round-prompts
frosthaven-manager/gui/rich-text-display)

(define (manager s)
(define @undo (make-undo s))
Expand Down Expand Up @@ -148,7 +149,7 @@
(cond-view
[(@> @error-text non-empty-string?)
(hpanel (text "Error message:" #:color "red")
(input @error-text #:style '(multiple)))]
(rich-text-display (@> @error-text list) #:min-size '(#f 60)))]
[else (spacer)]))
(hpanel #:stretch '(#t #f)
#:alignment '(center center)
Expand Down
23 changes: 15 additions & 8 deletions gui/monsters.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
frosthaven-manager/gui/font
frosthaven-manager/gui/helpers
frosthaven-manager/gui/table
frosthaven-manager/gui/rich-text-display

frosthaven-manager/defns
frosthaven-manager/manager
Expand Down Expand Up @@ -107,7 +108,8 @@
(~a "Swap to ")))
on-swap)
(vpanel
(text (@~> @monster (~> monster-conditions conditions->string)))
(rich-text-display (@~> @monster (~> monster-conditions conditions->string list))
#:min-size '(50 30))
(button "Edit Conditions" show-conditions))))

(define (monster-group-view @mg @ability-deck @monster-num @env
Expand Down Expand Up @@ -261,15 +263,23 @@
(monsters))])))

(define (monster-ability-view @ability @mg @env)
(vpanel
(text (@~> @ability (~> monster-ability-name->text escape-text)))
(hpanel
(rich-text-display
(obs-combine
(λ (ability mg env)
(list*
(monster-ability-name->text ability) newline
(append*
(for/list ([ability-text (if ability (monster-ability-abilities ability) empty)])
(list ((monster-ability-ability->text ability-text) mg env) newline)))))
@ability @mg @env)
#:min-size '(200 60))
(observable-view
@ability
(λ (ability)
(apply vpanel
(for/list ([ability-text (if ability (monster-ability-abilities ability) empty)])
(hpanel (ability->text @mg ability-text @env)
(ability->extras @mg @ability ability-text))))))))
(ability->extras @mg @ability ability-text)))))))

;; TODO: should be able to manipulate individual HP (? dialog with counter)
;; Takes a non-observable info-db b/c instantiated by a thunk in
Expand Down Expand Up @@ -575,9 +585,6 @@
[monster-name (in-hash-keys monster-name->monster-info)])
(string-length monster-name))))

(define (ability->text @mg ability @env)
(text (obs-combine (flow (~> (esc (monster-ability-ability->text ability)) escape-text)) @mg @env)))

(define (aoe-button pict)
(button "AoE" (thunk
(with-closing-custodian/eventspace
Expand Down
9 changes: 6 additions & 3 deletions gui/player-info.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
frosthaven-manager/gui/render
frosthaven-manager/gui/mixins
frosthaven-manager/gui/font
frosthaven-manager/gui/helpers)
frosthaven-manager/gui/helpers
frosthaven-manager/gui/rich-text-display)

(define (player-input-views @num-players
#:on-name [on-name void]
Expand Down Expand Up @@ -119,7 +120,8 @@
(map make-condition-checkbox conditions)))))
(define conditions-panel
(vpanel
(text (@~> @player (~> player-conditions* conditions->string)))
(rich-text-display (@~> @player (~> player-conditions* conditions->string list))
#:min-size '(50 30))
(button "Edit Conditions" show-conditions)))
(define add-summon-button
(button "Summon" (thunk (do-summon add-summon))))
Expand Down Expand Up @@ -177,7 +179,8 @@
(button "💀Kill💀" die)
(text (escape-text (summon-name s)))
(counter (summon->hp-text s) add-hp subtract-hp)
(text (~> (s) summon-conditions* conditions->string))
(rich-text-display (~> (s) summon-conditions* conditions->string list)
#:min-size '(50 30))
(button "Edit Conditions" edit-conditions)))

(define (do-summon add-summon)
Expand Down

0 comments on commit 1fffc00

Please sign in to comment.