ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/kgsueme/kgsueme/game.pl
(Generate patch)

Comparing kgsueme/kgsueme/game.pl (file contents):
Revision 1.121 by root, Wed Jun 2 04:39:07 2004 UTC vs.
Revision 1.140 by root, Wed Oct 13 00:33:15 2004 UTC

146 ]; 146 ];
147 147
148sub INIT_INSTANCE { 148sub 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
164sub SET_PROPERTY {
165 my ($self, $pspec, $value) = @_;
166
167 $self->{$pspec->get_name} = $value;
168
169 $self->set_name ("userpanel-$self->{colour}");
170}
171
162sub configure { 172sub 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 }
223 237
224 $self = $self->Glib::Object::new; 238 $self = $self->Glib::Object::new;
225 $self->{$_} = delete $arg{$_} for keys %arg; 239 $self->{$_} = delete $arg{$_} for keys %arg;
226 240
227 gtk::state $self, "game::window", undef, window_size => [620, 460]; 241 gtk::state $self, "game::window", undef, window_size => [620, 460];
242 $self->set (allow_shrink => 1);
228 243
229 $self->signal_connect (destroy => sub { 244 $self->signal_connect (destroy => sub {
230 $self->unlisten; 245 $self->unlisten;
231 delete $self->{app}{game}{$self->{channel}}; 246 delete $self->{app}{game}{$self->{channel}};
232 %{$_[0]} = (); 247 %{$_[0]} = ();
251 $vbox->pack_start ((my $frame = new Gtk2::Frame), 0, 1, 0); 266 $vbox->pack_start ((my $frame = new Gtk2::Frame), 0, 1, 0);
252 267
253 { 268 {
254 $frame->add (my $vbox = new Gtk2::VBox); 269 $frame->add (my $vbox = new Gtk2::VBox);
255 $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
256 272
257 $vbox->add (my $hbox = new Gtk2::HBox); 273 $vbox->add (my $hbox = new Gtk2::HBox);
258 274
259 $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);
260 276
276 for COLOUR_WHITE, COLOUR_BLACK; 292 for COLOUR_WHITE, COLOUR_BLACK;
277 293
278 $vbox->pack_start ((my $buttonbox = new Gtk2::HButtonBox), 0, 1, 0); 294 $vbox->pack_start ((my $buttonbox = new Gtk2::HButtonBox), 0, 1, 0);
279 295
280 $buttonbox->add ($self->{button_pass} = 296 $buttonbox->add ($self->{button_pass} =
281 Gtk2::Button->Glib::Object::new (label => "Pass", visible => 0)); 297 Gtk2::Button->Glib::Object::new (label => "Pass", visible => 0, no_show_all => 1));
282 $self->{button_pass}->signal_connect (clicked => sub { 298 $self->{button_pass}->signal_connect (clicked => sub {
283 $self->{board_click}->(255, 255) if $self->{board_click}; 299 $self->{board_click}->(255, 255) if $self->{board_click};
284 }); 300 });
285 eval { $self->{button_pass}->set (no_show_all => 1) }; # workaround for gtk+-2.2
286 $buttonbox->add ($self->{button_undo} = 301 $buttonbox->add ($self->{button_undo} =
287 Gtk2::Button->Glib::Object::new (label => "Undo", visible => 0)); 302 Gtk2::Button->Glib::Object::new (label => "Undo", visible => 0, no_show_all => 1));
288 $self->{button_undo}->signal_connect (clicked => sub { 303 $self->{button_undo}->signal_connect (clicked => sub {
289 $self->send (req_undo => channel => $self->{channel}); 304 $self->send (req_undo => channel => $self->{channel});
290 }); 305 });
291 eval { $self->{button_undo}->set (no_show_all => 1) }; # workaround for gtk+-2.2
292 $buttonbox->add ($self->{button_resign} = 306 $buttonbox->add ($self->{button_resign} =
293 Gtk2::Button->Glib::Object::new (label => "Resign", visible => 0)); 307 Gtk2::Button->Glib::Object::new (label => "Resign", visible => 0, no_show_all => 1));
294 $self->{button_resign}->signal_connect (clicked => sub { 308 $self->{button_resign}->signal_connect (clicked => sub {
295 $self->send (resign_game => channel => $self->{channel}, player => $self->{colour}); 309 $self->send (resign_game => channel => $self->{channel}, player => $self->{colour});
296 }); 310 });
297 eval { $self->{button_resign}->set (no_show_all => 1) }; # workaround for gtk+-2.2
298 311
299 $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 });
300 317
301 $self->set_channel ($self->{channel}); 318 $self->set_channel ($self->{channel});
302 319
303 $self->show_all; 320 $self->show_all;
304 321
308sub set_channel { 325sub set_channel {
309 my ($self, $channel) = @_; 326 my ($self, $channel) = @_;
310 327
311 $self->{channel} = $channel; 328 $self->{channel} = $channel;
312 329
313 if ($self->{channel} > 0) { 330 if (defined $self->{channel}) {
314 $self->listen ($self->{conn}); 331 $self->listen ($self->{conn});
315 332
316 $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);
317 $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);
318 335
319 $self->signal_connect (delete_event => sub { $self->part; 1 }); 336 $self->signal_connect (delete_event => sub { $self->part; 1 });
320 $self->{chat}->signal_connect (command => sub { 337 $self->{chat}->signal_connect (command => sub {
321 my ($chat, $cmd, $arg) = @_; 338 my ($chat, $cmd, $arg) = @_;
322 if ($cmd eq "rsave") { 339 if ($cmd eq "rsave") {
340 local $Storable::forgive_me = 1;
323 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#
324 } else { 343 } else {
325 $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);
326 } 345 }
327 }); 346 });
328 } 347 }
335 return if $self->{joined}; 354 return if $self->{joined};
336 355
337 $self->SUPER::join; 356 $self->SUPER::join;
338} 357}
339 358
359sub part {
360 my ($self) = @_;
361
362 $self->hide;
363 $self->SUPER::part;
364}
365
340sub event_join { 366sub event_join {
341 my ($self) = @_; 367 my ($self) = @_;
342 368
343 $self->SUPER::event_join (@_); 369 $self->SUPER::event_join (@_);
344 $self->init_tree; 370 $self->init_tree;
363 389
364sub draw_users { 390sub draw_users {
365 my ($self, $inlay) = @_; 391 my ($self, $inlay) = @_;
366 392
367 for (sort keys %{$self->{users}}) { 393 for (sort keys %{$self->{users}}) {
368 $inlay->append_text (" <user>" . $self->{users}{$_}->as_string . "</user>"); 394 $inlay->append_text ("\t<user>" . $self->{users}{$_}->as_string . "</user>");
369 } 395 }
370} 396}
371 397
372sub event_update_users { 398sub event_update_users {
373 my ($self, $add, $update, $remove) = @_; 399 my ($self, $add, $update, $remove) = @_;
383 $important{$self->{black}{name}}++; 409 $important{$self->{black}{name}}++;
384 $important{$self->{white}{name}}++; 410 $important{$self->{white}{name}}++;
385 $important{$self->{owner}{name}}++; 411 $important{$self->{owner}{name}}++;
386 412
387 if (my @users = grep $important{$_->{name}}, @$add) { 413 if (my @users = grep $important{$_->{name}}, @$add) {
388 $self->{chat}->append_text ("\n<header>Joins:</header>"); 414 $self->{chat}->append_text ("\n<leader>Joins:</leader>");
389 $self->{chat}->append_text (" <user>" . $_->as_string . "</user>") for @users; 415 $self->{chat}->append_text (" <user>" . $_->as_string . "</user>") for @users;
390 } 416 }
391 if (my @users = grep $important{$_->{name}}, @$remove) { 417 if (my @users = grep $important{$_->{name}}, @$remove) {
392 $self->{chat}->append_text ("\n<header>Parts:</header>"); 418 $self->{chat}->append_text ("\n<leader>Parts:</leader>");
393 $self->{chat}->append_text (" <user>" . $_->as_string . "</user>") for @users; 419 $self->{chat}->append_text (" <user>" . $_->as_string . "</user>") for @users;
394 } 420 }
395} 421}
396 422
397### GAME INFO ############################################################### 423### GAME INFO ###############################################################
488 my $title = defined $self->{channel} 514 my $title = defined $self->{channel}
489 ? $self->owner->as_string . " " . $self->opponent_string 515 ? $self->owner->as_string . " " . $self->opponent_string
490 : "Game Window"; 516 : "Game Window";
491 $self->set_title ("KGS Game $title"); 517 $self->set_title ("KGS Game $title");
492 $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
493 520
494 $self->{rules_inlay}->refresh; 521 $self->{rules_inlay}->refresh;
495 522
496 if (exists $self->{teacher}) { 523 if (exists $self->{teacher}) {
497 $self->{teacher_inlay} ||= $self->{chat}->new_inlay; 524 $self->{teacher_inlay} ||= $self->{chat}->new_inlay;
554sub update_cursor { 581sub update_cursor {
555 my ($self) = @_; 582 my ($self) = @_;
556 583
557 return unless $self->{cur_board}; 584 return unless $self->{cur_board};
558 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
559 my $running = $self->{showmove} == @{$self->{path}} && $self->is_active; 603 my $running = $self->{showmove} == @{$self->{path}} && $self->is_active;
560 604
561 delete $self->{board_click}; 605 delete $self->{board_click};
562 606
563 if ($self->{teacher} eq $self->{app}{conn}) { 607 if ($self->{teacher} eq $self->{app}{conn}) {
564 #TODO# # teaching mode not implemented 608 #TODO# # teaching mode not implemented
565 $self->{button_pass}->set (label => "Pass", visible => 1, sensitive => 1); 609 $self->{button_pass}->set (label => "Pass", sensitive => 1);
610 $self->{button_pass}->show;
566 $self->{button_undo}->hide; 611 $self->{button_undo}->hide;
567 $self->{button_resign}->hide; 612 $self->{button_resign}->hide;
568 $self->{board}->set (cursor => undef); 613 $self->{board}->set (cursor => undef);
569 614
570 } elsif ($running && $self->{colour} != COLOUR_NONE) { 615 } elsif ($running && $self->{colour} != COLOUR_NONE) {
572 $self->{button_undo}->show; 617 $self->{button_undo}->show;
573 $self->{button_resign}->show; 618 $self->{button_resign}->show;
574 619
575 if ($self->{cur_board}{score}) { 620 if ($self->{cur_board}{score}) {
576 # during scoring 621 # during scoring
577 $self->{button_pass}->set (label => "Done", visible => 1, sensitive => 1); 622 $self->{button_pass}->set (label => "Done", sensitive => 1);
623 $self->{button_pass}->show;
578 $self->{board}->set (cursor => sub { 624 $self->{board}->set (cursor => sub {
579 $_[0] & (MARK_B | MARK_W) 625 $_[0] & (MARK_B | MARK_W)
580 ? $_[0] ^ MARK_GRAYED 626 ? $_[0] ^ MARK_GRAYED
581 : $_[0]; 627 : $_[0];
582 }); 628 });
594 } 640 }
595 }; 641 };
596 642
597 } elsif ($self->{colour} == $self->{whosemove}) { 643 } elsif ($self->{colour} == $self->{whosemove}) {
598 # normal move 644 # normal move
599 $self->{button_pass}->set (label => "Pass", visible => 1, sensitive => 1); 645 $self->{button_pass}->set (label => "Pass", sensitive => 1);
646 $self->{button_pass}->show;
600 $self->{board}->set (cursor => sub { 647 $self->{board}->set (cursor => sub {
601 $self->{cur_board} 648 $self->{cur_board}
602 && $self->{cur_board}->is_valid_move ($self->{colour}, $_[1], $_[2], 649 && $self->{cur_board}->is_valid_move ($self->{colour}, $_[1], $_[2],
603 $self->{rules}{ruleset} == RULESET_NEW_ZEALAND) 650 $self->{rules}{ruleset} == RULESET_NEW_ZEALAND)
604 ? $_[0] | MARK_GRAYED | ($self->{colour} == COLOUR_WHITE ? MARK_W : MARK_B) 651 ? $_[0] | MARK_GRAYED | ($self->{colour} == COLOUR_WHITE ? MARK_W : MARK_B)
605 : $_[0]; 652 : $_[0];
606 }); 653 });
607 $self->{board_click} = sub { 654 $self->{board_click} = sub {
608 return unless 655 return unless
609 $self->{cur_board}->is_valid_move ($self->{colour}, $_[1], $_[2], 656 $self->{cur_board}->is_valid_move ($self->{colour}, $_[0], $_[1],
610 $self->{rules}{ruleset} == RULESET_NEW_ZEALAND); 657 $self->{rules}{ruleset} == RULESET_NEW_ZEALAND);
611 $self->send (game_move => channel => $self->{channel}, x => $_[0], y => $_[1]); 658 $self->send (game_move => channel => $self->{channel}, x => $_[0], y => $_[1]);
612 $self->{board}->set (cursor => undef); 659 $self->{board}->set (cursor => undef);
613 delete $self->{board_click}; 660 delete $self->{board_click};
614 $self->{button_pass}->sensitive (0); 661 $self->{button_pass}->sensitive (0);
615 }; 662 };
616 } else { 663 } else {
617 $self->{button_pass}->set (label => "Pass", sensitive => 0, visible => 1); 664 $self->{button_pass}->set (label => "Pass", sensitive => 0);
665 $self->{button_pass}->show;
618 $self->{board}->set (cursor => undef); 666 $self->{board}->set (cursor => undef);
619 } 667 }
620 } else { 668 } else {
621 $self->{button_undo}->hide; 669 $self->{button_undo}->hide;
622 $self->{button_resign}->hide; 670 $self->{button_resign}->hide;
634 $self->{board_label}->set_text ("Move " . ($self->{showmove} - 1)); 682 $self->{board_label}->set_text ("Move " . ($self->{showmove} - 1));
635 683
636 $self->{cur_board} = new KGS::Game::Board $self->{size}; 684 $self->{cur_board} = new KGS::Game::Board $self->{size};
637 $self->{cur_board}->interpret_path ([@{$self->{path}}[0 .. $self->{showmove} - 1]]); 685 $self->{cur_board}->interpret_path ([@{$self->{path}}[0 .. $self->{showmove} - 1]]);
638 686
639 if ($self->{rules}{ruleset} == RULESET_JAPANESE) {
640 if ($self->{curnode}{move} == 0) {
641 $self->{whosemove} = $self->{handicap} ? COLOUR_WHITE : COLOUR_BLACK;
642 } else {
643 $self->{whosemove} = 1 - $self->{cur_board}{last};
644 }
645 } else {
646 # Chinese, Aga, NZ all have manual placement
647 if ($self->{curnode}{move} < $self->{handicap}) {
648 $self->{whosemove} = COLOUR_BLACK;
649 } elsif ($self->{curnode}{move} == $self->{handicap}) {
650 $self->{whosemove} = $self->{handicap} ? COLOUR_WHITE : COLOUR_BLACK;
651 } else {
652 $self->{whosemove} = 1 - $self->{cur_board}{last};
653 }
654 }
655
656 $self->{userpanel}[$_]->set_captures ($self->{cur_board}{captures}[$_]) 687 $self->{userpanel}[$_]->set_captures ($self->{cur_board}{captures}[$_])
657 for COLOUR_WHITE, COLOUR_BLACK; 688 for COLOUR_WHITE, COLOUR_BLACK;
658 689
659 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;
660 705
661 if ($self->{showmove} == @{$self->{path}}) { 706 if ($self->{showmove} == @{$self->{path}}) {
662 $self->{timers} = [ 707 $self->{timers} = [
663 [$self->{lastmove_time}, @{$self->{cur_board}{timer}[0]}], 708 [$self->{lastmove_time}, @{$self->{cur_board}{timer}[0]}],
664 [$self->{lastmove_time}, @{$self->{cur_board}{timer}[1]}], 709 [$self->{lastmove_time}, @{$self->{cur_board}{timer}[1]}],
669 [0, @{$self->{cur_board}{timer}[0]}], 714 [0, @{$self->{cur_board}{timer}[0]}],
670 [0, @{$self->{cur_board}{timer}[1]}], 715 [0, @{$self->{cur_board}{timer}[1]}],
671 ]); 716 ]);
672 } 717 }
673 718
674 $self->{board}->set_board ($self->{cur_board});
675
676 if ($self->{cur_board}{score}) {
677 $self->{score_inlay} ||= $self->{chat}->new_inlay;
678 $self->{score_inlay}->clear;
679 $self->{score_inlay}->append_text ("\n<header>Scoring</header>"
680 . "\n<score>"
681 . "White: $self->{cur_board}{score}[COLOUR_WHITE], "
682 . "Black: $self->{cur_board}{score}[COLOUR_BLACK]"
683 . "</score>");
684 } elsif ($self->{score_inlay}) {
685 (delete $self->{score_inlay})->clear;
686 }
687
688 $self->update_cursor;
689
690} 719}
691 720
692sub event_update_tree { 721sub event_update_tree {
693 my ($self) = @_; 722 my ($self) = @_;
694 723
712 } 741 }
713} 742}
714 743
715sub event_update_comments { 744sub event_update_comments {
716 my ($self, $node, $comment, $newnode) = @_; 745 my ($self, $node, $comment, $newnode) = @_;
717 $self->SUPER::event_update_comments($node, $comment, $newnode); 746 $self->SUPER::event_update_comments ($node, $comment, $newnode);
718 747
719 my $text; 748 my $text;
720 749
721 $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>"
722 if $newnode; 751 if $newnode;
761 my ($self, $player) = @_; 790 my ($self, $player) = @_;
762 791
763 sound::play 3, "resign"; 792 sound::play 3, "resign";
764 $self->{chat}->append_text ("\n<infoblock><header>Resign</header>" 793 $self->{chat}->append_text ("\n<infoblock><header>Resign</header>"
765 . "\n<user>" 794 . "\n<user>"
766 . (util::toxml $self->{user}[$msg->{player}]->as_string) 795 . (util::toxml $self->{user}[$player]->as_string)
767 . "</user> resigned." 796 . "</user> resigned."
768 . "\n<user>" 797 . "\n<user>"
769 . (util::toxml $self->{user}[1 - $msg->{player}]->as_string) 798 . (util::toxml $self->{user}[1 - $player]->as_string)
770 . "</user> wins the game." 799 . "</user> wins the game."
771 . "</infoblock>"); 800 . "</infoblock>");
772} 801}
773 802
774sub event_time_win { 803sub event_out_of_time {
775 my ($self, $player) = @_; 804 my ($self, $player) = @_;
776 805
777 sound::play 3, "timewin"; 806 sound::play 3, "timewin";
778 $self->{chat}->append_text ("\n<infoblock><header>Out of Time</header>" 807 $self->{chat}->append_text ("\n<infoblock><header>Out of Time</header>"
779 . "\n<user>" 808 . "\n<user>"
780 . (util::toxml $self->{user}[1 - $msg->{player}]->as_string) 809 . (util::toxml $self->{user}[$msg->{1 - player}]->as_string)
781 . "</user> ran out of time and lost." 810 . "</user> ran out of time and lost."
782 . "\n<user>" 811 . "\n<user>"
783 . (util::toxml $self->{user}[$msg->{player}]->as_string) 812 . (util::toxml $self->{user}[$msg->{player}]->as_string)
784 . "</user> wins the game." 813 . "</user> wins the game."
785 . "</infoblock>"); 814 . "</infoblock>");
876 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;;
877 my $opponent = $as_black ? $info->{white} : $info->{black}; 906 my $opponent = $as_black ? $info->{white} : $info->{black};
878 907
879 my ($size, $time, $interval, $count, $type); 908 my ($size, $time, $interval, $count, $type);
880 909
881 if (!$self->{channel}) { 910 if (!defined $self->{channel}) {
882 $inlay->append_text ("\nNotes: "); 911 $inlay->append_text ("\nNotes: ");
883 $inlay->append_entry (\$info->{notes}, 20, ""); 912 $inlay->append_widget (gtk::textentry \$info->{notes}, 20, "");
884 $inlay->append_text ("\nGlobal Offer: "); 913 $inlay->append_text ("\nGlobal Offer: ");
885 $inlay->append_optionmenu (\$info->{flags}, 914 $inlay->append_optionmenu (\$info->{flags},
886 0 => "No", 915 0 => "No",
887 2 => "Yes", 916 2 => "Yes",
888 ); 917 );
903 sub { 932 sub {
904 $size->set_history (2) if $_[0] eq GAMETYPE_RATED; 933 $size->set_history (2) if $_[0] eq GAMETYPE_RATED;
905 }, 934 },
906 ); 935 );
907 936
908 if ($self->{channel}) { 937 if (defined $self->{channel}) {
909 $inlay->append_text ("\nMy Colour: "); 938 $inlay->append_text ("\nMy Colour: ");
910 $inlay->append_optionmenu ( 939 $inlay->append_optionmenu (
911 \$as_black, 940 \$as_black,
912 0 => "White", 941 0 => "White",
913 1 => "Black", 942 1 => "Black",
936 $type->set_history (5) # reset to free 965 $type->set_history (5) # reset to free
937 if $_[0] != 19 && $info->{gametype} == GAMETYPE_RATED; 966 if $_[0] != 19 && $info->{gametype} == GAMETYPE_RATED;
938 }, 967 },
939 ); 968 );
940 969
941 if ($self->{channel}) { 970 if (defined $self->{channel}) {
942 $inlay->append_text ("\nHandicap: "); 971 $inlay->append_text ("\nHandicap: ");
943 $inlay->append_optionmenu (\$info->{rules}{handicap}, map +($_, $_), 0..9); 972 $inlay->append_optionmenu (\$info->{rules}{handicap}, map +($_, $_), 0..9);
944 973
945 $inlay->append_text ("\nKomi: "); 974 $inlay->append_text ("\nKomi: ");
946 $inlay->append_entry (\$info->{rules}{komi}, 5); 975 $inlay->append_widget (gtk::numentry \$info->{rules}{komi}, 5);
947 } 976 }
948 977
949 $inlay->append_text ("\nTimesys: "); 978 $inlay->append_text ("\nTimesys: ");
950 $inlay->append_optionmenu ( 979 $inlay->append_optionmenu (
951 \$info->{rules}{timesys}, 980 \$info->{rules}{timesys},
980 } 1009 }
981 } 1010 }
982 ); 1011 );
983 1012
984 $inlay->append_text ("\nMain Time: "); 1013 $inlay->append_text ("\nMain Time: ");
985 $time = $inlay->append_entry (\$info->{rules}{time}, 5); 1014 $time = $inlay->append_widget (gtk::timeentry \$info->{rules}{time}, 5);
986 $inlay->append_text ("\nInterval: "); 1015 $inlay->append_text ("\nInterval: ");
987 $interval = $inlay->append_entry (\$info->{rules}{interval}, 3); 1016 $interval = $inlay->append_widget (gtk::timeentry \$info->{rules}{interval}, 5);
988 $inlay->append_text ("\nPeriods/Stones: "); 1017 $inlay->append_text ("\nPeriods/Stones: ");
989 $count = $inlay->append_entry (\$info->{rules}{count}, 2); 1018 $count = $inlay->append_widget (gtk::numentry \$info->{rules}{count}, 5);
990 1019
991 $inlay->append_text ("\n"); 1020 $inlay->append_text ("\n");
992 1021
993 if (!$self->{channel}) { 1022 if (!defined $self->{channel}) {
994 $inlay->append_button ("Create Challenge", sub { 1023 $inlay->append_button ("Create Challenge", sub {
995 $inlay->clear; 1024 $inlay->clear;
996 $self->{cid} = $self->{conn}->alloc_clientid; 1025 $self->{cid} = $self->{conn}->alloc_clientid;
997 $self->send (new_game => 1026 $self->send (new_game =>
998 channel => delete $self->{roomid}, 1027 channel => delete $self->{roomid},

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines