… | |
… | |
39 | my ($self, $command, $tooltip, $widget, $cb) = @_; |
39 | my ($self, $command, $tooltip, $widget, $cb) = @_; |
40 | |
40 | |
41 | (my $data = $command) =~ s/\\//g; |
41 | (my $data = $command) =~ s/\\//g; |
42 | |
42 | |
43 | $tooltip =~ s/^\s+//; |
43 | $tooltip =~ s/^\s+//; |
44 | |
|
|
45 | $tooltip = "<big>$data</big>\n\n$tooltip"; |
44 | $tooltip = "<big>$data</big>\n\n$tooltip"; |
46 | |
|
|
47 | $tooltip =~ s/\s+$//; |
45 | $tooltip =~ s/\s+$//; |
48 | |
46 | |
49 | $self->{completer}{command}{$command} = [$data, $tooltip, $widget, $cb, ++$self->{command_id}]; |
47 | $self->{completer}{command}{$command} = [$data, $tooltip, $widget, $cb, ++$self->{command_id}]; |
50 | } |
48 | } |
51 | |
49 | |
… | |
… | |
136 | $::CONN->user_send ("apply"); |
134 | $::CONN->user_send ("apply"); |
137 | } elsif ($uni == ord ".") { |
135 | } elsif ($uni == ord ".") { |
138 | $::CONN->user_send ($self->{completer}{last_command}) |
136 | $::CONN->user_send ($self->{completer}{last_command}) |
139 | if exists $self->{completer}{last_command}; |
137 | if exists $self->{completer}{last_command}; |
140 | } elsif ($uni == ord "\t") { |
138 | } elsif ($uni == ord "\t") { |
141 | # TODO: toggle inventory |
139 | $::INV_WINDOW->toggle_visibility; |
142 | } elsif ($sym == CFClient::SDLK_KP_PLUS || $uni == ord "+") { |
140 | } elsif ($sym == CFClient::SDLK_KP_PLUS || $uni == ord "+") { |
143 | $::CONN->user_send ("rotateshoottype +"); |
141 | $::CONN->user_send ("rotateshoottype +"); |
144 | } elsif ($sym == CFClient::SDLK_KP_MINUS || $uni == ord "-") { |
142 | } elsif ($sym == CFClient::SDLK_KP_MINUS || $uni == ord "-") { |
145 | $::CONN->user_send ("rotateshoottype -"); |
143 | $::CONN->user_send ("rotateshoottype -"); |
146 | } elsif ($uni == ord '"') { |
144 | } elsif ($uni == ord '"') { |
… | |
… | |
157 | $self->{ctrl}++; |
155 | $self->{ctrl}++; |
158 | $::CONN->user_send ("run $DIR{$sym}[0]"); |
156 | $::CONN->user_send ("run $DIR{$sym}[0]"); |
159 | } else { |
157 | } else { |
160 | $::CONN->user_send ("$DIR{$sym}[1]"); |
158 | $::CONN->user_send ("$DIR{$sym}[1]"); |
161 | } |
159 | } |
162 | } elsif ($ev->{unicode}) { |
160 | } elsif ($sym == CFClient::SDLK_INSERT && $mod & CFClient::KMOD_CTRL) { |
|
|
161 | CFClient::Recorder::start (1); |
|
|
162 | } elsif ($sym == CFClient::SDLK_INSERT && not ($mod & CFClient::KMOD_CTRL)) { |
|
|
163 | CFClient::Recorder::stop (1); |
|
|
164 | } elsif (my $bind_cmd = $::CFG->{bindings}->{$mod}->{$sym}) { |
|
|
165 | $::CONN->user_send ($_) for @$bind_cmd; |
|
|
166 | } elsif ((ord 'a') <= $uni && $uni <= (ord 'z')) { |
163 | $self->{completer}->key_down ($ev); |
167 | $self->{completer}->key_down ($ev); |
164 | $self->{completer}->show; |
168 | $self->{completer}->show; |
165 | } |
169 | } |
166 | } |
170 | } |
167 | |
171 | |
… | |
… | |
204 | glTranslate $sx0 - 32, $sy0 - 32, 0; |
208 | glTranslate $sx0 - 32, $sy0 - 32, 0; |
205 | |
209 | |
206 | my ($w, $h, $data) = $::MAP->draw ($sx, $sy, 0, 0, $sw + 1, $sh + 1); |
210 | my ($w, $h, $data) = $::MAP->draw ($sx, $sy, 0, 0, $sw + 1, $sh + 1); |
207 | |
211 | |
208 | if ($::CFG->{fow_enable}) { |
212 | if ($::CFG->{fow_enable}) { |
209 | if ($::CFG->{fow_smooth} && $CFClient::GL_VERSION >= 1.2) { # smooth fog of war |
213 | if ($::CFG->{fow_smooth} && $CFClient::OpenGL::GL_VERSION >= 1.2) { # smooth fog of war |
210 | glConvolutionParameter (GL_CONVOLUTION_2D, GL_CONVOLUTION_BORDER_MODE, GL_CONSTANT_BORDER); |
214 | glConvolutionParameter (GL_CONVOLUTION_2D, GL_CONVOLUTION_BORDER_MODE, GL_CONSTANT_BORDER); |
211 | glConvolutionFilter2D ( |
215 | glConvolutionFilter2D ( |
212 | GL_CONVOLUTION_2D, |
216 | GL_CONVOLUTION_2D, |
213 | GL_ALPHA, |
217 | GL_ALPHA, |
214 | 3, 3, |
218 | 3, 3, |
… | |
… | |
267 | glVertex $::WIDTH, $::HEIGHT; |
271 | glVertex $::WIDTH, $::HEIGHT; |
268 | glVertex $::WIDTH, 0; |
272 | glVertex $::WIDTH, 0; |
269 | glEnd; |
273 | glEnd; |
270 | glDisable GL_BLEND; |
274 | glDisable GL_BLEND; |
271 | |
275 | |
272 | $self->{out_of_focus} ||= do { |
276 | # $self->{out_of_focus} ||= do { |
273 | my $label = new CFClient::UI::Label |
277 | # my $label = new CFClient::UI::Label |
274 | x => 0, |
278 | # x => 0, |
275 | y => 0, |
279 | # y => 0, |
276 | z => 1, |
280 | # z => 1, |
277 | ellipsise => 0, |
281 | # ellipsise => 0, |
278 | text => "map out of focus (click map to play)"; |
282 | # text => "map out of focus (click map to play)"; |
279 | |
283 | # |
280 | $label->show; |
284 | # $label->show; |
281 | $label->update; |
285 | # $label->update; |
282 | |
286 | # |
283 | $CFClient::UI::ROOT->on_post_alloc ("$self$label" => sub { |
287 | # $CFClient::UI::ROOT->on_post_alloc ("$self$label" => sub { |
284 | $label->move ( |
288 | # $label->move_abs ( |
285 | ($::WIDTH - $label->{w}) * 0.5, |
289 | # ($::WIDTH - $label->{w}) * 0.5, |
286 | ($::HEIGHT - $label->{h}) * 0.5, |
290 | # ($::HEIGHT - $label->{h}) * 0.5, |
287 | ); |
291 | # ); |
288 | }); |
292 | # }); |
289 | |
293 | # |
290 | $label |
294 | # $label |
291 | }; |
295 | # }; |
292 | } |
296 | } |
293 | } |
297 | } |
294 | |
298 | |
295 | sub DESTROY { |
299 | sub DESTROY { |
296 | my $self = shift; |
300 | my $self = shift; |
… | |
… | |
406 | fontsize => $_, |
410 | fontsize => $_, |
407 | ), (0.8) x 16 |
411 | ), (0.8) x 16 |
408 | ]; |
412 | ]; |
409 | |
413 | |
410 | $self->{entry} = new CFClient::UI::Entry |
414 | $self->{entry} = new CFClient::UI::Entry |
411 | connect_changed => sub { |
415 | on_changed => sub { |
412 | $self->update_labels; |
416 | $self->update_labels; |
413 | }, |
417 | }, |
414 | connect_key_down => sub { |
418 | on_key_down => sub { |
415 | my ($entry, $ev) = @_; |
419 | my ($entry, $ev) = @_; |
416 | |
420 | |
417 | my $self = $entry->{parent}{parent}; |
421 | my $self = $entry->{parent}{parent}; |
418 | |
422 | |
419 | if ($ev->{sym} == 13) { |
423 | if ($ev->{sym} == 13) { |
… | |
… | |
458 | |
462 | |
459 | sub size_allocate { |
463 | sub size_allocate { |
460 | my ($self, $w, $h) = @_; |
464 | my ($self, $w, $h) = @_; |
461 | |
465 | |
462 | $self->SUPER::size_allocate ($w, $h); |
466 | $self->SUPER::size_allocate ($w, $h); |
463 | $self->move (($::WIDTH - $w) * 0.5, ($::HEIGHT - $h) * 0.6, 10); |
467 | $self->move_abs (($::WIDTH - $w) * 0.5, ($::HEIGHT - $h) * 0.6, 10); |
464 | } |
468 | } |
465 | |
469 | |
466 | sub show { |
470 | sub show { |
467 | my ($self) = @_; |
471 | my ($self) = @_; |
468 | |
472 | |
… | |
… | |
521 | |
525 | |
522 | @match = map $self->{command}{$_->[0]}, |
526 | @match = map $self->{command}{$_->[0]}, |
523 | sort { |
527 | sort { |
524 | $a->[1] <=> $b->[1] |
528 | $a->[1] <=> $b->[1] |
525 | or $self->{command}{$a->[0]}[4] <=> $self->{command}{$b->[0]}[4] |
529 | or $self->{command}{$a->[0]}[4] <=> $self->{command}{$b->[0]}[4] |
526 | or (length $a->[0]) <=> (length $b->[0]) |
530 | or (length $b->[0]) <=> (length $a->[0]) |
527 | } @match; |
531 | } @match; |
528 | } |
532 | } |
529 | |
533 | |
530 | $self->{last_search} = $cmd; |
534 | $self->{last_search} = $text; |
531 | $self->{last_match} = \@match; |
535 | $self->{last_match} = \@match; |
532 | |
536 | |
533 | $self->{select_offset} = 0; |
537 | $self->{select_offset} = 0; |
534 | } |
538 | } |
535 | |
539 | |