… | |
… | |
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 | |
37 | sub set_tilesize { |
32 | sub 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 | |
55 | sub clr_commands { |
50 | sub 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 | |
64 | sub server_login { |
59 | sub server_login { |
65 | my ($server) = @_; |
60 | my ($server) = @_; |
66 | |
61 | |
… | |
… | |
77 | print "preparing editor startup...\n"; |
72 | print "preparing editor startup...\n"; |
78 | |
73 | |
79 | my $server = $editsup->{gameserver} || "default"; |
74 | my $server = $editsup->{gameserver} || "default"; |
80 | $server =~ s/([^a-zA-Z0-9_\-])/sprintf "=%x=", ord $1/ge; |
75 | $server =~ s/([^a-zA-Z0-9_\-])/sprintf "=%x=", ord $1/ge; |
81 | |
76 | |
82 | local $ENV{CROSSFIRE_MAPDIR} = my $mapdir = "$Crossfire::VARDIR/map.$server"; mkdir $mapdir; |
77 | local $ENV{CROSSFIRE_MAPDIR} = my $mapdir = "$Deliantra::VARDIR/map.$server"; mkdir $mapdir; |
83 | local $ENV{CROSSFIRE_LIBDIR} = my $libdir = "$Crossfire::VARDIR/lib.$server"; mkdir $libdir; |
78 | local $ENV{CROSSFIRE_LIBDIR} = my $libdir = "$Deliantra::VARDIR/lib.$server"; mkdir $libdir; |
84 | |
79 | |
85 | print "map directory is $mapdir\n"; |
80 | print "map directory is $mapdir\n"; |
86 | print "lib directory is $libdir\n"; |
81 | print "lib directory is $libdir\n"; |
87 | |
82 | |
88 | my $ua = CFPlus::lwp_useragent; |
83 | my $ua = CFPlus::lwp_useragent; |
… | |
… | |
125 | require File::Path; |
120 | require File::Path; |
126 | |
121 | |
127 | File::Path::mkpath (File::Basename::dirname ($mappath)); |
122 | File::Path::mkpath (File::Basename::dirname ($mappath)); |
128 | open my $fh, ">:raw:perlio", "$mappath.meta" |
123 | open my $fh, ">:raw:perlio", "$mappath.meta" |
129 | or die "$mappath.meta: $!\n"; |
124 | or die "$mappath.meta: $!\n"; |
130 | print $fh CFPlus::to_json $meta; |
125 | print $fh CFPlus::encode_json $meta; |
131 | close $fh; |
126 | close $fh; |
132 | open my $fh, ">:raw:perlio:utf8", $mappath |
127 | open my $fh, ">:raw:perlio:utf8", $mappath |
133 | or die "$mappath: $!\n"; |
128 | or die "$mappath: $!\n"; |
134 | print $fh $map; |
129 | print $fh $map; |
135 | close $fh; |
130 | close $fh; |
… | |
… | |
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 ($uni >= ord "0" && $uni <= ord "9" && $mod & CFPlus::KMOD_ALT) { |
|
|
345 | $::MESSAGE_WINDOW->user_switch_to_page (chr $uni); |
|
|
346 | } elsif (!$::CONN) { |
|
|
347 | return 0; # bindings further down need a valid connection |
|
|
348 | |
|
|
349 | } elsif ($uni == ord ",") { |
|
|
350 | $::CONN->user_send ("take"); |
|
|
351 | } elsif ($uni == ord " ") { |
|
|
352 | $::CONN->user_send ("apply"); |
|
|
353 | } elsif ($uni == 13) { |
|
|
354 | $::MESSAGE_WINDOW->activate_current; |
|
|
355 | } elsif ($uni == ord ".") { |
|
|
356 | $::CONN->user_send ($self->{completer}{last_command}) |
|
|
357 | if exists $self->{completer}{last_command}; |
|
|
358 | } elsif (my @macros = CFPlus::Macro::match_event $ev) { |
|
|
359 | $::CONN->macro_send ($_) for @macros; |
|
|
360 | } elsif (($sym == CFPlus::SDLK_KP_PLUS && !$mod) || $uni == ord "+") { |
|
|
361 | $::CONN->user_send ("rotateshoottype +"); |
|
|
362 | } elsif (($sym == CFPlus::SDLK_KP_MINUS && !$mod) || $uni == ord "-") { |
|
|
363 | $::CONN->user_send ("rotateshoottype -"); |
|
|
364 | } elsif ($uni == ord '!') { |
|
|
365 | $self->{completer}->set_prefix ("shout "); |
|
|
366 | $self->{completer}->show; |
|
|
367 | } elsif ($uni == ord '"') { |
|
|
368 | $self->{completer}->set_prefix ("$::CFG->{say_command} "); |
|
|
369 | $self->{completer}->show; |
|
|
370 | } elsif ($uni == ord "'") { |
|
|
371 | $self->{completer}->set_prefix (""); |
|
|
372 | $self->{completer}->show; |
|
|
373 | } elsif (my $dir = $DIR{(!!($mod & CFPlus::KMOD_ALT)) . ",$sym"}) { |
325 | if ($::CONN && (my $dir = $DIR{(!!($mod & CFPlus::KMOD_ALT)) . ",$sym"})) { |
374 | if ($mod & CFPlus::KMOD_SHIFT) { |
326 | if ($mod & CFPlus::KMOD_SHIFT) { |
375 | $self->{shft}++; |
327 | $self->{shft}++; |
376 | if ($dir->[0] != $self->{fire_dir}) { |
328 | if ($dir->[0] != $self->{fire_dir}) { |
377 | $::CONN->user_send ("fire $dir->[0]"); |
329 | $::CONN->user_send ("fire $dir->[0]"); |
378 | } |
330 | } |
379 | $self->{fire_dir} = $DIR{$sym}[0]; |
331 | $self->{fire_dir} = $dir->[0]; |
380 | } elsif ($mod & CFPlus::KMOD_CTRL) { |
332 | } elsif ($mod & CFPlus::KMOD_CTRL) { |
381 | $self->{ctrl}++; |
333 | $self->{ctrl}++; |
382 | $::CONN->user_send ("run $dir->[0]"); |
334 | $::CONN->user_send ("run $dir->[0]"); |
383 | } else { |
335 | } else { |
384 | $::CONN->user_send ("$dir->[1]"); |
336 | $::CONN->user_send ("$dir->[1]"); |
385 | } |
337 | } |
386 | } elsif ((ord 'a') <= $uni && $uni <= (ord 'z')) { |
338 | |
387 | $self->{completer}->inject_key_down ($ev); |
|
|
388 | $self->{completer}->show; |
|
|
389 | } else { |
|
|
390 | return 0; |
339 | return 1; |
391 | } |
|
|
392 | |
|
|
393 | 1 |
340 | } |
|
|
341 | |
|
|
342 | 0 |
394 | } |
343 | } |
395 | |
344 | |
396 | sub invoke_key_up { |
345 | sub invoke_key_up { |
397 | my ($self, $ev) = @_; |
346 | my ($self, $ev) = @_; |
398 | |
347 | |
… | |
… | |
405 | $::CONN->user_send ("fire_stop"); |
354 | $::CONN->user_send ("fire_stop"); |
406 | delete $self->{fire_dir}; |
355 | delete $self->{fire_dir}; |
407 | $res = 1; |
356 | $res = 1; |
408 | } |
357 | } |
409 | } else { |
358 | } else { |
410 | if (exists $DIR{$sym} && delete $self->{shft}) { |
359 | if (exists $DIR{(!!($mod & CFPlus::KMOD_ALT)) . ",$sym"} && delete $self->{shft}) { |
411 | $::CONN->user_send ("fire_stop"); |
360 | $::CONN->user_send ("fire_stop"); |
412 | delete $self->{fire_dir}; |
361 | delete $self->{fire_dir}; |
413 | $res = 1; |
362 | $res = 1; |
414 | } elsif (($sym == CFPlus::SDLK_LSHIFT || $sym == CFPlus::SDLK_RSHIFT) && delete $self->{shft}) { # XXX: is RSHIFT ok? |
363 | } elsif (($sym == CFPlus::SDLK_LSHIFT || $sym == CFPlus::SDLK_RSHIFT) |
|
|
364 | && delete $self->{shft}) { # XXX: is RSHIFT ok? |
415 | $::CONN->user_send ("fire_stop"); |
365 | $::CONN->user_send ("fire_stop"); |
416 | delete $self->{fire_dir}; |
366 | delete $self->{fire_dir}; |
417 | $res = 1; |
367 | $res = 1; |
418 | } |
368 | } |
419 | } |
369 | } |
… | |
… | |
526 | $self->{root}->on_post_alloc (prepare => sub { $self->refresh_hook }); |
476 | $self->{root}->on_post_alloc (prepare => sub { $self->refresh_hook }); |
527 | |
477 | |
528 | return unless $self->{list}; |
478 | return unless $self->{list}; |
529 | |
479 | |
530 | my $focused = $CFPlus::UI::FOCUS == $self |
480 | my $focused = $CFPlus::UI::FOCUS == $self |
531 | || $CFPlus::UI::FOCUS == $self->{completer}{entry}; |
481 | || $CFPlus::UI::FOCUS == $::COMPLETER->{entry}; |
532 | |
482 | |
533 | return |
483 | return |
534 | unless $focused || !$::FAST; |
484 | unless $focused || !$::FAST; |
535 | |
485 | |
536 | glCallList $self->{list}; |
486 | glCallList $self->{list}; |
537 | |
487 | |
538 | # TNT2 emulates logops in software (or worse :) |
488 | # TNT2 emulates logops in software (or worse :) |
539 | unless ($focused) { |
489 | unless ($focused) { |
540 | glColor 0.4, 0.2, 0.2, 0.6; |
490 | glColor_premultiply 0, 0, 1, 0.25; |
541 | glEnable GL_BLEND; |
491 | glEnable GL_BLEND; |
542 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
492 | glBlendFunc GL_ONE, GL_ONE_MINUS_SRC_ALPHA; |
543 | glBegin GL_QUADS; |
493 | glBegin GL_QUADS; |
544 | glVertex 0, 0; |
494 | glVertex 0, 0; |
545 | glVertex 0, $::HEIGHT; |
495 | glVertex 0, $::HEIGHT; |
546 | glVertex $::WIDTH, $::HEIGHT; |
496 | glVertex $::WIDTH, $::HEIGHT; |
547 | glVertex $::WIDTH, 0; |
497 | glVertex $::WIDTH, 0; |