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.91 by root, Wed Apr 12 23:15:39 2006 UTC vs.
Revision 1.98 by root, Fri Apr 14 00:15:52 2006 UTC

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;
45our %SDL_CB; 46our %SDL_CB;
46 47
47our $ALT_ENTER_MESSAGE; 48our $ALT_ENTER_MESSAGE;
48our $STATUS_LINE; 49our $STATUS_LINE;
49our $DEBUG_STATUS; 50our $DEBUG_STATUS;
51our $BUTTONBAR;
50 52
51sub status { 53sub status {
52 $STATUS_LINE->set_text ($_[0]); 54 $STATUS_LINE->set_text ($_[0]);
53 my ($w, $h) = $STATUS_LINE->size_request; 55 my ($w, $h) = $STATUS_LINE->size_request;
54 $STATUS_LINE->size_allocate (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $h, $w, $h); 56 $STATUS_LINE->size_allocate (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $h, $w, $h);
63sub start_game { 65sub start_game {
64 status "logging in..."; 66 status "logging in...";
65 67
66 my $mapsize = List::Util::min 64, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; 68 my $mapsize = List::Util::min 64, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32;
67 69
70 $MAP = new CFClient::Map $mapsize, $mapsize;
71
68 $CONN = new conn 72 $CONN = new conn
69 host => $CFG->{host}, 73 host => $CFG->{host},
70 port => $CFG->{port}, 74 port => $CFG->{port},
71 user => $CFG->{user}, 75 user => $CFG->{user},
72 pass => $CFG->{password}, 76 pass => $CFG->{password},
114 my ($self, $value) = @_; 118 my ($self, $value) = @_;
115 $CFG->{fast} = $value; 119 $CFG->{fast} = $value;
116 }); 120 });
117 121
118 $table->add (0, 3, new CFClient::UI::Label align => 1, text => "Fog of War"); 122 $table->add (0, 3, new CFClient::UI::Label align => 1, text => "Fog of War");
123 $table->add (1, 3, new CFClient::UI::CheckBox state => $CFG->{fow_enable}, connect_changed => sub {
124 my ($self, $value) = @_;
125 $CFG->{fow_enable} = $value;
126 });
127
128 $table->add (0, 4, new CFClient::UI::Label align => 1, text => "FoW Intensity");
119 $table->add (1, 3, new CFClient::UI::Slider range => [$CFG->{fow_intensity}, 0, 1 + 0.001, 0.001], connect_changed => sub { 129 $table->add (1, 4, new CFClient::UI::Slider range => [$CFG->{fow_intensity}, 0, 1 + 0.001, 0.001], connect_changed => sub {
120 my ($self, $value) = @_; 130 my ($self, $value) = @_;
121 $CFG->{fow_intensity} = $value; 131 $CFG->{fow_intensity} = $value;
122 }); 132 });
123 133
124 $table->add (0, 4, new CFClient::UI::Label align => 1, text => "Smooth FoW"); 134 $table->add (0, 5, new CFClient::UI::Label align => 1, text => "FoW Smooth");
125 $table->add (1, 4, new CFClient::UI::CheckBox state => $CFG->{fow_smooth}, connect_changed => sub { 135 $table->add (1, 5, new CFClient::UI::CheckBox state => $CFG->{fow_smooth}, connect_changed => sub {
126 my ($self, $value) = @_; 136 my ($self, $value) = @_;
127 $CFG->{fow_smooth} = $value; 137 $CFG->{fow_smooth} = $value;
128 }); 138 });
129 139
130 $table->add (1, 5, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { 140 $table->add (1, 6, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub {
131 destroy_screen (); 141 destroy_screen ();
132 init_screen (); 142 init_screen ();
133 }); 143 });
134 144
135 $vbox->add (new CFClient::UI::Label align => 0, text => "Server Setup"); 145 $vbox->add (new CFClient::UI::Label align => 0, text => "Server Setup");
165 175
166 $hbox->add (new CFClient::UI::Button expand => 1, align => 0, text => "Save", connect_activate => sub { 176 $hbox->add (new CFClient::UI::Button expand => 1, align => 0, text => "Save", connect_activate => sub {
167 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; 177 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc";
168 status "Configuration Saved"; 178 status "Configuration Saved";
169 }); 179 });
170 $CFClient::UI::TOPLEVEL->add ($dialog); 180
181 $dialog
171} 182}
172 183
173sub sdl_init { 184sub sdl_init {
174 SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO 185 SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE
175 and die "SDL::Init failed!\n"; 186 and die "SDL::Init failed!\n";
176} 187}
177 188
178sub init_screen { 189sub init_screen {
179 sdl_init; 190 sdl_init;
229 y => $HEIGHT * 49 / 50, 240 y => $HEIGHT * 49 / 50,
230 height => $HEIGHT / 50, 241 height => $HEIGHT / 50,
231 text => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; 242 text => "Use <b>Alt-Enter</b> to toggle fullscreen mode";
232 $CFClient::UI::TOPLEVEL->add ($ALT_ENTER_MESSAGE); 243 $CFClient::UI::TOPLEVEL->add ($ALT_ENTER_MESSAGE);
233 244
234 $MAPWIDGET = new CFClient::UI::MapWidget;
235 $CFClient::UI::TOPLEVEL->add ($MAPWIDGET); 245 $CFClient::UI::TOPLEVEL->add ($MAPWIDGET = new CFClient::UI::MapWidget);
236 $MAPWIDGET->focus_in; 246 $MAPWIDGET->focus_in;
237 247
238 config_dialog; 248 $CFClient::UI::TOPLEVEL->add ($BUTTONBAR = new CFClient::UI::HBox);
249
250 $BUTTONBAR->add (my $setup = new CFClient::UI::Flopper x => 0, y => 0, text => "Setup", other => config_dialog, state => 1);
239} 251}
240 252
241sub destroy_screen { 253sub destroy_screen {
242 $CFClient::UI::TOPLEVEL->{children} = []; 254 $CFClient::UI::TOPLEVEL->{children} = [];
243 undef $SDL_ACTIVE; 255 undef $SDL_ACTIVE;
317 329
318 $self->send ($command); 330 $self->send ($command);
319 status $command; 331 status $command;
320} 332}
321 333
322sub conn::map_update { 334sub conn::feed_map1a {
323 my ($self, $dirty) = @_; 335 my ($self, $data) = @_;
324 336
337# $self->Crossfire::Protocol::feed_map1a ($data);
338
339 $MAP->scroll (delete $self->{delayed_scroll_x}, delete $self->{delayed_scroll_y});
340 $MAP->map1a_update ($data);
325 $MAPWIDGET->update; 341 $MAPWIDGET->update;
326} 342}
327 343
328sub conn::map_scroll { 344#sub conn::map_update {
329 my ($self, $dx, $dy) = @_; 345# my ($self, $dirty) = @_;
330 346#
331# refresh; 347# $MAPWIDGET->update;
332} 348#}
333 349
334sub conn::map_clear { 350sub conn::map_clear {
335 my ($self) = @_; 351 my ($self) = @_;
336 352
353 $MAP->clear;
354
337# refresh; 355# refresh;
338} 356}
339 357
340sub conn::face_find { 358sub conn::face_find {
341 my ($self, $face) = @_; 359 my ($self, $face) = @_;
342 360
343 $FACECACHE->{"$face->{chksum},$face->{name}"} 361 $FACECACHE->{"$face->{chksum},$face->{name}"}
344} 362}
345 363
346sub conn::face_update { 364sub conn::face_update {
347 my ($self, $face) = @_; 365 my ($self, $facenum, $face) = @_;
348 366
349 $FACECACHE->{"$face->{chksum},$face->{name}"} = $face->{image}; 367 $FACECACHE->{"$face->{chksum},$face->{name}"} = $face->{image};
350 368
351 $face->{texture} = new_from_image CFClient::Texture delete $face->{image}; 369 my $tex = $face->{texture} = new_from_image CFClient::Texture delete $face->{image};
370
371 $MAP->set_texture ($facenum, @$tex{qw(name w h s t)});
372 $MAPWIDGET->update;
352} 373}
353 374
354sub conn::query { 375sub conn::query {
355 my ($self, $flags, $prompt) = @_; 376 my ($self, $flags, $prompt) = @_;
356 377
399 420
400my %DEF_CFG = ( 421my %DEF_CFG = (
401 width => 640, 422 width => 640,
402 height => 480, 423 height => 480,
403 fast => 0, 424 fast => 0,
425 fow_enable => 1,
404 fow_intensity => 0.45, 426 fow_intensity => 0.45,
405 fow_smooth => 1, 427 fow_smooth => 0,
406 fullscreen => 0, 428 fullscreen => 0,
407 sdl_mode => 0, 429 sdl_mode => 0,
408 mapsize => 100, 430 mapsize => 100,
409 host => "crossfire.schmorp.de", 431 host => "crossfire.schmorp.de",
410 port => 13327, 432 port => 13327,
414 $CFG->{$k} = $v unless exists $CFG->{$k}; 436 $CFG->{$k} = $v unless exists $CFG->{$k};
415} 437}
416 438
417sdl_init; 439sdl_init;
418 440
419@SDL_MODES = reverse map [SDL::RectW ($_), SDL::RectH ($_)], 441@SDL_MODES = reverse
442 grep $_->[0] >= 640 && $_->[1] >= 480,
443 map [SDL::RectW ($_), SDL::RectH ($_)],
420 @{ SDL::ListModes 0, SDL_FULLSCREEN | SDL_HWSURFACE | SDL_OPENGL }; 444 @{ SDL::ListModes 0, SDL_FULLSCREEN | SDL_HWSURFACE | SDL_OPENGL };
421 445
422@SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; 446@SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)";
423 447
424$CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES; 448$CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES;
425 449

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines