1 |
root |
1.4 |
#! perl # depends=widget |
2 |
root |
1.1 |
|
3 |
|
|
sub settings_page { |
4 |
|
|
my ($ns) = @_; |
5 |
|
|
my $pl = $ns->pl; |
6 |
|
|
|
7 |
|
|
my $ws = $ns->{ws_settings} = $ns->new_widgetset; |
8 |
|
|
|
9 |
root |
1.2 |
cf::weaken $ws; |
10 |
|
|
|
11 |
root |
1.1 |
# I hope not doing range checking is ok here... |
12 |
|
|
$ws->template (face => (cf::face::find "res/ui/pl_settings_page"), |
13 |
|
|
[ |
14 |
|
|
page => { }, |
15 |
|
|
|
16 |
root |
1.3 |
title => { |
17 |
|
|
text => $pl->ob->is_dragon ? $pl->title : $pl->own_title, |
18 |
|
|
can_events => !$pl->ob->is_dragon, |
19 |
|
|
}, |
20 |
root |
1.1 |
info => { text => $pl->{user_info} }, |
21 |
|
|
info_save => { |
22 |
|
|
on_activate => sub { |
23 |
root |
1.3 |
$ws->{title}->get (text => sub { |
24 |
|
|
return if $pl->ob->is_dragon; |
25 |
root |
1.2 |
|
26 |
root |
1.1 |
$pl->statusmsg ("new title has been saved"); |
27 |
|
|
$pl->own_title ($_[0]); |
28 |
|
|
}); |
29 |
|
|
$ws->{info}->get (text => sub { |
30 |
|
|
$pl->statusmsg ("new character info text has been saved"); |
31 |
|
|
$pl->{user_info} = $_[0]; |
32 |
|
|
}); |
33 |
|
|
}, |
34 |
|
|
}, |
35 |
|
|
|
36 |
|
|
applymode => { value => $pl->unapply , on_changed => sub { $pl->unapply ($_[1]) } }, |
37 |
|
|
bowmode => { value => $pl->bowtype , on_changed => sub { $pl->bowtype ($_[1]) } }, |
38 |
|
|
petmode => { value => $pl->petmode , on_changed => sub { $pl->petmode ($_[1]) } }, |
39 |
|
|
hintmode => { value => $pl->hintmode , on_changed => sub { $pl->hintmode ($_[1]) } }, |
40 |
|
|
usekeys => { value => $pl->usekeys , on_changed => sub { $pl->usekeys ($_[1]) } }, |
41 |
|
|
], |
42 |
|
|
sub { |
43 |
|
|
$ws->find ("pl_notebook")->add ($ws->{page}); |
44 |
root |
1.2 |
}, |
45 |
root |
1.1 |
); |
46 |
|
|
} |
47 |
|
|
|
48 |
|
|
cf::player->attach ( |
49 |
|
|
on_login => sub { |
50 |
|
|
my ($pl) = @_; |
51 |
|
|
|
52 |
|
|
my $ns = $pl->ns; |
53 |
|
|
return unless $ns->{can_widget}; |
54 |
|
|
|
55 |
|
|
settings_page $ns; |
56 |
|
|
}, |
57 |
|
|
); |
58 |
|
|
|