--- deliantra/Deliantra-Client/DC/UI.pm 2006/06/06 03:05:16 1.293
+++ deliantra/Deliantra-Client/DC/UI.pm 2006/06/12 12:28:06 1.301
@@ -317,8 +317,8 @@
sub move_abs {
my ($self, $x, $y, $z) = @_;
- $self->{x} = List::Util::max 0, int $x;
- $self->{y} = List::Util::max 0, int $y;
+ $self->{x} = List::Util::max 0, List::Util::min $self->{root}{w} - $self->{w}, int $x;
+ $self->{y} = List::Util::max 0, List::Util::min $self->{root}{h} - $self->{h}, int $y;
$self->{z} = $z if defined $z;
$self->update;
@@ -1660,13 +1660,16 @@
glEnable GL_TEXTURE_2D;
+ my $w = List::Util::min $self->{w} + 4, $tex->{w};
+ my $h = List::Util::min $self->{h} + 2, $tex->{h};
+
if ($tex->{format} == GL_ALPHA) {
glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE;
glColor @{$self->{fg}};
- $tex->draw_quad_alpha ($self->{ox}, $self->{oy});
+ $tex->draw_quad_alpha ($self->{ox}, $self->{oy}, $w, $h);
} else {
glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
- $tex->draw_quad_alpha_premultiplied ($self->{ox}, $self->{oy});
+ $tex->draw_quad_alpha_premultiplied ($self->{ox}, $self->{oy}, $w, $h);
}
glDisable GL_TEXTURE_2D;
@@ -2306,8 +2309,10 @@
($range, $self->{range}) = ($self->{range}, $range);
- $self->update
- if "@$range" ne "@{$self->{range}}";
+ if ("@$range" ne "@{$self->{range}}") {
+ $self->update;
+ $self->set_value ($self->{range}[0]);
+ }
}
sub set_value {
@@ -2464,7 +2469,7 @@
#############################################################################
-package CFClient::UI::TextView;
+package CFClient::UI::TextScroller;
our @ISA = CFClient::UI::HBox::;
@@ -2570,7 +2575,7 @@
delete $self->{texture};
- $ROOT->on_post_alloc ($self, sub {
+ $ROOT->on_post_alloc ($self => sub {
my ($W, $H) = @{$self->{children}[0]}{qw(w h)};
if (delete $self->{need_reflow}) {
@@ -2596,7 +2601,7 @@
$self->{height} = $height;
$self->{children}[1]->set_range ([$height, 0, $height, $H, 1]);
-
+
delete $self->{texture};
}
@@ -2750,6 +2755,9 @@
. "visible $widget->{visible}";
}
+ $tooltip =~ s/^\n+//;
+ $tooltip =~ s/\n+$//;
+
$self->add (new CFClient::UI::Label
markup => $tooltip,
max_w => ($widget->{tooltip_width} || 0.25) * $::WIDTH,
@@ -2786,7 +2794,7 @@
my ($x, $y) = $widget->coord2global ($widget->{w}, 0);
($x, $y) = $widget->coord2global (-$self->{w}, 0)
- if $x + $self->{w} > $::WIDTH;
+ if $x + $self->{w} > $self->{root}{w};
$self->move_abs ($x, $y);
});
@@ -2935,7 +2943,7 @@
$widget = new CFClient::UI::Label
can_hover => 1,
can_events => 1,
- text => $widget,
+ markup => $widget,
tooltip => $tooltip
}
@@ -3107,7 +3115,7 @@
my $class = shift;
my $self = $class->SUPER::new (
- options => [], # [title, value, tooltip], ...
+ options => [], # [value, title, longdesc], ...
value => undef,
@_,
);
@@ -3123,9 +3131,9 @@
my @menu_items;
for (@{ $self->{options} }) {
- my ($title, $value, $tooltip) = @$_;
+ my ($value, $title, $tooltip) = @$_;
- push @menu_items, [$tooltip, sub { $self->set_value ($value) }];
+ push @menu_items, [$tooltip || $title, sub { $self->set_value ($value) }];
}
CFClient::UI::Menu->new (items => \@menu_items)->popup ($ev);
@@ -3134,11 +3142,11 @@
sub _set_value {
my ($self, $value) = @_;
- my ($item) = grep $_->[1] eq $value, @{ $self->{options} }
+ my ($item) = grep $_->[0] eq $value, @{ $self->{options} }
or return;
- $self->{value} = $item->[1];
- $self->set_markup ("$item->[0] ⇓");
+ $self->{value} = $item->[0];
+ $self->set_markup ("$item->[1] ⇓");
$self->set_tooltip ($item->[2]);
}
@@ -3257,7 +3265,7 @@
$item->{count} = 1;
$item->{text} = $item->{tooltip} = $text;
}
- $item->{id} = ++$self->{id};
+ $item->{id} += 0.2;#d#
$item->{timeout} = $timeout;
delete $item->{label};
} else {
@@ -3549,12 +3557,18 @@
)
}
+my $TOOLTIP_ALL = "\n\nLeft click - ready spell\nMiddle click - invoke spell\nRight click - further options";
+
+my @TOOLTIP_NAME = (align => -1, can_events => 1, can_hover => 1, tooltip =>
+ "Name. The name of the spell.$TOOLTIP_ALL");
+my @TOOLTIP_SKILL = (align => -1, can_events => 1, can_hover => 1, tooltip =>
+ "Skill. The skill (or magic school) required to be able to attempt casting this spell.$TOOLTIP_ALL");
my @TOOLTIP_LVL = (align => 1, can_events => 1, can_hover => 1, tooltip =>
- "Level. Minimum level the caster needs in the associated skill to be able to attempt casting this spell.");
+ "Level. Minimum level the caster needs in the associated skill to be able to attempt casting this spell.$TOOLTIP_ALL");
my @TOOLTIP_SP = (align => 1, can_events => 1, can_hover => 1, tooltip =>
- "Spell points / Grace points. Amount of spell or grace points used by each invocation.");
+ "Spell points / Grace points. Amount of spell or grace points used by each invocation.$TOOLTIP_ALL");
my @TOOLTIP_DMG = (align => 1, can_events => 1, can_hover => 1, tooltip =>
- "Damage. The amount of damage the spell deals when it hits.");
+ "Damage. The amount of damage the spell deals when it hits.$TOOLTIP_ALL");
sub rebuild_spell_list {
my ($self) = @_;
@@ -3562,10 +3576,11 @@
$CFClient::UI::ROOT->on_refresh ($self => sub {
$self->clear;
- $self->add (1, 0, new CFClient::UI::Label text => "Spell Name");
- $self->add (2, 0, new CFClient::UI::Label text => "Lvl" , @TOOLTIP_LVL);
- $self->add (3, 0, new CFClient::UI::Label text => "Sp/Gp", @TOOLTIP_SP);
- $self->add (4, 0, new CFClient::UI::Label text => "Dmg" , @TOOLTIP_DMG);
+ $self->add (1, 0, new CFClient::UI::Label text => "Spell Name", @TOOLTIP_NAME);
+ $self->add (2, 0, new CFClient::UI::Label text => "Skill", @TOOLTIP_SKILL);
+ $self->add (3, 0, new CFClient::UI::Label text => "Lvl" , @TOOLTIP_LVL);
+ $self->add (4, 0, new CFClient::UI::Label text => "Sp/Gp", @TOOLTIP_SP);
+ $self->add (5, 0, new CFClient::UI::Label text => "Dmg" , @TOOLTIP_DMG);
my $row = 0;
@@ -3574,11 +3589,38 @@
$row++;
+ my $spell_cb = sub {
+ my ($widget, $ev) = @_;
+
+ if ($ev->{button} == 1) {
+ $::CONN->user_send ("cast $spell->{name}");
+ } elsif ($ev->{button} == 2) {
+ $::CONN->user_send ("invoke $spell->{name}");
+ } elsif ($ev->{button} == 3) {
+ (new CFClient::UI::Menu
+ items => [
+ ["bind cast $spell->{name} to a key" => sub { $::BIND_EDITOR->do_quick_binding (["cast $spell->{name}"]) }],
+ ["bind invoke $spell->{name} to a key" => sub { $::BIND_EDITOR->do_quick_binding (["invoke $spell->{name}"]) }],
+ ],
+ )->popup ($ev);
+ } else {
+ return 0;
+ }
+
+ 1
+ };
+
+ my $tooltip = "$spell->{message}$TOOLTIP_ALL";
+
+ #TODO: add path info to tooltip
+ #$self->add (6, $row, new CFClient::UI::Label text => $spell->{path});
+
$self->add (0, $row, new CFClient::UI::Face
face => $spell->{face},
can_hover => 1,
can_events => 1,
- tooltip => $spell->{message},
+ tooltip => $tooltip,
+ on_button_down => $spell_cb,
);
$self->add (1, $row, new CFClient::UI::Label
@@ -3586,19 +3628,14 @@
text => $spell->{name},
can_hover => 1,
can_events => 1,
- tooltip => $spell->{message},
+ tooltip => $tooltip,
+ on_button_down => $spell_cb,
);
- $self->add (2, $row, new CFClient::UI::Label text => $spell->{level}, @TOOLTIP_LVL);
- $self->add (3, $row, new CFClient::UI::Label text => $spell->{mana} || $spell->{grace}, @TOOLTIP_SP);
- $self->add (4, $row, new CFClient::UI::Label text => $spell->{damage}, @TOOLTIP_DMG);
-
- # TODO: should be done via popup
- $self->add (5, $row, new CFClient::UI::Button
- text => "bind",
- tooltip => "bind spell readying (cast command) to key",
- on_activate => sub { $::BIND_EDITOR->do_quick_binding (["cast $spell->{name}"]) },
- );
+ $self->add (2, $row, new CFClient::UI::Label text => $::CONN->{skill_info}{$spell->{skill}}, @TOOLTIP_SKILL);
+ $self->add (3, $row, new CFClient::UI::Label text => $spell->{level}, @TOOLTIP_LVL);
+ $self->add (4, $row, new CFClient::UI::Label text => $spell->{mana} || $spell->{grace}, @TOOLTIP_SP);
+ $self->add (5, $row, new CFClient::UI::Label text => $spell->{damage}, @TOOLTIP_DMG);
}
});
}
@@ -3617,6 +3654,13 @@
$self->rebuild_spell_list;
}
+sub clear_spells {
+ my ($self) = @_;
+
+ $self->{spell} = {};
+ $self->rebuild_spell_list;
+}
+
#############################################################################
package CFClient::UI::Root;