6 namespace eval ::plist {}
10 set ::plist::sort Name
12 proc ::plist::defaults {} {
14 set ::plist::minGames ""
15 set ::plist::maxGames ""
16 set ::plist::minElo ""
17 set ::plist::maxElo ""
23 trace variable ::plist::minElo w [list ::utils::validate::Integer [
sc_info limit elo] 0]
24 trace variable ::plist::maxElo w [list ::utils::validate::Integer [
sc_info limit elo] 0]
25 trace variable ::plist::minGames w [list ::utils::validate::Integer 9999 0]
26 trace variable ::plist::maxGames w [list ::utils::validate::Integer 9999 0]
28 proc ::plist::toggle {} {
30 if {[
winfo exists $w]} {
37 proc ::plist::Open {} {
39 if {[
winfo exists .plist]} {
return}
45 ttk::frame $w.t -relief sunken -borderwidth 1
46 text $w.t.text -width 55 -height 25 -font font_Small -wrap none \
47 -fg black -bg white -cursor top_left_arrow -borderwidth 0
49 set xwidth [font measure [$w.t.text cget -font] "0"]
51 foreach {tab justify} {4 r 10 r 18 r 24 r 32 r 35 l} {
52 set tabwidth [
expr {$xwidth * $tab}]
53 lappend tablist $tabwidth $justify
55 $w.t.text configure -tabs $tablist
56 $w.t.text tag configure ng -foreground darkBlue
57 $w.t.text tag configure date -foreground darkRed
58 $w.t.text tag configure elo -foreground darkGreen
59 $w.t.text tag configure name -foreground black
60 $w.t.text tag configure title -background lightSteelBlue
63 set fbold font_SmallBold
67 ttk::label $f.nlabel -text $::tr(Player:) -font $fbold
68 ttk::combobox $f.name -textvariable ::plist::name -width 20
72 ttk::label $f.size -text $::tr(TmtLimit:) -font $fbold
73 ttk::combobox $f.esize -width 4 -justify right -textvar ::plist::size -values {50 100 200 500 1000}
74 trace variable ::plist::size w {::utils::validate::Integer 1000 0}
79 pack $f.esize -side right -padx "0 8" -pady 2
80 pack $f.size -side right -pady 2
81 pack $f.nlabel -side left -padx "8 0" -pady 2
82 pack $f.name -side left -pady 2
86 ttk::label $f.elo -text "[
tr PListSortElo]:" -font $fbold
87 ttk::entry $f.emin -textvariable ::plist::minElo
88 ttk::label $f.eto -text "-"
89 ttk::entry $f.emax -textvariable ::plist::maxElo
90 ttk::label $f.games -text "[
tr PListSortGames]:" -font $fbold
91 ttk::entry $f.gmin -textvariable ::plist::minGames
92 ttk::label $f.gto -text "-"
93 ttk::entry $f.gmax -textvariable ::plist::maxGames
95 foreach entry {emin emax} {
96 $f.$entry configure -width 4 -justify right -font $font
100 foreach entry {gmin gmax} {
101 $f.$entry configure -width 6 -justify right -font $font
105 pack $f.elo -side left -padx "8 0"
106 pack $f.emin $f.eto $f.emax -side left
107 pack $f.gmax -side right -padx "0 8"
108 pack $f.gto $f.gmin $f.games -side right
111 dialogbutton $w.b.defaults -text $::tr(Defaults) -command ::plist::defaults
112 dialogbutton $w.b.update -text $::tr(Search) -command ::plist::refresh
116 grid $w.o1 -sticky news
117 grid $w.o2 -sticky news
118 grid $w.b -sticky news
119 grid $w.t -sticky news
120 grid rowconfigure $w 3 -weight 1
121 grid columnconfigure $w 0 -weight 1
123 bind $w <F1> {helpWindow PList}
124 bind $w.t <Destroy> { set plistWin 0 }
125 bind $w <Return> ::plist::refresh
130 proc ::plist::refresh {} {
132 if {! [
winfo exists $w]} {
return}
137 $t configure -state normal
140 $t insert end "\t" title
141 foreach i {Games Oldest Newest Elo Name} {
142 $t tag configure s$i -font font_SmallBold
143 $t tag bind s$i <1> "set ::plist::sort $i; ::plist::refresh"
144 $t tag bind s$i <Any-Enter> "$t tag config s$i -foreground red"
145 $t tag bind s$i <Any-Leave> "$t tag config s$i -foreground {}"
146 $t insert end "\t" title
147 $t insert end [
tr PListSort$i] [list title s$i]
149 $t insert end "\n" title
156 $t insert end "\n$pdata\n"
163 foreach player $pdata {
165 set ng [
lindex $player 0]
166 set oldest [
lindex $player 1]
167 set newest [
lindex $player 2]
168 set elo [
lindex $player 3]
169 set name [
lindex $player 4]
171 $t tag bind p$count <ButtonPress-1> [list ::pinfo::playerInfo $name]
173 $t tag bind p$count <Any-Enter> \
174 "$t tag configure p$count -background $hc"
175 $t tag bind p$count <Any-Leave> \
176 "$t tag configure p$count -background {}"
178 $t insert end "\t$count\t" p$count
179 $t insert end $ng [list ng p$count]
180 $t insert end "\t" p$count
181 $t insert end $oldest [list date p$count]
182 $t insert end "\t" p$count
183 $t insert end "- $newest" [list date p$count]
184 $t insert end "\t" p$count
185 $t insert end $elo [list elo p$count]
186 $t insert end "\t" p$count
187 $t insert end $name [list name p$count]
190 $t configure -state disabled
194 proc ::plist::check {} {
195 if { $::plist::maxGames ne "" && $::plist::minGames > $::plist::maxGames} {
196 set help $::plist::maxGames
197 set ::plist::maxGames $::plist::minGames
198 set ::plist::minGames $help
200 if {$::plist::maxElo ne "" && $::plist::minElo > $::plist::maxElo} {
201 set help $::plist::maxElo
202 set ::plist::maxElo $::plist::minElo
203 set ::plist::minElo $help
207 proc ::plist::getSearchOptions {} {
209 if {$::plist::name ne ""} {
210 lappend options "-name" $::plist::name
212 if {$::plist::size ne ""} {
213 lappend options "-size" $::plist::size
215 if {$::plist::minGames ne ""} {
216 lappend options "-minGames" $::plist::minGames
218 if {$::plist::maxGames ne ""} {
219 lappend options "-maxGames" $::plist::maxGames
221 if {$::plist::minElo ne ""} {
222 lappend options "-minElo" $::plist::minElo
224 if {$::plist::maxElo ne ""} {
225 lappend options "-maxElo" $::plist::maxElo
227 if {$::plist::sort ne ""} {
228 lappend options "-sort" [
string tolower $::plist::sort]