8 proc ::game::Clear {} {
10 if {$confirm == 0} {
return "cancel"}
22 proc ::game::Strip {type} {
24 if {[
catch {
sc_game strip $type} result]} {
25 tk_messageBox -parent . -type ok -icon info -title "Scid" -message $result
34 proc ::game::TruncateBegin {} {
36 if {[
catch {
sc_game truncate -start} result]} {
37 tk_messageBox -parent . -type ok -icon info -title "Scid" -message $result
46 proc ::game::Truncate {} {
48 if {[
catch {
sc_game truncate} result]} {
49 tk_messageBox -parent . -type ok -icon info -title "Scid" -message $result
61 proc ::game::LoadNextPrev {action} {
73 proc ::game::Reload {} {
75 if {[
sc_game number] < 1} {
return}
83 proc ::game::LoadRandom {} {
87 if {$ngames == 0} {
return}
88 set r [
expr {(int (rand() * $ngames))}]
89 set gnumber [
sc_base gameslist $db $r 1 $filter N+]
98 proc ::game::LoadMenu {w base gnum x y} {
100 if {! [
winfo exists $m]} {
102 $m add command -label $::tr(BrowseGame)
103 $m add command -label $::tr(LoadGame)
104 $m add command -label $::tr(MergeGame)
106 $m entryconfigure 0 -command "::gbrowser::new $base $gnum"
107 $m entryconfigure 1 -command "::file::SwitchToBase $base 0; ::game::Load $gnum"
108 $m entryconfigure 2 -command "mergeGame $base $gnum"
109 event generate $w <ButtonRelease-1>
111 event generate $m <ButtonPress-1>
119 set ::game::moveEntryNumber ""
120 trace variable ::game::moveEntryNumber w {::utils::validate::Regexp {^[0-9]*$}}
126 proc ::game::GotoMoveNumber {} {
127 set ::game::moveEntryNumber ""
128 set w [
toplevel .mnumDialog]
129 wm title $w "Scid: [
tr GameGotoMove]"
131 set f [ttk::frame $w.f]
134 ttk::label $f.label -text $::tr(GotoMoveNumber)
135 pack $f.label -side top -pady 5 -padx 5
137 ttk::entry $f.entry -width 8 -textvariable ::game::moveEntryNumber
138 bind $f.entry <Escape> { .mnumDialog.f.buttons.cancel invoke }
139 bind $f.entry <Return> { .mnumDialog.f.buttons.load invoke }
140 pack $f.entry -side top -pady 5
142 set b [ttk::frame $f.buttons]
143 pack $b -side top -fill x
145 grab release .mnumDialog
146 if {$::game::moveEntryNumber > 0} {
147 catch {sc_move ply [expr {($::game::moveEntryNumber - 1) * 2}]}
155 grab release .mnumDialog
161 set x [
expr {[winfo width .] / 4 + [winfo rootx .] }]
162 set y [
expr {[winfo height .] / 4 + [winfo rooty .] }]
163 wm geometry $w "+$x+$y"
172 proc ::game::mergeInBase { srcBase destBase gnum } {
191 proc ::game::Load { selection {ply ""} } {
193 if {$confirm == 0} {
return 0}
197 if {[
catch {
sc_game load $selection}]} {
202 if {$ply != ""} {
eval "sc_move ply $ply"}
204 set extraTags [
sc_game tag get Extra]
205 regexp {FlipB "([01])"\n} $extraTags -> flipB
206 if {![
info exists flipB]} {
set flipB -1}
224 proc ::game::ConfirmDiscard {} {
225 if {! [
sc_game altered]} {
return 3}
230 set fname [
file tail [
sc_base filename $::curr_db]]
233 if {[
string equal " - \n" $players]} {
set players ""}
235 set w .confirmDiscard
238 wm title $w "Scid: [
tr Save]"
241 ttk::label $w.msg.image -image tb_iconSave
242 ttk::frame $w.msg.txt
243 ttk::label $w.msg.txt.l1 -text "$players$fname: [
tr game] $gnum" -relief groove
244 ttk::label $w.msg.txt.l2 -text $::tr(ClearGameDialog) -wraplength 360 -font font_Bold -justify left
245 grid $w.msg.txt.l1 -row 0 -sticky news -pady 4 -padx 2
246 grid $w.msg.txt.l2 -row 1 -sticky news
247 grid $w.msg.txt -row 0 -column 0 -pady 6 -padx 10 -sticky w
248 grid $w.msg.image -row 0 -column 1 -pady 6 -padx 6 -sticky ne
252 ttk::button $w.backBtn -text $::tr(GoBack) -command {
253 destroy .confirmDiscard
256 ttk::button $w.saveBtn -text [
tr SaveAndContinue] -image tb_BD_Save -compound left -command {
257 set gnum [sc_game number]
258 if {[catch {sc_game save $gnum $::curr_db}]} {
264 destroy .confirmDiscard
267 ttk::button $w.clipbaseBtn -text [
tr EditCopy] -image tb_BD_SaveAs -compound left -command {
268 if {[catch {sc_game save 0 $::clipbase_db}]} {
272 set gnum [sc_base numGames $::clipbase_db]
275 destroy .confirmDiscard
278 ttk::button $w.discardBtn -text [
tr DiscardChangesAndContinue] -image tb_BD_VarDelete -compound left -command {
280 destroy .confirmDiscard
283 grid $w.msg -row 0 -columnspan 2
284 grid $w.saveBtn -row 1 -sticky nwe -padx 10 -pady 4 -columnspan 2
285 grid $w.clipbaseBtn -row 2 -sticky nwe -padx 10 -pady 4 -columnspan 2
286 grid $w.discardBtn -row 3 -sticky nwe -padx 10 -pady 4 -columnspan 2
287 grid $w.backBtn -row 4 -column 1 -sticky e -padx 10 -pady "14 4"
288 grid columnconfigure $w 2 -weight 1
293 return $::game::answer
298 namespace eval ::notify {
300 proc GameChanged {} {
315 proc PosChanged {args} {
319 if {! [
string compare $arg "-pgn"]} {
set pgnNeedsUpdate 1}
320 if {! [
string compare $arg "-animate"]} {
set animate 1}
328 after cancel ::notify::privPosChanged
330 after idle ::notify::privPosChanged
332 if {$pgnNeedsUpdate} {
338 proc privPosChanged {} {
357 proc DatabaseChanged {} {
358 set ::curr_db [
sc_base current]
365 set ::treeWin [
winfo exists .treeWin$::curr_db]
372 proc DatabaseModified {{dbase} {filter -1}} {