--- deliantra/Deliantra-Client/DC/UI.pm 2006/04/15 22:55:59 1.117 +++ deliantra/Deliantra-Client/DC/UI.pm 2006/04/19 06:06:45 1.134 @@ -98,8 +98,6 @@ x => 0, y => 0, z => 0, - w => -1, - h => -1, @_ }, $class; @@ -112,11 +110,30 @@ $self } +sub show { + my ($self) = @_; + + return if $self->{parent}; + + $CFClient::UI::ROOT->add ($self); +} + +sub hide { + my ($self) = @_; + + return unless $self->{parent}; + + $self->{parent}->remove ($self); +} + sub move { my ($self, $x, $y, $z) = @_; + $self->{x} = int $x; $self->{y} = int $y; $self->{z} = $z if defined $z; + + $self->update; } sub needs_redraw { @@ -128,7 +145,7 @@ Carp::confess "size_request is abtract"; } -sub _size_allocate { +sub configure { my ($self, $x, $y, $w, $h) = @_; $self->{x} = $x; @@ -139,13 +156,12 @@ $self->{w} = $w; $self->{h} = $h; - 1 + $self->size_allocate ($w, $h); + $self->update; } sub size_allocate { - my ($self, $x, $y, $w, $h) = @_; - - $self->_size_allocate ($x, $y, $w, $h); + # nothing to be done } # return top left coordinates @@ -178,6 +194,9 @@ return unless $self->{can_focus}; my $focus = $FOCUS; $FOCUS = $self; + + $self->emit (focus_in => $focus); + $focus->update if $focus; $FOCUS->update; } @@ -188,6 +207,9 @@ return unless $FOCUS == $self; my $focus = $FOCUS; undef $FOCUS; + + $self->emit (focus_out => $focus); + $focus->update if $focus; #? } @@ -221,7 +243,7 @@ if ($self == $HOVER && $self->{can_hover}) { my ($x, $y) = @$self{qw(x y)}; - glColor 0, 0, 1, 0.2; + glColor 1, 0.8, 0.5, 0.2; glEnable GL_BLEND; glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; glBegin GL_QUADS; @@ -256,6 +278,20 @@ Scalar::Util::weaken ($self->{parent} = $parent); } +sub check_size { + my ($self) = @_; + + my ($w, $h) = $self->size_request; + + if ($w != $self->{req_w} || $h != $self->{req_h}) { + $self->{req_w} = $w; + $self->{req_h} = $h; + + $self->{parent}->check_size + if $self->{parent}; + } +} + sub update { my ($self) = @_; @@ -266,14 +302,15 @@ sub connect { my ($self, $signal, $cb) = @_; - push @{ $self->{cb}{$signal} }, $cb; + push @{ $self->{signal_cb}{$signal} }, $cb; } sub emit { my ($self, $signal, @args) = @_; - $_->($self, @args) - for @{$self->{cb}{$signal} || []}; + for my $cb (@{$self->{signal_cb}{$signal} || []}) { + $cb->($self, @args); + } } sub DESTROY { @@ -363,16 +400,17 @@ @{$self->{children}}, $child ]; - $self->{w} = $self->{h} = -1; - $self->update; + $child->check_size; } sub remove { - my ($self, $widget) = @_; + my ($self, $child) = @_; + + delete $child->{parent}; - $self->{children} = [ grep $_ != $widget, @{ $self->{children} } ]; + $self->{children} = [ grep $_ != $child, @{ $self->{children} } ]; - $self->size_allocate (0, 0, $self->{w}, $self->{h}); + $self->check_size; } sub find_widget { @@ -412,11 +450,11 @@ } sub add { - my ($self, $widget) = @_; + my ($self, $child) = @_; $self->{children} = []; - $self->SUPER::add ($widget); + $self->SUPER::add ($child); } sub remove { @@ -435,11 +473,9 @@ } sub size_allocate { - my ($self, $x, $y, $w, $h) = @_; + my ($self, $w, $h) = @_; - $self->_size_allocate ($x, $y, $w, $h) or return; - - $self->{children}[0]->size_allocate (0, 0, $w, $h); + $self->{children}[0]->configure (0, 0, $w, $h); } ############################################################################# @@ -475,11 +511,9 @@ } sub size_allocate { - my ($self, $x, $y, $w, $h) = @_; - - $self->_size_allocate ($x, $y, $w, $h) or return; + my ($self, $w, $h) = @_; - $self->child->size_allocate (0, 0, $w, $h); + $self->child->configure (0, 0, $w, $h); $self->render_chld; } @@ -505,6 +539,30 @@ ############################################################################# +package CFClient::UI::ViewPort; + +our @ISA = CFClient::UI::Window::; + +sub new { die } + +sub size_request { + my ($self) = @_; + + @$self{qw(child_w child_h)} = $self->child->size_request; + $self->child->size_allocate (0, 0, @$self{qw(child_w child_h)}); + + @$self{qw(child_w child_h)} +} + +sub _draw { + my ($self) = @_; + + $self->{children}[1]->draw; +} + + +############################################################################# + package CFClient::UI::Frame; our @ISA = CFClient::UI::Bin::; @@ -524,9 +582,7 @@ sub size_allocate { my ($self, $x, $y, $w, $h) = @_; - $self->_size_allocate ($x, $y, $w, $h) or return; - - $self->child->size_allocate (2, 2, $w - 4, $h - 4); + $self->child->configure (2, 2, $w - 4, $h - 4); } sub _draw { @@ -567,11 +623,15 @@ $class->SUPER::new ( bg => [1, 1, 1, 1], border_bg => [1, 1, 1, 1], - border => int $::FONTSIZE * 0.8, + border => 0.8, @_ ) } +sub border { + int $_[0]{border} * $::FONTSIZE +} + sub size_request { my ($self) = @_; @@ -580,27 +640,27 @@ my ($w, $h) = $self->SUPER::size_request; ( - $w + $self->{border} * 2, - $h + $self->{border} * 2, + $w + $self->border * 2, + $h + $self->border * 2, ) } sub size_allocate { - my ($self, $x, $y, $w, $h) = @_; + my ($self, $w, $h) = @_; - $self->_size_allocate ($x, $y, $w, $h) or return; + $h -= List::Util::max 0, $self->border * 2; + $w -= List::Util::max 0, $self->border * 2; - $h -= List::Util::max 0, $self->{border} * 2; - $w -= List::Util::max 0, $self->{border} * 2; - - $self->child->size_allocate ($self->{border}, $self->{border}, $w, $h); + $self->child->configure ($self->border, $self->border, $w, $h); } sub button_down { my ($self, $ev, $x, $y) = @_; - if ($x < $self->{w} && $x >= $self->{w} - $self->{border} - && $y < $self->{h} && $y >= $self->{h} - $self->{border}) { + my $border = $self->border; + + if ($x < $self->{w} && $x >= $self->{w} - $border + && $y < $self->{h} && $y >= $self->{h} - $border) { my ($ox, $oy) = ($ev->button_x, $ev->button_y); my ($bw, $bh) = ($self->{w}, $self->{h}); @@ -612,11 +672,11 @@ $self->{user_w} = $bw + $x - $ox; $self->{user_h} = $bh + $y - $oy; - $self->update; + $self->check_size; }; } elsif ($x >= 0 && $x < $self->{w} - && $y >= 0 && $y < $self->{border}) { + && $y >= 0 && $y < $border) { my ($ox, $oy) = ($ev->button_x, $ev->button_y); my ($bx, $by) = ($self->{x}, $self->{y}); @@ -655,11 +715,13 @@ glEnable GL_TEXTURE_2D; glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; + my $border = $self->border; + glColor @{ $self->{border_bg} }; - $tex[1]->draw_quad (0, 0, $w, $self->{border}); - $tex[3]->draw_quad (0, $self->{border}, $self->{border}, $ch); - $tex[2]->draw_quad ($w - $self->{border}, $self->{border}, $self->{border}, $ch); - $tex[4]->draw_quad (0, $h - $self->{border}, $w, $self->{border}); + $tex[1]->draw_quad (0, 0, $w, $border); + $tex[3]->draw_quad (0, $border, $border, $ch); + $tex[2]->draw_quad ($w - $border, $border, $border, $ch); + $tex[4]->draw_quad (0, $h - $border, $w, $border); my $bg = $tex[0]; @@ -672,7 +734,7 @@ $bg->{s} = $rep_x; $bg->{t} = $rep_y; $bg->{wrap_mode} = 1; - $bg->draw_quad ($self->{border}, $self->{border}, $cw, $ch); + $bg->draw_quad ($border, $border, $cw, $ch); glDisable GL_TEXTURE_2D; glDisable GL_BLEND; @@ -705,8 +767,7 @@ $child->set_parent ($self); $self->{children}[$y][$x] = $child; - $self->{w} = $self->{h} = -1; - $self->update; + $child->check_size; } # TODO: move to container class maybe? send childs a signal on removal? @@ -751,9 +812,7 @@ } sub size_allocate { - my ($self, $x, $y, $w, $h) = @_; - - $self->_size_allocate ($x, $y, $w, $h) or return; + my ($self, $w, $h) = @_; my ($ws, $hs) = $self->get_wh; @@ -785,7 +844,7 @@ my $col_w = $ws->[$c]; if (my $widget = $row->[$c]) { - $widget->size_allocate ($x, $y, $col_w, $row_h); + $widget->configure ($x, $y, $col_w, $row_h); } $x += $col_w; @@ -840,9 +899,7 @@ } sub size_allocate { - my ($self, $x, $y, $w, $h) = @_; - - $self->_size_allocate ($x, $y, $w, $h); + my ($self, $w, $h) = @_; ($h, $w) = ($w, $h); @@ -874,10 +931,12 @@ for (0 .. $#$children) { my $child = $children->[$_]; my $h = $h[$_]; - $child->size_allocate ($y, 0, $h, $w); + $child->configure ($y, 0, $h, $w); $y += $h; } + + 1 } ############################################################################# @@ -900,9 +959,7 @@ } sub size_allocate { - my ($self, $x, $y, $w, $h) = @_; - - $self->_size_allocate ($x, $y, $w, $h); + my ($self, $w, $h) = @_; my $children = $self->{children}; @@ -930,10 +987,12 @@ for (0 .. $#$children) { my $child = $children->[$_]; my $h = $h[$_]; - $child->size_allocate (0, $y, $w, $h); + $child->configure (0, $y, $w, $h); $y += $h; } + + 1 } ############################################################################# @@ -949,7 +1008,7 @@ my $self = $class->SUPER::new ( fg => [1, 1, 1], - fontsize => $::FONTSIZE, + fontsize => 1, text => "", align => -1, valign => -1, @@ -958,7 +1017,10 @@ %arg ); - $self->set_text ($self->{text}); + $self->{xxx}++ if $self->{text} eq "Client Setup" && $self->{align};#d# + + $self->set_text (delete $self->{text}) if exists $self->{text}; + $self->set_markup (delete $self->{markup}) if exists $self->{markup}; $self } @@ -976,25 +1038,27 @@ sub set_text { my ($self, $text) = @_; - $self->{text} = $text; - $self->{layout}->set_markup ($text); + $self->{layout}->set_text ($text); delete $self->{texture}; -# $self->{w} = $self->{h} = -1; $self->update; } -sub get_text { - my ($self, $text) = @_; +sub set_markup { + my ($self, $markup) = @_; - $self->{text} + $self->{layout}->set_markup ($markup); + + delete $self->{texture}; + $self->update; } sub size_request { my ($self) = @_; $self->{layout}->set_width; - $self->{layout}->set_height ($self->{fontsize}); + $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE); + my ($w, $h) = $self->{layout}->size; ( @@ -1004,26 +1068,17 @@ } sub size_allocate { - my ($self, $x, $y, $w, $h) = @_; - - $self->_size_allocate ($x, $y, $w, $h) or return; + my ($self, $w, $h) = @_; delete $self->{texture}; } -sub update { - my ($self) = @_; - - delete $self->{texture}; - $self->SUPER::update; -} - sub _draw { my ($self) = @_; my $tex = $self->{texture} ||= do { $self->{layout}->set_width ($self->{w}); - $self->{layout}->set_height (List::Util::min $self->{h} - $self->{padding} * 2, $self->{fontsize}); + $self->{layout}->set_height (List::Util::min $self->{h}, $self->{fontsize} * $::FONTSIZE); new_from_layout CFClient::Texture $self->{layout} }; @@ -1034,17 +1089,19 @@ glColor @{$self->{fg}}; - my $x = + $self->{ox} = int ( $self->{align} < 0 ? $self->{padding} : $self->{align} > 0 ? $self->{w} - $tex->{w} - $self->{padding} - : ($self->{w} - $tex->{w}) * 0.5; + : ($self->{w} - $tex->{w}) * 0.5 + ); - my $y = + $self->{oy} = int ( $self->{valign} < 0 ? $self->{padding} : $self->{valign} > 0 ? $self->{h} - $tex->{h} - $self->{padding} - : ($self->{h} - $tex->{h}) * 0.5; + : ($self->{h} - $tex->{h}) * 0.5 + ); - $tex->draw_quad (int $x, int $y); + $tex->draw_quad ($self->{ox}, $self->{oy}); glDisable GL_TEXTURE_2D; glDisable GL_BLEND; @@ -1052,7 +1109,7 @@ ############################################################################# -package CFClient::UI::Entry; +package CFClient::UI::EntryBase; our @ISA = CFClient::UI::Label::; @@ -1077,25 +1134,23 @@ sub _set_text { my ($self, $text) = @_; - my $old_text = $self->{text}; + delete $self->{cur_h}; - $self->{last_activity} = $::NOW; + return if $self->{text} eq $text; + + delete $self->{texture}; + $self->{last_activity} = $::NOW; $self->{text} = $text; - $self->{layout}->set_width ($self->{w}); - $self->{layout}->set_height (List::Util::min $self->{h} - $self->{padding} * 2, $self->{fontsize}); $text =~ s/./*/g if $self->{hidden}; + $self->{layout}->set_text ("$text "); - $self->{layout}->set_markup ($self->escape_text ($text) . " "); - - $text = substr $text, 0, $self->{cursor}; - utf8::encode $text; - - @$self{qw(cur_x cur_y cur_h)} = $self->{layout}->cursor_pos (length $text); + $self->emit (changed => $self->{text}); +} - $self->emit (changed => $self->{text}) # XXX: is this the right place to do this? - if $old_text ne $self->{text}; +sub get_text { + $_[0]{text} } sub size_request { @@ -1107,9 +1162,7 @@ } sub size_allocate { - my ($self, $x, $y, $w, $h) = @_; - - $self->SUPER::size_allocate ($x, $y, $w, $h); + my ($self, $w, $h) = @_; $self->_set_text ($self->{text}); } @@ -1209,17 +1262,25 @@ #TODO: force update every cursor change :( if ($FOCUS == $self && (($::NOW - $self->{last_activity}) & 1023) < 600) { + + unless (exists $self->{cur_h}) { + my $text = substr $self->{text}, 0, $self->{cursor}; + utf8::encode $text; + + @$self{qw(cur_x cur_y cur_h)} = $self->{layout}->cursor_pos (length $text) + } + glColor @{$self->{fg}}; glBegin GL_LINES; - glVertex $self->{cur_x}, $self->{cur_y}; - glVertex $self->{cur_x}, $self->{cur_y} + $self->{cur_h}; + glVertex $self->{cur_x} + $self->{ox}, $self->{cur_y} + $self->{oy}; + glVertex $self->{cur_x} + $self->{ox}, $self->{cur_y} + $self->{oy} + $self->{cur_h}; glEnd; } } -package CFClient::UI::LineEntry; +package CFClient::UI::Entry; -our @ISA = CFClient::UI::Entry::; +our @ISA = CFClient::UI::EntryBase::; use SDL; use SDL::OpenGL; @@ -1259,8 +1320,10 @@ padding => 4, fg => [1, 1, 1], bg => [1, 1, 1, 0.2], - active_fg => [1, 1, 0], + active_fg => [0, 0, 1], can_hover => 1, + align => 0, + valign => 0, @_ ) } @@ -1278,20 +1341,18 @@ my ($self) = @_; local $self->{fg} = $self->{fg}; - my $tex = $tex[0]; - - glEnable GL_BLEND; - glEnable GL_TEXTURE_2D; - glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; if ($GRAB == $self) { $self->{fg} = $self->{active_fg}; } - glBindTexture GL_TEXTURE_2D, $tex->{name}; + glEnable GL_BLEND; + glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; + glEnable GL_TEXTURE_2D; glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; + glColor 0, 0, 0, 1; - $tex->draw_quad (0, 0, $self->{w}, $self->{h}); + $tex[0]->draw_quad (0, 0, $self->{w}, $self->{h}); glDisable GL_TEXTURE_2D; glDisable GL_BLEND; @@ -1331,12 +1392,6 @@ ($self->{padding} * 2 + 6) x 2 } -sub size_allocate { - my ($self, $x, $y, $w, $h) = @_; - - $self->_size_allocate ($x, $y, $w, $h); -} - sub button_down { my ($self, $ev, $x, $y) = @_; @@ -1372,6 +1427,113 @@ ############################################################################# +package CFClient::UI::VGauge; + +our @ISA = CFClient::UI::Base::; + +use SDL::OpenGL; + +my %tex = ( + food => [ + map { new_from_file CFClient::Texture CFClient::find_rcfile $_ } + qw/g1_food_gauge_empty.png g1_food_gauge_full.png/ + ], + grace => [ + map { new_from_file CFClient::Texture CFClient::find_rcfile $_ } + qw/g1_grace_gauge_empty.png g1_grace_gauge_full.png/ + ], + hp => [ + map { new_from_file CFClient::Texture CFClient::find_rcfile $_ } + qw/g1_hp_gauge_empty.png g1_hp_gauge_full.png/ + ], + mana => [ + map { new_from_file CFClient::Texture CFClient::find_rcfile $_ } + qw/g1_mana_gauge_empty.png g1_mana_gauge_full.png/ + ], +); + +# eg. VGauge->new (gauge => 'food'), default gauge: food +sub new { + my $class = shift; + + my $self = $class->SUPER::new (gauge => 'food', @_); + + $self +} + +sub size_request { + my ($self) = @_; + + my $tex = $tex{$self->{gauge}}[0]; + + @$tex{qw(w h)} +} + +sub set_max { + my ($self, $max) = @_; + + $self->{max_val} = $max; +} + +sub set_value { + my ($self, $val, $max) = @_; + + $self->set_max ($max) + if defined $max; + + $max = $self->{max_val}; + $self->{val} = $val; + + $self->update; +} + +sub _draw { + my ($self) = @_; + + my $tex = $tex{$self->{gauge}}; + + my ($w, $h) = ($self->{w}, $self->{h}); + + my $ycut = $self->{val} / ($self->{max_val} || 1); + $ycut = 1 if $self->{val} > $self->{max_val}; + + my $t1 = $tex->[0]; + my $t2 = $tex->[1]; + + glEnable GL_BLEND; + glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; + glEnable GL_TEXTURE_2D; + glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; + + my $h1 = $self->{h} - $ycut * $self->{h}; + my $h2 = $ycut * $self->{h}; + + my $yp = 0; + + glBindTexture GL_TEXTURE_2D, $t1->{name}; + glBegin GL_QUADS; + glTexCoord 0 , 0; glVertex 0 , $yp; + glTexCoord 0 , $t1->{t} * (1 - $ycut); glVertex 0 , $yp + $h1; + glTexCoord $t1->{s}, $t1->{t} * (1 - $ycut); glVertex 0 + $w, $yp + $h1; + glTexCoord $t1->{s}, 0; glVertex 0 + $w, $yp; + glEnd; + + $yp += $h1; + + glBindTexture GL_TEXTURE_2D, $t2->{name}; + glBegin GL_QUADS; + glTexCoord 0 , $t2->{t} * (1 - $ycut); glVertex 0 , $yp; + glTexCoord 0 , $t2->{t}; glVertex 0 , $yp + $h2; + glTexCoord $t2->{s}, $t2->{t}; glVertex 0 + $w, $yp + $h2; + glTexCoord $t2->{s}, $t2->{t} * (1 - $ycut); glVertex 0 + $w, $yp; + glEnd; + + glDisable GL_BLEND; + glDisable GL_TEXTURE_2D; +} + +############################################################################# + package CFClient::UI::Slider; use strict; @@ -1396,8 +1558,8 @@ fg => [1, 1, 1], active_fg => [0, 0, 0], range => [0, 0, 100, 10], - req_w => 40, - req_h => 13, + req_w => 20, + req_h => 20, vertical => 0, can_hover => 1, inner_pad => 5, @@ -1517,9 +1679,7 @@ my $class = shift; my $self = $class->SUPER::new ( - req_w => $::WIDTH / 6, - req_h => $::HEIGHT / 6, - fontsize => $::FONTSIZE, + fontsize => 1, @_, layout => (new CFClient::Layout), @@ -1550,7 +1710,7 @@ my $layout = $self->{layout}; - $layout->set_height ($self->{fontsize}); + $layout->set_height ($self->{fontsize} * $::FONTSIZE); $layout->set_width ($self->{w}); $layout->set_text ($text); @@ -1564,19 +1724,13 @@ $self->update; } -sub size_request { - my ($self) = @_; - - ($self->{req_w}, $self->{req_h}) -} - sub size_allocate { - my ($self, $x, $y, $w, $h) = @_; + my ($self, $w, $h) = @_; - $self->SUPER::size_allocate ($x, $y, $w, $h); + $self->SUPER::size_allocate ($w, $h); - $self->{layout}->set_height ($self->{fontsize}); - $self->{layout}->set_width ($self->{w}); + $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE); + $self->{layout}->set_width ($self->{children}[0]{w}); $self->reflow; } @@ -1768,9 +1922,9 @@ my ($w, $h, $data) = $::MAP->draw ($sx, $sy, 0, 0, $sw + 1, $sh + 1); if ($::CFG->{fow_enable}) { - if ($::CFG->{fow_smooth}) { # smooth fog of war - glConvolutionParameter GL_CONVOLUTION_2D, GL_CONVOLUTION_BORDER_MODE, GL_CONSTANT_BORDER; - glConvolutionFilter2D + if ($::CFG->{fow_smooth} && $CFClient::GL_VERSION >= 1.2) { # smooth fog of war + glConvolutionParameter (GL_CONVOLUTION_2D, GL_CONVOLUTION_BORDER_MODE, GL_CONSTANT_BORDER); + glConvolutionFilter2D ( GL_CONVOLUTION_2D, GL_ALPHA, 3, 3, @@ -1779,11 +1933,11 @@ 0.1, 0.1, 0.1, 0.1, 0.2, 0.1, 0.1, 0.1, 0.1, - ; + ); glEnable GL_CONVOLUTION_2D; } - my $tex = new CFClient::Texture + $self->{fow_texture} = new CFClient::Texture w => $w, h => $h, data => $data, @@ -1798,7 +1952,7 @@ glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; glColor +($::CFG->{fow_intensity}) x 3, 1; - $tex->draw_quad (0, 0, $w * 32, $h * 32); + $self->{fow_texture}->draw_quad (0, 0, $w * 32, $h * 32); glDisable GL_TEXTURE_2D; glDisable GL_BLEND; @@ -1814,12 +1968,14 @@ glEnable GL_TEXTURE_2D; glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; - CFClient::Texture->new ( - w => $w, - h => $h, - data => $::MAP->mapmap ($w, $h), - type => GL_UNSIGNED_INT_8_8_8_8_REV - )->draw_quad (100, 100); + $self->{mapmap_texture} = + new CFClient::Texture + w => $w, + h => $h, + data => $::MAP->mapmap ($w, $h), + type => $CFClient::GL_VERSION >= 1.2 ? GL_UNSIGNED_INT_8_8_8_8_REV : GL_UNSIGNED_BYTE; + + $self->{mapmap_texture}->draw_quad (100, 100); glDisable GL_TEXTURE_2D; glDisable GL_BLEND; @@ -1871,9 +2027,9 @@ my $sym = $ev->key_sym; if ($sym == SDLK_KP5) { - $::CONN->user_send ("command stay fire"); + $::CONN->user_send ("stay fire"); } elsif ($sym == SDLK_a) { - $::CONN->user_send ("command apply"); + $::CONN->user_send ("apply"); } elsif ($sym == SDLK_QUOTE) { $self->emit ('activate_console'); } elsif ($sym == SDLK_SLASH) { @@ -1881,12 +2037,12 @@ } elsif (exists $DIR{$sym}) { if ($mod & KMOD_SHIFT) { $self->{shft}++; - $::CONN->user_send ("command fire $DIR{$sym}[0]"); + $::CONN->user_send ("fire $DIR{$sym}[0]"); } elsif ($mod & KMOD_CTRL) { $self->{ctrl}++; - $::CONN->user_send ("command run $DIR{$sym}[0]"); + $::CONN->user_send ("run $DIR{$sym}[0]"); } else { - $::CONN->user_send ("command $DIR{$sym}[1]"); + $::CONN->user_send ("$DIR{$sym}[1]"); } } } @@ -1898,10 +2054,10 @@ my $sym = $ev->key_sym; if (!($mod & KMOD_SHIFT) && delete $self->{shft}) { - $::CONN->user_send ("command fire_stop"); + $::CONN->user_send ("fire_stop"); } if (!($mod & KMOD_CTRL ) && delete $self->{ctrl}) { - $::CONN->user_send ("command run_stop"); + $::CONN->user_send ("run_stop"); } } @@ -1994,16 +2150,22 @@ use SDL::OpenGL; +sub check_size { + my ($self) = @_; + + $self->configure (0, 0, $::WITH, $::HEIGHT); +} + sub size_request { ($::WIDTH, $::HEIGHT) } -sub size_allocate { +sub configure { my ($self, $x, $y, $w, $h) = @_; - $self->_size_allocate ($x, $y, $w, $h); + $self->SUPER::configure ($x, $y, $w, $h); - $_->size_allocate ($_->{x}, $_->{y}, $_->size_request) + $_->configure ($_->{x}, $_->{y}, $_->size_request) for @{$self->{children}}; } @@ -2016,16 +2178,14 @@ sub update { my ($self) = @_; - $self->size_allocate (0, 0, $::WIDTH, $::HEIGHT); + $self->check_size; ::refresh (); } sub add { - my ($self, $widget) = @_; - - $self->SUPER::add ($widget); + my ($self, $child) = @_; - $widget->size_allocate (int $widget->{x}, int $widget->{y}, $widget->size_request); + $self->SUPER::add ($child); } sub on_refresh {