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.11 by root, Mon Apr 24 03:33:51 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 },
262 $::CONN->user_send ("run_stop"); 265 $::CONN->user_send ("run_stop");
263 } 266 }
264} 267}
265 268
266sub add_command { 269sub add_command {
267 my ($self, $command, $widget, $cb) = @_; 270 my ($self, $command, $tooltip, $widget, $cb) = @_;
268 271
269 (my $abbrev = $command) =~ s/(\S)[^[:space:]_]*[[:space:]_]+/$1/g; 272 (my $abbrev = $command) =~ s/(\S)[^[:space:]_]*[[:space:]_]+/$1/g;
270 273
271 push @{$self->{command}}, [$abbrev, $command]; 274 push @{$self->{command}}, [$abbrev, $command, $tooltip, $widget, $cb];
272 #warn "$command|$abbrev|$widget\n";#d#
273} 275}
274 276
275package CFClient::MapWidget::Command; 277package CFClient::MapWidget::Command;
276 278
277use strict; 279use strict;
285 287
286 my $self = $class->SUPER::new ( 288 my $self = $class->SUPER::new (
287 @_, 289 @_,
288 children => [map 290 children => [map
289 CFClient::UI::Label->new ( 291 CFClient::UI::Label->new (
290 can_hover => 1, 292 can_hover => 1,
293 can_events => 1,
291 fontsize => $_, 294 fontsize => $_,
292 ), 1, 1, 0.8, 0.8, 0.8, 0.8, 0.8 295 ), 1, 1, 0.8, 0.8, 0.8, 0.8, 0.8
293 ], 296 ],
294 ); 297 );
295 298
296 $self 299 $self
324 327
325 $self->{children}[0]->set_text ("$self->{search}_"); 328 $self->{children}[0]->set_text ("$self->{search}_");
326 329
327 for (0..5) { 330 for (0..5) {
328 $self->{children}[$_ + 1]->set_text ($found[$_] ? "$found[$_][0] ($found[$_][1][1])" : ""); 331 $self->{children}[$_ + 1]->set_text ($found[$_] ? "$found[$_][0] ($found[$_][1][1])" : "");
332 $self->{children}[$_ + 1]{tooltip} = ($found[$_] ? $found[$_][1][2] : "");
329 } 333 }
330 334
331 $self->{select} = $found[0][1][1] 335 $self->{select} = $found[0][1]
332 if @found; 336 if @found;
333 337
334 if (@found > 6) { 338 if (@found > 6) {
335 $self->{children}[6]->set_text ("..."); 339 $self->{children}[6]->set_text ("...");
336 } 340 }
349 $self->emit (execute => $self->{select}); 353 $self->emit (execute => $self->{select});
350 $self->emit ("close"); 354 $self->emit ("close");
351 } 355 }
352 } elsif ($ev->{sym} == 27) { 356 } elsif ($ev->{sym} == 27) {
353 $self->emit ("close"); 357 $self->emit ("close");
354 } elsif ($ev->{unicode}) { 358 } elsif ((chr $ev->{unicode}) =~ /^[[:alpha:]]$/) {
355 $self->{search} .= chr $ev->{unicode}; 359 $self->{search} .= chr $ev->{unicode};
356 $self->update_labels; 360 $self->update_labels;
357 } 361 }
362
363 length $self->{search}
364 or $self->emit ("close");
358} 365}
359 366
3601 3671

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines