… | |
… | |
78 | $self->SUPER::update; |
78 | $self->SUPER::update; |
79 | } |
79 | } |
80 | |
80 | |
81 | sub draw { |
81 | sub draw { |
82 | my ($self) = @_; |
82 | my ($self) = @_; |
|
|
83 | |
|
|
84 | return |
|
|
85 | unless $CFClient::UI::FOCUS == $self || !$::FAST; |
83 | |
86 | |
84 | if (delete $self->{need_update}) { |
87 | if (delete $self->{need_update}) { |
85 | glNewList $self->{list}; |
88 | glNewList $self->{list}; |
86 | |
89 | |
87 | if ($::MAP) { |
90 | if ($::MAP) { |
… | |
… | |
112 | 0.05, 0.13, 0.05, |
115 | 0.05, 0.13, 0.05, |
113 | ); |
116 | ); |
114 | glEnable GL_CONVOLUTION_2D; |
117 | glEnable GL_CONVOLUTION_2D; |
115 | } |
118 | } |
116 | |
119 | |
|
|
120 | # try to re-use the texture name: TODO improve texture class instead |
|
|
121 | my $prev_name = ((delete $self->{fow_texture}) || {})->{name}; |
|
|
122 | |
117 | $self->{fow_texture} = new CFClient::Texture |
123 | $self->{fow_texture} = new CFClient::Texture |
118 | w => $w, |
124 | w => $w, |
119 | h => $h, |
125 | h => $h, |
120 | data => $data, |
126 | data => $data, |
|
|
127 | name => $prev_name, # a bit hackish |
121 | internalformat => GL_ALPHA, |
128 | internalformat => GL_ALPHA, |
122 | format => GL_ALPHA; |
129 | format => GL_ALPHA; |
123 | |
130 | |
124 | glDisable GL_CONVOLUTION_2D if $::CFG->{fow_smooth}; |
131 | glDisable GL_CONVOLUTION_2D if $::CFG->{fow_smooth}; |
125 | |
132 | |
126 | glEnable GL_BLEND; |
|
|
127 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
|
|
128 | glEnable GL_TEXTURE_2D; |
133 | glEnable GL_TEXTURE_2D; |
129 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; |
134 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; |
130 | |
135 | |
131 | glColor +($::CFG->{fow_intensity}) x 3, 0.8; |
136 | glColor +($::CFG->{fow_intensity}) x 3, 0.8; |
132 | $self->{fow_texture}->draw_quad (0, 0, $w * 32, $h * 32); |
137 | $self->{fow_texture}->draw_quad_alpha (0, 0, $w * 32, $h * 32); |
133 | |
138 | |
134 | glDisable GL_TEXTURE_2D; |
139 | glDisable GL_TEXTURE_2D; |
135 | glDisable GL_BLEND; |
|
|
136 | } |
140 | } |
137 | |
141 | |
138 | glPopMatrix; |
142 | glPopMatrix; |
139 | } |
143 | } |
140 | |
144 | |
… | |
… | |
143 | |
147 | |
144 | glPushMatrix; |
148 | glPushMatrix; |
145 | glCallList $self->{list}; |
149 | glCallList $self->{list}; |
146 | glPopMatrix; |
150 | glPopMatrix; |
147 | |
151 | |
|
|
152 | # TNT2 emulates logops in software (or worse :) |
148 | if ($CFClient::UI::FOCUS != $self) { |
153 | if ($CFClient::UI::FOCUS != $self) { |
149 | glColor 64/255, 64/255, 64/255; |
154 | glColor 0.4, 0.2, 0.2, 0.9; |
150 | glLogicOp GL_AND; |
155 | glEnable GL_BLEND; |
151 | glEnable GL_COLOR_LOGIC_OP; |
156 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
152 | glBegin GL_QUADS; |
157 | glBegin GL_QUADS; |
153 | glVertex 0, 0; |
158 | glVertex 0, 0; |
154 | glVertex 0, $::HEIGHT; |
159 | glVertex 0, $::HEIGHT; |
155 | glVertex $::WIDTH, $::HEIGHT; |
160 | glVertex $::WIDTH, $::HEIGHT; |
156 | glVertex $::WIDTH, 0; |
161 | glVertex $::WIDTH, 0; |
157 | glEnd; |
162 | glEnd; |
158 | glDisable GL_COLOR_LOGIC_OP; |
163 | glDisable GL_BLEND; |
159 | } |
164 | } |
160 | } |
165 | } |
161 | |
166 | |
162 | my %DIR = ( |
167 | my %DIR = ( |
163 | CFClient::SDLK_KP8, [1, "north"], |
168 | CFClient::SDLK_KP8, [1, "north"], |
… | |
… | |
186 | |
191 | |
187 | if ($sym == CFClient::SDLK_KP5) { |
192 | if ($sym == CFClient::SDLK_KP5) { |
188 | $::CONN->user_send ("stay fire"); |
193 | $::CONN->user_send ("stay fire"); |
189 | } elsif ($uni == ord ",") { |
194 | } elsif ($uni == ord ",") { |
190 | $::CONN->user_send ("take"); |
195 | $::CONN->user_send ("take"); |
191 | } elsif ($uni == ord "\t") { |
196 | } elsif ($uni == ord "\t" or $uni == ord " ") { |
192 | $::CONN->user_send ("apply"); |
197 | $::CONN->user_send ("apply"); |
|
|
198 | } elsif ($sym == CFClient::SDLK_KP_PLUS || $uni == ord "+") { |
|
|
199 | $::CONN->user_send ("rotateshoottype +"); |
|
|
200 | } elsif ($sym == CFClient::SDLK_KP_MINUS || $uni == ord "-") { |
|
|
201 | $::CONN->user_send ("rotateshoottype -"); |
193 | } elsif ($uni == ord "'") { |
202 | } elsif ($uni == ord "'") { |
194 | $self->emit ('activate_console'); |
203 | $self->emit ('activate_console'); |
195 | } elsif ($uni == ord "/") { |
204 | } elsif ($uni == ord "/") { |
196 | $self->emit (activate_console => '/'); |
205 | $self->emit (activate_console => '/'); |
197 | } elsif (exists $DIR{$sym}) { |
206 | } elsif (exists $DIR{$sym}) { |
… | |
… | |
245 | |
254 | |
246 | (my $data = $command) =~ s/\\//g; |
255 | (my $data = $command) =~ s/\\//g; |
247 | |
256 | |
248 | $tooltip =~ s/^\s+//; |
257 | $tooltip =~ s/^\s+//; |
249 | |
258 | |
250 | $tooltip = "<big>" . (CFClient::UI::Label::escape $data) . "</big>\n\n" |
259 | $tooltip = "<big>$data</big>\n\n$tooltip"; |
251 | . CFClient::UI::Label::escape $tooltip; |
|
|
252 | |
260 | |
253 | $tooltip =~ s/\s+$//; |
261 | $tooltip =~ s/\s+$//; |
254 | |
262 | |
255 | $self->{command}{$command} = [$data, $tooltip, $widget, $cb]; |
263 | $self->{command}{$command} = [$data, $tooltip, $widget, $cb, ++$self->{command_id}]; |
256 | } |
264 | } |
257 | |
265 | |
258 | sub clr_commands { |
266 | sub clr_commands { |
259 | my ($self) = @_; |
267 | my ($self) = @_; |
260 | |
268 | |
… | |
… | |
359 | $self->add ($self->{vbox} = new CFClient::UI::VBox); |
367 | $self->add ($self->{vbox} = new CFClient::UI::VBox); |
360 | |
368 | |
361 | $self->{label} = [ |
369 | $self->{label} = [ |
362 | map |
370 | map |
363 | CFClient::UI::Label->new ( |
371 | CFClient::UI::Label->new ( |
364 | can_hover => 1, |
372 | can_hover => 1, |
365 | can_events => 1, |
373 | can_events => 1, |
|
|
374 | tooltip_width => 0.33, |
366 | fontsize => $_, |
375 | fontsize => $_, |
367 | ), (0.8) x 6 |
376 | ), (0.8) x 16 |
368 | ]; |
377 | ]; |
369 | |
378 | |
370 | $self->{entry} = new CFClient::UI::Entry |
379 | $self->{entry} = new CFClient::UI::Entry |
371 | connect_changed => sub { |
380 | connect_changed => sub { |
372 | $self->update_labels; |
381 | $self->update_labels; |
… | |
… | |
446 | } |
455 | } |
447 | |
456 | |
448 | @match = map $self->{command}{$_->[0]}, |
457 | @match = map $self->{command}{$_->[0]}, |
449 | sort { |
458 | sort { |
450 | $a->[1] <=> $b->[1] |
459 | $a->[1] <=> $b->[1] |
451 | or (length $a->[0]) <=> (length $b->[0]) |
460 | or $self->{command}{$a->[0]}[4] <=> $self->{command}{$b->[0]}[4] |
452 | } @match; |
461 | } @match; |
453 | |
462 | |
454 | $self->{last_search} = $cmd; |
463 | $self->{last_search} = $cmd; |
455 | $self->{last_match} = \@match; |
464 | $self->{last_match} = \@match; |
456 | |
465 | |