1 | package CFPlus::UI::SpellList; |
1 | package dc::UI::SpellList; |
2 | |
2 | |
3 | use strict; |
3 | use strict; |
4 | use utf8; |
4 | use utf8; |
5 | |
5 | |
6 | use CFPlus::Macro; |
6 | use dc::Macro; |
7 | |
7 | |
8 | our @ISA = CFPlus::UI::Table::; |
8 | our @ISA = dc::UI::Table::; |
9 | |
9 | |
10 | sub new { |
10 | sub new { |
11 | my $class = shift; |
11 | my $class = shift; |
12 | |
12 | |
13 | my $self = $class->SUPER::new ( |
13 | my $self = $class->SUPER::new ( |
… | |
… | |
31 | "<b>Damage</b>. The amount of damage the spell deals when it hits.$TOOLTIP_ALL"); |
31 | "<b>Damage</b>. The amount of damage the spell deals when it hits.$TOOLTIP_ALL"); |
32 | |
32 | |
33 | sub rebuild_spell_list { |
33 | sub rebuild_spell_list { |
34 | my ($self) = @_; |
34 | my ($self) = @_; |
35 | |
35 | |
36 | $CFPlus::UI::ROOT->on_refresh ($self => sub { |
36 | $dc::UI::ROOT->on_refresh ($self => sub { |
37 | $self->clear; |
37 | $self->clear; |
38 | |
38 | |
39 | return unless $::CONN; |
39 | return unless $::CONN; |
40 | |
40 | |
41 | my @add; |
41 | my @add; |
42 | |
42 | |
43 | push @add, |
43 | push @add, |
44 | 1, 0, (new CFPlus::UI::Label text => "Spell Name", @TOOLTIP_NAME), |
44 | 1, 0, (new dc::UI::Label text => "Spell Name", @TOOLTIP_NAME), |
45 | 2, 0, (new CFPlus::UI::Label text => "Skill", @TOOLTIP_SKILL), |
45 | 2, 0, (new dc::UI::Label text => "Skill", @TOOLTIP_SKILL), |
46 | 3, 0, (new CFPlus::UI::Label text => "Lvl" , @TOOLTIP_LVL), |
46 | 3, 0, (new dc::UI::Label text => "Lvl" , @TOOLTIP_LVL), |
47 | 4, 0, (new CFPlus::UI::Label text => "Sp/Gp", @TOOLTIP_SP), |
47 | 4, 0, (new dc::UI::Label text => "Sp/Gp", @TOOLTIP_SP), |
48 | 5, 0, (new CFPlus::UI::Label text => "Dmg" , @TOOLTIP_DMG), |
48 | 5, 0, (new dc::UI::Label text => "Dmg" , @TOOLTIP_DMG), |
49 | ; |
49 | ; |
50 | |
50 | |
51 | my $row = 0; |
51 | my $row = 0; |
52 | |
52 | |
53 | for (sort { $a cmp $b } keys %{ $self->{spell} }) { |
53 | for (sort { $a cmp $b } keys %{ $self->{spell} }) { |
… | |
… | |
61 | if ($ev->{button} == 1) { |
61 | if ($ev->{button} == 1) { |
62 | $::CONN->user_send ("cast $spell->{name}"); |
62 | $::CONN->user_send ("cast $spell->{name}"); |
63 | } elsif ($ev->{button} == 2) { |
63 | } elsif ($ev->{button} == 2) { |
64 | $::CONN->user_send ("invoke $spell->{name}"); |
64 | $::CONN->user_send ("invoke $spell->{name}"); |
65 | } elsif ($ev->{button} == 3) { |
65 | } elsif ($ev->{button} == 3) { |
66 | my $shortname = CFPlus::shorten $spell->{name}, 14; |
66 | my $shortname = dc::shorten $spell->{name}, 14; |
67 | (new CFPlus::UI::Menu |
67 | (new dc::UI::Menu |
68 | items => [ |
68 | items => [ |
69 | ["bind <i>cast $shortname</i> to a key" => sub { CFPlus::Macro::quick_macro ["cast $spell->{name}"] }], |
69 | ["bind <i>cast $shortname</i> to a key" => sub { dc::Macro::quick_macro ["cast $spell->{name}"] }], |
70 | ["bind <i>invoke $shortname</i> to a key" => sub { CFPlus::Macro::quick_macro ["invoke $spell->{name}"] }], |
70 | ["bind <i>invoke $shortname</i> to a key" => sub { dc::Macro::quick_macro ["invoke $spell->{name}"] }], |
71 | ], |
71 | ], |
72 | )->popup ($ev); |
72 | )->popup ($ev); |
73 | } else { |
73 | } else { |
74 | return 0; |
74 | return 0; |
75 | } |
75 | } |
76 | |
76 | |
77 | 1 |
77 | 1 |
78 | }; |
78 | }; |
79 | |
79 | |
80 | my $tooltip = (CFPlus::asxml $spell->{message}) . $TOOLTIP_ALL; |
80 | my $tooltip = (dc::asxml $spell->{message}) . $TOOLTIP_ALL; |
81 | |
81 | |
82 | #TODO: add path info to tooltip |
82 | #TODO: add path info to tooltip |
83 | #push @add, 6, $row, new CFPlus::UI::Label text => $spell->{path}; |
83 | #push @add, 6, $row, new dc::UI::Label text => $spell->{path}; |
84 | |
84 | |
85 | push @add, 0, $row, new CFPlus::UI::Face |
85 | push @add, 0, $row, new dc::UI::Face |
86 | face => $spell->{face}, |
86 | face => $spell->{face}, |
87 | can_hover => 1, |
87 | can_hover => 1, |
88 | can_events => 1, |
88 | can_events => 1, |
89 | tooltip => $tooltip, |
89 | tooltip => $tooltip, |
90 | on_button_down => $spell_cb, |
90 | on_button_down => $spell_cb, |
91 | ; |
91 | ; |
92 | |
92 | |
93 | push @add, 1, $row, new CFPlus::UI::Label |
93 | push @add, 1, $row, new dc::UI::Label |
94 | expand => 1, |
94 | expand => 1, |
95 | text => $spell->{name}, |
95 | text => $spell->{name}, |
96 | can_hover => 1, |
96 | can_hover => 1, |
97 | can_events => 1, |
97 | can_events => 1, |
98 | tooltip => $tooltip, |
98 | tooltip => $tooltip, |
99 | on_button_down => $spell_cb, |
99 | on_button_down => $spell_cb, |
100 | ; |
100 | ; |
101 | |
101 | |
102 | push @add, |
102 | push @add, |
103 | 2, $row, (new CFPlus::UI::Label text => $::CONN->{skill_info}{$spell->{skill}}, @TOOLTIP_SKILL), |
103 | 2, $row, (new dc::UI::Label text => $::CONN->{skill_info}{$spell->{skill}}, @TOOLTIP_SKILL), |
104 | 3, $row, (new CFPlus::UI::Label text => $spell->{level}, @TOOLTIP_LVL), |
104 | 3, $row, (new dc::UI::Label text => $spell->{level}, @TOOLTIP_LVL), |
105 | 4, $row, (new CFPlus::UI::Label text => $spell->{mana} || $spell->{grace}, @TOOLTIP_SP), |
105 | 4, $row, (new dc::UI::Label text => $spell->{mana} || $spell->{grace}, @TOOLTIP_SP), |
106 | 5, $row, (new CFPlus::UI::Label text => $spell->{damage}, @TOOLTIP_DMG), |
106 | 5, $row, (new dc::UI::Label text => $spell->{damage}, @TOOLTIP_DMG), |
107 | ; |
107 | ; |
108 | } |
108 | } |
109 | |
109 | |
110 | $self->add_at (@add); |
110 | $self->add_at (@add); |
111 | }); |
111 | }); |