… | |
… | |
525 | if $self->{parent}; |
525 | if $self->{parent}; |
526 | } |
526 | } |
527 | |
527 | |
528 | sub reconfigure { |
528 | sub reconfigure { |
529 | my ($self) = @_; |
529 | my ($self) = @_; |
530 | |
|
|
531 | # some widgets cache req_w and req_h |
|
|
532 | delete $self->{req_w}; |
|
|
533 | delete $self->{req_h}; |
|
|
534 | |
530 | |
535 | $self->realloc; |
531 | $self->realloc; |
536 | $self->update; |
532 | $self->update; |
537 | } |
533 | } |
538 | |
534 | |
… | |
… | |
1559 | $self->{text} = "T$text"; |
1555 | $self->{text} = "T$text"; |
1560 | |
1556 | |
1561 | $self->{layout} = new CFClient::Layout if $self->{layout}->is_rgba; |
1557 | $self->{layout} = new CFClient::Layout if $self->{layout}->is_rgba; |
1562 | $self->{layout}->set_text ($text); |
1558 | $self->{layout}->set_text ($text); |
1563 | |
1559 | |
1564 | delete $self->{req_h}; |
1560 | delete $self->{size_req}; |
1565 | $self->realloc; |
1561 | $self->realloc; |
1566 | $self->update; |
1562 | $self->update; |
1567 | } |
1563 | } |
1568 | |
1564 | |
1569 | sub set_markup { |
1565 | sub set_markup { |
… | |
… | |
1575 | my $rgba = $markup =~ /span.*(?:foreground|background)/; |
1571 | my $rgba = $markup =~ /span.*(?:foreground|background)/; |
1576 | |
1572 | |
1577 | $self->{layout} = new CFClient::Layout $rgba if $self->{layout}->is_rgba != $rgba; |
1573 | $self->{layout} = new CFClient::Layout $rgba if $self->{layout}->is_rgba != $rgba; |
1578 | $self->{layout}->set_markup ($markup); |
1574 | $self->{layout}->set_markup ($markup); |
1579 | |
1575 | |
1580 | delete $self->{req_h}; |
1576 | delete $self->{size_req}; |
1581 | $self->realloc; |
1577 | $self->realloc; |
1582 | $self->update; |
1578 | $self->update; |
1583 | } |
1579 | } |
1584 | |
1580 | |
1585 | sub size_request { |
1581 | sub size_request { |
1586 | my ($self) = @_; |
1582 | my ($self) = @_; |
1587 | |
1583 | |
1588 | if (exists $self->{req_h}) { |
1584 | $self->{size_req} ||= do { |
1589 | @$self{qw(req_w req_h)} |
|
|
1590 | } else { |
|
|
1591 | $self->{layout}->set_font ($self->{font}) if $self->{font}; |
1585 | $self->{layout}->set_font ($self->{font}) if $self->{font}; |
1592 | $self->{layout}->set_width ($self->{max_w} || -1); |
1586 | $self->{layout}->set_width ($self->{max_w} || -1); |
1593 | $self->{layout}->set_ellipsise ($self->{ellipsise}); |
1587 | $self->{layout}->set_ellipsise ($self->{ellipsise}); |
1594 | $self->{layout}->set_single_paragraph_mode ($self->{ellipsise}); |
1588 | $self->{layout}->set_single_paragraph_mode ($self->{ellipsise}); |
1595 | $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE); |
1589 | $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE); |
… | |
… | |
1604 | |
1598 | |
1605 | $w = List::Util::max $w, $w2; |
1599 | $w = List::Util::max $w, $w2; |
1606 | $h = List::Util::max $h, $h2; |
1600 | $h = List::Util::max $h, $h2; |
1607 | } |
1601 | } |
1608 | |
1602 | |
1609 | ($w, $h) |
1603 | [$w, $h] |
1610 | } |
1604 | }; |
|
|
1605 | |
|
|
1606 | @{ $self->{size_req} } |
1611 | } |
1607 | } |
1612 | |
1608 | |
1613 | sub size_allocate { |
1609 | sub size_allocate { |
1614 | my ($self, $w, $h) = @_; |
1610 | my ($self, $w, $h) = @_; |
1615 | |
1611 | |
… | |
… | |
1624 | |
1620 | |
1625 | $self->{fontsize} = $fontsize; |
1621 | $self->{fontsize} = $fontsize; |
1626 | delete $self->{texture}; |
1622 | delete $self->{texture}; |
1627 | |
1623 | |
1628 | $self->realloc; |
1624 | $self->realloc; |
|
|
1625 | } |
|
|
1626 | |
|
|
1627 | sub reconfigure { |
|
|
1628 | my ($self) = @_; |
|
|
1629 | |
|
|
1630 | delete $self->{size_req}; |
|
|
1631 | |
|
|
1632 | $self->SUPER::reconfigure; |
1629 | } |
1633 | } |
1630 | |
1634 | |
1631 | sub _draw { |
1635 | sub _draw { |
1632 | my ($self) = @_; |
1636 | my ($self) = @_; |
1633 | |
1637 | |
… | |
… | |
1703 | $self->{last_activity} = $::NOW; |
1707 | $self->{last_activity} = $::NOW; |
1704 | $self->{text} = $text; |
1708 | $self->{text} = $text; |
1705 | |
1709 | |
1706 | $text =~ s/./*/g if $self->{hidden}; |
1710 | $text =~ s/./*/g if $self->{hidden}; |
1707 | $self->{layout}->set_text ("$text "); |
1711 | $self->{layout}->set_text ("$text "); |
1708 | delete $self->{req_h}; |
1712 | delete $self->{size_req}; |
1709 | |
1713 | |
1710 | $self->_emit (changed => $self->{text}); |
1714 | $self->_emit (changed => $self->{text}); |
1711 | |
1715 | |
1712 | $self->realloc; |
1716 | $self->realloc; |
1713 | $self->update; |
1717 | $self->update; |
… | |
… | |
3480 | commands => [], |
3484 | commands => [], |
3481 | @_, |
3485 | @_, |
3482 | ) |
3486 | ) |
3483 | } |
3487 | } |
3484 | |
3488 | |
3485 | # 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 | |
3486 | sub add_spell { |
3543 | sub add_spell { |
3487 | my ($self, $spell) = @_; |
3544 | my ($self, $spell) = @_; |
|
|
3545 | |
3488 | $self->{spells}->{$spell->{name}} = $spell; |
3546 | $self->{spell}->{$spell->{name}} = $spell; |
3489 | |
3547 | $self->rebuild_spell_list; |
3490 | $self->add (0, $self->{tbl_idx}, new CFClient::UI::Face |
|
|
3491 | face => $spell->{face}, |
|
|
3492 | can_hover => 1, |
|
|
3493 | can_events => 1, |
|
|
3494 | tooltip => $spell->{message}); |
|
|
3495 | |
|
|
3496 | $self->add (1, $self->{tbl_idx}, new CFClient::UI::Label |
|
|
3497 | text => $spell->{name}, |
|
|
3498 | can_hover => 1, |
|
|
3499 | can_events => 1, |
|
|
3500 | tooltip => $spell->{message}, |
|
|
3501 | expand => 1); |
|
|
3502 | |
|
|
3503 | $self->add (2, $self->{tbl_idx}, new CFClient::UI::Label |
|
|
3504 | text => (sprintf "lvl: %2d sp: %2d dmg: %2d", |
|
|
3505 | $spell->{level}, ($spell->{mana} || $spell->{grace}), $spell->{damage}), |
|
|
3506 | expand => 1); |
|
|
3507 | |
|
|
3508 | $self->add (3, $self->{tbl_idx}++, new CFClient::UI::Button |
|
|
3509 | text => "bind to key", |
|
|
3510 | on_activate => sub { $::BIND_EDITOR->do_quick_binding (["cast $spell->{name}"]) }); |
|
|
3511 | } |
|
|
3512 | |
|
|
3513 | sub rebuild_spell_list { |
|
|
3514 | my ($self) = @_; |
|
|
3515 | $self->{tbl_idx} = 0; |
|
|
3516 | $self->add_spell ($_) for values %{$self->{spells}}; |
|
|
3517 | } |
3548 | } |
3518 | |
3549 | |
3519 | sub remove_spell { |
3550 | sub remove_spell { |
3520 | my ($self, $spell) = @_; |
3551 | my ($self, $spell) = @_; |
|
|
3552 | |
3521 | delete $self->{spells}->{$spell->{name}}; |
3553 | delete $self->{spell}->{$spell->{name}}; |
3522 | $self->rebuild_spell_list; |
3554 | $self->rebuild_spell_list; |
3523 | } |
3555 | } |
3524 | |
3556 | |
3525 | ############################################################################# |
3557 | ############################################################################# |
3526 | |
3558 | |