ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/bin/cfplus
(Generate patch)

Comparing deliantra/Deliantra-Client/bin/cfplus (file contents):
Revision 1.69 by root, Mon Jun 12 13:26:15 2006 UTC vs.
Revision 1.75 by root, Sun Jun 18 17:23:36 2006 UTC

155 $hbox->add (new CFClient::UI::Button 155 $hbox->add (new CFClient::UI::Button
156 text => "No", 156 text => "No",
157 on_activate => sub { 157 on_activate => sub {
158 $conn->send ("reply n"); 158 $conn->send ("reply n");
159 $dialog->destroy; 159 $dialog->destroy;
160 0
160 } 161 }
161 ); 162 );
162 $hbox->add (new CFClient::UI::Button 163 $hbox->add (new CFClient::UI::Button
163 text => "Yes", 164 text => "Yes",
164 on_activate => sub { 165 on_activate => sub {
165 $conn->send ("reply y"); 166 $conn->send ("reply y");
166 destroy_query_dialog $conn; 167 destroy_query_dialog $conn;
168 0
167 }, 169 },
168 ); 170 );
169 171
170 $dialog->focus_in; 172 $dialog->grab_focus;
171 173
172 } elsif ($flags & CS_QUERY_SINGLECHAR) { 174 } elsif ($flags & CS_QUERY_SINGLECHAR) {
173 $dialog->{tooltip} = "Press a key (click on the entry to make sure it has keyboard focus)"; 175 $dialog->{tooltip} = "Press a key (click on the entry to make sure it has keyboard focus)";
174 176
175 if ($prompt =~ /Now choose a character|Press any key for the next race/i) { 177 if ($prompt =~ /Now choose a character|Press any key for the next race/i) {
185 $table->add (0, 0, new CFClient::UI::Button 187 $table->add (0, 0, new CFClient::UI::Button
186 text => "Next Race", 188 text => "Next Race",
187 on_activate => sub { 189 on_activate => sub {
188 $conn->send ("reply n"); 190 $conn->send ("reply n");
189 destroy_query_dialog $conn; 191 destroy_query_dialog $conn;
192 0
190 }, 193 },
191 ); 194 );
192 $table->add (2, 0, new CFClient::UI::Button 195 $table->add (2, 0, new CFClient::UI::Button
193 text => "Accept", 196 text => "Accept",
194 on_activate => sub { 197 on_activate => sub {
195 $conn->send ("reply d"); 198 $conn->send ("reply d");
196 destroy_query_dialog $conn; 199 destroy_query_dialog $conn;
200 0
197 }, 201 },
198 ); 202 );
199 203
200 unshift @dialog, new CFClient::UI::Label 204 unshift @dialog, new CFClient::UI::Label
201 max_w => $::WIDTH * 0.4, 205 max_w => $::WIDTH * 0.4,
231 $table->add (0, 0, new CFClient::UI::Button 235 $table->add (0, 0, new CFClient::UI::Button
232 text => "Roll Again", 236 text => "Roll Again",
233 on_activate => sub { 237 on_activate => sub {
234 $conn->send ("reply y"); 238 $conn->send ("reply y");
235 destroy_query_dialog $conn; 239 destroy_query_dialog $conn;
240 0
236 }, 241 },
237 ); 242 );
238 243
239 # center: swap stats 244 # center: swap stats
240 my ($sw1, $sw2) = map +(new CFClient::UI::Combobox 245 my ($sw1, $sw2) = map +(new CFClient::UI::Combobox
254 text => "Swap Stats", 259 text => "Swap Stats",
255 on_activate => sub { 260 on_activate => sub {
256 $conn->{stat_change_with} = $sw2->{value}; 261 $conn->{stat_change_with} = $sw2->{value};
257 $conn->send ("reply $sw1->{value}"); 262 $conn->send ("reply $sw1->{value}");
258 destroy_query_dialog $conn; 263 destroy_query_dialog $conn;
264 0
259 }, 265 },
260 ); 266 );
261 $table->add (2, 1, new CFClient::UI::HBox children => [$sw1, $sw2]); 267 $table->add (2, 1, new CFClient::UI::HBox children => [$sw1, $sw2]);
262 268
263 # right: accept 269 # right: accept
265 text => "Accept", 271 text => "Accept",
266 on_activate => sub { 272 on_activate => sub {
267 $conn->send ("reply n"); 273 $conn->send ("reply n");
268 $STATS_WINDOW->hide; 274 $STATS_WINDOW->hide;
269 destroy_query_dialog $conn; 275 destroy_query_dialog $conn;
276 0
270 }, 277 },
271 ); 278 );
272 279
273 unshift @dialog, new CFClient::UI::Label 280 unshift @dialog, new CFClient::UI::Label
274 max_w => $::WIDTH * 0.4, 281 max_w => $::WIDTH * 0.4,
284 291
285 push @dialog, my $entry = new CFClient::UI::Entry 292 push @dialog, my $entry = new CFClient::UI::Entry
286 on_changed => sub { 293 on_changed => sub {
287 $conn->send ("reply $_[1]"); 294 $conn->send ("reply $_[1]");
288 destroy_query_dialog $conn; 295 destroy_query_dialog $conn;
296 0
289 }, 297 },
290 ; 298 ;
291 299
292 $entry->focus_in; 300 $entry->grab_focus;
293 301
294 } else { 302 } else {
295 $dialog->{tooltip} = "Enter the reply and press return (click on the entry to make sure it has keyboard focus)"; 303 $dialog->{tooltip} = "Enter the reply and press return (click on the entry to make sure it has keyboard focus)";
296 304
297 push @dialog, my $entry = new CFClient::UI::Entry 305 push @dialog, my $entry = new CFClient::UI::Entry
298 $flags & CS_QUERY_HIDEINPUT ? (hidden => "*") : (), 306 $flags & CS_QUERY_HIDEINPUT ? (hidden => "*") : (),
299 on_activate => sub { 307 on_activate => sub {
300 $conn->send ("reply $_[1]"); 308 $conn->send ("reply $_[1]");
301 destroy_query_dialog $conn; 309 destroy_query_dialog $conn;
310 0
302 }, 311 },
303 ; 312 ;
304 313
305 $entry->focus_in; 314 $entry->grab_focus;
306 } 315 }
307 316
308 $vbox->add (@dialog); 317 $vbox->add (@dialog);
309 $dialog->show; 318 $dialog->show;
310} 319}
315 $LOGIN_BUTTON->set_text ("Logout"); 324 $LOGIN_BUTTON->set_text ("Logout");
316 $SETUP_DIALOG->hide; 325 $SETUP_DIALOG->hide;
317 326
318 my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; 327 my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32;
319 328
320 my ($host, $port) = split /:/, $CFG->{host}; 329 my ($host, $port) = split /:/, $CFG->{profile}{default}{host};
321 330
322 $MAP = new CFClient::Map $mapsize, $mapsize; 331 $MAP = new CFClient::Map $mapsize, $mapsize;
323 332
324 $CONN = eval { 333 $CONN = eval {
325 new CFClient::Protocol 334 new CFClient::Protocol
326 host => $host, 335 host => $host,
327 port => $port || 13327, 336 port => $port || 13327,
328 user => $CFG->{user}, 337 user => $CFG->{profile}{default}{user},
329 pass => $CFG->{password}, 338 pass => $CFG->{profile}{default}{password},
330 mapw => $mapsize, 339 mapw => $mapsize,
331 maph => $mapsize, 340 maph => $mapsize,
332 341
333 map_widget => $MAPWIDGET, 342 map_widget => $MAPWIDGET,
334 logview => $LOGVIEW, 343 logview => $LOGVIEW,
399 408
400 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Fullscreen"); 409 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Fullscreen");
401 $table->add (1, $row++, new CFClient::UI::CheckBox 410 $table->add (1, $row++, new CFClient::UI::CheckBox
402 state => $CFG->{fullscreen}, 411 state => $CFG->{fullscreen},
403 tooltip => "Bring the client into fullscreen mode.", 412 tooltip => "Bring the client into fullscreen mode.",
404 on_changed => sub { 413 on_changed => sub { my ($self, $value) = @_; $CFG->{fullscreen} = $value; 0 }
405 my ($self, $value) = @_;
406 $CFG->{fullscreen} = $value;
407 }
408 ); 414 );
409 415
410 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Fast & Ugly"); 416 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Fast & Ugly");
411 $table->add (1, $row++, new CFClient::UI::CheckBox 417 $table->add (1, $row++, new CFClient::UI::CheckBox
412 state => $CFG->{fast}, 418 state => $CFG->{fast},
413 tooltip => "Lower the visual quality considerably to speed up rendering.", 419 tooltip => "Lower the visual quality considerably to speed up rendering.",
414 on_changed => sub { 420 on_changed => sub { my ($self, $value) = @_; $CFG->{fast} = $value; 0 }
415 my ($self, $value) = @_;
416 $CFG->{fast} = $value;
417 }
418 ); 421 );
419 422
420 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Map Scale"); 423 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Map Scale");
421 $table->add (1, $row++, new CFClient::UI::Slider 424 $table->add (1, $row++, new CFClient::UI::Slider
422 range => [(log $CFG->{map_scale}) / (log 2), -3, 1, 0, 1], 425 range => [(log $CFG->{map_scale}) / (log 2), -3, 1, 0, 1],
423 tooltip => "Enlarge or shrink the displayed map. Changes are instant.", 426 tooltip => "Enlarge or shrink the displayed map. Changes are instant.",
424 on_changed => sub { 427 on_changed => sub { my ($self, $value) = @_; $CFG->{map_scale} = 2 ** $value; 0 }
425 my ($self, $value) = @_;
426 $CFG->{map_scale} = 2 ** $value;
427 }
428 ); 428 );
429 429
430 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Fog of War"); 430 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Fog of War");
431 $table->add (1, $row++, new CFClient::UI::CheckBox 431 $table->add (1, $row++, new CFClient::UI::CheckBox
432 state => $CFG->{fow_enable}, 432 state => $CFG->{fow_enable},
433 tooltip => "<b>Fog-of-War</b> marks areas that cannot be seen by the player. Changes are instant.", 433 tooltip => "<b>Fog-of-War</b> marks areas that cannot be seen by the player. Changes are instant.",
434 on_changed => sub { 434 on_changed => sub { my ($self, $value) = @_; $CFG->{fow_enable} = $value; 0 }
435 my ($self, $value) = @_;
436 $CFG->{fow_enable} = $value;
437 }
438 ); 435 );
439 436
440 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "FoW Intensity"); 437 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "FoW Intensity");
441 $table->add (1, $row++, new CFClient::UI::Slider 438 $table->add (1, $row++, new CFClient::UI::Slider
442 range => [$CFG->{fow_intensity}, 0, 1, 0, 1 / 256], 439 range => [$CFG->{fow_intensity}, 0, 1, 0, 1 / 256],
443 tooltip => "<b>Fog of War Lightness.</b> The higher the intensity, the lighter the Fog-of-War color. Changes are instant.", 440 tooltip => "<b>Fog of War Lightness.</b> The higher the intensity, the lighter the Fog-of-War color. Changes are instant.",
444 on_changed => sub { 441 on_changed => sub { my ($self, $value) = @_; $CFG->{fow_intensity} = $value; 0 }
445 my ($self, $value) = @_;
446 $CFG->{fow_intensity} = $value;
447 }
448 ); 442 );
449 443
450 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "FoW Smooth"); 444 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "FoW Smooth");
451 $table->add (1, $row++, new CFClient::UI::CheckBox 445 $table->add (1, $row++, new CFClient::UI::CheckBox
452 state => $CFG->{fow_smooth}, 446 state => $CFG->{fow_smooth},
453 tooltip => "Smooth the Fog-of-War a bit to make it more realistic. Changes are instant.", 447 tooltip => "Smooth the Fog-of-War a bit to make it more realistic. Changes are instant.",
454 on_changed => sub { 448 on_changed => sub {
455 my ($self, $value) = @_; 449 my ($self, $value) = @_;
456 $CFG->{fow_smooth} = $value; 450 $CFG->{fow_smooth} = $value;
457 status "Fog of War smoothing requires OpenGL 1.2 or higher" if $CFClient::OpenGL::GL_VERSION < 1.2; 451 status "Fog of War smoothing requires OpenGL 1.2 or higher" if $CFClient::OpenGL::GL_VERSION < 1.2;
452 0
458 } 453 }
459 ); 454 );
460 455
461 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "GUI Fontsize"); 456 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "GUI Fontsize");
462 $table->add (1, $row++, new CFClient::UI::Slider 457 $table->add (1, $row++, new CFClient::UI::Slider
463 range => [$CFG->{gui_fontsize}, 0.5, 2, 0, 0.1], 458 range => [$CFG->{gui_fontsize}, 0.5, 2, 0, 0.1],
464 tooltip => "The base font size used by most GUI elements that do not have their own setting.", 459 tooltip => "The base font size used by most GUI elements that do not have their own setting.",
465 on_changed => sub { $CFG->{gui_fontsize} = $_[1] }, 460 on_changed => sub { $CFG->{gui_fontsize} = $_[1]; 0 },
466 ); 461 );
467 462
468 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Message Fontsize"); 463 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Message Fontsize");
469 $table->add (1, $row++, new CFClient::UI::Slider 464 $table->add (1, $row++, new CFClient::UI::Slider
470 range => [$CFG->{log_fontsize}, 0.5, 2, 0, 0.1], 465 range => [$CFG->{log_fontsize}, 0.5, 2, 0, 0.1],
471 tooltip => "The font size used by the <b>message/server log</b> window only. Changes are instant.", 466 tooltip => "The font size used by the <b>message/server log</b> window only. Changes are instant.",
472 on_changed => sub { $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = $_[1]) }, 467 on_changed => sub { $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = $_[1]); 0 },
473 ); 468 );
474 469
475 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Stats Fontsize"); 470 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Stats Fontsize");
476 471
477 $table->add (1, $row++, new CFClient::UI::Slider 472 $table->add (1, $row++, new CFClient::UI::Slider
478 range => [$CFG->{stat_fontsize}, 0.5, 2, 0, 0.1], 473 range => [$CFG->{stat_fontsize}, 0.5, 2, 0, 0.1],
479 tooltip => "The font size used by the <b>statistics window</b> only. Changes are instant.", 474 tooltip => "The font size used by the <b>statistics window</b> only. Changes are instant.",
480 on_changed => sub { 475 on_changed => sub {
481 $CFG->{stat_fontsize} = $_[1]; 476 $CFG->{stat_fontsize} = $_[1];
482 &set_stats_window_fontsize; 477 &set_stats_window_fontsize;
478 0
483 } 479 }
484 ); 480 );
485 481
486 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Gauge fontsize"); 482 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Gauge fontsize");
487 $table->add (1, $row++, new CFClient::UI::Slider 483 $table->add (1, $row++, new CFClient::UI::Slider
488 range => [$CFG->{gauge_fontsize}, 0.5, 2, 0, 0.1], 484 range => [$CFG->{gauge_fontsize}, 0.5, 2, 0, 0.1],
489 tooltip => "Adjusts the fontsize of the gauges at the bottom right. Changes are instant.", 485 tooltip => "Adjusts the fontsize of the gauges at the bottom right. Changes are instant.",
490 on_changed => sub { 486 on_changed => sub {
491 $CFG->{gauge_fontsize} = $_[1]; 487 $CFG->{gauge_fontsize} = $_[1];
492 &set_gauge_window_fontsize; 488 &set_gauge_window_fontsize;
489 0
493 } 490 }
494 ); 491 );
495 492
496 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Gauge size"); 493 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Gauge size");
497 $table->add (1, $row++, new CFClient::UI::Slider 494 $table->add (1, $row++, new CFClient::UI::Slider
498 range => [$CFG->{gauge_size}, 0.2, 0.8], 495 range => [$CFG->{gauge_size}, 0.2, 0.8],
499 tooltip => "Adjust the size of the stats gauges at the bottom right. Changes are instant.", 496 tooltip => "Adjust the size of the stats gauges at the bottom right. Changes are instant.",
500 on_changed => sub { 497 on_changed => sub {
501 $CFG->{gauge_size} = $_[1]; 498 $CFG->{gauge_size} = $_[1];
502 $GAUGES->{win}->set_size ($WIDTH, int $HEIGHT * $CFG->{gauge_size}); 499 $GAUGES->{win}->set_size ($WIDTH, int $HEIGHT * $CFG->{gauge_size});
500 0
503 } 501 }
504 ); 502 );
505 503
506 $table->add (1, $row++, new CFClient::UI::Button 504 $table->add (1, $row++, new CFClient::UI::Button
507 expand => 1, align => 0, text => "Apply", 505 expand => 1, align => 0, text => "Apply",
508 tooltip => "Apply the video settings", 506 tooltip => "Apply the video settings",
509 on_activate => sub { 507 on_activate => sub {
510 video_shutdown (); 508 video_shutdown ();
511 video_init (); 509 video_init ();
510 0
512 } 511 }
513 ); 512 );
514 513
515 $vbox 514 $vbox
516} 515}
524 523
525 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Audio Enable"); 524 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Audio Enable");
526 $table->add (1, $row++, new CFClient::UI::CheckBox 525 $table->add (1, $row++, new CFClient::UI::CheckBox
527 state => $CFG->{audio_enable}, 526 state => $CFG->{audio_enable},
528 tooltip => "<b>Master Audio Enable.</b> If enabled, sound effects and music will be played. If disabled, no audio will be used and the soundcard will not be opened.", 527 tooltip => "<b>Master Audio Enable.</b> If enabled, sound effects and music will be played. If disabled, no audio will be used and the soundcard will not be opened.",
529 on_changed => sub { 528 on_changed => sub { $CFG->{audio_enable} = $_[1]; 0 }
530 $CFG->{audio_enable} = $_[1];
531 }
532 ); 529 );
533# $table->add (0, 9, new CFClient::UI::Label valign => 0, align => 1, text => "Effects Volume"); 530# $table->add (0, 9, new CFClient::UI::Label valign => 0, align => 1, text => "Effects Volume");
534# $table->add (1, 8, new CFClient::UI::Slider range => [$CFG->{effects_volume}, 0, 128, 1], on_changed => sub { 531# $table->add (1, 8, new CFClient::UI::Slider range => [$CFG->{effects_volume}, 0, 128, 1], on_changed => sub {
535# $CFG->{effects_volume} = $_[1]; 532# $CFG->{effects_volume} = $_[1];
536# }); 533# });
537 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Background Music"); 534 $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Background Music");
538 $table->add (1, $row++, my $hbox = new CFClient::UI::HBox); 535 $table->add (1, $row++, my $hbox = new CFClient::UI::HBox);
539 $hbox->add (new CFClient::UI::CheckBox 536 $hbox->add (new CFClient::UI::CheckBox
540 expand => 1, state => $CFG->{bgm_enable}, 537 expand => 1, state => $CFG->{bgm_enable},
541 tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played.", 538 tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played.",
542 on_changed => sub { 539 on_changed => sub { $CFG->{bgm_enable} = $_[1]; 0 }
543 $CFG->{bgm_enable} = $_[1];
544 }
545 ); 540 );
546 $hbox->add (new CFClient::UI::Slider 541 $hbox->add (new CFClient::UI::Slider
547 expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0, 1/128], 542 expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0, 1/128],
548 tooltip => "The volume of the background music. Changes are instant.", 543 tooltip => "The volume of the background music. Changes are instant.",
549 on_changed => sub { 544 on_changed => sub { $CFG->{bgm_volume} = $_[1]; CFClient::MixMusic::volume $_[1] * 128; 0 }
550 $CFG->{bgm_volume} = $_[1];
551 CFClient::MixMusic::volume $_[1] * 128;
552 }
553 ); 545 );
554 546
555 $table->add (1, $row++, new CFClient::UI::Button 547 $table->add (1, $row++, new CFClient::UI::Button
556 expand => 1, align => 0, text => "Apply", 548 expand => 1, align => 0, text => "Apply",
557 tooltip => "Apply the audio settings", 549 tooltip => "Apply the audio settings",
558 on_activate => sub { 550 on_activate => sub {
559 audio_shutdown (); 551 audio_shutdown ();
560 audio_init (); 552 audio_init ();
553 0
561 } 554 }
562 ); 555 );
563 556
564 $vbox 557 $vbox
565} 558}
631 624
632sub debug_setup { 625sub debug_setup {
633 my $table = new CFClient::UI::Table; 626 my $table = new CFClient::UI::Table;
634 627
635 $table->add (0, 0, new CFClient::UI::Label text => "Widget Borders"); 628 $table->add (0, 0, new CFClient::UI::Label text => "Widget Borders");
636 $table->add (1, 0, new CFClient::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 1 }); 629 $table->add (1, 0, new CFClient::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 1; 0 });
637 $table->add (0, 1, new CFClient::UI::Label text => "Tooltip Widget Info"); 630 $table->add (0, 1, new CFClient::UI::Label text => "Tooltip Widget Info");
638 $table->add (1, 1, new CFClient::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 2 }); 631 $table->add (1, 1, new CFClient::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 2; 0 });
639 $table->add (0, 2, new CFClient::UI::Label text => "Show FPS"); 632 $table->add (0, 2, new CFClient::UI::Label text => "Show FPS");
640 $table->add (1, 2, new CFClient::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 4 }); 633 $table->add (1, 2, new CFClient::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 4; 0 });
641 $table->add (0, 3, new CFClient::UI::Label text => "Suppress Tooltips"); 634 $table->add (0, 3, new CFClient::UI::Label text => "Suppress Tooltips");
642 $table->add (1, 3, new CFClient::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 8 }); 635 $table->add (1, 3, new CFClient::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 8; 0 });
643 636
644 my @default_smooth = (0.05, 0.13, 0.05, 0.13, 0.30, 0.13, 0.05, 0.13, 0.05); 637 my @default_smooth = (0.05, 0.13, 0.05, 0.13, 0.30, 0.13, 0.05, 0.13, 0.05);
645 638
646 for my $x (0..2) { 639 for my $x (0..2) {
647 for my $y (0 .. 2) { 640 for my $y (0 .. 2) {
660sub stats_window { 653sub stats_window {
661 my $tgw = new CFClient::UI::FancyFrame 654 my $tgw = new CFClient::UI::FancyFrame
662 y => $HEIGHT * (2/8), 655 y => $HEIGHT * (2/8),
663 x => "max", 656 x => "max",
664 title => "Stats", 657 title => "Stats",
665 name => "stats_window"; 658 name => "stats_window",
659 has_close_button => 1;
666 660
667 $tgw->add (new CFClient::UI::Window child => my $vb = new CFClient::UI::VBox); 661 $tgw->add (new CFClient::UI::Window child => my $vb = new CFClient::UI::VBox);
668 $vb->add ($STATWIDS->{title} = new CFClient::UI::Label valign => 0, align => -1, text => "Title:", expand => 1, 662 $vb->add ($STATWIDS->{title} = new CFClient::UI::Label valign => 0, align => -1, text => "Title:", expand => 1,
669 can_hover => 1, can_events => 1, 663 can_hover => 1, can_events => 1,
670 tooltip => "Your name and title. You can change your title by using the <b>title</b> command, if supported by the server."); 664 tooltip => "Your name and title. You can change your title by using the <b>title</b> command, if supported by the server.");
816 $STATWIDS->{st_spd} ->set_text (sprintf "%.1f", $stats->{+CS_STAT_SPEED}); 810 $STATWIDS->{st_spd} ->set_text (sprintf "%.1f", $stats->{+CS_STAT_SPEED});
817 $STATWIDS->{st_wspd}->set_text (sprintf "%.1f", $stats->{+CS_STAT_WEAP_SP}); 811 $STATWIDS->{st_wspd}->set_text (sprintf "%.1f", $stats->{+CS_STAT_WEAP_SP});
818 812
819 $STATWIDS->{m_weight}->set_text (sprintf "Max weight: %.1fkg", $stats->{+CS_STAT_WEIGHT_LIM} / 1000); 813 $STATWIDS->{m_weight}->set_text (sprintf "Max weight: %.1fkg", $stats->{+CS_STAT_WEIGHT_LIM} / 1000);
820 814
821 # TODO: replace by CS_STAT_RES_xxx constants
822 my %tbl = ( 815 my %tbl = (
823 phys => 100, 816 phys => CS_STAT_RES_PHYS,
824 magic => 101, 817 magic => CS_STAT_RES_MAG,
825 fire => 102, 818 fire => CS_STAT_RES_FIRE,
826 elec => 103, 819 elec => CS_STAT_RES_ELEC,
827 cold => 104, 820 cold => CS_STAT_RES_COLD,
828 conf => 105, 821 conf => CS_STAT_RES_CONF,
829 acid => 106, 822 acid => CS_STAT_RES_ACID,
830 drain => 107, 823 drain => CS_STAT_RES_DRAIN,
831 ghit => 108, 824 ghit => CS_STAT_RES_GHOSTHIT,
832 pois => 109, 825 pois => CS_STAT_RES_POISON,
833 slow => 110, 826 slow => CS_STAT_RES_SLOW,
834 para => 111, 827 para => CS_STAT_RES_PARA,
835 tund => 112, 828 tund => CS_STAT_TURN_UNDEAD,
836 fear => 113, 829 fear => CS_STAT_RES_FEAR,
837 depl => 113, 830 depl => CS_STAT_RES_DEPLETE,
838 deat => 115, 831 deat => CS_STAT_RES_DEATH,
839 holyw => 116, 832 holyw => CS_STAT_RES_HOLYWORD,
840 blind => 117, 833 blind => CS_STAT_RES_BLIND,
841 ); 834 );
842 835
843 $STATWIDS->{"res_$_"}->set_text (sprintf "%d%", $stats->{$tbl{$_}}) 836 $STATWIDS->{"res_$_"}->set_text (sprintf "%d%", $stats->{$tbl{$_}})
844 for keys %tbl; 837 for keys %tbl;
845} 838}
919 $table->add (scalar @$m, $y, new CFClient::UI::VBox children => [ 912 $table->add (scalar @$m, $y, new CFClient::UI::VBox children => [
920 (new CFClient::UI::Button 913 (new CFClient::UI::Button
921 text => "Use", 914 text => "Use",
922 tooltip => "Put this server into the <b>Host:Port</b> field", 915 tooltip => "Put this server into the <b>Host:Port</b> field",
923 on_activate => sub { 916 on_activate => sub {
924 $HOST_ENTRY->set_text ($CFG->{host} = $host); 917 $HOST_ENTRY->set_text ($CFG->{profile}{default}{host} = $host);
925 $METASERVER->hide; 918 $METASERVER->hide;
919 0
926 }, 920 },
927 ), 921 ),
928 (new CFClient::UI::Empty expand => 1), 922 (new CFClient::UI::Empty expand => 1),
929 ]); 923 ]);
930 924
951 z => 3, 945 z => 3,
952 force_h => $::HEIGHT * 0.4, 946 force_h => $::HEIGHT * 0.4,
953 child => (my $vbox = new CFClient::UI::VBox), 947 child => (my $vbox = new CFClient::UI::VBox),
954 on_visibility_change => sub { 948 on_visibility_change => sub {
955 update_metaserver if $_[1]; 949 update_metaserver if $_[1];
950 0
956 }, 951 },
957 ; 952 ;
958 953
959 $dialog->{table} = new CFClient::UI::Table; 954 $dialog->{table} = new CFClient::UI::Table;
960 955
973 $table->add (1, 2, my $vbox = new CFClient::UI::VBox); 968 $table->add (1, 2, my $vbox = new CFClient::UI::VBox);
974 969
975 $vbox->add ( 970 $vbox->add (
976 $HOST_ENTRY = new CFClient::UI::Entry 971 $HOST_ENTRY = new CFClient::UI::Entry
977 expand => 1, 972 expand => 1,
978 text => $CFG->{host}, 973 text => $CFG->{profile}{default}{host},
979 tooltip => "The hostname or ip address of the Crossfire(+) server to connect to", 974 tooltip => "The hostname or ip address of the Crossfire(+) server to connect to",
980 on_changed => sub { 975 on_changed => sub {
981 my ($self, $value) = @_; 976 my ($self, $value) = @_;
982 $CFG->{host} = $value; 977 $CFG->{profile}{default}{host} = $value;
978 0
983 } 979 }
984 ); 980 );
985 981
986 $METASERVER = metaserver_dialog; 982 $METASERVER = metaserver_dialog;
987 983
988 $vbox->add (new CFClient::UI::Button 984 $vbox->add (new CFClient::UI::Button
989 expand => 1, 985 expand => 1,
990 text => "Server List", 986 text => "Server List",
991 other => $METASERVER, 987 other => $METASERVER,
992 tooltip => "Show a list of available crossfire servers", 988 tooltip => "Show a list of available crossfire servers",
993 on_activate => sub { $METASERVER->toggle_visibility }, 989 on_activate => sub { $METASERVER->toggle_visibility; 0 },
994 on_visibility_change => sub { $METASERVER->hide unless $_[1] }, 990 on_visibility_change => sub { $METASERVER->hide unless $_[1]; 0 },
995 ); 991 );
996 } 992 }
997 993
998 $table->add (0, 4, new CFClient::UI::Label valign => 0, align => 1, text => "Username"); 994 $table->add (0, 4, new CFClient::UI::Label valign => 0, align => 1, text => "Username");
999 $table->add (1, 4, new CFClient::UI::Entry 995 $table->add (1, 4, new CFClient::UI::Entry
1000 text => $CFG->{user}, 996 text => $CFG->{profile}{default}{user},
1001 tooltip => "The name of your character on the server", 997 tooltip => "The name of your character on the server",
1002 on_changed => sub { 998 on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{user} = $value }
1003 my ($self, $value) = @_;
1004 $CFG->{user} = $value;
1005 }
1006 ); 999 );
1007 1000
1008 $table->add (0, 5, new CFClient::UI::Label valign => 0, align => 1, text => "Password"); 1001 $table->add (0, 5, new CFClient::UI::Label valign => 0, align => 1, text => "Password");
1009 $table->add (1, 5, new CFClient::UI::Entry 1002 $table->add (1, 5, new CFClient::UI::Entry
1010 text => $CFG->{password}, 1003 text => $CFG->{profile}{default}{password},
1011 hidden => 1, 1004 hidden => 1,
1012 tooltip => "The password for your character", 1005 tooltip => "The password for your character",
1013 on_changed => sub { 1006 on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{password} = $value }
1014 my ($self, $value) = @_;
1015 $CFG->{password} = $value;
1016 }
1017 ); 1007 );
1018 1008
1019 $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size"); 1009 $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size");
1020 $table->add (1, 7, new CFClient::UI::Slider 1010 $table->add (1, 7, new CFClient::UI::Slider
1021 force_w => 100, 1011 force_w => 100,
1022 range => [$CFG->{mapsize}, 10, 100, 0, 1], 1012 range => [$CFG->{mapsize}, 10, 100, 0, 1],
1023 tooltip => "This is the size of the portion of the map update the server sends you. " 1013 tooltip => "This is the size of the portion of the map update the server sends you. "
1024 . "If you set this to a high value you will be able to see further, " 1014 . "If you set this to a high value you will be able to see further, "
1025 . "but you also increase bandwidth requirements and latency. " 1015 . "but you also increase bandwidth requirements and latency. "
1026 . "This option is only used once at log-in.", 1016 . "This option is only used once at log-in.",
1027 on_changed => sub { 1017 on_changed => sub { my ($self, $value) = @_; $CFG->{mapsize} = $self->{range}[0] = $value = int $value; 0 },
1028 my ($self, $value) = @_;
1029
1030 $CFG->{mapsize} = $self->{range}[0] = $value = int $value;
1031 },
1032 ); 1018 );
1033 1019
1034 $table->add (0, 8, new CFClient::UI::Label valign => 0, align => 1, text => "Face Prefetch"); 1020 $table->add (0, 8, new CFClient::UI::Label valign => 0, align => 1, text => "Face Prefetch");
1035 $table->add (1, 8, new CFClient::UI::CheckBox 1021 $table->add (1, 8, new CFClient::UI::CheckBox
1036 state => $CFG->{face_prefetch}, 1022 state => $CFG->{face_prefetch},
1039 . "This might increase or create lag, but increases the chances " 1025 . "This might increase or create lag, but increases the chances "
1040 . "of faces being ready for display when you encounter them. " 1026 . "of faces being ready for display when you encounter them. "
1041 . "It also uses up server bandwidth on every connect, " 1027 . "It also uses up server bandwidth on every connect, "
1042 . "so only set it if you really need to prefetch images. " 1028 . "so only set it if you really need to prefetch images. "
1043 . "This option can be set and unset any time.", 1029 . "This option can be set and unset any time.",
1044 on_changed => sub { $CFG->{face_prefetch} = $_[1] }, 1030 on_changed => sub { $CFG->{face_prefetch} = $_[1]; 0 },
1045 ); 1031 );
1046 1032
1047 $table->add (0, 9, new CFClient::UI::Label valign => 0, align => 1, text => "Output-Count"); 1033 $table->add (0, 9, new CFClient::UI::Label valign => 0, align => 1, text => "Output-Count");
1048 $table->add (1, 9, new CFClient::UI::Entry 1034 $table->add (1, 9, new CFClient::UI::Entry
1049 text => $CFG->{output_count}, 1035 text => $CFG->{output_count},
1050 tooltip => "Should be set to 1 unless you know what you are doing. This option is only used once at log-in.", 1036 tooltip => "Should be set to 1 unless you know what you are doing. This option is only used once at log-in.",
1051 on_changed => sub { $CFG->{output_count} = $_[1] }, 1037 on_changed => sub { $CFG->{output_count} = $_[1]; 0 },
1052 ); 1038 );
1053 1039
1054 $table->add (0, 10, new CFClient::UI::Label valign => 0, align => 1, text => "Output-Sync"); 1040 $table->add (0, 10, new CFClient::UI::Label valign => 0, align => 1, text => "Output-Sync");
1055 $table->add (1, 10, new CFClient::UI::Entry 1041 $table->add (1, 10, new CFClient::UI::Entry
1056 text => $CFG->{output_sync}, 1042 text => $CFG->{output_sync},
1057 tooltip => "Should be set to 1 unless you know what you are doing. This option is only used once at log-in.", 1043 tooltip => "Should be set to 1 unless you know what you are doing. This option is only used once at log-in.",
1058 on_changed => sub { $CFG->{output_sync} = $_[1] }, 1044 on_changed => sub { $CFG->{output_sync} = $_[1]; 0 },
1059 ); 1045 );
1060 1046
1061 $table->add (1, 11, $LOGIN_BUTTON = new CFClient::UI::Button 1047 $table->add (1, 11, $LOGIN_BUTTON = new CFClient::UI::Button
1062 expand => 1, 1048 expand => 1,
1063 align => 0, 1049 align => 0,
1064 text => "Login", 1050 text => "Login",
1065 on_activate => sub { 1051 on_activate => sub {
1066 $CONN ? stop_game 1052 $CONN ? stop_game
1067 : start_game; 1053 : start_game;
1054 0
1068 }, 1055 },
1069 ); 1056 );
1070 1057
1071 $table->add (0, 12, new CFClient::UI::Label valign => 0, align => 1, text => "Chat Command"); 1058 $table->add (0, 12, new CFClient::UI::Label valign => 0, align => 1, text => "Chat Command");
1072 $table->add (1, 12, my $saycmd = new CFClient::UI::Entry 1059 $table->add (1, 12, my $saycmd = new CFClient::UI::Entry
1075 . "Usually you want to enter something like 'say' or 'shout' or 'gsay' here. " 1062 . "Usually you want to enter something like 'say' or 'shout' or 'gsay' here. "
1076 . "But you could also set it to <b>tell <i>playername</i></b> to only chat with that user.", 1063 . "But you could also set it to <b>tell <i>playername</i></b> to only chat with that user.",
1077 on_changed => sub { 1064 on_changed => sub {
1078 my ($self, $value) = @_; 1065 my ($self, $value) = @_;
1079 $CFG->{say_command} = $value; 1066 $CFG->{say_command} = $value;
1067 0
1080 } 1068 }
1081 ); 1069 );
1082 1070
1083 $vbox->add (new CFClient::UI::Label 1071 $vbox->add (new CFClient::UI::Label
1084 text => "Server Info", 1072 text => "Server Info",
1100 bg => [0, 0, 0, 0.75], 1088 bg => [0, 0, 0, 0.75],
1101 x => "max", 1089 x => "max",
1102 y => 0, 1090 y => 0,
1103 force_w => $::WIDTH * 0.4, 1091 force_w => $::WIDTH * 0.4,
1104 force_h => $::HEIGHT * 0.5, 1092 force_h => $::HEIGHT * 0.5,
1105 child => (my $vbox = new CFClient::UI::VBox); 1093 child => (my $vbox = new CFClient::UI::VBox),
1094 has_close_button => 1;
1106 1095
1107 $vbox->add ($LOGVIEW); 1096 $vbox->add ($LOGVIEW);
1108 1097
1109 $vbox->add (my $input = new CFClient::UI::Entry 1098 $vbox->add (my $input = new CFClient::UI::Entry
1110 tooltip => "<b>Chat Box</b>. If you enter a text and press return/enter here, the current <i>communication command</i> " 1099 tooltip => "<b>Chat Box</b>. If you enter a text and press return/enter here, the current <i>communication command</i> "
1118 1107
1119 if ($prev_focus == $MAPWIDGET && $input->{auto_activated}) { 1108 if ($prev_focus == $MAPWIDGET && $input->{auto_activated}) {
1120 $input->{refocus_map} = 1; 1109 $input->{refocus_map} = 1;
1121 } 1110 }
1122 delete $input->{auto_activated}; 1111 delete $input->{auto_activated};
1112
1113 0
1123 }, 1114 },
1124 on_activate => sub { 1115 on_activate => sub {
1125 my ($input, $text) = @_; 1116 my ($input, $text) = @_;
1126 $input->set_text (''); 1117 $input->set_text ('');
1127 1118
1133 } 1124 }
1134 if ($input->{refocus_map}) { 1125 if ($input->{refocus_map}) {
1135 delete $input->{refocus_map}; 1126 delete $input->{refocus_map};
1136 $MAPWIDGET->focus_in 1127 $MAPWIDGET->focus_in
1137 } 1128 }
1129
1130 0
1138 }, 1131 },
1139 on_escape => sub { 1132 on_escape => sub {
1140 $MAPWIDGET->focus_in 1133 $MAPWIDGET->grab_focus;
1134
1135 0
1141 }, 1136 },
1142 ); 1137 );
1143 1138
1144 $CONSOLE = { 1139 $CONSOLE = {
1145 window => $window, 1140 window => $window,
1167 ); 1162 );
1168 $vb->add (my $hb = new CFClient::UI::HBox expand => 1); 1163 $vb->add (my $hb = new CFClient::UI::HBox expand => 1);
1169 $hb->add (new CFClient::UI::Button 1164 $hb->add (new CFClient::UI::Button
1170 text => "Ok", 1165 text => "Ok",
1171 expand => 1, 1166 expand => 1,
1172 on_activate => sub { $QUIT_DIALOG->hide }, 1167 on_activate => sub { $QUIT_DIALOG->hide; 0 },
1173 ); 1168 );
1174 $hb->add (new CFClient::UI::Button 1169 $hb->add (new CFClient::UI::Button
1175 text => "Quit anyway", 1170 text => "Quit anyway",
1176 expand => 1, 1171 expand => 1,
1177 on_activate => sub { exit }, 1172 on_activate => sub { exit },
1244 $::CFG->{pickup} &= ~$mask; 1239 $::CFG->{pickup} &= ~$mask;
1245 } 1240 }
1246 1241
1247 $::CONN->send_command ("pickup $::CFG->{pickup}") 1242 $::CONN->send_command ("pickup $::CFG->{pickup}")
1248 if defined $::CONN; 1243 if defined $::CONN;
1244
1245 0
1249 }); 1246 });
1250 } 1247 }
1251 } 1248 }
1252 1249
1253 $table->add (2, 18, new CFClient::UI::ValSlider 1250 $table->add (2, 18, new CFClient::UI::ValSlider
1264 $table->add (3, 18, new CFClient::UI::Button 1261 $table->add (3, 18, new CFClient::UI::Button
1265 text => "set", 1262 text => "set",
1266 on_activate => sub { 1263 on_activate => sub {
1267 $::CONN->send_command ("pickup $::CFG->{pickup}") 1264 $::CONN->send_command ("pickup $::CFG->{pickup}")
1268 if defined $::CONN; 1265 if defined $::CONN;
1269 1; 1266 0
1270 }); 1267 });
1271 1268
1272 $table 1269 $table
1273} 1270}
1274 1271
1277 x => "center", 1274 x => "center",
1278 y => "center", 1275 y => "center",
1279 force_w => $WIDTH * 9/10, 1276 force_w => $WIDTH * 9/10,
1280 force_h => $HEIGHT * 9/10, 1277 force_h => $HEIGHT * 9/10,
1281 title => "Inventory", 1278 title => "Inventory",
1279 has_close_button => 1,
1282 ; 1280 ;
1283 1281
1284 $invwin->add (my $hb = new CFClient::UI::HBox homogeneous => 1); 1282 $invwin->add (my $hb = new CFClient::UI::HBox homogeneous => 1);
1285 1283
1286 $hb->add (my $vb1 = new CFClient::UI::VBox); 1284 $hb->add (my $vb1 = new CFClient::UI::VBox);
1308 1306
1309 my $refresh; 1307 my $refresh;
1310 $refresh = sub { 1308 $refresh = sub {
1311 $binding_list->clear (); 1309 $binding_list->clear ();
1312 1310
1313 for my $mod (keys %{$::CFG->{bindings}}) { 1311 for my $mod (keys %{$::CFG->{profile}{default}{bindings}}) {
1314 for my $sym (keys %{$::CFG->{bindings}->{$mod}}) { 1312 for my $sym (keys %{$::CFG->{profile}{default}{bindings}{$mod}}) {
1315 my $cmds = $::CFG->{bindings}->{$mod}->{$sym}; 1313 my $cmds = $::CFG->{profile}{default}{bindings}{$mod}{$sym};
1316 next unless ref $cmds eq 'ARRAY' and @$cmds > 0; 1314 next unless ref $cmds eq 'ARRAY' and @$cmds > 0;
1317 1315
1318 my $lbl = join "; ", @$cmds; 1316 my $lbl = join "; ", @$cmds;
1319 my $nam = CFClient::Binder::keycombo_to_name ($mod, $sym); 1317 my $nam = CFClient::Binder::keycombo_to_name ($mod, $sym);
1320 $binding_list->add (my $hb = new CFClient::UI::HBox); 1318 $binding_list->add (my $hb = new CFClient::UI::HBox);
1321 $hb->add (new CFClient::UI::Button 1319 $hb->add (new CFClient::UI::Button
1322 text => "delete", 1320 text => "delete",
1323 tooltip => "Deletes the binding", 1321 tooltip => "Deletes the binding",
1324 on_activate => sub { 1322 on_activate => sub {
1325 $binding_list->remove ($hb); 1323 $binding_list->remove ($hb);
1326 delete $::CFG->{bindings}->{$mod}->{$sym}; 1324 delete $::CFG->{profile}{default}{bindings}{$mod}{$sym};
1325 0
1327 }); 1326 });
1328 1327
1329 $hb->add (new CFClient::UI::Button 1328 $hb->add (new CFClient::UI::Button
1330 text => "edit", 1329 text => "edit",
1331 tooltip => "Edits the binding", 1330 tooltip => "Edits the binding",
1332 on_activate => sub { 1331 on_activate => sub {
1333 $::BIND_EDITOR->set_binding ( 1332 $::BIND_EDITOR->set_binding (
1334 $mod, $sym, $::CFG->{bindings}->{$mod}->{$sym}, 1333 $mod, $sym, $::CFG->{profile}{default}{bindings}{$mod}{$sym},
1335 sub { 1334 sub {
1336 my ($nmod, $nsym, $ncmds) = @_; 1335 my ($nmod, $nsym, $ncmds) = @_;
1337 delete $::CFG->{bindings}->{$mod}->{$sym}; 1336 delete $::CFG->{profile}{default}{bindings}{$mod}{$sym};
1338 $::CFG->{bindings}->{$nmod}->{$nsym} = $ncmds; 1337 $::CFG->{profile}{default}{bindings}{$nmod}{$nsym} = $ncmds;
1339 $refresh->(); 1338 $refresh->();
1340 $SETUP_NOTEBOOK->set_current_page ($SETUP_KEYBOARD); 1339 $SETUP_NOTEBOOK->set_current_page ($SETUP_KEYBOARD);
1341 $SETUP_DIALOG->show; 1340 $SETUP_DIALOG->show;
1342 }, 1341 },
1343 sub { 1342 sub {
1344 $SETUP_NOTEBOOK->set_current_page ($SETUP_KEYBOARD); 1343 $SETUP_NOTEBOOK->set_current_page ($SETUP_KEYBOARD);
1345 $SETUP_DIALOG->show; 1344 $SETUP_DIALOG->show;
1346 }); 1345 });
1347 $::BIND_EDITOR->show; 1346 $::BIND_EDITOR->show;
1348 $SETUP_DIALOG->hide; 1347 $SETUP_DIALOG->hide;
1348 0
1349 }); 1349 });
1350 1350
1351 $hb->add (new CFClient::UI::Label text => "(Key: $nam)"); 1351 $hb->add (new CFClient::UI::Label text => "(Key: $nam)");
1352 $hb->add (new CFClient::UI::Label text => $lbl, expand => 1); 1352 $hb->add (new CFClient::UI::Label text => $lbl, expand => 1);
1353 } 1353 }
1354 } 1354 }
1355 }; 1355 };
1356 1356
1357 my $vb = new CFClient::UI::VBox; 1357 my $vb = new CFClient::UI::VBox;
1358 $vb->add (my $hb = new CFClient::UI::HBox);
1359 $hb->add (new CFClient::UI::Label text => "only shift-up stops fire");
1360 $hb->add (new CFClient::UI::CheckBox
1361 expand => 1,
1362 state => $CFG->{shift_fire_stop},
1363 tooltip => "If this checkbox is enabled you will stop fire only if you stop pressing shift",
1364 on_changed => sub {
1365 my ($cbox, $value) = @_;
1366 $CFG->{shift_fire_stop} = $value;
1367 0
1368 });
1369
1358 $vb->add ($binding_list); 1370 $vb->add ($binding_list);
1359 $vb->add (my $hb = new CFClient::UI::HBox); 1371 $vb->add (my $hb = new CFClient::UI::HBox);
1360 1372
1361 $hb->add (new CFClient::UI::Button 1373 $hb->add (new CFClient::UI::Button
1362 text => "record new", 1374 text => "record new",
1364 tooltip => "This button opens the binding editor with an empty binding.", 1376 tooltip => "This button opens the binding editor with an empty binding.",
1365 on_activate => sub { 1377 on_activate => sub {
1366 $::BIND_EDITOR->set_binding (undef, undef, [], 1378 $::BIND_EDITOR->set_binding (undef, undef, [],
1367 sub { 1379 sub {
1368 my ($mod, $sym, $cmds) = @_; 1380 my ($mod, $sym, $cmds) = @_;
1369 $::CFG->{bindings}->{$mod}->{$sym} = $cmds; 1381 $::CFG->{profile}{default}{bindings}{$mod}{$sym} = $cmds;
1370 $refresh->(); 1382 $refresh->();
1371 $SETUP_NOTEBOOK->set_current_page ($SETUP_KEYBOARD); 1383 $SETUP_NOTEBOOK->set_current_page ($SETUP_KEYBOARD);
1372 $SETUP_DIALOG->show; 1384 $SETUP_DIALOG->show;
1373 }, 1385 },
1374 sub { 1386 sub {
1376 $SETUP_DIALOG->show; 1388 $SETUP_DIALOG->show;
1377 }, 1389 },
1378 ); 1390 );
1379 $SETUP_DIALOG->hide; 1391 $SETUP_DIALOG->hide;
1380 $::BIND_EDITOR->show; 1392 $::BIND_EDITOR->show;
1393 0
1381 }, 1394 },
1382 ); 1395 );
1383 1396
1384 $hb->add (new CFClient::UI::Button 1397 $hb->add (new CFClient::UI::Button
1385 text => "close", 1398 text => "close",
1386 tooltip => "Closes the binding window", 1399 tooltip => "Closes the binding window",
1387 expand => 1, 1400 expand => 1,
1388 on_activate => sub { 1401 on_activate => sub {
1389 $SETUP_DIALOG->hide; 1402 $SETUP_DIALOG->hide;
1403 0
1390 } 1404 }
1391 ); 1405 );
1392 1406
1393 $refresh->(); 1407 $refresh->();
1394 1408
1432 1446
1433 $viewer->add_paragraph ([1, 1, 1, 1], $_->[1], $_->[0]) 1447 $viewer->add_paragraph ([1, 1, 1, 1], $_->[1], $_->[0])
1434 for @$pom; 1448 for @$pom;
1435 1449
1436 $viewer->set_offset (0); 1450 $viewer->set_offset (0);
1451 0
1437 }, 1452 },
1438 on_visibility_change => sub { 1453 on_visibility_change => sub {
1439 my ($self, $visible) = @_; 1454 my ($self, $visible) = @_;
1440 return unless $visible; 1455 return unless $visible;
1441 return if $self->{value}; 1456 return if $self->{value};
1442 $self->set_value ("intro"); 1457 $self->set_value ("intro");
1458 0
1443 }, 1459 },
1444 ); 1460 );
1445 1461
1446 $win 1462 $win
1447} 1463}
1516 $MAPWIDGET->connect (activate_console => sub { 1532 $MAPWIDGET->connect (activate_console => sub {
1517 my ($mapwidget, $preset) = @_; 1533 my ($mapwidget, $preset) = @_;
1518 1534
1519 if ($CONSOLE) { 1535 if ($CONSOLE) {
1520 $CONSOLE->{input}->{auto_activated} = 1; 1536 $CONSOLE->{input}->{auto_activated} = 1;
1521 $CONSOLE->{input}->focus_in; 1537 $CONSOLE->{input}->grab_focus;
1522 1538
1523 if ($preset && $CONSOLE->{input}->get_text eq '') { 1539 if ($preset && $CONSOLE->{input}->get_text eq '') {
1524 $CONSOLE->{input}->set_text ($preset); 1540 $CONSOLE->{input}->set_text ($preset);
1525 } 1541 }
1526 } 1542 }
1527 }); 1543 });
1528 $MAPWIDGET->show; 1544 $MAPWIDGET->show;
1529 $MAPWIDGET->focus_in; 1545 $MAPWIDGET->grab_focus;
1530 1546
1531 $LOGVIEW = new CFClient::UI::TextScroller 1547 $LOGVIEW = new CFClient::UI::TextScroller
1532 expand => 1, 1548 expand => 1,
1533 font => $FONT_FIXED, 1549 font => $FONT_FIXED,
1534 fontsize => $::CFG->{log_fontsize}, 1550 fontsize => $::CFG->{log_fontsize},
1544 x => 'center', 1560 x => 'center',
1545 y => 'center', 1561 y => 'center',
1546 z => 2, 1562 z => 2,
1547 force_w => $::WIDTH * 0.6, 1563 force_w => $::WIDTH * 0.6,
1548 force_h => $::HEIGHT * 0.6, 1564 force_h => $::HEIGHT * 0.6,
1565 has_close_button => 1,
1549 ; 1566 ;
1550 1567
1551 $SETUP_DIALOG->add ($SETUP_NOTEBOOK = new CFClient::UI::Notebook expand => 1, debug => 1, 1568 $SETUP_DIALOG->add ($SETUP_NOTEBOOK = new CFClient::UI::Notebook expand => 1, debug => 1,
1552 filter => new CFClient::UI::ScrolledWindow expand => 1, scroll_y => 1); 1569 filter => new CFClient::UI::ScrolledWindow expand => 1, scroll_y => 1);
1553 1570
1558 $SETUP_NOTEBOOK->add (Graphics => graphics_setup, 1575 $SETUP_NOTEBOOK->add (Graphics => graphics_setup,
1559 "Configure the video mode, performance, fonts and other graphical aspects of the game."); 1576 "Configure the video mode, performance, fonts and other graphical aspects of the game.");
1560 $SETUP_NOTEBOOK->add (Audio => audio_setup, 1577 $SETUP_NOTEBOOK->add (Audio => audio_setup,
1561 "Configure the use of audio, sound effects and background music."); 1578 "Configure the use of audio, sound effects and background music.");
1562 $SETUP_NOTEBOOK->add (Keyboard => $SETUP_KEYBOARD = keyboard_setup, 1579 $SETUP_NOTEBOOK->add (Keyboard => $SETUP_KEYBOARD = keyboard_setup,
1563 "Lets you define, edit and delete bindings." 1580 "Lets you define, edit and delete key bindings."
1564 . "There is a shortcut for making bindings: <b>Left Control + Insert</b> opens the binding editor " 1581 . "There is a shortcut for making bindings: <b>Control-Insert</b> opens the binding editor "
1565 . "with nothing set and the recording started. After doing the actions you " 1582 . "with nothing set and the recording started. After doing the actions you "
1566 . "want to record press <b>Insert</b> and you will be asked to press a key-combo. " 1583 . "want to record press <b>Insert</b> and you will be asked to press a key-combo. "
1567 . "After pressing the combo the binding will be saved automatically and the " 1584 . "After pressing the combo the binding will be saved automatically and the "
1568 . "binding editor closes"); 1585 . "binding editor closes");
1569 $SETUP_NOTEBOOK->add (Spells => $SETUP_SPELLS = spell_setup, 1586 $SETUP_NOTEBOOK->add (Spells => $SETUP_SPELLS = spell_setup,
1570 "Displays all spells you have and lets you edit keyboard shortcuts for them."); 1587 "Displays all spells you have and lets you edit keyboard shortcuts for them.");
1571 $SETUP_NOTEBOOK->add (Debug => debug_setup, 1588 $SETUP_NOTEBOOK->add (Debug => debug_setup,
1572 "Some debuggign options. Do not ask."); 1589 "Some debuggin' options. Do not ask.");
1573 1590
1574 $BUTTONBAR = new CFClient::UI::Buttonbar x => 0, y => 0, z => 200; # put on top 1591 $BUTTONBAR = new CFClient::UI::Buttonbar x => 0, y => 0, z => 200; # put on top
1575 1592
1576 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Setup", other => $SETUP_DIALOG, 1593 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Setup", other => $SETUP_DIALOG,
1577 tooltip => "Toggles a dialog where you can configure all aspects of this client."); 1594 tooltip => "Toggles a dialog where you can configure all aspects of this client.");
1592 tooltip => "Saves the options chosen in the client setting, server settings and the window layout to be restored on later runs.", 1609 tooltip => "Saves the options chosen in the client setting, server settings and the window layout to be restored on later runs.",
1593 on_activate => sub { 1610 on_activate => sub {
1594 $::CFG->{layout} = CFClient::UI::get_layout; 1611 $::CFG->{layout} = CFClient::UI::get_layout;
1595 CFClient::write_cfg "$Crossfire::VARDIR/cfplusrc"; 1612 CFClient::write_cfg "$Crossfire::VARDIR/cfplusrc";
1596 status "Configuration Saved"; 1613 status "Configuration Saved";
1614 0
1597 }, 1615 },
1598 ); 1616 );
1599 1617
1600 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Help!", other => help_window, 1618 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Help!", other => help_window,
1601 tooltip => "View Documentation"); 1619 tooltip => "View Documentation");
1607 if ($CONN) { 1625 if ($CONN) {
1608 open_quit_dialog; 1626 open_quit_dialog;
1609 } else { 1627 } else {
1610 exit; 1628 exit;
1611 } 1629 }
1630 0
1612 }, 1631 },
1613 ); 1632 );
1614 1633
1615 $BUTTONBAR->show; 1634 $BUTTONBAR->show;
1616 $SETUP_DIALOG->show; 1635 $SETUP_DIALOG->show;
1618 1637
1619 $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]); 1638 $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]);
1620} 1639}
1621 1640
1622sub video_shutdown { 1641sub video_shutdown {
1642 CFClient::OpenGL::shutdown;
1643
1623 undef $SDL_ACTIVE; 1644 undef $SDL_ACTIVE;
1624} 1645}
1625 1646
1626my @bgmusic = qw(game1.ogg game2.ogg game3.ogg game5.ogg game6.ogg ross1.ogg ross2.ogg ross3.ogg ross4.ogg ross5.ogg); #d# 1647my @bgmusic = qw(game1.ogg game2.ogg game3.ogg game5.ogg game6.ogg ross1.ogg ross2.ogg ross3.ogg ross4.ogg ross5.ogg); #d#
1627my $bgmusic;#TODO#hack#d# 1648my $bgmusic;#TODO#hack#d#
1843 1864
1844 CFClient::read_cfg "$Crossfire::VARDIR/cfplusrc"; 1865 CFClient::read_cfg "$Crossfire::VARDIR/cfplusrc";
1845 CFClient::UI::set_layout ($::CFG->{layout}); 1866 CFClient::UI::set_layout ($::CFG->{layout});
1846 1867
1847 my %DEF_CFG = ( 1868 my %DEF_CFG = (
1848 sdl_mode => 0, 1869 sdl_mode => 0,
1849 width => 640, 1870 width => 640,
1850 height => 480, 1871 height => 480,
1851 fullscreen => 0, 1872 fullscreen => 0,
1852 fast => 0, 1873 fast => 0,
1853 map_scale => 1, 1874 map_scale => 1,
1854 fow_enable => 1, 1875 fow_enable => 1,
1855 fow_intensity => 0.45, 1876 fow_intensity => 0.45,
1856 fow_smooth => 0, 1877 fow_smooth => 0,
1857 gui_fontsize => 1, 1878 gui_fontsize => 1,
1858 log_fontsize => 0.7, 1879 log_fontsize => 0.7,
1859 gauge_fontsize=> 1, 1880 gauge_fontsize => 1,
1860 gauge_size => 0.35, 1881 gauge_size => 0.35,
1861 stat_fontsize => 0.7, 1882 stat_fontsize => 0.7,
1862 mapsize => 100, 1883 mapsize => 100,
1863 host => "crossfire.schmorp.de",
1864 say_command => 'say', 1884 say_command => 'say',
1865 audio_enable => 1, 1885 audio_enable => 1,
1866 bgm_enable => 1, 1886 bgm_enable => 1,
1867 bgm_volume => 0.25, 1887 bgm_volume => 0.25,
1868 face_prefetch => 0, 1888 face_prefetch => 0,
1869 output_sync => 1, 1889 output_sync => 1,
1870 output_count => 1, 1890 output_count => 1,
1871 pickup => 0, 1891 pickup => 0,
1892 default => "profile", # default profile
1893 );
1872 ); 1894
1873
1874 while (my ($k, $v) = each %DEF_CFG) { 1895 while (my ($k, $v) = each %DEF_CFG) {
1875 $CFG->{$k} = $v unless exists $CFG->{$k}; 1896 $CFG->{$k} = $v unless exists $CFG->{$k};
1876 } 1897 }
1898
1899 $CFG->{profile}{default}{host} ||= "crossfire.schmorp.de";
1877 1900
1878 sdl_init; 1901 sdl_init;
1879 1902
1880 @SDL_MODES = reverse 1903 @SDL_MODES = reverse
1881 grep $_->[0] >= 640 && $_->[1] >= 480, 1904 grep $_->[0] >= 640 && $_->[1] >= 480,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines