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.116 by root, Mon Aug 6 05:06:33 2007 UTC vs.
Revision 1.121 by root, Tue Aug 28 16:26:13 2007 UTC

24 can_focus => 1, 24 can_focus => 1,
25 tilesize => 32, 25 tilesize => 32,
26 @_ 26 @_
27 ); 27 );
28 28
29 $self->{completer} = new CFPlus::MapWidget::Command::
30 command => $self->{command},
31 tooltip => "#completer_help",
32 ;
33
34 $self 29 $self
35} 30}
36 31
37sub set_tilesize { 32sub set_tilesize {
38 my ($self, $tilesize) = @_; 33 my ($self, $tilesize) = @_;
47 42
48 $tooltip =~ s/^\s+//; 43 $tooltip =~ s/^\s+//;
49 $tooltip = "<big>$data</big>\n\n$tooltip"; 44 $tooltip = "<big>$data</big>\n\n$tooltip";
50 $tooltip =~ s/\s+$//; 45 $tooltip =~ s/\s+$//;
51 46
52 $self->{completer}{command}{$command} = [$data, $tooltip, $widget, $cb, ++$self->{command_id}]; 47 $::COMPLETER->{command}{$command} = [$data, $tooltip, $widget, $cb, ++$self->{command_id}];
53} 48}
54 49
55sub clr_commands { 50sub clr_commands {
56 my ($self) = @_; 51 my ($self) = @_;
57 52
58 %{$self->{completer}{command}} = (); 53 %{$::COMPLETER->{command}} = ();
59 54
60 $self->{completer}->hide 55 $::COMPLETER->hide
61 if $self->{completer}; 56 if $::COMPLETER;
62} 57}
63 58
64sub server_login { 59sub server_login {
65 my ($server) = @_; 60 my ($server) = @_;
66 61
325 my $sym = $ev->{sym}; 320 my $sym = $ev->{sym};
326 my $uni = $ev->{unicode}; 321 my $uni = $ev->{unicode};
327 322
328 $mod &= CFPlus::KMOD_CTRL | CFPlus::KMOD_ALT | CFPlus::KMOD_SHIFT; 323 $mod &= CFPlus::KMOD_CTRL | CFPlus::KMOD_ALT | CFPlus::KMOD_SHIFT;
329 324
330 if ($sym == 9) {
331 ($mod & CFPlus::KMOD_SHIFT ? $::MESSAGE_WINDOW : $::PL_WINDOW)->toggle_visibility;
332 } elsif ($sym == CFPlus::SDLK_F1 && !$mod) {
333 $::HELP_WINDOW->toggle_visibility;
334 } elsif ($sym == CFPlus::SDLK_F2 && !$mod) {
335 ::toggle_player_page ($::STATS_PAGE);
336 } elsif ($sym == CFPlus::SDLK_F3 && !$mod) {
337 ::toggle_player_page ($::SKILL_PAGE);
338 } elsif ($sym == CFPlus::SDLK_F4 && !$mod) {
339 ::toggle_player_page ($::SPELL_PAGE);
340 } elsif ($sym == CFPlus::SDLK_F5 && !$mod) {
341 ::toggle_player_page ($::INVENTORY_PAGE);
342 } elsif ($sym == CFPlus::SDLK_F9 && !$mod) {
343 $::SETUP_DIALOG->toggle_visibility;
344 } elsif (!$::CONN) {
345 return 0; # bindings further down need a valid connection
346
347 } elsif ($uni == ord ",") {
348 $::CONN->user_send ("take");
349 } elsif ($uni == ord " ") {
350 $::CONN->user_send ("apply");
351 } elsif ($uni == 13) {
352 $::CONN->user_send ("examine");
353 } elsif ($uni == ord ".") {
354 $::CONN->user_send ($self->{completer}{last_command})
355 if exists $self->{completer}{last_command};
356 } elsif (my @macros = CFPlus::Macro::match_event $ev) {
357 $::CONN->macro_send ($_) for @macros;
358 } elsif (($sym == CFPlus::SDLK_KP_PLUS && !$mod) || $uni == ord "+") {
359 $::CONN->user_send ("rotateshoottype +");
360 } elsif (($sym == CFPlus::SDLK_KP_MINUS && !$mod) || $uni == ord "-") {
361 $::CONN->user_send ("rotateshoottype -");
362 } elsif ($uni == ord '!') {
363 $self->{completer}->set_prefix ("shout ");
364 $self->{completer}->show;
365 } elsif ($uni == ord '"') {
366 $self->{completer}->set_prefix ("$::CFG->{say_command} ");
367 $self->{completer}->show;
368 } elsif ($uni == ord "'") {
369 $self->{completer}->set_prefix ("");
370 $self->{completer}->show;
371 } elsif (my $dir = $DIR{(!!($mod & CFPlus::KMOD_ALT)) . ",$sym"}) { 325 if ($::CONN && (my $dir = $DIR{(!!($mod & CFPlus::KMOD_ALT)) . ",$sym"})) {
372 if ($mod & CFPlus::KMOD_SHIFT) { 326 if ($mod & CFPlus::KMOD_SHIFT) {
373 $self->{shft}++; 327 $self->{shft}++;
374 if ($dir->[0] != $self->{fire_dir}) { 328 if ($dir->[0] != $self->{fire_dir}) {
375 $::CONN->user_send ("fire $dir->[0]"); 329 $::CONN->user_send ("fire $dir->[0]");
376 } 330 }
379 $self->{ctrl}++; 333 $self->{ctrl}++;
380 $::CONN->user_send ("run $dir->[0]"); 334 $::CONN->user_send ("run $dir->[0]");
381 } else { 335 } else {
382 $::CONN->user_send ("$dir->[1]"); 336 $::CONN->user_send ("$dir->[1]");
383 } 337 }
384 } elsif ((ord 'a') <= $uni && $uni <= (ord 'z')) { 338
385 $self->{completer}->inject_key_down ($ev);
386 $self->{completer}->show;
387 } else {
388 return 0; 339 return 1;
389 }
390
391 1 340 }
341
342 0
392} 343}
393 344
394sub invoke_key_up { 345sub invoke_key_up {
395 my ($self, $ev) = @_; 346 my ($self, $ev) = @_;
396 347
479 430
480 glPushMatrix; 431 glPushMatrix;
481 glTranslate $sx0, $sy0; 432 glTranslate $sx0, $sy0;
482 glScale $::CFG->{map_scale}, $::CFG->{map_scale}; 433 glScale $::CFG->{map_scale}, $::CFG->{map_scale};
483 434
484 my $missing = $::MAP->draw ($dx, $dy, $sw, $sh, $self->{tilesize}); 435 $::MAP->draw ($dx, $dy, $sw, $sh, $self->{tilesize});
485 436
486 glScale $self->{tilesize}, $self->{tilesize}; 437 glScale $self->{tilesize}, $self->{tilesize};
487 438
488 if (my $tex = $self->{fow_texture}) { 439 if (my $tex = $self->{fow_texture}) {
489 glPushMatrix; 440 glPushMatrix;
509 $::MAP->draw_magicmap ($x, $y, $w, $h, $data); 460 $::MAP->draw_magicmap ($x, $y, $w, $h, $data);
510 } 461 }
511 462
512 glPopMatrix; 463 glPopMatrix;
513 glEndList; 464 glEndList;
514
515 for my $tile (@$missing) {
516 $tile = $::CONN->{texture}[$tile]
517 or next;
518 next if $tile->{loading};
519 $tile->upload;
520 }
521 } 465 }
522 } else { 466 } else {
523 glDeleteList delete $self->{list} 467 glDeleteList delete $self->{list}
524 if $self->{list}; 468 if $self->{list};
525 } 469 }
531 $self->{root}->on_post_alloc (prepare => sub { $self->refresh_hook }); 475 $self->{root}->on_post_alloc (prepare => sub { $self->refresh_hook });
532 476
533 return unless $self->{list}; 477 return unless $self->{list};
534 478
535 my $focused = $CFPlus::UI::FOCUS == $self 479 my $focused = $CFPlus::UI::FOCUS == $self
536 || $CFPlus::UI::FOCUS == $self->{completer}{entry}; 480 || $CFPlus::UI::FOCUS == $::COMPLETER->{entry};
537 481
538 return 482 return
539 unless $focused || !$::FAST; 483 unless $focused || !$::FAST;
540 484
541 glCallList $self->{list}; 485 glCallList $self->{list};
542 486
543 # TNT2 emulates logops in software (or worse :) 487 # TNT2 emulates logops in software (or worse :)
544 unless ($focused) { 488 unless ($focused) {
545 glColor 0.4, 0.2, 0.2, 0.6; 489 glColor_premultiply 0, 0, 1, 0.25;
546 glEnable GL_BLEND; 490 glEnable GL_BLEND;
547 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; 491 glBlendFunc GL_ONE, GL_ONE_MINUS_SRC_ALPHA;
548 glBegin GL_QUADS; 492 glBegin GL_QUADS;
549 glVertex 0, 0; 493 glVertex 0, 0;
550 glVertex 0, $::HEIGHT; 494 glVertex 0, $::HEIGHT;
551 glVertex $::WIDTH, $::HEIGHT; 495 glVertex $::WIDTH, $::HEIGHT;
552 glVertex $::WIDTH, 0; 496 glVertex $::WIDTH, 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines