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.88 by root, Wed Apr 12 21:01:47 2006 UTC vs.
Revision 1.93 by root, Wed Apr 12 23:37:38 2006 UTC

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 = 60;
24my $MIN_FPS = 5; # unused 24my $MIN_FPS = 5; # unused as of yet
25 25
26our $FACECACHE; 26our $FACECACHE;
27 27
28our $LAST_REFRESH; 28our $LAST_REFRESH;
29our $NOW; 29our $NOW;
107 $table->add (1, 1, new CFClient::UI::CheckBox state => $CFG->{fullscreen}, connect_changed => sub { 107 $table->add (1, 1, new CFClient::UI::CheckBox state => $CFG->{fullscreen}, connect_changed => sub {
108 my ($self, $value) = @_; 108 my ($self, $value) = @_;
109 $CFG->{fullscreen} = $value; 109 $CFG->{fullscreen} = $value;
110 }); 110 });
111 111
112 $table->add (0, 2, new CFClient::UI::Label align => 1, text => "Fast & Ugly");
113 $table->add (1, 2, new CFClient::UI::CheckBox state => $CFG->{fast}, connect_changed => sub {
114 my ($self, $value) = @_;
115 $CFG->{fast} = $value;
116 });
117
118 $table->add (0, 3, new CFClient::UI::Label align => 1, text => "Fog of War");
119 $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) = @_;
121 $CFG->{fow_intensity} = $value;
122 });
123
124 $table->add (0, 4, new CFClient::UI::Label align => 1, text => "Smooth FoW");
125 $table->add (1, 4, new CFClient::UI::CheckBox state => $CFG->{fow_smooth}, connect_changed => sub {
126 my ($self, $value) = @_;
127 $CFG->{fow_smooth} = $value;
128 });
129
112 $table->add (1, 2, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { 130 $table->add (1, 5, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub {
113 destroy_screen (); 131 destroy_screen ();
114 init_screen (); 132 init_screen ();
115 }); 133 });
116 134
117 $vbox->add (new CFClient::UI::Label align => 0, text => "Server"); 135 $vbox->add (new CFClient::UI::Label align => 0, text => "Server Setup");
118 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); 136 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]);
119 $table->add (0, 2, new CFClient::UI::Label align => 1, text => "Host"); 137 $table->add (0, 2, new CFClient::UI::Label align => 1, text => "Host");
120 $table->add (1, 2, my $host = new CFClient::UI::Entry text => $CFG->{host}); 138 $table->add (1, 2, my $host = new CFClient::UI::Entry text => $CFG->{host});
121 139
122 $table->add (0, 3, new CFClient::UI::Label align => 1, text => "Port"); 140 $table->add (0, 3, new CFClient::UI::Label align => 1, text => "Port");
150 status "Configuration Saved"; 168 status "Configuration Saved";
151 }); 169 });
152 $CFClient::UI::TOPLEVEL->add ($dialog); 170 $CFClient::UI::TOPLEVEL->add ($dialog);
153} 171}
154 172
173sub sdl_init {
174 SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO
175 and die "SDL::Init failed!\n";
176}
177
155sub init_screen { 178sub init_screen {
179 sdl_init;
180
156 ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; 181 ($WIDTH, $HEIGHT) = @{ $SDL_MODES[$CFG->{sdl_mode}] };
157 $FULLSCREEN = $CFG->{fullscreen}; 182 $FULLSCREEN = $CFG->{fullscreen};
183 $FAST = $CFG->{fast};
158 184
159 SDL::GLSetAttribute SDL_GL_RED_SIZE, 5; 185 SDL::GLSetAttribute SDL_GL_RED_SIZE, 5;
160 SDL::GLSetAttribute SDL_GL_GREEN_SIZE, 5; 186 SDL::GLSetAttribute SDL_GL_GREEN_SIZE, 5;
161 SDL::GLSetAttribute SDL_GL_BLUE_SIZE, 5; 187 SDL::GLSetAttribute SDL_GL_BLUE_SIZE, 5;
162 SDL::GLSetAttribute SDL_GL_ALPHA_SIZE, 0; 188 SDL::GLSetAttribute SDL_GL_ALPHA_SIZE, 0;
240 glLoadIdentity; 266 glLoadIdentity;
241 glOrtho 0, $WIDTH, $HEIGHT, 0, -10000 , 10000; 267 glOrtho 0, $WIDTH, $HEIGHT, 0, -10000 , 10000;
242 glMatrixMode GL_MODELVIEW; 268 glMatrixMode GL_MODELVIEW;
243 glLoadIdentity; 269 glLoadIdentity;
244 270
271 glClearColor +($CFG->{fow_intensity}) x 3, 1;
245 glClear GL_COLOR_BUFFER_BIT; 272 glClear GL_COLOR_BUFFER_BIT;
246 273
247 $CFClient::UI::TOPLEVEL->draw; 274 $CFClient::UI::TOPLEVEL->draw;
248 275
249 SDL::GLSwapBuffers; 276 SDL::GLSwapBuffers;
283 delete $animate_object{$widget}; 310 delete $animate_object{$widget};
284} 311}
285 312
286@conn::ISA = Crossfire::Protocol::; 313@conn::ISA = Crossfire::Protocol::;
287 314
288sub conn::send { 315sub conn::user_send {
289 my ($self, $command) = @_; 316 my ($self, $command) = @_;
290 317
291 $self->Crossfire::Protocol::send ($command); 318 $self->send ($command);
292 status $command; 319 status $command;
293} 320}
294 321
295sub conn::map_update { 322sub conn::map_update {
296 my ($self, $dirty) = @_; 323 my ($self, $dirty) = @_;
368 395
369############################################################################# 396#############################################################################
370 397
371CFClient::read_cfg "$Crossfire::VARDIR/pclientrc"; 398CFClient::read_cfg "$Crossfire::VARDIR/pclientrc";
372 399
373$CFG ||= { 400my %DEF_CFG = (
374 width => 640, 401 width => 640,
375 height => 480, 402 height => 480,
403 fast => 0,
404 fow_intensity => 0.45,
405 fow_smooth => 0,
376 fullscreen => 0, 406 fullscreen => 0,
377 sdl_mode => 0, 407 sdl_mode => 0,
378 mapsize => 100, 408 mapsize => 100,
379 host => "crossfire.schmorp.de", 409 host => "crossfire.schmorp.de",
380 port => 13327, 410 port => 13327,
381}; 411);
382 412
383SDL::Init SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO 413while (my ($k, $v) = each %DEF_CFG) {
384 and die "SDL::Init failed!\n"; 414 $CFG->{$k} = $v unless exists $CFG->{$k};
415}
385 416
386@SDL_MODES = reverse map [SDL::RectW ($_), SDL::RectH ($_)], 417sdl_init;
418
419@SDL_MODES = reverse
420 grep $_->[0] >= 640 && $_->[1] >= 480,
421 map [SDL::RectW ($_), SDL::RectH ($_)],
387 @{ SDL::ListModes 0, SDL_FULLSCREEN | SDL_HWSURFACE | SDL_OPENGL }; 422 @{ SDL::ListModes 0, SDL_FULLSCREEN | SDL_HWSURFACE | SDL_OPENGL };
423
424@SDL_MODES or CFClient::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)";
425
426$CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES;
388 427
389init_screen; 428init_screen;
390 429
391{ 430{
392 my @fonts = map CFClient::find_rcfile $_, qw(uifont.ttf uifontb.ttf uifonti.ttf uifontbi.ttf); 431 my @fonts = map CFClient::find_rcfile $_, qw(uifont.ttf uifontb.ttf uifonti.ttf uifontbi.ttf);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines