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.146 by root, Wed Apr 19 21:17:16 2006 UTC vs.
Revision 1.147 by root, Wed Apr 19 21:38:05 2006 UTC

3use strict; 3use strict;
4use utf8; 4use utf8;
5 5
6use Time::HiRes 'time'; 6use Time::HiRes 'time';
7use Event; 7use Event;
8
9use SDL::Event;
10 8
11use SDL::OpenGL; 9use SDL::OpenGL;
12 10
13use Crossfire; 11use Crossfire;
14use Crossfire::Protocol; 12use Crossfire::Protocol;
51our $METASERVER; 49our $METASERVER;
52 50
53our $GAUGES; 51our $GAUGES;
54 52
55our $SDL_ACTIVE; 53our $SDL_ACTIVE;
56our $SDL_EV;
57our %SDL_CB; 54our %SDL_CB;
58 55
59our $SDL_MIXER; 56our $SDL_MIXER;
60our @SOUNDS; # event => file mapping 57our @SOUNDS; # event => file mapping
61our %AUDIO_CHUNKS; # audio files 58our %AUDIO_CHUNKS; # audio files
395 $FAST = $CFG->{fast}; 392 $FAST = $CFG->{fast};
396 393
397 CFClient::SDL_SetVideoMode $WIDTH, $HEIGHT, $FULLSCREEN 394 CFClient::SDL_SetVideoMode $WIDTH, $HEIGHT, $FULLSCREEN
398 or die "SDL_SetVideoMode failed!\n"; 395 or die "SDL_SetVideoMode failed!\n";
399 396
400 $SDL_EV = new SDL::Event;
401 $SDL_EV->set_unicode (1);
402
403 $SDL_ACTIVE = 1; 397 $SDL_ACTIVE = 1;
404 398
405 $LAST_REFRESH = time - 0.01; 399 $LAST_REFRESH = time - 0.01;
406 400
407 CFClient::gl_init; 401 CFClient::gl_init;
466} 460}
467 461
468sub video_shutdown { 462sub video_shutdown {
469 $CFClient::UI::ROOT->{children} = []; 463 $CFClient::UI::ROOT->{children} = [];
470 undef $SDL_ACTIVE; 464 undef $SDL_ACTIVE;
471 undef $SDL_EV;
472} 465}
473 466
474my $bgmusic;#TODO#hack#d# 467my $bgmusic;#TODO#hack#d#
475 468
476sub audio_init { 469sub audio_init {
537} 530}
538 531
539my $refresh_watcher = Event->timer (after => 0, hard => 1, interval => 1 / $MAX_FPS, cb => sub { 532my $refresh_watcher = Event->timer (after => 0, hard => 1, interval => 1 / $MAX_FPS, cb => sub {
540 $NOW = time; 533 $NOW = time;
541 534
542 ($SDL_CB{$SDL_EV->type} || sub { warn "unhandled event ", $SDL_EV->type })->() 535 ($SDL_CB{$_->{type}} || sub { warn "unhandled event $_->{type}" })->($_)
543 while $SDL_EV->poll; 536 for CFClient::SDL_PollEvent;
544 537
545 if (%animate_object) { 538 if (%animate_object) {
546 $_->animate ($LAST_REFRESH - $NOW) for values %animate_object; 539 $_->animate ($LAST_REFRESH - $NOW) for values %animate_object;
547 $want_refresh++; 540 $want_refresh++;
548 } 541 }
838 }, 831 },
839 CFClient::SDL_VIDEOEXPOSE => sub { 832 CFClient::SDL_VIDEOEXPOSE => sub {
840 refresh; 833 refresh;
841 }, 834 },
842 CFClient::SDL_KEYDOWN => sub { 835 CFClient::SDL_KEYDOWN => sub {
843 if ($SDL_EV->key_mod & CFClient::KMOD_ALT && $SDL_EV->key_sym == 13) { 836 if ($_[0]{mod} & CFClient::KMOD_ALT && $_[0]{sym} == 13) {
844 # alt-enter 837 # alt-enter
845 video_shutdown; 838 video_shutdown;
846 $CFG->{fullscreen} = !$CFG->{fullscreen}; 839 $CFG->{fullscreen} = !$CFG->{fullscreen};
847 video_init; 840 video_init;
848 } else { 841 } else {
849 CFClient::UI::feed_sdl_key_down_event ($SDL_EV); 842 CFClient::UI::feed_sdl_key_down_event ($_[0]);
850 } 843 }
851 }, 844 },
852 CFClient::SDL_KEYUP => sub { 845 CFClient::SDL_KEYUP => sub {
853 CFClient::UI::feed_sdl_key_up_event ($SDL_EV); 846 CFClient::UI::feed_sdl_key_up_event ($_[0]);
854 }, 847 },
855 CFClient::SDL_MOUSEMOTION => sub { 848 CFClient::SDL_MOUSEMOTION => sub {
856 CFClient::UI::feed_sdl_motion_event ($SDL_EV); 849 CFClient::UI::feed_sdl_motion_event ($_[0]);
857 }, 850 },
858 CFClient::SDL_MOUSEBUTTONDOWN => sub { 851 CFClient::SDL_MOUSEBUTTONDOWN => sub {
859 CFClient::UI::feed_sdl_button_down_event ($SDL_EV); 852 CFClient::UI::feed_sdl_button_down_event ($_[0]);
860 }, 853 },
861 CFClient::SDL_MOUSEBUTTONUP => sub { 854 CFClient::SDL_MOUSEBUTTONUP => sub {
862 CFClient::UI::feed_sdl_button_up_event ($SDL_EV); 855 CFClient::UI::feed_sdl_button_up_event ($_[0]);
863 }, 856 },
864 CFClient::SDL_ACTIVEEVENT => sub { 857 CFClient::SDL_ACTIVEEVENT => sub {
865# printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d# 858# printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d#
866 }, 859 },
867); 860);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines