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.90 by root, Wed Apr 12 21:35:11 2006 UTC vs.
Revision 1.95 by root, Thu Apr 13 23:07:58 2006 UTC

18use CFClient; 18use CFClient;
19use CFClient::UI; 19use CFClient::UI;
20 20
21our $VERSION = '0.1'; 21our $VERSION = '0.1';
22 22
23my $MAX_FPS = 60; 23my $MAX_FPS = 500;
24my $MIN_FPS = 5; # unused as of yet 24my $MIN_FPS = 5; # unused as of yet
25 25
26our $FACECACHE; 26our $FACECACHE;
27 27
28our $LAST_REFRESH; 28our $LAST_REFRESH;
35our @SDL_MODES; 35our @SDL_MODES;
36our $WIDTH; 36our $WIDTH;
37our $HEIGHT; 37our $HEIGHT;
38our $FULLSCREEN; 38our $FULLSCREEN;
39 39
40our $MAP;
40our $MAPWIDGET; 41our $MAPWIDGET;
41our $FONTSIZE; 42our $FONTSIZE;
42 43
43our $SDL_ACTIVE; 44our $SDL_ACTIVE;
44our $SDL_EV; 45our $SDL_EV;
63sub start_game { 64sub start_game {
64 status "logging in..."; 65 status "logging in...";
65 66
66 my $mapsize = List::Util::min 64, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; 67 my $mapsize = List::Util::min 64, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32;
67 68
69 $MAP = new CFClient::Map $mapsize, $mapsize;
70
68 $CONN = new conn 71 $CONN = new conn
69 host => $CFG->{host}, 72 host => $CFG->{host},
70 port => $CFG->{port}, 73 port => $CFG->{port},
71 user => $CFG->{user}, 74 user => $CFG->{user},
72 pass => $CFG->{password}, 75 pass => $CFG->{password},
113 $table->add (1, 2, new CFClient::UI::CheckBox state => $CFG->{fast}, connect_changed => sub { 116 $table->add (1, 2, new CFClient::UI::CheckBox state => $CFG->{fast}, connect_changed => sub {
114 my ($self, $value) = @_; 117 my ($self, $value) = @_;
115 $CFG->{fast} = $value; 118 $CFG->{fast} = $value;
116 }); 119 });
117 120
118 $table->add (0, 2, new CFClient::UI::Label align => 1, text => "Fog of War"); 121 $table->add (0, 3, new CFClient::UI::Label align => 1, text => "Fog of War");
119 $table->add (1, 2, new CFClient::UI::Slider range => [$CFG->{fow_intensity}, 0, 1 + 0.001, 0.001], connect_changed => sub { 122 $table->add (1, 3, new CFClient::UI::Slider range => [$CFG->{fow_intensity}, 0, 1 + 0.001, 0.001], connect_changed => sub {
120 my ($self, $value) = @_; 123 my ($self, $value) = @_;
121 $CFG->{fow_intensity} = $value; 124 $CFG->{fow_intensity} = $value;
122 }); 125 });
123 126
127 $table->add (0, 4, new CFClient::UI::Label align => 1, text => "Smooth FoW");
128 $table->add (1, 4, new CFClient::UI::CheckBox state => $CFG->{fow_smooth}, connect_changed => sub {
129 my ($self, $value) = @_;
130 $CFG->{fow_smooth} = $value;
131 });
132
124 $table->add (1, 4, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { 133 $table->add (1, 5, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub {
125 destroy_screen (); 134 destroy_screen ();
126 init_screen (); 135 init_screen ();
127 }); 136 });
128 137
129 $vbox->add (new CFClient::UI::Label align => 0, text => "Server Setup"); 138 $vbox->add (new CFClient::UI::Label align => 0, text => "Server Setup");
163 }); 172 });
164 $CFClient::UI::TOPLEVEL->add ($dialog); 173 $CFClient::UI::TOPLEVEL->add ($dialog);
165} 174}
166 175
167sub sdl_init { 176sub sdl_init {
168 SDL::Init SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO 177 SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE
169 and die "SDL::Init failed!\n"; 178 and die "SDL::Init failed!\n";
170} 179}
171 180
172sub init_screen { 181sub init_screen {
173 sdl_init; 182 sdl_init;
249 258
250sub force_refresh { 259sub force_refresh {
251 $fps = $fps * 0.95 + 1 / ($NOW - $LAST_REFRESH) * 0.05; 260 $fps = $fps * 0.95 + 1 / ($NOW - $LAST_REFRESH) * 0.05;
252 debug sprintf "%3.2f", $fps; 261 debug sprintf "%3.2f", $fps;
253 262
254 $want_refresh = 0; 263# $want_refresh = 0;#d#
255 $can_refresh = 0; 264 $can_refresh = 0;
256 265
257 glViewport 0, 0, $WIDTH, $HEIGHT; 266 glViewport 0, 0, $WIDTH, $HEIGHT;
258 267
259 glMatrixMode GL_PROJECTION; 268 glMatrixMode GL_PROJECTION;
311 320
312 $self->send ($command); 321 $self->send ($command);
313 status $command; 322 status $command;
314} 323}
315 324
316sub conn::map_update { 325sub conn::feed_map1a {
317 my ($self, $dirty) = @_; 326 my ($self, $data) = @_;
318 327
328# $self->Crossfire::Protocol::feed_map1a ($data);
329
330 $MAP->scroll (delete $self->{delayed_scroll_x}, delete $self->{delayed_scroll_y});
331 $MAP->map1a_update ($data);
319 $MAPWIDGET->update; 332 $MAPWIDGET->update;
320} 333}
321 334
322sub conn::map_scroll { 335#sub conn::map_update {
323 my ($self, $dx, $dy) = @_; 336# my ($self, $dirty) = @_;
324 337#
325# refresh; 338# $MAPWIDGET->update;
326} 339#}
327 340
328sub conn::map_clear { 341sub conn::map_clear {
329 my ($self) = @_; 342 my ($self) = @_;
330 343
344 $MAP->clear;
345
331# refresh; 346# refresh;
332} 347}
333 348
334sub conn::face_find { 349sub conn::face_find {
335 my ($self, $face) = @_; 350 my ($self, $face) = @_;
336 351
337 $FACECACHE->{"$face->{chksum},$face->{name}"} 352 $FACECACHE->{"$face->{chksum},$face->{name}"}
338} 353}
339 354
340sub conn::face_update { 355sub conn::face_update {
341 my ($self, $face) = @_; 356 my ($self, $facenum, $face) = @_;
342 357
343 $FACECACHE->{"$face->{chksum},$face->{name}"} = $face->{image}; 358 $FACECACHE->{"$face->{chksum},$face->{name}"} = $face->{image};
344 359
345 $face->{texture} = new_from_image CFClient::Texture delete $face->{image}; 360 my $tex = $face->{texture} = new_from_image CFClient::Texture delete $face->{image};
361
362 $MAP->set_texture ($facenum, @$tex{qw(name w h s t)});
363 $MAPWIDGET->update;
346} 364}
347 365
348sub conn::query { 366sub conn::query {
349 my ($self, $flags, $prompt) = @_; 367 my ($self, $flags, $prompt) = @_;
350 368
394my %DEF_CFG = ( 412my %DEF_CFG = (
395 width => 640, 413 width => 640,
396 height => 480, 414 height => 480,
397 fast => 0, 415 fast => 0,
398 fow_intensity => 0.45, 416 fow_intensity => 0.45,
417 fow_smooth => 0,
399 fullscreen => 0, 418 fullscreen => 0,
400 sdl_mode => 0, 419 sdl_mode => 0,
401 mapsize => 100, 420 mapsize => 100,
402 host => "crossfire.schmorp.de", 421 host => "crossfire.schmorp.de",
403 port => 13327, 422 port => 13327,
407 $CFG->{$k} = $v unless exists $CFG->{$k}; 426 $CFG->{$k} = $v unless exists $CFG->{$k};
408} 427}
409 428
410sdl_init; 429sdl_init;
411 430
412@SDL_MODES = reverse map [SDL::RectW ($_), SDL::RectH ($_)], 431@SDL_MODES = reverse
432 grep $_->[0] >= 640 && $_->[1] >= 480,
433 map [SDL::RectW ($_), SDL::RectH ($_)],
413 @{ SDL::ListModes 0, SDL_FULLSCREEN | SDL_HWSURFACE | SDL_OPENGL }; 434 @{ SDL::ListModes 0, SDL_FULLSCREEN | SDL_HWSURFACE | SDL_OPENGL };
414 435
415@SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; 436@SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)";
416 437
417$CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES; 438$CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES;
418 439

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines