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.301 by elmex, Mon Jun 12 12:28:06 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
3260 $item->{count}++; 3263 $item->{count}++;
3261 } else { 3264 } else {
3262 $item->{count} = 1; 3265 $item->{count} = 1;
3263 $item->{text} = $item->{tooltip} = $text; 3266 $item->{text} = $item->{tooltip} = $text;
3264 } 3267 }
3265 $item->{id} = ++$self->{id}; 3268 $item->{id} += 0.2;#d#
3266 $item->{timeout} = $timeout; 3269 $item->{timeout} = $timeout;
3267 delete $item->{label}; 3270 delete $item->{label};
3268 } else { 3271 } else {
3269 $self->{item}{$group} = { 3272 $self->{item}{$group} = {
3270 id => ++$self->{id}, 3273 id => ++$self->{id},
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 => -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");
3557my @TOOLTIP_LVL = (align => 1, can_events => 1, can_hover => 1, tooltip => 3566my @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."); 3567 "<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 => 3568my @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."); 3569 "<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 => 3570my @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."); 3571 "<b>Damage</b>. The amount of damage the spell deals when it hits.$TOOLTIP_ALL");
3563 3572
3564sub rebuild_spell_list { 3573sub rebuild_spell_list {
3565 my ($self) = @_; 3574 my ($self) = @_;
3566 3575
3567 $CFClient::UI::ROOT->on_refresh ($self => sub { 3576 $CFClient::UI::ROOT->on_refresh ($self => sub {
3568 $self->clear; 3577 $self->clear;
3569 3578
3570 $self->add (1, 0, new CFClient::UI::Label text => "Spell Name"); 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);
3571 $self->add (2, 0, new CFClient::UI::Label text => "Lvl" , @TOOLTIP_LVL); 3581 $self->add (3, 0, new CFClient::UI::Label text => "Lvl" , @TOOLTIP_LVL);
3572 $self->add (3, 0, new CFClient::UI::Label text => "Sp/Gp", @TOOLTIP_SP); 3582 $self->add (4, 0, new CFClient::UI::Label text => "Sp/Gp", @TOOLTIP_SP);
3573 $self->add (4, 0, new CFClient::UI::Label text => "Dmg" , @TOOLTIP_DMG); 3583 $self->add (5, 0, new CFClient::UI::Label text => "Dmg" , @TOOLTIP_DMG);
3574 3584
3575 my $row = 0; 3585 my $row = 0;
3576 3586
3577 for (sort { $a cmp $b } keys %{ $self->{spell} }) { 3587 for (sort { $a cmp $b } keys %{ $self->{spell} }) {
3578 my $spell = $self->{spell}{$_}; 3588 my $spell = $self->{spell}{$_};
3579 3589
3580 $row++; 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});
3581 3617
3582 $self->add (0, $row, new CFClient::UI::Face 3618 $self->add (0, $row, new CFClient::UI::Face
3583 face => $spell->{face}, 3619 face => $spell->{face},
3584 can_hover => 1, 3620 can_hover => 1,
3585 can_events => 1, 3621 can_events => 1,
3586 tooltip => $spell->{message}, 3622 tooltip => $tooltip,
3623 on_button_down => $spell_cb,
3587 ); 3624 );
3588 3625
3589 $self->add (1, $row, new CFClient::UI::Label 3626 $self->add (1, $row, new CFClient::UI::Label
3590 expand => 1, 3627 expand => 1,
3591 text => $spell->{name}, 3628 text => $spell->{name},
3592 can_hover => 1, 3629 can_hover => 1,
3593 can_events => 1, 3630 can_events => 1,
3594 tooltip => $spell->{message}, 3631 tooltip => $tooltip,
3632 on_button_down => $spell_cb,
3595 ); 3633 );
3596 3634
3635 $self->add (2, $row, new CFClient::UI::Label text => $::CONN->{skill_info}{$spell->{skill}}, @TOOLTIP_SKILL);
3597 $self->add (2, $row, new CFClient::UI::Label text => $spell->{level}, @TOOLTIP_LVL); 3636 $self->add (3, $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); 3637 $self->add (4, $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); 3638 $self->add (5, $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 } 3639 }
3608 }); 3640 });
3609} 3641}
3610 3642
3611sub add_spell { 3643sub add_spell {
3617 3649
3618sub remove_spell { 3650sub remove_spell {
3619 my ($self, $spell) = @_; 3651 my ($self, $spell) = @_;
3620 3652
3621 delete $self->{spell}->{$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} = {};
3622 $self->rebuild_spell_list; 3661 $self->rebuild_spell_list;
3623} 3662}
3624 3663
3625############################################################################# 3664#############################################################################
3626 3665

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines