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.126 by root, Wed Jun 2 12:23:35 2004 UTC vs.
Revision 1.128 by root, Thu Jun 3 04:21:10 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;
162}
163
164sub SET_PROPERTY {
165 my ($self, $pspec, $value) = @_;
166
167 $self->{$pspec->get_name} = $value;
168
169 $self->set_name ("userpanel-$self->{colour}");
160} 170}
161 171
162sub configure { 172sub configure {
163 my ($self, $app, $user, $rules) = @_; 173 my ($self, $app, $user, $rules) = @_;
164 174
568 578
569 delete $self->{board_click}; 579 delete $self->{board_click};
570 580
571 if ($self->{teacher} eq $self->{app}{conn}) { 581 if ($self->{teacher} eq $self->{app}{conn}) {
572 #TODO# # teaching mode not implemented 582 #TODO# # teaching mode not implemented
573 $self->{button_pass}->set (label => "Pass", visible => 1, sensitive => 1); 583 $self->{button_pass}->set (label => "Pass", sensitive => 1);
584 $self->{button_pass}->show;
574 $self->{button_undo}->hide; 585 $self->{button_undo}->hide;
575 $self->{button_resign}->hide; 586 $self->{button_resign}->hide;
576 $self->{board}->set (cursor => undef); 587 $self->{board}->set (cursor => undef);
577 588
578 } elsif ($running && $self->{colour} != COLOUR_NONE) { 589 } elsif ($running && $self->{colour} != COLOUR_NONE) {
580 $self->{button_undo}->show; 591 $self->{button_undo}->show;
581 $self->{button_resign}->show; 592 $self->{button_resign}->show;
582 593
583 if ($self->{cur_board}{score}) { 594 if ($self->{cur_board}{score}) {
584 # during scoring 595 # during scoring
585 $self->{button_pass}->set (label => "Done", visible => 1, sensitive => 1); 596 $self->{button_pass}->set (label => "Done", sensitive => 1);
597 $self->{button_pass}->show;
586 $self->{board}->set (cursor => sub { 598 $self->{board}->set (cursor => sub {
587 $_[0] & (MARK_B | MARK_W) 599 $_[0] & (MARK_B | MARK_W)
588 ? $_[0] ^ MARK_GRAYED 600 ? $_[0] ^ MARK_GRAYED
589 : $_[0]; 601 : $_[0];
590 }); 602 });
602 } 614 }
603 }; 615 };
604 616
605 } elsif ($self->{colour} == $self->{whosemove}) { 617 } elsif ($self->{colour} == $self->{whosemove}) {
606 # normal move 618 # normal move
607 $self->{button_pass}->set (label => "Pass", visible => 1, sensitive => 1); 619 $self->{button_pass}->set (label => "Pass", sensitive => 1);
620 $self->{button_pass}->show;
608 $self->{board}->set (cursor => sub { 621 $self->{board}->set (cursor => sub {
609 $self->{cur_board} 622 $self->{cur_board}
610 && $self->{cur_board}->is_valid_move ($self->{colour}, $_[1], $_[2], 623 && $self->{cur_board}->is_valid_move ($self->{colour}, $_[1], $_[2],
611 $self->{rules}{ruleset} == RULESET_NEW_ZEALAND) 624 $self->{rules}{ruleset} == RULESET_NEW_ZEALAND)
612 ? $_[0] | MARK_GRAYED | ($self->{colour} == COLOUR_WHITE ? MARK_W : MARK_B) 625 ? $_[0] | MARK_GRAYED | ($self->{colour} == COLOUR_WHITE ? MARK_W : MARK_B)
620 $self->{board}->set (cursor => undef); 633 $self->{board}->set (cursor => undef);
621 delete $self->{board_click}; 634 delete $self->{board_click};
622 $self->{button_pass}->sensitive (0); 635 $self->{button_pass}->sensitive (0);
623 }; 636 };
624 } else { 637 } else {
625 $self->{button_pass}->set (label => "Pass", sensitive => 0, visible => 1); 638 $self->{button_pass}->set (label => "Pass", sensitive => 0);
639 $self->{button_pass}->show;
626 $self->{board}->set (cursor => undef); 640 $self->{board}->set (cursor => undef);
627 } 641 }
628 } else { 642 } else {
629 $self->{button_undo}->hide; 643 $self->{button_undo}->hide;
630 $self->{button_resign}->hide; 644 $self->{button_resign}->hide;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines