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.49 by elmex, Sun Apr 9 18:35:09 2006 UTC vs.
Revision 1.50 by root, Sun Apr 9 21:05:50 2006 UTC

46our $TOPLEVEL; 46our $TOPLEVEL;
47 47
48our $tw; # Test widget #d# 48our $tw; # Test widget #d#
49 49
50my $last_refresh; 50my $last_refresh;
51my %ANIMATE;
52my $refresh_handler;
51 53
52sub init_screen { 54sub init_screen {
53 $SDL_APP = new SDL::App 55 $SDL_APP = new SDL::App
54 -flags => SDL_ANYFORMAT | SDL_HWSURFACE, 56 -flags => SDL_ANYFORMAT | SDL_HWSURFACE,
55 -title => "Crossfire+ Client", 57 -title => "Crossfire+ Client",
115 117
116 $_->() for @GL_INIT; 118 $_->() for @GL_INIT;
117} 119}
118 120
119sub start_game { 121sub start_game {
120 $SDL_TIMER = add Glib::Timeout 1000/100, sub { 122 $SDL_TIMER = add Glib::Timeout 1000/50, sub {
121 ($SDL_CB{$SDL_EV->type} || sub { warn "unhandled event ", $SDL_EV->type })->() 123 ($SDL_CB{$SDL_EV->type} || sub { warn "unhandled event ", $SDL_EV->type })->()
122 while $SDL_EV->poll; 124 while $SDL_EV->poll;
123 125
124 1 126 1
125 }; 127 };
127 $WIDTH = $CFG->{width}; 129 $WIDTH = $CFG->{width};
128 $HEIGHT = $CFG->{height}; 130 $HEIGHT = $CFG->{height};
129 $FULLSCREEN = 0; 131 $FULLSCREEN = 0;
130 132
131 init_screen; 133 init_screen;
134
135 my $mapsize = List::Util::min 64, List::Util::max 11, int $HEIGHT * $CFG->{mapsize} * 0.01 / 32;
132 136
133 $CONN = new conn 137 $CONN = new conn
134 host => $CFG->{host}, 138 host => $CFG->{host},
135 port => $CFG->{port}, 139 port => $CFG->{port},
136 user => $CFG->{user}, 140 user => $CFG->{user},
137 pass => $CFG->{password}, 141 pass => $CFG->{password},
138 mapw => 50, 142 mapw => $mapsize,
139 maph => 37, 143 maph => $mapsize,
140 ; 144 ;
141 145
142 Crossfire::Client::lowdelay fileno $CONN->{fh}; 146 Crossfire::Client::lowdelay fileno $CONN->{fh};
143} 147}
144 148
145sub stop_game { 149sub stop_game {
146 remove Glib::Source $SDL_TIMER; 150 remove Glib::Source $SDL_TIMER;
151 remove Glib::Source $refresh_handler;
152 undef $refresh_handler;
147 153
148 undef $SDL_APP; 154 undef $SDL_APP;
155 undef $CONN;
149 SDL::Quit; 156 SDL::Quit;
150} 157}
151 158
152 159
153sub force_refresh { 160sub force_refresh {
163 $TOPLEVEL->draw; 170 $TOPLEVEL->draw;
164 171
165 SDL::GLSwapBuffers; 172 SDL::GLSwapBuffers;
166} 173}
167 174
168my %ANIMATE;
169
170my $refresh_handler;
171
172sub refresh { 175sub refresh {
173 $refresh_handler ||= add Glib::Idle sub { 176 $refresh_handler ||= add Glib::Idle sub {
177 return unless $SDL_APP;
178
174 my $next_refresh = SDL::GetTicks; 179 my $next_refresh = SDL::GetTicks;
175 my $interval = ($next_refresh - $last_refresh) * 0.001; 180 my $interval = ($next_refresh - $last_refresh) * 0.001;
176 $last_refresh = $next_refresh; 181 $last_refresh = $next_refresh;
177 182
178 force_refresh; 183 force_refresh;
360 my $cb = $events{login} || sub {}; 365 my $cb = $events{login} || sub {};
361 $cb->($::CFG->{user}, $::CFG->{password}); 366 $cb->($::CFG->{user}, $::CFG->{password});
362 }); 367 });
363 $hb->pack_start (my $cb = Gtk2::Button->new ("logout"), 1, 1, 5); 368 $hb->pack_start (my $cb = Gtk2::Button->new ("logout"), 1, 1, 5);
364 $cb->signal_connect (clicked => sub { 369 $cb->signal_connect (clicked => sub {
365 my $cb = $events{login} || sub {}; 370 my $cb = $events{logout} || sub {};
366 $cb->(); 371 $cb->();
367 }); 372 });
368 $hb->pack_start (my $cb = Gtk2::Button->new ("quit"), 1, 1, 5); 373 $hb->pack_start (my $cb = Gtk2::Button->new ("quit"), 1, 1, 5);
369 $cb->signal_connect (clicked => sub { $w->destroy }); 374 $cb->signal_connect (clicked => sub { $w->destroy });
370 375

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines