ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/UI.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/UI.pm (file contents):
Revision 1.286 by root, Mon Jun 5 03:48:49 2006 UTC vs.
Revision 1.301 by elmex, Mon Jun 12 12:28:06 2006 UTC

315} 315}
316 316
317sub move_abs { 317sub move_abs {
318 my ($self, $x, $y, $z) = @_; 318 my ($self, $x, $y, $z) = @_;
319 319
320 $self->{x} = List::Util::max 0, int $x; 320 $self->{x} = List::Util::max 0, List::Util::min $self->{root}{w} - $self->{w}, int $x;
321 $self->{y} = List::Util::max 0, int $y; 321 $self->{y} = List::Util::max 0, List::Util::min $self->{root}{h} - $self->{h}, int $y;
322 $self->{z} = $z if defined $z; 322 $self->{z} = $z if defined $z;
323 323
324 $self->update; 324 $self->update;
325} 325}
326 326
1554 return if $self->{text} eq "T$text"; 1554 return if $self->{text} eq "T$text";
1555 $self->{text} = "T$text"; 1555 $self->{text} = "T$text";
1556 1556
1557 $self->{layout} = new CFClient::Layout if $self->{layout}->is_rgba; 1557 $self->{layout} = new CFClient::Layout if $self->{layout}->is_rgba;
1558 $self->{layout}->set_text ($text); 1558 $self->{layout}->set_text ($text);
1559
1559 delete $self->{req_h}; 1560 delete $self->{size_req};
1560
1561 $self->realloc; 1561 $self->realloc;
1562 $self->update; 1562 $self->update;
1563} 1563}
1564 1564
1565sub set_markup { 1565sub set_markup {
1570 1570
1571 my $rgba = $markup =~ /span.*(?:foreground|background)/; 1571 my $rgba = $markup =~ /span.*(?:foreground|background)/;
1572 1572
1573 $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;
1574 $self->{layout}->set_markup ($markup); 1574 $self->{layout}->set_markup ($markup);
1575
1575 delete $self->{req_h}; 1576 delete $self->{size_req};
1576
1577 $self->realloc; 1577 $self->realloc;
1578 $self->update; 1578 $self->update;
1579} 1579}
1580 1580
1581sub size_request { 1581sub size_request {
1582 my ($self) = @_; 1582 my ($self) = @_;
1583 1583
1584 if (exists $self->{req_h}) { 1584 $self->{size_req} ||= do {
1585 @$self{qw(req_w req_h)}
1586 } else {
1587 $self->{layout}->set_font ($self->{font}) if $self->{font}; 1585 $self->{layout}->set_font ($self->{font}) if $self->{font};
1588 $self->{layout}->set_width ($self->{max_w} || -1); 1586 $self->{layout}->set_width ($self->{max_w} || -1);
1589 $self->{layout}->set_ellipsise ($self->{ellipsise}); 1587 $self->{layout}->set_ellipsise ($self->{ellipsise});
1590 $self->{layout}->set_single_paragraph_mode ($self->{ellipsise}); 1588 $self->{layout}->set_single_paragraph_mode ($self->{ellipsise});
1591 $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE); 1589 $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE);
1600 1598
1601 $w = List::Util::max $w, $w2; 1599 $w = List::Util::max $w, $w2;
1602 $h = List::Util::max $h, $h2; 1600 $h = List::Util::max $h, $h2;
1603 } 1601 }
1604 1602
1605 ($w, $h) 1603 [$w, $h]
1606 } 1604 };
1605
1606 @{ $self->{size_req} }
1607} 1607}
1608 1608
1609sub size_allocate { 1609sub size_allocate {
1610 my ($self, $w, $h) = @_; 1610 my ($self, $w, $h) = @_;
1611 1611
1620 1620
1621 $self->{fontsize} = $fontsize; 1621 $self->{fontsize} = $fontsize;
1622 delete $self->{texture}; 1622 delete $self->{texture};
1623 1623
1624 $self->realloc; 1624 $self->realloc;
1625}
1626
1627sub reconfigure {
1628 my ($self) = @_;
1629
1630 delete $self->{size_req};
1631
1632 $self->SUPER::reconfigure;
1625} 1633}
1626 1634
1627sub _draw { 1635sub _draw {
1628 my ($self) = @_; 1636 my ($self) = @_;
1629 1637
1649 : $self->{valign} > 0 ? $self->{h} - $tex->{h} - $self->{padding_y} 1657 : $self->{valign} > 0 ? $self->{h} - $tex->{h} - $self->{padding_y}
1650 : ($self->{h} - $tex->{h}) * 0.5); 1658 : ($self->{h} - $tex->{h}) * 0.5);
1651 }; 1659 };
1652 1660
1653 glEnable GL_TEXTURE_2D; 1661 glEnable GL_TEXTURE_2D;
1654 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; 1662
1663 my $w = List::Util::min $self->{w} + 4, $tex->{w};
1664 my $h = List::Util::min $self->{h} + 2, $tex->{h};
1655 1665
1656 if ($tex->{format} == GL_ALPHA) { 1666 if ($tex->{format} == GL_ALPHA) {
1667 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE;
1657 glColor @{$self->{fg}}; 1668 glColor @{$self->{fg}};
1658 $tex->draw_quad_alpha ($self->{ox}, $self->{oy}); 1669 $tex->draw_quad_alpha ($self->{ox}, $self->{oy}, $w, $h);
1659 } else { 1670 } else {
1671 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
1660 $tex->draw_quad_alpha_premultiplied ($self->{ox}, $self->{oy}); 1672 $tex->draw_quad_alpha_premultiplied ($self->{ox}, $self->{oy}, $w, $h);
1661 } 1673 }
1662 1674
1663 glDisable GL_TEXTURE_2D; 1675 glDisable GL_TEXTURE_2D;
1664} 1676}
1665 1677
1682 can_hover => 1, 1694 can_hover => 1,
1683 can_focus => 1, 1695 can_focus => 1,
1684 valign => 0, 1696 valign => 0,
1685 can_events => 1, 1697 can_events => 1,
1686 #text => ... 1698 #text => ...
1699 #hidden => "*",
1687 @_ 1700 @_
1688 ) 1701 )
1689} 1702}
1690 1703
1691sub _set_text { 1704sub _set_text {
1698 $self->{last_activity} = $::NOW; 1711 $self->{last_activity} = $::NOW;
1699 $self->{text} = $text; 1712 $self->{text} = $text;
1700 1713
1701 $text =~ s/./*/g if $self->{hidden}; 1714 $text =~ s/./*/g if $self->{hidden};
1702 $self->{layout}->set_text ("$text "); 1715 $self->{layout}->set_text ("$text ");
1703 delete $self->{req_h}; 1716 delete $self->{size_req};
1704 1717
1705 $self->_emit (changed => $self->{text}); 1718 $self->_emit (changed => $self->{text});
1706 1719
1707 $self->realloc; 1720 $self->realloc;
1708 $self->update; 1721 $self->update;
2294sub set_range { 2307sub set_range {
2295 my ($self, $range) = @_; 2308 my ($self, $range) = @_;
2296 2309
2297 ($range, $self->{range}) = ($self->{range}, $range); 2310 ($range, $self->{range}) = ($self->{range}, $range);
2298 2311
2299 $self->update
2300 if "@$range" ne "@{$self->{range}}"; 2312 if ("@$range" ne "@{$self->{range}}") {
2313 $self->update;
2314 $self->set_value ($self->{range}[0]);
2315 }
2301} 2316}
2302 2317
2303sub set_value { 2318sub set_value {
2304 my ($self, $value) = @_; 2319 my ($self, $value) = @_;
2305 2320
2452sub set_range { shift->{slider}->set_range (@_) } 2467sub set_range { shift->{slider}->set_range (@_) }
2453sub set_value { shift->{slider}->set_value (@_) } 2468sub set_value { shift->{slider}->set_value (@_) }
2454 2469
2455############################################################################# 2470#############################################################################
2456 2471
2457package CFClient::UI::TextView; 2472package CFClient::UI::TextScroller;
2458 2473
2459our @ISA = CFClient::UI::HBox::; 2474our @ISA = CFClient::UI::HBox::;
2460 2475
2461use CFClient::OpenGL; 2476use CFClient::OpenGL;
2462 2477
2464 my $class = shift; 2479 my $class = shift;
2465 2480
2466 my $self = $class->SUPER::new ( 2481 my $self = $class->SUPER::new (
2467 fontsize => 1, 2482 fontsize => 1,
2468 can_events => 0, 2483 can_events => 0,
2484 indent => 0,
2469 #font => default_font 2485 #font => default_font
2470 @_, 2486 @_,
2471 2487
2472 layout => (new CFClient::Layout 1), 2488 layout => (new CFClient::Layout 1),
2473 par => [], 2489 par => [],
2496 $self->SUPER::size_allocate ($w, $h); 2512 $self->SUPER::size_allocate ($w, $h);
2497 2513
2498 $self->{layout}->set_font ($self->{font}) if $self->{font}; 2514 $self->{layout}->set_font ($self->{font}) if $self->{font};
2499 $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE); 2515 $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE);
2500 $self->{layout}->set_width ($self->{children}[0]{w}); 2516 $self->{layout}->set_width ($self->{children}[0]{w});
2517 $self->{layout}->set_indent ($self->{fontsize} * $::FONTSIZE * $self->{indent});
2501 2518
2502 $self->reflow; 2519 $self->reflow;
2503} 2520}
2504 2521
2505sub text_size { 2522sub text_size {
2507 2524
2508 my $layout = $self->{layout}; 2525 my $layout = $self->{layout};
2509 2526
2510 $layout->set_height ($self->{fontsize} * $::FONTSIZE); 2527 $layout->set_height ($self->{fontsize} * $::FONTSIZE);
2511 $layout->set_width ($self->{children}[0]{w} - $indent); 2528 $layout->set_width ($self->{children}[0]{w} - $indent);
2529 $layout->set_indent ($self->{fontsize} * $::FONTSIZE * $self->{indent});
2512 $layout->set_markup ($text); 2530 $layout->set_markup ($text);
2513 2531
2514 $layout->size 2532 $layout->size
2515} 2533}
2516 2534
2555 2573
2556 return unless $self->{h} > 0; 2574 return unless $self->{h} > 0;
2557 2575
2558 delete $self->{texture}; 2576 delete $self->{texture};
2559 2577
2560 $ROOT->on_post_alloc ($self, sub { 2578 $ROOT->on_post_alloc ($self => sub {
2561 my ($W, $H) = @{$self->{children}[0]}{qw(w h)}; 2579 my ($W, $H) = @{$self->{children}[0]}{qw(w h)};
2562 2580
2563 if (delete $self->{need_reflow}) { 2581 if (delete $self->{need_reflow}) {
2564 my $height = 0; 2582 my $height = 0;
2565 2583
2568 $layout->set_height ($self->{fontsize} * $::FONTSIZE); 2586 $layout->set_height ($self->{fontsize} * $::FONTSIZE);
2569 2587
2570 for (@{$self->{par}}) { 2588 for (@{$self->{par}}) {
2571 if (1 || $_->[0] >= $W) { # TODO: works,but needs reconfigure etc. support 2589 if (1 || $_->[0] >= $W) { # TODO: works,but needs reconfigure etc. support
2572 $layout->set_width ($W - $_->[3]); 2590 $layout->set_width ($W - $_->[3]);
2591 $layout->set_indent ($self->{fontsize} * $::FONTSIZE * $self->{indent});
2573 $layout->set_markup ($_->[4]); 2592 $layout->set_markup ($_->[4]);
2574 my ($w, $h) = $layout->size; 2593 my ($w, $h) = $layout->size;
2575 $_->[0] = $w + $_->[3]; 2594 $_->[0] = $w + $_->[3];
2576 $_->[1] = $h; 2595 $_->[1] = $h;
2577 } 2596 }
2580 } 2599 }
2581 2600
2582 $self->{height} = $height; 2601 $self->{height} = $height;
2583 2602
2584 $self->{children}[1]->set_range ([$height, 0, $height, $H, 1]); 2603 $self->{children}[1]->set_range ([$height, 0, $height, $H, 1]);
2585 2604
2586 delete $self->{texture}; 2605 delete $self->{texture};
2587 } 2606 }
2588 2607
2589 $self->{texture} ||= new_from_opengl CFClient::Texture $W, $H, sub { 2608 $self->{texture} ||= new_from_opengl CFClient::Texture $W, $H, sub {
2590 glClearColor 0, 0, 0, 0; 2609 glClearColor 0, 0, 0, 0;
2609 my $h = $par->[1]; 2628 my $h = $par->[1];
2610 2629
2611 if ($y0 < $y + $h && $y < $y1) { 2630 if ($y0 < $y + $h && $y < $y1) {
2612 $layout->set_foreground (@{ $par->[2] }); 2631 $layout->set_foreground (@{ $par->[2] });
2613 $layout->set_width ($W - $par->[3]); 2632 $layout->set_width ($W - $par->[3]);
2633 $layout->set_indent ($self->{fontsize} * $::FONTSIZE * $self->{indent});
2614 $layout->set_markup ($par->[4]); 2634 $layout->set_markup ($par->[4]);
2615 2635
2616 my ($w, $h, $data, $format, $internalformat) = $layout->render; 2636 my ($w, $h, $data, $format, $internalformat) = $layout->render;
2617 2637
2618 glRasterPos $par->[3], $y - $y0; 2638 glRasterPos $par->[3], $y - $y0;
2732 $tooltip .= "\n\n" . (ref $widget) . "\n" 2752 $tooltip .= "\n\n" . (ref $widget) . "\n"
2733 . "$widget->{x} $widget->{y} $widget->{w} $widget->{h}\n" 2753 . "$widget->{x} $widget->{y} $widget->{w} $widget->{h}\n"
2734 . "req $widget->{req_w} $widget->{req_h}\n" 2754 . "req $widget->{req_w} $widget->{req_h}\n"
2735 . "visible $widget->{visible}"; 2755 . "visible $widget->{visible}";
2736 } 2756 }
2757
2758 $tooltip =~ s/^\n+//;
2759 $tooltip =~ s/\n+$//;
2737 2760
2738 $self->add (new CFClient::UI::Label 2761 $self->add (new CFClient::UI::Label
2739 markup => $tooltip, 2762 markup => $tooltip,
2740 max_w => ($widget->{tooltip_width} || 0.25) * $::WIDTH, 2763 max_w => ($widget->{tooltip_width} || 0.25) * $::WIDTH,
2741 fontsize => 0.8, 2764 fontsize => 0.8,
2769 or return; 2792 or return;
2770 2793
2771 my ($x, $y) = $widget->coord2global ($widget->{w}, 0); 2794 my ($x, $y) = $widget->coord2global ($widget->{w}, 0);
2772 2795
2773 ($x, $y) = $widget->coord2global (-$self->{w}, 0) 2796 ($x, $y) = $widget->coord2global (-$self->{w}, 0)
2774 if $x + $self->{w} > $::WIDTH; 2797 if $x + $self->{w} > $self->{root}{w};
2775 2798
2776 $self->move_abs ($x, $y); 2799 $self->move_abs ($x, $y);
2777 }); 2800 });
2778} 2801}
2779 2802
2911 ); 2934 );
2912 2935
2913 $self->add ($self->{vbox} = new CFClient::UI::VBox); 2936 $self->add ($self->{vbox} = new CFClient::UI::VBox);
2914 2937
2915 for my $item (@{ $self->{items} }) { 2938 for my $item (@{ $self->{items} }) {
2916 my ($widget, $cb) = @$item; 2939 my ($widget, $cb, $tooltip) = @$item;
2917 2940
2918 # handle various types of items, only text for now 2941 # handle various types of items, only text for now
2919 if (!ref $widget) { 2942 if (!ref $widget) {
2920 $widget = new CFClient::UI::Label 2943 $widget = new CFClient::UI::Label
2921 can_hover => 1, 2944 can_hover => 1,
2922 can_events => 1, 2945 can_events => 1,
2923 text => $widget; 2946 markup => $widget,
2947 tooltip => $tooltip
2924 } 2948 }
2925 2949
2926 $self->{item}{$widget} = $item; 2950 $self->{item}{$widget} = $item;
2927 2951
2928 $self->{vbox}->add ($widget); 2952 $self->{vbox}->add ($widget);
3075sub set_current_page { 3099sub set_current_page {
3076 my ($self, $page) = @_; 3100 my ($self, $page) = @_;
3077 3101
3078 $self->{multiplexer}->set_current_page ($page); 3102 $self->{multiplexer}->set_current_page ($page);
3079 $self->_emit (page_changed => $self->{multiplexer}{current}); 3103 $self->_emit (page_changed => $self->{multiplexer}{current});
3104}
3105
3106#############################################################################
3107
3108package CFClient::UI::Combobox;
3109
3110use utf8;
3111
3112our @ISA = CFClient::UI::Button::;
3113
3114sub new {
3115 my $class = shift;
3116
3117 my $self = $class->SUPER::new (
3118 options => [], # [value, title, longdesc], ...
3119 value => undef,
3120 @_,
3121 );
3122
3123 $self->_set_value ($self->{value});
3124
3125 $self
3126}
3127
3128sub button_down {
3129 my ($self, $ev) = @_;
3130
3131 my @menu_items;
3132
3133 for (@{ $self->{options} }) {
3134 my ($value, $title, $tooltip) = @$_;
3135
3136 push @menu_items, [$tooltip || $title, sub { $self->set_value ($value) }];
3137 }
3138
3139 CFClient::UI::Menu->new (items => \@menu_items)->popup ($ev);
3140}
3141
3142sub _set_value {
3143 my ($self, $value) = @_;
3144
3145 my ($item) = grep $_->[0] eq $value, @{ $self->{options} }
3146 or return;
3147
3148 $self->{value} = $item->[0];
3149 $self->set_markup ("$item->[1] ⇓");
3150 $self->set_tooltip ($item->[2]);
3151}
3152
3153sub set_value {
3154 my ($self, $value) = @_;
3155
3156 return unless $self->{value} ne $value;
3157
3158 $self->_set_value ($value);
3159 $self->_emit (changed => $value);
3080} 3160}
3081 3161
3082############################################################################# 3162#############################################################################
3083 3163
3084package CFClient::UI::Statusbox; 3164package CFClient::UI::Statusbox;
3183 $item->{count}++; 3263 $item->{count}++;
3184 } else { 3264 } else {
3185 $item->{count} = 1; 3265 $item->{count} = 1;
3186 $item->{text} = $item->{tooltip} = $text; 3266 $item->{text} = $item->{tooltip} = $text;
3187 } 3267 }
3188 $item->{id} = ++$self->{id}; 3268 $item->{id} += 0.2;#d#
3189 $item->{timeout} = $timeout; 3269 $item->{timeout} = $timeout;
3190 delete $item->{label}; 3270 delete $item->{label};
3191 } else { 3271 } else {
3192 $self->{item}{$group} = { 3272 $self->{item}{$group} = {
3193 id => ++$self->{id}, 3273 id => ++$self->{id},
3475 commands => [], 3555 commands => [],
3476 @_, 3556 @_,
3477 ) 3557 )
3478} 3558}
3479 3559
3480# XXX: Do sorting? Argl... 3560my $TOOLTIP_ALL = "\n\n<small>Left click - ready spell\nMiddle click - invoke spell\nRight click - further options</small>";
3561
3562my @TOOLTIP_NAME = (align => -1, can_events => 1, can_hover => 1, tooltip =>
3563 "<b>Name</b>. The name of the spell.$TOOLTIP_ALL");
3564my @TOOLTIP_SKILL = (align => -1, can_events => 1, can_hover => 1, tooltip =>
3565 "<b>Skill</b>. The skill (or magic school) required to be able to attempt casting this spell.$TOOLTIP_ALL");
3566my @TOOLTIP_LVL = (align => 1, can_events => 1, can_hover => 1, tooltip =>
3567 "<b>Level</b>. Minimum level the caster needs in the associated skill to be able to attempt casting this spell.$TOOLTIP_ALL");
3568my @TOOLTIP_SP = (align => 1, can_events => 1, can_hover => 1, tooltip =>
3569 "<b>Spell points / Grace points</b>. Amount of spell or grace points used by each invocation.$TOOLTIP_ALL");
3570my @TOOLTIP_DMG = (align => 1, can_events => 1, can_hover => 1, tooltip =>
3571 "<b>Damage</b>. The amount of damage the spell deals when it hits.$TOOLTIP_ALL");
3572
3573sub rebuild_spell_list {
3574 my ($self) = @_;
3575
3576 $CFClient::UI::ROOT->on_refresh ($self => sub {
3577 $self->clear;
3578
3579 $self->add (1, 0, new CFClient::UI::Label text => "Spell Name", @TOOLTIP_NAME);
3580 $self->add (2, 0, new CFClient::UI::Label text => "Skill", @TOOLTIP_SKILL);
3581 $self->add (3, 0, new CFClient::UI::Label text => "Lvl" , @TOOLTIP_LVL);
3582 $self->add (4, 0, new CFClient::UI::Label text => "Sp/Gp", @TOOLTIP_SP);
3583 $self->add (5, 0, new CFClient::UI::Label text => "Dmg" , @TOOLTIP_DMG);
3584
3585 my $row = 0;
3586
3587 for (sort { $a cmp $b } keys %{ $self->{spell} }) {
3588 my $spell = $self->{spell}{$_};
3589
3590 $row++;
3591
3592 my $spell_cb = sub {
3593 my ($widget, $ev) = @_;
3594
3595 if ($ev->{button} == 1) {
3596 $::CONN->user_send ("cast $spell->{name}");
3597 } elsif ($ev->{button} == 2) {
3598 $::CONN->user_send ("invoke $spell->{name}");
3599 } elsif ($ev->{button} == 3) {
3600 (new CFClient::UI::Menu
3601 items => [
3602 ["bind <i>cast $spell->{name}</i> to a key" => sub { $::BIND_EDITOR->do_quick_binding (["cast $spell->{name}"]) }],
3603 ["bind <i>invoke $spell->{name}</i> to a key" => sub { $::BIND_EDITOR->do_quick_binding (["invoke $spell->{name}"]) }],
3604 ],
3605 )->popup ($ev);
3606 } else {
3607 return 0;
3608 }
3609
3610 1
3611 };
3612
3613 my $tooltip = "$spell->{message}$TOOLTIP_ALL";
3614
3615 #TODO: add path info to tooltip
3616 #$self->add (6, $row, new CFClient::UI::Label text => $spell->{path});
3617
3618 $self->add (0, $row, new CFClient::UI::Face
3619 face => $spell->{face},
3620 can_hover => 1,
3621 can_events => 1,
3622 tooltip => $tooltip,
3623 on_button_down => $spell_cb,
3624 );
3625
3626 $self->add (1, $row, new CFClient::UI::Label
3627 expand => 1,
3628 text => $spell->{name},
3629 can_hover => 1,
3630 can_events => 1,
3631 tooltip => $tooltip,
3632 on_button_down => $spell_cb,
3633 );
3634
3635 $self->add (2, $row, new CFClient::UI::Label text => $::CONN->{skill_info}{$spell->{skill}}, @TOOLTIP_SKILL);
3636 $self->add (3, $row, new CFClient::UI::Label text => $spell->{level}, @TOOLTIP_LVL);
3637 $self->add (4, $row, new CFClient::UI::Label text => $spell->{mana} || $spell->{grace}, @TOOLTIP_SP);
3638 $self->add (5, $row, new CFClient::UI::Label text => $spell->{damage}, @TOOLTIP_DMG);
3639 }
3640 });
3641}
3642
3481sub add_spell { 3643sub add_spell {
3482 my ($self, $spell) = @_; 3644 my ($self, $spell) = @_;
3645
3483 $self->{spells}->{$spell->{name}} = $spell; 3646 $self->{spell}->{$spell->{name}} = $spell;
3484 3647 $self->rebuild_spell_list;
3485 $self->add (0, $self->{tbl_idx}, new CFClient::UI::Face
3486 face => $spell->{face},
3487 can_hover => 1,
3488 can_events => 1,
3489 tooltip => $spell->{message});
3490
3491 $self->add (1, $self->{tbl_idx}, new CFClient::UI::Label
3492 text => $spell->{name},
3493 can_hover => 1,
3494 can_events => 1,
3495 tooltip => $spell->{message},
3496 expand => 1);
3497
3498 $self->add (2, $self->{tbl_idx}, new CFClient::UI::Label
3499 text => (sprintf "lvl: %2d sp: %2d dmg: %2d",
3500 $spell->{level}, ($spell->{mana} || $spell->{grace}), $spell->{damage}),
3501 expand => 1);
3502
3503 $self->add (3, $self->{tbl_idx}++, new CFClient::UI::Button
3504 text => "bind to key",
3505 on_activate => sub { $::BIND_EDITOR->do_quick_binding (["cast $spell->{name}"]) });
3506}
3507
3508sub rebuild_spell_list {
3509 my ($self) = @_;
3510 $self->{tbl_idx} = 0;
3511 $self->add_spell ($_) for values %{$self->{spells}};
3512} 3648}
3513 3649
3514sub remove_spell { 3650sub remove_spell {
3515 my ($self, $spell) = @_; 3651 my ($self, $spell) = @_;
3652
3516 delete $self->{spells}->{$spell->{name}}; 3653 delete $self->{spell}->{$spell->{name}};
3654 $self->rebuild_spell_list;
3655}
3656
3657sub clear_spells {
3658 my ($self) = @_;
3659
3660 $self->{spell} = {};
3517 $self->rebuild_spell_list; 3661 $self->rebuild_spell_list;
3518} 3662}
3519 3663
3520############################################################################# 3664#############################################################################
3521 3665

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines