ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/help.ext
(Generate patch)

Comparing deliantra/server/ext/help.ext (file contents):
Revision 1.4 by root, Thu Apr 19 21:54:41 2007 UTC vs.
Revision 1.12 by root, Fri Apr 11 01:15:49 2008 UTC

1#! perl 1#! perl
2 2
3our $TOPIC; 3our $TOPIC;
4
5our $HELP_CHANNEL = {
6 id => "help",
7 title => "Help",
8 reply => "help ",
9 tooltip => "Online Help",
10};
4 11
5sub load_topics($$) { 12sub load_topics($$) {
6 my ($type, $path) = @_; 13 my ($type, $path) = @_;
7 14
8 my $paragraphs = cf::pod::load_pod "$PODDIR/$path.pod" 15 my $paragraphs = cf::pod::load_pod "$PODDIR/$path.pod"
10 17
11 my @topics; 18 my @topics;
12 my $level = 1e9; 19 my $level = 1e9;
13 20
14 for my $par (@$paragraphs) { 21 for my $par (@$paragraphs) {
15 Coro::cede; 22 cf::cede_to_tick;
16 if ($par->{type} eq "head2") { 23 if ($par->{type} eq "head2") {
17 if ($par->{markup} =~ /^(\S+)/) { 24 if ($par->{markup} =~ /^(\S+)/) {
18 push @topics, $1 => [$type => $par]; 25 push @topics, $1 => [$type => $par];
19 $level = $par->{level}; 26 $level = $par->{level};
20 } 27 }
36} 43}
37 44
38cf::sync_job { 45cf::sync_job {
39 my $guard = cf::lock_acquire "ext::help::loading"; 46 my $guard = cf::lock_acquire "ext::help::loading";
40 cf::async_ext { 47 cf::async_ext {
48 $Coro::current->{desc} = "help loader";
41 reload; 49 reload;
42 undef $guard; 50 undef $guard;
43 }; 51 };
44}; 52};
45 53
54# for lack of a better place: "media tags"
55# b bold
56# i italic
57# ul underlined
58# fixed font
59# arcane font
60# hand font
61# strange font
62# print font (default)
63# color=xxx
64
46cf::register_command help => sub { 65cf::register_command help => sub {
47 my ($pl, $topic) = @_; 66 my ($pl, $topic) = @_;
48 67
49 if (cf::lock_active "ext::help::loading") { 68 if (cf::lock_active "ext::help::loading") {
50 $pl->reply (undef, "help files are being loaded currently, try again in a few seconds."); 69 $pl->send_msg ($HELP_CHANNEL => "help files are being loaded currently, try again in a few seconds.", cf::NDI_REPLY | cf::NDI_CLEAR);
51 return; 70 return;
52 } 71 }
53 72
54 $topic = $1 if $topic =~ /(\S+)/; 73 $topic = $1 if $topic =~ /(\S+)/;
55 74
61 push @{$topics{$v->[0]}}, $k; 80 push @{$topics{$v->[0]}}, $k;
62 } 81 }
63 82
64 my $res; 83 my $res;
65 while (my ($k, $v) = each %topics) { 84 while (my ($k, $v) = each %topics) {
66 $res .= "[b]$k:[/b]\n" . (sort join " ", @$v) . "\n\n"; 85 $res .= "B<$k:>\n" . (join " ", sort @$v) . "\n\n";
67 } 86 }
68 87
69 $pl->reply (undef, $res); 88 $pl->send_msg ($HELP_CHANNEL => $res, cf::NDI_REPLY | cf::NDI_CLEAR);
70 89
71 } elsif (my $topic = $TOPIC->{$topic}) { 90 } elsif (my $item = $TOPIC->{$topic}) {
72 my ($type, @pars) = @$topic; 91 my ($type, @pars) = @$item;
73 $pl->reply (undef, cf::pod::as_text \@pars); 92 $pl->send_msg ($HELP_CHANNEL => (cf::pod::as_cfpod \@pars), cf::NDI_REPLY | cf::NDI_CLEAR);
74 93
75 } else { 94 } else {
76 $pl->reply (undef, "'$topic' no such help topic, try just 'help' to get a list of topics."); 95 $pl->send_msg ($HELP_CHANNEL => "'$topic' no such help topic, try just 'help' to get a list of topics.", cf::NDI_REPLY);
77 } 96 }
78}; 97};
79 98

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines