| 1 | package Games::Sudoku::SudokuTk; | ||
| 2 | |||
| 3 | 1 | ▶ | use 5.008008; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | #use strict; | ||
| 5 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | require Exporter; | ||
| 8 | |||
| 9 | our @ISA = qw(Exporter); | ||
| 10 | |||
| 11 | # Items to export into callers namespace by default. Note: do not export | ||
| 12 | # names by default without a very good reason. Use EXPORT_OK instead. | ||
| 13 | # Do not simply export all your public functions/methods/constants. | ||
| 14 | |||
| 15 | # This allows declaration use Games::Sudoku::SudokuTk ':all'; | ||
| 16 | # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK | ||
| 17 | # will save memory. | ||
| 18 | our %EXPORT_TAGS = ( 'all' => [ qw( | ||
| 19 | |||
| 20 | ) ] ); | ||
| 21 | |||
| 22 | our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); | ||
| 23 | |||
| 24 | our @EXPORT = qw( | ||
| 25 | |||
| 26 | ); | ||
| 27 | |||
| 28 | our $VERSION = '0.14'; | ||
| 29 | sudoku(); | ||
| 30 | # Preloaded methods go here. | ||
| 31 | |||
| 32 | 1; | ||
| 33 | |||
| 34 | sub sudoku { | ||
| 35 | 0 | ▶ | use Tk; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 36 | use Tk::Balloon; | ||
| 37 | use Games::Sudoku::menu; | ||
| 38 | use Games::Sudoku::affichgrille; | ||
| 39 | use Games::Sudoku::tr1; | ||
| 40 | use Games::Sudoku::conf; | ||
| 41 | conf(); | ||
| 42 | foreach $a (@INC) { # we verifie that drawings are here | ||
| 43 | $retour = opendir('DIRECTORY',$a . '/Games/Sudoku/photos'); | ||
| 44 | $b = $a; | ||
| 45 | if ($retour) { | ||
| 46 | last; | ||
| 47 | } | ||
| 48 | } | ||
| 49 | closedir('DIRECTORY'); | ||
| 50 | #print ("fichier " . "$b" . "\n"); | ||
| 51 | $system = $^O; # we find the system | ||
| 52 | #print "system $system\n"; | ||
| 53 | $pref = "$b" . "/Games/Sudoku"; | ||
| 54 | @precarre = ""; | ||
| 55 | @wprecarre = ""; | ||
| 56 | # Definition of main window | ||
| 57 | $langue = ""; | ||
| 58 | $dessin = "chiffres"; | ||
| 59 | $MaxiSudoku = 0; # 0 non choisi 1 choisi 2 autre choisi | ||
| 60 | $Normal = 0; # idem | ||
| 61 | $Enfant = 0; # idem | ||
| 62 | $Simpliste = 0; # idem | ||
| 63 | $Ardu = 0; # idem | ||
| 64 | $trait = "sudoku"; | ||
| 65 | $main = MainWindow->new(); | ||
| 66 | menu($trait); | ||
| 67 | if ($skin == 1) { | ||
| 68 | # --------------------------------------------------------- | ||
| 69 | # frame1 |frame3 frame31 | | ||
| 70 | # frame2 |---------------------- | ||
| 71 | # frame4 |frame32 |34frame35 | | ||
| 72 | # |frame33 | |frame37 | | ||
| 73 | # |frame38 | | | | ||
| 74 | # | | | | | ||
| 75 | # | | | | | ||
| 76 | #-----------------------------------| | | | | ||
| 77 | # frame5 | | | | | ||
| 78 | #-----------------------------------| | | | | ||
| 79 | # frame6 frame7 |frame8 | | | | | ||
| 80 | #-----------------------------------|---------------------- | ||
| 81 | # frame9 |frame36 | | ||
| 82 | #---------------------------------------------------------- | ||
| 83 | $frame1 = $main->Frame(-background => $couleurfond)->pack(); | ||
| 84 | $frame2 = $frame1->Frame(-background => $couleurfond)->pack(-side => 'left'); | ||
| 85 | $frame3 = $frame1->Frame(-background => $couleurfond)->pack(-side => 'right'); | ||
| 86 | $frame4 = $frame2->Frame(-background => $couleurfond)->pack(); | ||
| 87 | $canvas = $frame4->Canvas(-width => 500, -height => 300); | ||
| 88 | $frame4->Photo("imagesudoku", -file => $pref . '/photos/sudoku.bmp'); | ||
| 89 | $canvas->createImage(250 ,0,-anchor => 'n', -image => "imagesudoku"); | ||
| 90 | $canvas->pack; | ||
| 91 | |||
| 92 | $frame5 = $frame2->Frame(-background => $couleurfond)->pack(); | ||
| 93 | $frame5->Photo('imagenormal', -file => $pref . '/photos/button/' . $langue . '/normal.bmp'); | ||
| 94 | $rbutton1= $frame5->Button(-command => [\&CType,'Normal'], | ||
| 95 | -image => "imagenormal")->pack(-side => 'left'); | ||
| 96 | my $balloon1 = $rbutton1->Balloon(); | ||
| 97 | $balloon1->attach($rbutton1, -msg => tr1("Grille 9x9 normale")); | ||
| 98 | $frame6 = $frame2->Frame(-background => $couleurfond)->pack(); | ||
| 99 | $frame7 = $frame6->Frame(-background => $couleurfond)->pack(-side => 'left'); | ||
| 100 | $frame7->Photo('imagesimpliste', -file => $pref . '/photos/button/' . $langue . '/simpliste.bmp'); | ||
| 101 | $rbutton2= $frame7->Button(-command => [\&CType,'Simpliste'], | ||
| 102 | -image => "imagesimpliste")->pack(-side => 'left'); | ||
| 103 | my $balloon2 = $rbutton2->Balloon(); | ||
| 104 | $balloon2->attach($rbutton2, -msg => tr1("Grille 6x6 facile")); | ||
| 105 | $frame8 = $frame6->Frame(-background => $couleurfond)->pack(-side => 'left'); | ||
| 106 | $frame8->Photo('imageardu', -file => $pref . '/photos/button/' . $langue . '/ardu.bmp'); | ||
| 107 | $rbutton3= $frame8->Button(-command => [\&CType,'Ardu'], | ||
| 108 | -image => "imageardu")->pack(-side => 'left'); | ||
| 109 | my $balloon3 = $rbutton3->Balloon(); | ||
| 110 | $balloon3->attach($rbutton3, -msg => tr1("Grille 8x8 pas facile")); | ||
| 111 | $frame9 = $frame2->Frame(-background => $couleurfond)->pack(); | ||
| 112 | $frame9->Photo('imagedifficile', -file => $pref . '/photos/button/' . $langue . '/difficile.bmp'); | ||
| 113 | $rbutton6= $frame9->Button(-command => [\&CType,'Difficile'], | ||
| 114 | -image => "imagedifficile")->pack(-side => 'left'); | ||
| 115 | my $balloon6 = $rbutton6->Balloon(); | ||
| 116 | $balloon6->attach($rbutton6, -msg => tr1("Grille 10x10 difficile")); | ||
| 117 | $frame9->Photo('imagemaxisudoku', -file => $pref . '/photos/button/' . $langue . '/maxisudoku.bmp'); | ||
| 118 | $rbutton4= $frame9->Button(-command => [\&CType,'MaxiSudoku'], | ||
| 119 | -image => "imagemaxisudoku")->pack(-side => 'left'); | ||
| 120 | my $balloon4 = $rbutton4->Balloon(); | ||
| 121 | $balloon4->attach($rbutton4, -msg => tr1("Grille 16x16 très difficile")); | ||
| 122 | $frame10 = $frame2->Frame(-background => $couleurfond)->pack(); | ||
| 123 | my $frame11 = $frame10->Frame(-background => $couleurfond)->pack(-side => 'left'); | ||
| 124 | my $button6 = $frame11->Label(-text => ' ', -background => $couleurfond, | ||
| 125 | -height => 2, -width => 50)->pack; | ||
| 126 | $frame12 = $frame10->Frame->pack(-side => 'right'); | ||
| 127 | $frame12->Photo('imagetresdifficile', -file => $pref . '/photos/button/' . | ||
| 128 | $langue . '/tresdifficile.bmp'); | ||
| 129 | $rbutton7 = $frame12->Button(-command => [\&CType,'Tresdifficile'], | ||
| 130 | -image => "imagetresdifficile")->pack(-side => 'left'); | ||
| 131 | my $balloon7 = $rbutton7->Balloon(); | ||
| 132 | $balloon7->attach($rbutton7, -msg => tr1("Grille 12x12 très difficile")); | ||
| 133 | $frame12->Photo('imageenfant', -file => $pref . '/photos/button/' . $langue . '/enfant.bmp'); | ||
| 134 | $rbutton5 = $frame12->Button(-command => [\&CType,'Enfant'], | ||
| 135 | -image => "imageenfant")->pack(-side => 'left'); | ||
| 136 | my $balloon5 = $rbutton5->Balloon(); | ||
| 137 | $balloon5->attach($rbutton5, -msg => tr1("Grille 4x4 très facile\navec dessins d'animaux\npar défaut")); | ||
| 138 | my $frame31 = $frame3->Frame(-height => 3, -background => $couleurfond)->pack(); | ||
| 139 | my $frame32 = $frame3->Frame(-background => $couleurfond)->pack(); | ||
| 140 | my $frame33 = $frame32->Frame(-background => $couleurfond)->pack(-side => 'left'); | ||
| 141 | my $frame34 = $frame32->Frame(-background => $couleurfond)->pack(-side => 'left'); | ||
| 142 | my $frame35 = $frame32->Frame(-background => $couleurfond)->pack(-side => 'left'); | ||
| 143 | my $canvas3 = $frame34->Canvas('-width' => 5, '-height' => 500, -background => 'black')->pack(); | ||
| 144 | my $frame36 = $frame32->Frame(-height => 3, -background => $couleurfond)->pack(); | ||
| 145 | my $frame37 = $frame32->Frame(-background => $couleurfond)->pack(-side => 'left'); | ||
| 146 | my $frame38 = $frame32->Frame(-background => $couleurfond)->pack(-side => 'left'); | ||
| 147 | |||
| 148 | # Left column ------------------------------- | ||
| 149 | |||
| 150 | $frame33->Photo('imageresoudre', -file => $pref . '/photos/button/' . $langue . '/resoudre.bmp'); | ||
| 151 | $rbutton10 = $frame33->Button(-command => [\&affichgrille,"R"], | ||
| 152 | #-text => "Resoudre une grille")->pack(); | ||
| 153 | -image => "imageresoudre")->pack(); | ||
| 154 | my $balloon10 = $rbutton10->Balloon(); | ||
| 155 | $balloon10->attach($rbutton10, -msg => tr1("Saisir une grille\npour la résoudre")); | ||
| 156 | $frame33->Photo('imagecreer', -file => $pref . '/photos/button/' . $langue . '/creer.bmp'); | ||
| 157 | $rbutton12 = $frame33->Button(-command => [\&creation_grille], | ||
| 158 | #-text => "Creer une grille")->pack(); | ||
| 159 | -image => "imagecreer")->pack(); | ||
| 160 | my $balloon12 = $rbutton12->Balloon(); | ||
| 161 | $balloon12->attach($rbutton12, -msg => tr1("Créer une grille soi même")); | ||
| 162 | $frame33->Photo('imagechiffres', -file => $pref . '/photos/button/' . $langue . '/chiffres.bmp'); | ||
| 163 | if ($dessin ne "chiffres") { | ||
| 164 | $rbutton13 = $frame33->Button(-command => [sub{$dessin = "chiffres"}], | ||
| 165 | #-text => "Résoudre avec\ndes chiffres")->pack(); | ||
| 166 | -image => "imagechiffres")->pack(); | ||
| 167 | } else { | ||
| 168 | $rbutton13 = $frame33->Label(-background => $couleurfond, | ||
| 169 | #-text => "Résoudre avec\ndes chiffres")->pack(); | ||
| 170 | -image => "imagechiffres")->pack(); | ||
| 171 | } | ||
| 172 | my $balloon13 = $rbutton13->Balloon(); | ||
| 173 | $balloon13->attach($rbutton13, -msg => tr1("Il y a des chiffres\n dans les cases")); | ||
| 174 | $frame38->Photo('imagecouleurs', -file => $pref . '/photos/button/' . $langue . '/couleurs.bmp'); | ||
| 175 | if ($dessin ne "couleurs") { | ||
| 176 | $rbutton21 = $frame33->Button(-command => [sub{$dessin = "couleurs"}], | ||
| 177 | #-text => "Résoudre avec\ndes lettres")->pack(); | ||
| 178 | -image => "imagecouleurs")->pack(); | ||
| 179 | } else { | ||
| 180 | $rbutton21 = $frame33->Label( | ||
| 181 | #-text => "Résoudre avec\ndes lettres")->pack(); | ||
| 182 | -image => "imagecouleurs")->pack(); | ||
| 183 | } | ||
| 184 | my $balloon21 = $rbutton21->Balloon(); | ||
| 185 | $balloon21->attach($rbutton21, -msg => tr1("Il y a des couleurs\n dans les cases")); | ||
| 186 | my $Label5 = $frame33->Label(-text => tr1('Langues'), | ||
| 187 | -font => "Nimbus 20", | ||
| 188 | -background => $couleurfond, | ||
| 189 | -height => 2, -width => 10)->pack; | ||
| 190 | $frame33->Photo('imagefr', -file => $pref . '/photos/button/fr/drapeau.gif'); | ||
| 191 | if ($langue ne "fr") { | ||
| 192 | $rbutton14 = $frame33->Button(-command => [\&changelang,"fr"], | ||
| 193 | #-text => "Français")->pack(); | ||
| 194 | -background => $couleurfond, | ||
| 195 | -image => "imagefr")->pack(); | ||
| 196 | } else { | ||
| 197 | $rbutton14 = $frame33->Label(-background => $couleurfond, | ||
| 198 | #-text => "Français")->pack(); | ||
| 199 | -background => $couleurfond, | ||
| 200 | -image => "imagefr")->pack(); | ||
| 201 | } | ||
| 202 | my $balloon14 = $rbutton14->Balloon(); | ||
| 203 | $balloon14->attach($rbutton14, -msg => tr1("français")); | ||
| 204 | $frame33->Photo('imagege', -file => $pref . '/photos/button/ge/drapeau.gif'); | ||
| 205 | if ($langue ne "ge") { | ||
| 206 | $rbutton15 = $frame33->Button(-command => [\&changelang,"ge"], | ||
| 207 | -background => $couleurfond, | ||
| 208 | -image => "imagege")->pack(); | ||
| 209 | } else { | ||
| 210 | $rbutton15 = $frame33->Label(-background => $couleurfond, | ||
| 211 | -background => $couleurfond, | ||
| 212 | -image => "imagege")->pack(); | ||
| 213 | } | ||
| 214 | my $balloon15 = $rbutton15->Balloon(); | ||
| 215 | $balloon15->attach($rbutton15, -msg => tr1("allemand")); | ||
| 216 | $frame33->Photo('imageit', -file => $pref . '/photos/button/it/drapeau.gif'); | ||
| 217 | if ($langue ne "it") { | ||
| 218 | $rbutton16 = $frame33->Button(-command => [\&changelang,"it"], | ||
| 219 | -background => $couleurfond, | ||
| 220 | -image => "imageit")->pack(); | ||
| 221 | } else { | ||
| 222 | $rbutton16 = $frame33->Label(-background => $couleurfond, | ||
| 223 | -background => $couleurfond, | ||
| 224 | -image => "imageit")->pack(); | ||
| 225 | } | ||
| 226 | my $balloon16 = $rbutton16->Balloon(); | ||
| 227 | $balloon16->attach($rbutton16, -msg => tr1("italien")); | ||
| 228 | |||
| 229 | # Right column ------------------------------ | ||
| 230 | |||
| 231 | $frame35->Photo('imagenewgrille', -file => $pref . '/photos/button/' . $langue . '/newgrille.bmp'); | ||
| 232 | $rbutton17 = $frame35->Button(-command => [\&affichgrille,"C"], | ||
| 233 | #-text => "Demander\nune nouvelle grille")->pack(); | ||
| 234 | -image => "imagenewgrille")->pack(); | ||
| 235 | my $balloon17 = $rbutton17->Balloon(); | ||
| 236 | $balloon17->attach($rbutton17, -msg => tr1("Demander une nouvelle grille")); | ||
| 237 | $frame33->Photo('imageanimaux', -file => $pref . '/photos/button/' . $langue . '/animaux.bmp'); | ||
| 238 | my $button18 = $frame35->Label(-text => ' ', -background => $couleurfond, | ||
| 239 | -height => 4, -width => 10)->pack; | ||
| 240 | if ($dessin ne "animaux") { | ||
| 241 | $rbutton19 = $frame35->Button(-command => [sub{$dessin = "animaux"}], | ||
| 242 | #-text => "Résoudre avec\ndes animaux")->pack(); | ||
| 243 | -image => "imageanimaux")->pack(); | ||
| 244 | } else { | ||
| 245 | $rbutton19 = $frame35->Label( | ||
| 246 | #-text => "Résoudre avec\ndes animaux")->pack(); | ||
| 247 | -image => "imageanimaux")->pack(); | ||
| 248 | } | ||
| 249 | my $balloon19 = $rbutton19->Balloon(); | ||
| 250 | $balloon19->attach($rbutton19, -msg => tr1("Il y a des animaux\n dans les cases")); | ||
| 251 | $frame37->Photo('imagelettres', -file => $pref . '/photos/button/' . $langue . '/lettres.bmp'); | ||
| 252 | if ($dessin ne "lettres") { | ||
| 253 | $rbutton20 = $frame35->Button(-command => [sub{$dessin = "lettres"}], | ||
| 254 | #-text => "Résoudre avec\ndes lettres")->pack(); | ||
| 255 | -image => "imagelettres")->pack(); | ||
| 256 | } else { | ||
| 257 | $rbutton20 = $frame35->Label( | ||
| 258 | #-text => "Résoudre avec\ndes lettres")->pack(); | ||
| 259 | -image => "imagelettres")->pack(); | ||
| 260 | } | ||
| 261 | my $balloon20 = $rbutton20->Balloon(); | ||
| 262 | $balloon20->attach($rbutton20, -msg => tr1("Il y a des lettres\n dans les cases")); | ||
| 263 | #my $Label6 = $frame35->Label(-text => ' ', -background => $couleurfond, | ||
| 264 | # -height => 4, -width => 10)->pack; | ||
| 265 | my $Label6 = $frame35->Label(-text => ' ', -background => $couleurfond, | ||
| 266 | -height => 4, -width => 10)->pack; | ||
| 267 | $frame35->Photo('imageen', -file => $pref . '/photos/button/en/drapeau.gif'); | ||
| 268 | if ($langue ne "en") { | ||
| 269 | $rbutton22 = $frame35->Button(-command => [\&changelang,"en"], | ||
| 270 | -background => $couleurfond, | ||
| 271 | #-text => "English")->pack(); | ||
| 272 | -image => "imageen")->pack(); | ||
| 273 | } else { | ||
| 274 | $rbutton22 = $frame35->Label( | ||
| 275 | #-text => "English")->pack(); | ||
| 276 | -background => $couleurfond, | ||
| 277 | -image => "imageen")->pack(); | ||
| 278 | } | ||
| 279 | my $balloon22 = $rbutton22->Balloon(); | ||
| 280 | $balloon22->attach($rbutton22, -msg => tr1("anglais")); | ||
| 281 | $frame35->Photo('imagesp', -file => $pref . '/photos/button/sp/drapeau.gif'); | ||
| 282 | if ($langue ne "sp") { | ||
| 283 | $rbutton23 = $frame35->Button(-command => [\&changelang,"sp"], | ||
| 284 | -background => $couleurfond, | ||
| 285 | -image => "imagesp")->pack(); | ||
| 286 | } else { | ||
| 287 | $rbutton23 = $frame35->Label( | ||
| 288 | -background => $couleurfond, | ||
| 289 | -image => "imagesp")->pack(); | ||
| 290 | } | ||
| 291 | my $balloon23 = $rbutton23->Balloon(); | ||
| 292 | $balloon23->attach($rbutton23, -msg => tr1("espagnol")); | ||
| 293 | $frame35->Photo('imagept', -file => $pref . '/photos/button/pt/drapeau.gif'); | ||
| 294 | if ($langue ne "pt") { | ||
| 295 | $rbutton24 = $frame35->Button(-command => [\&changelang,"pt"], | ||
| 296 | -background => $couleurfond, | ||
| 297 | -image => "imagept")->pack(); | ||
| 298 | } else { | ||
| 299 | $rbutton24 = $frame35->Label( | ||
| 300 | -background => $couleurfond, | ||
| 301 | -image => "imagept")->pack(); | ||
| 302 | } | ||
| 303 | my $balloon24 = $rbutton24->Balloon(); | ||
| 304 | $balloon24->attach($rbutton24, -msg => tr1("portugais")); | ||
| 305 | } else { # normal look | ||
| 306 | $canvas = $main->Label(-text => 'Sudoku', | ||
| 307 | -height => 4, -width => 10, | ||
| 308 | -font => "Nimbus 80")->pack; | ||
| 309 | $framed1 = $main->Frame->pack(); | ||
| 310 | $framed2 = $main->Frame->pack(); | ||
| 311 | $canvas1 = $framed1->Canvas('-width' => 100, | ||
| 312 | -height => 80); | ||
| 313 | $framed1->Photo('image1', -file => $pref . '/photos/20.gif'); | ||
| 314 | $canvas1->createImage(0, 0, -anchor => 'nw', | ||
| 315 | -image => image1); | ||
| 316 | $canvas1->pack; | ||
| 317 | $rbutton1= $framed1->Radiobutton(-text | ||
| 318 | => tr1('Normal'), | ||
| 319 | -font => "Nimbus 20", | ||
| 320 | -value => 1, # valeur transmise de la variable | ||
| 321 | -command => [\&CType], | ||
| 322 | -variable => \$Normal | ||
| 323 | )->pack(-side => 'left'); | ||
| 324 | $rbutton2= $framed1->Radiobutton(-text | ||
| 325 | => tr1('Simpliste'), | ||
| 326 | -font => "Nimbus 20", | ||
| 327 | -value => 1, | ||
| 328 | -command => [\&CType], | ||
| 329 | -variable => \$Simpliste | ||
| 330 | )->pack(-side => 'left'); | ||
| 331 | $rbutton3= $framed1->Radiobutton(-text | ||
| 332 | => tr1('Ardu'), | ||
| 333 | -font => "Nimbus 20", | ||
| 334 | -value => 1, | ||
| 335 | -command => [\&CType], | ||
| 336 | -variable => \$Ardu | ||
| 337 | )->pack(-side => 'left'); | ||
| 338 | $rbutton4= $framed2->Radiobutton(-text | ||
| 339 | => tr1('MaxiSudoku'), | ||
| 340 | -font => "Nimbus 20", | ||
| 341 | -value => 1, | ||
| 342 | -command => [\&CType], | ||
| 343 | -variable => \$MaxiSudoku | ||
| 344 | )->pack(-side => 'left'); | ||
| 345 | $rbutton5= $framed2->Radiobutton(-text | ||
| 346 | => tr1('Enfant'), | ||
| 347 | -font => "Nimbus 20", | ||
| 348 | -value => 1, | ||
| 349 | -command => [\&CType], | ||
| 350 | -variable => \$Enfant | ||
| 351 | )->pack(-side => 'left'); | ||
| 352 | $rbutton6= $framed2->Radiobutton(-text | ||
| 353 | => tr1('Difficile'), | ||
| 354 | -font => "Nimbus 20", | ||
| 355 | -value => 1, | ||
| 356 | -command => [\&CType], | ||
| 357 | -variable => \$Difficile | ||
| 358 | )->pack(-side => 'left'); | ||
| 359 | $rbutton7= $framed2->Radiobutton(-text | ||
| 360 | => tr1('Très difficile'), | ||
| 361 | -font => "Nimbus 20", | ||
| 362 | -value => 1, | ||
| 363 | -command => [\&CType], | ||
| 364 | -variable => \$Tresdifficile | ||
| 365 | )->pack(-side => 'left'); | ||
| 366 | } | ||
| 367 | $wcanvas = 1; | ||
| 368 | MainLoop; | ||
| 369 | } | ||
| 370 | __END__ | ||