… | |
… | |
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 | (delete $self->{out_of_focus})->destroy |
150 | glLogicOp GL_AND; |
155 | if $self->{out_of_focus}; |
151 | glEnable GL_COLOR_LOGIC_OP; |
156 | } else { |
|
|
157 | glColor 0.4, 0.2, 0.2, 0.6; |
|
|
158 | glEnable GL_BLEND; |
|
|
159 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
152 | glBegin GL_QUADS; |
160 | glBegin GL_QUADS; |
153 | glVertex 0, 0; |
161 | glVertex 0, 0; |
154 | glVertex 0, $::HEIGHT; |
162 | glVertex 0, $::HEIGHT; |
155 | glVertex $::WIDTH, $::HEIGHT; |
163 | glVertex $::WIDTH, $::HEIGHT; |
156 | glVertex $::WIDTH, 0; |
164 | glVertex $::WIDTH, 0; |
157 | glEnd; |
165 | glEnd; |
158 | glDisable GL_COLOR_LOGIC_OP; |
166 | glDisable GL_BLEND; |
|
|
167 | |
|
|
168 | $self->{out_of_focus} ||= do { |
|
|
169 | my $label = new CFClient::UI::Label |
|
|
170 | x => 0, |
|
|
171 | y => 0, |
|
|
172 | z => 1, |
|
|
173 | ellipsise => 0, |
|
|
174 | text => "map out of focus (click map to play)"; |
|
|
175 | |
|
|
176 | $label->show; |
|
|
177 | $label->update; |
|
|
178 | |
|
|
179 | $CFClient::UI::ROOT->on_post_alloc ("$self$label" => sub { |
|
|
180 | $label->move ( |
|
|
181 | ($::WIDTH - $label->{w}) * 0.5, |
|
|
182 | ($::HEIGHT - $label->{h}) * 0.5, |
|
|
183 | ); |
|
|
184 | }); |
|
|
185 | |
|
|
186 | $label |
|
|
187 | }; |
159 | } |
188 | } |
160 | } |
189 | } |
161 | |
190 | |
162 | my %DIR = ( |
191 | my %DIR = ( |
163 | CFClient::SDLK_KP8, [1, "north"], |
192 | CFClient::SDLK_KP8, [1, "north"], |
… | |
… | |
186 | |
215 | |
187 | if ($sym == CFClient::SDLK_KP5) { |
216 | if ($sym == CFClient::SDLK_KP5) { |
188 | $::CONN->user_send ("stay fire"); |
217 | $::CONN->user_send ("stay fire"); |
189 | } elsif ($uni == ord ",") { |
218 | } elsif ($uni == ord ",") { |
190 | $::CONN->user_send ("take"); |
219 | $::CONN->user_send ("take"); |
191 | } elsif ($uni == ord "\t") { |
220 | } elsif ($uni == ord "\t" or $uni == ord " ") { |
192 | $::CONN->user_send ("apply"); |
221 | $::CONN->user_send ("apply"); |
|
|
222 | } elsif ($sym == CFClient::SDLK_KP_PLUS || $uni == ord "+") { |
|
|
223 | $::CONN->user_send ("rotateshoottype +"); |
|
|
224 | } elsif ($sym == CFClient::SDLK_KP_MINUS || $uni == ord "-") { |
|
|
225 | $::CONN->user_send ("rotateshoottype -"); |
193 | } elsif ($uni == ord "'") { |
226 | } elsif ($uni == ord "'") { |
194 | $self->emit ('activate_console'); |
227 | $self->emit ('activate_console'); |
195 | } elsif ($uni == ord "/") { |
228 | } elsif ($uni == ord "/") { |
196 | $self->emit (activate_console => '/'); |
229 | $self->emit (activate_console => '/'); |
197 | } elsif (exists $DIR{$sym}) { |
230 | } elsif (exists $DIR{$sym}) { |
… | |
… | |
249 | |
282 | |
250 | $tooltip = "<big>$data</big>\n\n$tooltip"; |
283 | $tooltip = "<big>$data</big>\n\n$tooltip"; |
251 | |
284 | |
252 | $tooltip =~ s/\s+$//; |
285 | $tooltip =~ s/\s+$//; |
253 | |
286 | |
254 | $self->{command}{$command} = [$data, $tooltip, $widget, $cb]; |
287 | $self->{command}{$command} = [$data, $tooltip, $widget, $cb, ++$self->{command_id}]; |
255 | } |
288 | } |
256 | |
289 | |
257 | sub clr_commands { |
290 | sub clr_commands { |
258 | my ($self) = @_; |
291 | my ($self) = @_; |
259 | |
292 | |
… | |
… | |
362 | CFClient::UI::Label->new ( |
395 | CFClient::UI::Label->new ( |
363 | can_hover => 1, |
396 | can_hover => 1, |
364 | can_events => 1, |
397 | can_events => 1, |
365 | tooltip_width => 0.33, |
398 | tooltip_width => 0.33, |
366 | fontsize => $_, |
399 | fontsize => $_, |
367 | ), (0.8) x 6 |
400 | ), (0.8) x 16 |
368 | ]; |
401 | ]; |
369 | |
402 | |
370 | $self->{entry} = new CFClient::UI::Entry |
403 | $self->{entry} = new CFClient::UI::Entry |
371 | connect_changed => sub { |
404 | connect_changed => sub { |
372 | $self->update_labels; |
405 | $self->update_labels; |
… | |
… | |
446 | } |
479 | } |
447 | |
480 | |
448 | @match = map $self->{command}{$_->[0]}, |
481 | @match = map $self->{command}{$_->[0]}, |
449 | sort { |
482 | sort { |
450 | $a->[1] <=> $b->[1] |
483 | $a->[1] <=> $b->[1] |
|
|
484 | or $self->{command}{$a->[0]}[4] <=> $self->{command}{$b->[0]}[4] |
451 | or (length $a->[0]) <=> (length $b->[0]) |
485 | or (length $a->[0]) <=> (length $b->[0]) |
452 | } @match; |
486 | } @match; |
453 | |
487 | |
454 | $self->{last_search} = $cmd; |
488 | $self->{last_search} = $cmd; |
455 | $self->{last_match} = \@match; |
489 | $self->{last_match} = \@match; |