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.8 by root, Sat Apr 22 21:47:45 2006 UTC vs.
Revision 1.12 by root, Mon Apr 24 06:05:35 2006 UTC

80 80
81 if (delete $self->{need_update}) { 81 if (delete $self->{need_update}) {
82 glNewList $self->{list}; 82 glNewList $self->{list};
83 83
84 if ($::MAP) { 84 if ($::MAP) {
85 my $sw = int $::WIDTH / 32; 85 my $sw = int $::WIDTH / (32 * $::CFG->{map_scale});
86 my $sh = int $::HEIGHT / 32; 86 my $sh = int $::HEIGHT / (32 * $::CFG->{map_scale});
87 87
88 glScale $::CFG->{map_scale}, $::CFG->{map_scale};
89
88 my $sx = $::CFG->{map_shift_x}; my $sx0 = $sx & 31; $sx = ($sx - $sx0) / 32; 90 my $sx = $::CFG->{map_shift_x} / $::CFG->{map_scale}; my $sx0 = $sx & 31; $sx = ($sx - $sx0) / 32;
89 my $sy = $::CFG->{map_shift_y}; my $sy0 = $sy & 31; $sy = ($sy - $sy0) / 32; 91 my $sy = $::CFG->{map_shift_y} / $::CFG->{map_scale}; my $sy0 = $sy & 31; $sy = ($sy - $sy0) / 32;
90 92
91 glTranslate $sx0 - 32, $sy0 - 32, 0; 93 glTranslate $sx0 - 32, $sy0 - 32, 0;
92 94
93 my ($w, $h, $data) = $::MAP->draw ($sx, $sy, 0, 0, $sw + 1, $sh + 1); 95 my ($w, $h, $data) = $::MAP->draw ($sx, $sy, 0, 0, $sw + 1, $sh + 1);
94 96
234 $self->{command_widget} ||= 236 $self->{command_widget} ||=
235 new CFClient::MapWidget::Command:: 237 new CFClient::MapWidget::Command::
236 command => $self->{command}, 238 command => $self->{command},
237 can_focus => 1, 239 can_focus => 1,
238 connect_execute => sub { 240 connect_execute => sub {
241 # todo: support callback instead of user_send
239 $::CONN->user_send ($_[1]); 242 $::CONN->user_send ($_[1][1]);
240 }, 243 },
241 connect_close => sub { 244 connect_close => sub {
242 (delete $self->{command_widget})->hide; 245 (delete $self->{command_widget})->hide;
243 $self->focus_in; 246 $self->focus_in;
244 }, 247 },
245 ; 248 ;
246 $self->{command_widget}->key_down ($ev); 249 $self->{command_widget}->key_down ($ev);
250 return unless $self->{command_widget};
247 $self->{command_widget}->show; 251 $self->{command_widget}->show;
248 $self->{command_widget}->focus_in; 252 $self->{command_widget}->focus_in;
249 } 253 }
250} 254}
251 255
262 $::CONN->user_send ("run_stop"); 266 $::CONN->user_send ("run_stop");
263 } 267 }
264} 268}
265 269
266sub add_command { 270sub add_command {
267 my ($self, $command, $widget, $cb) = @_; 271 my ($self, $command, $tooltip, $widget, $cb) = @_;
268 272
269 (my $abbrev = $command) =~ s/(\S)[^[:space:]_]*[[:space:]_]+/$1/g; 273 (my $abbrev = $command) =~ s/(\S)[^[:space:]_]*[[:space:]_]+/$1/g;
270 274
271 push @{$self->{command}}, [$abbrev, $command]; 275 push @{$self->{command}}, [$abbrev, $command, $tooltip, $widget, $cb];
272 #warn "$command|$abbrev|$widget\n";#d#
273} 276}
274 277
275package CFClient::MapWidget::Command; 278package CFClient::MapWidget::Command;
276 279
277use strict; 280use strict;
285 288
286 my $self = $class->SUPER::new ( 289 my $self = $class->SUPER::new (
287 @_, 290 @_,
288 children => [map 291 children => [map
289 CFClient::UI::Label->new ( 292 CFClient::UI::Label->new (
290 can_hover => 1, 293 can_hover => 1,
294 can_events => 1,
291 fontsize => $_, 295 fontsize => $_,
292 ), 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
293 ], 297 ],
294 ); 298 );
295 299
296 $self 300 $self
324 328
325 $self->{children}[0]->set_text ("$self->{search}_"); 329 $self->{children}[0]->set_text ("$self->{search}_");
326 330
327 for (0..5) { 331 for (0..5) {
328 $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] : "");
329 } 334 }
330 335
331 $self->{select} = $found[0][1][1] 336 $self->{select} = $found[0][1]
332 if @found; 337 if @found;
333 338
334 if (@found > 6) { 339 if (@found > 6) {
335 $self->{children}[6]->set_text ("..."); 340 $self->{children}[6]->set_text ("...");
336 } 341 }
349 $self->emit (execute => $self->{select}); 354 $self->emit (execute => $self->{select});
350 $self->emit ("close"); 355 $self->emit ("close");
351 } 356 }
352 } elsif ($ev->{sym} == 27) { 357 } elsif ($ev->{sym} == 27) {
353 $self->emit ("close"); 358 $self->emit ("close");
354 } elsif ($ev->{unicode}) { 359 } elsif ((chr $ev->{unicode}) =~ /^[[:alpha:]]$/) {
355 $self->{search} .= chr $ev->{unicode}; 360 $self->{search} .= chr $ev->{unicode};
356 $self->update_labels; 361 $self->update_labels;
357 } 362 }
363
364 length $self->{search}
365 or $self->emit ("close");
358} 366}
359 367
3601 3681

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines