… | |
… | |
955 | package CFClient::UI::ScrolledWindow; |
955 | package CFClient::UI::ScrolledWindow; |
956 | |
956 | |
957 | our @ISA = CFClient::UI::HBox::; |
957 | our @ISA = CFClient::UI::HBox::; |
958 | |
958 | |
959 | sub new { |
959 | sub new { |
960 | my $class = shift; |
960 | my ($class, %arg) = @_; |
|
|
961 | |
|
|
962 | my $child = delete $arg{child}; |
961 | |
963 | |
962 | my $self; |
964 | my $self; |
963 | |
965 | |
964 | my $slider = new CFClient::UI::Slider |
966 | my $slider = new CFClient::UI::Slider |
965 | vertical => 1, |
967 | vertical => 1, |
… | |
… | |
970 | ; |
972 | ; |
971 | |
973 | |
972 | $self = $class->SUPER::new ( |
974 | $self = $class->SUPER::new ( |
973 | vp => (new CFClient::UI::ViewPort expand => 1), |
975 | vp => (new CFClient::UI::ViewPort expand => 1), |
974 | slider => $slider, |
976 | slider => $slider, |
975 | @_, |
977 | %arg, |
976 | ); |
978 | ); |
977 | |
979 | |
978 | $self->{vp}->add ($self->{scrolled}); |
|
|
979 | $self->add ($self->{vp}); |
|
|
980 | $self->add ($self->{slider}); |
980 | $self->SUPER::add ($self->{vp}, $self->{slider}); |
|
|
981 | $self->add ($child) if $child; |
981 | |
982 | |
982 | $self |
983 | $self |
|
|
984 | } |
|
|
985 | |
|
|
986 | sub add { |
|
|
987 | my ($self, $widget) = @_; |
|
|
988 | |
|
|
989 | $self->{vp}->add ($self->{child} = $widget); |
983 | } |
990 | } |
984 | |
991 | |
985 | sub update { |
992 | sub update { |
986 | my ($self) = @_; |
993 | my ($self) = @_; |
987 | |
994 | |
… | |
… | |
3022 | my $class = shift; |
3029 | my $class = shift; |
3023 | |
3030 | |
3024 | my $self = $class->SUPER::new ( |
3031 | my $self = $class->SUPER::new ( |
3025 | buttonbar => (new CFClient::UI::Buttonbar), |
3032 | buttonbar => (new CFClient::UI::Buttonbar), |
3026 | multiplexer => (new CFClient::UI::Multiplexer expand => 1), |
3033 | multiplexer => (new CFClient::UI::Multiplexer expand => 1), |
|
|
3034 | # filter => # will be put between multiplexer and $self |
3027 | @_, |
3035 | @_, |
3028 | ); |
3036 | ); |
3029 | |
3037 | |
|
|
3038 | $self->{filter}->add ($self->{multiplexer}) if $self->{filter}; |
3030 | $self->SUPER::add ($self->{buttonbar}, $self->{multiplexer}); |
3039 | $self->SUPER::add ($self->{buttonbar}, $self->{filter} || $self->{multiplexer}); |
3031 | |
3040 | |
3032 | $self |
3041 | $self |
3033 | } |
3042 | } |
3034 | |
3043 | |
3035 | sub add { |
3044 | sub add { |
… | |
… | |
3171 | |
3180 | |
3172 | sub new { |
3181 | sub new { |
3173 | my $class = shift; |
3182 | my $class = shift; |
3174 | |
3183 | |
3175 | my $self = $class->SUPER::new ( |
3184 | my $self = $class->SUPER::new ( |
3176 | scrolled => (new CFClient::UI::Table col_expand => [0, 1, 0]), |
3185 | child => (new CFClient::UI::Table col_expand => [0, 1, 0]), |
3177 | @_, |
3186 | @_, |
3178 | ); |
3187 | ); |
3179 | |
3188 | |
3180 | $self |
3189 | $self |
3181 | } |
3190 | } |
3182 | |
3191 | |
3183 | sub set_items { |
3192 | sub set_items { |
3184 | my ($self, $items) = @_; |
3193 | my ($self, $items) = @_; |
3185 | |
3194 | |
3186 | $self->{scrolled}->clear; |
3195 | $self->{child}->clear; |
3187 | return unless $items; |
3196 | return unless $items; |
3188 | |
3197 | |
3189 | my @items = sort { |
3198 | my @items = sort { |
3190 | ($a->{type} <=> $b->{type}) |
3199 | ($a->{type} <=> $b->{type}) |
3191 | or ($a->{name} cmp $b->{name}) |
3200 | or ($a->{name} cmp $b->{name}) |
… | |
… | |
3195 | |
3204 | |
3196 | my $row = 0; |
3205 | my $row = 0; |
3197 | for my $item (@items) { |
3206 | for my $item (@items) { |
3198 | CFClient::Item::update_widgets $item; |
3207 | CFClient::Item::update_widgets $item; |
3199 | |
3208 | |
3200 | $self->{scrolled}->add (0, $row, $item->{face_widget}); |
3209 | $self->{child}->add (0, $row, $item->{face_widget}); |
3201 | $self->{scrolled}->add (1, $row, $item->{desc_widget}); |
3210 | $self->{child}->add (1, $row, $item->{desc_widget}); |
3202 | $self->{scrolled}->add (2, $row, $item->{weight_widget}); |
3211 | $self->{child}->add (2, $row, $item->{weight_widget}); |
3203 | |
3212 | |
3204 | $row++; |
3213 | $row++; |
3205 | } |
3214 | } |
3206 | } |
3215 | } |
3207 | |
3216 | |
… | |
… | |
3404 | |
3413 | |
3405 | ############################################################################# |
3414 | ############################################################################# |
3406 | |
3415 | |
3407 | package CFClient::UI::SpellList; |
3416 | package CFClient::UI::SpellList; |
3408 | |
3417 | |
3409 | our @ISA = CFClient::UI::ScrolledWindow::; |
3418 | our @ISA = CFClient::UI::Table::; |
3410 | |
3419 | |
3411 | sub new { |
3420 | sub new { |
3412 | my $class = shift; |
3421 | my $class = shift; |
3413 | |
3422 | |
3414 | my $self = $class->SUPER::new ( |
3423 | my $self = $class->SUPER::new ( |
3415 | binding => [], |
3424 | binding => [], |
3416 | commands => [], |
3425 | commands => [], |
3417 | scrolled => (new CFClient::UI::Table), |
|
|
3418 | @_, |
3426 | @_, |
3419 | ) |
3427 | ) |
3420 | } |
3428 | } |
3421 | |
3429 | |
3422 | # XXX: Do sorting? Argl... |
3430 | # XXX: Do sorting? Argl... |
3423 | sub add_spell { |
3431 | sub add_spell { |
3424 | my ($self, $spell) = @_; |
3432 | my ($self, $spell) = @_; |
3425 | $self->{spells}->{$spell->{name}} = $spell; |
3433 | $self->{spells}->{$spell->{name}} = $spell; |
3426 | |
3434 | |
3427 | $self->{scrolled}->add (0, $self->{tbl_idx}, new CFClient::UI::Face |
3435 | $self->add (0, $self->{tbl_idx}, new CFClient::UI::Face |
3428 | face => $spell->{face}, |
3436 | face => $spell->{face}, |
3429 | can_hover => 1, |
3437 | can_hover => 1, |
3430 | can_events => 1, |
3438 | can_events => 1, |
3431 | tooltip => $spell->{message}); |
3439 | tooltip => $spell->{message}); |
3432 | |
3440 | |
3433 | $self->{scrolled}->add (1, $self->{tbl_idx}, new CFClient::UI::Label |
3441 | $self->add (1, $self->{tbl_idx}, new CFClient::UI::Label |
3434 | text => $spell->{name}, |
3442 | text => $spell->{name}, |
3435 | can_hover => 1, |
3443 | can_hover => 1, |
3436 | can_events => 1, |
3444 | can_events => 1, |
3437 | tooltip => $spell->{message}, |
3445 | tooltip => $spell->{message}, |
3438 | expand => 1); |
3446 | expand => 1); |
3439 | |
3447 | |
3440 | $self->{scrolled}->add (2, $self->{tbl_idx}, new CFClient::UI::Label |
3448 | $self->add (2, $self->{tbl_idx}, new CFClient::UI::Label |
3441 | text => (sprintf "lvl: %2d sp: %2d dmg: %2d", |
3449 | text => (sprintf "lvl: %2d sp: %2d dmg: %2d", |
3442 | $spell->{level}, ($spell->{mana} || $spell->{grace}), $spell->{damage}), |
3450 | $spell->{level}, ($spell->{mana} || $spell->{grace}), $spell->{damage}), |
3443 | expand => 1); |
3451 | expand => 1); |
3444 | |
3452 | |
3445 | $self->{scrolled}->add (3, $self->{tbl_idx}++, new CFClient::UI::Button |
3453 | $self->add (3, $self->{tbl_idx}++, new CFClient::UI::Button |
3446 | text => "bind to key", |
3454 | text => "bind to key", |
3447 | on_activate => sub { $::BIND_EDITOR->do_quick_binding (["cast $spell->{name}"]) }); |
3455 | on_activate => sub { $::BIND_EDITOR->do_quick_binding (["cast $spell->{name}"]) }); |
3448 | } |
3456 | } |
3449 | |
3457 | |
3450 | sub rebuild_spell_list { |
3458 | sub rebuild_spell_list { |