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.1 by root, Mon Jun 25 05:43:53 2007 UTC vs.
Revision 1.3 by root, Tue Jun 26 04:50:05 2007 UTC

18 18
19 $ns->{id} = "a"; 19 $ns->{id} = "a";
20 }, 20 },
21); 21);
22 22
23sub csc_update_stats {
24 my ($ns) = @_;
25
26 while (my ($k, $v) = each %{ $ns->{csc}{stat} }) {
27 $v->set_text ($ns->pl->ob->stats->$k);
28 }
29}
30
31sub csc_start {
32 my ($ns) = @_;
33
34 my $ws = $ns->{csc} = $ns->new_widgetset;
35
36 my $w = $ws->new (Toplevel =>
37 min_w => 600,
38 min_h => 400,
39 x => "center",
40 y => "center",
41 title => "Character Creation",
42 has_close_button => 1,
43 on_delete => sub {
44 $ws->destroy;
45 },
46 );
47
48 $w->add (my $ntb = $ws->new (Notebook => expand => 1));
49
50 $ntb->add (Statistics => (my $stats = $ws->new (Table => expand => 1)), "Basic statistics of your new character");
51
52 $stats->add (0, 0, (my $statstable = $ws->new ("Table")));
53
54 for (
55 [0, "Str"],
56 [1, "Dex"],
57 [2, "Con"],
58 [3, "Int"],
59 [4, "Wis"],
60 [5, "Pow"],
61 [6, "Cha"],
62 ) {
63 my ($x, $label) = @$_;
64
65 $statstable->add ($x, 0, $ws->new (Label =>
66 can_hover => 1, can_events => 1,
67 align => +1, text => $label, tooltip => "#stat_$label",
68 ));
69 $statstable->add ($x, 1, $ws->{stat}{$label} = $ws->new (Label =>
70 can_hover => 1, can_events => 1,
71 align => +1, template => "88", tooltip => "#stat_$label",
72 ));
73 }
74
75 csc_update_stats $ns;
76
77 $w->show;
78}
79
23cf::player->attach ( 80cf::player->attach (
24 on_login => sub { 81 on_login => sub {
25 my ($pl) = @_; 82 my ($pl) = @_;
26 83
27 #DEMO CODE 84 return unless $cf::CFG{devel};
28 return unless $pl->ob->name eq "schmorp";
29 85
30 my $ns = $pl->ns; 86 my $ns = $pl->ns;
31 87
32 return unless $ns->{can_widgetx}; 88 return unless $ns->{can_widget};
33 89
34 my $ws = $ns->new_widgetset; 90 csc_start $ns;
35
36 $ns->async (sub {
37 Coro::Timer::sleep 20;
38 warn "undef\n";#d#
39 undef $ws;#
40 });#d#
41
42 my $w = $ws->new (Toplevel =>
43 x => "center",
44 y => "center",
45 title => "Server Query",
46 has_close_button => 1,
47 on_delete => sub {
48 warn "i was being d-e-l-e-t-e-d\n";
49 },
50 );
51
52 $w->add ($ws->new (Entry =>
53 on_changed => sub {
54 warn "i was changed<@_>\n";
55 }
56 ));
57
58 $ns->async (sub {
59 warn $w->get ("parent");
60 });
61
62 $w->show;
63
64 }, 91 },
65); 92);
66 93
67cf::register_exticmd w_e => sub { 94cf::register_exticmd w_e => sub {
68 my ($ns, $pkt) = @_; 95 my ($ns, $pkt) = @_;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines