ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/MapWidget.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/MapWidget.pm (file contents):
Revision 1.36 by root, Thu May 25 00:26:19 2006 UTC vs.
Revision 1.44 by root, Tue May 30 07:13:08 2006 UTC

20 ); 20 );
21 21
22 $self->{completer} = new CFClient::MapWidget::Command:: 22 $self->{completer} = new CFClient::MapWidget::Command::
23 command => $self->{command}, 23 command => $self->{command},
24 can_focus => 1, 24 can_focus => 1,
25 tooltip => "<b>The Command Completer</b>\n\n"
26 . "This is your central interface to send text commands to the server. "
27 . "To enter a verbatim command to send to the server, just type the command, "
28 . "followed by a space, and press return. "
29 . "Typing the initial letters of words (or just any letters) displays guesses "
30 . "for commands you might want to use.\n"
31 . "You can use the cursor-up and cursor-down keys to select between those guesses.\n"
32 . "<b>Right-Click</b> opens a menu where you cna select further options, sich as redefining keybindings.",
25 ; 33 ;
26 34
27 $self 35 $self
28} 36}
29 37
31 my ($self, $command, $tooltip, $widget, $cb) = @_; 39 my ($self, $command, $tooltip, $widget, $cb) = @_;
32 40
33 (my $data = $command) =~ s/\\//g; 41 (my $data = $command) =~ s/\\//g;
34 42
35 $tooltip =~ s/^\s+//; 43 $tooltip =~ s/^\s+//;
36
37 $tooltip = "<big>$data</big>\n\n$tooltip"; 44 $tooltip = "<big>$data</big>\n\n$tooltip";
38
39 $tooltip =~ s/\s+$//; 45 $tooltip =~ s/\s+$//;
40 46
41 $self->{completer}{command}{$command} = [$data, $tooltip, $widget, $cb, ++$self->{command_id}]; 47 $self->{completer}{command}{$command} = [$data, $tooltip, $widget, $cb, ++$self->{command_id}];
42} 48}
43 49
124 $::CONN->user_send ("stay fire"); 130 $::CONN->user_send ("stay fire");
125 } elsif ($uni == ord ",") { 131 } elsif ($uni == ord ",") {
126 $::CONN->user_send ("take"); 132 $::CONN->user_send ("take");
127 } elsif ($uni == ord " ") { 133 } elsif ($uni == ord " ") {
128 $::CONN->user_send ("apply"); 134 $::CONN->user_send ("apply");
135 } elsif ($uni == ord ".") {
136 $::CONN->user_send ($self->{completer}{last_command})
137 if exists $self->{completer}{last_command};
129 } elsif ($uni == ord "\t") { 138 } elsif ($uni == ord "\t") {
130 # TODO: toggle inventory 139 $::INV_WINDOW->toggle_visibility;
131 } elsif ($sym == CFClient::SDLK_KP_PLUS || $uni == ord "+") { 140 } elsif ($sym == CFClient::SDLK_KP_PLUS || $uni == ord "+") {
132 $::CONN->user_send ("rotateshoottype +"); 141 $::CONN->user_send ("rotateshoottype +");
133 } elsif ($sym == CFClient::SDLK_KP_MINUS || $uni == ord "-") { 142 } elsif ($sym == CFClient::SDLK_KP_MINUS || $uni == ord "-") {
134 $::CONN->user_send ("rotateshoottype -"); 143 $::CONN->user_send ("rotateshoottype -");
135 } elsif ($uni == ord '"') { 144 } elsif ($uni == ord '"') {
146 $self->{ctrl}++; 155 $self->{ctrl}++;
147 $::CONN->user_send ("run $DIR{$sym}[0]"); 156 $::CONN->user_send ("run $DIR{$sym}[0]");
148 } else { 157 } else {
149 $::CONN->user_send ("$DIR{$sym}[1]"); 158 $::CONN->user_send ("$DIR{$sym}[1]");
150 } 159 }
151 } 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')) {
152 $self->{completer}->key_down ($ev); 167 $self->{completer}->key_down ($ev);
153 $self->{completer}->show; 168 $self->{completer}->show;
154 } 169 }
155} 170}
156 171
193 glTranslate $sx0 - 32, $sy0 - 32, 0; 208 glTranslate $sx0 - 32, $sy0 - 32, 0;
194 209
195 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);
196 211
197 if ($::CFG->{fow_enable}) { 212 if ($::CFG->{fow_enable}) {
198 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
199 glConvolutionParameter (GL_CONVOLUTION_2D, GL_CONVOLUTION_BORDER_MODE, GL_CONSTANT_BORDER); 214 glConvolutionParameter (GL_CONVOLUTION_2D, GL_CONVOLUTION_BORDER_MODE, GL_CONSTANT_BORDER);
200 glConvolutionFilter2D ( 215 glConvolutionFilter2D (
201 GL_CONVOLUTION_2D, 216 GL_CONVOLUTION_2D,
202 GL_ALPHA, 217 GL_ALPHA,
203 3, 3, 218 3, 3,
256 glVertex $::WIDTH, $::HEIGHT; 271 glVertex $::WIDTH, $::HEIGHT;
257 glVertex $::WIDTH, 0; 272 glVertex $::WIDTH, 0;
258 glEnd; 273 glEnd;
259 glDisable GL_BLEND; 274 glDisable GL_BLEND;
260 275
261 $self->{out_of_focus} ||= do { 276# $self->{out_of_focus} ||= do {
262 my $label = new CFClient::UI::Label 277# my $label = new CFClient::UI::Label
263 x => 0, 278# x => 0,
264 y => 0, 279# y => 0,
265 z => 1, 280# z => 1,
266 ellipsise => 0, 281# ellipsise => 0,
267 text => "map out of focus (click map to play)"; 282# text => "map out of focus (click map to play)";
268 283#
269 $label->show; 284# $label->show;
270 $label->update; 285# $label->update;
271 286#
272 $CFClient::UI::ROOT->on_post_alloc ("$self$label" => sub { 287# $CFClient::UI::ROOT->on_post_alloc ("$self$label" => sub {
273 $label->move ( 288# $label->move_abs (
274 ($::WIDTH - $label->{w}) * 0.5, 289# ($::WIDTH - $label->{w}) * 0.5,
275 ($::HEIGHT - $label->{h}) * 0.5, 290# ($::HEIGHT - $label->{h}) * 0.5,
276 ); 291# );
277 }); 292# });
278 293#
279 $label 294# $label
280 }; 295# };
281 } 296 }
282} 297}
283 298
284sub DESTROY { 299sub DESTROY {
285 my $self = shift; 300 my $self = shift;
395 fontsize => $_, 410 fontsize => $_,
396 ), (0.8) x 16 411 ), (0.8) x 16
397 ]; 412 ];
398 413
399 $self->{entry} = new CFClient::UI::Entry 414 $self->{entry} = new CFClient::UI::Entry
400 connect_changed => sub { 415 on_changed => sub {
401 $self->update_labels; 416 $self->update_labels;
402 }, 417 },
403 connect_key_down => sub { 418 on_key_down => sub {
404 my ($entry, $ev) = @_; 419 my ($entry, $ev) = @_;
405 420
406 my $self = $entry->{parent}{parent}; 421 my $self = $entry->{parent}{parent};
407 422
408 if ($ev->{sym} == 13) { 423 if ($ev->{sym} == 13) {
409 if (exists $self->{select}) { 424 if (exists $self->{select}) {
425 $self->{last_command} = $self->{select};
410 $::CONN->user_send ($self->{select}); 426 $::CONN->user_send ($self->{select});
411 $self->hide; 427 $self->hide;
412 } 428 }
413 } elsif ($ev->{sym} == 27) { 429 } elsif ($ev->{sym} == 27) {
414 $self->hide; 430 $self->hide;
446 462
447sub size_allocate { 463sub size_allocate {
448 my ($self, $w, $h) = @_; 464 my ($self, $w, $h) = @_;
449 465
450 $self->SUPER::size_allocate ($w, $h); 466 $self->SUPER::size_allocate ($w, $h);
451 $self->move (($::WIDTH - $w) * 0.5, ($::HEIGHT - $h) * 0.6, 10); 467 $self->move_abs (($::WIDTH - $w) * 0.5, ($::HEIGHT - $h) * 0.6, 10);
452} 468}
453 469
454sub show { 470sub show {
455 my ($self) = @_; 471 my ($self) = @_;
456 472
509 525
510 @match = map $self->{command}{$_->[0]}, 526 @match = map $self->{command}{$_->[0]},
511 sort { 527 sort {
512 $a->[1] <=> $b->[1] 528 $a->[1] <=> $b->[1]
513 or $self->{command}{$a->[0]}[4] <=> $self->{command}{$b->[0]}[4] 529 or $self->{command}{$a->[0]}[4] <=> $self->{command}{$b->[0]}[4]
514 or (length $a->[0]) <=> (length $b->[0]) 530 or (length $b->[0]) <=> (length $a->[0])
515 } @match; 531 } @match;
516 } 532 }
517 533
518 $self->{last_search} = $cmd; 534 $self->{last_search} = $text;
519 $self->{last_match} = \@match; 535 $self->{last_match} = \@match;
520 536
521 $self->{select_offset} = 0; 537 $self->{select_offset} = 0;
522 } 538 }
523 539

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines