--- kgsueme/bin/kgsueme 2003/05/30 07:19:16 1.16 +++ kgsueme/bin/kgsueme 2003/05/31 03:47:26 1.27 @@ -1,4 +1,4 @@ -#!/usr/bin/perl -I../lib/ +#!/usr/bin/perl use Gtk; use Gtk::Gdk; @@ -12,12 +12,19 @@ use Audio::Play; use IO::Socket::INET; - +use List::Util; use Errno; init Gtk; -$HACK = 1; # do NEVER enable. ;) +our $HACK = 1; # do NEVER enable. ;) +our $DEBUG_EXPOSE = 1; + +if ($HACK) { + $KGS::debug = 1; +} + +our $VERSION = "0.1"; our $config; our $LIBDIR = "."; @@ -30,6 +37,8 @@ or die "$IMGDIR/$_[0]: $!"; } +my @fontchars = ('A' .. 'Z', 0 .. 9); + our @black_img = load_img "b-01.png"; our @white_img = map +(load_img "w-0$_.png"), 1,2,3,4,5; our @triangle_img = map +(load_img "triangle-$_.png"), qw(b w); @@ -37,6 +46,14 @@ our @circle_img = map +(load_img "circle-$_.png"), qw(b w); our $board_img = load_img "woodgrain-01.jpg"; +our @font = ( + [map +(load_img "font/$_-black.png"), @fontchars], + [map +(load_img "font/$_-white.png"), @fontchars], + ); +our %fontmap; +@fontmap{@fontchars} = (0..25 + 10); +@fontmap{'a' .. 'z'} = (0..25); + { #my $audioserver = new Audio::Play(0); my %sound; @@ -54,8 +71,9 @@ sub play_sound { if (fork == 0) { - my $audioserver = new Audio::Play(1); - $audioserver->play ($sound{$_[0]}); + if (my $audioserver = new Audio::Play(1)) { + $audioserver->play ($sound{$_[0]}); + } Gtk->_exit(0); } } @@ -72,6 +90,9 @@ $config = $state->{config} ||= {}; + $config{speed} = 0;#d# optimize for speed or memory? + $config{conserve_memory} = 0; + # grr... more gtk+ brokenness my %get = ( hpane_position => sub { ($_[0]->children)[0]->allocation->[2] }, @@ -168,8 +189,23 @@ } if (0) { - my $board = new game size => 5; - $board->{window}->show_all; + use KGS::Constants; + + for (19) { + my $board = new game %{Storable::retrieve "testboard.storable"}; + + if (0) { + $board->{board} = new KGS::Game::Board; + $board->{board}{board}[0][0] = MARK_B; + $board->{board}{board}[1][1] = MARK_GRAY_B | MARK_SMALL_W; + $board->{board}{board}[2][2] = MARK_W | MARK_TRIANGLE; + $board->{board}{board}[1][2] = MARK_B | MARK_LABEL; + $board->{board}{label}[1][2] = "198"; + $board->{board}{board}[0][2] = MARK_W | MARK_LABEL; + $board->{board}{label}[0][2] = "AWA"; + } + $board->{window}->show_all; + } } main Gtk; @@ -188,7 +224,7 @@ KGS::Listener::Debug->new->listen($self->{conn}); #d# debug only :) - $self->listen($self->{conn}); + $self->listen($self->{conn}, "login"); $self->{roomlist} = new roomlist conn => $self->{conn}; @@ -261,7 +297,7 @@ }; # now login - $self->{conn}->login($self->{login}->get_text, $self->{password}->get_text); + $self->{conn}->login("kgsueme $VERSION $^O", $self->{login}->get_text, $self->{password}->get_text); } sub inject_login { @@ -365,7 +401,7 @@ my $self = shift; $self = $self->SUPER::new(@_); - $self->listen($self->{conn}); + $self->listen($self->{conn}, qw(msg_room:)); $self->{window} = new Gtk::Window 'toplevel'; $self->{window}->set_title("KGS Room $self->{name}"); @@ -389,7 +425,7 @@ $self->{gamelist}->signal_connect(select_row => sub { my $game = $self->{gamelist}->get_row_data($_[1]) or return; - $self->{game}{$game->{channel}} ||= new game %$game, conn => $self->{conn}; + $self->{game}{$game->{channel}} ||= new game %$game, conn => $self->{conn}, room => $self; $self->{game}{$game->{channel}}->join; $self->{gamelist}->unselect_all; }); @@ -418,6 +454,27 @@ $self; } +sub join { + my ($self) = @_; + $self->SUPER::join; + + $self->{window}->show_all; +} + +sub part { + my ($self) = @_; + $self->SUPER::part; + + delete $::config->{rooms}{$self->{channel}}; + $self->{window}->hide_all; +} + +sub inject_msg_room { + my ($self, $msg) = @_; + + $self->{text}->insert(undef, undef, undef, "\n$msg->{name}: $msg->{message}"); +} + sub event_update_users { my ($self) = @_; @@ -466,23 +523,6 @@ }); } -sub join { - my ($self) = @_; - $self->SUPER::join; - - $self->{window}->show_all; -} - -sub part { - my ($self) = @_; - $self->SUPER::part; - - delete $::config->{rooms}{$self->{channel}}; - $self->{window}->hide_all; - $self->event_update_users; - $self->event_update_games; -} - sub event_join { my ($self) = @_; $self->SUPER::event_join; @@ -496,13 +536,6 @@ $self->{text}->insert(undef, undef, undef, "\n$self->{owner}: $self->{description}\n"); } -sub inject_msg_room { - my ($self, $msg) = @_; - return unless $self->{channel} == $msg->{channel}; - - $self->{text}->insert(undef, undef, undef, "\n$msg->{name}: $msg->{message}"); -} - ############################################################################# package game; @@ -520,7 +553,8 @@ $self->listen($self->{conn}); $self->{window} = new Gtk::Window 'toplevel'; - $self->{window}->set_title("KGS Game ".$self->user0." ".$self->user1) if $self->{channel};#d# + my $title = $self->{channel} ? $self->user0." ".$self->user1 : "Game Window"; + $self->{window}->set_title("KGS Game $title"); ::state $self->{window}, "game::window", undef, window_size => [600, 500]; $self->{window}->signal_connect(delete_event => sub { $self->part; 1 }); @@ -528,9 +562,39 @@ $self->{window}->add(my $hpane = new Gtk::HPaned); ::state $hpane, "game::hpane", undef, hpane_position => 500; + $hpane->pack1(my $vbox = new Gtk::VBox); + + $vbox->pack_start((my $frame = new Gtk::Frame), 0, 1, 0); + + { + $frame->add(my $vbox = new Gtk::VBox); + $vbox->add($self->{title} = new Gtk::Label $title); + + $self->{moveadj} = new Gtk::Adjustment 0, 0, 0, 1, 10, 0; + $vbox->add(my $scale = new Gtk::HScale $self->{moveadj}); + $scale->set_draw_value (1); + $scale->set_digits (0); + $scale->set_value_pos('top'); + + $self->{moveadj}->signal_connect (value_changed => sub { + $self->{board} = new KGS::Game::Board $self->{size}; + $self->{board}->interpret_path ([@{$self->{path}}[0 .. $self->{moveadj}->value - 1]]); + + my $area = $self->repaint_board; + + # force a redraw (not perfect(?)) + $self->expose ($area); + + $self->{text}->backward_delete($self->{text}->get_length); + $self->{text}->insert(undef, undef, undef, KGS::Listener::Debug::dumpval([$self->{board}{time},$self->{board}{captures}]). $self->{board}{comment}); + }); + + $self->{moveadj}->upper (scalar @{$self->{path}}) if $self->{path}; + } + Gtk::Widget->push_visual (Gtk::Gdk::Rgb->get_visual); Gtk::Widget->push_colormap (Gtk::Gdk::Rgb->get_cmap); - $hpane->pack1(($self->{canvas} = new Gtk::DrawingArea), 1, 1); + $vbox->pack_start(($self->{canvas} = new Gtk::DrawingArea), 1, 1, 0); Gtk::Widget->pop_colormap; Gtk::Widget->pop_visual; @@ -587,46 +651,22 @@ sub configure_event { my ($widget, $self, $event) = @_; delete $self->{stack}; + delete $self->{pixbuf}; + delete $self->{board_shown}; + delete $self->{background}; $self->repaint_board; 1; } -sub expose_event { - my ($widget, $self, $event) = @_; - - $self->{pixmap} or return; - - my ($ox, $oy, $s) = @{$self->{offsets}}; - - my ($x, $y, $w, $h) = - @{Gtk::Gdk::Rectangle->intersect( - $event->{area}, - [$ox, $oy, $s, $s] - )}; - - $self->{canvas}->window->draw_pixmap ( - $self->{canvas}->style->white_gc, - $self->{pixmap}, - $x - $ox, $y - $oy, $x, $y, $w, $h, - ); - 1; -} - -# create new, _transparent_ pixbuf -sub new_pixbuf { - my ($w, $h) = @_; - - $pixbuf; -} - +sub INTERP_NEAREST (){ 1 } sub INTERP_TILES (){ 1 } sub INTERP_BILINEAR (){ 2 } sub INTERP_HYPER (){ 3 } sub new_pixbuf { - my ($w, $h, $clear) = @_; + my ($w, $h, $alpha, $clear) = @_; - my $pixbuf = new Gtk::Gdk::Pixbuf 'rgb', 1, 8, $w, $h; + my $pixbuf = new Gtk::Gdk::Pixbuf 'rgb', $alpha, 8, $w, $h; if ($clear) { # damn, need to clear it ourselves my $row = "\x00\x00\x00\x00" x $w; @@ -639,7 +679,7 @@ sub scale_pixbuf { my ($src, $w, $h, $mode) = @_; - my $dst = new_pixbuf $w, $h; + my $dst = new_pixbuf $w, $h, 1; $src->scale( $dst, 0, 0, $w, $h, 0, 0, @@ -650,65 +690,55 @@ $dst; } -sub label_font { - my ($size) = @_; - - $size = int $size; - $size = 34 if $size > 34; - - # I am soo incapable - for (8, 10, 11, 12, 14, 17, 18, 20, 24, 25, 34) { - next unless $size <= $_; - my $font = Gtk::Gdk::Font->fontset_load ("-*-helvetica-bold-r-*--$_-*"); - return $font if $font; - } - - return Gtk::Gdk::Font->fontset_load ("-*-helvetica-bold-r-*--8-*"); -} - -sub center_text { - my ($drawable, $font, $gc, $x, $y, $t) = @_; - my $w = $font->string_width ($t); - my $h = $font->string_height($t) - $font->descent; - $drawable->draw_text ($font, $gc, $x - $w*0.5, $y + $h * 0.5, $t, length $t); -} - # create a stack of stones sub create_stack { - my ($self, $gc, $mark, $size, $rand) = @_; + my ($self, $mark, $size, $rand) = @_; + + my $shadow = $size * 0.05; my $c = \$self->{stack}{$mark}; unless ($$c) { for my $stone ($mark & (MARK_W | MARK_GRAY_W) ? @::white_img : @::black_img) { - my $base = - $mark & (MARK_B | MARK_GRAY_B | MARK_W | MARK_GRAY_W) - ? scale_pixbuf $stone, $size, $size, INTERP_HYPER - : new_pixbuf $size, $size, 1; - - if ($mark & (MARK_GRAY_B | MARK_GRAY_W)) { - # make transparent by stippling :( - # fix this to use compositing if/when we have full compositing support - # in kgsueme - my @row = ( - "\xff\xff\xff\xff\x00\x00\x00\x00" x ($size / 2 + 1), - "\x00\x00\x00\x00\xff\xff\xff\xff" x ($size / 2 + 1), - ); - $base->put_pixels ($base->get_pixels ($_) & $row[$_ & 1], $_, 0) - for 0 .. $size - 1; + my $base = new_pixbuf $size + $shadow, $size + $shadow, 1, 1; + + # zeroeth the shadow + if ($mark & (MARK_B | MARK_W)) { + $::black_img[0]->composite ( + $base, $shadow, $shadow, $size, $size, $shadow-0.5, $shadow-0.5, + $size / $stone->get_width, $size / $stone->get_height, + $::config{speed} ? INTERP_NEAREST : INTERP_TILES, 128 + ); + } + + # first the big stones + for ([MARK_B, 255], + [MARK_W, 255], + [MARK_GRAY_B, 128], + [MARK_GRAY_W, 128]) { + my ($mask, $alpha) = @$_; + if ($mark & $mask) { + $stone->composite ( + $base, 0, 0, $size, $size, -0.5, -0.5, + $size / $stone->get_width, $size / $stone->get_height, + $::config{speed} ? INTERP_NEAREST : INTERP_HYPER, $alpha + ); + } } + # then the samll stones for ([MARK_SMALL_B, $::black_img[$rand % @::black_img]], [MARK_SMALL_W, $::white_img[$rand % @::white_img]]) { my ($mask, $img) = @$_; if ($mark & $mask) { $img->composite ( - $base, ($size / 4) x2, (int ($size / 2 + 0.5)) x2, ($size / 4) x 2, + $base, ($size / 4) x2, (int ($size / 2 + 0.5)) x2, ($size / 4 - 0.5) x 2, $size / $img->get_width / 2, $size / $img->get_height / 2, - INTERP_HYPER, 192 + $::config{speed} ? INTERP_NEAREST : INTERP_HYPER, 192 ); } } + # and lastly any markers my $dark_bg = ! ! ($mark & (MARK_B | MARK_GRAY_B)); for ([MARK_CIRCLE, $::circle_img[$dark_bg]], @@ -717,27 +747,65 @@ my ($mask, $img) = @$_; if ($mark & $mask) { $img->composite ( - $base, 0, 0, $size, $size, 0, 0, - ($size - 1) / ($img->get_width - 1), ($size - 1) / ($img->get_height - 1), - INTERP_HYPER, 255 + $base, 0, 0, $size, $size, -0.5, -0.5, + $size / $img->get_width, $size / $img->get_height, + $::config{speed} ? INTERP_NEAREST : INTERP_HYPER, 255 ); } } - push @$$c, [$base->render_pixmap_and_mask (128)]; + push @$$c, $base; } } - @{$$c->[$rand % @$$c]}; + $$c->[$rand % @$$c]; +} + +sub pixbuf_text { + my ($pixbuf, $colour, $x, $y, $height, $text) = @_; + + my @c = grep $_, + map $::font[$colour][$::fontmap{$_}], + split //, $text; + + if (@c) { + my $spacing = $height * 0.1; + my $s = $height / List::Util::max map $_->get_height, @c; + my $W = List::Util::sum map $_->get_width, @c; + + $x -= ($W * $s + $spacing * (@c - 1)) * 0.5; + $y -= $height * 0.5; + + for (@c) { + my $w = $_->get_width * $s; + $_->composite ($pixbuf, + $x, $y, $w+0.999, $height+0.999, $x, $y, $s, $s, + $::config{speed} ? INTERP_NEAREST : INTERP_BILINEAR, 255); + + $x += $w + $spacing; + } + } +} + +my $black_pb; + +sub pixbuf_rect { + my ($pb, $x1, $y1, $x2, $y2) = @_; + # we fake lines by... an unspeakable method :/ + unless ($black_pb) { + $black_pb = new_pixbuf 1, 1, 0, 0; + $black_pb->put_pixels ("\x44\x11\x11", 0, 0); + } + + $black_pb->composite ($pb, $x1, $y1, $x2 - $x1 + 1, $y2 - $y1 + 1, $x1, $y1, 1, 1, INTERP_NEAREST, 192); } sub repaint_board { my ($self) = @_; my $canvas = $self->{canvas}; + my $expose_area = undef; - return unless $self->{board}; - - %cache = (); + return $expose_area unless $self->{board}; my ($w, $h) = @{$canvas->allocation}[2,3]; @@ -745,85 +813,184 @@ $self->{offsets} = [int (($w - $s) / 2), int (($h - $s) / 2), $s]; - my $pixmap = $self->{pixmap} = new Gtk::Gdk::Pixmap $self->{canvas}->window, $s, $s; + my $size = $self->{size}; - { - my ($bw, $bh) = ($::board_img->get_width, $::board_img->get_height); + my $border = int ($s / ($size + 3) * 0.5); + my $s2 = $s - $border * 2; + my $edge = int ($s2 / ($size + 1) * 0.95); + my $ofs = int ($edge / 2); - my $bg = $s < $bw && $s < $bh ? $::board_img : scale_pixbuf $::board_img, $s, $s, INTERP_TILES; - $bg->render_to_drawable( - $pixmap, $self->{canvas}->style->white_gc, - 0, 0, 0, 0, $s, $s, - 0, 0, 0 - ); - } + my @k = map int ($s2 * $_ / ($size+1) + $border + 0.5), 0 .. $size; - my $gc = Gtk::Gdk::GC->new ($pixmap); + my $pixbuf; - $gc->rgb_gc_set_foreground($line_colour); - $gc->set_line_attributes (int ($s / 300) + 1, 'solid', 'projecting', 'miter'); + my $oldboard; - my $size = $self->{size}; - my $border = int ($s / $size); - my $s2 = $s - $border * 2; - my $edge = int ($s2 / $size) | 1; - my $ofs = int ($edge / 2); + if ($self->{background}) { + if ($oldboard = $self->{board_shown}) { + $pixbuf = $self->{pixbuf}; + } else { + $pixbuf = $self->{background}->copy; + $expose_area = [0, 0, $s, $s]; + } + } else { + $expose_area = [0, 0, $s, $s]; - my $font = label_font $ofs; + my ($bw, $bh) = ($::board_img->get_width, $::board_img->get_height); + + if ($s < $bw && $s < $bh) { + $pixbuf = new_pixbuf $s, $s, $::config{conserve_memory} ? 0 : 1, 0; + $::board_img->copy_area (0, 0, $s, $s, $pixbuf, 0, 0); + } else { + $pixbuf = scale_pixbuf $::board_img, $s, $s, $::config{speed} ? INTERP_NEAREST : INTERP_TILES; + } - my @k = map int ($s2 * $_ / $size - $ofs + $border + 0.5), 0 .. $size; + my $linew = int ($s / 25 / $size); - my $a = "A"; - for my $i (1 .. $size) { - $pixmap->draw_line ($gc, $k[$i], $k[1], $k[$i], $k[$size]); - $pixmap->draw_line ($gc, $k[1], $k[$i], $k[$size], $k[$i]); - - center_text $pixmap, $font, $gc, $k[$i], ($ofs +$border) / 2, $a; - center_text $pixmap, $font, $gc, $k[$i], $s2 + $border + $ofs / 2, $a; - center_text $pixmap, $font, $gc, ($ofs + $border) / 2, $k[$i], $size - $i + 1; - center_text $pixmap, $font, $gc, $s2 + $border + $ofs / 2, $k[$i], $size - $i + 1; + for my $i (1 .. $size) { + pixbuf_rect $pixbuf, $k[$i] - $linew, $k[1] - $linew, $k[$i] + $linew, $k[$size] + $linew; + pixbuf_rect $pixbuf, $k[1] - $linew, $k[$i] - $linew, $k[$size] + $linew, $k[$i] + $linew; + + # 38 max, but we allow a bit more + my $label = (qw(- A B C D E F G H J K L M N O P Q R S T U V W X Y Z + AA BB CC DD EE FF GG HH JJ KK LL MM NN OO PP QQ RR SS TT UU VV WW XX YY ZZ))[$i]; + + pixbuf_text $pixbuf, 0, $k[$i], $border, $ofs, $label; + pixbuf_text $pixbuf, 0, $k[$i], $s2 + $border, $ofs, $label; + pixbuf_text $pixbuf, 0, $border, $k[$i], $ofs, $size - $i + 1; + pixbuf_text $pixbuf, 0, $s2 + $border, $k[$i], $ofs, $size - $i + 1; - $a++; - $a++ if $a eq "I"; # not correct, instead of AA AB, we should get HH JJ KK... + $a++; + $a++ if $a eq "I"; # not correct, instead of AA AB, we should get HH JJ KK... + } + + unless ($::config->{conserve_memory}) { + $self->{background} = $pixbuf; + $pixbuf = $pixbuf->copy; + } } + $self->{pixbuf} = $pixbuf; + # hoshi-points(!)#d# # caching of empty board gfx(!)#d# for my $x (1 .. $size) { for my $y (1 .. $size) { - my $yk = $s2 * $x / $size - $ofs + $border; + my ($dx, $dy) = ($k[$x] - $ofs, $k[$y] - $ofs); my $mark = $self->{board}{board}[$x-1][$y-1]; + my $old = $oldboard ? $oldboard->{board}[$x-1][$y-1] : 0; + + if ($oldboard && $old != $mark) { + my $shadow = $edge * 0.05; + my $new_expose = [$dx, $dy, $edge + $shadow, $edge + $shadow]; + $self->{background}->copy_area (@$new_expose, $pixbuf, $dx, $dy); + $expose_area = $expose_area + ? Gtk::Gdk::Rectangle->union ($expose_area, $new_expose) + : $new_expose; + } if ($mark) { - my ($dx, $dy) = ($k[$x] - $ofs, $k[$y] - $ofs); - my ($pm, $bm) = $self->create_stack($gc, $mark, $edge, $x * 17 + $y * 11 ); + my $pb = $self->create_stack($mark, $edge, $x * 17 + $y * 11 ); + + $pb->composite ($pixbuf, $dx, $dy, $pb->get_width, $pb->get_height, + $dx, $dy, 1, 1, $::config{speed} ? INTERP_NEAREST : INTERP_NEAREST, 255); - $gc->set_clip_mask ($bm); - $gc->set_clip_origin ($dx, $dy); - $pixmap->draw_pixmap ($gc, $pm, 0, 0, $dx, $dy, $edge, $edge); + # labels are handled here because they are quite rare + if ($mark & MARK_LABEL) { + my $white = $mark & (MARK_W | MARK_GRAY_W) ? 0 : 1; + + if ($white) { + pixbuf_text $pixbuf, 0, + $k[$x] + $ofs * 0.1, $k[$y] + $ofs * 0.1, $ofs * 0.7, + $self->{board}{label}[$x-1][$y-1]; + } + pixbuf_text $pixbuf, $white, + $k[$x], $k[$y], $ofs * 0.7, + $self->{board}{label}[$x-1][$y-1]; + } + + # old pixmap&mask-way. that was fast ;( + #my ($pm, $bm) = $self->create_stack($gc, $mark, $edge, $x * 17 + $y * 11 ); + + #$gc->set_clip_mask ($bm); + #$gc->set_clip_origin ($dx, $dy); + #$pixmap->draw_pixmap ($gc, $pm, 0, 0, $dx, $dy, $edge, $edge); } } } + + $self->{board_shown} = Storable::dclone $self->{board}; + #d# save + #Storable::nstore { board => $self->{board}, size => $self->{size}, path => $self->{path}}, "testboard.storable"; + + $expose_area; +} + +sub expose { + my ($self, $area) = @_; + + if ($area && $self->{pixbuf}) { + my ($x, $y, $w, $h) = @$area; + my ($ox, $oy, $s) = @{$self->{offsets}}; + + $self->{pixbuf}->render_to_drawable ($self->{canvas}->window, $self->{canvas}->style->white_gc, + $x, $y, $x + $ox, $y + $oy, $w, $h); + $self->{canvas}->window->draw_rectangle ($self->{canvas}->style->black_gc, 0, + $x + $ox - 1, $y + $oy - 1, $w + 2, $h + 2) if $::DEBUG_EXPOSE; + + #$self->{canvas}->window->draw_pixmap ( + # $self->{canvas}->style->white_gc, + # $self->{pixmap}, + # $x - $ox, $y - $oy, $x, $y, $w, $h, + #); + } +} + +sub expose_event { + my ($widget, $self, $event) = @_; + + $self->{pixbuf} or return; + + my $area = $event->{area}; + my ($ox, $oy, $s) = @{$self->{offsets}}; + + $self->expose (Gtk::Gdk::Rectangle->intersect ( + [$area->[0] - $ox, $area->[1] - $oy, $area->[2], $area->[3]], + [0, 0, $s, $s], + )); + + 1; } sub event_update_tree { my ($self) = @_; - $self->{board} = new KGS::Game::Board $self->{size}; - $self->{board}->interpret_path ($self->get_path); + $self->{path} = $self->get_path; + + my $move = @{$self->{path}}; - $self->repaint_board; + $self->{moveadj}->upper($move); - # force a redraw (not perfect(?)) - expose_event $self->{canvas}, $self, { area => $self->{canvas}->allocation }; + if ($self->{moveadj}->value >= $move - 1 || !$self->{moveadj}->value) { + $self->{moveadj}->set_value ($move); + } +} - $self->{text}->backward_delete($self->{text}->get_length); - $self->{text}->insert(undef, undef, undef, KGS::Listener::Debug::dumpval([$self->{board}{time},$self->{board}{captures}]). $self->{board}{comment}); +sub event_part { + my ($self) = @_; + $self->SUPER::event_part; + $self->{window}->destroy; # hmm.. why does this keep the object alive? puzzling.. ahh.. callback ;) + delete $self->{room}{game}{$self->{channel}}; } sub event_move { - ::play_sound "move"; + my ($self, $pass) = @_; + ::play_sound $pass ? "pass" : "move"; +} + +sub DESTROY {#d# + warn "DESTROY(@_)\n";#d# } 1;