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.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},
113 $table->add (1, 2, new CFClient::UI::CheckBox state => $CFG->{fast}, connect_changed => sub { 117 $table->add (1, 2, new CFClient::UI::CheckBox state => $CFG->{fast}, connect_changed => sub {
114 my ($self, $value) = @_; 118 my ($self, $value) = @_;
115 $CFG->{fast} = $value; 119 $CFG->{fast} = $value;
116 }); 120 });
117 121
118 $table->add (0, 2, 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, 2, 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
134 $table->add (0, 5, new CFClient::UI::Label align => 1, text => "FoW Smooth");
135 $table->add (1, 5, new CFClient::UI::CheckBox state => $CFG->{fow_smooth}, connect_changed => sub {
136 my ($self, $value) = @_;
137 $CFG->{fow_smooth} = $value;
138 });
139
124 $table->add (1, 4, 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 {
125 destroy_screen (); 141 destroy_screen ();
126 init_screen (); 142 init_screen ();
127 }); 143 });
128 144
129 $vbox->add (new CFClient::UI::Label align => 0, text => "Server Setup"); 145 $vbox->add (new CFClient::UI::Label align => 0, text => "Server Setup");
159 175
160 $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 {
161 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; 177 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc";
162 status "Configuration Saved"; 178 status "Configuration Saved";
163 }); 179 });
164 $CFClient::UI::TOPLEVEL->add ($dialog); 180
181 $dialog
165} 182}
166 183
167sub sdl_init { 184sub sdl_init {
168 SDL::Init SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO 185 SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE
169 and die "SDL::Init failed!\n"; 186 and die "SDL::Init failed!\n";
170} 187}
171 188
172sub init_screen { 189sub init_screen {
173 sdl_init; 190 sdl_init;
223 y => $HEIGHT * 49 / 50, 240 y => $HEIGHT * 49 / 50,
224 height => $HEIGHT / 50, 241 height => $HEIGHT / 50,
225 text => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; 242 text => "Use <b>Alt-Enter</b> to toggle fullscreen mode";
226 $CFClient::UI::TOPLEVEL->add ($ALT_ENTER_MESSAGE); 243 $CFClient::UI::TOPLEVEL->add ($ALT_ENTER_MESSAGE);
227 244
228 $MAPWIDGET = new CFClient::UI::MapWidget;
229 $CFClient::UI::TOPLEVEL->add ($MAPWIDGET); 245 $CFClient::UI::TOPLEVEL->add ($MAPWIDGET = new CFClient::UI::MapWidget);
230 $MAPWIDGET->focus_in; 246 $MAPWIDGET->focus_in;
231 247
232 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);
233} 251}
234 252
235sub destroy_screen { 253sub destroy_screen {
236 $CFClient::UI::TOPLEVEL->{children} = []; 254 $CFClient::UI::TOPLEVEL->{children} = [];
237 undef $SDL_ACTIVE; 255 undef $SDL_ACTIVE;
311 329
312 $self->send ($command); 330 $self->send ($command);
313 status $command; 331 status $command;
314} 332}
315 333
316sub conn::map_update { 334sub conn::feed_map1a {
317 my ($self, $dirty) = @_; 335 my ($self, $data) = @_;
318 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);
319 $MAPWIDGET->update; 341 $MAPWIDGET->update;
320} 342}
321 343
322sub conn::map_scroll { 344#sub conn::map_update {
323 my ($self, $dx, $dy) = @_; 345# my ($self, $dirty) = @_;
324 346#
325# refresh; 347# $MAPWIDGET->update;
326} 348#}
327 349
328sub conn::map_clear { 350sub conn::map_clear {
329 my ($self) = @_; 351 my ($self) = @_;
330 352
353 $MAP->clear;
354
331# refresh; 355# refresh;
332} 356}
333 357
334sub conn::face_find { 358sub conn::face_find {
335 my ($self, $face) = @_; 359 my ($self, $face) = @_;
336 360
337 $FACECACHE->{"$face->{chksum},$face->{name}"} 361 $FACECACHE->{"$face->{chksum},$face->{name}"}
338} 362}
339 363
340sub conn::face_update { 364sub conn::face_update {
341 my ($self, $face) = @_; 365 my ($self, $facenum, $face) = @_;
342 366
343 $FACECACHE->{"$face->{chksum},$face->{name}"} = $face->{image}; 367 $FACECACHE->{"$face->{chksum},$face->{name}"} = $face->{image};
344 368
345 $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;
346} 373}
347 374
348sub conn::query { 375sub conn::query {
349 my ($self, $flags, $prompt) = @_; 376 my ($self, $flags, $prompt) = @_;
350 377
393 420
394my %DEF_CFG = ( 421my %DEF_CFG = (
395 width => 640, 422 width => 640,
396 height => 480, 423 height => 480,
397 fast => 0, 424 fast => 0,
425 fow_enable => 1,
398 fow_intensity => 0.45, 426 fow_intensity => 0.45,
427 fow_smooth => 0,
399 fullscreen => 0, 428 fullscreen => 0,
400 sdl_mode => 0, 429 sdl_mode => 0,
401 mapsize => 100, 430 mapsize => 100,
402 host => "crossfire.schmorp.de", 431 host => "crossfire.schmorp.de",
403 port => 13327, 432 port => 13327,
407 $CFG->{$k} = $v unless exists $CFG->{$k}; 436 $CFG->{$k} = $v unless exists $CFG->{$k};
408} 437}
409 438
410sdl_init; 439sdl_init;
411 440
412@SDL_MODES = reverse map [SDL::RectW ($_), SDL::RectH ($_)], 441@SDL_MODES = reverse
442 grep $_->[0] >= 640 && $_->[1] >= 480,
443 map [SDL::RectW ($_), SDL::RectH ($_)],
413 @{ SDL::ListModes 0, SDL_FULLSCREEN | SDL_HWSURFACE | SDL_OPENGL }; 444 @{ SDL::ListModes 0, SDL_FULLSCREEN | SDL_HWSURFACE | SDL_OPENGL };
414 445
415@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)";
416 447
417$CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES; 448$CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES;
418 449

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines