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.122 by root, Sun Jul 15 22:07:48 2007 UTC vs.
Revision 1.126 by root, Sun Jul 22 19:34:58 2007 UTC

125 ->convert_blessed 125 ->convert_blessed
126 ->filter_json_single_key_object (__widget_ref__ => sub { 126 ->filter_json_single_key_object (__widget_ref__ => sub {
127 $self->{widget}{$_[0]} 127 $self->{widget}{$_[0]}
128 }); 128 });
129 129
130 # widgetset new
130 $self->connect_ext (ws_n => sub { 131 $self->connect_ext (ws_n => sub {
131 my ($arg) = @_; 132 my ($arg) = @_;
132 133
133 $self->{widgetset}{$arg{id}} = { 134 $self->{widgetset}{$arg{id}} = {
134 w => {}, 135 w => {},
135 }; 136 };
136 }); 137 });
137 138
139 # widgetset destroy
138 $self->connect_ext (ws_d => sub { 140 $self->connect_ext (ws_d => sub {
139 my ($arg) = @_; 141 my ($arg) = @_;
140 142
141 my $ws = delete $self->{widgetset}{$arg{id}} 143 my $ws = delete $self->{widgetset}{$arg{id}}
142 or return; 144 or return;
143 145
144 $_->destroy 146 $_->destroy
145 for values %{$ws->{w}}; 147 for values %{$ws->{w}};
146 }); 148 });
147 149
150 # widgetset destroy
148 $self->connect_ext (ws_c => sub { 151 $self->connect_ext (ws_c => sub {
149 my ($arg) = @_; 152 my ($arg) = @_;
150 153
151 my $args = $arg->{args} || {}; 154 my $args = $arg->{args} || {};
152 155
182 warn "server failed creating client-side widget " . (CFPlus::to_json $arg) . ": $@\n"; 185 warn "server failed creating client-side widget " . (CFPlus::to_json $arg) . ": $@\n";
183 $self->send_exti_msg (w_e => id => $arg->{id}, name => "destroy"); 186 $self->send_exti_msg (w_e => id => $arg->{id}, name => "destroy");
184 } 187 }
185 }); 188 });
186 189
190 # widget call
187 $self->connect_ext (w_c => sub { 191 $self->connect_ext (w_c => sub {
188 my ($arg) = @_; 192 my ($arg) = @_;
189 193
190 my $w = $self->{widget}{$arg->{id}} 194 my $w = $self->{widget}{$arg->{id}}
191 or return; 195 or return;
198 } else { 202 } else {
199 $w->$m (@$a); 203 $w->$m (@$a);
200 } 204 }
201 }); 205 });
202 206
207 # widget set
203 $self->connect_ext (w_s => sub { 208 $self->connect_ext (w_s => sub {
204 my ($arg) = @_; 209 my ($arg) = @_;
205 210
206 my $w = $self->{widget}{$arg->{id}} 211 my $w = $self->{widget}{$arg->{id}}
207 or return; 212 or return;
208 213
209 $w->{$arg->{name}} = $arg->{value}; 214 my $attr = $arg->{attr};
215
216 for (my $i = 0; $i < $#$attr; $i += 2) {
217 $w->{$attr->[$i]} = $attr->[$i+1];
218 $w->{parent}->realloc if $attr->[$i] =~ /^c_/ && $w->{visible};#d# really?
219 }
210 }); 220 });
211 221
222 # widget get
212 $self->connect_ext (w_g => sub { 223 $self->connect_ext (w_g => sub {
213 my ($arg) = @_; 224 my ($arg) = @_;
214 225
215 my $w = $self->{widget}{$arg->{id}} 226 my $w = $self->{widget}{$arg->{id}}
216 or return; 227 or return;
217 228
218 $self->send_exti_msg (w_r => rid => $arg->{rid}, res => [$w->{$arg->{name}}]); 229 $self->send_exti_msg (w_r => rid => $arg->{rid}, res => [map $w->{$_}, @{$arg->{attr}}]);
219 }); 230 });
220 231
232 # destroy widgets on logout
221 $self->{on_stop_game_guard} = $self->{map_widget}{root}->connect (stop_game => sub { 233 $self->{on_stop_game_guard} = $self->{map_widget}{root}->connect (stop_game => sub {
222 for my $ws (values %{delete $self->{widgetset} || {}}) { 234 for my $ws (values %{delete $self->{widgetset} || {}}) {
223 $_->destroy 235 $_->destroy
224 for values %{delete $ws->{w} || {}}; 236 for values %{delete $ws->{w} || {}};
225 } 237 }
438 my @skills = keys %{ $self->{skill_info} }; 450 my @skills = keys %{ $self->{skill_info} };
439 451
440 if (grep +(exists $stats->{$_}) != (exists $prev->{$_}), @skills) { 452 if (grep +(exists $stats->{$_}) != (exists $prev->{$_}), @skills) {
441 $sktbl->clear; 453 $sktbl->clear;
442 454
455 my @add;
456
457 push @add,
443 $sktbl->add (0, 0, new CFPlus::UI::Label text => "Experience", align => 1); 458 0, 0, (new CFPlus::UI::Label text => "Experience", align => 1),
444 $sktbl->add (1, 0, new CFPlus::UI::Label text => "Lvl.", align => 1); 459 1, 0, (new CFPlus::UI::Label text => "Lvl.", align => 1),
445 $sktbl->add (2, 0, new CFPlus::UI::Label text => "Skill", expand => 1); 460 2, 0, (new CFPlus::UI::Label text => "Skill", expand => 1),
446 $sktbl->add (3, 0, new CFPlus::UI::Label text => "Experience", align => 1); 461 3, 0, (new CFPlus::UI::Label text => "Experience", align => 1),
447 $sktbl->add (4, 0, new CFPlus::UI::Label text => "Lvl.", align => 1); 462 4, 0, (new CFPlus::UI::Label text => "Lvl.", align => 1),
448 $sktbl->add (5, 0, new CFPlus::UI::Label text => "Skill", expand => 1); 463 5, 0, (new CFPlus::UI::Label text => "Skill", expand => 1),
464 ;
449 465
450 my $TOOLTIP_ALL = "\n\n<small>Left click - ready skill\nMiddle click - use spell\nRight click - further options</small>"; 466 my $TOOLTIP_ALL = "\n\n<small>Left click - ready skill\nMiddle click - use spell\nRight click - further options</small>";
451 467
452 my @TOOLTIP_LVL = (tooltip => "<b>Level</b>. The level of the skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1); 468 my @TOOLTIP_LVL = (tooltip => "<b>Level</b>. The level of the skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1);
453 my @TOOLTIP_EXP = (tooltip => "<b>Experience</b>. The experience points you have in this skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1); 469 my @TOOLTIP_EXP = (tooltip => "<b>Experience</b>. The experience points you have in this skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1);
481 } 497 }
482 498
483 1 499 1
484 }; 500 };
485 501
502 push @add,
486 $sktbl->add ($x * 3 + 0, $y, $self->{stat_widget_exp}{$idx} = new CFPlus::UI::Label 503 $x * 3 + 0, $y, ($self->{stat_widget_exp}{$idx} = new CFPlus::UI::Label
487 text => "0", align => 1, font => $::FONT_FIXED, fg => [1, 1, 0], on_button_down => $spell_cb, @TOOLTIP_EXP); 504 align => 1, font => $::FONT_FIXED, fg => [1, 1, 0], on_button_down => $spell_cb, @TOOLTIP_EXP),
488 $sktbl->add ($x * 3 + 1, $y, $self->{stat_widget_lvl}{$idx} = new CFPlus::UI::Label 505 $x * 3 + 1, $y, ($self->{stat_widget_lvl}{$idx} = new CFPlus::UI::Label
489 text => "0", align => 1, font => $::FONT_FIXED, fg => [0, 1, 0], padding_x => 4, on_button_down => $spell_cb, @TOOLTIP_LVL); 506 text => "0", align => 1, font => $::FONT_FIXED, fg => [0, 1, 0], padding_x => 4, on_button_down => $spell_cb, @TOOLTIP_LVL),
490 $sktbl->add ($x * 3 + 2, $y, new CFPlus::UI::Label text => $name, on_button_down => $spell_cb, 507 $x * 3 + 2, $y, (new CFPlus::UI::Label text => $name, on_button_down => $spell_cb,
491 can_events => 1, can_hover => 1, tooltip => (CFPlus::Pod::section_label skill_description => $name) . $TOOLTIP_ALL); 508 can_events => 1, can_hover => 1, tooltip => (CFPlus::Pod::section_label skill_description => $name) . $TOOLTIP_ALL),
509 ;
492 510
493 $x++ and ($x, $y) = (0, $y + 1); 511 $x++ and ($x, $y) = (0, $y + 1);
494 } 512 }
513
514 $sktbl->add_at (@add);
495 } 515 }
496 516
497 for (grep exists $stats->{$_}, @skills) { 517 for (grep exists $stats->{$_}, @skills) {
498 $self->{stat_widget_exp}{$_}->set_text (::formsep ($stats->{$_}[1])); 518 $self->{stat_widget_exp}{$_}->set_text (::formsep ($stats->{$_}[1]));
499 $self->{stat_widget_lvl}{$_}->set_text ($stats->{$_}[0] * 1); 519 $self->{stat_widget_lvl}{$_}->set_text ($stats->{$_}[0] * 1);
981 $CFPlus::UI::ROOT->on_refresh ($::FLOORBOX => sub { 1001 $CFPlus::UI::ROOT->on_refresh ($::FLOORBOX => sub {
982 return unless $::CONN; 1002 return unless $::CONN;
983 1003
984 $::FLOORBOX->clear; 1004 $::FLOORBOX->clear;
985 1005
1006 my @add;
1007
986 my $row; 1008 my $row;
987 for (sort { $a->{count} <=> $b->{count} } values %{ $::CONN->{container}{$::CONN->{open_container} || 0} }) { 1009 for (sort { $a->{count} <=> $b->{count} } values %{ $::CONN->{container}{$::CONN->{open_container} || 0} }) {
988 if ($row < 6) { 1010 if ($row < 6) {
989 local $_->{face_widget}; # hack to force recreation of widget 1011 local $_->{face_widget}; # hack to force recreation of widget
990 local $_->{desc_widget}; # hack to force recreation of widget 1012 local $_->{desc_widget}; # hack to force recreation of widget
991 CFPlus::Item::update_widgets $_; 1013 CFPlus::Item::update_widgets $_;
992 1014
1015 push @add,
993 $::FLOORBOX->add (0, $row, $_->{face_widget}); 1016 0, $row, $_->{face_widget},
994 $::FLOORBOX->add (1, $row, $_->{desc_widget}); 1017 1, $row, $_->{desc_widget};
995 1018
996 $row++; 1019 $row++;
997 } else { 1020 } else {
998 $::FLOORBOX->add (1, $row, new CFPlus::UI::Button 1021 push @add, 1, $row, new CFPlus::UI::Button
999 text => "More...", 1022 text => "More...",
1000 on_activate => sub { ::toggle_player_page ($::INVENTORY_PAGE); 0 }, 1023 on_activate => sub { ::toggle_player_page ($::INVENTORY_PAGE); 0 },
1001 ); 1024 ;
1002 last; 1025 last;
1003 } 1026 }
1004 } 1027 }
1005 if ($::CONN->{open_container}) { 1028 if ($::CONN->{open_container}) {
1006 $::FLOORBOX->add (1, $row++, new CFPlus::UI::Button 1029 push @add, 1, $row++, new CFPlus::UI::Button
1007 text => "Close container", 1030 text => "Close container",
1008 on_activate => sub { $::CONN->send ("apply $::CONN->{open_container}") } 1031 on_activate => sub { $::CONN->send ("apply $::CONN->{open_container}") }
1009 ); 1032 ;
1010 } 1033 }
1034
1035 $::FLOORBOX->add_at (@add);
1011 }); 1036 });
1012 1037
1013 $::WANT_REFRESH++; 1038 $::WANT_REFRESH++;
1014} 1039}
1015 1040

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines