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.101 by elmex, Fri Apr 14 11:32:22 2006 UTC vs.
Revision 1.109 by root, Sat Apr 15 01:45:32 2006 UTC

48our $ALT_ENTER_MESSAGE; 48our $ALT_ENTER_MESSAGE;
49our $STATUS_LINE; 49our $STATUS_LINE;
50our $DEBUG_STATUS; 50our $DEBUG_STATUS;
51our $BUTTONBAR; 51our $BUTTONBAR;
52our $LOGVIEW; 52our $LOGVIEW;
53our $CONSOLE;
53 54
54sub status { 55sub status {
55 $STATUS_LINE->set_text ($_[0]); 56 $STATUS_LINE->set_text ($_[0]);
56 my ($w, $h) = $STATUS_LINE->size_request; 57 my ($w, $h) = $STATUS_LINE->size_request;
57 $STATUS_LINE->size_allocate (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $h, $w, $h); 58 $STATUS_LINE->size_allocate (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h} - $h, $w, $h);
64} 65}
65 66
66sub start_game { 67sub start_game {
67 status "logging in..."; 68 status "logging in...";
68 69
69 my $mapsize = List::Util::min 64, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; 70 my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32;
70 71
71 $MAP = new CFClient::Map $mapsize, $mapsize; 72 $MAP = new CFClient::Map $mapsize, $mapsize;
72 73
73 $CONN = new conn 74 $CONN = new conn
74 host => $CFG->{host}, 75 host => $CFG->{host},
136 $table->add (1, 5, new CFClient::UI::CheckBox state => $CFG->{fow_smooth}, connect_changed => sub { 137 $table->add (1, 5, new CFClient::UI::CheckBox state => $CFG->{fow_smooth}, connect_changed => sub {
137 my ($self, $value) = @_; 138 my ($self, $value) = @_;
138 $CFG->{fow_smooth} = $value; 139 $CFG->{fow_smooth} = $value;
139 }); 140 });
140 141
142 $table->add (0, 5, new CFClient::UI::Label align => 1, text => "Log Fontsize");
143 $table->add (1, 5, new CFClient::UI::Slider range => [$CFG->{log_fontsize}, 8, 30, 1], connect_changed => sub {
144 my ($self, $value) = @_;
145 $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = int $value);
146 });
147
141 $table->add (1, 6, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { 148 $table->add (1, 6, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub {
142 destroy_screen (); 149 destroy_screen ();
143 init_screen (); 150 init_screen ();
144 }); 151 });
145 152
202 209
203sub console_window { 210sub console_window {
204 my $window = new CFClient::UI::FancyFrame 211 my $window = new CFClient::UI::FancyFrame
205 border_bg => [1, 1, 1, 0.5], 212 border_bg => [1, 1, 1, 0.5],
206 bg => [0.3, 0.3, 0.3, 0.8], 213 bg => [0.3, 0.3, 0.3, 0.8],
214 user_w => $::WIDTH/4,
215 user_h => $::HEIGHT,
207 child => (my $vbox = new CFClient::UI::VBox); 216 child => (my $vbox = new CFClient::UI::VBox);
208 217
209 $vbox->add ($LOGVIEW = new CFClient::UI::TextView expand => 1); 218 $vbox->add ($LOGVIEW = new CFClient::UI::TextView
219 expand => 1,
220 fontsize => $::CFG->{log_fontsize},
221 );
222
210 $vbox->add (my $input = new CFClient::UI::LineEntry); 223 $vbox->add (my $input = new CFClient::UI::LineEntry);
211 $input->connect (activate => sub { 224 $input->connect (activate => sub {
212 my ($input, $text) = @_; 225 my ($input, $text) = @_;
213 $input->set_text (''); 226 $input->set_text ('');
214 227
218 my $say_cmd = $::CFG->{say_command} || 'say'; 231 my $say_cmd = $::CFG->{say_command} || 'say';
219 $::CONN->user_send ("command $say_cmd $text"); 232 $::CONN->user_send ("command $say_cmd $text");
220 } 233 }
221 1 234 1
222 }); 235 });
236 $input->connect (escape => sub {
237 $MAPWIDGET->focus_in
238 });
239 $input->focus_in;
240
241 $CONSOLE = {
242 window => $window,
243 input => $input
244 };
223 245
224 $window 246 $window
225} 247}
226 248
227sub sdl_init { 249sub sdl_init {
250 #SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE
228 SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO 251 SDL::Init SDL_INIT_AUDIO | SDL_INIT_VIDEO
229 and die "SDL::Init failed!\n"; 252 and die "SDL::Init failed!\n";
230} 253}
231 254
232sub init_screen { 255sub init_screen {
285 text => "Use <b>Alt-Enter</b> to toggle fullscreen mode"; 308 text => "Use <b>Alt-Enter</b> to toggle fullscreen mode";
286 $CFClient::UI::TOPLEVEL->add ($ALT_ENTER_MESSAGE); 309 $CFClient::UI::TOPLEVEL->add ($ALT_ENTER_MESSAGE);
287 310
288 $CFClient::UI::TOPLEVEL->add ($MAPWIDGET = new CFClient::UI::MapWidget); 311 $CFClient::UI::TOPLEVEL->add ($MAPWIDGET = new CFClient::UI::MapWidget);
289 $MAPWIDGET->focus_in; 312 $MAPWIDGET->focus_in;
313 $MAPWIDGET->connect (activate_console => sub {
314 my ($mapwidget, $preset) = @_;
315
316 if ($CONSOLE) {
317 $CONSOLE->{input}->focus_in;
318
319 if ($preset && $CONSOLE->{input}->get_text eq '') {
320 $CONSOLE->{input}->set_text ($preset);
321 }
322 }
323 });
290 324
291 $CFClient::UI::TOPLEVEL->add ($BUTTONBAR = new CFClient::UI::HBox); 325 $CFClient::UI::TOPLEVEL->add ($BUTTONBAR = new CFClient::UI::HBox);
292 326
293 $BUTTONBAR->add (my $setup = new CFClient::UI::Flopper x => 0, y => 0, text => "Setup", other => config_dialog, state => 1); 327 $BUTTONBAR->add (my $setup = new CFClient::UI::Flopper x => 0, y => 0, text => "Setup", other => config_dialog, state => 1);
294 $BUTTONBAR->add (my $setup = new CFClient::UI::Flopper x => 0, y => 0, text => "Console", other => console_window); 328 $BUTTONBAR->add (my $setup = new CFClient::UI::Flopper x => 0, y => 0, text => "Console", other => console_window);
313 $fps = $fps * 0.95 + 1 / ($NOW - $LAST_REFRESH) * 0.05; 347 $fps = $fps * 0.95 + 1 / ($NOW - $LAST_REFRESH) * 0.05;
314 debug sprintf "%3.2f", $fps; 348 debug sprintf "%3.2f", $fps;
315 349
316 $want_refresh = 0; 350 $want_refresh = 0;
317 $can_refresh = 0; 351 $can_refresh = 0;
318
319 glViewport 0, 0, $WIDTH, $HEIGHT;
320
321 glMatrixMode GL_PROJECTION;
322 glLoadIdentity;
323 glOrtho 0, $WIDTH, $HEIGHT, 0, -10000 , 10000;
324 glMatrixMode GL_MODELVIEW;
325 glLoadIdentity;
326
327 glClearColor +($CFG->{fow_intensity}) x 3, 1;
328 glClear GL_COLOR_BUFFER_BIT;
329 352
330 $CFClient::UI::TOPLEVEL->draw; 353 $CFClient::UI::TOPLEVEL->draw;
331 354
332 SDL::GLSwapBuffers; 355 SDL::GLSwapBuffers;
333 356
408sub conn::face_update { 431sub conn::face_update {
409 my ($self, $facenum, $face) = @_; 432 my ($self, $facenum, $face) = @_;
410 433
411 $FACECACHE->{"$face->{chksum},$face->{name}"} = $face->{image}; 434 $FACECACHE->{"$face->{chksum},$face->{name}"} = $face->{image};
412 435
413 my $tex = $face->{texture} = new_from_image CFClient::Texture delete $face->{image}; 436 my $tex = $face->{texture} =
437 new_from_image CFClient::Texture
438 delete $face->{image}, minify => 1;
414 439
415 $MAP->set_texture ($facenum, @$tex{qw(name w h s t)}); 440 $MAP->set_texture ($facenum, @$tex{qw(name w h s t)}, @{$tex->{minified}});
416 $MAPWIDGET->update; 441 $MAPWIDGET->update;
417} 442}
418 443
419sub conn::query { 444sub conn::query {
420 my ($self, $flags, $prompt) = @_; 445 my ($self, $flags, $prompt) = @_;
484############################################################################# 509#############################################################################
485 510
486CFClient::read_cfg "$Crossfire::VARDIR/pclientrc"; 511CFClient::read_cfg "$Crossfire::VARDIR/pclientrc";
487 512
488my %DEF_CFG = ( 513my %DEF_CFG = (
514 sdl_mode => 0,
489 width => 640, 515 width => 640,
490 height => 480, 516 height => 480,
517 fullscreen => 0,
491 fast => 0, 518 fast => 0,
492 fow_enable => 1, 519 fow_enable => 1,
493 fow_intensity => 0.45, 520 fow_intensity => 0.45,
494 fow_smooth => 0, 521 fow_smooth => 0,
495 fullscreen => 0, 522 log_fontsize => 14,
496 sdl_mode => 0,
497 mapsize => 100, 523 mapsize => 100,
498 host => "crossfire.schmorp.de", 524 host => "crossfire.schmorp.de",
499 port => 13327, 525 port => 13327,
500 say_command => 'say', 526 say_command => 'say',
501); 527);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines