ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/Macro.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/Macro.pm (file contents):
Revision 1.16 by root, Wed Dec 26 21:03:21 2007 UTC vs.
Revision 1.22 by root, Sat Apr 3 02:58:24 2010 UTC

1package DC::Macro; 1package DC::Macro;
2 2
3use strict; 3use common::sense;
4 4
5use List::Util (); 5use List::Util ();
6use DC::UI; 6use DC::UI;
7 7
8our $REFRESH_MACRO_LIST; 8our $REFRESH_MACRO_LIST;
11 (map +("($_)" => "!completer $_"), "a" .. "z"), 11 (map +("($_)" => "!completer $_"), "a" .. "z"),
12 "(!)" => "!completer shout ", 12 "(!)" => "!completer shout ",
13 "(\")" => "!completer say ", 13 "(\")" => "!completer say ",
14 "(')" => "!completer", 14 "(')" => "!completer",
15 15
16 "LShift-tab" => "!toggle-messagewindow", 16# "LShift-tab" => "!toggle-messagewindow",
17 "RShift-tab" => "!toggle-messagewindow", 17# "RShift-tab" => "!toggle-messagewindow",
18 "tab" => "!toggle-playerbook", 18 "tab" => "!toggle-playerbook",
19 "f1" => "!toggle-help", 19 "f1" => "!toggle-help",
20 "f2" => "!toggle-stats", 20 "f2" => "!toggle-stats",
21 "f3" => "!toggle-skills", 21 "f3" => "!toggle-skills",
22 "f4" => "!toggle-spells", 22 "f4" => "!toggle-spells",
23 "f5" => "!toggle-inventory", 23 "f5" => "!toggle-inventory",
24 "f9" => "!toggle-setup", 24 "f9" => "!toggle-setup",
25
25 (map +("LAlt-$_" => "!switch-tab $_"), 0..9), 26 (map +("LRAM-$_" => "!switch-tab $_"), 0..9),
26 (map +("RAlt-$_" => "!switch-tab $_"), 0..9),
27 "LAlt-x" => "!close-current-tab", 27 "LRAM-x" => "!close-current-tab",
28
28 "return" => "!activate-chat", 29 "return" => "!activate-chat",
29 "." => "!repeat-command", 30 "." => "!repeat-command",
30 31
31 "," => "take", 32 "," => "take",
32 "space" => "apply", 33 "space" => "apply",
33 "enter" => "examine", 34 "enter" => "examine",
34 "[+]" => "rotateshoottype +", 35 "[+]" => "rotateshoottype +",
35 "[-]" => "rotateshoottype -", 36 "[-]" => "rotateshoottype -",
37
36 "LAlt-e" => "examine", 38 "LRAM-e" => "examine",
37 "LAlt-s" => "ready_skill find traps", 39 "LRAM-s" => "ready_skill find traps",
38 "LAlt-d" => "ready_skill disarm traps", 40 "LRAM-d" => "ready_skill disarm traps",
39 "LAlt-p" => "ready_skill praying", 41 "LRAM-p" => "ready_skill praying",
40); 42);
41 43
42# allowed modifiers 44# allowed modifiers
43our %MODIFIER = ( 45our %MODIFIER = (
44 "LShift" => DC::KMOD_LSHIFT, 46 "LShift" => DC::KMOD_LSHIFT,
107 109
108our $DEFAULT_KEYMAP; 110our $DEFAULT_KEYMAP;
109 111
110sub init { 112sub init {
111 $DEFAULT_KEYMAP ||= do { 113 $DEFAULT_KEYMAP ||= do {
114 local $MODIFIER{LRAM} = DC::KMOD_LRAM; # hack to enable internal LRAM modifer
115
112 my %sym = map +(DC::SDL_GetKeyName $_, $_), DC::SDLK_FIRST .. DC::SDLK_LAST; 116 my %sym = map +(DC::SDL_GetKeyName $_, $_), DC::SDLK_FIRST .. DC::SDLK_LAST;
113 my $map; 117 my $map;
114 118
115 while (my ($k, $v) = each %DEFAULT_KEYMAP) { 119 while (my ($k, $v) = each %DEFAULT_KEYMAP) {
116 if ($k =~ /^\((.)\)$/) { 120 if ($k =~ /^\((.)\)$/) {
434 $REFRESH_MACRO_LIST = $refresh = sub { 438 $REFRESH_MACRO_LIST = $refresh = sub {
435 $macrolist->clear; 439 $macrolist->clear;
436 440
437 $macrolist->add_at (0, 1, new DC::UI::Label 441 $macrolist->add_at (0, 1, new DC::UI::Label
438 text => "Trigger", 442 text => "Trigger",
443 tooltip => $tooltip_trigger . $tooltip_common,
444 );
445 $macrolist->add_at (1, 1, new DC::UI::Label
446 text => "Actions",
439 align => 0, 447 align => 0,
440 tooltip => $tooltip_trigger . $tooltip_common,
441 );
442 $macrolist->add_at (1, 1, new DC::UI::Label
443 text => "Commands",
444 tooltip => $tooltip_commands . $tooltip_common, 448 tooltip => $tooltip_commands . $tooltip_common,
445 ); 449 );
446 450
447 for my $idx (0 .. $#{$::PROFILE->{macro} || []}) { 451 for my $idx (0 .. $#{$::PROFILE->{macro} || []}) {
448 my $macro = $::PROFILE->{macro}[$idx]; 452 my $macro = $::PROFILE->{macro}[$idx];
452 my ($widget, $ev) = @_; 456 my ($widget, $ev) = @_;
453 457
454 if ($ev->{button} == 1) { 458 if ($ev->{button} == 1) {
455 $edit_macro->($macro), 459 $edit_macro->($macro),
456 } elsif ($ev->{button} == 2) { 460 } elsif ($ev->{button} == 2) {
457 $::CONN->macro_send ($macro) if $::CONN; 461 execute ($macro);
458 } elsif ($ev->{button} == 3) { 462 } elsif ($ev->{button} == 3) {
459 (new DC::UI::Menu 463 (new DC::UI::Menu
460 items => [ 464 items => [
461 ["Edit" => sub { $edit_macro->($macro) }], 465 ["Edit" => sub { $edit_macro->($macro) }],
462 ["Invoke" => sub { $::CONN->macro_send ($macro) if $::CONN }], 466 ["Invoke" => sub { execute ($macro) }],
463 ["Delete" => sub { 467 ["Delete" => sub {
464 # might want to use grep instead 468 # might want to use grep instead
465 splice @{$::PROFILE->{macro}}, $idx, 1, (); 469 splice @{$::PROFILE->{macro}}, $idx, 1, ();
466 $refresh->(); 470 $refresh->();
467 }], 471 }],
475 }; 479 };
476 480
477 $macrolist->add_at (0, $y, new DC::UI::Label 481 $macrolist->add_at (0, $y, new DC::UI::Label
478 text => trigger_to_string $macro, 482 text => trigger_to_string $macro,
479 tooltip => $tooltip_trigger . $tooltip_common, 483 tooltip => $tooltip_trigger . $tooltip_common,
480 align => 0, 484 fg => [1, 0.8, 0.8],
481 can_hover => 1, 485 can_hover => 1,
482 can_events => 1, 486 can_events => 1,
483 on_button_down => $macro_cb, 487 on_button_down => $macro_cb,
484 ); 488 );
485 489
486 $macrolist->add_at (1, $y, new DC::UI::Label 490 $macrolist->add_at (1, $y, new DC::UI::Label
487 text => (join "; ", @{ $macro->{action} || [] }), 491 text => (join "; ", @{ $macro->{action} || [] }),
488 tooltip => $tooltip_commands . $tooltip_common, 492 tooltip => $tooltip_commands . $tooltip_common,
493 fg => [0.9, 0.9, 0.9],
494 align => 0,
489 expand => 1, 495 expand => 1,
490 ellipsise => 3, 496 ellipsise => 3,
491 can_hover => 1, 497 can_hover => 1,
492 can_events => 1, 498 can_events => 1,
493 on_button_down => $macro_cb, 499 on_button_down => $macro_cb,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines