… | |
… | |
146 | ]; |
146 | ]; |
147 | |
147 | |
148 | sub INIT_INSTANCE { |
148 | sub INIT_INSTANCE { |
149 | my ($self) = @_; |
149 | my ($self) = @_; |
150 | |
150 | |
|
|
151 | $self->add ($self->{window} = my $window = new Gtk2::EventBox); # for bg |
|
|
152 | |
151 | $self->add (my $vbox = new Gtk2::VBox); |
153 | $window->add (my $vbox = new Gtk2::VBox); |
152 | |
154 | |
153 | $vbox->pack_start (($self->{name} = new Gtk2::Label "-"), 1, 1, 0); |
155 | $vbox->pack_start (($self->{name} = new Gtk2::Label "-"), 1, 1, 0); |
154 | $vbox->pack_start (($self->{info} = new Gtk2::Label "-"), 1, 1, 0); |
156 | $vbox->pack_start (($self->{info} = new Gtk2::Label "-"), 1, 1, 0); |
155 | $vbox->pack_start (($self->{clock} = new game::goclock), 1, 1, 0); |
157 | $vbox->pack_start (($self->{clock} = new game::goclock), 1, 1, 0); |
156 | |
158 | |
157 | $vbox->add ($self->{imagebox} = new Gtk2::VBox); |
159 | $vbox->add ($self->{imagebox} = new Gtk2::VBox); |
158 | |
160 | |
159 | $self; |
161 | $self; |
160 | } |
162 | } |
161 | |
163 | |
|
|
164 | sub SET_PROPERTY { |
|
|
165 | my ($self, $pspec, $value) = @_; |
|
|
166 | |
|
|
167 | $self->{$pspec->get_name} = $value; |
|
|
168 | |
|
|
169 | $self->set_name ("userpanel-$self->{colour}"); |
|
|
170 | } |
|
|
171 | |
162 | sub configure { |
172 | sub configure { |
163 | my ($self, $app, $user, $rules) = @_; |
173 | my ($self, $app, $user, $rules) = @_; |
164 | |
174 | |
165 | if ($self->{name}->get_text ne $user->as_string) { |
175 | if ($self->{name}->get_text ne $user->as_string) { |
166 | $self->{name}->set_text ($user->as_string); |
176 | $self->{name}->set_text ($user->as_string); |
167 | |
177 | |
168 | $self->{imagebox}->remove ($_) for $self->{imagebox}->get_children; |
178 | $self->{imagebox}->remove ($_) for $self->{imagebox}->get_children; |
|
|
179 | unless ($::config{suppress_userpic}) { |
169 | $self->{imagebox}->add (gtk::image_from_data undef); |
180 | $self->{imagebox}->add (gtk::image_from_data undef); |
|
|
181 | } |
170 | $self->{imagebox}->show_all; |
182 | $self->{imagebox}->show_all; |
171 | |
183 | |
172 | if ($user->has_pic) { |
184 | if ($user->has_pic) { |
173 | # the big picture... |
185 | # the big picture... |
174 | $app->userpic ($user->{name}, sub { |
186 | $app->userpic ($user->{name}, sub { |
175 | return unless $self->{imagebox}; |
187 | return unless $self->{imagebox}; |
176 | |
188 | |
177 | if ($_[0]) { |
189 | if ($_[0]) { |
178 | $self->{imagebox}->remove ($_) for $self->{imagebox}->get_children; |
190 | $self->{imagebox}->remove ($_) for $self->{imagebox}->get_children; |
|
|
191 | unless ($::config{suppress_userpic}) { |
179 | $self->{imagebox}->add (gtk::image_from_data $_[0]); |
192 | $self->{imagebox}->add (gtk::image_from_data $_[0]); |
|
|
193 | } |
180 | $self->{imagebox}->show_all; |
194 | $self->{imagebox}->show_all; |
181 | } |
195 | } |
182 | }); |
196 | }); |
183 | } |
197 | } |
184 | } |
198 | } |
… | |
… | |
252 | $vbox->pack_start ((my $frame = new Gtk2::Frame), 0, 1, 0); |
266 | $vbox->pack_start ((my $frame = new Gtk2::Frame), 0, 1, 0); |
253 | |
267 | |
254 | { |
268 | { |
255 | $frame->add (my $vbox = new Gtk2::VBox); |
269 | $frame->add (my $vbox = new Gtk2::VBox); |
256 | $vbox->add ($self->{title} = new Gtk2::Label "-"); |
270 | $vbox->add ($self->{title} = new Gtk2::Label "-"); |
|
|
271 | $self->{title}->set (visible => 0, no_show_all => 1); # workaround for refresh-bug |
257 | |
272 | |
258 | $vbox->add (my $hbox = new Gtk2::HBox); |
273 | $vbox->add (my $hbox = new Gtk2::HBox); |
259 | |
274 | |
260 | $hbox->pack_start (($self->{board_label} = new Gtk2::Label), 0, 0, 0); |
275 | $hbox->pack_start (($self->{board_label} = new Gtk2::Label), 0, 0, 0); |
261 | |
276 | |
… | |
… | |
277 | for COLOUR_WHITE, COLOUR_BLACK; |
292 | for COLOUR_WHITE, COLOUR_BLACK; |
278 | |
293 | |
279 | $vbox->pack_start ((my $buttonbox = new Gtk2::HButtonBox), 0, 1, 0); |
294 | $vbox->pack_start ((my $buttonbox = new Gtk2::HButtonBox), 0, 1, 0); |
280 | |
295 | |
281 | $buttonbox->add ($self->{button_pass} = |
296 | $buttonbox->add ($self->{button_pass} = |
282 | Gtk2::Button->Glib::Object::new (label => "Pass", visible => 0)); |
297 | Gtk2::Button->Glib::Object::new (label => "Pass", visible => 0, no_show_all => 1)); |
283 | $self->{button_pass}->signal_connect (clicked => sub { |
298 | $self->{button_pass}->signal_connect (clicked => sub { |
284 | $self->{board_click}->(255, 255) if $self->{board_click}; |
299 | $self->{board_click}->(255, 255) if $self->{board_click}; |
285 | }); |
300 | }); |
286 | eval { $self->{button_pass}->set (no_show_all => 1) }; # workaround for gtk+-2.2 |
|
|
287 | $buttonbox->add ($self->{button_undo} = |
301 | $buttonbox->add ($self->{button_undo} = |
288 | Gtk2::Button->Glib::Object::new (label => "Undo", visible => 0)); |
302 | Gtk2::Button->Glib::Object::new (label => "Undo", visible => 0, no_show_all => 1)); |
289 | $self->{button_undo}->signal_connect (clicked => sub { |
303 | $self->{button_undo}->signal_connect (clicked => sub { |
290 | $self->send (req_undo => channel => $self->{channel}); |
304 | $self->send (req_undo => channel => $self->{channel}); |
291 | }); |
305 | }); |
292 | eval { $self->{button_undo}->set (no_show_all => 1) }; # workaround for gtk+-2.2 |
|
|
293 | $buttonbox->add ($self->{button_resign} = |
306 | $buttonbox->add ($self->{button_resign} = |
294 | Gtk2::Button->Glib::Object::new (label => "Resign", visible => 0)); |
307 | Gtk2::Button->Glib::Object::new (label => "Resign", visible => 0, no_show_all => 1)); |
295 | $self->{button_resign}->signal_connect (clicked => sub { |
308 | $self->{button_resign}->signal_connect (clicked => sub { |
296 | $self->send (resign_game => channel => $self->{channel}, player => $self->{colour}); |
309 | $self->send (resign_game => channel => $self->{channel}, player => $self->{colour}); |
297 | }); |
310 | }); |
298 | eval { $self->{button_resign}->set (no_show_all => 1) }; # workaround for gtk+-2.2 |
|
|
299 | |
311 | |
300 | $vbox->pack_start (($self->{chat} = new chat), 1, 1, 0); |
312 | $vbox->pack_start (($self->{chat} = new chat app => $self->{app}), 1, 1, 0); |
|
|
313 | |
|
|
314 | $self->{chat}->signal_connect (tag_event => sub { |
|
|
315 | my (undef, $tag, $event, $content) = @_; |
|
|
316 | }); |
301 | |
317 | |
302 | $self->set_channel ($self->{channel}); |
318 | $self->set_channel ($self->{channel}); |
303 | |
319 | |
304 | $self->show_all; |
320 | $self->show_all; |
305 | |
321 | |
… | |
… | |
309 | sub set_channel { |
325 | sub set_channel { |
310 | my ($self, $channel) = @_; |
326 | my ($self, $channel) = @_; |
311 | |
327 | |
312 | $self->{channel} = $channel; |
328 | $self->{channel} = $channel; |
313 | |
329 | |
314 | if ($self->{channel} > 0) { |
330 | if (defined $self->{channel}) { |
315 | $self->listen ($self->{conn}); |
331 | $self->listen ($self->{conn}); |
316 | |
332 | |
317 | $self->{rules_inlay} = $self->{chat}->new_switchable_inlay ("Game Setup:", sub { $self->draw_setup (@_) }, 1); |
333 | $self->{rules_inlay} = $self->{chat}->new_switchable_inlay ("Game Setup:", sub { $self->draw_setup (@_) }, 1); |
318 | $self->{users_inlay} = $self->{chat}->new_switchable_inlay ("Users:", sub { $self->draw_users (@_) }, 1); |
334 | $self->{users_inlay} = $self->{chat}->new_switchable_inlay ("Users:", sub { $self->draw_users (@_) }, 1); |
319 | |
335 | |
320 | $self->signal_connect (delete_event => sub { $self->part; 1 }); |
336 | $self->signal_connect (delete_event => sub { $self->part; 1 }); |
321 | $self->{chat}->signal_connect (command => sub { |
337 | $self->{chat}->signal_connect (command => sub { |
322 | my ($chat, $cmd, $arg) = @_; |
338 | my ($chat, $cmd, $arg) = @_; |
323 | if ($cmd eq "rsave") { |
339 | if ($cmd eq "rsave") { |
|
|
340 | local $Storable::forgive_me = 1; |
324 | Storable::nstore { tree => $self->{tree}, curnode => $self->{curnode}, move => $self->{move} }, $arg;#d# |
341 | #Storable::nstore { tree => $self->{tree}, curnode => $self->{curnode}, move => $self->{move} }, $arg;#d# |
|
|
342 | Storable::nstore { %$self }, $arg;#d# |
325 | } else { |
343 | } else { |
326 | $self->{app}->do_command ($chat, $cmd, $arg, userlist => $self->{userlist}, game => $self); |
344 | $self->{app}->do_command ($chat, $cmd, $arg, userlist => $self->{userlist}, game => $self); |
327 | } |
345 | } |
328 | }); |
346 | }); |
329 | } |
347 | } |
… | |
… | |
371 | |
389 | |
372 | sub draw_users { |
390 | sub draw_users { |
373 | my ($self, $inlay) = @_; |
391 | my ($self, $inlay) = @_; |
374 | |
392 | |
375 | for (sort keys %{$self->{users}}) { |
393 | for (sort keys %{$self->{users}}) { |
376 | $inlay->append_text (" <user>" . $self->{users}{$_}->as_string . "</user>"); |
394 | $inlay->append_text ("\t<user>" . $self->{users}{$_}->as_string . "</user>"); |
377 | } |
395 | } |
378 | } |
396 | } |
379 | |
397 | |
380 | sub event_update_users { |
398 | sub event_update_users { |
381 | my ($self, $add, $update, $remove) = @_; |
399 | my ($self, $add, $update, $remove) = @_; |
… | |
… | |
496 | my $title = defined $self->{channel} |
514 | my $title = defined $self->{channel} |
497 | ? $self->owner->as_string . " " . $self->opponent_string |
515 | ? $self->owner->as_string . " " . $self->opponent_string |
498 | : "Game Window"; |
516 | : "Game Window"; |
499 | $self->set_title ("KGS Game $title"); |
517 | $self->set_title ("KGS Game $title"); |
500 | $self->{title}->set_text ($title); # title gets redrawn wrongly |
518 | $self->{title}->set_text ($title); # title gets redrawn wrongly |
|
|
519 | $self->{title}->show; # workaround for refresh-bug |
501 | |
520 | |
502 | $self->{rules_inlay}->refresh; |
521 | $self->{rules_inlay}->refresh; |
503 | |
522 | |
504 | if (exists $self->{teacher}) { |
523 | if (exists $self->{teacher}) { |
505 | $self->{teacher_inlay} ||= $self->{chat}->new_inlay; |
524 | $self->{teacher_inlay} ||= $self->{chat}->new_inlay; |
… | |
… | |
562 | sub update_cursor { |
581 | sub update_cursor { |
563 | my ($self) = @_; |
582 | my ($self) = @_; |
564 | |
583 | |
565 | return unless $self->{cur_board}; |
584 | return unless $self->{cur_board}; |
566 | |
585 | |
|
|
586 | if ($self->{rules}{ruleset} == RULESET_JAPANESE) { |
|
|
587 | if ($self->{curnode}{move} == 0) { |
|
|
588 | $self->{whosemove} = $self->{handicap} ? COLOUR_WHITE : COLOUR_BLACK; |
|
|
589 | } else { |
|
|
590 | $self->{whosemove} = 1 - $self->{cur_board}{last}; |
|
|
591 | } |
|
|
592 | } else { |
|
|
593 | # Chinese, Aga, NZ all have manual placement |
|
|
594 | if ($self->{curnode}{move} < $self->{handicap}) { |
|
|
595 | $self->{whosemove} = COLOUR_BLACK; |
|
|
596 | } elsif ($self->{curnode}{move} == $self->{handicap}) { |
|
|
597 | $self->{whosemove} = $self->{handicap} ? COLOUR_WHITE : COLOUR_BLACK; |
|
|
598 | } else { |
|
|
599 | $self->{whosemove} = 1 - $self->{cur_board}{last}; |
|
|
600 | } |
|
|
601 | } |
|
|
602 | |
567 | my $running = $self->{showmove} == @{$self->{path}} && $self->is_active; |
603 | my $running = $self->{showmove} == @{$self->{path}} && $self->is_active; |
568 | |
604 | |
569 | delete $self->{board_click}; |
605 | delete $self->{board_click}; |
570 | |
606 | |
571 | if ($self->{teacher} eq $self->{app}{conn}) { |
607 | if ($self->{teacher} eq $self->{app}{conn}) { |
572 | #TODO# # teaching mode not implemented |
608 | #TODO# # teaching mode not implemented |
573 | $self->{button_pass}->set (label => "Pass", visible => 1, sensitive => 1); |
609 | $self->{button_pass}->set (label => "Pass", sensitive => 1); |
|
|
610 | $self->{button_pass}->show; |
574 | $self->{button_undo}->hide; |
611 | $self->{button_undo}->hide; |
575 | $self->{button_resign}->hide; |
612 | $self->{button_resign}->hide; |
576 | $self->{board}->set (cursor => undef); |
613 | $self->{board}->set (cursor => undef); |
577 | |
614 | |
578 | } elsif ($running && $self->{colour} != COLOUR_NONE) { |
615 | } elsif ($running && $self->{colour} != COLOUR_NONE) { |
… | |
… | |
580 | $self->{button_undo}->show; |
617 | $self->{button_undo}->show; |
581 | $self->{button_resign}->show; |
618 | $self->{button_resign}->show; |
582 | |
619 | |
583 | if ($self->{cur_board}{score}) { |
620 | if ($self->{cur_board}{score}) { |
584 | # during scoring |
621 | # during scoring |
585 | $self->{button_pass}->set (label => "Done", visible => 1, sensitive => 1); |
622 | $self->{button_pass}->set (label => "Done", sensitive => 1); |
|
|
623 | $self->{button_pass}->show; |
586 | $self->{board}->set (cursor => sub { |
624 | $self->{board}->set (cursor => sub { |
587 | $_[0] & (MARK_B | MARK_W) |
625 | $_[0] & (MARK_B | MARK_W) |
588 | ? $_[0] ^ MARK_GRAYED |
626 | ? $_[0] ^ MARK_GRAYED |
589 | : $_[0]; |
627 | : $_[0]; |
590 | }); |
628 | }); |
… | |
… | |
602 | } |
640 | } |
603 | }; |
641 | }; |
604 | |
642 | |
605 | } elsif ($self->{colour} == $self->{whosemove}) { |
643 | } elsif ($self->{colour} == $self->{whosemove}) { |
606 | # normal move |
644 | # normal move |
607 | $self->{button_pass}->set (label => "Pass", visible => 1, sensitive => 1); |
645 | $self->{button_pass}->set (label => "Pass", sensitive => 1); |
|
|
646 | $self->{button_pass}->show; |
608 | $self->{board}->set (cursor => sub { |
647 | $self->{board}->set (cursor => sub { |
609 | $self->{cur_board} |
648 | $self->{cur_board} |
610 | && $self->{cur_board}->is_valid_move ($self->{colour}, $_[1], $_[2], |
649 | && $self->{cur_board}->is_valid_move ($self->{colour}, $_[1], $_[2], |
611 | $self->{rules}{ruleset} == RULESET_NEW_ZEALAND) |
650 | $self->{rules}{ruleset} == RULESET_NEW_ZEALAND) |
612 | ? $_[0] | MARK_GRAYED | ($self->{colour} == COLOUR_WHITE ? MARK_W : MARK_B) |
651 | ? $_[0] | MARK_GRAYED | ($self->{colour} == COLOUR_WHITE ? MARK_W : MARK_B) |
613 | : $_[0]; |
652 | : $_[0]; |
614 | }); |
653 | }); |
615 | $self->{board_click} = sub { |
654 | $self->{board_click} = sub { |
616 | return unless |
655 | return unless |
617 | $self->{cur_board}->is_valid_move ($self->{colour}, $_[1], $_[2], |
656 | $self->{cur_board}->is_valid_move ($self->{colour}, $_[0], $_[1], |
618 | $self->{rules}{ruleset} == RULESET_NEW_ZEALAND); |
657 | $self->{rules}{ruleset} == RULESET_NEW_ZEALAND); |
619 | $self->send (game_move => channel => $self->{channel}, x => $_[0], y => $_[1]); |
658 | $self->send (game_move => channel => $self->{channel}, x => $_[0], y => $_[1]); |
620 | $self->{board}->set (cursor => undef); |
659 | $self->{board}->set (cursor => undef); |
621 | delete $self->{board_click}; |
660 | delete $self->{board_click}; |
622 | $self->{button_pass}->sensitive (0); |
661 | $self->{button_pass}->sensitive (0); |
623 | }; |
662 | }; |
624 | } else { |
663 | } else { |
625 | $self->{button_pass}->set (label => "Pass", sensitive => 0, visible => 1); |
664 | $self->{button_pass}->set (label => "Pass", sensitive => 0); |
|
|
665 | $self->{button_pass}->show; |
626 | $self->{board}->set (cursor => undef); |
666 | $self->{board}->set (cursor => undef); |
627 | } |
667 | } |
628 | } else { |
668 | } else { |
629 | $self->{button_undo}->hide; |
669 | $self->{button_undo}->hide; |
630 | $self->{button_resign}->hide; |
670 | $self->{button_resign}->hide; |
… | |
… | |
642 | $self->{board_label}->set_text ("Move " . ($self->{showmove} - 1)); |
682 | $self->{board_label}->set_text ("Move " . ($self->{showmove} - 1)); |
643 | |
683 | |
644 | $self->{cur_board} = new KGS::Game::Board $self->{size}; |
684 | $self->{cur_board} = new KGS::Game::Board $self->{size}; |
645 | $self->{cur_board}->interpret_path ([@{$self->{path}}[0 .. $self->{showmove} - 1]]); |
685 | $self->{cur_board}->interpret_path ([@{$self->{path}}[0 .. $self->{showmove} - 1]]); |
646 | |
686 | |
647 | if ($self->{rules}{ruleset} == RULESET_JAPANESE) { |
|
|
648 | if ($self->{curnode}{move} == 0) { |
|
|
649 | $self->{whosemove} = $self->{handicap} ? COLOUR_WHITE : COLOUR_BLACK; |
|
|
650 | } else { |
|
|
651 | $self->{whosemove} = 1 - $self->{cur_board}{last}; |
|
|
652 | } |
|
|
653 | } else { |
|
|
654 | # Chinese, Aga, NZ all have manual placement |
|
|
655 | if ($self->{curnode}{move} < $self->{handicap}) { |
|
|
656 | $self->{whosemove} = COLOUR_BLACK; |
|
|
657 | } elsif ($self->{curnode}{move} == $self->{handicap}) { |
|
|
658 | $self->{whosemove} = $self->{handicap} ? COLOUR_WHITE : COLOUR_BLACK; |
|
|
659 | } else { |
|
|
660 | $self->{whosemove} = 1 - $self->{cur_board}{last}; |
|
|
661 | } |
|
|
662 | } |
|
|
663 | |
|
|
664 | $self->{userpanel}[$_]->set_captures ($self->{cur_board}{captures}[$_]) |
687 | $self->{userpanel}[$_]->set_captures ($self->{cur_board}{captures}[$_]) |
665 | for COLOUR_WHITE, COLOUR_BLACK; |
688 | for COLOUR_WHITE, COLOUR_BLACK; |
666 | |
689 | |
667 | my $start_time = $self->{rules}{time}; |
690 | $self->{board}->set_board ($self->{cur_board}); |
|
|
691 | |
|
|
692 | if ($self->{cur_board}{score}) { |
|
|
693 | $self->{score_inlay} ||= $self->{chat}->new_inlay; |
|
|
694 | $self->{score_inlay}->clear; |
|
|
695 | $self->{score_inlay}->append_text ("\n<header>Scoring</header>" |
|
|
696 | . "\n<score>" |
|
|
697 | . "White: $self->{cur_board}{score}[COLOUR_WHITE], " |
|
|
698 | . "Black: $self->{cur_board}{score}[COLOUR_BLACK]" |
|
|
699 | . "</score>"); |
|
|
700 | } elsif ($self->{score_inlay}) { |
|
|
701 | (delete $self->{score_inlay})->clear; |
|
|
702 | } |
|
|
703 | |
|
|
704 | $self->update_cursor; |
668 | |
705 | |
669 | if ($self->{showmove} == @{$self->{path}}) { |
706 | if ($self->{showmove} == @{$self->{path}}) { |
670 | $self->{timers} = [ |
707 | $self->{timers} = [ |
671 | [$self->{lastmove_time}, @{$self->{cur_board}{timer}[0]}], |
708 | [$self->{lastmove_time}, @{$self->{cur_board}{timer}[0]}], |
672 | [$self->{lastmove_time}, @{$self->{cur_board}{timer}[1]}], |
709 | [$self->{lastmove_time}, @{$self->{cur_board}{timer}[1]}], |
… | |
… | |
677 | [0, @{$self->{cur_board}{timer}[0]}], |
714 | [0, @{$self->{cur_board}{timer}[0]}], |
678 | [0, @{$self->{cur_board}{timer}[1]}], |
715 | [0, @{$self->{cur_board}{timer}[1]}], |
679 | ]); |
716 | ]); |
680 | } |
717 | } |
681 | |
718 | |
682 | $self->{board}->set_board ($self->{cur_board}); |
|
|
683 | |
|
|
684 | if ($self->{cur_board}{score}) { |
|
|
685 | $self->{score_inlay} ||= $self->{chat}->new_inlay; |
|
|
686 | $self->{score_inlay}->clear; |
|
|
687 | $self->{score_inlay}->append_text ("\n<header>Scoring</header>" |
|
|
688 | . "\n<score>" |
|
|
689 | . "White: $self->{cur_board}{score}[COLOUR_WHITE], " |
|
|
690 | . "Black: $self->{cur_board}{score}[COLOUR_BLACK]" |
|
|
691 | . "</score>"); |
|
|
692 | } elsif ($self->{score_inlay}) { |
|
|
693 | (delete $self->{score_inlay})->clear; |
|
|
694 | } |
|
|
695 | |
|
|
696 | $self->update_cursor; |
|
|
697 | |
|
|
698 | } |
719 | } |
699 | |
720 | |
700 | sub event_update_tree { |
721 | sub event_update_tree { |
701 | my ($self) = @_; |
722 | my ($self) = @_; |
702 | |
723 | |
… | |
… | |
720 | } |
741 | } |
721 | } |
742 | } |
722 | |
743 | |
723 | sub event_update_comments { |
744 | sub event_update_comments { |
724 | my ($self, $node, $comment, $newnode) = @_; |
745 | my ($self, $node, $comment, $newnode) = @_; |
725 | $self->SUPER::event_update_comments($node, $comment, $newnode); |
746 | $self->SUPER::event_update_comments ($node, $comment, $newnode); |
726 | |
747 | |
727 | my $text; |
748 | my $text; |
728 | |
749 | |
729 | $text .= "\n<header>Move <move>$node->{move}</move>, Node <node>$node->{id}</node></header>" |
750 | $text .= "\n<header>Move <move>$node->{move}</move>, Node <node>$node->{id}</node></header>" |
730 | if $newnode; |
751 | if $newnode; |
… | |
… | |
769 | my ($self, $player) = @_; |
790 | my ($self, $player) = @_; |
770 | |
791 | |
771 | sound::play 3, "resign"; |
792 | sound::play 3, "resign"; |
772 | $self->{chat}->append_text ("\n<infoblock><header>Resign</header>" |
793 | $self->{chat}->append_text ("\n<infoblock><header>Resign</header>" |
773 | . "\n<user>" |
794 | . "\n<user>" |
774 | . (util::toxml $self->{user}[$msg->{player}]->as_string) |
795 | . (util::toxml $self->{user}[$player]->as_string) |
775 | . "</user> resigned." |
796 | . "</user> resigned." |
776 | . "\n<user>" |
797 | . "\n<user>" |
777 | . (util::toxml $self->{user}[1 - $msg->{player}]->as_string) |
798 | . (util::toxml $self->{user}[1 - $player]->as_string) |
778 | . "</user> wins the game." |
799 | . "</user> wins the game." |
779 | . "</infoblock>"); |
800 | . "</infoblock>"); |
780 | } |
801 | } |
781 | |
802 | |
782 | sub event_time_win { |
803 | sub event_out_of_time { |
783 | my ($self, $player) = @_; |
804 | my ($self, $player) = @_; |
784 | |
805 | |
785 | sound::play 3, "timewin"; |
806 | sound::play 3, "timewin"; |
786 | $self->{chat}->append_text ("\n<infoblock><header>Out of Time</header>" |
807 | $self->{chat}->append_text ("\n<infoblock><header>Out of Time</header>" |
787 | . "\n<user>" |
808 | . "\n<user>" |
788 | . (util::toxml $self->{user}[1 - $msg->{player}]->as_string) |
809 | . (util::toxml $self->{user}[$msg->{1 - player}]->as_string) |
789 | . "</user> ran out of time and lost." |
810 | . "</user> ran out of time and lost." |
790 | . "\n<user>" |
811 | . "\n<user>" |
791 | . (util::toxml $self->{user}[$msg->{player}]->as_string) |
812 | . (util::toxml $self->{user}[$msg->{player}]->as_string) |
792 | . "</user> wins the game." |
813 | . "</user> wins the game." |
793 | . "</infoblock>"); |
814 | . "</infoblock>"); |
… | |
… | |
884 | my $as_black = $info->{black}{name} eq $self->{conn}{name} ? 1 : 0;; |
905 | my $as_black = $info->{black}{name} eq $self->{conn}{name} ? 1 : 0;; |
885 | my $opponent = $as_black ? $info->{white} : $info->{black}; |
906 | my $opponent = $as_black ? $info->{white} : $info->{black}; |
886 | |
907 | |
887 | my ($size, $time, $interval, $count, $type); |
908 | my ($size, $time, $interval, $count, $type); |
888 | |
909 | |
889 | if (!$self->{channel}) { |
910 | if (!defined $self->{channel}) { |
890 | $inlay->append_text ("\nNotes: "); |
911 | $inlay->append_text ("\nNotes: "); |
891 | $inlay->append_widget (gtk::textentry \$info->{notes}, 20, ""); |
912 | $inlay->append_widget (gtk::textentry \$info->{notes}, 20, ""); |
892 | $inlay->append_text ("\nGlobal Offer: "); |
913 | $inlay->append_text ("\nGlobal Offer: "); |
893 | $inlay->append_optionmenu (\$info->{flags}, |
914 | $inlay->append_optionmenu (\$info->{flags}, |
894 | 0 => "No", |
915 | 0 => "No", |
… | |
… | |
911 | sub { |
932 | sub { |
912 | $size->set_history (2) if $_[0] eq GAMETYPE_RATED; |
933 | $size->set_history (2) if $_[0] eq GAMETYPE_RATED; |
913 | }, |
934 | }, |
914 | ); |
935 | ); |
915 | |
936 | |
916 | if ($self->{channel}) { |
937 | if (defined $self->{channel}) { |
917 | $inlay->append_text ("\nMy Colour: "); |
938 | $inlay->append_text ("\nMy Colour: "); |
918 | $inlay->append_optionmenu ( |
939 | $inlay->append_optionmenu ( |
919 | \$as_black, |
940 | \$as_black, |
920 | 0 => "White", |
941 | 0 => "White", |
921 | 1 => "Black", |
942 | 1 => "Black", |
… | |
… | |
944 | $type->set_history (5) # reset to free |
965 | $type->set_history (5) # reset to free |
945 | if $_[0] != 19 && $info->{gametype} == GAMETYPE_RATED; |
966 | if $_[0] != 19 && $info->{gametype} == GAMETYPE_RATED; |
946 | }, |
967 | }, |
947 | ); |
968 | ); |
948 | |
969 | |
949 | if ($self->{channel}) { |
970 | if (defined $self->{channel}) { |
950 | $inlay->append_text ("\nHandicap: "); |
971 | $inlay->append_text ("\nHandicap: "); |
951 | $inlay->append_optionmenu (\$info->{rules}{handicap}, map +($_, $_), 0..9); |
972 | $inlay->append_optionmenu (\$info->{rules}{handicap}, map +($_, $_), 0..9); |
952 | |
973 | |
953 | $inlay->append_text ("\nKomi: "); |
974 | $inlay->append_text ("\nKomi: "); |
954 | $inlay->append_widget (gtk::numentry \$info->{rules}{komi}, 5); |
975 | $inlay->append_widget (gtk::numentry \$info->{rules}{komi}, 5); |
… | |
… | |
996 | $inlay->append_text ("\nPeriods/Stones: "); |
1017 | $inlay->append_text ("\nPeriods/Stones: "); |
997 | $count = $inlay->append_widget (gtk::numentry \$info->{rules}{count}, 5); |
1018 | $count = $inlay->append_widget (gtk::numentry \$info->{rules}{count}, 5); |
998 | |
1019 | |
999 | $inlay->append_text ("\n"); |
1020 | $inlay->append_text ("\n"); |
1000 | |
1021 | |
1001 | if (!$self->{channel}) { |
1022 | if (!defined $self->{channel}) { |
1002 | $inlay->append_button ("Create Challenge", sub { |
1023 | $inlay->append_button ("Create Challenge", sub { |
1003 | $inlay->clear; |
1024 | $inlay->clear; |
1004 | $self->{cid} = $self->{conn}->alloc_clientid; |
1025 | $self->{cid} = $self->{conn}->alloc_clientid; |
1005 | $self->send (new_game => |
1026 | $self->send (new_game => |
1006 | channel => delete $self->{roomid}, |
1027 | channel => delete $self->{roomid}, |