ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC.pm (file contents):
Revision 1.205 by root, Sun Mar 29 22:28:12 2009 UTC vs.
Revision 1.215 by root, Wed Jan 18 13:42:19 2012 UTC

17use Carp (); 17use Carp ();
18 18
19our $VERSION; 19our $VERSION;
20 20
21BEGIN { 21BEGIN {
22 $VERSION = '2.03'; 22 $VERSION = '3.0';
23 23
24 use XSLoader; 24 use XSLoader;
25 XSLoader::load "Deliantra::Client", $VERSION; 25 XSLoader::load "Deliantra::Client", $VERSION;
26} 26}
27 27
35use File::Path (); 35use File::Path ();
36use Storable (); # finally 36use Storable (); # finally
37use Fcntl (); 37use Fcntl ();
38use JSON::XS qw(encode_json decode_json); 38use JSON::XS qw(encode_json decode_json);
39use Guard qw(guard); 39use Guard qw(guard);
40
41# modules to support other DC::* packages
42use List::Util ();
43use IO::AIO ();
44use Coro::AIO ();
45use AnyEvent::AIO ();
46
47use Deliantra::Protocol::Constants ();
40 48
41=item shorten $string[, $maxlength] 49=item shorten $string[, $maxlength]
42 50
43=cut 51=cut
44 52
179 187
180 %THEME = ( %$theme, %THEME ); 188 %THEME = ( %$theme, %THEME );
181 } 189 }
182} 190}
183 191
184sub read_cfg { 192sub read_cfg($) {
185 my ($file) = @_; 193 my ($file) = @_;
186 194
187 $::CFG = (load_json $file) || (load_json "$file.bak"); 195 $::CFG = (load_json $file) || (load_json "$file.bak");
188} 196}
189 197
190sub write_cfg { 198sub write_cfg($) {
191 my $file = "$Deliantra::VARDIR/client.cf"; 199 my $file = "$Deliantra::VARDIR/client.cf";
192 200
193 $::CFG->{VERSION} = $::VERSION; 201 $::CFG->{VERSION} = $::VERSION;
194 $::CFG->{layout} = DC::UI::get_layout (); 202 $::CFG->{layout} = DC::UI::get_layout ();
195 203
198 print $fh JSON::XS->new->utf8->pretty->encode ($::CFG); 206 print $fh JSON::XS->new->utf8->pretty->encode ($::CFG);
199 close $fh; 207 close $fh;
200 208
201 rename $file, "$file.bak"; 209 rename $file, "$file.bak";
202 rename "$file~", $file; 210 rename "$file~", $file;
211}
212
213sub load_cfg() {
214 if (-e "$Deliantra::VARDIR/client.cf") {
215 DC::read_cfg "$Deliantra::VARDIR/client.cf";
216 } else {
217 $::CFG = {};
218 }
219}
220
221sub save_cfg() {
222 write_cfg "$Deliantra::VARDIR/client.cf";
223}
224
225sub upgrade_cfg() {
226 my %DEF_CFG = (
227 config_autosave => 1,
228 sdl_mode => undef,
229 fullscreen => 1,
230 fast => 0,
231 force_opengl11 => undef,
232 disable_alpha => 0,
233 smooth_movement => 1,
234 smooth_transitions => 1,
235 texture_compression => 1,
236 map_scale => 1,
237 fow_enable => 1,
238 fow_intensity => 0,
239 fow_texture => 0,
240 map_smoothing => 1,
241 gui_fontsize => 1,
242 log_fontsize => 0.7,
243 gauge_fontsize => 1,
244 gauge_size => 0.35,
245 stat_fontsize => 0.7,
246 mapsize => 100,
247 audio_enable => 1,
248 audio_hw_channels => 0,
249 audio_hw_frequency => 0,
250 audio_hw_chunksize => 0,
251 audio_mix_channels => 8,
252 effects_enable => 1,
253 effects_volume => 1,
254 bgm_enable => 1,
255 bgm_volume => 0.5,
256 output_rate => "",
257 pickup => Deliantra::Protocol::Constants::PICKUP_SPELLBOOK
258 | Deliantra::Protocol::Constants::PICKUP_SKILLSCROLL
259 | Deliantra::Protocol::Constants::PICKUP_VALUABLES,
260 inv_sort => "mtime",
261 default => "profile", # default profile
262 show_tips => 1,
263 logview_max_par => 1000,
264 shift_fire_stop => 0,
265 uitheme => "wood",
266 map_shift_x => -24, # arbitrary
267 map_shift_y => +24, # arbitrary
268 #db_schema => 0,
269 );
270
271 while (my ($k, $v) = each %DEF_CFG) {
272 $::CFG->{$k} = $v unless exists $::CFG->{$k};
273 }
203} 274}
204 275
205sub http_proxy { 276sub http_proxy {
206 my @proxy = win32_proxy_info; 277 my @proxy = win32_proxy_info;
207 278

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines