… | |
… | |
8 | |
8 | |
9 | use SDL; |
9 | use SDL; |
10 | use SDL::App; |
10 | use SDL::App; |
11 | use SDL::Event; |
11 | use SDL::Event; |
12 | use SDL::Surface; |
12 | use SDL::Surface; |
|
|
13 | |
|
|
14 | use SDL::Mixer; |
|
|
15 | use SDL::Sound; |
|
|
16 | use SDL::Music; |
|
|
17 | |
13 | use SDL::OpenGL; |
18 | use SDL::OpenGL; |
14 | |
19 | |
15 | use Crossfire; |
20 | use Crossfire; |
16 | use Crossfire::Protocol; |
21 | use Crossfire::Protocol; |
17 | |
22 | |
… | |
… | |
49 | our $BUTTONBAR; |
54 | our $BUTTONBAR; |
50 | our $LOGVIEW; |
55 | our $LOGVIEW; |
51 | our $CONSOLE; |
56 | our $CONSOLE; |
52 | our $METASERVER; |
57 | our $METASERVER; |
53 | |
58 | |
|
|
59 | our $GAUGES; |
|
|
60 | |
54 | our $SDL_ACTIVE; |
61 | our $SDL_ACTIVE; |
55 | our $SDL_EV; |
62 | our $SDL_EV; |
56 | our %SDL_CB; |
63 | our %SDL_CB; |
57 | |
64 | |
|
|
65 | our $SDL_MIXER; |
|
|
66 | our @SOUNDS; # event => file mapping |
|
|
67 | our %AUDIO_CHUNKS; # audio files |
|
|
68 | |
58 | our $ALT_ENTER_MESSAGE; |
69 | our $ALT_ENTER_MESSAGE; |
59 | our $STATUS_LINE; |
70 | our $STATUS_LINE; |
60 | our $DEBUG_STATUS; |
71 | our $DEBUG_STATUS; |
61 | |
72 | |
62 | sub status { |
73 | sub status { |
63 | $STATUS_LINE->set_text ($_[0]); |
74 | $STATUS_LINE->set_text ($_[0]); |
64 | my ($w, $h) = $STATUS_LINE->size_request; |
|
|
65 | $STATUS_LINE->size_allocate (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $h, $w, $h); |
75 | $STATUS_LINE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $STATUS_LINE->{h}); |
66 | } |
76 | } |
67 | |
77 | |
68 | sub debug { |
78 | sub debug { |
69 | $DEBUG_STATUS->set_text ($_[0]); |
79 | $DEBUG_STATUS->set_text ($_[0]); |
70 | my ($w, $h) = $DEBUG_STATUS->size_request; |
80 | $DEBUG_STATUS->move ($WIDTH - $DEBUG_STATUS->{w}, 0, $DEBUG_STATUS->{w}, $DEBUG_STATUS->{h}); |
71 | $DEBUG_STATUS->size_allocate ($WIDTH - $w, 0, $w, $h); |
|
|
72 | } |
81 | } |
73 | |
82 | |
74 | sub start_game { |
83 | sub start_game { |
75 | status "logging in..."; |
84 | status "logging in..."; |
76 | |
85 | |
… | |
… | |
146 | |
155 | |
147 | $table->add (0, 5, new CFClient::UI::Label align => 1, text => "FoW Smooth"); |
156 | $table->add (0, 5, new CFClient::UI::Label align => 1, text => "FoW Smooth"); |
148 | $table->add (1, 5, new CFClient::UI::CheckBox state => $CFG->{fow_smooth}, connect_changed => sub { |
157 | $table->add (1, 5, new CFClient::UI::CheckBox state => $CFG->{fow_smooth}, connect_changed => sub { |
149 | my ($self, $value) = @_; |
158 | my ($self, $value) = @_; |
150 | $CFG->{fow_smooth} = $value; |
159 | $CFG->{fow_smooth} = $value; |
|
|
160 | status "Fog of War smoothing requires OpenGL 1.2 or higher" if $CFClient::GL_VERSION < 1.2; |
151 | }); |
161 | }); |
152 | |
162 | |
153 | $table->add (0, 6, new CFClient::UI::Label align => 1, text => "Log Fontsize"); |
163 | $table->add (0, 6, new CFClient::UI::Label align => 1, text => "Log Fontsize"); |
154 | $table->add (1, 6, new CFClient::UI::Slider range => [$CFG->{log_fontsize}, 8, 30, 1], connect_changed => sub { |
164 | $table->add (1, 6, new CFClient::UI::Slider range => [$CFG->{log_fontsize}, 8, 30, 1], connect_changed => sub { |
155 | my ($self, $value) = @_; |
165 | my ($self, $value) = @_; |
156 | $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = int $value); |
166 | $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = int $value); |
157 | }); |
167 | }); |
158 | |
168 | |
159 | $table->add (1, 7, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { |
169 | $table->add (1, 7, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { |
160 | destroy_screen (); |
170 | video_shutdown (); |
161 | init_screen (); |
171 | video_init (); |
|
|
172 | }); |
|
|
173 | |
|
|
174 | $table->add (0, 8, new CFClient::UI::Label align => 1, text => "Sound"); |
|
|
175 | $table->add (1, 8, new CFClient::UI::CheckBox state => $CFG->{audio_enable}, connect_changed => sub { |
|
|
176 | my ($self, $value) = @_; |
|
|
177 | $CFG->{audio_enable} = $value; |
|
|
178 | }); |
|
|
179 | $table->add (0, 9, new CFClient::UI::Label align => 1, text => "Bg. Music"); |
|
|
180 | $table->add (1, 9, new CFClient::UI::CheckBox state => $CFG->{bgm_enable}, connect_changed => sub { |
|
|
181 | my ($self, $value) = @_; |
|
|
182 | $CFG->{bgm_enable} = $value; |
|
|
183 | }); |
|
|
184 | $table->add (1, 10, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { |
|
|
185 | audio_shutdown (); |
|
|
186 | audio_init (); |
162 | }); |
187 | }); |
163 | |
188 | |
164 | $dialog |
189 | $dialog |
165 | } |
190 | } |
166 | |
191 | |
… | |
… | |
300 | |
325 | |
301 | sub message_window { |
326 | sub message_window { |
302 | my $window = new CFClient::UI::FancyFrame |
327 | my $window = new CFClient::UI::FancyFrame |
303 | border_bg => [1, 1, 1, 0.5], |
328 | border_bg => [1, 1, 1, 0.5], |
304 | bg => [0.3, 0.3, 0.3, 0.8], |
329 | bg => [0.3, 0.3, 0.3, 0.8], |
305 | user_w => $::WIDTH/4, |
330 | user_w => int $::WIDTH / 3, |
306 | user_h => $::HEIGHT, |
331 | user_h => int $::HEIGHT / 5, |
307 | child => (my $vbox = new CFClient::UI::VBox); |
332 | child => (my $vbox = new CFClient::UI::VBox); |
308 | |
333 | |
309 | $vbox->add ($LOGVIEW = new CFClient::UI::TextView |
334 | $vbox->add ($LOGVIEW = new CFClient::UI::TextView |
310 | expand => 1, |
335 | expand => 1, |
311 | fontsize => $::CFG->{log_fontsize}, |
336 | fontsize => $::CFG->{log_fontsize}, |
312 | ); |
337 | ); |
313 | |
338 | |
314 | $vbox->add (my $input = new CFClient::UI::LineEntry |
339 | $vbox->add (my $input = new CFClient::UI::Entry |
315 | connect_focus_in => sub { |
340 | connect_focus_in => sub { |
316 | my ($input, $prev_focus) = @_; |
341 | my ($input, $prev_focus) = @_; |
317 | |
342 | |
318 | delete $input->{refocus_map}; |
343 | delete $input->{refocus_map}; |
319 | |
344 | |
… | |
… | |
325 | connect_activate => sub { |
350 | connect_activate => sub { |
326 | my ($input, $text) = @_; |
351 | my ($input, $text) = @_; |
327 | $input->set_text (''); |
352 | $input->set_text (''); |
328 | |
353 | |
329 | if ($text =~ /^\/(.*)/) { |
354 | if ($text =~ /^\/(.*)/) { |
330 | $::CONN->user_send ("command $1"); |
355 | $::CONN->user_send ($1); |
331 | } else { |
356 | } else { |
332 | my $say_cmd = $::CFG->{say_command} || 'say'; |
357 | my $say_cmd = $::CFG->{say_command} || 'say'; |
333 | $::CONN->user_send ("command $say_cmd $text"); |
358 | $::CONN->user_send ("$say_cmd $text"); |
334 | } |
359 | } |
335 | if ($input->{refocus_map}) { |
360 | if ($input->{refocus_map}) { |
336 | delete $input->{refocus_map}; |
361 | delete $input->{refocus_map}; |
337 | $MAPWIDGET->focus_in |
362 | $MAPWIDGET->focus_in |
338 | } |
363 | } |
… | |
… | |
354 | #SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE |
379 | #SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE |
355 | SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO |
380 | SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO |
356 | and die "SDL::Init failed!\n"; |
381 | and die "SDL::Init failed!\n"; |
357 | } |
382 | } |
358 | |
383 | |
359 | sub init_screen { |
384 | sub video_init { |
360 | sdl_init; |
385 | sdl_init; |
361 | |
386 | |
362 | ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; |
387 | ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; |
363 | $FULLSCREEN = $CFG->{fullscreen}; |
388 | $FULLSCREEN = $CFG->{fullscreen}; |
364 | $FAST = $CFG->{fast}; |
389 | $FAST = $CFG->{fast}; |
… | |
… | |
404 | padding => 0, |
429 | padding => 0, |
405 | y => $HEIGHT * 44 / 45 - $FONTSIZE; |
430 | y => $HEIGHT * 44 / 45 - $FONTSIZE; |
406 | $CFClient::UI::ROOT->add ($STATUS_LINE); |
431 | $CFClient::UI::ROOT->add ($STATUS_LINE); |
407 | |
432 | |
408 | $ALT_ENTER_MESSAGE = new CFClient::UI::Label |
433 | $ALT_ENTER_MESSAGE = new CFClient::UI::Label |
409 | padding => 0, |
434 | padding => 0, |
410 | y => $HEIGHT * 44 / 45, |
435 | y => $HEIGHT * 44 / 45, |
411 | height => $HEIGHT / 45, |
436 | fontsize => $HEIGHT / 45, |
412 | text => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; |
437 | markup => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; |
413 | $CFClient::UI::ROOT->add ($ALT_ENTER_MESSAGE); |
438 | $CFClient::UI::ROOT->add ($ALT_ENTER_MESSAGE); |
414 | |
439 | |
415 | $CFClient::UI::ROOT->add ($MAPWIDGET = new CFClient::UI::MapWidget); |
440 | $CFClient::UI::ROOT->add ($MAPWIDGET = new CFClient::UI::MapWidget); |
416 | $MAPWIDGET->focus_in; |
441 | $MAPWIDGET->focus_in; |
417 | $MAPWIDGET->connect (activate_console => sub { |
442 | $MAPWIDGET->connect (activate_console => sub { |
… | |
… | |
437 | CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; |
462 | CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; |
438 | status "Configuration Saved"; |
463 | status "Configuration Saved"; |
439 | }); |
464 | }); |
440 | |
465 | |
441 | $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup |
466 | $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup |
442 | } |
|
|
443 | |
467 | |
444 | sub destroy_screen { |
468 | my $tgw = new CFClient::UI::FancyFrame (x => $WIDTH - 300, y => 0); |
|
|
469 | $tgw->add (my $hbox = new CFClient::UI::HBox ()); |
|
|
470 | |
|
|
471 | $hbox->add (my $hg = new CFClient::UI::VGauge (gauge => 'hp')); |
|
|
472 | $hbox->add (my $mg = new CFClient::UI::VGauge (gauge => 'mana')); |
|
|
473 | $hbox->add (my $gg = new CFClient::UI::VGauge (gauge => 'grace')); |
|
|
474 | $hbox->add (my $fg = new CFClient::UI::VGauge (gauge => 'food')); |
|
|
475 | |
|
|
476 | $GAUGES = { food => $fg, mana => $mg, hp => $hg, grace => $gg }; |
|
|
477 | $CFClient::UI::ROOT->add ($tgw); |
|
|
478 | } |
|
|
479 | |
|
|
480 | sub video_shutdown { |
445 | $CFClient::UI::ROOT->{children} = []; |
481 | $CFClient::UI::ROOT->{children} = []; |
446 | undef $SDL_ACTIVE; |
482 | undef $SDL_ACTIVE; |
447 | undef $SDL_EV; |
483 | undef $SDL_EV; |
448 | SDL::Quit; |
484 | } |
|
|
485 | |
|
|
486 | my $bgmusic;#TODO#hack#d# |
|
|
487 | |
|
|
488 | sub audio_init { |
|
|
489 | if ($CFG->{audio_enable}) { |
|
|
490 | if (open my $fh, "<:utf8", CFClient::find_rcfile "sounds/config") { |
|
|
491 | $SDL_MIXER = new SDL::Mixer; |
|
|
492 | $SDL_MIXER->allocate_channels (8); |
|
|
493 | |
|
|
494 | # TODO: hack, do play loop and mood music |
|
|
495 | if ($CFG->{bgm_enable}) { |
|
|
496 | $bgmusic = new SDL::Music CFClient::find_rcfile "music/game3.ogg"; |
|
|
497 | $SDL_MIXER->play_music ($bgmusic, -1); |
|
|
498 | } |
|
|
499 | |
|
|
500 | while (<$fh>) { |
|
|
501 | next if /^\s*#/; |
|
|
502 | next if /^\s*$/; |
|
|
503 | |
|
|
504 | my ($file, $volume, $event) = split /\s+/, $_, 3; |
|
|
505 | |
|
|
506 | push @SOUNDS, "$volume,$file"; |
|
|
507 | |
|
|
508 | $AUDIO_CHUNKS{"$volume,$file"} ||= do { |
|
|
509 | my $chunk = new SDL::Sound CFClient::find_rcfile "sounds/$file"; |
|
|
510 | $chunk->volume ($volume * 128 / 100); |
|
|
511 | $chunk |
|
|
512 | }; |
|
|
513 | } |
|
|
514 | } else { |
|
|
515 | status "unable to open sound config: $!"; |
|
|
516 | } |
|
|
517 | } |
|
|
518 | } |
|
|
519 | |
|
|
520 | sub audio_shutdown { |
|
|
521 | undef $SDL_MIXER; |
|
|
522 | @SOUNDS = (); |
|
|
523 | %AUDIO_CHUNKS = (); |
449 | } |
524 | } |
450 | |
525 | |
451 | my %animate_object; |
526 | my %animate_object; |
452 | my $animate_timer; |
527 | my $animate_timer; |
453 | |
528 | |
… | |
… | |
502 | delete $animate_object{$widget}; |
577 | delete $animate_object{$widget}; |
503 | } |
578 | } |
504 | |
579 | |
505 | @conn::ISA = Crossfire::Protocol::; |
580 | @conn::ISA = Crossfire::Protocol::; |
506 | |
581 | |
|
|
582 | sub conn::stats_update { |
|
|
583 | my ($self, $stats) = @_; |
|
|
584 | |
|
|
585 | # i love text protocols!!! |
|
|
586 | # FIXME: the stats are somehow weird |
|
|
587 | my $hp = $stats->{1}; |
|
|
588 | my $hp_m = $stats->{2}; |
|
|
589 | my $sp = $stats->{3}; |
|
|
590 | my $sp_m = $stats->{4}; |
|
|
591 | my $fo = $stats->{18}; |
|
|
592 | my $fo_m = 1000; |
|
|
593 | my $gr = $stats->{23}; |
|
|
594 | my $gr_m = $stats->{24}; |
|
|
595 | |
|
|
596 | #d# warn "DATA $hp $hp_m $sp $sp_m $fo $fo_m $gr $gr_m\n"; |
|
|
597 | $GAUGES->{hp}->set_value ($hp, $hp_m); |
|
|
598 | $GAUGES->{mana}->set_value ($sp, $sp_m); |
|
|
599 | $GAUGES->{food}->set_value ($fo, $fo_m); |
|
|
600 | $GAUGES->{grace}->set_value ($gr, $gr_m); |
|
|
601 | } |
|
|
602 | |
507 | sub conn::user_send { |
603 | sub conn::user_send { |
508 | my ($self, $command) = @_; |
604 | my ($self, $command) = @_; |
509 | |
605 | |
510 | $self->send ($command); |
606 | $self->send_command ($command); |
511 | status $command; |
607 | status $command; |
512 | } |
608 | } |
513 | |
609 | |
514 | sub conn::map_scroll { |
610 | sub conn::map_scroll { |
515 | my ($self, $dx, $dy) = @_; |
611 | my ($self, $dx, $dy) = @_; |
… | |
… | |
579 | my $neigh = $self->{neigh}{$hash} ||= []; |
675 | my $neigh = $self->{neigh}{$hash} ||= []; |
580 | |
676 | |
581 | $self->send_mapinfo ("spatial $path$tile", sub { |
677 | $self->send_mapinfo ("spatial $path$tile", sub { |
582 | my ($mode, $flags, $x, $y, $w, $h, $hash) = @_; |
678 | my ($mode, $flags, $x, $y, $w, $h, $hash) = @_; |
583 | |
679 | |
584 | warn "map<$path>_$tile=<$mode,$x,$y,$w,$h,$hash>\n";#d# |
680 | #warn "map<$path>_$tile=<$mode,$x,$y,$w,$h,$hash>\n";#d# |
585 | return if $mode ne "spatial"; |
681 | return if $mode ne "spatial"; |
586 | |
682 | |
587 | $x += $MAP->ox; |
683 | $x += $MAP->ox; |
588 | $y += $MAP->oy; |
684 | $y += $MAP->oy; |
589 | |
685 | |
590 | $self->load_map ($hash, $x, $y); |
686 | $self->load_map ($hash, $x, $y) |
|
|
687 | unless $self->{neigh}{$hash}[5]++;#d# |
591 | |
688 | |
592 | $neigh->[$tile] = [$x, $y, $w, $h]; |
689 | $neigh->[$tile] = [$x, $y, $w, $h]; |
593 | |
690 | |
594 | $self->flood_fill ("$path$tile", $hash, $flags, $x0, $y0, $x1, $y1) |
691 | $self->flood_fill ("$path$tile", $hash, $flags, $x0, $y0, $x1, $y1) |
595 | if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1; |
692 | if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1; |
… | |
… | |
601 | my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_; |
698 | my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_; |
602 | |
699 | |
603 | $self->flush_map; |
700 | $self->flush_map; |
604 | |
701 | |
605 | my ($ox, $oy) = ($::MAP->ox, $::MAP->oy); |
702 | my ($ox, $oy) = ($::MAP->ox, $::MAP->oy); |
606 | |
|
|
607 | warn "$ox $oy map_info<$flags, $x, $y, $w, $h, $hash>\n";#d# |
|
|
608 | |
703 | |
609 | my $mapmapw = 250; |
704 | my $mapmapw = 250; |
610 | my $mapmaph = 250; |
705 | my $mapmaph = 250; |
611 | |
706 | |
612 | $self->flood_fill ("", $hash, $flags, |
707 | $self->flood_fill ("", $hash, $flags, |
… | |
… | |
674 | $MAP->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}}); |
769 | $MAP->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}}); |
675 | $MAPWIDGET->update; |
770 | $MAPWIDGET->update; |
676 | |
771 | |
677 | $tex |
772 | $tex |
678 | }; |
773 | }; |
|
|
774 | } |
|
|
775 | |
|
|
776 | sub conn::sound_play { |
|
|
777 | my ($self, $x, $y, $soundnum, $type) = @_; |
|
|
778 | |
|
|
779 | $SDL_MIXER |
|
|
780 | or return; |
|
|
781 | |
|
|
782 | my $chunk = $AUDIO_CHUNKS{$SOUNDS[$soundnum]} |
|
|
783 | or return; |
|
|
784 | |
|
|
785 | $SDL_MIXER->play_channel (-1, $chunk); |
|
|
786 | warn "sound $x,$y,$soundnum,$type\n";#d# |
679 | } |
787 | } |
680 | |
788 | |
681 | sub conn::query { |
789 | sub conn::query { |
682 | my ($self, $flags, $prompt) = @_; |
790 | my ($self, $flags, $prompt) = @_; |
683 | |
791 | |
… | |
… | |
717 | refresh; |
825 | refresh; |
718 | }, |
826 | }, |
719 | SDL_KEYDOWN() => sub { |
827 | SDL_KEYDOWN() => sub { |
720 | if ($SDL_EV->key_mod & KMOD_ALT && $SDL_EV->key_sym == SDLK_RETURN) { |
828 | if ($SDL_EV->key_mod & KMOD_ALT && $SDL_EV->key_sym == SDLK_RETURN) { |
721 | # alt-enter |
829 | # alt-enter |
722 | destroy_screen; |
830 | video_shutdown; |
723 | $CFG->{fullscreen} = !$CFG->{fullscreen}; |
831 | $CFG->{fullscreen} = !$CFG->{fullscreen}; |
724 | init_screen; |
832 | video_init; |
725 | } else { |
833 | } else { |
726 | CFClient::UI::feed_sdl_key_down_event ($SDL_EV); |
834 | CFClient::UI::feed_sdl_key_down_event ($SDL_EV); |
727 | } |
835 | } |
728 | }, |
836 | }, |
729 | SDL_KEYUP() => sub { |
837 | SDL_KEYUP() => sub { |
… | |
… | |
743 | }, |
851 | }, |
744 | ); |
852 | ); |
745 | |
853 | |
746 | ############################################################################# |
854 | ############################################################################# |
747 | |
855 | |
|
|
856 | $SIG{INT} = $SIG{TERM} = sub { exit }; |
|
|
857 | |
748 | $TILECACHE = CFClient::db_table "tilecache"; |
858 | $TILECACHE = CFClient::db_table "tilecache"; |
749 | $FACEMAP = CFClient::db_table "facemap"; |
859 | $FACEMAP = CFClient::db_table "facemap"; |
750 | |
860 | |
751 | CFClient::read_cfg "$Crossfire::VARDIR/pclientrc"; |
861 | CFClient::read_cfg "$Crossfire::VARDIR/pclientrc"; |
752 | |
862 | |
… | |
… | |
761 | fow_smooth => 0, |
871 | fow_smooth => 0, |
762 | log_fontsize => 14, |
872 | log_fontsize => 14, |
763 | mapsize => 100, |
873 | mapsize => 100, |
764 | host => "crossfire.schmorp.de", |
874 | host => "crossfire.schmorp.de", |
765 | say_command => 'say', |
875 | say_command => 'say', |
|
|
876 | audio_enable => 1, |
|
|
877 | bgm_enable => 1, |
766 | ); |
878 | ); |
767 | |
879 | |
768 | while (my ($k, $v) = each %DEF_CFG) { |
880 | while (my ($k, $v) = each %DEF_CFG) { |
769 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
881 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
770 | } |
882 | } |
… | |
… | |
778 | |
890 | |
779 | @SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; |
891 | @SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; |
780 | |
892 | |
781 | $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES; |
893 | $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES; |
782 | |
894 | |
783 | init_screen; |
|
|
784 | |
|
|
785 | { |
895 | { |
786 | my @fonts = map CFClient::find_rcfile $_, qw(uifont.ttf uifontb.ttf uifonti.ttf uifontbi.ttf); |
896 | my @fonts = map CFClient::find_rcfile $_, qw(uifont.ttf uifontb.ttf uifonti.ttf uifontbi.ttf); |
787 | |
897 | |
788 | CFClient::add_font $_ for @fonts; |
898 | CFClient::add_font $_ for @fonts; |
789 | CFClient::set_font $fonts[0]; |
899 | CFClient::set_font $fonts[0]; |
790 | } |
900 | } |
791 | |
901 | |
|
|
902 | video_init; |
|
|
903 | audio_init; |
|
|
904 | |
792 | Event::loop; |
905 | Event::loop; |
793 | |
906 | |
|
|
907 | END { SDL::Quit } |
794 | |
908 | |
|
|
909 | |