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.114 by root, Mon Jul 23 23:52:41 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
183 178
184 $x -= CFPlus::floor $::MAP->w * 0.5; 179 $x -= CFPlus::floor $::MAP->w * 0.5;
185 $y -= CFPlus::floor $::MAP->h * 0.5; 180 $y -= CFPlus::floor $::MAP->h * 0.5;
186 181
187 if ($::CONN) { 182 if ($::CONN) {
188 if ($::IN_BUILD_MODE) {
189 $::CONN->buildat ($::IN_BUILD_MODE, $x, $y);
190 } else {
191 $::CONN->lookat ($x, $y) 183 $::CONN->lookat ($x, $y)
192 }
193 } 184 }
194 185
195 } elsif ($ev->{button} == 2) { 186 } elsif ($ev->{button} == 2) {
196 $self->grab_focus; 187 $self->grab_focus;
197 return unless $::CONN; 188 return unless $::CONN;
329 my $sym = $ev->{sym}; 320 my $sym = $ev->{sym};
330 my $uni = $ev->{unicode}; 321 my $uni = $ev->{unicode};
331 322
332 $mod &= CFPlus::KMOD_CTRL | CFPlus::KMOD_ALT | CFPlus::KMOD_SHIFT; 323 $mod &= CFPlus::KMOD_CTRL | CFPlus::KMOD_ALT | CFPlus::KMOD_SHIFT;
333 324
334 if ($sym == 9) {
335 ($mod & CFPlus::KMOD_SHIFT ? $::MESSAGE_WINDOW : $::PL_WINDOW)->toggle_visibility;
336 } elsif ($sym == CFPlus::SDLK_F1 && !$mod) {
337 $::HELP_WINDOW->toggle_visibility;
338 } elsif ($sym == CFPlus::SDLK_F2 && !$mod) {
339 ::toggle_player_page ($::STATS_PAGE);
340 } elsif ($sym == CFPlus::SDLK_F3 && !$mod) {
341 ::toggle_player_page ($::SKILL_PAGE);
342 } elsif ($sym == CFPlus::SDLK_F4 && !$mod) {
343 ::toggle_player_page ($::SPELL_PAGE);
344 } elsif ($sym == CFPlus::SDLK_F5 && !$mod) {
345 ::toggle_player_page ($::INVENTORY_PAGE);
346 } elsif ($sym == CFPlus::SDLK_F9 && !$mod) {
347 $::SETUP_DIALOG->toggle_visibility;
348 } elsif (!$::CONN) {
349 return 0; # bindings further down need a valid connection
350
351 } elsif ($uni == ord ",") {
352 $::CONN->user_send ("take");
353 } elsif ($uni == ord " ") {
354 $::CONN->user_send ("apply");
355 } elsif ($uni == 13) {
356 $::CONN->user_send ("examine");
357 } elsif ($uni == ord ".") {
358 $::CONN->user_send ($self->{completer}{last_command})
359 if exists $self->{completer}{last_command};
360 } elsif (my @macros = CFPlus::Macro::match_event $ev) {
361 $::CONN->macro_send ($_) for @macros;
362 } elsif (($sym == CFPlus::SDLK_KP_PLUS && !$mod) || $uni == ord "+") {
363 $::CONN->user_send ("rotateshoottype +");
364 } elsif (($sym == CFPlus::SDLK_KP_MINUS && !$mod) || $uni == ord "-") {
365 $::CONN->user_send ("rotateshoottype -");
366 } elsif ($uni == ord '!') {
367 $self->{completer}->set_prefix ("shout ");
368 $self->{completer}->show;
369 } elsif ($uni == ord '"') {
370 $self->{completer}->set_prefix ("$::CFG->{say_command} ");
371 $self->{completer}->show;
372 } elsif ($uni == ord "'") {
373 $self->{completer}->set_prefix ("");
374 $self->{completer}->show;
375 } elsif (my $dir = $DIR{(!!($mod & CFPlus::KMOD_ALT)) . ",$sym"}) { 325 if ($::CONN && (my $dir = $DIR{(!!($mod & CFPlus::KMOD_ALT)) . ",$sym"})) {
376 if ($mod & CFPlus::KMOD_SHIFT) { 326 if ($mod & CFPlus::KMOD_SHIFT) {
377 $self->{shft}++; 327 $self->{shft}++;
378 if ($dir->[0] != $self->{fire_dir}) { 328 if ($dir->[0] != $self->{fire_dir}) {
379 $::CONN->user_send ("fire $dir->[0]"); 329 $::CONN->user_send ("fire $dir->[0]");
380 } 330 }
383 $self->{ctrl}++; 333 $self->{ctrl}++;
384 $::CONN->user_send ("run $dir->[0]"); 334 $::CONN->user_send ("run $dir->[0]");
385 } else { 335 } else {
386 $::CONN->user_send ("$dir->[1]"); 336 $::CONN->user_send ("$dir->[1]");
387 } 337 }
388 } elsif ((ord 'a') <= $uni && $uni <= (ord 'z')) { 338
389 $self->{completer}->inject_key_down ($ev);
390 $self->{completer}->show;
391 } else {
392 return 0; 339 return 1;
393 }
394
395 1 340 }
341
342 0
396} 343}
397 344
398sub invoke_key_up { 345sub invoke_key_up {
399 my ($self, $ev) = @_; 346 my ($self, $ev) = @_;
400 347
448} 395}
449 396
450sub refresh_hook { 397sub refresh_hook {
451 my ($self) = @_; 398 my ($self) = @_;
452 399
453 if ($::MAP) { 400 if ($::MAP && $::CONN) {
454 if (delete $self->{need_update}) { 401 if (delete $self->{need_update}) {
455 my $tilesize = $self->{ctilesize} = (int $self->{tilesize} * $::CFG->{map_scale}) || 1; 402 my $tilesize = $self->{ctilesize} = (int $self->{tilesize} * $::CFG->{map_scale}) || 1;
456 403
457 my $sw = $self->{sw} = 1 + CFPlus::ceil $self->{w} / $tilesize; 404 my $sw = $self->{sw} = 1 + CFPlus::ceil $self->{w} / $tilesize;
458 my $sh = $self->{sh} = 1 + CFPlus::ceil $self->{h} / $tilesize; 405 my $sh = $self->{sh} = 1 + CFPlus::ceil $self->{h} / $tilesize;
528 $self->{root}->on_post_alloc (prepare => sub { $self->refresh_hook }); 475 $self->{root}->on_post_alloc (prepare => sub { $self->refresh_hook });
529 476
530 return unless $self->{list}; 477 return unless $self->{list};
531 478
532 my $focused = $CFPlus::UI::FOCUS == $self 479 my $focused = $CFPlus::UI::FOCUS == $self
533 || $CFPlus::UI::FOCUS == $self->{completer}{entry}; 480 || $CFPlus::UI::FOCUS == $::COMPLETER->{entry};
534 481
535 return 482 return
536 unless $focused || !$::FAST; 483 unless $focused || !$::FAST;
537 484
538 glCallList $self->{list}; 485 glCallList $self->{list};
539 486
540 # TNT2 emulates logops in software (or worse :) 487 # TNT2 emulates logops in software (or worse :)
541 unless ($focused) { 488 unless ($focused) {
542 glColor 0.4, 0.2, 0.2, 0.6; 489 glColor_premultiply 0, 0, 1, 0.25;
543 glEnable GL_BLEND; 490 glEnable GL_BLEND;
544 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; 491 glBlendFunc GL_ONE, GL_ONE_MINUS_SRC_ALPHA;
545 glBegin GL_QUADS; 492 glBegin GL_QUADS;
546 glVertex 0, 0; 493 glVertex 0, 0;
547 glVertex 0, $::HEIGHT; 494 glVertex 0, $::HEIGHT;
548 glVertex $::WIDTH, $::HEIGHT; 495 glVertex $::WIDTH, $::HEIGHT;
549 glVertex $::WIDTH, 0; 496 glVertex $::WIDTH, 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines