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

Comparing deliantra/Deliantra-Client/bin/pclient (file contents):
Revision 1.144 by root, Wed Apr 19 09:40:01 2006 UTC vs.
Revision 1.145 by root, Wed Apr 19 20:46:45 2006 UTC

4use utf8; 4use utf8;
5 5
6use Time::HiRes 'time'; 6use Time::HiRes 'time';
7use Event; 7use Event;
8 8
9use SDL;
10use SDL::App;
11use SDL::Event; 9use SDL::Event;
12use SDL::Surface;
13 10
14use SDL::Mixer; 11use SDL::Mixer;
15use SDL::Sound; 12use SDL::Sound;
16use SDL::Music; 13use SDL::Music;
17 14
388 385
389 $window 386 $window
390} 387}
391 388
392sub sdl_init { 389sub sdl_init {
393 #SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE 390 CFClient::SDL_Init
394 SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO
395 and die "SDL::Init failed!\n"; 391 and die "SDL::Init failed!\n";
396} 392}
397 393
398sub video_init { 394sub video_init {
399 sdl_init; 395 sdl_init;
400 396
401 ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; 397 ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] };
402 $FULLSCREEN = $CFG->{fullscreen}; 398 $FULLSCREEN = $CFG->{fullscreen};
403 $FAST = $CFG->{fast}; 399 $FAST = $CFG->{fast};
404 400
405 SDL::GLSetAttribute SDL_GL_RED_SIZE, 5; 401 CFClient::SDL_SetVideoMode $WIDTH, $HEIGHT, $FULLSCREEN
406 SDL::GLSetAttribute SDL_GL_GREEN_SIZE, 5;
407 SDL::GLSetAttribute SDL_GL_BLUE_SIZE, 5;
408 SDL::GLSetAttribute SDL_GL_ALPHA_SIZE, 1;
409
410 SDL::GLSetAttribute SDL_GL_ACCUM_RED_SIZE, 0;
411 SDL::GLSetAttribute SDL_GL_ACCUM_GREEN_SIZE, 0;
412 SDL::GLSetAttribute SDL_GL_ACCUM_BLUE_SIZE, 0;
413 SDL::GLSetAttribute SDL_GL_ACCUM_ALPHA_SIZE, 0;
414
415 SDL::GLSetAttribute SDL_GL_DOUBLEBUFFER, 1;
416 SDL::GLSetAttribute SDL_GL_BUFFER_SIZE, 15;
417 SDL::GLSetAttribute SDL_GL_DEPTH_SIZE, 0;
418
419 SDL::SetVideoMode $WIDTH, $HEIGHT, 0,
420 SDL_HWSURFACE | SDL_ANYFORMAT | SDL_OPENGL | SDL_DOUBLEBUF
421 | ($FULLSCREEN ? SDL_FULLSCREEN : 0)
422 or die "SDL::SetVideoMode failed!\n"; 402 or die "SDL_SetVideoMode failed!\n";
423
424 SDL::WMSetCaption "Crossfire+ Client", "Crossfire+";
425 403
426 $SDL_EV = new SDL::Event; 404 $SDL_EV = new SDL::Event;
427 $SDL_EV->set_unicode (1); 405 $SDL_EV->set_unicode (1);
428 406
429 $SDL_ACTIVE = 1; 407 $SDL_ACTIVE = 1;
858 }); 836 });
859 } 837 }
860} 838}
861 839
862%SDL_CB = ( 840%SDL_CB = (
863 SDL_QUIT() => sub { 841 CFClient::SDL_QUIT => sub {
864 Event::unloop -1; 842 Event::unloop -1;
865 }, 843 },
866 SDL_VIDEORESIZE() => sub { 844 CFClient::SDL_VIDEORESIZE => sub {
867 }, 845 },
868 SDL_VIDEOEXPOSE() => sub { 846 CFClient::SDL_VIDEOEXPOSE => sub {
869 refresh; 847 refresh;
870 }, 848 },
871 SDL_KEYDOWN() => sub { 849 CFClient::SDL_KEYDOWN => sub {
872 if ($SDL_EV->key_mod & KMOD_ALT && $SDL_EV->key_sym == SDLK_RETURN) { 850 if ($SDL_EV->key_mod & CFClient::KMOD_ALT && $SDL_EV->key_sym == 13) {
873 # alt-enter 851 # alt-enter
874 video_shutdown; 852 video_shutdown;
875 $CFG->{fullscreen} = !$CFG->{fullscreen}; 853 $CFG->{fullscreen} = !$CFG->{fullscreen};
876 video_init; 854 video_init;
877 } else { 855 } else {
878 CFClient::UI::feed_sdl_key_down_event ($SDL_EV); 856 CFClient::UI::feed_sdl_key_down_event ($SDL_EV);
879 } 857 }
880 }, 858 },
881 SDL_KEYUP() => sub { 859 CFClient::SDL_KEYUP => sub {
882 CFClient::UI::feed_sdl_key_up_event ($SDL_EV); 860 CFClient::UI::feed_sdl_key_up_event ($SDL_EV);
883 }, 861 },
884 SDL_MOUSEMOTION() => sub { 862 CFClient::SDL_MOUSEMOTION => sub {
885 CFClient::UI::feed_sdl_motion_event ($SDL_EV); 863 CFClient::UI::feed_sdl_motion_event ($SDL_EV);
886 }, 864 },
887 SDL_MOUSEBUTTONDOWN() => sub { 865 CFClient::SDL_MOUSEBUTTONDOWN => sub {
888 CFClient::UI::feed_sdl_button_down_event ($SDL_EV); 866 CFClient::UI::feed_sdl_button_down_event ($SDL_EV);
889 }, 867 },
890 SDL_MOUSEBUTTONUP() => sub { 868 CFClient::SDL_MOUSEBUTTONUP => sub {
891 CFClient::UI::feed_sdl_button_up_event ($SDL_EV); 869 CFClient::UI::feed_sdl_button_up_event ($SDL_EV);
892 }, 870 },
893 SDL_ACTIVEEVENT() => sub { 871 CFClient::SDL_ACTIVEEVENT => sub {
894# printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d# 872# printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d#
895 }, 873 },
896); 874);
897 875
898############################################################################# 876#############################################################################
929 907
930sdl_init; 908sdl_init;
931 909
932@SDL_MODES = reverse 910@SDL_MODES = reverse
933 grep $_->[0] >= 640 && $_->[1] >= 480, 911 grep $_->[0] >= 640 && $_->[1] >= 480,
934 map [SDL::RectW ($_), SDL::RectH ($_)], 912 CFClient::SDL_ListModes;
935 @{ SDL::ListModes 0, SDL_FULLSCREEN | SDL_HWSURFACE | SDL_OPENGL };
936 913
937@SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; 914@SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)";
938 915
939$CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES; 916$CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES;
940 917

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines