--- deliantra/Deliantra-Client/DC/MapWidget.pm 2006/05/17 10:14:52 1.24
+++ deliantra/Deliantra-Client/DC/MapWidget.pm 2006/05/24 21:49:58 1.35
@@ -81,6 +81,9 @@
sub draw {
my ($self) = @_;
+ return
+ unless $CFClient::UI::FOCUS == $self || !$::FAST;
+
if (delete $self->{need_update}) {
glNewList $self->{list};
@@ -114,25 +117,26 @@
glEnable GL_CONVOLUTION_2D;
}
+ $self->{fow_texture_name} ||= glGenTexture;
+ # try to re-use the texture name: TODO improve texture class instead
+
$self->{fow_texture} = new CFClient::Texture
w => $w,
h => $h,
data => $data,
+ name => $self->{fow_texture_name},
internalformat => GL_ALPHA,
format => GL_ALPHA;
glDisable GL_CONVOLUTION_2D if $::CFG->{fow_smooth};
- 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_MODULATE;
glColor +($::CFG->{fow_intensity}) x 3, 0.8;
- $self->{fow_texture}->draw_quad (0, 0, $w * 32, $h * 32);
+ $self->{fow_texture}->draw_quad_alpha (0, 0, $w * 32, $h * 32);
glDisable GL_TEXTURE_2D;
- glDisable GL_BLEND;
}
glPopMatrix;
@@ -145,17 +149,42 @@
glCallList $self->{list};
glPopMatrix;
- if ($CFClient::UI::FOCUS != $self) {
- glColor 64/255, 64/255, 64/255;
- glLogicOp GL_AND;
- glEnable GL_COLOR_LOGIC_OP;
+ # TNT2 emulates logops in software (or worse :)
+ if ($CFClient::UI::FOCUS == $self) {
+ (delete $self->{out_of_focus})->destroy
+ if $self->{out_of_focus};
+ } else {
+ glColor 0.4, 0.2, 0.2, 0.6;
+ glEnable GL_BLEND;
+ glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
glBegin GL_QUADS;
glVertex 0, 0;
glVertex 0, $::HEIGHT;
glVertex $::WIDTH, $::HEIGHT;
glVertex $::WIDTH, 0;
glEnd;
- glDisable GL_COLOR_LOGIC_OP;
+ glDisable GL_BLEND;
+
+ $self->{out_of_focus} ||= do {
+ my $label = new CFClient::UI::Label
+ x => 0,
+ y => 0,
+ z => 1,
+ ellipsise => 0,
+ text => "map out of focus (click map to play)";
+
+ $label->show;
+ $label->update;
+
+ $CFClient::UI::ROOT->on_post_alloc ("$self$label" => sub {
+ $label->move (
+ ($::WIDTH - $label->{w}) * 0.5,
+ ($::HEIGHT - $label->{h}) * 0.5,
+ );
+ });
+
+ $label
+ };
}
}
@@ -188,8 +217,12 @@
$::CONN->user_send ("stay fire");
} elsif ($uni == ord ",") {
$::CONN->user_send ("take");
- } elsif ($uni == ord "\t") {
+ } elsif ($uni == ord "\t" or $uni == ord " ") {
$::CONN->user_send ("apply");
+ } elsif ($sym == CFClient::SDLK_KP_PLUS || $uni == ord "+") {
+ $::CONN->user_send ("rotateshoottype +");
+ } elsif ($sym == CFClient::SDLK_KP_MINUS || $uni == ord "-") {
+ $::CONN->user_send ("rotateshoottype -");
} elsif ($uni == ord "'") {
$self->emit ('activate_console');
} elsif ($uni == ord "/") {
@@ -247,12 +280,11 @@
$tooltip =~ s/^\s+//;
- $tooltip = "" . (CFClient::UI::Label::escape $data) . "\n\n"
- . CFClient::UI::Label::escape $tooltip;
+ $tooltip = "$data\n\n$tooltip";
$tooltip =~ s/\s+$//;
- $self->{command}{$command} = [$data, $tooltip, $widget, $cb];
+ $self->{command}{$command} = [$data, $tooltip, $widget, $cb, ++$self->{command_id}];
}
sub clr_commands {
@@ -361,10 +393,11 @@
$self->{label} = [
map
CFClient::UI::Label->new (
- can_hover => 1,
- can_events => 1,
- fontsize => $_,
- ), (0.8) x 6
+ can_hover => 1,
+ can_events => 1,
+ tooltip_width => 0.33,
+ fontsize => $_,
+ ), (0.8) x 16
];
$self->{entry} = new CFClient::UI::Entry
@@ -448,6 +481,7 @@
@match = map $self->{command}{$_->[0]},
sort {
$a->[1] <=> $b->[1]
+ or $self->{command}{$a->[0]}[4] <=> $self->{command}{$b->[0]}[4]
or (length $a->[0]) <=> (length $b->[0])
} @match;