… | |
… | |
3484 | commands => [], |
3484 | commands => [], |
3485 | @_, |
3485 | @_, |
3486 | ) |
3486 | ) |
3487 | } |
3487 | } |
3488 | |
3488 | |
3489 | # XXX: Do sorting? Argl... |
3489 | my @TOOLTIP_LVL = (align => 1, can_events => 1, can_hover => 1, tooltip => |
|
|
3490 | "<b>Level</b>. Minimum level the caster needs in the associated skill to be able to attempt casting this spell."); |
|
|
3491 | my @TOOLTIP_SP = (align => 1, can_events => 1, can_hover => 1, tooltip => |
|
|
3492 | "<b>Spell points / Grace points</b>. Amount of spell or grace points used by each invocation."); |
|
|
3493 | my @TOOLTIP_DMG = (align => 1, can_events => 1, can_hover => 1, tooltip => |
|
|
3494 | "<b>Damage</b>. The amount of damage the spell deals when it hits."); |
|
|
3495 | |
|
|
3496 | sub rebuild_spell_list { |
|
|
3497 | my ($self) = @_; |
|
|
3498 | |
|
|
3499 | $CFClient::UI::ROOT->on_refresh ($self => sub { |
|
|
3500 | $self->clear; |
|
|
3501 | |
|
|
3502 | $self->add (1, 0, new CFClient::UI::Label text => "Spell Name"); |
|
|
3503 | $self->add (2, 0, new CFClient::UI::Label text => "Lvl" , @TOOLTIP_LVL); |
|
|
3504 | $self->add (3, 0, new CFClient::UI::Label text => "Sp/Gp", @TOOLTIP_SP); |
|
|
3505 | $self->add (4, 0, new CFClient::UI::Label text => "Dmg" , @TOOLTIP_DMG); |
|
|
3506 | |
|
|
3507 | my $row = 0; |
|
|
3508 | |
|
|
3509 | for (sort { $a cmp $b } keys %{ $self->{spell} }) { |
|
|
3510 | my $spell = $self->{spell}{$_}; |
|
|
3511 | |
|
|
3512 | $row++; |
|
|
3513 | |
|
|
3514 | $self->add (0, $row, new CFClient::UI::Face |
|
|
3515 | face => $spell->{face}, |
|
|
3516 | can_hover => 1, |
|
|
3517 | can_events => 1, |
|
|
3518 | tooltip => $spell->{message}, |
|
|
3519 | ); |
|
|
3520 | |
|
|
3521 | $self->add (1, $row, new CFClient::UI::Label |
|
|
3522 | expand => 1, |
|
|
3523 | text => $spell->{name}, |
|
|
3524 | can_hover => 1, |
|
|
3525 | can_events => 1, |
|
|
3526 | tooltip => $spell->{message}, |
|
|
3527 | ); |
|
|
3528 | |
|
|
3529 | $self->add (2, $row, new CFClient::UI::Label text => $spell->{level}, @TOOLTIP_LVL); |
|
|
3530 | $self->add (3, $row, new CFClient::UI::Label text => $spell->{mana} || $spell->{grace}, @TOOLTIP_SP); |
|
|
3531 | $self->add (4, $row, new CFClient::UI::Label text => $spell->{damage}, @TOOLTIP_DMG); |
|
|
3532 | |
|
|
3533 | # TODO: should be done via popup |
|
|
3534 | $self->add (5, $row, new CFClient::UI::Button |
|
|
3535 | text => "bind", |
|
|
3536 | tooltip => "bind spell readying (cast command) to key", |
|
|
3537 | on_activate => sub { $::BIND_EDITOR->do_quick_binding (["cast $spell->{name}"]) }, |
|
|
3538 | ); |
|
|
3539 | } |
|
|
3540 | }); |
|
|
3541 | } |
|
|
3542 | |
3490 | sub add_spell { |
3543 | sub add_spell { |
3491 | my ($self, $spell) = @_; |
3544 | my ($self, $spell) = @_; |
|
|
3545 | |
3492 | $self->{spells}->{$spell->{name}} = $spell; |
3546 | $self->{spell}->{$spell->{name}} = $spell; |
3493 | |
3547 | $self->rebuild_spell_list; |
3494 | $self->add (0, $self->{tbl_idx}, new CFClient::UI::Face |
|
|
3495 | face => $spell->{face}, |
|
|
3496 | can_hover => 1, |
|
|
3497 | can_events => 1, |
|
|
3498 | tooltip => $spell->{message}); |
|
|
3499 | |
|
|
3500 | $self->add (1, $self->{tbl_idx}, new CFClient::UI::Label |
|
|
3501 | text => $spell->{name}, |
|
|
3502 | can_hover => 1, |
|
|
3503 | can_events => 1, |
|
|
3504 | tooltip => $spell->{message}, |
|
|
3505 | expand => 1); |
|
|
3506 | |
|
|
3507 | $self->add (2, $self->{tbl_idx}, new CFClient::UI::Label |
|
|
3508 | text => (sprintf "lvl: %2d sp: %2d dmg: %2d", |
|
|
3509 | $spell->{level}, ($spell->{mana} || $spell->{grace}), $spell->{damage}), |
|
|
3510 | expand => 1); |
|
|
3511 | |
|
|
3512 | $self->add (3, $self->{tbl_idx}++, new CFClient::UI::Button |
|
|
3513 | text => "bind to key", |
|
|
3514 | on_activate => sub { $::BIND_EDITOR->do_quick_binding (["cast $spell->{name}"]) }); |
|
|
3515 | } |
|
|
3516 | |
|
|
3517 | sub rebuild_spell_list { |
|
|
3518 | my ($self) = @_; |
|
|
3519 | $self->{tbl_idx} = 0; |
|
|
3520 | $self->add_spell ($_) for values %{$self->{spells}}; |
|
|
3521 | } |
3548 | } |
3522 | |
3549 | |
3523 | sub remove_spell { |
3550 | sub remove_spell { |
3524 | my ($self, $spell) = @_; |
3551 | my ($self, $spell) = @_; |
|
|
3552 | |
3525 | delete $self->{spells}->{$spell->{name}}; |
3553 | delete $self->{spell}->{$spell->{name}}; |
3526 | $self->rebuild_spell_list; |
3554 | $self->rebuild_spell_list; |
3527 | } |
3555 | } |
3528 | |
3556 | |
3529 | ############################################################################# |
3557 | ############################################################################# |
3530 | |
3558 | |