… | |
… | |
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 | } |
… | |
… | |
218 | |
232 | |
219 | use POSIX qw(ceil); |
233 | use POSIX qw(ceil); |
220 | |
234 | |
221 | sub new { |
235 | sub new { |
222 | my ($self, %arg) = @_; |
236 | my ($self, %arg) = @_; |
|
|
237 | |
223 | $self = $self->Glib::Object::new; |
238 | $self = $self->Glib::Object::new; |
224 | $self->{$_} = delete $arg{$_} for keys %arg; |
239 | $self->{$_} = delete $arg{$_} for keys %arg; |
225 | |
240 | |
226 | gtk::state $self, "game::window", undef, window_size => [600, 500]; |
241 | gtk::state $self, "game::window", undef, window_size => [620, 460]; |
|
|
242 | $self->set (allow_shrink => 1); |
227 | |
243 | |
228 | $self->signal_connect (destroy => sub { |
244 | $self->signal_connect (destroy => sub { |
229 | $self->unlisten; |
245 | $self->unlisten; |
230 | delete $self->{app}{game}{$self->{channel}}; |
246 | delete $self->{app}{game}{$self->{channel}}; |
231 | %{$_[0]} = (); |
247 | %{$_[0]} = (); |
232 | });#d# |
248 | });#d# |
233 | |
249 | |
234 | $self->add (my $hpane = new Gtk2::HPaned); |
250 | $self->add (my $hpane = new Gtk2::HPaned); |
235 | gtk::state $hpane, "game::hpane", undef, position => 500; |
251 | gtk::state $hpane, "game::hpane", undef, position => 420; |
236 | |
252 | |
237 | # LEFT PANE |
253 | # LEFT PANE |
238 | |
254 | |
239 | $hpane->pack1 (($self->{left} = new Gtk2::VBox), 1, 0); |
255 | $hpane->pack1 (($self->{left} = new Gtk2::VBox), 1, 0); |
240 | |
256 | |
… | |
… | |
275 | for COLOUR_WHITE, COLOUR_BLACK; |
291 | for COLOUR_WHITE, COLOUR_BLACK; |
276 | |
292 | |
277 | $vbox->pack_start ((my $buttonbox = new Gtk2::HButtonBox), 0, 1, 0); |
293 | $vbox->pack_start ((my $buttonbox = new Gtk2::HButtonBox), 0, 1, 0); |
278 | |
294 | |
279 | $buttonbox->add ($self->{button_pass} = |
295 | $buttonbox->add ($self->{button_pass} = |
280 | Gtk2::Button->Glib::Object::new (label => "Pass", no_show_all => 1, visible => 0)); |
296 | Gtk2::Button->Glib::Object::new (label => "Pass", visible => 0, no_show_all => 1)); |
281 | $self->{button_pass}->signal_connect (clicked => sub { |
297 | $self->{button_pass}->signal_connect (clicked => sub { |
282 | $self->{board_click}->(255, 255) if $self->{board_click}; |
298 | $self->{board_click}->(255, 255) if $self->{board_click}; |
283 | }); |
299 | }); |
284 | $buttonbox->add ($self->{button_undo} = |
300 | $buttonbox->add ($self->{button_undo} = |
285 | Gtk2::Button->Glib::Object::new (label => "Undo", no_show_all => 1, visible => 0)); |
301 | Gtk2::Button->Glib::Object::new (label => "Undo", visible => 0, no_show_all => 1)); |
286 | $self->{button_undo}->signal_connect (clicked => sub { |
302 | $self->{button_undo}->signal_connect (clicked => sub { |
287 | $self->send (req_undo => channel => $self->{channel}); |
303 | $self->send (req_undo => channel => $self->{channel}); |
288 | }); |
304 | }); |
289 | $buttonbox->add ($self->{button_resign} = |
305 | $buttonbox->add ($self->{button_resign} = |
290 | Gtk2::Button->Glib::Object::new (label => "Resign", no_show_all => 1, visible => 0)); |
306 | Gtk2::Button->Glib::Object::new (label => "Resign", visible => 0, no_show_all => 1)); |
291 | $self->{button_resign}->signal_connect (clicked => sub { |
307 | $self->{button_resign}->signal_connect (clicked => sub { |
292 | $self->send (resign_game => channel => $self->{channel}, player => $self->{colour}); |
308 | $self->send (resign_game => channel => $self->{channel}, player => $self->{colour}); |
293 | }); |
309 | }); |
294 | |
310 | |
295 | $vbox->pack_start (($self->{chat} = new superchat), 1, 1, 0); |
311 | $vbox->pack_start (($self->{chat} = new chat app => $self->{app}), 1, 1, 0); |
|
|
312 | |
|
|
313 | $self->{chat}->signal_connect (tag_event => sub { |
|
|
314 | my (undef, $tag, $event, $content) = @_; |
|
|
315 | }); |
296 | |
316 | |
297 | $self->set_channel ($self->{channel}); |
317 | $self->set_channel ($self->{channel}); |
298 | |
318 | |
299 | $self->show_all; |
319 | $self->show_all; |
300 | |
320 | |
… | |
… | |
331 | return if $self->{joined}; |
351 | return if $self->{joined}; |
332 | |
352 | |
333 | $self->SUPER::join; |
353 | $self->SUPER::join; |
334 | } |
354 | } |
335 | |
355 | |
|
|
356 | sub part { |
|
|
357 | my ($self) = @_; |
|
|
358 | |
|
|
359 | $self->hide; |
|
|
360 | $self->SUPER::part; |
|
|
361 | } |
|
|
362 | |
336 | sub event_join { |
363 | sub event_join { |
337 | my ($self) = @_; |
364 | my ($self) = @_; |
338 | |
365 | |
339 | $self->SUPER::event_join (@_); |
366 | $self->SUPER::event_join (@_); |
340 | $self->init_tree; |
367 | $self->init_tree; |
… | |
… | |
359 | |
386 | |
360 | sub draw_users { |
387 | sub draw_users { |
361 | my ($self, $inlay) = @_; |
388 | my ($self, $inlay) = @_; |
362 | |
389 | |
363 | for (sort keys %{$self->{users}}) { |
390 | for (sort keys %{$self->{users}}) { |
364 | $inlay->append_text (" <user>" . $self->{users}{$_}->as_string . "</user>"); |
391 | $inlay->append_text ("\t<user>" . $self->{users}{$_}->as_string . "</user>"); |
365 | } |
392 | } |
366 | } |
393 | } |
367 | |
394 | |
368 | sub event_update_users { |
395 | sub event_update_users { |
369 | my ($self, $add, $update, $remove) = @_; |
396 | my ($self, $add, $update, $remove) = @_; |
… | |
… | |
379 | $important{$self->{black}{name}}++; |
406 | $important{$self->{black}{name}}++; |
380 | $important{$self->{white}{name}}++; |
407 | $important{$self->{white}{name}}++; |
381 | $important{$self->{owner}{name}}++; |
408 | $important{$self->{owner}{name}}++; |
382 | |
409 | |
383 | if (my @users = grep $important{$_->{name}}, @$add) { |
410 | if (my @users = grep $important{$_->{name}}, @$add) { |
384 | $self->{chat}->append_text ("\n<header>Joins:</header>"); |
411 | $self->{chat}->append_text ("\n<leader>Joins:</leader>"); |
385 | $self->{chat}->append_text (" <user>" . $_->as_string . "</user>") for @users; |
412 | $self->{chat}->append_text (" <user>" . $_->as_string . "</user>") for @users; |
386 | } |
413 | } |
387 | if (my @users = grep $important{$_->{name}}, @$remove) { |
414 | if (my @users = grep $important{$_->{name}}, @$remove) { |
388 | $self->{chat}->append_text ("\n<header>Parts:</header>"); |
415 | $self->{chat}->append_text ("\n<leader>Parts:</leader>"); |
389 | $self->{chat}->append_text (" <user>" . $_->as_string . "</user>") for @users; |
416 | $self->{chat}->append_text (" <user>" . $_->as_string . "</user>") for @users; |
390 | } |
417 | } |
391 | } |
418 | } |
392 | |
419 | |
393 | ### GAME INFO ############################################################### |
420 | ### GAME INFO ############################################################### |
… | |
… | |
550 | sub update_cursor { |
577 | sub update_cursor { |
551 | my ($self) = @_; |
578 | my ($self) = @_; |
552 | |
579 | |
553 | return unless $self->{cur_board}; |
580 | return unless $self->{cur_board}; |
554 | |
581 | |
|
|
582 | if ($self->{rules}{ruleset} == RULESET_JAPANESE) { |
|
|
583 | if ($self->{curnode}{move} == 0) { |
|
|
584 | $self->{whosemove} = $self->{handicap} ? COLOUR_WHITE : COLOUR_BLACK; |
|
|
585 | } else { |
|
|
586 | $self->{whosemove} = 1 - $self->{cur_board}{last}; |
|
|
587 | } |
|
|
588 | } else { |
|
|
589 | # Chinese, Aga, NZ all have manual placement |
|
|
590 | if ($self->{curnode}{move} < $self->{handicap}) { |
|
|
591 | $self->{whosemove} = COLOUR_BLACK; |
|
|
592 | } elsif ($self->{curnode}{move} == $self->{handicap}) { |
|
|
593 | $self->{whosemove} = $self->{handicap} ? COLOUR_WHITE : COLOUR_BLACK; |
|
|
594 | } else { |
|
|
595 | $self->{whosemove} = 1 - $self->{cur_board}{last}; |
|
|
596 | } |
|
|
597 | } |
|
|
598 | |
555 | my $running = $self->{showmove} == @{$self->{path}} && $self->is_active; |
599 | my $running = $self->{showmove} == @{$self->{path}} && $self->is_active; |
556 | |
600 | |
557 | delete $self->{board_click}; |
601 | delete $self->{board_click}; |
558 | |
602 | |
559 | if ($self->{teacher} eq $self->{app}{conn}) { |
603 | if ($self->{teacher} eq $self->{app}{conn}) { |
560 | #TODO# # teaching mode not implemented |
604 | #TODO# # teaching mode not implemented |
561 | $self->{button_pass}->set (label => "Pass", visible => 1, sensitive => 1); |
605 | $self->{button_pass}->set (label => "Pass", sensitive => 1); |
|
|
606 | $self->{button_pass}->show; |
562 | $self->{button_undo}->hide; |
607 | $self->{button_undo}->hide; |
563 | $self->{button_resign}->hide; |
608 | $self->{button_resign}->hide; |
564 | $self->{board}->set (cursor => undef); |
609 | $self->{board}->set (cursor => undef); |
565 | |
610 | |
566 | } elsif ($running && $self->{colour} != COLOUR_NONE) { |
611 | } elsif ($running && $self->{colour} != COLOUR_NONE) { |
… | |
… | |
568 | $self->{button_undo}->show; |
613 | $self->{button_undo}->show; |
569 | $self->{button_resign}->show; |
614 | $self->{button_resign}->show; |
570 | |
615 | |
571 | if ($self->{cur_board}{score}) { |
616 | if ($self->{cur_board}{score}) { |
572 | # during scoring |
617 | # during scoring |
573 | $self->{button_pass}->set (label => "Done", visible => 1, sensitive => 1); |
618 | $self->{button_pass}->set (label => "Done", sensitive => 1); |
|
|
619 | $self->{button_pass}->show; |
574 | $self->{board}->set (cursor => sub { |
620 | $self->{board}->set (cursor => sub { |
575 | $_[0] & (MARK_B | MARK_W) |
621 | $_[0] & (MARK_B | MARK_W) |
576 | ? $_[0] ^ MARK_GRAYED |
622 | ? $_[0] ^ MARK_GRAYED |
577 | : $_[0]; |
623 | : $_[0]; |
578 | }); |
624 | }); |
… | |
… | |
590 | } |
636 | } |
591 | }; |
637 | }; |
592 | |
638 | |
593 | } elsif ($self->{colour} == $self->{whosemove}) { |
639 | } elsif ($self->{colour} == $self->{whosemove}) { |
594 | # normal move |
640 | # normal move |
595 | $self->{button_pass}->set (label => "Pass", visible => 1, sensitive => 1); |
641 | $self->{button_pass}->set (label => "Pass", sensitive => 1); |
|
|
642 | $self->{button_pass}->show; |
596 | $self->{board}->set (cursor => sub { |
643 | $self->{board}->set (cursor => sub { |
597 | $self->{cur_board} |
644 | $self->{cur_board} |
598 | && $self->{cur_board}->is_valid_move ($self->{colour}, $_[1], $_[2], |
645 | && $self->{cur_board}->is_valid_move ($self->{colour}, $_[1], $_[2], |
599 | $self->{rules}{ruleset} == RULESET_NEW_ZEALAND) |
646 | $self->{rules}{ruleset} == RULESET_NEW_ZEALAND) |
600 | ? $_[0] | MARK_GRAYED | ($self->{colour} == COLOUR_WHITE ? MARK_W : MARK_B) |
647 | ? $_[0] | MARK_GRAYED | ($self->{colour} == COLOUR_WHITE ? MARK_W : MARK_B) |
601 | : $_[0]; |
648 | : $_[0]; |
602 | }); |
649 | }); |
603 | $self->{board_click} = sub { |
650 | $self->{board_click} = sub { |
604 | return unless |
651 | return unless |
605 | $self->{cur_board}->is_valid_move ($self->{colour}, $_[1], $_[2], |
652 | $self->{cur_board}->is_valid_move ($self->{colour}, $_[0], $_[1], |
606 | $self->{rules}{ruleset} == RULESET_NEW_ZEALAND); |
653 | $self->{rules}{ruleset} == RULESET_NEW_ZEALAND); |
607 | $self->send (game_move => channel => $self->{channel}, x => $_[0], y => $_[1]); |
654 | $self->send (game_move => channel => $self->{channel}, x => $_[0], y => $_[1]); |
608 | $self->{board}->set (cursor => undef); |
655 | $self->{board}->set (cursor => undef); |
609 | delete $self->{board_click}; |
656 | delete $self->{board_click}; |
610 | $self->{button_pass}->sensitive (0); |
657 | $self->{button_pass}->sensitive (0); |
611 | }; |
658 | }; |
612 | } else { |
659 | } else { |
613 | $self->{button_pass}->set (label => "Pass", sensitive => 0, visible => 1); |
660 | $self->{button_pass}->set (label => "Pass", sensitive => 0); |
|
|
661 | $self->{button_pass}->show; |
614 | $self->{board}->set (cursor => undef); |
662 | $self->{board}->set (cursor => undef); |
615 | } |
663 | } |
616 | } else { |
664 | } else { |
617 | $self->{button_undo}->hide; |
665 | $self->{button_undo}->hide; |
618 | $self->{button_resign}->hide; |
666 | $self->{button_resign}->hide; |
… | |
… | |
625 | sub update_board { |
673 | sub update_board { |
626 | my ($self) = @_; |
674 | my ($self) = @_; |
627 | |
675 | |
628 | return unless $self->{path}; |
676 | return unless $self->{path}; |
629 | |
677 | |
630 | if ($self->{rules}{ruleset} == RULESET_JAPANESE) { |
|
|
631 | if ($self->{curnode}{move} == 0) { |
|
|
632 | $self->{whosemove} = $self->{handicap} ? COLOUR_WHITE : COLOUR_BLACK; |
|
|
633 | } else { |
|
|
634 | $self->{whosemove} = 1 - $self->{cur_board}{last}; |
|
|
635 | } |
|
|
636 | } else { |
|
|
637 | # Chinese, Aga, NZ all have manual placement |
|
|
638 | if ($self->{curnode}{move} < $self->{handicap}) { |
|
|
639 | $self->{whosemove} = COLOUR_BLACK; |
|
|
640 | } elsif ($self->{curnode}{move} == $self->{handicap}) { |
|
|
641 | $self->{whosemove} = $self->{handicap} ? COLOUR_WHITE : COLOUR_BLACK; |
|
|
642 | } else { |
|
|
643 | $self->{whosemove} = 1 - $self->{cur_board}{last}; |
|
|
644 | } |
|
|
645 | } |
|
|
646 | |
|
|
647 | $self->{board_label}->set_text ("Move " . ($self->{showmove} - 1)); |
678 | $self->{board_label}->set_text ("Move " . ($self->{showmove} - 1)); |
648 | |
679 | |
649 | $self->{cur_board} = new KGS::Game::Board $self->{size}; |
680 | $self->{cur_board} = new KGS::Game::Board $self->{size}; |
650 | $self->{cur_board}->interpret_path ([@{$self->{path}}[0 .. $self->{showmove} - 1]]); |
681 | $self->{cur_board}->interpret_path ([@{$self->{path}}[0 .. $self->{showmove} - 1]]); |
651 | |
682 | |
652 | $self->update_cursor; |
|
|
653 | |
|
|
654 | $self->{userpanel}[$_]->set_captures ($self->{cur_board}{captures}[$_]) |
683 | $self->{userpanel}[$_]->set_captures ($self->{cur_board}{captures}[$_]) |
655 | for COLOUR_WHITE, COLOUR_BLACK; |
684 | for COLOUR_WHITE, COLOUR_BLACK; |
656 | |
685 | |
657 | my $start_time = $self->{rules}{time}; |
686 | $self->{board}->set_board ($self->{cur_board}); |
|
|
687 | |
|
|
688 | if ($self->{cur_board}{score}) { |
|
|
689 | $self->{score_inlay} ||= $self->{chat}->new_inlay; |
|
|
690 | $self->{score_inlay}->clear; |
|
|
691 | $self->{score_inlay}->append_text ("\n<header>Scoring</header>" |
|
|
692 | . "\n<score>" |
|
|
693 | . "White: $self->{cur_board}{score}[COLOUR_WHITE], " |
|
|
694 | . "Black: $self->{cur_board}{score}[COLOUR_BLACK]" |
|
|
695 | . "</score>"); |
|
|
696 | } elsif ($self->{score_inlay}) { |
|
|
697 | (delete $self->{score_inlay})->clear; |
|
|
698 | } |
|
|
699 | |
|
|
700 | $self->update_cursor; |
658 | |
701 | |
659 | if ($self->{showmove} == @{$self->{path}}) { |
702 | if ($self->{showmove} == @{$self->{path}}) { |
660 | $self->{timers} = [ |
703 | $self->{timers} = [ |
661 | [$self->{lastmove_time}, @{$self->{cur_board}{timer}[0]}], |
704 | [$self->{lastmove_time}, @{$self->{cur_board}{timer}[0]}], |
662 | [$self->{lastmove_time}, @{$self->{cur_board}{timer}[1]}], |
705 | [$self->{lastmove_time}, @{$self->{cur_board}{timer}[1]}], |
… | |
… | |
667 | [0, @{$self->{cur_board}{timer}[0]}], |
710 | [0, @{$self->{cur_board}{timer}[0]}], |
668 | [0, @{$self->{cur_board}{timer}[1]}], |
711 | [0, @{$self->{cur_board}{timer}[1]}], |
669 | ]); |
712 | ]); |
670 | } |
713 | } |
671 | |
714 | |
672 | $self->{board}->set_board ($self->{cur_board}); |
|
|
673 | |
|
|
674 | if ($self->{cur_board}{score}) { |
|
|
675 | $self->{score_inlay} ||= $self->{chat}->new_inlay; |
|
|
676 | $self->{score_inlay}->clear; |
|
|
677 | $self->{score_inlay}->append_text ("\n<header>Scoring</header>" |
|
|
678 | . "\n<score>" |
|
|
679 | . "White: $self->{cur_board}{score}[COLOUR_WHITE], " |
|
|
680 | . "Black: $self->{cur_board}{score}[COLOUR_BLACK]" |
|
|
681 | . "</score>"); |
|
|
682 | } elsif ($self->{score_inlay}) { |
|
|
683 | (delete $self->{score_inlay})->clear; |
|
|
684 | } |
|
|
685 | } |
715 | } |
686 | |
716 | |
687 | sub event_update_tree { |
717 | sub event_update_tree { |
688 | my ($self) = @_; |
718 | my ($self) = @_; |
689 | |
719 | |
… | |
… | |
707 | } |
737 | } |
708 | } |
738 | } |
709 | |
739 | |
710 | sub event_update_comments { |
740 | sub event_update_comments { |
711 | my ($self, $node, $comment, $newnode) = @_; |
741 | my ($self, $node, $comment, $newnode) = @_; |
712 | $self->SUPER::event_update_comments($node, $comment, $newnode); |
742 | $self->SUPER::event_update_comments ($node, $comment, $newnode); |
713 | |
743 | |
714 | my $text; |
744 | my $text; |
715 | |
745 | |
716 | $text .= "\n<header>Move <move>$node->{move}</move>, Node <node>$node->{id}</node></header>" |
746 | $text .= "\n<header>Move <move>$node->{move}</move>, Node <node>$node->{id}</node></header>" |
717 | if $newnode; |
747 | if $newnode; |
… | |
… | |
756 | my ($self, $player) = @_; |
786 | my ($self, $player) = @_; |
757 | |
787 | |
758 | sound::play 3, "resign"; |
788 | sound::play 3, "resign"; |
759 | $self->{chat}->append_text ("\n<infoblock><header>Resign</header>" |
789 | $self->{chat}->append_text ("\n<infoblock><header>Resign</header>" |
760 | . "\n<user>" |
790 | . "\n<user>" |
761 | . (util::toxml $self->{user}[$msg->{player}]->as_string) |
791 | . (util::toxml $self->{user}[$player]->as_string) |
762 | . "</user> resigned." |
792 | . "</user> resigned." |
763 | . "\n<user>" |
793 | . "\n<user>" |
764 | . (util::toxml $self->{user}[1 - $msg->{player}]->as_string) |
794 | . (util::toxml $self->{user}[1 - $player]->as_string) |
765 | . "</user> wins the game." |
795 | . "</user> wins the game." |
766 | . "</infoblock>"); |
796 | . "</infoblock>"); |
767 | } |
797 | } |
768 | |
798 | |
769 | sub event_time_win { |
799 | sub event_out_of_time { |
770 | my ($self, $player) = @_; |
800 | my ($self, $player) = @_; |
771 | |
801 | |
772 | sound::play 3, "timewin"; |
802 | sound::play 3, "timewin"; |
773 | $self->{chat}->append_text ("\n<infoblock><header>Out of Time</header>" |
803 | $self->{chat}->append_text ("\n<infoblock><header>Out of Time</header>" |
774 | . "\n<user>" |
804 | . "\n<user>" |
775 | . (util::toxml $self->{user}[1 - $msg->{player}]->as_string) |
805 | . (util::toxml $self->{user}[$msg->{player}]->as_string) |
776 | . "</user> ran out of time and lost." |
806 | . "</user> ran out of time and lost." |
777 | . "\n<user>" |
807 | . "\n<user>" |
778 | . (util::toxml $self->{user}[$msg->{player}]->as_string) |
808 | . (util::toxml $self->{user}[1 - $msg->{player}]->as_string) |
779 | . "</user> wins the game." |
809 | . "</user> wins the game." |
780 | . "</infoblock>"); |
810 | . "</infoblock>"); |
781 | } |
811 | } |
782 | |
812 | |
783 | sub event_owner_left { |
813 | sub event_owner_left { |
… | |
… | |
873 | |
903 | |
874 | my ($size, $time, $interval, $count, $type); |
904 | my ($size, $time, $interval, $count, $type); |
875 | |
905 | |
876 | if (!$self->{channel}) { |
906 | if (!$self->{channel}) { |
877 | $inlay->append_text ("\nNotes: "); |
907 | $inlay->append_text ("\nNotes: "); |
878 | $inlay->append_entry (\$info->{notes}, 20, ""); |
908 | $inlay->append_widget (gtk::textentry \$info->{notes}, 20, ""); |
879 | $inlay->append_text ("\nGlobal Offer: "); |
909 | $inlay->append_text ("\nGlobal Offer: "); |
880 | $inlay->append_optionmenu (\$info->{flags}, |
910 | $inlay->append_optionmenu (\$info->{flags}, |
881 | 0 => "No", |
911 | 0 => "No", |
882 | 2 => "Yes", |
912 | 2 => "Yes", |
883 | ); |
913 | ); |
… | |
… | |
936 | if ($self->{channel}) { |
966 | if ($self->{channel}) { |
937 | $inlay->append_text ("\nHandicap: "); |
967 | $inlay->append_text ("\nHandicap: "); |
938 | $inlay->append_optionmenu (\$info->{rules}{handicap}, map +($_, $_), 0..9); |
968 | $inlay->append_optionmenu (\$info->{rules}{handicap}, map +($_, $_), 0..9); |
939 | |
969 | |
940 | $inlay->append_text ("\nKomi: "); |
970 | $inlay->append_text ("\nKomi: "); |
941 | $inlay->append_entry (\$info->{rules}{komi}, 5); |
971 | $inlay->append_widget (gtk::numentry \$info->{rules}{komi}, 5); |
942 | } |
972 | } |
943 | |
973 | |
944 | $inlay->append_text ("\nTimesys: "); |
974 | $inlay->append_text ("\nTimesys: "); |
945 | $inlay->append_optionmenu ( |
975 | $inlay->append_optionmenu ( |
946 | \$info->{rules}{timesys}, |
976 | \$info->{rules}{timesys}, |
… | |
… | |
975 | } |
1005 | } |
976 | } |
1006 | } |
977 | ); |
1007 | ); |
978 | |
1008 | |
979 | $inlay->append_text ("\nMain Time: "); |
1009 | $inlay->append_text ("\nMain Time: "); |
980 | $time = $inlay->append_entry (\$info->{rules}{time}, 5); |
1010 | $time = $inlay->append_widget (gtk::timeentry \$info->{rules}{time}, 5); |
981 | $inlay->append_text ("\nInterval: "); |
1011 | $inlay->append_text ("\nInterval: "); |
982 | $interval = $inlay->append_entry (\$info->{rules}{interval}, 3); |
1012 | $interval = $inlay->append_widget (gtk::timeentry \$info->{rules}{interval}, 5); |
983 | $inlay->append_text ("\nPeriods/Stones: "); |
1013 | $inlay->append_text ("\nPeriods/Stones: "); |
984 | $count = $inlay->append_entry (\$info->{rules}{count}, 2); |
1014 | $count = $inlay->append_widget (gtk::numentry \$info->{rules}{count}, 5); |
985 | |
1015 | |
986 | $inlay->append_text ("\n"); |
1016 | $inlay->append_text ("\n"); |
987 | |
1017 | |
988 | if (!$self->{channel}) { |
1018 | if (!$self->{channel}) { |
989 | $inlay->append_button ("Create Challenge", sub { |
1019 | $inlay->append_button ("Create Challenge", sub { |