\ VP-statsui
\ Display of statistics
\ 
\ $Id: VP-statsui.txt,v 1.1 2000/10/25 01:02:57 kris_johnson Exp $

\ Copyright 2000
\ Kristopher D. Johnson
\ 
\ See LICENSE-JacksOrBetter for the
\ conditions under which you may
\ use, redistribute, or modify this 
\ code, or create derived works.

docneeds VP-stats
docneeds VP-alerts

.( VP-statsui... )

: +lf   zlf append ;

\ Append linefeed and indent
: +lfin   +lf s"    " append ;

: +tab   ztab append ;

: +dnum ( cadr u1 ud. -- cadr u2 )
  <# #s #> append ;

: +num ( cadr u1 uNum -- cadr u2 )
  s>d +dnum ;

: +Games   s" Games:" append ;

: +Hands   s" Hands:" append ;

: +Bet   s" Bet:" append ;

: +Payout   s" Payout:" append ;

: +totals-string ( cadr u1 -- cadr u2 )
  s" All Games:" append
  +lfin +Games
  +tab gamesPlayed 2@ +dnum
  +lfin +Hands
  +tab totalHands 2@ +dnum
  +lfin +Bet
  +tab +tab totalBet 2@ +dnum
  +lfin +Payout
  +tab totalPayout 2@ +dnum
  +lfin s" Max Chips:" append
  +tab highChips @ +num
;

: +game-stats-string ( cadr u1 -- cadr u2 )
  s" Current Game:" append
  +lfin +Hands
  +tab gameHands 2@ +dnum
  +lfin +Bet
  +tab +tab gameBet 2@ +dnum
  +lfin +Payout
  +tab gamePayout 2@ +dnum
;

create stats-buf   256 cells allot

\ Generate string
\ (uses HERE as buffer)
: stats-string ( -- cadr u )
  stats-buf 0
  +game-stats-string
  +lf
  +totals-string
;

: handle-reset ( -- )
  altConfirmReset FrmAlert
  btnYes = if
    init-stats
  then
;

\ Show Statistics window
: show-stats ( -- )
  stats-string 2dup zterm
  altStatistics custom-alert1
  btnReset = if
    handle-reset
  then
;

