… | |
… | |
142 | |
142 | |
143 | $vbox->add ($self->{name} = new Gtk2::Label $self->{name}); |
143 | $vbox->add ($self->{name} = new Gtk2::Label $self->{name}); |
144 | $vbox->add ($self->{info} = new Gtk2::Label ""); |
144 | $vbox->add ($self->{info} = new Gtk2::Label ""); |
145 | $vbox->add (($self->{clock} = new game::goclock)->widget); |
145 | $vbox->add (($self->{clock} = new game::goclock)->widget); |
146 | |
146 | |
|
|
147 | $vbox->add ($self->{imagebox} = new Gtk2::VBox); |
|
|
148 | |
147 | $self; |
149 | $self; |
148 | } |
150 | } |
149 | |
151 | |
150 | sub set_rules { |
152 | sub set_rules { |
151 | my ($self, $rules) = @_; |
153 | my ($self, $rules) = @_; |
152 | |
154 | |
153 | if ($self->{name}->get_text ne $rules->{player}[$self->{colour}]) { |
155 | if ($self->{name}->get_text ne $rules->{player}[$self->{colour}]) { |
154 | $self->{name}->set_text ($rules->{player}[$self->{colour}]); |
156 | $self->{name}->set_text ($rules->{player}[$self->{colour}]); |
155 | |
157 | |
|
|
158 | $self->{imagebox}->remove ($_) for $self->{imagebox}->get_children; |
|
|
159 | $self->{imagebox}->add (gtk::image_from_data undef); |
|
|
160 | |
156 | # the big picture... |
161 | # the big picture... |
157 | appwin::userpic ($rules->{player}[$self->{colour}], sub { |
162 | appwin::userpic ($rules->{player}[$self->{colour}], sub { |
|
|
163 | if ($_[0]) { |
|
|
164 | $self->{imagebox}->remove ($_) for $self->{imagebox}->get_children; |
158 | $self->{widget}->add (gtk::image_from_data $_[0]) if $_[0]; |
165 | $self->{imagebox}->add (gtk::image_from_data $_[0]); |
159 | $self->{widget}->show_all; |
166 | $self->{imagebox}->show_all; |
160 | # undef => show sth. funny |
167 | } |
161 | }); |
168 | }); |
162 | } |
169 | } |
163 | |
170 | |
164 | $self->{clock}->set_rules (@{$rules->{rules}}{qw(timesys time interval count)}); |
171 | $self->{clock}->set_rules (@{$rules->{rules}}{qw(timesys time interval count)}); |
165 | } |
172 | } |
… | |
… | |
734 | $self->{left}->remove ($_) for $self->{left}->get_children; |
741 | $self->{left}->remove ($_) for $self->{left}->get_children; |
735 | if ($self->is_valid) { |
742 | if ($self->is_valid) { |
736 | $self->{left}->add ($self->{boardbox}); |
743 | $self->{left}->add ($self->{boardbox}); |
737 | (delete $self->{challenge})->destroy if $self->{challenge}; |
744 | (delete $self->{challenge})->destroy if $self->{challenge}; |
738 | } else { |
745 | } else { |
739 | $self->{left}->add ($self->{challenge}); |
746 | $self->{left}->add ($self->{challenge}->widget); |
740 | } |
747 | } |
741 | $self->{left}->show_all; |
748 | $self->{left}->show_all; |
742 | } |
749 | } |
743 | |
750 | |
744 | sub destroy { |
751 | sub destroy { |