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.9 by root, Mon Apr 24 02:41:48 2006 UTC vs.
Revision 1.12 by root, Mon Apr 24 06:05:35 2006 UTC

236 $self->{command_widget} ||= 236 $self->{command_widget} ||=
237 new CFClient::MapWidget::Command:: 237 new CFClient::MapWidget::Command::
238 command => $self->{command}, 238 command => $self->{command},
239 can_focus => 1, 239 can_focus => 1,
240 connect_execute => sub { 240 connect_execute => sub {
241 # todo: support callback instead of user_send
241 $::CONN->user_send ($_[1]); 242 $::CONN->user_send ($_[1][1]);
242 }, 243 },
243 connect_close => sub { 244 connect_close => sub {
244 (delete $self->{command_widget})->hide; 245 (delete $self->{command_widget})->hide;
245 $self->focus_in; 246 $self->focus_in;
246 }, 247 },
247 ; 248 ;
248 $self->{command_widget}->key_down ($ev); 249 $self->{command_widget}->key_down ($ev);
250 return unless $self->{command_widget};
249 $self->{command_widget}->show; 251 $self->{command_widget}->show;
250 $self->{command_widget}->focus_in; 252 $self->{command_widget}->focus_in;
251 } 253 }
252} 254}
253 255
264 $::CONN->user_send ("run_stop"); 266 $::CONN->user_send ("run_stop");
265 } 267 }
266} 268}
267 269
268sub add_command { 270sub add_command {
269 my ($self, $command, $widget, $cb) = @_; 271 my ($self, $command, $tooltip, $widget, $cb) = @_;
270 272
271 (my $abbrev = $command) =~ s/(\S)[^[:space:]_]*[[:space:]_]+/$1/g; 273 (my $abbrev = $command) =~ s/(\S)[^[:space:]_]*[[:space:]_]+/$1/g;
272 274
273 push @{$self->{command}}, [$abbrev, $command]; 275 push @{$self->{command}}, [$abbrev, $command, $tooltip, $widget, $cb];
274 #warn "$command|$abbrev|$widget\n";#d#
275} 276}
276 277
277package CFClient::MapWidget::Command; 278package CFClient::MapWidget::Command;
278 279
279use strict; 280use strict;
287 288
288 my $self = $class->SUPER::new ( 289 my $self = $class->SUPER::new (
289 @_, 290 @_,
290 children => [map 291 children => [map
291 CFClient::UI::Label->new ( 292 CFClient::UI::Label->new (
292 can_hover => 1, 293 can_hover => 1,
294 can_events => 1,
293 fontsize => $_, 295 fontsize => $_,
294 ), 1, 1, 0.8, 0.8, 0.8, 0.8, 0.8 296 ), 1, 1, 0.8, 0.8, 0.8, 0.8, 0.8
295 ], 297 ],
296 ); 298 );
297 299
298 $self 300 $self
326 328
327 $self->{children}[0]->set_text ("$self->{search}_"); 329 $self->{children}[0]->set_text ("$self->{search}_");
328 330
329 for (0..5) { 331 for (0..5) {
330 $self->{children}[$_ + 1]->set_text ($found[$_] ? "$found[$_][0] ($found[$_][1][1])" : ""); 332 $self->{children}[$_ + 1]->set_text ($found[$_] ? "$found[$_][0] ($found[$_][1][1])" : "");
333 $self->{children}[$_ + 1]{tooltip} = ($found[$_] ? $found[$_][1][2] : "");
331 } 334 }
332 335
333 $self->{select} = $found[0][1][1] 336 $self->{select} = $found[0][1]
334 if @found; 337 if @found;
335 338
336 if (@found > 6) { 339 if (@found > 6) {
337 $self->{children}[6]->set_text ("..."); 340 $self->{children}[6]->set_text ("...");
338 } 341 }
351 $self->emit (execute => $self->{select}); 354 $self->emit (execute => $self->{select});
352 $self->emit ("close"); 355 $self->emit ("close");
353 } 356 }
354 } elsif ($ev->{sym} == 27) { 357 } elsif ($ev->{sym} == 27) {
355 $self->emit ("close"); 358 $self->emit ("close");
356 } elsif ($ev->{unicode}) { 359 } elsif ((chr $ev->{unicode}) =~ /^[[:alpha:]]$/) {
357 $self->{search} .= chr $ev->{unicode}; 360 $self->{search} .= chr $ev->{unicode};
358 $self->update_labels; 361 $self->update_labels;
359 } 362 }
363
364 length $self->{search}
365 or $self->emit ("close");
360} 366}
361 367
3621 3681

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines