… | |
… | |
18 | |
18 | |
19 | $ns->{id} = "a"; |
19 | $ns->{id} = "a"; |
20 | }, |
20 | }, |
21 | ); |
21 | ); |
22 | |
22 | |
|
|
23 | sub 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 | |
|
|
31 | sub 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 | ); |
|
|
43 | |
|
|
44 | $w->add (my $ntb = $ws->new (Notebook => expand => 1)); |
|
|
45 | |
|
|
46 | $ntb->add (Statistics => (my $stats = $ws->new (Table => expand => 1)), "Basic statistics of your new character"); |
|
|
47 | |
|
|
48 | $stats->add (0, 0, (my $statstable = $ws->new ("Table"))); |
|
|
49 | |
|
|
50 | for ( |
|
|
51 | [0, "Str", "Strength"], |
|
|
52 | [1, "Dex", "Dexterity"], |
|
|
53 | [2, "Con", "Constitution"], |
|
|
54 | [3, "Int", "Intelligence"], |
|
|
55 | [4, "Wis", "Wisdom"], |
|
|
56 | [5, "Pow", "Power"], |
|
|
57 | [6, "Cha", "Charisma"], |
|
|
58 | ) { |
|
|
59 | my ($x, $label, $description) = @$_; |
|
|
60 | |
|
|
61 | $statstable->add ($x, 0, $ws->new (Label => |
|
|
62 | can_hover => 1, can_events => 1, |
|
|
63 | align => +1, text => $label, tooltip => "#stat_$label", |
|
|
64 | )); |
|
|
65 | $statstable->add ($x, 1, $ws->{stat}{$label} = $ws->new (Label => |
|
|
66 | can_hover => 1, can_events => 1, |
|
|
67 | align => +1, template => "88", tooltip => "#stat_$label", |
|
|
68 | )); |
|
|
69 | } |
|
|
70 | |
|
|
71 | csc_update_stats $ns; |
|
|
72 | |
|
|
73 | $w->show; |
|
|
74 | } |
|
|
75 | |
23 | cf::player->attach ( |
76 | cf::player->attach ( |
24 | on_login => sub { |
77 | on_login => sub { |
25 | my ($pl) = @_; |
78 | my ($pl) = @_; |
26 | |
79 | |
27 | #DEMO CODE |
80 | return unless $cf::CFG{devel}; |
28 | return unless $pl->ob->name eq "schmorp"; |
|
|
29 | |
81 | |
30 | my $ns = $pl->ns; |
82 | my $ns = $pl->ns; |
31 | |
83 | |
32 | return unless $ns->{can_widgetx}; |
84 | return unless $ns->{can_widget}; |
33 | |
85 | |
34 | my $ws = $ns->new_widgetset; |
86 | 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 | }, |
87 | }, |
65 | ); |
88 | ); |
66 | |
89 | |
67 | cf::register_exticmd w_e => sub { |
90 | cf::register_exticmd w_e => sub { |
68 | my ($ns, $pkt) = @_; |
91 | my ($ns, $pkt) = @_; |