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.135 by root, Tue Jun 8 17:35:00 2004 UTC vs.
Revision 1.140 by root, Wed Oct 13 00:33:15 2004 UTC

266 $vbox->pack_start ((my $frame = new Gtk2::Frame), 0, 1, 0); 266 $vbox->pack_start ((my $frame = new Gtk2::Frame), 0, 1, 0);
267 267
268 { 268 {
269 $frame->add (my $vbox = new Gtk2::VBox); 269 $frame->add (my $vbox = new Gtk2::VBox);
270 $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
271 272
272 $vbox->add (my $hbox = new Gtk2::HBox); 273 $vbox->add (my $hbox = new Gtk2::HBox);
273 274
274 $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);
275 276
306 Gtk2::Button->Glib::Object::new (label => "Resign", visible => 0, no_show_all => 1)); 307 Gtk2::Button->Glib::Object::new (label => "Resign", visible => 0, no_show_all => 1));
307 $self->{button_resign}->signal_connect (clicked => sub { 308 $self->{button_resign}->signal_connect (clicked => sub {
308 $self->send (resign_game => channel => $self->{channel}, player => $self->{colour}); 309 $self->send (resign_game => channel => $self->{channel}, player => $self->{colour});
309 }); 310 });
310 311
311 $vbox->pack_start (($self->{chat} = new chat), 1, 1, 0); 312 $vbox->pack_start (($self->{chat} = new chat app => $self->{app}), 1, 1, 0);
312 313
313 $self->{chat}->signal_connect (tag_event => sub { 314 $self->{chat}->signal_connect (tag_event => sub {
314 my (undef, $tag, $event, $content) = @_; 315 my (undef, $tag, $event, $content) = @_;
315
316 if ($tag eq "user" && $event->type eq "button-release") {
317 if ($event->button == 1) {
318 $content =~ /^(\S+)/;
319 $self->{app}->open_user ($1);
320 }
321 }
322 }); 316 });
323 317
324 $self->set_channel ($self->{channel}); 318 $self->set_channel ($self->{channel});
325 319
326 $self->show_all; 320 $self->show_all;
331sub set_channel { 325sub set_channel {
332 my ($self, $channel) = @_; 326 my ($self, $channel) = @_;
333 327
334 $self->{channel} = $channel; 328 $self->{channel} = $channel;
335 329
336 if ($self->{channel} > 0) { 330 if (defined $self->{channel}) {
337 $self->listen ($self->{conn}); 331 $self->listen ($self->{conn});
338 332
339 $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);
340 $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);
341 335
342 $self->signal_connect (delete_event => sub { $self->part; 1 }); 336 $self->signal_connect (delete_event => sub { $self->part; 1 });
343 $self->{chat}->signal_connect (command => sub { 337 $self->{chat}->signal_connect (command => sub {
344 my ($chat, $cmd, $arg) = @_; 338 my ($chat, $cmd, $arg) = @_;
345 if ($cmd eq "rsave") { 339 if ($cmd eq "rsave") {
340 local $Storable::forgive_me = 1;
346 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#
347 } else { 343 } else {
348 $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);
349 } 345 }
350 }); 346 });
351 } 347 }
518 my $title = defined $self->{channel} 514 my $title = defined $self->{channel}
519 ? $self->owner->as_string . " " . $self->opponent_string 515 ? $self->owner->as_string . " " . $self->opponent_string
520 : "Game Window"; 516 : "Game Window";
521 $self->set_title ("KGS Game $title"); 517 $self->set_title ("KGS Game $title");
522 $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
523 520
524 $self->{rules_inlay}->refresh; 521 $self->{rules_inlay}->refresh;
525 522
526 if (exists $self->{teacher}) { 523 if (exists $self->{teacher}) {
527 $self->{teacher_inlay} ||= $self->{chat}->new_inlay; 524 $self->{teacher_inlay} ||= $self->{chat}->new_inlay;
807 my ($self, $player) = @_; 804 my ($self, $player) = @_;
808 805
809 sound::play 3, "timewin"; 806 sound::play 3, "timewin";
810 $self->{chat}->append_text ("\n<infoblock><header>Out of Time</header>" 807 $self->{chat}->append_text ("\n<infoblock><header>Out of Time</header>"
811 . "\n<user>" 808 . "\n<user>"
812 . (util::toxml $self->{user}[$msg->{player}]->as_string) 809 . (util::toxml $self->{user}[$msg->{1 - player}]->as_string)
813 . "</user> ran out of time and lost." 810 . "</user> ran out of time and lost."
814 . "\n<user>" 811 . "\n<user>"
815 . (util::toxml $self->{user}[1 - $msg->{player}]->as_string) 812 . (util::toxml $self->{user}[$msg->{player}]->as_string)
816 . "</user> wins the game." 813 . "</user> wins the game."
817 . "</infoblock>"); 814 . "</infoblock>");
818} 815}
819 816
820sub event_owner_left { 817sub event_owner_left {
908 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;;
909 my $opponent = $as_black ? $info->{white} : $info->{black}; 906 my $opponent = $as_black ? $info->{white} : $info->{black};
910 907
911 my ($size, $time, $interval, $count, $type); 908 my ($size, $time, $interval, $count, $type);
912 909
913 if (!$self->{channel}) { 910 if (!defined $self->{channel}) {
914 $inlay->append_text ("\nNotes: "); 911 $inlay->append_text ("\nNotes: ");
915 $inlay->append_widget (gtk::textentry \$info->{notes}, 20, ""); 912 $inlay->append_widget (gtk::textentry \$info->{notes}, 20, "");
916 $inlay->append_text ("\nGlobal Offer: "); 913 $inlay->append_text ("\nGlobal Offer: ");
917 $inlay->append_optionmenu (\$info->{flags}, 914 $inlay->append_optionmenu (\$info->{flags},
918 0 => "No", 915 0 => "No",
935 sub { 932 sub {
936 $size->set_history (2) if $_[0] eq GAMETYPE_RATED; 933 $size->set_history (2) if $_[0] eq GAMETYPE_RATED;
937 }, 934 },
938 ); 935 );
939 936
940 if ($self->{channel}) { 937 if (defined $self->{channel}) {
941 $inlay->append_text ("\nMy Colour: "); 938 $inlay->append_text ("\nMy Colour: ");
942 $inlay->append_optionmenu ( 939 $inlay->append_optionmenu (
943 \$as_black, 940 \$as_black,
944 0 => "White", 941 0 => "White",
945 1 => "Black", 942 1 => "Black",
968 $type->set_history (5) # reset to free 965 $type->set_history (5) # reset to free
969 if $_[0] != 19 && $info->{gametype} == GAMETYPE_RATED; 966 if $_[0] != 19 && $info->{gametype} == GAMETYPE_RATED;
970 }, 967 },
971 ); 968 );
972 969
973 if ($self->{channel}) { 970 if (defined $self->{channel}) {
974 $inlay->append_text ("\nHandicap: "); 971 $inlay->append_text ("\nHandicap: ");
975 $inlay->append_optionmenu (\$info->{rules}{handicap}, map +($_, $_), 0..9); 972 $inlay->append_optionmenu (\$info->{rules}{handicap}, map +($_, $_), 0..9);
976 973
977 $inlay->append_text ("\nKomi: "); 974 $inlay->append_text ("\nKomi: ");
978 $inlay->append_widget (gtk::numentry \$info->{rules}{komi}, 5); 975 $inlay->append_widget (gtk::numentry \$info->{rules}{komi}, 5);
1020 $inlay->append_text ("\nPeriods/Stones: "); 1017 $inlay->append_text ("\nPeriods/Stones: ");
1021 $count = $inlay->append_widget (gtk::numentry \$info->{rules}{count}, 5); 1018 $count = $inlay->append_widget (gtk::numentry \$info->{rules}{count}, 5);
1022 1019
1023 $inlay->append_text ("\n"); 1020 $inlay->append_text ("\n");
1024 1021
1025 if (!$self->{channel}) { 1022 if (!defined $self->{channel}) {
1026 $inlay->append_button ("Create Challenge", sub { 1023 $inlay->append_button ("Create Challenge", sub {
1027 $inlay->clear; 1024 $inlay->clear;
1028 $self->{cid} = $self->{conn}->alloc_clientid; 1025 $self->{cid} = $self->{conn}->alloc_clientid;
1029 $self->send (new_game => 1026 $self->send (new_game =>
1030 channel => delete $self->{roomid}, 1027 channel => delete $self->{roomid},

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines