… | |
… | |
3 | use utf8; |
3 | use utf8; |
4 | use strict; |
4 | use strict; |
5 | |
5 | |
6 | use Crossfire::Protocol::Constants; |
6 | use Crossfire::Protocol::Constants; |
7 | |
7 | |
|
|
8 | use CFClient; |
8 | use CFClient::UI; |
9 | use CFClient::UI; |
9 | |
10 | |
10 | use base 'Crossfire::Protocol::Base'; |
11 | use base 'Crossfire::Protocol::Base'; |
11 | |
12 | |
12 | sub new { |
13 | sub new { |
… | |
… | |
14 | |
15 | |
15 | my $self = $class->SUPER::new (@_); |
16 | my $self = $class->SUPER::new (@_); |
16 | |
17 | |
17 | $self->{map_widget}->clr_commands; |
18 | $self->{map_widget}->clr_commands; |
18 | |
19 | |
19 | my $parser = new Pod::POM; |
20 | my $cmd_help = CFClient::load_pod CFClient::find_rcfile "pod/command_help.pod", command_help => 1, sub { |
20 | my $pod = $parser->parse_file (CFClient::find_rcfile "pod/command_help.pod"); |
21 | my ($pom) = @_; |
21 | |
22 | |
|
|
23 | my @cmd_help; |
|
|
24 | |
22 | for my $head2 ($pod->head1->[-2]->head2) { |
25 | for my $head2 ($pom->head1->[-2]->head2) { |
23 | $head2->title =~ /^(\S+) (?:\s+ \( ([^\)]*) \) )?/x |
26 | $head2->title =~ /^(\S+) (?:\s+ \( ([^\)]*) \) )?/x |
24 | or next; |
27 | or next; |
25 | |
28 | |
26 | my $cmd = $1; |
29 | my $cmd = $1; |
27 | my @args = split /\|/, $2; |
30 | my @args = split /\|/, $2; |
28 | @args = (".*") unless @args; |
31 | @args = (".*") unless @args; |
29 | |
32 | |
30 | $_ = $_ eq ".*" ? "" : " $_" |
33 | $_ = $_ eq ".*" ? "" : " $_" |
31 | for @args; |
34 | for @args; |
32 | |
35 | |
33 | my $text = CFClient::pod_to_pango $head2->content; |
36 | my $text = CFClient::pod_to_pango $head2->content; |
34 | |
37 | |
35 | $self->{map_widget}->add_command ("$cmd$_", $text) |
38 | push @cmd_help, ["$cmd$_", $text] |
36 | for sort { (length $a) <=> (length $b) } |
39 | for sort { (length $a) <=> (length $b) } |
37 | @args; |
40 | @args; |
|
|
41 | } |
|
|
42 | |
|
|
43 | \@cmd_help |
38 | } |
44 | }; |
|
|
45 | |
|
|
46 | $self->{map_widget}->add_command (@$_) |
|
|
47 | for @$cmd_help; |
39 | |
48 | |
40 | $self->{noface} = new_from_file CFClient::Texture |
49 | $self->{noface} = new_from_file CFClient::Texture |
41 | CFClient::find_rcfile "noface.png", minify => 1, mipmap => 1; |
50 | CFClient::find_rcfile "noface.png", minify => 1, mipmap => 1; |
42 | |
51 | |
43 | $self->{open_container} = 0; |
52 | $self->{open_container} = 0; |
… | |
… | |
459 | } |
468 | } |
460 | |
469 | |
461 | sub addme_success { |
470 | sub addme_success { |
462 | my ($self) = @_; |
471 | my ($self) = @_; |
463 | |
472 | |
464 | my $parser = new Pod::POM; |
473 | my $skill_help = CFClient::load_pod CFClient::find_rcfile "pod/skill_help.pod", skill_help => 1, sub { |
465 | my $pod = $parser->parse_file (CFClient::find_rcfile "pod/skill_help.pod"); |
474 | my ($pom) = @_; |
466 | |
475 | |
467 | my %skill_tooltip; |
476 | my %skill_help; |
468 | |
477 | |
469 | for my $head2 ($pod->head1->[-2]->head2) { |
478 | for my $head2 ($pom->head1->[3]->head2) { |
470 | $skill_tooltip{$head2->title} = CFClient::pod_to_pango $head2->content; |
479 | $skill_help{$head2->title} = CFClient::pod_to_pango $head2->content; |
|
|
480 | } |
|
|
481 | |
|
|
482 | \%skill_help |
471 | } |
483 | }; |
472 | |
484 | |
473 | for my $skill (values %{$self->{skill_info}}) { |
485 | for my $skill (values %{$self->{skill_info}}) { |
474 | $self->{map_widget}->add_command ("ready_skill $skill", |
486 | $self->{map_widget}->add_command ("ready_skill $skill", |
475 | (CFClient::UI::Label::escape "Ready the skill '$skill'\n\n") |
487 | (CFClient::UI::Label::escape "Ready the skill '$skill'\n\n") |
476 | . $skill_tooltip{$skill}); |
488 | . $skill_help->{$skill}); |
477 | $self->{map_widget}->add_command ("use_skill $skill", |
489 | $self->{map_widget}->add_command ("use_skill $skill", |
478 | (CFClient::UI::Label::escape "Immediately use the skill '$skill'\n\n") |
490 | (CFClient::UI::Label::escape "Immediately use the skill '$skill'\n\n") |
479 | . $skill_tooltip{$skill}); |
491 | . $skill_help->{$skill}); |
480 | } |
492 | } |
481 | } |
493 | } |
482 | |
494 | |
483 | sub eof { |
495 | sub eof { |
484 | my ($self) = @_; |
496 | my ($self) = @_; |