5 namespace eval ::gbrowser {}
7 proc ::gbrowser::new {base gnum {ply -1}} {
8 if {! [
info exists ::gbrowser::size] } {
set ::gbrowser::size 65}
12 while {[
winfo exists .gb$n]} {
incr n}
15 if {$base < 1} {
set base [
sc_base current]}
16 if {$gnum < 1} {
set game [
sc_game number]}
17 set filename [
file tail [
sc_base filename $base]]
18 wm title $w "Scid: $::tr(BrowseGame) ($filename: $gnum)"
19 set header [
sc_game summary -base $base -game $gnum header]
20 set ::gbrowser::boards($n) [
sc_game summary -base $base -game $gnum boards]
21 set moves [
sc_game summary -base $base -game $gnum moves]
23 pack [ttk::frame $w.b] -side bottom -fill x
25 pack $w.bd -side left -padx 4 -pady 4
35 -foreground black -background white -wrap word \
36 -width 45 -height 12 -font font_Small -setgrid 1
37 pack $w.t -side right -fill both -expand yes
40 event generate $t <ButtonRelease-1>
41 $t tag configure header -foreground darkBlue
42 $t tag configure next -foreground yellow -background darkBlue
43 $t insert end "$header" header
49 $t insert end [
::trans $i] $moveTag
51 $t tag bind $moveTag <ButtonRelease-1> "::gbrowser::update $n $m"
52 $t tag bind $moveTag <Any-Enter> \
53 "$t tag configure $moveTag -foreground red
54 $t configure -cursor hand2"
55 $t tag bind $moveTag <Any-Leave> \
56 "$t tag configure $moveTag -foreground {}
57 $t configure -cursor {}"
60 bind $w <F1> {helpWindow GameList Browsing}
61 bind $w <Escape> "destroy $w"
62 bind $w <Home> "::gbrowser::update $n start"
63 bind $w <End> "::gbrowser::update $n end"
64 bind $w <Left> "::gbrowser::update $n -1"
65 bind $w <Right> "::gbrowser::update $n +1"
66 bind $w <Up> "::gbrowser::update $n -10"
67 bind $w <Down> "::gbrowser::update $n +10"
68 bind $w <minus> {set ::gbrowser::size [::board::resize %W.bd -1]}
69 bind $w <Control-Shift-Left> {set ::gbrowser::size [::board::resize %W.bd -1]}
70 bind $w <plus> {set ::gbrowser::size [::board::resize %W.bd +1]}
71 bind $w <Control-Shift-Right> {set ::gbrowser::size [::board::resize %W.bd +1]}
74 ttk::button $w.b.start -image tb_start -command "::gbrowser::update $n start"
75 ttk::button $w.b.back -image tb_prev -command "::gbrowser::update $n -1"
76 ttk::button $w.b.forward -image tb_next -command "::gbrowser::update $n +1"
77 ttk::button $w.b.end -image tb_end -command "::gbrowser::update $n end"
78 ttk::frame $w.b.gap -width 3
79 ttk::button $w.b.autoplay -image tb_play -command "::gbrowser::autoplay $n"
80 ttk::frame $w.b.gap2 -width 3
81 ttk::button $w.b.flip -image tb_flip -command "::gbrowser::flip $n"
83 pack $w.b.start $w.b.back $w.b.forward $w.b.end $w.b.gap \
84 $w.b.autoplay $w.b.gap2 $w.b.flip -side left -padx 3 -pady 1
86 set ::gbrowser::autoplay($n) 0
89 ttk::button $w.b.load -textvar ::tr(LoadGame) -command "sc_base switch $base; ::game::Load $gnum"
90 ttk::button $w.b.merge -textvar ::tr(MergeGame) -command "mergeGame $base $gnum"
92 ttk::button $w.b.close -textvar ::tr(Close) -command "destroy $w"
93 pack $w.b.close -side right -padx 1 -pady 1
95 pack $w.b.merge $w.b.load -side right -padx 1 -pady 1
110 proc gbrowser::mousewheelHandler {n direction} {
111 if {$direction < 0} {
118 proc ::gbrowser::flip {n} {
122 proc ::gbrowser::update {n ply} {
124 if {! [
winfo exists $w]} {
return}
126 if {[
info exists ::gbrowser::ply($n)]} {
set oldply $::gbrowser::ply($n)}
127 if {$ply == "forward"} {
set ply [
expr {$oldply + 1}]}
128 if {$ply == "back"} {
set ply [
expr {$oldply - 1}]}
129 if {$ply == "start"} {
set ply 0}
130 if {$ply == "end"} {
set ply 9999}
131 if {[
string index $ply 0] == "-" || [
string index $ply 0] == "+"} {
132 set ply [
expr {$oldply + $ply}]
134 if {$ply < 0} {
set ply 0}
135 set max [
expr {[llength $::gbrowser::boards($n)] - 1}]
136 if {$ply > $max} {
set ply $max}
137 set ::gbrowser::ply($n) $ply
141 $t configure -state normal
142 set moveRange [$t tag nextrange m$ply 1.0]
143 $t tag remove next 1.0 end
144 set moveRange [$t tag nextrange m$ply 1.0]
145 if {[
llength $moveRange] == 2} {
146 $t tag add next [
lindex $moveRange 0] [
lindex $moveRange 1]
147 $t see [
lindex $moveRange 0]
149 $t configure -state disabled
151 if {$::gbrowser::autoplay($n)} {
155 after cancel "::gbrowser::update $n +1"
156 after $::autoplayDelay "::gbrowser::update $n +1"
161 proc ::gbrowser::autoplay {n} {
162 if {$::gbrowser::autoplay($n)} {
163 set ::gbrowser::autoplay($n) 0
164 .gb$n.b.autoplay configure -image tb_play
167 set ::gbrowser::autoplay($n) 1
168 .gb$n.b.autoplay configure -image tb_stop