… | |
… | |
55 | Playing sounds required the L<Audio::Play> module. If it isn't installed, |
55 | Playing sounds required the L<Audio::Play> module. If it isn't installed, |
56 | sounds will silently not being played. The module intentionally doesn't |
56 | sounds will silently not being played. The module intentionally doesn't |
57 | depend on L<Audio::Play> as it isn't actively maintained anymore and fails |
57 | depend on L<Audio::Play> as it isn't actively maintained anymore and fails |
58 | to install cleanly. |
58 | to install cleanly. |
59 | |
59 | |
|
|
60 | Note that L<Audio::Play> is broken on 64-bit platforms, which the author |
|
|
61 | knows about for half a decade now, but apparently can't be bothered to |
|
|
62 | fix. The symptoms are that it cannot load the soundfile and will silently |
|
|
63 | result in - silence. |
|
|
64 | |
60 | =over 4 |
65 | =over 4 |
61 | |
66 | |
62 | =cut |
67 | =cut |
63 | |
68 | |
64 | our $VERSION = '1.0'; |
69 | our $VERSION = '1.02'; |
65 | |
70 | |
66 | no warnings; |
71 | no warnings; |
67 | use strict; |
72 | use strict; |
68 | |
73 | |
69 | use Scalar::Util; |
74 | use Scalar::Util; |
… | |
… | |
313 | delete $self->{backgroundpm}; |
318 | delete $self->{backgroundpm}; |
314 | delete $self->{backgroundpb}; |
319 | delete $self->{backgroundpb}; |
315 | |
320 | |
316 | my $pixmap = new Gtk2::Gdk::Pixmap $self->window, $w, $h, -1; |
321 | my $pixmap = new Gtk2::Gdk::Pixmap $self->window, $w, $h, -1; |
317 | |
322 | |
318 | #my $gridcolour = 0x88444400; # black is traditional, but only with overlapping stones |
|
|
319 | my $gridcolour = 0x44444400; # black is traditional, but only with overlapping stones |
323 | my $gridcolour = 0x44444400; # black is traditional, but only with overlapping stones |
320 | my $labelcolour = 0x88444400; |
324 | my $labelcolour = 0x88444400; |
321 | |
325 | |
322 | # we leave enough space for the shadows.. I like smaller stones, and we |
|
|
323 | # do no need to do the nifty recursive screen updates that cgoban2 does |
|
|
324 | my $borderw = int ($w / ($size + 1) * 0.5); |
326 | my $borderw = int $w / ($size + 1) * 0.5; |
325 | my $borderh = $borderw; |
327 | my $borderh = $borderw; |
326 | my $w2 = $w - $borderw * 2; |
328 | my $w2 = $w - $borderw * 2; |
327 | my $h2 = $h - $borderh * 2; |
329 | my $h2 = $h - $borderh * 2; |
328 | my $edge = ceil ($w2 / ($size + 1)); |
330 | my $edge = ceil $w2 / ($size + 1); |
329 | my $ofs = $edge * 0.5; |
331 | my $ofs = $edge * 0.5; |
330 | |
332 | |
331 | # we need a certain minimum size, and just fudge some formula here |
333 | # we need a certain minimum size, and just fudge some formula here |
332 | return if $w < $size * 5 + 2 + $borderw |
334 | return if $w < $size * 5 + 2 + $borderw |
333 | || $h < $size * 6 + 2 + $borderh; |
335 | || $h < $size * 6 + 2 + $borderh; |
… | |
… | |
344 | $board_img->copy_area (0, 0, $w, $h, $pixbuf, 0, 0); |
346 | $board_img->copy_area (0, 0, $w, $h, $pixbuf, 0, 0); |
345 | } else { |
347 | } else { |
346 | $pixbuf = scale_pixbuf $board_img, $w, $h, 'bilinear', 0; # nearest for extra speed |
348 | $pixbuf = scale_pixbuf $board_img, $w, $h, 'bilinear', 0; # nearest for extra speed |
347 | } |
349 | } |
348 | |
350 | |
349 | my $linew = int ($w / 40 / $size); |
351 | my $linew = int $w / 40 / $size; |
350 | |
352 | |
351 | # ornamental border... we have time to waste :/ |
353 | # ornamental border... we have time to waste :/ |
352 | pixbuf_rect $pixbuf, 0xffcc7700, 0, 0, $w-1, $linew, 255; |
354 | pixbuf_rect $pixbuf, 0xffcc7700, 0, 0, $w-1, $linew, 255; |
353 | pixbuf_rect $pixbuf, 0xffcc7700, 0, 0, $linew, $h-1, 255; |
355 | pixbuf_rect $pixbuf, 0xffcc7700, 0, 0, $linew, $h-1, 255; |
354 | pixbuf_rect $pixbuf, 0xffcc7700, $w-$linew-1, 0, $w-1, $h-1, 255; |
356 | pixbuf_rect $pixbuf, 0xffcc7700, $w-$linew-1, 0, $w-1, $h-1, 255; |
… | |
… | |
519 | ); |
521 | ); |
520 | } |
522 | } |
521 | } |
523 | } |
522 | |
524 | |
523 | # then the small stones (always using the first image) |
525 | # then the small stones (always using the first image) |
524 | for ([MARK_SMALL_B, $mark & MARK_GRAYED ? 106 : 255, $black_img[0]], |
526 | for ([MARK_SMALL_B, $mark & MARK_SMALL_GRAYED ? 106 : 255, $black_img[0]], |
525 | [MARK_SMALL_W, $mark & MARK_GRAYED ? 190 : 255,$white_img[0]]) { |
527 | [MARK_SMALL_W, $mark & MARK_SMALL_GRAYED ? 190 : 255, $white_img[0]]) { |
526 | my ($mask, $alpha, $img) = @$_; |
528 | my ($mask, $alpha, $img) = @$_; |
527 | if ($mark & $mask) { |
529 | if ($mark & $mask) { |
528 | $img->composite ( |
530 | $img->composite ( |
529 | $base, ($size / 4) x2, (ceil $size / 2 + 1) x2, ($size / 4) x2, |
531 | $base, ($size / 4) x2, (ceil $size / 2 + 1) x2, ($size / 4) x2, |
530 | $size / $img->get_width / 2, $size / $img->get_height / 2, |
532 | $size / $img->get_width / 2, $size / $img->get_height / 2, |