ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/kgsueme/kgsueme/util.pl
Revision: 1.6
Committed: Sun Jun 1 16:51:38 2003 UTC (21 years ago) by pcg
Content type: text/plain
Branch: MAIN
Changes since 1.5: +8 -0 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 package util;
2
3 use Storable ();
4 use Scalar::Util ();
5
6 my $staterc = "$ENV{HOME}/.kgsueme";
7
8 $stateversion = 1;
9
10 our $state = -r $staterc ? Storable::retrieve($staterc) : {};
11
12 if ($state->{version} != $stateversion) {
13 warn "$staterc has wrong version - ignoring it.\n";
14 $state = {};
15 }
16
17 $state->{version} = $stateversion;
18
19 $::config = $state->{config} ||= {};
20
21 $::config->{speed} = 0;#d# optimize for speed or memory? (0,1)
22 $::config->{conserve_memory} = 0; # try to conserve memory at the expense of speed (0,1,2)
23 $::config->{randomize} = 0; # randomize placement of stones (BROKEN)
24
25 sub save_config {
26 &gtk::save_state;
27 Storable::nstore($state, $staterc);
28 appwin::status("save_state", "layout saved");
29 }
30
31 sub toxml($) {
32 local $_ = shift;
33 s/&/&/g;
34 s/</&lt;/g;
35 s/]]>/]]&gt;/g;
36 $_;
37 }
38
39 1;
40