ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/widget.ext
(Generate patch)

Comparing deliantra/server/ext/widget.ext (file contents):
Revision 1.4 by root, Mon Jul 2 03:15:30 2007 UTC vs.
Revision 1.12 by root, Sun Jul 22 20:08:38 2007 UTC

3# sends the following ext message types 3# sends the following ext message types
4# ws_n id # widgetset new 4# ws_n id # widgetset new
5# ws_d id # widgetset destroy 5# ws_d id # widgetset destroy
6# ws_c ws id class args # widgetset create 6# ws_c ws id class args # widgetset create
7# w_c id [rid] name args # widget method call 7# w_c id [rid] name args # widget method call
8# w_s id name value # widget member set 8# w_s id @attr # widget member set
9# w_g id rid name # widget member get 9# w_g id rid @attr # widget member get
10# 10#
11# and expects the following exti message types 11# and expects the following exti message types
12# w_r rid res # widget call return 12# w_r rid res # widget call return
13# w_e id name args # widget_event 13# w_e id name args # widget_event
14 14
66 [5, "Pow"], 66 [5, "Pow"],
67 [6, "Cha"], 67 [6, "Cha"],
68 ) { 68 ) {
69 my ($x, $label) = @$_; 69 my ($x, $label) = @$_;
70 70
71 $statstable->add ($x, 0, $ws->new (Label => 71 $statstable->add_at ($x, 0, $ws->new (Label =>
72 can_hover => 1, can_events => 1, 72 can_hover => 1, can_events => 1,
73 align => +1, text => $label, tooltip => "#stat_$label", 73 align => +1, text => $label, tooltip => "#stat_$label",
74 )); 74 ));
75 $statstable->add ($x, 1, $ws->{stat}{$label} = $ws->new (Label => 75 $statstable->add_at ($x, 1, $ws->{stat}{$label} = $ws->new (Label =>
76 can_hover => 1, can_events => 1, 76 can_hover => 1, can_events => 1,
77 align => +1, template => "88", tooltip => "#stat_$label", 77 align => +1, template => "88", tooltip => "#stat_$label",
78 )); 78 ));
79 } 79 }
80 80
90 return unless $cf::CFG{devel}; 90 return unless $cf::CFG{devel};
91 91
92 my $ns = $pl->ns; 92 my $ns = $pl->ns;
93 93
94 return unless $ns->{can_widget}; 94 return unless $ns->{can_widget};
95
96 csc_start $ns; 95 #csc_start $ns;
97 }, 96 },
98); 97);
99 98
100cf::register_exticmd w_e => sub { 99cf::register_exticmd w_e => sub {
101 my ($ns, $pkt) = @_; 100 my ($ns, $pkt) = @_;
126 my $id = ++$self->{id}; 125 my $id = ++$self->{id};
127 126
128 my $ws = bless { 127 my $ws = bless {
129 id => $id, 128 id => $id,
130 ns => $self, 129 ns => $self,
131 w => {}, 130 _w => {},
132 }, "ext::widget::set"; 131 }, "ext::widget::set";
133 132
134 $ws->msg (ws_n => id => $id); 133 $ws->msg (ws_n => id => $id);
135 134
136 $ws 135 $ws
165sub new { 164sub new {
166 my ($self, $class, %args) = @_; 165 my ($self, $class, %args) = @_;
167 166
168 my $id = ++$self->{ns}{id}; 167 my $id = ++$self->{ns}{id};
169 168
170 my $proxy = $self->{w}{$id} = bless { 169 my $proxy = $self->{_w}{$id} = bless {
171 id => $id, 170 id => $id,
172 }, "ext::widget::proxy"; 171 }, "ext::widget::proxy";
173 172
174 Scalar::Util::weaken ($proxy->{ws} = $self); 173 Scalar::Util::weaken ($proxy->{ws} = $self);
175 Scalar::Util::weaken ($proxy->{ns} = $self->{ns}); 174 Scalar::Util::weaken ($proxy->{ns} = $self->{ns});
179 push @{$proxy->{ev}{$ev}}, $args{$ev}; 178 push @{$proxy->{ev}{$ev}}, $args{$ev};
180 $args{$ev} = 0; 179 $args{$ev} = 0;
181 } 180 }
182 181
183 $self->msg (ws_c => 182 $self->msg (ws_c =>
184 ws => $self->{w}{id}, 183 ws => $proxy->{id},
185 id => $id, 184 id => $id,
186 class => $class, 185 class => $class,
187 args => \%args, 186 args => \%args,
188 ); 187 );
189 188
197sub DESTROY { 196sub DESTROY {
198 my ($self) = @_; 197 my ($self) = @_;
199 198
200 delete $self->{ns}{widget}{$self->{id}}; 199 delete $self->{ns}{widget}{$self->{id}};
201 200
201 #warn "DES<$self> $self->{ws}\n";#d#
202 if (my $ws = $self->{ws}) { 202 if (my $ws = $self->{ws}) {
203 delete $ws->{w}{$self->{id}};
204 $self->msg (w_c => name => "destroy"); 203 $self->msg (w_c => name => "destroy");
204 delete $ws->{_w}{$self->{id}};
205 } 205 }
206} 206}
207 207
208sub msg { 208sub msg {
209 my ($self, $type, %msg) = @_; 209 my ($self, $type, %msg) = @_;
244 244
245 () 245 ()
246} 246}
247 247
248sub set { 248sub set {
249 my ($self, $member, $value) = @_; 249 my ($self, @kv) = @_;
250 250
251 $self->msg (w_s => name => $member, value => $value); 251 $self->msg (w_s => attr => \@kv);
252} 252}
253 253
254sub get { 254sub get {
255 my ($self, $member, $cb) = @_; 255 my ($self, $member, $cb) = @_;
256 256
257 $self->msg_cb ($cb, w_g => name => $member); 257 $self->msg_cb ($cb, w_g => attr => [$member]);
258} 258}
259 259
260sub TO_JSON { 260sub TO_JSON {
261 { __widget_ref__ => $_[0]{id} } 261 { __widget_ref__ => $_[0]{id} }
262} 262}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines