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

Comparing deliantra/Deliantra-Client/DC/Protocol.pm (file contents):
Revision 1.123 by root, Thu Jul 19 16:44:14 2007 UTC vs.
Revision 1.127 by root, Mon Jul 23 15:30:45 2007 UTC

209 my ($arg) = @_; 209 my ($arg) = @_;
210 210
211 my $w = $self->{widget}{$arg->{id}} 211 my $w = $self->{widget}{$arg->{id}}
212 or return; 212 or return;
213 213
214 $w->{$arg->{name}} = $arg->{value}; 214 my $attr = $arg->{attr};
215
216 for (my $i = 0; $i < $#$attr; $i += 2) {
217 my ($member, $value) = @$attr[$i, $i+1];
218 if (defined $value) {
219 $w->{$member} = $value;
220 } else {
221 delete $w->{$member};
222 }
223 $w->{parent}->realloc if $member =~ /^c_/ && $w->{visible};
224 }
215 }); 225 });
216 226
217 # widget get 227 # widget get
218 $self->connect_ext (w_g => sub { 228 $self->connect_ext (w_g => sub {
219 my ($arg) = @_; 229 my ($arg) = @_;
220 230
221 my $w = $self->{widget}{$arg->{id}} 231 my $w = $self->{widget}{$arg->{id}}
222 or return; 232 or return;
223 233
224 $self->send_exti_msg (w_r => rid => $arg->{rid}, res => [$w->{$arg->{name}}]); 234 $self->send_exti_msg (w_r => rid => $arg->{rid}, res => [map $w->{$_}, @{$arg->{attr}}]);
225 }); 235 });
226 236
227 # destroy widgets on logout 237 # destroy widgets on logout
228 $self->{on_stop_game_guard} = $self->{map_widget}{root}->connect (stop_game => sub { 238 $self->{on_stop_game_guard} = $self->{map_widget}{root}->connect (stop_game => sub {
229 for my $ws (values %{delete $self->{widgetset} || {}}) { 239 for my $ws (values %{delete $self->{widgetset} || {}}) {
445 my @skills = keys %{ $self->{skill_info} }; 455 my @skills = keys %{ $self->{skill_info} };
446 456
447 if (grep +(exists $stats->{$_}) != (exists $prev->{$_}), @skills) { 457 if (grep +(exists $stats->{$_}) != (exists $prev->{$_}), @skills) {
448 $sktbl->clear; 458 $sktbl->clear;
449 459
460 my @add;
461
462 push @add,
450 $sktbl->add (0, 0, new CFPlus::UI::Label text => "Experience", align => 1); 463 0, 0, (new CFPlus::UI::Label text => "Experience", align => 1),
451 $sktbl->add (1, 0, new CFPlus::UI::Label text => "Lvl.", align => 1); 464 1, 0, (new CFPlus::UI::Label text => "Lvl.", align => 1),
452 $sktbl->add (2, 0, new CFPlus::UI::Label text => "Skill", expand => 1); 465 2, 0, (new CFPlus::UI::Label text => "Skill", expand => 1),
453 $sktbl->add (3, 0, new CFPlus::UI::Label text => "Experience", align => 1); 466 3, 0, (new CFPlus::UI::Label text => "Experience", align => 1),
454 $sktbl->add (4, 0, new CFPlus::UI::Label text => "Lvl.", align => 1); 467 4, 0, (new CFPlus::UI::Label text => "Lvl.", align => 1),
455 $sktbl->add (5, 0, new CFPlus::UI::Label text => "Skill", expand => 1); 468 5, 0, (new CFPlus::UI::Label text => "Skill", expand => 1),
469 ;
456 470
457 my $TOOLTIP_ALL = "\n\n<small>Left click - ready skill\nMiddle click - use spell\nRight click - further options</small>"; 471 my $TOOLTIP_ALL = "\n\n<small>Left click - ready skill\nMiddle click - use spell\nRight click - further options</small>";
458 472
459 my @TOOLTIP_LVL = (tooltip => "<b>Level</b>. The level of the skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1); 473 my @TOOLTIP_LVL = (tooltip => "<b>Level</b>. The level of the skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1);
460 my @TOOLTIP_EXP = (tooltip => "<b>Experience</b>. The experience points you have in this skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1); 474 my @TOOLTIP_EXP = (tooltip => "<b>Experience</b>. The experience points you have in this skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1);
488 } 502 }
489 503
490 1 504 1
491 }; 505 };
492 506
507 push @add,
493 $sktbl->add ($x * 3 + 0, $y, $self->{stat_widget_exp}{$idx} = new CFPlus::UI::Label 508 $x * 3 + 0, $y, ($self->{stat_widget_exp}{$idx} = new CFPlus::UI::Label
494 text => "0", align => 1, font => $::FONT_FIXED, fg => [1, 1, 0], on_button_down => $spell_cb, @TOOLTIP_EXP); 509 align => 1, font => $::FONT_FIXED, fg => [1, 1, 0], on_button_down => $spell_cb, @TOOLTIP_EXP),
495 $sktbl->add ($x * 3 + 1, $y, $self->{stat_widget_lvl}{$idx} = new CFPlus::UI::Label 510 $x * 3 + 1, $y, ($self->{stat_widget_lvl}{$idx} = new CFPlus::UI::Label
496 text => "0", align => 1, font => $::FONT_FIXED, fg => [0, 1, 0], padding_x => 4, on_button_down => $spell_cb, @TOOLTIP_LVL); 511 text => "0", align => 1, font => $::FONT_FIXED, fg => [0, 1, 0], padding_x => 4, on_button_down => $spell_cb, @TOOLTIP_LVL),
497 $sktbl->add ($x * 3 + 2, $y, new CFPlus::UI::Label text => $name, on_button_down => $spell_cb, 512 $x * 3 + 2, $y, (new CFPlus::UI::Label text => $name, on_button_down => $spell_cb,
498 can_events => 1, can_hover => 1, tooltip => (CFPlus::Pod::section_label skill_description => $name) . $TOOLTIP_ALL); 513 can_events => 1, can_hover => 1, tooltip => (CFPlus::Pod::section_label skill_description => $name) . $TOOLTIP_ALL),
514 ;
499 515
500 $x++ and ($x, $y) = (0, $y + 1); 516 $x++ and ($x, $y) = (0, $y + 1);
501 } 517 }
518
519 $sktbl->add_at (@add);
502 } 520 }
503 521
504 for (grep exists $stats->{$_}, @skills) { 522 for (grep exists $stats->{$_}, @skills) {
505 $self->{stat_widget_exp}{$_}->set_text (::formsep ($stats->{$_}[1])); 523 $self->{stat_widget_exp}{$_}->set_text (::formsep ($stats->{$_}[1]));
506 $self->{stat_widget_lvl}{$_}->set_text ($stats->{$_}[0] * 1); 524 $self->{stat_widget_lvl}{$_}->set_text ($stats->{$_}[0] * 1);
988 $CFPlus::UI::ROOT->on_refresh ($::FLOORBOX => sub { 1006 $CFPlus::UI::ROOT->on_refresh ($::FLOORBOX => sub {
989 return unless $::CONN; 1007 return unless $::CONN;
990 1008
991 $::FLOORBOX->clear; 1009 $::FLOORBOX->clear;
992 1010
1011 my @add;
1012
993 my $row; 1013 my $row;
994 for (sort { $a->{count} <=> $b->{count} } values %{ $::CONN->{container}{$::CONN->{open_container} || 0} }) { 1014 for (sort { $a->{count} <=> $b->{count} } values %{ $::CONN->{container}{$::CONN->{open_container} || 0} }) {
995 if ($row < 6) { 1015 if ($row < 6) {
996 local $_->{face_widget}; # hack to force recreation of widget 1016 local $_->{face_widget}; # hack to force recreation of widget
997 local $_->{desc_widget}; # hack to force recreation of widget 1017 local $_->{desc_widget}; # hack to force recreation of widget
998 CFPlus::Item::update_widgets $_; 1018 CFPlus::Item::update_widgets $_;
999 1019
1020 push @add,
1000 $::FLOORBOX->add (0, $row, $_->{face_widget}); 1021 0, $row, $_->{face_widget},
1001 $::FLOORBOX->add (1, $row, $_->{desc_widget}); 1022 1, $row, $_->{desc_widget};
1002 1023
1003 $row++; 1024 $row++;
1004 } else { 1025 } else {
1005 $::FLOORBOX->add (1, $row, new CFPlus::UI::Button 1026 push @add, 1, $row, new CFPlus::UI::Button
1006 text => "More...", 1027 text => "More...",
1007 on_activate => sub { ::toggle_player_page ($::INVENTORY_PAGE); 0 }, 1028 on_activate => sub { ::toggle_player_page ($::INVENTORY_PAGE); 0 },
1008 ); 1029 ;
1009 last; 1030 last;
1010 } 1031 }
1011 } 1032 }
1012 if ($::CONN->{open_container}) { 1033 if ($::CONN->{open_container}) {
1013 $::FLOORBOX->add (1, $row++, new CFPlus::UI::Button 1034 push @add, 1, $row++, new CFPlus::UI::Button
1014 text => "Close container", 1035 text => "Close container",
1015 on_activate => sub { $::CONN->send ("apply $::CONN->{open_container}") } 1036 on_activate => sub { $::CONN->send ("apply $::CONN->{open_container}") }
1016 ); 1037 ;
1017 } 1038 }
1039
1040 $::FLOORBOX->add_at (@add);
1018 }); 1041 });
1019 1042
1020 $::WANT_REFRESH++; 1043 $::WANT_REFRESH++;
1021} 1044}
1022 1045

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines