1 | #!/opt/bin/perl |
1 | #!/opt/bin/perl |
2 | |
2 | |
|
|
3 | # do splash-screen thingy on win32 |
3 | my $startup_done = sub { }; |
4 | my $startup_done = sub { }; |
4 | our $PANGO = "1.5.0"; |
|
|
5 | |
|
|
6 | # do splash-screen thingy on win32 |
|
|
7 | BEGIN { |
5 | BEGIN { |
8 | if (%PAR::LibCache && $^O eq "MSWin32") { |
6 | if (%PAR::LibCache && $^O eq "MSWin32") { |
9 | while (my ($filename, $zip) = each %PAR::LibCache) { |
7 | while (my ($filename, $zip) = each %PAR::LibCache) { |
10 | $zip->extractMember ("SPLASH.bmp", "$ENV{PAR_TEMP}/SPLASH.bmp"); |
8 | $zip->extractMember ("SPLASH.bmp", "$ENV{PAR_TEMP}/SPLASH.bmp"); |
11 | } |
9 | } |
… | |
… | |
30 | # do things only needed for single-binary version (par) |
28 | # do things only needed for single-binary version (par) |
31 | BEGIN { |
29 | BEGIN { |
32 | if (%PAR::LibCache) { |
30 | if (%PAR::LibCache) { |
33 | @INC = grep ref, @INC; # weed out all paths except pars loader refs |
31 | @INC = grep ref, @INC; # weed out all paths except pars loader refs |
34 | |
32 | |
35 | my $tmp = $ENV{PAR_TEMP}; |
33 | my $root = $ENV{PAR_TEMP}; |
36 | |
34 | |
37 | while (my ($filename, $zip) = each %PAR::LibCache) { |
35 | while (my ($filename, $zip) = each %PAR::LibCache) { |
38 | for ($zip->memberNames) { |
36 | for ($zip->memberNames) { |
39 | next unless /^root\/(.*)/; |
37 | next unless /^root\/(.*)/; |
40 | $zip->extractMember ($_, "$tmp/$1") |
38 | $zip->extractMember ($_, "$root/$1") |
41 | unless -e "$tmp/$1"; |
39 | unless -e "$root/$1"; |
42 | } |
40 | } |
43 | } |
41 | } |
44 | |
42 | |
45 | if ($^O eq "MSWin32") { |
43 | if ($^O eq "MSWin32") { |
46 | # relocatable |
44 | # pango is relocatable on win32 |
47 | } else { |
45 | } else { |
|
|
46 | open my $fh, "<:perlio", "$root/pangoversion" |
|
|
47 | or die "pangoversion: $!"; |
|
|
48 | my $PANGO = <$fh>; |
48 | # unix, need to patch pango rc file |
49 | # unix, need to patch pango rc file |
49 | open my $fh, "<:perlio", "$tmp/usr/lib/pango/$PANGO/module-files.d/libpango1.0-0.modules" |
50 | open my $fh, "<:perlio", "$root/usr/lib/pango/$PANGO/module-files.d/libpango1.0-0.modules" |
50 | or die "$tmp/usr/lib/$PANGO/module-files.d/libpango1.0-0.modules: $!"; |
51 | or die "$root/usr/lib/$PANGO/module-files.d/libpango1.0-0.modules: $!"; |
51 | local $/; |
52 | local $/; |
52 | my $rc = <$fh>; |
53 | my $rc = <$fh>; |
53 | $rc =~ s/^\//$tmp\//gm; # replace abs paths by relative ones |
54 | $rc =~ s/^\//$root\//gm; # replace abs paths by relative ones |
54 | |
55 | |
55 | mkdir "$tmp/pango-modules"; |
56 | mkdir "$root/pango-modules"; |
56 | open my $fh, ">:perlio", "$tmp/pango-modules/pango.modules" |
57 | open my $fh, ">:perlio", "$root/pango-modules/pango.modules" |
57 | or die "$tmp/pango-modules/pango.modules: $!"; |
58 | or die "$root/pango-modules/pango.modules: $!"; |
58 | print $fh $rc; |
59 | print $fh $rc; |
59 | |
60 | |
60 | $ENV{PANGO_RC_FILE} = "$tmp/pango.rc"; |
61 | $ENV{PANGO_RC_FILE} = "$root/pango.rc"; |
61 | open my $fh, ">:perlio", $ENV{PANGO_RC_FILE} |
62 | open my $fh, ">:perlio", $ENV{PANGO_RC_FILE} |
62 | or die "$ENV{PANGO_RC_FILE}: $!"; |
63 | or die "$ENV{PANGO_RC_FILE}: $!"; |
63 | print $fh "[Pango]\nModuleFiles = $tmp/pango-modules\n"; |
64 | print $fh "[Pango]\nModuleFiles = $root/pango-modules\n"; |
64 | } |
65 | } |
65 | |
66 | |
66 | unshift @INC, $tmp; |
67 | unshift @INC, $root; |
67 | } |
68 | } |
68 | } |
69 | } |
69 | |
70 | |
70 | # need to do it again because that pile of garbage called PAR nukes it before main |
71 | # need to do it again because that pile of garbage called PAR nukes it before main |
71 | unshift @INC, $ENV{PAR_TEMP} |
72 | unshift @INC, $ENV{PAR_TEMP} |
… | |
… | |
86 | use CFPlus::DB; |
87 | use CFPlus::DB; |
87 | use CFPlus::UI; |
88 | use CFPlus::UI; |
88 | use CFPlus::UI::Canvas; |
89 | use CFPlus::UI::Canvas; |
89 | use CFPlus::UI::Inventory; |
90 | use CFPlus::UI::Inventory; |
90 | use CFPlus::UI::SpellList; |
91 | use CFPlus::UI::SpellList; |
|
|
92 | use CFPlus::UI::Dockable; |
91 | use CFPlus::UI::MessageWindow; |
93 | use CFPlus::UI::MessageWindow; |
|
|
94 | use CFPlus::UI::ChatView; |
92 | use CFPlus::Pod; |
95 | use CFPlus::Pod; |
93 | use CFPlus::MapWidget; |
96 | use CFPlus::MapWidget; |
94 | use CFPlus::Macro; |
97 | use CFPlus::Macro; |
95 | |
98 | |
96 | $SIG{QUIT} = sub { Carp::cluck "QUIT" }; |
99 | $SIG{QUIT} = sub { Carp::cluck "QUIT" }; |
… | |
… | |
113 | our $CONN; |
116 | our $CONN; |
114 | our $PROFILE; # current profile |
117 | our $PROFILE; # current profile |
115 | our $FAST; # fast, low-quality mode, possibly useful for software-rendering |
118 | our $FAST; # fast, low-quality mode, possibly useful for software-rendering |
116 | |
119 | |
117 | our $WANT_REFRESH; |
120 | our $WANT_REFRESH; |
118 | our $CAN_REFRESH; |
|
|
119 | |
121 | |
120 | our @SDL_MODES; |
122 | our @SDL_MODES; |
121 | our $WIDTH; |
123 | our $WIDTH; |
122 | our $HEIGHT; |
124 | our $HEIGHT; |
123 | our $FULLSCREEN; |
125 | our $FULLSCREEN; |
… | |
… | |
127 | our $FONT_FIXED; |
129 | our $FONT_FIXED; |
128 | |
130 | |
129 | our $MAP; |
131 | our $MAP; |
130 | our $MAPMAP; |
132 | our $MAPMAP; |
131 | our $MAPWIDGET; |
133 | our $MAPWIDGET; |
|
|
134 | our $COMPLETER; |
132 | our $BUTTONBAR; |
135 | our $BUTTONBAR; |
133 | our $METASERVER; |
136 | our $METASERVER; |
134 | our $LOGIN_BUTTON; |
137 | our $LOGIN_BUTTON; |
135 | our $QUIT_DIALOG; |
138 | our $QUIT_DIALOG; |
136 | our $HOST_ENTRY; |
139 | our $HOST_ENTRY; |
… | |
… | |
147 | our $PL_WINDOW; |
150 | our $PL_WINDOW; |
148 | |
151 | |
149 | our $MUSIC_PLAYING_WIDGET; |
152 | our $MUSIC_PLAYING_WIDGET; |
150 | our $LICENSE_WIDGET; |
153 | our $LICENSE_WIDGET; |
151 | |
154 | |
|
|
155 | our $PICKUP_PAGE; |
152 | our $INVENTORY_PAGE; |
156 | our $INVENTORY_PAGE; |
153 | our $STATS_PAGE; |
157 | our $STATS_PAGE; |
154 | our $SKILL_PAGE; |
158 | our $SKILL_PAGE; |
155 | our $SPELL_PAGE; |
159 | our $SPELL_PAGE; |
156 | our $SPELL_LIST; |
160 | our $SPELL_LIST; |
… | |
… | |
168 | our $STATUSBOX; |
172 | our $STATUSBOX; |
169 | our $DEBUG_STATUS; |
173 | our $DEBUG_STATUS; |
170 | |
174 | |
171 | our $INV; |
175 | our $INV; |
172 | our $INVR; |
176 | our $INVR; |
173 | our $INV_RIGHT_HB; |
177 | our $INVR_HB; |
174 | |
|
|
175 | our $PICKUP_CFG; |
|
|
176 | |
178 | |
177 | ############################################################################# |
179 | ############################################################################# |
178 | |
180 | |
179 | sub status { |
181 | sub status { |
180 | $STATUSBOX->add (CFPlus::asxml $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); |
182 | $STATUSBOX->add (CFPlus::asxml $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); |
… | |
… | |
183 | sub debug { |
185 | sub debug { |
184 | $DEBUG_STATUS->set_text ($_[0]); |
186 | $DEBUG_STATUS->set_text ($_[0]); |
185 | } |
187 | } |
186 | |
188 | |
187 | sub message { |
189 | sub message { |
188 | my ($para) = @_; |
|
|
189 | $MESSAGE_WINDOW->message ($para); |
190 | $MESSAGE_WINDOW->message (@_); |
190 | } |
191 | } |
191 | |
192 | |
192 | ############################################################################# |
193 | ############################################################################# |
193 | #TODO: maybe move into own audio module... |
194 | #TODO: maybe move into own audio module... |
194 | |
195 | |
… | |
… | |
217 | my ($face) = @_; |
218 | my ($face) = @_; |
218 | |
219 | |
219 | $CFG->{effects_enable} |
220 | $CFG->{effects_enable} |
220 | or return; |
221 | or return; |
221 | |
222 | |
|
|
223 | $AUDIO_PLAY{$face} |
|
|
224 | or return; |
|
|
225 | |
222 | if (my $chunk = $AUDIO_CHUNK{$face}) { |
226 | if (my $chunk = $AUDIO_CHUNK{$face}) { |
223 | for (grep $_->[0] >= Event::time, @{(delete $AUDIO_PLAY{$face}) || []}) { |
227 | for (grep $_->[0] >= Event::time, @{(delete $AUDIO_PLAY{$face}) || []}) { |
224 | my (undef, $dx, $dy, $vol) = @$_; |
228 | my (undef, $dx, $dy, $vol) = @$_; |
225 | |
229 | |
226 | my $channel = CFPlus::Channel::find; |
230 | my $channel = CFPlus::Channel::find; |
227 | $channel->volume ($vol * $CFG->{effects_volume} * 128 / 255); |
231 | $channel->volume ($vol * $CFG->{effects_volume} * 128 / 255); |
228 | $dx = $dx / 10 * 255; |
|
|
229 | $channel->set_panning (255 - $dx, 255 + $dx); |
|
|
230 | |
|
|
231 | # my $angle = $dx ? : $dx < 0 ? |
|
|
232 | # my $distance = -$vol; |
|
|
233 | # $channel->set_position ($angle, $distance); |
232 | $channel->set_position_r ($dx, $dy, 20); |
234 | |
|
|
235 | $chunk->play ($channel); |
233 | $chunk->play ($channel); |
236 | } |
234 | } |
237 | } else { |
235 | } else { |
238 | # sound_meta not set means data is in flight either way |
236 | # sound_meta not set means data is in flight either way |
239 | my $meta = $CONN->{sound_meta}{$face} |
237 | my $meta = $CONN->{face}[$face] |
240 | or return; |
238 | or return; |
241 | |
239 | |
|
|
240 | $meta->{data} |
|
|
241 | or return; |
|
|
242 | |
242 | # if its a jingle, play it as ambient music |
243 | # if its a jingle, play it as ambient music |
243 | if ($meta->{meta}{jingle}) { |
244 | if ($meta->{data}{jingle}) { |
244 | delete $AUDIO_PLAY{$face}; # take the jingle out of the sound queue |
245 | if (delete $AUDIO_PLAY{$face}) { # take the jingle out of the sound queue |
245 | push @MUSIC_JINGLE, $meta; # push it oto the music/jingle queue |
246 | push @MUSIC_JINGLE, $meta; # push it oto the music/jingle queue |
246 | &audio_music_push ($face); |
247 | &audio_music_push ($face); |
|
|
248 | } |
247 | } else { |
249 | } else { |
248 | # fetch from database |
250 | # fetch from database |
249 | CFPlus::DB::get res_data => $meta->{name}, sub { |
251 | CFPlus::DB::get res_data => $meta->{name}, sub { |
250 | my $rwops = new CFPlus::RW $_[0]; |
252 | my $rwops = new CFPlus::RW $_[0]; |
251 | my $chunk = new CFPlus::MixChunk $rwops; |
253 | my $chunk = new CFPlus::MixChunk $rwops |
|
|
254 | or Carp::confess "sound face " . (JSON::XS::to_json $meta) . " unloadable: " . CFPlus::Mix_GetError; |
252 | $chunk->volume (($meta->{meta}{volume} || 1) * 128); |
255 | $chunk->volume (($meta->{data}{volume} || 1) * 128); |
253 | $AUDIO_CHUNK{$face} = $chunk; |
256 | $AUDIO_CHUNK{$face} = $chunk; |
254 | |
257 | |
255 | audio_sound_push ($face); |
258 | audio_sound_push ($face); |
256 | }; |
259 | }; |
257 | } |
260 | } |
… | |
… | |
265 | or return; |
268 | or return; |
266 | $CFG->{effects_enable} |
269 | $CFG->{effects_enable} |
267 | or return; |
270 | or return; |
268 | |
271 | |
269 | my $queue = $AUDIO_PLAY{$face} ||= []; |
272 | my $queue = $AUDIO_PLAY{$face} ||= []; |
270 | push @$queue, [Event::time + 0.2, $dx, $dy, $vol]; # delay sound by max. 0.2s |
273 | push @$queue, [Event::time + 0.6, $dx, $dy, $vol]; # do not play sound for outdated events |
271 | audio_sound_push $face |
274 | audio_sound_push $face |
272 | unless @$queue > 1; |
275 | unless @$queue > 1; |
273 | } |
276 | } |
274 | |
277 | |
275 | sub audio_music_set_meta { |
278 | sub audio_music_set_meta { |
276 | my ($meta) = @_; |
279 | my ($meta) = @_; |
277 | |
280 | |
278 | $MUSIC_PLAYING_META = $meta; |
281 | $MUSIC_PLAYING_META = $meta; |
279 | $MUSIC_PLAYING_WIDGET->set_markup ( |
282 | $MUSIC_PLAYING_WIDGET->set_markup ( |
280 | "<b>Name</b>: " . (CFPlus::asxml $meta->{meta}{name}) . "\n" |
283 | "<b>Name</b>: " . (CFPlus::asxml $meta->{data}{name}) . "\n" |
281 | . "<b>Author</b>: " . (CFPlus::asxml $meta->{meta}{author}) . "\n" |
284 | . "<b>Author</b>: " . (CFPlus::asxml $meta->{data}{author}) . "\n" |
282 | . "<b>Source</b>: " . (CFPlus::asxml $meta->{meta}{source}) . "\n" |
285 | . "<b>Source</b>: " . (CFPlus::asxml $meta->{data}{source}) . "\n" |
283 | . "<b>License</b>: " . (CFPlus::asxml $meta->{meta}{license}) |
286 | . "<b>License</b>: " . (CFPlus::asxml $meta->{data}{license}) |
284 | ); |
287 | ); |
285 | } |
288 | } |
286 | |
289 | |
287 | sub audio_music_update_volume { |
290 | sub audio_music_update_volume { |
288 | return unless $MUSIC_PLAYING_META; |
291 | return unless $MUSIC_PLAYING_META; |
289 | my $volume = $MUSIC_PLAYING_META->{meta}{volume} || 1; |
292 | my $volume = $MUSIC_PLAYING_META->{data}{volume} || 1; |
290 | my $base = $MUSIC_PLAYING_META->{meta}{jingle} ? 1 : $CFG->{bgm_volume}; |
293 | my $base = $MUSIC_PLAYING_META->{data}{jingle} ? 1 : $CFG->{bgm_volume}; |
291 | CFPlus::MixMusic::volume $base * $volume * 128; |
294 | CFPlus::MixMusic::volume $base * $volume * 128; |
292 | } |
295 | } |
293 | |
296 | |
294 | sub audio_music_start { |
297 | sub audio_music_start { |
295 | my $meta = $MUSIC_PLAYING_META; |
298 | my $meta = $MUSIC_PLAYING_META; |
… | |
… | |
308 | my $rwops = $meta->{path} |
311 | my $rwops = $meta->{path} |
309 | ? new_from_file CFPlus::RW $meta->{path} |
312 | ? new_from_file CFPlus::RW $meta->{path} |
310 | : new CFPlus::RW $$MUSIC_PLAYING_DATA; |
313 | : new CFPlus::RW $$MUSIC_PLAYING_DATA; |
311 | |
314 | |
312 | $MUSIC_PLAYER = new CFPlus::MixMusic $rwops |
315 | $MUSIC_PLAYER = new CFPlus::MixMusic $rwops |
313 | or ((warn CFPlus::Mix_GetError), return); # pretty fatal error |
316 | or Carp::confess "music face $meta->{face} unloadable: " . CFPlus::Mix_GetError; |
314 | |
317 | |
315 | my $NOW = time; |
318 | my $NOW = time; |
316 | |
319 | |
317 | if ($MUSIC_PLAYING_META->{stop_time} > $NOW - $MUSIC_RESUME) { |
320 | if ($MUSIC_PLAYING_META->{stop_time} > $NOW - $MUSIC_RESUME) { |
318 | my $pos = $MUSIC_PLAYING_META->{stop_pos}; |
321 | my $pos = $MUSIC_PLAYING_META->{stop_pos}; |
319 | $MUSIC_PLAYER->fade_in_pos (0, 1000, $pos); |
322 | $MUSIC_PLAYER->fade_in_pos (0, 700, $pos); |
320 | $MUSIC_START = time - $pos; |
323 | $MUSIC_START = time - $pos; |
321 | } else { |
324 | } else { |
322 | $MUSIC_PLAYER->play (0); |
325 | $MUSIC_PLAYER->play (0); |
323 | $MUSIC_START = time; |
326 | $MUSIC_START = time; |
324 | } |
327 | } |
… | |
… | |
338 | $fade_out = 333; |
341 | $fade_out = 333; |
339 | } else { |
342 | } else { |
340 | return unless $CFG->{bgm_enable}; |
343 | return unless $CFG->{bgm_enable}; |
341 | |
344 | |
342 | my @have = |
345 | my @have = |
343 | grep $_, |
346 | grep $_ && $_->{data}, |
344 | map $CONN->{music_meta}{$_}, |
347 | map $CONN->{face}[$_], |
345 | @$MUSIC_WANT; |
348 | @$MUSIC_WANT; |
|
|
349 | |
|
|
350 | # randomize music a bit so that the order is not always the same |
|
|
351 | $_->{stop_time} ||= rand for @have; |
346 | |
352 | |
347 | @MUSIC_HAVE = @have |
353 | @MUSIC_HAVE = @have |
348 | if @have; |
354 | if @have; |
349 | |
355 | |
350 | # default MUSIC_HAVE == MUSIC_DEFAULT |
356 | # default MUSIC_HAVE == MUSIC_DEFAULT |
351 | @MUSIC_HAVE = { path => CFPlus::find_rcfile "music/$MUSIC_DEFAULT" } unless @MUSIC_HAVE; |
357 | @MUSIC_HAVE = { path => CFPlus::find_rcfile "music/$MUSIC_DEFAULT" } unless @MUSIC_HAVE; |
352 | $fade_out = 1000; |
358 | $fade_out = 700; |
353 | } |
359 | } |
354 | |
360 | |
355 | # if the currently playing song is acceptable, let it continue |
361 | # if the currently playing song is acceptable, let it continue |
356 | return if grep $MUSIC_PLAYING_META == $_, @MUSIC_HAVE; |
362 | return if grep $MUSIC_PLAYING_META == $_, @MUSIC_HAVE; |
357 | |
363 | |
… | |
… | |
366 | @MUSIC_HAVE = sort { $a->{stop_time} <=> $b->{stop_time} } @MUSIC_HAVE; |
372 | @MUSIC_HAVE = sort { $a->{stop_time} <=> $b->{stop_time} } @MUSIC_HAVE; |
367 | |
373 | |
368 | # if the most recently-played piece played very recently, |
374 | # if the most recently-played piece played very recently, |
369 | # resume it, else choose the oldest piece for rotation. |
375 | # resume it, else choose the oldest piece for rotation. |
370 | audio_music_set_meta |
376 | audio_music_set_meta |
371 | $MUSIC_HAVE[-1]{stop_time} > $NOW - $MUSIC_RESUME |
377 | $MUSIC_HAVE[-1]{stop_pos} && $MUSIC_HAVE[-1]{stop_time} > $NOW - $MUSIC_RESUME |
372 | ? $MUSIC_HAVE[-1] |
378 | ? $MUSIC_HAVE[-1] |
373 | : $MUSIC_HAVE[0]; |
379 | : $MUSIC_HAVE[0]; |
374 | |
380 | |
375 | audio_music_start; |
381 | audio_music_start; |
376 | } |
382 | } |
… | |
… | |
382 | $MUSIC_WANT = $songs; |
388 | $MUSIC_WANT = $songs; |
383 | audio_music_push; |
389 | audio_music_push; |
384 | } |
390 | } |
385 | |
391 | |
386 | sub audio_music_finished { |
392 | sub audio_music_finished { |
|
|
393 | if ($MUSIC_PLAYING_META) { |
|
|
394 | $MUSIC_PLAYING_META->{stop_time} = time; |
|
|
395 | } |
|
|
396 | |
387 | # we compress multiple jingles of the same type |
397 | # we compress multiple jingles of the same type |
388 | shift @MUSIC_JINGLE |
398 | shift @MUSIC_JINGLE |
389 | while @MUSIC_JINGLE && $MUSIC_PLAYING_META == $MUSIC_JINGLE[0]; |
399 | while @MUSIC_JINGLE && $MUSIC_PLAYING_META == $MUSIC_JINGLE[0]; |
390 | |
400 | |
391 | $MUSIC_PLAYING_WIDGET->clear; |
401 | $MUSIC_PLAYING_WIDGET->clear; |
… | |
… | |
417 | |
427 | |
418 | sub audio_shutdown { |
428 | sub audio_shutdown { |
419 | undef $MUSIC_PLAYER; |
429 | undef $MUSIC_PLAYER; |
420 | undef $MUSIC_PLAYING_META; |
430 | undef $MUSIC_PLAYING_META; |
421 | undef $MUSIC_PLAYING_DATA; |
431 | undef $MUSIC_PLAYING_DATA; |
422 | |
|
|
423 | audio_music_set_meta { }; |
|
|
424 | |
432 | |
425 | $MUSIC_WANT = []; |
433 | $MUSIC_WANT = []; |
426 | @MUSIC_JINGLE = (); |
434 | @MUSIC_JINGLE = (); |
427 | %AUDIO_PLAY = (); |
435 | %AUDIO_PLAY = (); |
428 | %AUDIO_CHUNK = (); |
436 | %AUDIO_CHUNK = (); |
… | |
… | |
773 | state => $CFG->{fullscreen}, |
781 | state => $CFG->{fullscreen}, |
774 | tooltip => "Bring the client into fullscreen mode.", |
782 | tooltip => "Bring the client into fullscreen mode.", |
775 | on_changed => sub { my ($self, $value) = @_; $CFG->{fullscreen} = $value; 0 } |
783 | on_changed => sub { my ($self, $value) = @_; $CFG->{fullscreen} = $value; 0 } |
776 | ); |
784 | ); |
777 | |
785 | |
|
|
786 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Force OpenGL 1.1"); |
|
|
787 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
|
|
788 | state => $CFG->{force_opengl11}, |
|
|
789 | tooltip => "Limit CFPlus to use OpenGL 1.1 features only. This will normally result in " |
|
|
790 | . "higher memory usage and slower performance. It will, however, help tremendously on " |
|
|
791 | . "cards that claim to support a feature but fall back to software rendering. " |
|
|
792 | . "Nvidia Geforce FX cards are known to claim features the hardware doesn't support, " |
|
|
793 | . "but cards and drivers from other vendors (ATI) are often just as bad. <b>If you " |
|
|
794 | . "experience extremely low framerates and your card should do better, try this option.</b>", |
|
|
795 | on_changed => sub { my ($self, $value) = @_; $CFG->{force_opengl11} = $value; 0 } |
|
|
796 | ); |
|
|
797 | |
|
|
798 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Compress Textures"); |
|
|
799 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
|
|
800 | state => $CFG->{texture_compression}, |
|
|
801 | tooltip => "Use texture compression. Normally this will not reduce visual quality noticable but " |
|
|
802 | . "will save a lot of memory and increase performance. The compression algorithm " |
|
|
803 | . "can differ form card to card, so your mileage may vary. This setting is ignored in " |
|
|
804 | . "forced OpenGL 1.1 mode.", |
|
|
805 | on_changed => sub { my ($self, $value) = @_; $CFG->{texture_compression} = $value; 0 } |
|
|
806 | ); |
|
|
807 | |
778 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fast & Ugly"); |
808 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fast & Ugly"); |
779 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
809 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
780 | state => $CFG->{fast}, |
810 | state => $CFG->{fast}, |
781 | tooltip => "Lower the visual quality considerably to speed up rendering.", |
811 | tooltip => "Lower the visual quality considerably to speed up rendering.", |
782 | on_changed => sub { my ($self, $value) = @_; $CFG->{fast} = $value; 0 } |
812 | on_changed => sub { my ($self, $value) = @_; $CFG->{fast} = $value; 0 } |
… | |
… | |
808 | |
838 | |
809 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Map Smoothing"); |
839 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Map Smoothing"); |
810 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
840 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
811 | state => $CFG->{map_smoothing}, |
841 | state => $CFG->{map_smoothing}, |
812 | tooltip => "<b>Map Smoothing</b> tries to make tile borders less square. " |
842 | tooltip => "<b>Map Smoothing</b> tries to make tile borders less square. " |
813 | . "This increases load on the graphics subsystem and works only with 2.x servers. " |
843 | . "This increases load on the graphics subsystem and works only with TRT servers. " |
814 | . "Changes take effect at next connection only.", |
844 | . "Changes take effect at next login only.", |
815 | on_changed => sub { my ($self, $value) = @_; $CFG->{map_smoothing} = $value; 0 } |
845 | on_changed => sub { my ($self, $value) = @_; $CFG->{map_smoothing} = $value; 0 } |
816 | ); |
846 | ); |
817 | |
847 | |
818 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fog of War"); |
848 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fog of War"); |
819 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
849 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
… | |
… | |
830 | ); |
860 | ); |
831 | |
861 | |
832 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Message Fontsize"); |
862 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Message Fontsize"); |
833 | $table->add_at (1, $row++, new CFPlus::UI::Slider |
863 | $table->add_at (1, $row++, new CFPlus::UI::Slider |
834 | range => [$CFG->{log_fontsize}, 0.5, 2, 0, 0.1], |
864 | range => [$CFG->{log_fontsize}, 0.5, 2, 0, 0.1], |
835 | tooltip => "The font size used by the <b>message/server log</b> window only. Changes are instant.", |
865 | tooltip => "The font size used by the <b>message/server log</b> window only. Changes are instant, " |
|
|
866 | . "but you still need to press apply to correctly re-layout the widget.", |
836 | on_changed => sub { $MESSAGE_WINDOW->set_fontsize ($CFG->{log_fontsize} = $_[1]); 0 }, |
867 | on_changed => sub { $MESSAGE_WINDOW->set_fontsize ($CFG->{log_fontsize} = $_[1]); 0 }, |
837 | ); |
868 | ); |
838 | |
869 | |
839 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Gauge fontsize"); |
870 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Gauge fontsize"); |
840 | $table->add_at (1, $row++, new CFPlus::UI::Slider |
871 | $table->add_at (1, $row++, new CFPlus::UI::Slider |
… | |
… | |
877 | # $table->add_at (0, 9, new CFPlus::UI::Label valign => 0, align => 1, text => "Effects Volume"); |
908 | # $table->add_at (0, 9, new CFPlus::UI::Label valign => 0, align => 1, text => "Effects Volume"); |
878 | # $table->add_at (1, 8, new CFPlus::UI::Slider range => [$CFG->{effects_volume}, 0, 128, 1], on_changed => sub { |
909 | # $table->add_at (1, 8, new CFPlus::UI::Slider range => [$CFG->{effects_volume}, 0, 128, 1], on_changed => sub { |
879 | # $CFG->{effects_volume} = $_[1]; |
910 | # $CFG->{effects_volume} = $_[1]; |
880 | # }); |
911 | # }); |
881 | |
912 | |
882 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Effects Volume"); |
913 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Sound Effects"); |
883 | $table->add_at (1, $row, new CFPlus::UI::CheckBox |
914 | $table->add_at (1, $row, new CFPlus::UI::CheckBox |
884 | expand => 1, state => $CFG->{effects_enable}, |
915 | expand => 1, state => $CFG->{effects_enable}, |
885 | tooltip => "If enabled, sound effects are enabled. If disabled, no sound effects will be played.", |
916 | tooltip => "If enabled, sound effects are enabled. If disabled, no sound effects will be played.", |
|
|
917 | on_changed => sub { |
886 | on_changed => sub { $CFG->{effects_enable} = $_[1]; 0 } |
918 | $CFG->{effects_enable} = $_[1]; |
|
|
919 | $CONN->update_fx_want if $CONN; |
|
|
920 | 0 |
|
|
921 | } |
887 | ); |
922 | ); |
888 | $table->add_at (2, $row++, new CFPlus::UI::Slider |
923 | $table->add_at (2, $row++, new CFPlus::UI::Slider |
889 | expand => 1, range => [$CFG->{effects_volume}, 0, 1, 0, 1/128], |
924 | expand => 1, range => [$CFG->{effects_volume}, 0, 1, 0, 1/128], |
890 | tooltip => "The relative volume of sound effects. Best audio quality is achieved if this " |
925 | tooltip => "The relative volume of sound effects. Best audio quality is achieved if this " |
891 | . "is set highest and you use your operating system volume setting. Changes are instant.", |
926 | . "is set highest (rightmost) and you use your operating system volume setting. Changes are instant.", |
892 | on_changed => sub { $CFG->{effects_volume} = $_[1]; 0 } |
927 | on_changed => sub { $CFG->{effects_volume} = $_[1]; 0 } |
893 | ); |
928 | ); |
894 | |
929 | |
895 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Background Music"); |
930 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Background Music"); |
896 | $table->add_at (1, $row, new CFPlus::UI::CheckBox |
931 | $table->add_at (1, $row, new CFPlus::UI::CheckBox |
897 | expand => 1, state => $CFG->{bgm_enable}, |
932 | expand => 1, state => $CFG->{bgm_enable}, |
898 | tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played.", |
933 | tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played.", |
899 | on_changed => sub { $CFG->{bgm_enable} = $_[1]; 0 } |
934 | on_changed => sub { |
|
|
935 | $CFG->{bgm_enable} = $_[1]; |
|
|
936 | $CONN->update_fx_want if $CONN; |
|
|
937 | audio_music_push; |
|
|
938 | 0 |
|
|
939 | } |
900 | ); |
940 | ); |
901 | $table->add_at (2, $row++, new CFPlus::UI::Slider |
941 | $table->add_at (2, $row++, new CFPlus::UI::Slider |
902 | expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0, 1/128], |
942 | expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0, 1/128], |
903 | tooltip => "The volume of the background music. Changes are instant.", |
943 | tooltip => "The volume of the background music. Changes are instant.", |
904 | on_changed => sub { $CFG->{bgm_volume} = $_[1]; audio_music_update_volume; 0 } |
944 | on_changed => sub { $CFG->{bgm_volume} = $_[1]; audio_music_update_volume; 0 } |
… | |
… | |
955 | $hb->add (my $hg = new CFPlus::UI::Gauge type => 'hp', tooltip => "#stat_health"); |
995 | $hb->add (my $hg = new CFPlus::UI::Gauge type => 'hp', tooltip => "#stat_health"); |
956 | $hb->add (my $mg = new CFPlus::UI::Gauge type => 'mana', tooltip => "#stat_mana"); |
996 | $hb->add (my $mg = new CFPlus::UI::Gauge type => 'mana', tooltip => "#stat_mana"); |
957 | $hb->add (my $gg = new CFPlus::UI::Gauge type => 'grace', tooltip => "#stat_grace"); |
997 | $hb->add (my $gg = new CFPlus::UI::Gauge type => 'grace', tooltip => "#stat_grace"); |
958 | $hb->add (my $fg = new CFPlus::UI::Gauge type => 'food', tooltip => "#stat_food"); |
998 | $hb->add (my $fg = new CFPlus::UI::Gauge type => 'food', tooltip => "#stat_food"); |
959 | |
999 | |
960 | $vbox->add (my $exp = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_exp"); |
1000 | $vbox->add (my $exp = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_exp"); |
|
|
1001 | $vbox->add (my $prg = new CFPlus::UI::ExperienceProgress); |
|
|
1002 | $vbox->add (my $sklprg = new CFPlus::UI::ExperienceProgress); |
961 | $vbox->add (my $rng = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_ranged"); |
1003 | $vbox->add (my $rng = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_ranged"); |
962 | |
1004 | |
963 | $GAUGES = { |
1005 | $GAUGES = { |
|
|
1006 | exp => $exp, prg => $prg, sklprg => $sklprg, |
964 | exp => $exp, win => $win, range => $rng, |
1007 | win => $win, range => $rng, |
965 | food => $fg, mana => $mg, hp => $hg, grace => $gg |
1008 | hp => $hg, mana => $mg, grace => $gg, food => $fg, |
966 | }; |
1009 | }; |
967 | |
1010 | |
968 | &set_gauge_window_fontsize; |
1011 | &set_gauge_window_fontsize; |
969 | |
1012 | |
970 | $win |
1013 | $win |
… | |
… | |
1171 | $r |
1214 | $r |
1172 | } |
1215 | } |
1173 | |
1216 | |
1174 | sub skill_window { |
1217 | sub skill_window { |
1175 | my $sw = new CFPlus::UI::ScrolledWindow (expand => 1); |
1218 | my $sw = new CFPlus::UI::ScrolledWindow (expand => 1); |
|
|
1219 | |
1176 | $sw->add ($STATWIDS->{skill_tbl} = new CFPlus::UI::Table expand => 1, col_expand => [0, 0, 1, 0, 0, 1]); |
1220 | $sw->add ($STATWIDS->{skill_tbl} = new CFPlus::UI::Table expand => 1, col_expand => [0, 0, 1, .1, 0, 0, 1, .1]); |
|
|
1221 | |
1177 | $sw |
1222 | $sw |
1178 | } |
1223 | } |
1179 | |
1224 | |
1180 | sub formsep($) { |
1225 | sub formsep($) { |
1181 | scalar reverse join ",", unpack "(A3)*", reverse $_[0] * 1 |
1226 | scalar reverse join ",", unpack "(A3)*", reverse $_[0] * 1 |
… | |
… | |
1593 | $sw1->add ($INV = new CFPlus::UI::Inventory); |
1638 | $sw1->add ($INV = new CFPlus::UI::Inventory); |
1594 | $INV->set_sort_order ($SORT_ORDER{$::CFG->{inv_sort}}); |
1639 | $INV->set_sort_order ($SORT_ORDER{$::CFG->{inv_sort}}); |
1595 | |
1640 | |
1596 | $hb->add (my $vb2 = new CFPlus::UI::VBox); |
1641 | $hb->add (my $vb2 = new CFPlus::UI::VBox); |
1597 | |
1642 | |
1598 | $vb2->add ($INV_RIGHT_HB = new CFPlus::UI::HBox); |
1643 | $vb2->add ($INVR_HB = new CFPlus::UI::HBox); |
1599 | |
1644 | |
1600 | $vb2->add (my $sw2 = new CFPlus::UI::ScrolledWindow expand => 1, scroll_y => 1); |
1645 | $vb2->add (my $sw2 = new CFPlus::UI::ScrolledWindow expand => 1, scroll_y => 1); |
1601 | $sw2->add ($INVR = new CFPlus::UI::Inventory); |
1646 | $sw2->add ($INVR = new CFPlus::UI::Inventory); |
1602 | |
1647 | |
1603 | # XXX: Call after $INVR = ... because set_opencont sets the items |
1648 | # XXX: Call after $INVR = ... because set_opencont sets the items |
… | |
… | |
1626 | } |
1671 | } |
1627 | |
1672 | |
1628 | sub add_license { |
1673 | sub add_license { |
1629 | my ($meta) = @_; |
1674 | my ($meta) = @_; |
1630 | |
1675 | |
1631 | $meta = $meta->{meta} |
1676 | $meta = $meta->{data} |
1632 | or return; |
1677 | or return; |
1633 | |
1678 | |
1634 | $meta->{license} || $meta->{author} || $meta->{source} |
1679 | $meta->{license} || $meta->{author} || $meta->{source} |
1635 | or return; |
1680 | or return; |
1636 | |
1681 | |
… | |
… | |
1690 | $ntb->add_tab ( |
1735 | $ntb->add_tab ( |
1691 | "Inventory (F5)" => $INVENTORY_PAGE = inventory_widget, |
1736 | "Inventory (F5)" => $INVENTORY_PAGE = inventory_widget, |
1692 | "Toggles the inventory window, where you can manage your loot (or treasures :). " |
1737 | "Toggles the inventory window, where you can manage your loot (or treasures :). " |
1693 | . "You can also hit the <b>Tab</b>-key to show/hide the Inventory." |
1738 | . "You can also hit the <b>Tab</b>-key to show/hide the Inventory." |
1694 | ); |
1739 | ); |
1695 | $ntb->add_tab (Pickup => autopickup_setup, |
1740 | $ntb->add_tab (Pickup => $PICKUP_PAGE = autopickup_setup, |
1696 | "Configure autopickup settings, i.e. which items you will pick up automatically when walking (or running) over them."); |
1741 | "Configure autopickup settings, i.e. which items you will pick up automatically when walking (or running) over them."); |
1697 | |
1742 | |
1698 | $ntb->add_tab (Media => media_window, |
1743 | $ntb->add_tab (Media => media_window, |
1699 | "License, Author and Source info for media sent by the server."); |
1744 | "License, Author and Source info for media sent by the server."); |
1700 | |
1745 | |
… | |
… | |
1858 | on_activate => sub { $QUIT_DIALOG->hide; 0 }, |
1903 | on_activate => sub { $QUIT_DIALOG->hide; 0 }, |
1859 | ); |
1904 | ); |
1860 | $hb->add (new CFPlus::UI::Button |
1905 | $hb->add (new CFPlus::UI::Button |
1861 | text => "Quit anyway", |
1906 | text => "Quit anyway", |
1862 | expand => 1, |
1907 | expand => 1, |
1863 | on_activate => sub { exit }, |
1908 | on_activate => sub { Event::unloop_all }, |
1864 | ); |
1909 | ); |
1865 | } |
1910 | } |
1866 | |
1911 | |
1867 | $QUIT_DIALOG->show; |
1912 | $QUIT_DIALOG->show; |
1868 | $QUIT_DIALOG->grab_focus; |
1913 | $QUIT_DIALOG->grab_focus; |
… | |
… | |
1941 | |
1986 | |
1942 | $SDL_ACTIVE = 1; |
1987 | $SDL_ACTIVE = 1; |
1943 | $LAST_REFRESH = time - 0.01; |
1988 | $LAST_REFRESH = time - 0.01; |
1944 | |
1989 | |
1945 | CFPlus::OpenGL::init; |
1990 | CFPlus::OpenGL::init; |
|
|
1991 | CFPlus::Macro::init; |
1946 | |
1992 | |
1947 | $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize}; |
1993 | $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize}; |
1948 | |
1994 | |
1949 | $CFPlus::UI::ROOT->configure (0, 0, $WIDTH, $HEIGHT);#d# |
1995 | $CFPlus::UI::ROOT->configure (0, 0, $WIDTH, $HEIGHT);#d# |
1950 | |
1996 | |
1951 | ############################################################################# |
1997 | ############################################################################# |
1952 | |
1998 | |
1953 | if ($DEBUG_STATUS) { |
1999 | if ($DEBUG_STATUS) { |
1954 | CFPlus::UI::rescale_widgets $WIDTH / $old_w, $HEIGHT / $old_h; |
2000 | CFPlus::UI::rescale_widgets $WIDTH / $old_w, $HEIGHT / $old_h; |
1955 | } else { |
2001 | } else { |
1956 | # create the widgets |
2002 | # create/configure the widgets |
|
|
2003 | |
|
|
2004 | $CFPlus::UI::ROOT->connect (key_down => sub { |
|
|
2005 | my (undef, $ev) = @_; |
|
|
2006 | |
|
|
2007 | if (my @macros = CFPlus::Macro::find $ev) { |
|
|
2008 | CFPlus::Macro::execute $_ for @macros; |
|
|
2009 | |
|
|
2010 | return 1; |
|
|
2011 | } |
|
|
2012 | |
|
|
2013 | 0 |
|
|
2014 | }); |
1957 | |
2015 | |
1958 | $DEBUG_STATUS = new CFPlus::UI::Label |
2016 | $DEBUG_STATUS = new CFPlus::UI::Label |
1959 | padding => 0, |
2017 | padding => 0, |
1960 | z => 100, |
2018 | z => 100, |
1961 | force_x => "max", |
2019 | force_x => "max", |
… | |
… | |
1991 | $MESSAGE_WINDOW->activate_console ($preset) |
2049 | $MESSAGE_WINDOW->activate_console ($preset) |
1992 | if $MESSAGE_WINDOW; |
2050 | if $MESSAGE_WINDOW; |
1993 | }); |
2051 | }); |
1994 | $MAPWIDGET->show; |
2052 | $MAPWIDGET->show; |
1995 | $MAPWIDGET->grab_focus; |
2053 | $MAPWIDGET->grab_focus; |
|
|
2054 | |
|
|
2055 | $COMPLETER = new CFPlus::MapWidget::Command:: |
|
|
2056 | command => { }, |
|
|
2057 | tooltip => "#completer_help", |
|
|
2058 | ; |
1996 | |
2059 | |
1997 | $SETUP_DIALOG = new CFPlus::UI::Toplevel |
2060 | $SETUP_DIALOG = new CFPlus::UI::Toplevel |
1998 | title => "Setup", |
2061 | title => "Setup", |
1999 | name => "setup_dialog", |
2062 | name => "setup_dialog", |
2000 | x => 'center', |
2063 | x => 'center', |
… | |
… | |
2062 | tooltip => "Terminates the program", |
2125 | tooltip => "Terminates the program", |
2063 | on_activate => sub { |
2126 | on_activate => sub { |
2064 | if ($CONN) { |
2127 | if ($CONN) { |
2065 | open_quit_dialog; |
2128 | open_quit_dialog; |
2066 | } else { |
2129 | } else { |
2067 | exit; |
2130 | Event::unloop_all; |
2068 | } |
2131 | } |
2069 | 0 |
2132 | 0 |
2070 | }, |
2133 | }, |
2071 | ); |
2134 | ); |
2072 | |
2135 | |
2073 | $BUTTONBAR->show; |
2136 | $BUTTONBAR->show; |
2074 | $SETUP_DIALOG->show; |
2137 | $SETUP_DIALOG->show; |
|
|
2138 | $MESSAGE_WINDOW->show; |
2075 | } |
2139 | } |
2076 | |
2140 | |
2077 | $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]); |
2141 | $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]); |
2078 | } |
2142 | } |
2079 | |
2143 | |
… | |
… | |
2087 | my $animate_timer; |
2151 | my $animate_timer; |
2088 | |
2152 | |
2089 | my $fps = 9; |
2153 | my $fps = 9; |
2090 | |
2154 | |
2091 | sub force_refresh { |
2155 | sub force_refresh { |
|
|
2156 | if ($ENV{CFPLUS_DEBUG} & 4) { |
2092 | $fps = $fps * 0.95 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.05; |
2157 | $fps = $fps * 0.98 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.02; |
2093 | debug sprintf "%3.2f", $fps if $ENV{CFPLUS_DEBUG} & 4; |
2158 | debug sprintf "%3.2f", $fps; |
|
|
2159 | } |
2094 | |
2160 | |
2095 | $CFPlus::UI::ROOT->draw; |
2161 | $CFPlus::UI::ROOT->draw; |
2096 | |
2162 | CFPlus::SDL_GL_SwapBuffers; |
2097 | $WANT_REFRESH = 0; |
|
|
2098 | $CAN_REFRESH = 0; |
|
|
2099 | $LAST_REFRESH = $NOW; |
2163 | $LAST_REFRESH = $NOW; |
2100 | |
2164 | $WANT_REFRESH->stop; |
2101 | CFPlus::SDL_GL_SwapBuffers; |
|
|
2102 | } |
2165 | } |
2103 | |
2166 | |
|
|
2167 | $WANT_REFRESH = Event->idle (min => 0.001, max => 0.06, parked => 1, cb => \&force_refresh); |
|
|
2168 | |
2104 | my $refresh_watcher = Event->timer (after => 0, hard => 0, interval => 1 / $MAX_FPS, cb => sub { |
2169 | my $input = Event->timer (after => 0, hard => 0, interval => 1 / 50, cb => sub { |
2105 | $NOW = time; |
2170 | $NOW = time; |
2106 | |
2171 | |
2107 | ($SDL_CB{$_->{type}} || sub { warn "unhandled event $_->{type}" })->($_) |
2172 | ($SDL_CB{$_->{type}} || sub { warn "unhandled event $_->{type}" })->($_) |
2108 | for CFPlus::poll_events; |
2173 | for CFPlus::poll_events; |
2109 | |
2174 | |
2110 | if (%animate_object) { |
2175 | if (%animate_object) { |
2111 | $_->animate ($LAST_REFRESH - $NOW) for values %animate_object; |
2176 | $_->animate ($LAST_REFRESH - $NOW) for values %animate_object; |
2112 | ++$WANT_REFRESH; |
2177 | $WANT_REFRESH->start; |
2113 | } |
|
|
2114 | |
|
|
2115 | if ($WANT_REFRESH) { |
|
|
2116 | force_refresh; |
|
|
2117 | } else { |
|
|
2118 | $CAN_REFRESH = 1; |
|
|
2119 | } |
2178 | } |
2120 | }); |
2179 | }); |
2121 | |
2180 | |
2122 | sub animation_start { |
2181 | sub animation_start { |
2123 | my ($widget) = @_; |
2182 | my ($widget) = @_; |
… | |
… | |
2129 | delete $animate_object{$widget}; |
2188 | delete $animate_object{$widget}; |
2130 | } |
2189 | } |
2131 | |
2190 | |
2132 | %SDL_CB = ( |
2191 | %SDL_CB = ( |
2133 | CFPlus::SDL_QUIT => sub { |
2192 | CFPlus::SDL_QUIT => sub { |
2134 | exit; |
2193 | Event::unloop_all; |
2135 | }, |
2194 | }, |
2136 | CFPlus::SDL_VIDEORESIZE => sub { |
2195 | CFPlus::SDL_VIDEORESIZE => sub { |
2137 | }, |
2196 | }, |
2138 | CFPlus::SDL_VIDEOEXPOSE => sub { |
2197 | CFPlus::SDL_VIDEOEXPOSE => sub { |
2139 | CFPlus::UI::full_refresh; |
2198 | CFPlus::UI::full_refresh; |
… | |
… | |
2178 | CFPlus::DB::Server::run; |
2237 | CFPlus::DB::Server::run; |
2179 | |
2238 | |
2180 | CFPlus::UI::set_layout ($::CFG->{layout}); |
2239 | CFPlus::UI::set_layout ($::CFG->{layout}); |
2181 | |
2240 | |
2182 | my %DEF_CFG = ( |
2241 | my %DEF_CFG = ( |
2183 | sdl_mode => 0, |
2242 | sdl_mode => 0, |
2184 | fullscreen => 0, |
2243 | fullscreen => 0, |
2185 | fast => 0, |
2244 | fast => 0, |
|
|
2245 | force_opengl11 => undef, |
|
|
2246 | texture_compression => 1, |
2186 | map_scale => 1, |
2247 | map_scale => 1, |
2187 | fow_enable => 1, |
2248 | fow_enable => 1, |
2188 | fow_intensity => 0, |
2249 | fow_intensity => 0, |
2189 | map_smoothing => 1, |
2250 | map_smoothing => 1, |
2190 | gui_fontsize => 1, |
2251 | gui_fontsize => 1, |
2191 | log_fontsize => 0.7, |
2252 | log_fontsize => 0.7, |
2192 | gauge_fontsize => 1, |
2253 | gauge_fontsize => 1, |
2193 | gauge_size => 0.35, |
2254 | gauge_size => 0.35, |
2194 | stat_fontsize => 0.7, |
2255 | stat_fontsize => 0.7, |
2195 | mapsize => 100, |
2256 | mapsize => 100, |
2196 | audio_enable => 1, |
2257 | audio_enable => 1, |
2197 | effects_enable => 1, |
2258 | effects_enable => 1, |
2198 | effects_volume => 1, |
2259 | effects_volume => 1, |
2199 | bgm_enable => 1, |
2260 | bgm_enable => 1, |
2200 | bgm_volume => 0.5, |
2261 | bgm_volume => 0.5, |
2201 | output_sync => 1, |
2262 | output_sync => 1, |
2202 | output_count => 1, |
2263 | output_count => 1, |
2203 | output_rate => "", |
2264 | output_rate => "", |
2204 | pickup => 0, |
2265 | pickup => 0, |
2205 | inv_sort => "mtime", |
2266 | inv_sort => "mtime", |
2206 | default => "profile", # default profile |
2267 | default => "profile", # default profile |
2207 | show_tips => 1, |
2268 | show_tips => 1, |
2208 | logview_max_par => 1000, |
2269 | logview_max_par => 1000, |
2209 | ); |
2270 | ); |
2210 | |
2271 | |
2211 | while (my ($k, $v) = each %DEF_CFG) { |
2272 | while (my ($k, $v) = each %DEF_CFG) { |
2212 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
2273 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
2213 | } |
2274 | } |
… | |
… | |
2270 | # } |
2331 | # } |
2271 | # my $t2 = Time::HiRes::time; |
2332 | # my $t2 = Time::HiRes::time; |
2272 | # warn $t2-$t1; |
2333 | # warn $t2-$t1; |
2273 | # } |
2334 | # } |
2274 | |
2335 | |
2275 | $startup_done->(); |
|
|
2276 | |
|
|
2277 | video_init; |
2336 | video_init; |
2278 | audio_init; |
2337 | audio_init; |
2279 | } |
2338 | } |
2280 | |
2339 | |
2281 | show_tip_of_the_day if $CFG->{show_tips}; |
2340 | show_tip_of_the_day if $CFG->{show_tips}; |
2282 | |
2341 | |
|
|
2342 | Event->idle (cb => sub { |
|
|
2343 | $_[0]->w->cancel; |
|
|
2344 | $startup_done->(); |
|
|
2345 | }); |
|
|
2346 | |
2283 | Event::loop; |
2347 | Event::loop; |
|
|
2348 | |
|
|
2349 | #video_shutdown; |
|
|
2350 | #audio_shutdown; |
2284 | #CFPlus::SDL_Quit; |
2351 | CFPlus::SDL_Quit; |
2285 | #CFPlus::_exit 0; |
|
|
2286 | |
|
|
2287 | END { |
|
|
2288 | CFPlus::SDL_Quit; |
|
|
2289 | CFPlus::DB::Server::stop; |
2352 | CFPlus::DB::Server::stop; |
2290 | } |
|
|
2291 | |
2353 | |
2292 | =head1 NAME |
2354 | =head1 NAME |
2293 | |
2355 | |
2294 | cfplus - A Crossfire+ and Crossfire game client |
2356 | cfplus - A Crossfire TRT and Crossfire game client |
2295 | |
2357 | |
2296 | =head1 SYNOPSIS |
2358 | =head1 SYNOPSIS |
2297 | |
2359 | |
2298 | Just run it - no commandline arguments are supported. |
2360 | Just run it - no commandline arguments are supported. |
2299 | |
2361 | |
2300 | =head1 USAGE |
2362 | =head1 USAGE |
2301 | |
2363 | |
2302 | cfplus utilises OpenGL for all UI elements and the game. It is supposed to be used |
2364 | cfplus utilises OpenGL for all UI elements and the game. It is supposed to |
2303 | fullscreen and interactively. |
2365 | be used in fullscreen mode and interactively. |
2304 | |
2366 | |
2305 | =head1 DEBUGGING |
2367 | =head1 DEBUGGING |
2306 | |
2368 | |
2307 | |
2369 | |
2308 | CFPLUS_DEBUG - environment variable |
2370 | CFPLUS_DEBUG - environment variable |