line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Livedoor::Wiki::Plugin::Function::Pad; |
2
|
11
|
|
|
11
|
|
66
|
use warnings; |
|
11
|
|
|
|
|
25
|
|
|
11
|
|
|
|
|
352
|
|
3
|
11
|
|
|
11
|
|
58
|
use strict; |
|
11
|
|
|
|
|
21
|
|
|
11
|
|
|
|
|
360
|
|
4
|
11
|
|
|
11
|
|
56
|
use base qw/Text::Livedoor::Wiki::Plugin::Function/; |
|
11
|
|
|
|
|
22
|
|
|
11
|
|
|
|
|
389
|
|
5
|
11
|
|
|
11
|
|
872
|
use Text::Livedoor::Wiki::Utils; |
|
11
|
|
|
|
|
128
|
|
|
11
|
|
|
|
|
259
|
|
6
|
|
|
|
|
|
|
|
7
|
11
|
|
|
11
|
|
1144
|
use Data::Dumper; |
|
11
|
|
|
|
|
5984
|
|
|
11
|
|
|
|
|
9134
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
__PACKAGE__->function_name('pad'); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub prepare_args { |
12
|
7
|
|
|
7
|
1
|
10
|
my $class = shift; |
13
|
7
|
|
|
|
|
9
|
my $args = shift; |
14
|
7
|
50
|
|
|
|
16
|
die 'no arg' unless scalar @$args; |
15
|
|
|
|
|
|
|
|
16
|
7
|
|
|
|
|
10
|
my $pad_type = $args->[0]; |
17
|
7
|
100
|
|
|
|
39
|
die 'invalid pad type.' unless $pad_type =~ /^(ps3)$/i; # you can add more pad types here such as DS, Xbox and PC |
18
|
|
|
|
|
|
|
|
19
|
6
|
|
|
|
|
24
|
return { pad_type => lc $pad_type }; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub process { |
23
|
6
|
|
|
6
|
1
|
10
|
my ( $class, $inline, $data ) = @_; |
24
|
6
|
|
|
|
|
9
|
my $pad_type = $data->{args}{pad_type}; |
25
|
6
|
|
|
|
|
11
|
my $input_str = $data->{value}; |
26
|
|
|
|
|
|
|
|
27
|
6
|
|
|
|
|
8
|
my $parser = '_' . $pad_type; # specifies parser function by pad type such as _ps3 for ps3 |
28
|
6
|
|
|
|
|
20
|
my @inputs = split /,/, $input_str; |
29
|
6
|
|
|
|
|
7
|
my $str; |
30
|
|
|
|
|
|
|
|
31
|
6
|
|
|
|
|
10
|
for my $input ( @inputs ) { |
32
|
15
|
100
|
|
|
|
52
|
$str .= $class->$parser( $input ) if $input; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
6
|
|
|
|
|
13
|
my $fixed_str = ''; |
36
|
6
|
|
|
|
|
35
|
return $fixed_str; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub _ps3 { |
40
|
14
|
|
|
14
|
|
18
|
my ( $class, $input ) = @_; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# for guys with bad typing |
43
|
14
|
100
|
|
|
|
63
|
$input = 'maru' if ( $input =~ /^(ma[lr]{1}u)$/ ); |
44
|
14
|
100
|
|
|
|
39
|
$input = 'sankaku' if ( $input =~ /^(san[ck]{1}a[ck]{1}[u]?)$/ ); |
45
|
14
|
100
|
|
|
|
33
|
$input = 'shikaku' if ( $input =~ /^(s[h]?ikak[u]?)$/ ); |
46
|
14
|
50
|
|
|
|
25
|
$input = 'batsu' if ( $input =~ /^(bat[s]?u)$/ ); |
47
|
14
|
50
|
|
|
|
23
|
$input = 'select' if ( $input =~ /^(se[lr]{1}ect)$/ ); |
48
|
14
|
50
|
|
|
|
27
|
$input = 'stick_L' if ( $input =~ /^(stick_[lL]{1})$/ ); |
49
|
14
|
50
|
|
|
|
23
|
$input = 'stick_R' if ( $input =~ /^(stick_[rR]{1})$/ ); |
50
|
|
|
|
|
|
|
|
51
|
14
|
100
|
|
|
|
49
|
if ( $input =~ /^(maru|sankaku|shikaku|batsu|start|select|ps|key|stick_[LR]{1}|[lr]{1}[12]{1})$/ ) { |
52
|
9
|
|
|
|
|
24
|
return ''; |
53
|
|
|
|
|
|
|
}else { |
54
|
|
|
|
|
|
|
# general actions or text |
55
|
5
|
|
66
|
|
|
12
|
return $class->_general_action( $input ) || Text::Livedoor::Wiki::Utils::escape( $input ); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub _general_action { |
60
|
5
|
|
|
5
|
|
9
|
my ( $class, $input ) = @_; |
61
|
|
|
|
|
|
|
|
62
|
5
|
100
|
|
|
|
31
|
return $input =~ /^(and|or|plus|push|soft|hard|repeat|long|[1-46-9]{1})$/ |
63
|
|
|
|
|
|
|
? '' |
64
|
|
|
|
|
|
|
: 0; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub img_base { |
68
|
10
|
|
|
10
|
1
|
12
|
my $class = shift; |
69
|
10
|
|
|
|
|
33
|
return $class->opts->{storage} . '/images/function/pad/'; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 NAME |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Text::Livedoor::Wiki::Plugin::Function::Pad - Game Pad Function Plugin |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 DESCRIPTION |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
displays game pad |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 SYNOPSIS |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
&pad(ps3){sankaku,shikaku} |
85
|
|
|
|
|
|
|
&pad(ps3){sankaku,and,shikaku,plus,here goes some text} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 FUNCTION |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head2 prepare_args |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
determine the pad type. |
92
|
|
|
|
|
|
|
to add more pad types, add the pad name to the script below |
93
|
|
|
|
|
|
|
$pad_type =~ /^(ps3)$/i; |
94
|
|
|
|
|
|
|
such as |
95
|
|
|
|
|
|
|
$pad_type =~ /^(ps3|Xbox|nintendo)/i; |
96
|
|
|
|
|
|
|
and create functions _Xbox and _nintendo to deal with game pad oriented buttons. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head2 process |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
parses the text into html. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head2 _ps3 |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
generates buttons that are only used by ps3 pad. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 _general_action |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
generates actions that are commonly used by many game pads including "push hard", "push repeatedly", "push longer" and so on... |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head2 img_base |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
set the location of directory for images |
113
|
|
|
|
|
|
|
general images are stored under storage_dir_name/images/function/pad/ |
114
|
|
|
|
|
|
|
and images for specific game pads arestored under storage_dir_name/images/function/pad/ps3/ |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 THANKS |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
thank clouder for giving us this great plugin idea! |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 SEE ALSO |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 AUTHOR |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
oklahomer |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=cut |