… | |
… | |
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 { |
… | |
… | |
2505 | $self->SUPER::size_allocate ($w, $h); |
2506 | $self->SUPER::size_allocate ($w, $h); |
2506 | |
2507 | |
2507 | $self->{layout}->set_font ($self->{font}) if $self->{font}; |
2508 | $self->{layout}->set_font ($self->{font}) if $self->{font}; |
2508 | $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE); |
2509 | $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE); |
2509 | $self->{layout}->set_width ($self->{children}[0]{w}); |
2510 | $self->{layout}->set_width ($self->{children}[0]{w}); |
|
|
2511 | $self->{layout}->set_indent (-$self->{fontsize} * $::FONTSIZE * 4); |
2510 | |
2512 | |
2511 | $self->reflow; |
2513 | $self->reflow; |
2512 | } |
2514 | } |
2513 | |
2515 | |
2514 | sub text_size { |
2516 | sub text_size { |
… | |
… | |
2516 | |
2518 | |
2517 | my $layout = $self->{layout}; |
2519 | my $layout = $self->{layout}; |
2518 | |
2520 | |
2519 | $layout->set_height ($self->{fontsize} * $::FONTSIZE); |
2521 | $layout->set_height ($self->{fontsize} * $::FONTSIZE); |
2520 | $layout->set_width ($self->{children}[0]{w} - $indent); |
2522 | $layout->set_width ($self->{children}[0]{w} - $indent); |
|
|
2523 | $layout->set_indent (-$self->{fontsize} * $::FONTSIZE * 4); |
2521 | $layout->set_markup ($text); |
2524 | $layout->set_markup ($text); |
2522 | |
2525 | |
2523 | $layout->size |
2526 | $layout->size |
2524 | } |
2527 | } |
2525 | |
2528 | |
… | |
… | |
2577 | $layout->set_height ($self->{fontsize} * $::FONTSIZE); |
2580 | $layout->set_height ($self->{fontsize} * $::FONTSIZE); |
2578 | |
2581 | |
2579 | for (@{$self->{par}}) { |
2582 | for (@{$self->{par}}) { |
2580 | if (1 || $_->[0] >= $W) { # TODO: works,but needs reconfigure etc. support |
2583 | if (1 || $_->[0] >= $W) { # TODO: works,but needs reconfigure etc. support |
2581 | $layout->set_width ($W - $_->[3]); |
2584 | $layout->set_width ($W - $_->[3]); |
|
|
2585 | $layout->set_indent (-$self->{fontsize} * $::FONTSIZE * 4); |
2582 | $layout->set_markup ($_->[4]); |
2586 | $layout->set_markup ($_->[4]); |
2583 | my ($w, $h) = $layout->size; |
2587 | my ($w, $h) = $layout->size; |
2584 | $_->[0] = $w + $_->[3]; |
2588 | $_->[0] = $w + $_->[3]; |
2585 | $_->[1] = $h; |
2589 | $_->[1] = $h; |
2586 | } |
2590 | } |
… | |
… | |
2618 | my $h = $par->[1]; |
2622 | my $h = $par->[1]; |
2619 | |
2623 | |
2620 | if ($y0 < $y + $h && $y < $y1) { |
2624 | if ($y0 < $y + $h && $y < $y1) { |
2621 | $layout->set_foreground (@{ $par->[2] }); |
2625 | $layout->set_foreground (@{ $par->[2] }); |
2622 | $layout->set_width ($W - $par->[3]); |
2626 | $layout->set_width ($W - $par->[3]); |
|
|
2627 | $layout->set_indent (-$self->{fontsize} * $::FONTSIZE * 4); |
2623 | $layout->set_markup ($par->[4]); |
2628 | $layout->set_markup ($par->[4]); |
2624 | |
2629 | |
2625 | my ($w, $h, $data, $format, $internalformat) = $layout->render; |
2630 | my ($w, $h, $data, $format, $internalformat) = $layout->render; |
2626 | |
2631 | |
2627 | glRasterPos $par->[3], $y - $y0; |
2632 | glRasterPos $par->[3], $y - $y0; |
… | |
… | |
2920 | ); |
2925 | ); |
2921 | |
2926 | |
2922 | $self->add ($self->{vbox} = new CFClient::UI::VBox); |
2927 | $self->add ($self->{vbox} = new CFClient::UI::VBox); |
2923 | |
2928 | |
2924 | for my $item (@{ $self->{items} }) { |
2929 | for my $item (@{ $self->{items} }) { |
2925 | my ($widget, $cb) = @$item; |
2930 | my ($widget, $cb, $tooltip) = @$item; |
2926 | |
2931 | |
2927 | # handle various types of items, only text for now |
2932 | # handle various types of items, only text for now |
2928 | if (!ref $widget) { |
2933 | if (!ref $widget) { |
2929 | $widget = new CFClient::UI::Label |
2934 | $widget = new CFClient::UI::Label |
2930 | can_hover => 1, |
2935 | can_hover => 1, |
2931 | can_events => 1, |
2936 | can_events => 1, |
2932 | text => $widget; |
2937 | text => $widget, |
|
|
2938 | tooltip => $tooltip |
2933 | } |
2939 | } |
2934 | |
2940 | |
2935 | $self->{item}{$widget} = $item; |
2941 | $self->{item}{$widget} = $item; |
2936 | |
2942 | |
2937 | $self->{vbox}->add ($widget); |
2943 | $self->{vbox}->add ($widget); |
… | |
… | |
3084 | sub set_current_page { |
3090 | sub set_current_page { |
3085 | my ($self, $page) = @_; |
3091 | my ($self, $page) = @_; |
3086 | |
3092 | |
3087 | $self->{multiplexer}->set_current_page ($page); |
3093 | $self->{multiplexer}->set_current_page ($page); |
3088 | $self->_emit (page_changed => $self->{multiplexer}{current}); |
3094 | $self->_emit (page_changed => $self->{multiplexer}{current}); |
|
|
3095 | } |
|
|
3096 | |
|
|
3097 | ############################################################################# |
|
|
3098 | |
|
|
3099 | package CFClient::UI::Combobox; |
|
|
3100 | |
|
|
3101 | use utf8; |
|
|
3102 | |
|
|
3103 | our @ISA = CFClient::UI::Button::; |
|
|
3104 | |
|
|
3105 | sub new { |
|
|
3106 | my $class = shift; |
|
|
3107 | |
|
|
3108 | my $self = $class->SUPER::new ( |
|
|
3109 | options => [], # [title, value, tooltip], ... |
|
|
3110 | value => undef, |
|
|
3111 | @_, |
|
|
3112 | ); |
|
|
3113 | |
|
|
3114 | $self->_set_value ($self->{value}); |
|
|
3115 | |
|
|
3116 | $self |
|
|
3117 | } |
|
|
3118 | |
|
|
3119 | sub button_down { |
|
|
3120 | my ($self, $ev) = @_; |
|
|
3121 | |
|
|
3122 | my @menu_items; |
|
|
3123 | |
|
|
3124 | for (@{ $self->{options} }) { |
|
|
3125 | my ($title, $value, $tooltip) = @$_; |
|
|
3126 | |
|
|
3127 | push @menu_items, [$tooltip, sub { $self->set_value ($value) }]; |
|
|
3128 | } |
|
|
3129 | |
|
|
3130 | CFClient::UI::Menu->new (items => \@menu_items)->popup ($ev); |
|
|
3131 | } |
|
|
3132 | |
|
|
3133 | sub _set_value { |
|
|
3134 | my ($self, $value) = @_; |
|
|
3135 | |
|
|
3136 | my ($item) = grep $_->[1] eq $value, @{ $self->{options} } |
|
|
3137 | or return; |
|
|
3138 | |
|
|
3139 | $self->{value} = $item->[1]; |
|
|
3140 | $self->set_markup ("$item->[0] ⇓"); |
|
|
3141 | $self->set_tooltip ($item->[2]); |
|
|
3142 | } |
|
|
3143 | |
|
|
3144 | sub set_value { |
|
|
3145 | my ($self, $value) = @_; |
|
|
3146 | |
|
|
3147 | return unless $self->{value} ne $value; |
|
|
3148 | |
|
|
3149 | $self->_set_value ($value); |
|
|
3150 | $self->_emit (changed => $value); |
3089 | } |
3151 | } |
3090 | |
3152 | |
3091 | ############################################################################# |
3153 | ############################################################################# |
3092 | |
3154 | |
3093 | package CFClient::UI::Statusbox; |
3155 | package CFClient::UI::Statusbox; |
… | |
… | |
3484 | commands => [], |
3546 | commands => [], |
3485 | @_, |
3547 | @_, |
3486 | ) |
3548 | ) |
3487 | } |
3549 | } |
3488 | |
3550 | |
3489 | # XXX: Do sorting? Argl... |
3551 | my @TOOLTIP_LVL = (align => 1, can_events => 1, can_hover => 1, tooltip => |
|
|
3552 | "<b>Level</b>. Minimum level the caster needs in the associated skill to be able to attempt casting this spell."); |
|
|
3553 | my @TOOLTIP_SP = (align => 1, can_events => 1, can_hover => 1, tooltip => |
|
|
3554 | "<b>Spell points / Grace points</b>. Amount of spell or grace points used by each invocation."); |
|
|
3555 | my @TOOLTIP_DMG = (align => 1, can_events => 1, can_hover => 1, tooltip => |
|
|
3556 | "<b>Damage</b>. The amount of damage the spell deals when it hits."); |
|
|
3557 | |
|
|
3558 | sub rebuild_spell_list { |
|
|
3559 | my ($self) = @_; |
|
|
3560 | |
|
|
3561 | $CFClient::UI::ROOT->on_refresh ($self => sub { |
|
|
3562 | $self->clear; |
|
|
3563 | |
|
|
3564 | $self->add (1, 0, new CFClient::UI::Label text => "Spell Name"); |
|
|
3565 | $self->add (2, 0, new CFClient::UI::Label text => "Lvl" , @TOOLTIP_LVL); |
|
|
3566 | $self->add (3, 0, new CFClient::UI::Label text => "Sp/Gp", @TOOLTIP_SP); |
|
|
3567 | $self->add (4, 0, new CFClient::UI::Label text => "Dmg" , @TOOLTIP_DMG); |
|
|
3568 | |
|
|
3569 | my $row = 0; |
|
|
3570 | |
|
|
3571 | for (sort { $a cmp $b } keys %{ $self->{spell} }) { |
|
|
3572 | my $spell = $self->{spell}{$_}; |
|
|
3573 | |
|
|
3574 | $row++; |
|
|
3575 | |
|
|
3576 | $self->add (0, $row, new CFClient::UI::Face |
|
|
3577 | face => $spell->{face}, |
|
|
3578 | can_hover => 1, |
|
|
3579 | can_events => 1, |
|
|
3580 | tooltip => $spell->{message}, |
|
|
3581 | ); |
|
|
3582 | |
|
|
3583 | $self->add (1, $row, new CFClient::UI::Label |
|
|
3584 | expand => 1, |
|
|
3585 | text => $spell->{name}, |
|
|
3586 | can_hover => 1, |
|
|
3587 | can_events => 1, |
|
|
3588 | tooltip => $spell->{message}, |
|
|
3589 | ); |
|
|
3590 | |
|
|
3591 | $self->add (2, $row, new CFClient::UI::Label text => $spell->{level}, @TOOLTIP_LVL); |
|
|
3592 | $self->add (3, $row, new CFClient::UI::Label text => $spell->{mana} || $spell->{grace}, @TOOLTIP_SP); |
|
|
3593 | $self->add (4, $row, new CFClient::UI::Label text => $spell->{damage}, @TOOLTIP_DMG); |
|
|
3594 | |
|
|
3595 | # TODO: should be done via popup |
|
|
3596 | $self->add (5, $row, new CFClient::UI::Button |
|
|
3597 | text => "bind", |
|
|
3598 | tooltip => "bind spell readying (cast command) to key", |
|
|
3599 | on_activate => sub { $::BIND_EDITOR->do_quick_binding (["cast $spell->{name}"]) }, |
|
|
3600 | ); |
|
|
3601 | } |
|
|
3602 | }); |
|
|
3603 | } |
|
|
3604 | |
3490 | sub add_spell { |
3605 | sub add_spell { |
3491 | my ($self, $spell) = @_; |
3606 | my ($self, $spell) = @_; |
|
|
3607 | |
3492 | $self->{spells}->{$spell->{name}} = $spell; |
3608 | $self->{spell}->{$spell->{name}} = $spell; |
3493 | |
3609 | $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 | } |
3610 | } |
3522 | |
3611 | |
3523 | sub remove_spell { |
3612 | sub remove_spell { |
3524 | my ($self, $spell) = @_; |
3613 | my ($self, $spell) = @_; |
|
|
3614 | |
3525 | delete $self->{spells}->{$spell->{name}}; |
3615 | delete $self->{spell}->{$spell->{name}}; |
3526 | $self->rebuild_spell_list; |
3616 | $self->rebuild_spell_list; |
3527 | } |
3617 | } |
3528 | |
3618 | |
3529 | ############################################################################# |
3619 | ############################################################################# |
3530 | |
3620 | |