… | |
… | |
1691 | can_hover => 1, |
1691 | can_hover => 1, |
1692 | can_focus => 1, |
1692 | can_focus => 1, |
1693 | valign => 0, |
1693 | valign => 0, |
1694 | can_events => 1, |
1694 | can_events => 1, |
1695 | #text => ... |
1695 | #text => ... |
|
|
1696 | #hidden => "*", |
1696 | @_ |
1697 | @_ |
1697 | ) |
1698 | ) |
1698 | } |
1699 | } |
1699 | |
1700 | |
1700 | sub _set_text { |
1701 | sub _set_text { |
… | |
… | |
2920 | ); |
2921 | ); |
2921 | |
2922 | |
2922 | $self->add ($self->{vbox} = new CFClient::UI::VBox); |
2923 | $self->add ($self->{vbox} = new CFClient::UI::VBox); |
2923 | |
2924 | |
2924 | for my $item (@{ $self->{items} }) { |
2925 | for my $item (@{ $self->{items} }) { |
2925 | my ($widget, $cb) = @$item; |
2926 | my ($widget, $cb, $tooltip) = @$item; |
2926 | |
2927 | |
2927 | # handle various types of items, only text for now |
2928 | # handle various types of items, only text for now |
2928 | if (!ref $widget) { |
2929 | if (!ref $widget) { |
2929 | $widget = new CFClient::UI::Label |
2930 | $widget = new CFClient::UI::Label |
2930 | can_hover => 1, |
2931 | can_hover => 1, |
2931 | can_events => 1, |
2932 | can_events => 1, |
2932 | text => $widget; |
2933 | text => $widget, |
|
|
2934 | tooltip => $tooltip |
2933 | } |
2935 | } |
2934 | |
2936 | |
2935 | $self->{item}{$widget} = $item; |
2937 | $self->{item}{$widget} = $item; |
2936 | |
2938 | |
2937 | $self->{vbox}->add ($widget); |
2939 | $self->{vbox}->add ($widget); |
… | |
… | |
3084 | sub set_current_page { |
3086 | sub set_current_page { |
3085 | my ($self, $page) = @_; |
3087 | my ($self, $page) = @_; |
3086 | |
3088 | |
3087 | $self->{multiplexer}->set_current_page ($page); |
3089 | $self->{multiplexer}->set_current_page ($page); |
3088 | $self->_emit (page_changed => $self->{multiplexer}{current}); |
3090 | $self->_emit (page_changed => $self->{multiplexer}{current}); |
|
|
3091 | } |
|
|
3092 | |
|
|
3093 | ############################################################################# |
|
|
3094 | |
|
|
3095 | package CFClient::UI::Combobox; |
|
|
3096 | |
|
|
3097 | use utf8; |
|
|
3098 | |
|
|
3099 | our @ISA = CFClient::UI::Button::; |
|
|
3100 | |
|
|
3101 | sub new { |
|
|
3102 | my $class = shift; |
|
|
3103 | |
|
|
3104 | my $self = $class->SUPER::new ( |
|
|
3105 | options => [], # [title, value, tooltip], ... |
|
|
3106 | value => undef, |
|
|
3107 | @_, |
|
|
3108 | ); |
|
|
3109 | |
|
|
3110 | $self->_set_value ($self->{value}); |
|
|
3111 | |
|
|
3112 | $self |
|
|
3113 | } |
|
|
3114 | |
|
|
3115 | sub button_down { |
|
|
3116 | my ($self, $ev) = @_; |
|
|
3117 | |
|
|
3118 | my @menu_items; |
|
|
3119 | |
|
|
3120 | for (@{ $self->{options} }) { |
|
|
3121 | my ($title, $value, $tooltip) = @$_; |
|
|
3122 | |
|
|
3123 | push @menu_items, [$tooltip, sub { $self->set_value ($value) }]; |
|
|
3124 | } |
|
|
3125 | |
|
|
3126 | CFClient::UI::Menu->new (items => \@menu_items)->popup ($ev); |
|
|
3127 | } |
|
|
3128 | |
|
|
3129 | sub _set_value { |
|
|
3130 | my ($self, $value) = @_; |
|
|
3131 | |
|
|
3132 | my ($item) = grep $_->[1] eq $value, @{ $self->{options} } |
|
|
3133 | or return; |
|
|
3134 | |
|
|
3135 | $self->{value} = $item->[1]; |
|
|
3136 | $self->set_markup ("$item->[0] ⇓"); |
|
|
3137 | $self->set_tooltip ($item->[2]); |
|
|
3138 | } |
|
|
3139 | |
|
|
3140 | sub set_value { |
|
|
3141 | my ($self, $value) = @_; |
|
|
3142 | |
|
|
3143 | return unless $self->{value} ne $value; |
|
|
3144 | |
|
|
3145 | $self->_set_value ($value); |
|
|
3146 | $self->_emit (changed => $value); |
3089 | } |
3147 | } |
3090 | |
3148 | |
3091 | ############################################################################# |
3149 | ############################################################################# |
3092 | |
3150 | |
3093 | package CFClient::UI::Statusbox; |
3151 | package CFClient::UI::Statusbox; |
… | |
… | |
3484 | commands => [], |
3542 | commands => [], |
3485 | @_, |
3543 | @_, |
3486 | ) |
3544 | ) |
3487 | } |
3545 | } |
3488 | |
3546 | |
3489 | # XXX: Do sorting? Argl... |
3547 | my @TOOLTIP_LVL = (align => 1, can_events => 1, can_hover => 1, tooltip => |
|
|
3548 | "<b>Level</b>. Minimum level the caster needs in the associated skill to be able to attempt casting this spell."); |
|
|
3549 | my @TOOLTIP_SP = (align => 1, can_events => 1, can_hover => 1, tooltip => |
|
|
3550 | "<b>Spell points / Grace points</b>. Amount of spell or grace points used by each invocation."); |
|
|
3551 | my @TOOLTIP_DMG = (align => 1, can_events => 1, can_hover => 1, tooltip => |
|
|
3552 | "<b>Damage</b>. The amount of damage the spell deals when it hits."); |
|
|
3553 | |
|
|
3554 | sub rebuild_spell_list { |
|
|
3555 | my ($self) = @_; |
|
|
3556 | |
|
|
3557 | $CFClient::UI::ROOT->on_refresh ($self => sub { |
|
|
3558 | $self->clear; |
|
|
3559 | |
|
|
3560 | $self->add (1, 0, new CFClient::UI::Label text => "Spell Name"); |
|
|
3561 | $self->add (2, 0, new CFClient::UI::Label text => "Lvl" , @TOOLTIP_LVL); |
|
|
3562 | $self->add (3, 0, new CFClient::UI::Label text => "Sp/Gp", @TOOLTIP_SP); |
|
|
3563 | $self->add (4, 0, new CFClient::UI::Label text => "Dmg" , @TOOLTIP_DMG); |
|
|
3564 | |
|
|
3565 | my $row = 0; |
|
|
3566 | |
|
|
3567 | for (sort { $a cmp $b } keys %{ $self->{spell} }) { |
|
|
3568 | my $spell = $self->{spell}{$_}; |
|
|
3569 | |
|
|
3570 | $row++; |
|
|
3571 | |
|
|
3572 | $self->add (0, $row, new CFClient::UI::Face |
|
|
3573 | face => $spell->{face}, |
|
|
3574 | can_hover => 1, |
|
|
3575 | can_events => 1, |
|
|
3576 | tooltip => $spell->{message}, |
|
|
3577 | ); |
|
|
3578 | |
|
|
3579 | $self->add (1, $row, new CFClient::UI::Label |
|
|
3580 | expand => 1, |
|
|
3581 | text => $spell->{name}, |
|
|
3582 | can_hover => 1, |
|
|
3583 | can_events => 1, |
|
|
3584 | tooltip => $spell->{message}, |
|
|
3585 | ); |
|
|
3586 | |
|
|
3587 | $self->add (2, $row, new CFClient::UI::Label text => $spell->{level}, @TOOLTIP_LVL); |
|
|
3588 | $self->add (3, $row, new CFClient::UI::Label text => $spell->{mana} || $spell->{grace}, @TOOLTIP_SP); |
|
|
3589 | $self->add (4, $row, new CFClient::UI::Label text => $spell->{damage}, @TOOLTIP_DMG); |
|
|
3590 | |
|
|
3591 | # TODO: should be done via popup |
|
|
3592 | $self->add (5, $row, new CFClient::UI::Button |
|
|
3593 | text => "bind", |
|
|
3594 | tooltip => "bind spell readying (cast command) to key", |
|
|
3595 | on_activate => sub { $::BIND_EDITOR->do_quick_binding (["cast $spell->{name}"]) }, |
|
|
3596 | ); |
|
|
3597 | } |
|
|
3598 | }); |
|
|
3599 | } |
|
|
3600 | |
3490 | sub add_spell { |
3601 | sub add_spell { |
3491 | my ($self, $spell) = @_; |
3602 | my ($self, $spell) = @_; |
|
|
3603 | |
3492 | $self->{spells}->{$spell->{name}} = $spell; |
3604 | $self->{spell}->{$spell->{name}} = $spell; |
3493 | |
3605 | $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 | } |
3606 | } |
3522 | |
3607 | |
3523 | sub remove_spell { |
3608 | sub remove_spell { |
3524 | my ($self, $spell) = @_; |
3609 | my ($self, $spell) = @_; |
|
|
3610 | |
3525 | delete $self->{spells}->{$spell->{name}}; |
3611 | delete $self->{spell}->{$spell->{name}}; |
3526 | $self->rebuild_spell_list; |
3612 | $self->rebuild_spell_list; |
3527 | } |
3613 | } |
3528 | |
3614 | |
3529 | ############################################################################# |
3615 | ############################################################################# |
3530 | |
3616 | |