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.21 by root, Thu Dec 27 19:41:26 2007 UTC vs.
Revision 1.22 by root, Fri Dec 28 12:44:45 2007 UTC

96 }, 96 },
97] 97]
98EOF 98EOF
99die if $@; 99die if $@;
100 100
101sub demo_start {
102 my ($ns) = @_;
103
104 my $ws = $ns->{csc} = $ns->new_widgetset;
105
106 my ($tl, $entry) = $ws->template (inline => $cg_template,
107 [
108 toplevel => {},
109 entry => {
110 text => "xyz",
111 on_changed => sub {
112 warn "changed<@_>\n";#d#
113 },
114 },
115 ],
116 );
117
118 $tl->show;
119
120 $ns->{xxxw} = [$tl, $entry];#d#
121
122# $ws->find ("setup_notebook")->add ($ws->{tab});
123# $ws->find ("setup_dialog")->toggle_visibility;
124}
125
126sub csc_start { 101sub csc_start {
127 my ($ns) = @_; 102 my ($ns) = @_;
128 103
129 my $ws = $ns->{csc} = $ns->new_widgetset; 104 my $ws = $ns->{csc} = $ns->new_widgetset;
130 105
169 144
170 csc_update_stats $ns; 145 csc_update_stats $ns;
171 146
172 $ws->{tl} = $w; 147 $ws->{tl} = $w;
173 $w->show; 148 $w->show;
149
150# my ($tl, $entry) = $ws->template (inline => $cg_template,
151# [
152# toplevel => {},
153# entry => {
154# text => "xyz",
155# on_changed => sub {
156# warn "changed<@_>\n";#d#
157# },
158# },
159# ],
160# );
161#
162# $tl->show;
163#
164# $ns->{xxxw} = [$tl, $entry];#d#
165#
166# $ws->find ("setup_notebook")->add ($ws->{tab});
167# $ws->find ("setup_dialog")->toggle_visibility;
174} 168}
175 169
176cf::player->attach ( 170cf::player->attach (
177 on_login => sub { 171 on_login => sub {
178 my ($pl) = @_; 172 my ($pl) = @_;
179 173
174 my $ns = $pl->ns;
175 return unless $ns->{can_widget};
176
180 return unless $cf::CFG{devel}; 177 return unless $cf::CFG{devel};
181 178
182 my $ns = $pl->ns;
183
184 return unless $ns->{can_widget};
185 #csc_start $ns; 179 #csc_start $ns;
186 demo_start $ns;
187 }, 180 },
188); 181);
189 182
190cf::register_exticmd w_e => sub { 183cf::register_exticmd w_e => sub {
191 my ($ns, $id, @args) = @_; 184 my ($ns, $id, @args) = @_;
287 280
288sub template { 281sub template {
289 my ($self, $type, $template, $args, $done_cb) = @_; 282 my ($self, $type, $template, $args, $done_cb) = @_;
290 283
291 my %cfg; 284 my %cfg;
292 my @res;
293 285
294 while (@$args) { 286 while (@$args) {
295 my ($name, $args) = splice @$args, 0, 2, (); 287 my ($name, $args) = splice @$args, 0, 2, ();
296 288
297 my $proxy = $self->alloc; 289 my $proxy = $self->alloc;
290
291 $self->{delete $args->{alias} or $name} = $proxy;
298 292
299 Scalar::Util::weaken ($self->{_w}{$proxy->{id}} = $proxy); 293 Scalar::Util::weaken ($self->{_w}{$proxy->{id}} = $proxy);
300 Scalar::Util::weaken ($proxy->{ws} = $self); 294 Scalar::Util::weaken ($proxy->{ws} = $self);
301 295
302 for my $ev (grep /^on_/, keys %$args) { 296 for my $ev (grep /^on_/, keys %$args) {
305 299
306 $cfg{$name} = { 300 $cfg{$name} = {
307 %$args, 301 %$args,
308 id => $proxy->{id}, 302 id => $proxy->{id},
309 }; 303 };
310
311 push @res, $proxy;
312 } 304 }
313 305
314 if ($done_cb) { 306 if ($done_cb) {
315 my $proxy = $self->alloc; 307 my $proxy = $self->alloc;
316 my $ocb = $done_cb; 308 my $ocb = $done_cb;
319 undef $done_cb; 311 undef $done_cb;
320 &$ocb 312 &$ocb
321 }); 313 });
322 } 314 }
323 315
316 if ($type eq "face") {
317 $self->{ns}->send_face ($template, 100);
318 $self->{ns}->flush_fx;
319 }
320
324 $self->msg (ws_ct => 321 $self->msg (ws_ct =>
325 $self->{id}, 322 $self->{id},
326 $type => $template, 323 $type => $template,
327 $done_cb, 324 $done_cb,
328 \%cfg, 325 \%cfg,
329 ); 326 );
330
331 @res
332} 327}
333 328
334sub find { 329sub find {
335 my ($self, @names) = @_; 330 my ($self, @names) = @_;
336 331

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines