5 set ::windows::stats::isOpen 0
6 set ::windows::stats::like_graphyear 1
7 set ::windows::stats::like_graphelo 1
8 set ::windows::stats::old_year 0
9 set ::windows::stats::old_elo 0
10 set ::windows::stats::stat_year 0
11 set ::windows::stats::statelo 0
13 proc ::windows::stats::Open {} {
15 if {[
winfo exists $w]} {
18 set ::windows::stats::isOpen 0
24 wm title $w "Scid: $::tr(FilterStatistic)"
26 bind $w <Configure> "recordWinSize $w"
30 -foreground black -background white -font font_Fixed\
33 ttk::frame $w.fbuttons
34 ttk::button $w.fbuttons.print -image tb_save -command {
36 { "Text files" {".txt"} }
39 set fname [tk_getSaveFile -initialdir [pwd] -filetypes $ftype -title "Save text file"]
41 if {[catch {set tempfile [open $fname w]}]} {
42 tk_messageBox -title "Scid: Error saving file" -type ok -icon warning \
43 -message "Unable to save the file: $fname\n\n"
45 puts $tempfile [.statsWin.stats get 1.0 end-1c]
50 ttk::checkbutton $w.fbuttons.graphyear -text $::tr(Year) \
51 -variable ::windows::stats::like_graphyear -command ::windows::stats::refresh_wnd
52 ttk::checkbutton $w.fbuttons.graphelo -text $::tr(Rating) \
53 -variable ::windows::stats::like_graphelo -command ::windows::stats::refresh_wnd
54 ttk::checkbutton $w.fbuttons.statelo -text "StatElo" \
55 -variable ::windows::stats::statelo -command ::windows::stats::refresh_wnd
56 ttk::checkbutton $w.fbuttons.statyear -text "StatYear" \
57 -variable ::windows::stats::stat_year -command ::windows::stats::refresh_wnd
58 ttk::checkbutton $w.fbuttons.old_elo -text "OldElo" \
59 -variable ::windows::stats::old_elo -command ::windows::stats::refresh_wnd
60 ttk::checkbutton $w.fbuttons.oldyear -text "OldYear" \
61 -variable ::windows::stats::old_year -command ::windows::stats::refresh_wnd
63 ttk::button $w.fbuttons.setup -image tb_config -command configureFilterGraph
64 pack $w.fbuttons.graphyear $w.fbuttons.graphelo $w.fbuttons.statyear $w.fbuttons.statelo $w.fbuttons.oldyear $w.fbuttons.old_elo -side left
65 pack $w.fbuttons.setup $w.fbuttons.print -side right -padx "5 0" -pady 2
66 pack $w.fbuttons -side top -fill x
67 pack $w.statsasb -side top -fill both -expand yes
68 set ::windows::stats::isOpen 1
69 bind $w <Control-q> "destroy $w"
70 bind $w <Escape> "destroy $w"
71 bind $w <F1> { helpWindow Index }
73 set ::windows::stats::isOpen 0
82 proc ::windows::stats::Refresh {} {
86 proc ::windows::stats::refresh_wnd {} {
87 global FilterMaxMoves FilterMinMoves FilterStepMoves FilterMaxElo FilterMinElo FilterStepElo FilterMaxYear FilterMinYear FilterStepYear FilterGuessELO
90 if {! [
winfo exists .statsWin]} {
return}
94 set both $::tr(OprepStatBoth)
95 set since $::tr(OprepStatSince)
100 set alen [
expr {[string length $all] + 1}]
101 set blen [
expr {[string length $both] + 7}]
102 set slen [
expr {[string length $since] + 12}]
104 if {$len < $blen} {
set len $blen}
105 if {$len < $slen} {
set len $slen}
110 set rlist [lsort -decreasing [
array names display r*]]
111 set ylist [lsort [
array names display y*]]
114 if {$display($i)} {
set ratings 1}
117 if {$display($i)} {
set years 1}
120 if {$ratings} {
incr height}
121 if {$years} {
incr height}
128 append s "--------------------------------------------------------------"
133 if { $::windows::stats::like_graphelo } {
134 set endElo $FilterMaxElo
135 set startElo $FilterMinElo
136 for {
set i $startElo} {$i <= $endElo} {
set i [
expr {$i + $FilterStepElo}]} {
139 set nelo [
expr {$i+$FilterStepElo}]
142 if { $i < 100 } {
set i [
expr { 1800 - $FilterStepElo}]}
143 set stat "min. Elo $i-$nelo"
145 set stat "max. Elo $i-$nelo"
150 if {$::windows::stats::statelo && $ratings} {
153 set k [
lindex $rlist $j]
154 while { $k!= "" && ! $display($k) } {
156 set k [
lindex $ylist $j]
157 if { $k == "" } { break}
159 set nelo [
string range [
lindex $rlist $j] 1 end]
162 set stat "min. Elo $nelo-3500"
164 set stat "max. Elo $nelo-3500"
171 set elo [
string range $i 1 end]
173 set k [
lindex $rlist $l]
174 while { $k!= "" && ! $display($k) } {
176 set k [
lindex $rlist $l]
177 if { $k == "" } { break}
179 set nelo [
string range [
lindex $rlist $l] 1 end]
180 if { $nelo == "" } {
set nelo 0}
182 set stat "min. Elo $nelo-$elo"
184 set stat "max. Elo $nelo-$elo"
195 if { $::windows::stats::like_graphyear } {
196 set endYear $FilterMaxYear
197 set startYear $FilterMinYear
198 for {
set i $startYear} {$i <= $endYear} {
set i [
expr {$i + $FilterStepYear}]} {
200 set ie [
expr {$i+$FilterStepYear}]
205 if {$::windows::stats::stat_year && $years} {
212 set year [
string range $i 1 end]
214 set k [
lindex $ylist $l]
215 while { $k!= "" && ! $display($k) } {
217 set k [
lindex $ylist $l]
218 if { $k == "" } { break}
220 set nyear [
string range $k 1 end]
221 if { $nyear == "" } {
set nyear 2099}
222 set stat "$year - $nyear"
229 if { $::windows::stats::old_elo || $::windows::stats::old_year} {
233 append s "--------------------------------------------------------------"
236 if {$ratings && $::windows::stats::old_elo} {
241 set elo [
string range $i 1 end]
242 set stat "$both $elo+"
248 if {$years && $::windows::stats::old_year} {
253 set year [
string range $i 1 end]
254 set stat "$since $year.01.01"
261 set w .statsWin.stats
262 if { $height > 50 } {
set height 50}
263 $w configure -state normal
266 $w tag configure bgGray -background gray95
268 set lastLineNum [
expr {int([$w index end])}]
269 for {
set i 2} {$i <= $lastLineNum} {
incr i 2} {
270 $w tag add bgGray $i.0 "$i.0 lineend +1c"
272 $w tag configure blue -foreground darkBlue
273 $w tag configure red -foreground red
274 $w tag add blue 1.0 2.0
275 $w tag add red 2.0 3.0
276 $w configure -height $height
277 $w configure -state disabled