--- deliantra/Deliantra-Client/DC/UI.pm 2006/06/05 03:06:04 1.284
+++ deliantra/Deliantra-Client/DC/UI.pm 2006/06/05 22:30:35 1.290
@@ -20,8 +20,6 @@
our %WIDGET; # all widgets, weak-referenced
our $TOOLTIP_WATCHER = Event->idle (min => 1/60, cb => sub {
- return if $ENV{CFPLUS_DEBUG} & 8;
-
if (!$GRAB) {
for (my $widget = $HOVER; $widget; $widget = $widget->{parent}) {
if (length $widget->{tooltip}) {
@@ -30,6 +28,8 @@
$TOOLTIP->{owner} = $widget;
+ return if $ENV{CFPLUS_DEBUG} & 8;
+
my $tip = $widget->{tooltip};
$tip = $tip->($widget) if CODE:: eq ref $tip;
@@ -1556,8 +1556,8 @@
$self->{layout} = new CFClient::Layout if $self->{layout}->is_rgba;
$self->{layout}->set_text ($text);
- delete $self->{req_h};
+ delete $self->{size_req};
$self->realloc;
$self->update;
}
@@ -1572,8 +1572,8 @@
$self->{layout} = new CFClient::Layout $rgba if $self->{layout}->is_rgba != $rgba;
$self->{layout}->set_markup ($markup);
- delete $self->{req_h};
+ delete $self->{size_req};
$self->realloc;
$self->update;
}
@@ -1581,9 +1581,7 @@
sub size_request {
my ($self) = @_;
- if (exists $self->{req_h}) {
- @$self{qw(req_w req_h)}
- } else {
+ $self->{size_req} ||= do {
$self->{layout}->set_font ($self->{font}) if $self->{font};
$self->{layout}->set_width ($self->{max_w} || -1);
$self->{layout}->set_ellipsise ($self->{ellipsise});
@@ -1602,8 +1600,10 @@
$h = List::Util::max $h, $h2;
}
- ($w, $h)
- }
+ [$w, $h]
+ };
+
+ @{ $self->{size_req} }
}
sub size_allocate {
@@ -1624,6 +1624,14 @@
$self->realloc;
}
+sub reconfigure {
+ my ($self) = @_;
+
+ delete $self->{size_req};
+
+ $self->SUPER::reconfigure;
+}
+
sub _draw {
my ($self) = @_;
@@ -1651,12 +1659,15 @@
};
glEnable GL_TEXTURE_2D;
- glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
-
- glColor_premultiply @{$self->{fg}}
- if $tex->{format} == GL_ALPHA;
- $tex->draw_quad_alpha_premultiplied ($self->{ox}, $self->{oy});
+ 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});
+ } else {
+ glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
+ $tex->draw_quad_alpha_premultiplied ($self->{ox}, $self->{oy});
+ }
glDisable GL_TEXTURE_2D;
}
@@ -1698,7 +1709,7 @@
$text =~ s/./*/g if $self->{hidden};
$self->{layout}->set_text ("$text ");
- delete $self->{req_h};
+ delete $self->{size_req};
$self->_emit (changed => $self->{text});
@@ -3475,43 +3486,71 @@
)
}
-# XXX: Do sorting? Argl...
-sub add_spell {
- my ($self, $spell) = @_;
- $self->{spells}->{$spell->{name}} = $spell;
+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.");
+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.");
+my @TOOLTIP_DMG = (align => 1, can_events => 1, can_hover => 1, tooltip =>
+ "Damage. The amount of damage the spell deals when it hits.");
- $self->add (0, $self->{tbl_idx}, new CFClient::UI::Face
- face => $spell->{face},
- can_hover => 1,
- can_events => 1,
- tooltip => $spell->{message});
+sub rebuild_spell_list {
+ my ($self) = @_;
- $self->add (1, $self->{tbl_idx}, new CFClient::UI::Label
- text => $spell->{name},
- can_hover => 1,
- can_events => 1,
- tooltip => $spell->{message},
- expand => 1);
+ $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);
+
+ my $row = 0;
- $self->add (2, $self->{tbl_idx}, new CFClient::UI::Label
- text => (sprintf "lvl: %2d sp: %2d dmg: %2d",
- $spell->{level}, ($spell->{mana} || $spell->{grace}), $spell->{damage}),
- expand => 1);
-
- $self->add (3, $self->{tbl_idx}++, new CFClient::UI::Button
- text => "bind to key",
- on_activate => sub { $::BIND_EDITOR->do_quick_binding (["cast $spell->{name}"]) });
+ for (sort { $a cmp $b } keys %{ $self->{spell} }) {
+ my $spell = $self->{spell}{$_};
+
+ $row++;
+
+ $self->add (0, $row, new CFClient::UI::Face
+ face => $spell->{face},
+ can_hover => 1,
+ can_events => 1,
+ tooltip => $spell->{message},
+ );
+
+ $self->add (1, $row, new CFClient::UI::Label
+ expand => 1,
+ text => $spell->{name},
+ can_hover => 1,
+ can_events => 1,
+ tooltip => $spell->{message},
+ );
+
+ $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}"]) },
+ );
+ }
+ });
}
-sub rebuild_spell_list {
- my ($self) = @_;
- $self->{tbl_idx} = 0;
- $self->add_spell ($_) for values %{$self->{spells}};
+sub add_spell {
+ my ($self, $spell) = @_;
+
+ $self->{spell}->{$spell->{name}} = $spell;
+ $self->rebuild_spell_list;
}
sub remove_spell {
my ($self, $spell) = @_;
- delete $self->{spells}->{$spell->{name}};
+
+ delete $self->{spell}->{$spell->{name}};
$self->rebuild_spell_list;
}