… | |
… | |
1522 | } |
1522 | } |
1523 | |
1523 | |
1524 | sub size_allocate { |
1524 | sub size_allocate { |
1525 | my ($self, $w, $h) = @_; |
1525 | my ($self, $w, $h) = @_; |
1526 | |
1526 | |
1527 | delete $self->{texture}; |
1527 | delete $self->{texture} |
|
|
1528 | ;#d# |
1528 | } |
1529 | } |
1529 | |
1530 | |
1530 | sub set_fontsize { |
1531 | sub set_fontsize { |
1531 | my ($self, $fontsize) = @_; |
1532 | my ($self, $fontsize) = @_; |
1532 | |
1533 | |
… | |
… | |
3210 | $self->_draw; |
3211 | $self->_draw; |
3211 | } |
3212 | } |
3212 | |
3213 | |
3213 | ############################################################################# |
3214 | ############################################################################# |
3214 | |
3215 | |
|
|
3216 | package CFClient::UI::SpellList; |
|
|
3217 | |
|
|
3218 | our @ISA = CFClient::UI::FancyFrame::; |
|
|
3219 | |
|
|
3220 | sub new { |
|
|
3221 | my $class = shift; |
|
|
3222 | |
|
|
3223 | my $self = $class->SUPER::new (binding => [], commands => [], @_); |
|
|
3224 | |
|
|
3225 | $self->add (new CFClient::UI::ScrolledWindow |
|
|
3226 | scrolled => $self->{spellbox} = new CFClient::UI::Table); |
|
|
3227 | |
|
|
3228 | $self; |
|
|
3229 | } |
|
|
3230 | |
|
|
3231 | # XXX: Do sorting? Argl... |
|
|
3232 | sub add_spell { |
|
|
3233 | my ($self, $spell) = @_; |
|
|
3234 | $self->{spells}->{$spell->{name}} = $spell; |
|
|
3235 | |
|
|
3236 | $self->{spellbox}->add (0, $self->{tbl_idx}, new CFClient::UI::Face |
|
|
3237 | face => $spell->{face}, |
|
|
3238 | can_hover => 1, |
|
|
3239 | can_events => 1, |
|
|
3240 | tooltip => $spell->{message}); |
|
|
3241 | |
|
|
3242 | $self->{spellbox}->add (1, $self->{tbl_idx}, new CFClient::UI::Label |
|
|
3243 | text => $spell->{name}, |
|
|
3244 | can_hover => 1, |
|
|
3245 | can_events => 1, |
|
|
3246 | tooltip => $spell->{message}, |
|
|
3247 | expand => 1); |
|
|
3248 | |
|
|
3249 | $self->{spellbox}->add (2, $self->{tbl_idx}, new CFClient::UI::Label |
|
|
3250 | text => (sprintf "lvl: %2d sp: %2d dmg: %2d", |
|
|
3251 | $spell->{level}, ($spell->{mana} || $spell->{grace}), $spell->{damage}), |
|
|
3252 | expand => 1); |
|
|
3253 | |
|
|
3254 | $self->{spellbox}->add (3, $self->{tbl_idx}++, new CFClient::UI::Button |
|
|
3255 | text => "bind to key", |
|
|
3256 | on_activate => sub { $::BIND_EDITOR->do_quick_binding (["cast $spell->{name}"]) }); |
|
|
3257 | } |
|
|
3258 | |
|
|
3259 | sub rebuild_spell_list { |
|
|
3260 | my ($self) = @_; |
|
|
3261 | $self->{tbl_idx} = 0; |
|
|
3262 | $self->add_spell ($_) for values %{$self->{spells}}; |
|
|
3263 | } |
|
|
3264 | |
|
|
3265 | sub remove_spell { |
|
|
3266 | my ($self, $spell) = @_; |
|
|
3267 | delete $self->{spells}->{$spell->{name}}; |
|
|
3268 | $self->rebuild_spell_list; |
|
|
3269 | } |
|
|
3270 | |
|
|
3271 | ############################################################################# |
|
|
3272 | |
3215 | package CFClient::UI::BindEditor; |
3273 | package CFClient::UI::BindEditor; |
3216 | |
3274 | |
3217 | our @ISA = CFClient::UI::FancyFrame::; |
3275 | our @ISA = CFClient::UI::FancyFrame::; |
3218 | |
3276 | |
3219 | sub new { |
3277 | sub new { |
… | |
… | |
3400 | |
3458 | |
3401 | $idx++ |
3459 | $idx++ |
3402 | } |
3460 | } |
3403 | } |
3461 | } |
3404 | |
3462 | |
3405 | |
|
|
3406 | ############################################################################# |
|
|
3407 | |
|
|
3408 | package CFClient::UI::SpellList; |
|
|
3409 | |
|
|
3410 | our @ISA = CFClient::UI::FancyFrame::; |
|
|
3411 | |
|
|
3412 | sub new { |
|
|
3413 | my $class = shift; |
|
|
3414 | |
|
|
3415 | my $self = $class->SUPER::new (binding => [], commands => [], @_); |
|
|
3416 | |
|
|
3417 | $self->add (new CFClient::UI::ScrolledWindow |
|
|
3418 | scrolled => $self->{spellbox} = new CFClient::UI::Table); |
|
|
3419 | |
|
|
3420 | $self; |
|
|
3421 | } |
|
|
3422 | |
|
|
3423 | # XXX: Do sorting? Argl... |
|
|
3424 | sub add_spell { |
|
|
3425 | my ($self, $spell) = @_; |
|
|
3426 | $self->{spells}->{$spell->{name}} = $spell; |
|
|
3427 | |
|
|
3428 | $self->{spellbox}->add (0, $self->{tbl_idx}, new CFClient::UI::Face |
|
|
3429 | face => $spell->{face}, |
|
|
3430 | can_hover => 1, |
|
|
3431 | can_events => 1, |
|
|
3432 | tooltip => $spell->{message}); |
|
|
3433 | |
|
|
3434 | $self->{spellbox}->add (1, $self->{tbl_idx}, new CFClient::UI::Label |
|
|
3435 | text => $spell->{name}, |
|
|
3436 | can_hover => 1, |
|
|
3437 | can_events => 1, |
|
|
3438 | tooltip => $spell->{message}, |
|
|
3439 | expand => 1); |
|
|
3440 | |
|
|
3441 | $self->{spellbox}->add (2, $self->{tbl_idx}, new CFClient::UI::Label |
|
|
3442 | text => (sprintf "lvl: %2d sp: %2d dmg: %2d", |
|
|
3443 | $spell->{level}, ($spell->{mana} || $spell->{grace}), $spell->{damage}), |
|
|
3444 | expand => 1); |
|
|
3445 | |
|
|
3446 | $self->{spellbox}->add (3, $self->{tbl_idx}++, new CFClient::UI::Button |
|
|
3447 | text => "bind to key", |
|
|
3448 | on_activate => sub { $::BIND_EDITOR->do_quick_binding (["cast $spell->{name}"]) }); |
|
|
3449 | } |
|
|
3450 | |
|
|
3451 | sub rebuild_spell_list { |
|
|
3452 | my ($self) = @_; |
|
|
3453 | $self->{tbl_idx} = 0; |
|
|
3454 | $self->add_spell ($_) for values %{$self->{spells}}; |
|
|
3455 | } |
|
|
3456 | |
|
|
3457 | sub remove_spell { |
|
|
3458 | my ($self, $spell) = @_; |
|
|
3459 | delete $self->{spells}->{$spell->{name}}; |
|
|
3460 | $self->rebuild_spell_list; |
|
|
3461 | } |
|
|
3462 | |
|
|
3463 | ############################################################################# |
3463 | ############################################################################# |
3464 | |
3464 | |
3465 | package CFClient::UI; |
3465 | package CFClient::UI; |
3466 | |
3466 | |
3467 | $ROOT = new CFClient::UI::Root; |
3467 | $ROOT = new CFClient::UI::Root; |