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.297 by root, Wed Jun 7 06:28:30 2006 UTC vs.
Revision 1.298 by root, Wed Jun 7 07:00:30 2006 UTC

2753 . "$widget->{x} $widget->{y} $widget->{w} $widget->{h}\n" 2753 . "$widget->{x} $widget->{y} $widget->{w} $widget->{h}\n"
2754 . "req $widget->{req_w} $widget->{req_h}\n" 2754 . "req $widget->{req_w} $widget->{req_h}\n"
2755 . "visible $widget->{visible}"; 2755 . "visible $widget->{visible}";
2756 } 2756 }
2757 2757
2758 $tooltip =~ s/^\n+//;
2759 $tooltip =~ s/\n+$//;
2760
2758 $self->add (new CFClient::UI::Label 2761 $self->add (new CFClient::UI::Label
2759 markup => $tooltip, 2762 markup => $tooltip,
2760 max_w => ($widget->{tooltip_width} || 0.25) * $::WIDTH, 2763 max_w => ($widget->{tooltip_width} || 0.25) * $::WIDTH,
2761 fontsize => 0.8, 2764 fontsize => 0.8,
2762 fg => [0, 0, 0, 1], 2765 fg => [0, 0, 0, 1],
2938 # handle various types of items, only text for now 2941 # handle various types of items, only text for now
2939 if (!ref $widget) { 2942 if (!ref $widget) {
2940 $widget = new CFClient::UI::Label 2943 $widget = new CFClient::UI::Label
2941 can_hover => 1, 2944 can_hover => 1,
2942 can_events => 1, 2945 can_events => 1,
2943 text => $widget, 2946 markup => $widget,
2944 tooltip => $tooltip 2947 tooltip => $tooltip
2945 } 2948 }
2946 2949
2947 $self->{item}{$widget} = $item; 2950 $self->{item}{$widget} = $item;
2948 2951
3552 commands => [], 3555 commands => [],
3553 @_, 3556 @_,
3554 ) 3557 )
3555} 3558}
3556 3559
3560my $TOOLTIP_ALL = "\n\n<small>Left click - ready spell\nMiddle click - invoke spell\nRight click - further options</small>";
3561
3562my @TOOLTIP_NAME = (align => 0, can_events => 1, can_hover => 1, tooltip =>
3563 "<b>Name</b>. The name of the spell.$TOOLTIP_ALL");
3557my @TOOLTIP_LVL = (align => 1, can_events => 1, can_hover => 1, tooltip => 3564my @TOOLTIP_LVL = (align => 1, can_events => 1, can_hover => 1, tooltip =>
3558 "<b>Level</b>. Minimum level the caster needs in the associated skill to be able to attempt casting this spell."); 3565 "<b>Level</b>. Minimum level the caster needs in the associated skill to be able to attempt casting this spell.$TOOLTIP_ALL");
3559my @TOOLTIP_SP = (align => 1, can_events => 1, can_hover => 1, tooltip => 3566my @TOOLTIP_SP = (align => 1, can_events => 1, can_hover => 1, tooltip =>
3560 "<b>Spell points / Grace points</b>. Amount of spell or grace points used by each invocation."); 3567 "<b>Spell points / Grace points</b>. Amount of spell or grace points used by each invocation.$TOOLTIP_ALL");
3561my @TOOLTIP_DMG = (align => 1, can_events => 1, can_hover => 1, tooltip => 3568my @TOOLTIP_DMG = (align => 1, can_events => 1, can_hover => 1, tooltip =>
3562 "<b>Damage</b>. The amount of damage the spell deals when it hits."); 3569 "<b>Damage</b>. The amount of damage the spell deals when it hits.$TOOLTIP_ALL");
3563 3570
3564sub rebuild_spell_list { 3571sub rebuild_spell_list {
3565 my ($self) = @_; 3572 my ($self) = @_;
3566 3573
3567 $CFClient::UI::ROOT->on_refresh ($self => sub { 3574 $CFClient::UI::ROOT->on_refresh ($self => sub {
3568 $self->clear; 3575 $self->clear;
3569 3576
3570 $self->add (1, 0, new CFClient::UI::Label text => "Spell Name"); 3577 $self->add (1, 0, new CFClient::UI::Label text => "Spell Name", @TOOLTIP_NAME);
3571 $self->add (2, 0, new CFClient::UI::Label text => "Lvl" , @TOOLTIP_LVL); 3578 $self->add (2, 0, new CFClient::UI::Label text => "Lvl" , @TOOLTIP_LVL);
3572 $self->add (3, 0, new CFClient::UI::Label text => "Sp/Gp", @TOOLTIP_SP); 3579 $self->add (3, 0, new CFClient::UI::Label text => "Sp/Gp", @TOOLTIP_SP);
3573 $self->add (4, 0, new CFClient::UI::Label text => "Dmg" , @TOOLTIP_DMG); 3580 $self->add (4, 0, new CFClient::UI::Label text => "Dmg" , @TOOLTIP_DMG);
3574 3581
3575 my $row = 0; 3582 my $row = 0;
3576 3583
3577 for (sort { $a cmp $b } keys %{ $self->{spell} }) { 3584 for (sort { $a cmp $b } keys %{ $self->{spell} }) {
3578 my $spell = $self->{spell}{$_}; 3585 my $spell = $self->{spell}{$_};
3579 3586
3580 $row++; 3587 $row++;
3588
3589 my $spell_cb = sub {
3590 my ($widget, $ev) = @_;
3591
3592 if ($ev->{button} == 1) {
3593 $::CONN->user_send ("cast $spell->{name}");
3594 } elsif ($ev->{button} == 2) {
3595 $::CONN->user_send ("invoke $spell->{name}");
3596 } elsif ($ev->{button} == 3) {
3597 (new CFClient::UI::Menu
3598 items => [
3599 ["bind <i>cast $spell->{name}</i> to a key" => sub { $::BIND_EDITOR->do_quick_binding (["cast $spell->{name}"]) }],
3600 ["bind <i>invoke $spell->{name}</i> to a key" => sub { $::BIND_EDITOR->do_quick_binding (["invoke $spell->{name}"]) }],
3601 ],
3602 )->popup ($ev);
3603 } else {
3604 return 0;
3605 }
3606
3607 1
3608 };
3581 3609
3582 $self->add (0, $row, new CFClient::UI::Face 3610 $self->add (0, $row, new CFClient::UI::Face
3583 face => $spell->{face}, 3611 face => $spell->{face},
3584 can_hover => 1, 3612 can_hover => 1,
3585 can_events => 1, 3613 can_events => 1,
3586 tooltip => $spell->{message}, 3614 tooltip => $spell->{message},
3615 on_button_down => $spell_cb,
3587 ); 3616 );
3588 3617
3589 $self->add (1, $row, new CFClient::UI::Label 3618 $self->add (1, $row, new CFClient::UI::Label
3590 expand => 1, 3619 expand => 1,
3591 text => $spell->{name}, 3620 text => $spell->{name},
3592 can_hover => 1, 3621 can_hover => 1,
3593 can_events => 1, 3622 can_events => 1,
3594 tooltip => $spell->{message}, 3623 tooltip => "$spell->{message}$TOOLTIP_ALL",
3624 on_button_down => $spell_cb,
3595 ); 3625 );
3596 3626
3597 $self->add (2, $row, new CFClient::UI::Label text => $spell->{level}, @TOOLTIP_LVL); 3627 $self->add (2, $row, new CFClient::UI::Label text => $spell->{level}, @TOOLTIP_LVL);
3598 $self->add (3, $row, new CFClient::UI::Label text => $spell->{mana} || $spell->{grace}, @TOOLTIP_SP); 3628 $self->add (3, $row, new CFClient::UI::Label text => $spell->{mana} || $spell->{grace}, @TOOLTIP_SP);
3599 $self->add (4, $row, new CFClient::UI::Label text => $spell->{damage}, @TOOLTIP_DMG); 3629 $self->add (4, $row, new CFClient::UI::Label text => $spell->{damage}, @TOOLTIP_DMG);
3600
3601 # TODO: should be done via popup
3602 $self->add (5, $row, new CFClient::UI::Button
3603 text => "bind",
3604 tooltip => "bind spell readying (cast command) to key",
3605 on_activate => sub { $::BIND_EDITOR->do_quick_binding (["cast $spell->{name}"]) },
3606 );
3607 } 3630 }
3608 }); 3631 });
3609} 3632}
3610 3633
3611sub add_spell { 3634sub add_spell {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines