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.63 by root, Wed Jun 7 05:54:09 2006 UTC vs.
Revision 1.74 by root, Sun Jun 18 17:13:12 2006 UTC

84our $CONSOLE; 84our $CONSOLE;
85our $METASERVER; 85our $METASERVER;
86our $LOGIN_BUTTON; 86our $LOGIN_BUTTON;
87our $QUIT_DIALOG; 87our $QUIT_DIALOG;
88our $HOST_ENTRY; 88our $HOST_ENTRY;
89our $SERVER_INFO;
89 90
90our $SETUP_DIALOG; 91our $SETUP_DIALOG;
91our $SETUP_NOTEBOOK; 92our $SETUP_NOTEBOOK;
92our $SETUP_SERVER; 93our $SETUP_SERVER;
93our $SETUP_KEYBOARD; 94our $SETUP_KEYBOARD;
154 $hbox->add (new CFClient::UI::Button 155 $hbox->add (new CFClient::UI::Button
155 text => "No", 156 text => "No",
156 on_activate => sub { 157 on_activate => sub {
157 $conn->send ("reply n"); 158 $conn->send ("reply n");
158 $dialog->destroy; 159 $dialog->destroy;
160 0
159 } 161 }
160 ); 162 );
161 $hbox->add (new CFClient::UI::Button 163 $hbox->add (new CFClient::UI::Button
162 text => "Yes", 164 text => "Yes",
163 on_activate => sub { 165 on_activate => sub {
164 $conn->send ("reply y"); 166 $conn->send ("reply y");
165 destroy_query_dialog $conn; 167 destroy_query_dialog $conn;
168 0
166 }, 169 },
167 ); 170 );
168 171
169 $dialog->focus_in; 172 $dialog->grab_focus;
170 173
171 } elsif ($flags & CS_QUERY_SINGLECHAR) { 174 } elsif ($flags & CS_QUERY_SINGLECHAR) {
172 $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)";
173 176
174 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) {
184 $table->add (0, 0, new CFClient::UI::Button 187 $table->add (0, 0, new CFClient::UI::Button
185 text => "Next Race", 188 text => "Next Race",
186 on_activate => sub { 189 on_activate => sub {
187 $conn->send ("reply n"); 190 $conn->send ("reply n");
188 destroy_query_dialog $conn; 191 destroy_query_dialog $conn;
192 0
189 }, 193 },
190 ); 194 );
191 $table->add (2, 0, new CFClient::UI::Button 195 $table->add (2, 0, new CFClient::UI::Button
192 text => "Accept", 196 text => "Accept",
193 on_activate => sub { 197 on_activate => sub {
194 $conn->send ("reply d"); 198 $conn->send ("reply d");
195 destroy_query_dialog $conn; 199 destroy_query_dialog $conn;
200 0
196 }, 201 },
197 ); 202 );
198 203
199 unshift @dialog, new CFClient::UI::Label 204 unshift @dialog, new CFClient::UI::Label
200 max_w => $::WIDTH * 0.4, 205 max_w => $::WIDTH * 0.4,
230 $table->add (0, 0, new CFClient::UI::Button 235 $table->add (0, 0, new CFClient::UI::Button
231 text => "Roll Again", 236 text => "Roll Again",
232 on_activate => sub { 237 on_activate => sub {
233 $conn->send ("reply y"); 238 $conn->send ("reply y");
234 destroy_query_dialog $conn; 239 destroy_query_dialog $conn;
240 0
235 }, 241 },
236 ); 242 );
237 243
238 # center: swap stats 244 # center: swap stats
239 my ($sw1, $sw2) = map +(new CFClient::UI::Combobox 245 my ($sw1, $sw2) = map +(new CFClient::UI::Combobox
240 value => $_, 246 value => $_,
241 options => [ 247 options => [
242 [Str => 1, "Strength ($conn->{stat}{+CS_STAT_STR})"], 248 [1 => "Str", "Strength ($conn->{stat}{+CS_STAT_STR})"],
243 [Dex => 2, "Dexterity ($conn->{stat}{+CS_STAT_DEX})"], 249 [2 => "Dex", "Dexterity ($conn->{stat}{+CS_STAT_DEX})"],
244 [Con => 3, "Constitution ($conn->{stat}{+CS_STAT_CON})"], 250 [3 => "Con", "Constitution ($conn->{stat}{+CS_STAT_CON})"],
245 [Int => 4, "Intelligence ($conn->{stat}{+CS_STAT_INT})"], 251 [4 => "Int", "Intelligence ($conn->{stat}{+CS_STAT_INT})"],
246 [Wis => 5, "Wisdom ($conn->{stat}{+CS_STAT_WIS})"], 252 [5 => "Wis", "Wisdom ($conn->{stat}{+CS_STAT_WIS})"],
247 [Pow => 6, "Power ($conn->{stat}{+CS_STAT_POW})"], 253 [6 => "Pow", "Power ($conn->{stat}{+CS_STAT_POW})"],
248 [Cha => 7, "Charisma ($conn->{stat}{+CS_STAT_CHA})"], 254 [7 => "Cha", "Charisma ($conn->{stat}{+CS_STAT_CHA})"],
249 ], 255 ],
250 ), 1 .. 2; 256 ), 1 .. 2;
251 257
252 $table->add (2, 0, new CFClient::UI::Button 258 $table->add (2, 0, new CFClient::UI::Button
253 text => "Swap Stats", 259 text => "Swap Stats",
254 on_activate => sub { 260 on_activate => sub {
255 $conn->{stat_change_with} = $sw2->{value}; 261 $conn->{stat_change_with} = $sw2->{value};
256 $conn->send ("reply $sw1->{value}"); 262 $conn->send ("reply $sw1->{value}");
257 destroy_query_dialog $conn; 263 destroy_query_dialog $conn;
264 0
258 }, 265 },
259 ); 266 );
260 $table->add (2, 1, new CFClient::UI::HBox children => [$sw1, $sw2]); 267 $table->add (2, 1, new CFClient::UI::HBox children => [$sw1, $sw2]);
261 268
262 # right: accept 269 # right: accept
264 text => "Accept", 271 text => "Accept",
265 on_activate => sub { 272 on_activate => sub {
266 $conn->send ("reply n"); 273 $conn->send ("reply n");
267 $STATS_WINDOW->hide; 274 $STATS_WINDOW->hide;
268 destroy_query_dialog $conn; 275 destroy_query_dialog $conn;
276 0
269 }, 277 },
270 ); 278 );
271 279
272 unshift @dialog, new CFClient::UI::Label 280 unshift @dialog, new CFClient::UI::Label
273 max_w => $::WIDTH * 0.4, 281 max_w => $::WIDTH * 0.4,
283 291
284 push @dialog, my $entry = new CFClient::UI::Entry 292 push @dialog, my $entry = new CFClient::UI::Entry
285 on_changed => sub { 293 on_changed => sub {
286 $conn->send ("reply $_[1]"); 294 $conn->send ("reply $_[1]");
287 destroy_query_dialog $conn; 295 destroy_query_dialog $conn;
296 0
288 }, 297 },
289 ; 298 ;
290 299
291 $entry->focus_in; 300 $entry->grab_focus;
292 301
293 } else { 302 } else {
294 $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)";
295 304
296 push @dialog, my $entry = new CFClient::UI::Entry 305 push @dialog, my $entry = new CFClient::UI::Entry
297 $flags & CS_QUERY_HIDEINPUT ? (hidden => "*") : (), 306 $flags & CS_QUERY_HIDEINPUT ? (hidden => "*") : (),
298 on_activate => sub { 307 on_activate => sub {
299 $conn->send ("reply $_[1]"); 308 $conn->send ("reply $_[1]");
300 destroy_query_dialog $conn; 309 destroy_query_dialog $conn;
310 0
301 }, 311 },
302 ; 312 ;
303 313
304 $entry->focus_in; 314 $entry->grab_focus;
305 } 315 }
306 316
307 $vbox->add (@dialog); 317 $vbox->add (@dialog);
308 $dialog->show; 318 $dialog->show;
309} 319}
362sub stop_game { 372sub stop_game {
363 $LOGIN_BUTTON->set_text ("Login"); 373 $LOGIN_BUTTON->set_text ("Login");
364 $SETUP_NOTEBOOK->set_current_page ($SETUP_SERVER); 374 $SETUP_NOTEBOOK->set_current_page ($SETUP_SERVER);
365 $SETUP_DIALOG->show; 375 $SETUP_DIALOG->show;
366 $INV_WINDOW->hide; 376 $INV_WINDOW->hide;
377 $SETUP_SPELLS->clear_spells;
367 378
368 return unless $CONN; 379 return unless $CONN;
369 380
370 status "connection closed"; 381 status "connection closed";
371 382
397 408
398 $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");
399 $table->add (1, $row++, new CFClient::UI::CheckBox 410 $table->add (1, $row++, new CFClient::UI::CheckBox
400 state => $CFG->{fullscreen}, 411 state => $CFG->{fullscreen},
401 tooltip => "Bring the client into fullscreen mode.", 412 tooltip => "Bring the client into fullscreen mode.",
402 on_changed => sub { 413 on_changed => sub { my ($self, $value) = @_; $CFG->{fullscreen} = $value; 0 }
403 my ($self, $value) = @_;
404 $CFG->{fullscreen} = $value;
405 }
406 ); 414 );
407 415
408 $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");
409 $table->add (1, $row++, new CFClient::UI::CheckBox 417 $table->add (1, $row++, new CFClient::UI::CheckBox
410 state => $CFG->{fast}, 418 state => $CFG->{fast},
411 tooltip => "Lower the visual quality considerably to speed up rendering.", 419 tooltip => "Lower the visual quality considerably to speed up rendering.",
412 on_changed => sub { 420 on_changed => sub { my ($self, $value) = @_; $CFG->{fast} = $value; 0 }
413 my ($self, $value) = @_;
414 $CFG->{fast} = $value;
415 }
416 ); 421 );
417 422
418 $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");
419 $table->add (1, $row++, new CFClient::UI::Slider 424 $table->add (1, $row++, new CFClient::UI::Slider
420 range => [(log $CFG->{map_scale}) / (log 2), -3, 1, 0, 1], 425 range => [(log $CFG->{map_scale}) / (log 2), -3, 1, 0, 1],
421 tooltip => "Enlarge or shrink the displayed map. Changes are instant.", 426 tooltip => "Enlarge or shrink the displayed map. Changes are instant.",
422 on_changed => sub { 427 on_changed => sub { my ($self, $value) = @_; $CFG->{map_scale} = 2 ** $value; 0 }
423 my ($self, $value) = @_;
424 $CFG->{map_scale} = 2 ** $value;
425 }
426 ); 428 );
427 429
428 $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");
429 $table->add (1, $row++, new CFClient::UI::CheckBox 431 $table->add (1, $row++, new CFClient::UI::CheckBox
430 state => $CFG->{fow_enable}, 432 state => $CFG->{fow_enable},
431 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.",
432 on_changed => sub { 434 on_changed => sub { my ($self, $value) = @_; $CFG->{fow_enable} = $value; 0 }
433 my ($self, $value) = @_;
434 $CFG->{fow_enable} = $value;
435 }
436 ); 435 );
437 436
438 $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");
439 $table->add (1, $row++, new CFClient::UI::Slider 438 $table->add (1, $row++, new CFClient::UI::Slider
440 range => [$CFG->{fow_intensity}, 0, 1, 0, 1 / 256], 439 range => [$CFG->{fow_intensity}, 0, 1, 0, 1 / 256],
441 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.",
442 on_changed => sub { 441 on_changed => sub { my ($self, $value) = @_; $CFG->{fow_intensity} = $value; 0 }
443 my ($self, $value) = @_;
444 $CFG->{fow_intensity} = $value;
445 }
446 ); 442 );
447 443
448 $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");
449 $table->add (1, $row++, new CFClient::UI::CheckBox 445 $table->add (1, $row++, new CFClient::UI::CheckBox
450 state => $CFG->{fow_smooth}, 446 state => $CFG->{fow_smooth},
451 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.",
452 on_changed => sub { 448 on_changed => sub {
453 my ($self, $value) = @_; 449 my ($self, $value) = @_;
454 $CFG->{fow_smooth} = $value; 450 $CFG->{fow_smooth} = $value;
455 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
456 } 453 }
457 ); 454 );
458 455
459 $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");
460 $table->add (1, $row++, new CFClient::UI::Slider 457 $table->add (1, $row++, new CFClient::UI::Slider
461 range => [$CFG->{gui_fontsize}, 0.5, 2, 0, 0.1], 458 range => [$CFG->{gui_fontsize}, 0.5, 2, 0, 0.1],
462 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.",
463 on_changed => sub { $CFG->{gui_fontsize} = $_[1] }, 460 on_changed => sub { $CFG->{gui_fontsize} = $_[1]; 0 },
464 ); 461 );
465 462
466 $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");
467 $table->add (1, $row++, new CFClient::UI::Slider 464 $table->add (1, $row++, new CFClient::UI::Slider
468 range => [$CFG->{log_fontsize}, 0.5, 2, 0, 0.1], 465 range => [$CFG->{log_fontsize}, 0.5, 2, 0, 0.1],
469 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.",
470 on_changed => sub { $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = $_[1]) }, 467 on_changed => sub { $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = $_[1]); 0 },
471 ); 468 );
472 469
473 $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");
474 471
475 $table->add (1, $row++, new CFClient::UI::Slider 472 $table->add (1, $row++, new CFClient::UI::Slider
476 range => [$CFG->{stat_fontsize}, 0.5, 2, 0, 0.1], 473 range => [$CFG->{stat_fontsize}, 0.5, 2, 0, 0.1],
477 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.",
478 on_changed => sub { 475 on_changed => sub {
479 $CFG->{stat_fontsize} = $_[1]; 476 $CFG->{stat_fontsize} = $_[1];
480 &set_stats_window_fontsize; 477 &set_stats_window_fontsize;
478 0
481 } 479 }
482 ); 480 );
483 481
484 $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");
485 $table->add (1, $row++, new CFClient::UI::Slider 483 $table->add (1, $row++, new CFClient::UI::Slider
486 range => [$CFG->{gauge_fontsize}, 0.5, 2, 0, 0.1], 484 range => [$CFG->{gauge_fontsize}, 0.5, 2, 0, 0.1],
487 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.",
488 on_changed => sub { 486 on_changed => sub {
489 $CFG->{gauge_fontsize} = $_[1]; 487 $CFG->{gauge_fontsize} = $_[1];
490 &set_gauge_window_fontsize; 488 &set_gauge_window_fontsize;
489 0
491 } 490 }
492 ); 491 );
493 492
494 $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");
495 $table->add (1, $row++, new CFClient::UI::Slider 494 $table->add (1, $row++, new CFClient::UI::Slider
496 range => [$CFG->{gauge_size}, 0.2, 0.8], 495 range => [$CFG->{gauge_size}, 0.2, 0.8],
497 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.",
498 on_changed => sub { 497 on_changed => sub {
499 $CFG->{gauge_size} = $_[1]; 498 $CFG->{gauge_size} = $_[1];
500 $GAUGES->{win}->set_size ($WIDTH, int $HEIGHT * $CFG->{gauge_size}); 499 $GAUGES->{win}->set_size ($WIDTH, int $HEIGHT * $CFG->{gauge_size});
500 0
501 } 501 }
502 ); 502 );
503 503
504 $table->add (1, $row++, new CFClient::UI::Button 504 $table->add (1, $row++, new CFClient::UI::Button
505 expand => 1, align => 0, text => "Apply", 505 expand => 1, align => 0, text => "Apply",
506 tooltip => "Apply the video settings", 506 tooltip => "Apply the video settings",
507 on_activate => sub { 507 on_activate => sub {
508 video_shutdown (); 508 video_shutdown ();
509 video_init (); 509 video_init ();
510 0
510 } 511 }
511 ); 512 );
512 513
513 $vbox 514 $vbox
514} 515}
522 523
523 $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");
524 $table->add (1, $row++, new CFClient::UI::CheckBox 525 $table->add (1, $row++, new CFClient::UI::CheckBox
525 state => $CFG->{audio_enable}, 526 state => $CFG->{audio_enable},
526 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.",
527 on_changed => sub { 528 on_changed => sub { $CFG->{audio_enable} = $_[1]; 0 }
528 $CFG->{audio_enable} = $_[1];
529 }
530 ); 529 );
531# $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");
532# $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 {
533# $CFG->{effects_volume} = $_[1]; 532# $CFG->{effects_volume} = $_[1];
534# }); 533# });
535 $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");
536 $table->add (1, $row++, my $hbox = new CFClient::UI::HBox); 535 $table->add (1, $row++, my $hbox = new CFClient::UI::HBox);
537 $hbox->add (new CFClient::UI::CheckBox 536 $hbox->add (new CFClient::UI::CheckBox
538 expand => 1, state => $CFG->{bgm_enable}, 537 expand => 1, state => $CFG->{bgm_enable},
539 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.",
540 on_changed => sub { 539 on_changed => sub { $CFG->{bgm_enable} = $_[1]; 0 }
541 $CFG->{bgm_enable} = $_[1];
542 }
543 ); 540 );
544 $hbox->add (new CFClient::UI::Slider 541 $hbox->add (new CFClient::UI::Slider
545 expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0, 1/128], 542 expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0, 1/128],
546 tooltip => "The volume of the background music. Changes are instant.", 543 tooltip => "The volume of the background music. Changes are instant.",
547 on_changed => sub { 544 on_changed => sub { $CFG->{bgm_volume} = $_[1]; CFClient::MixMusic::volume $_[1] * 128; 0 }
548 $CFG->{bgm_volume} = $_[1];
549 CFClient::MixMusic::volume $_[1] * 128;
550 }
551 ); 545 );
552 546
553 $table->add (1, $row++, new CFClient::UI::Button 547 $table->add (1, $row++, new CFClient::UI::Button
554 expand => 1, align => 0, text => "Apply", 548 expand => 1, align => 0, text => "Apply",
555 tooltip => "Apply the audio settings", 549 tooltip => "Apply the audio settings",
556 on_activate => sub { 550 on_activate => sub {
557 audio_shutdown (); 551 audio_shutdown ();
558 audio_init (); 552 audio_init ();
553 0
559 } 554 }
560 ); 555 );
561 556
562 $vbox 557 $vbox
563} 558}
625 &set_gauge_window_fontsize; 620 &set_gauge_window_fontsize;
626 621
627 $win 622 $win
628} 623}
629 624
625sub debug_setup {
626 my $table = new CFClient::UI::Table;
627
628 $table->add (0, 0, new CFClient::UI::Label text => "Widget Borders");
629 $table->add (1, 0, new CFClient::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 1; 0 });
630 $table->add (0, 1, new CFClient::UI::Label text => "Tooltip Widget Info");
631 $table->add (1, 1, new CFClient::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 2; 0 });
632 $table->add (0, 2, new CFClient::UI::Label text => "Show FPS");
633 $table->add (1, 2, new CFClient::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 4; 0 });
634 $table->add (0, 3, new CFClient::UI::Label text => "Suppress Tooltips");
635 $table->add (1, 3, new CFClient::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 8; 0 });
636
637 my @default_smooth = (0.05, 0.13, 0.05, 0.13, 0.30, 0.13, 0.05, 0.13, 0.05);
638
639 for my $x (0..2) {
640 for my $y (0 .. 2) {
641 $table->add ($x + 3, $y,
642 new CFClient::UI::Entry
643 text => $default_smooth[$x * 3 + $y],
644 on_changed => sub { $MAP->{smooth_matrix}[$x * 3 + $y] = $_[1] if $MAP; 0 },
645 );
646 }
647 }
648
649
650 $table
651}
630 652
631sub stats_window { 653sub stats_window {
632 my $tgw = new CFClient::UI::FancyFrame 654 my $tgw = new CFClient::UI::FancyFrame
633 y => $HEIGHT * (2/8), 655 y => $HEIGHT * (2/8),
634 x => "max", 656 x => "max",
635 title => "Stats", 657 title => "Stats",
636 name => "stats_window"; 658 name => "stats_window",
659 has_close_button => 1;
637 660
638 $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);
639 $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,
640 can_hover => 1, can_events => 1, 663 can_hover => 1, can_events => 1,
641 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.");
787 $STATWIDS->{st_spd} ->set_text (sprintf "%.1f", $stats->{+CS_STAT_SPEED}); 810 $STATWIDS->{st_spd} ->set_text (sprintf "%.1f", $stats->{+CS_STAT_SPEED});
788 $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});
789 812
790 $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);
791 814
792 # TODO: replace by CS_STAT_RES_xxx constants
793 my %tbl = ( 815 my %tbl = (
794 phys => 100, 816 phys => CS_STAT_RES_PHYS,
795 magic => 101, 817 magic => CS_STAT_RES_MAG,
796 fire => 102, 818 fire => CS_STAT_RES_FIRE,
797 elec => 103, 819 elec => CS_STAT_RES_ELEC,
798 cold => 104, 820 cold => CS_STAT_RES_COLD,
799 conf => 105, 821 conf => CS_STAT_RES_CONF,
800 acid => 106, 822 acid => CS_STAT_RES_ACID,
801 drain => 107, 823 drain => CS_STAT_RES_DRAIN,
802 ghit => 108, 824 ghit => CS_STAT_RES_GHOSTHIT,
803 pois => 109, 825 pois => CS_STAT_RES_POISON,
804 slow => 110, 826 slow => CS_STAT_RES_SLOW,
805 para => 111, 827 para => CS_STAT_RES_PARA,
806 tund => 112, 828 tund => CS_STAT_TURN_UNDEAD,
807 fear => 113, 829 fear => CS_STAT_RES_FEAR,
808 depl => 113, 830 depl => CS_STAT_RES_DEPLETE,
809 deat => 115, 831 deat => CS_STAT_RES_DEATH,
810 holyw => 116, 832 holyw => CS_STAT_RES_HOLYWORD,
811 blind => 117, 833 blind => CS_STAT_RES_BLIND,
812 ); 834 );
813 835
814 $STATWIDS->{"res_$_"}->set_text (sprintf "%d%", $stats->{$tbl{$_}}) 836 $STATWIDS->{"res_$_"}->set_text (sprintf "%d%", $stats->{$tbl{$_}})
815 for keys %tbl; 837 for keys %tbl;
816} 838}
892 text => "Use", 914 text => "Use",
893 tooltip => "Put this server into the <b>Host:Port</b> field", 915 tooltip => "Put this server into the <b>Host:Port</b> field",
894 on_activate => sub { 916 on_activate => sub {
895 $HOST_ENTRY->set_text ($CFG->{host} = $host); 917 $HOST_ENTRY->set_text ($CFG->{host} = $host);
896 $METASERVER->hide; 918 $METASERVER->hide;
919 0
897 }, 920 },
898 ), 921 ),
899 (new CFClient::UI::Empty expand => 1), 922 (new CFClient::UI::Empty expand => 1),
900 ]); 923 ]);
901 924
922 z => 3, 945 z => 3,
923 force_h => $::HEIGHT * 0.4, 946 force_h => $::HEIGHT * 0.4,
924 child => (my $vbox = new CFClient::UI::VBox), 947 child => (my $vbox = new CFClient::UI::VBox),
925 on_visibility_change => sub { 948 on_visibility_change => sub {
926 update_metaserver if $_[1]; 949 update_metaserver if $_[1];
950 0
927 }, 951 },
928 ; 952 ;
929 953
930 $dialog->{table} = new CFClient::UI::Table; 954 $dialog->{table} = new CFClient::UI::Table;
931 955
949 text => $CFG->{host}, 973 text => $CFG->{host},
950 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",
951 on_changed => sub { 975 on_changed => sub {
952 my ($self, $value) = @_; 976 my ($self, $value) = @_;
953 $CFG->{host} = $value; 977 $CFG->{host} = $value;
978 0
954 } 979 }
955 ); 980 );
956 981
957 $METASERVER = metaserver_dialog; 982 $METASERVER = metaserver_dialog;
958 983
959 $vbox->add (new CFClient::UI::Button 984 $vbox->add (new CFClient::UI::Button
960 expand => 1, 985 expand => 1,
961 text => "Server List", 986 text => "Server List",
962 other => $METASERVER, 987 other => $METASERVER,
963 tooltip => "Show a list of available crossfire servers", 988 tooltip => "Show a list of available crossfire servers",
964 on_activate => sub { $METASERVER->toggle_visibility }, 989 on_activate => sub { $METASERVER->toggle_visibility; 0 },
965 on_visibility_change => sub { $METASERVER->hide unless $_[1] }, 990 on_visibility_change => sub { $METASERVER->hide unless $_[1]; 0 },
966 ); 991 );
967 } 992 }
968 993
969 $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");
970 $table->add (1, 4, new CFClient::UI::Entry 995 $table->add (1, 4, new CFClient::UI::Entry
971 text => $CFG->{user}, 996 text => $CFG->{user},
972 tooltip => "The name of your character on the server", 997 tooltip => "The name of your character on the server",
973 on_changed => sub { 998 on_changed => sub { my ($self, $value) = @_; $CFG->{user} = $value; 0 }
974 my ($self, $value) = @_;
975 $CFG->{user} = $value;
976 }
977 ); 999 );
978 1000
979 $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");
980 $table->add (1, 5, new CFClient::UI::Entry 1002 $table->add (1, 5, new CFClient::UI::Entry
981 text => $CFG->{password}, 1003 text => $CFG->{password},
982 hidden => 1, 1004 hidden => 1,
983 tooltip => "The password for your character", 1005 tooltip => "The password for your character",
984 on_changed => sub { 1006 on_changed => sub { my ($self, $value) = @_; $CFG->{password} = $value; 0 }
985 my ($self, $value) = @_;
986 $CFG->{password} = $value;
987 }
988 ); 1007 );
989 1008
990 $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");
991 $table->add (1, 7, new CFClient::UI::Slider 1010 $table->add (1, 7, new CFClient::UI::Slider
992 force_w => 100, 1011 force_w => 100,
993 range => [$CFG->{mapsize}, 10, 100, 0, 1], 1012 range => [$CFG->{mapsize}, 10, 100, 0, 1],
994 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. "
995 . "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, "
996 . "but you also increase bandwidth requirements and latency. " 1015 . "but you also increase bandwidth requirements and latency. "
997 . "This option is only used once at log-in.", 1016 . "This option is only used once at log-in.",
998 on_changed => sub { 1017 on_changed => sub { my ($self, $value) = @_; $CFG->{mapsize} = $self->{range}[0] = $value = int $value; 0 },
999 my ($self, $value) = @_;
1000
1001 $CFG->{mapsize} = $self->{range}[0] = $value = int $value;
1002 },
1003 ); 1018 );
1004 1019
1005 $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");
1006 $table->add (1, 8, new CFClient::UI::CheckBox 1021 $table->add (1, 8, new CFClient::UI::CheckBox
1007 state => $CFG->{face_prefetch}, 1022 state => $CFG->{face_prefetch},
1010 . "This might increase or create lag, but increases the chances " 1025 . "This might increase or create lag, but increases the chances "
1011 . "of faces being ready for display when you encounter them. " 1026 . "of faces being ready for display when you encounter them. "
1012 . "It also uses up server bandwidth on every connect, " 1027 . "It also uses up server bandwidth on every connect, "
1013 . "so only set it if you really need to prefetch images. " 1028 . "so only set it if you really need to prefetch images. "
1014 . "This option can be set and unset any time.", 1029 . "This option can be set and unset any time.",
1015 on_changed => sub { $CFG->{face_prefetch} = $_[1] }, 1030 on_changed => sub { $CFG->{face_prefetch} = $_[1]; 0 },
1016 ); 1031 );
1017 1032
1018 $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");
1019 $table->add (1, 9, new CFClient::UI::Entry 1034 $table->add (1, 9, new CFClient::UI::Entry
1020 text => $CFG->{output_count}, 1035 text => $CFG->{output_count},
1021 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.",
1022 on_changed => sub { $CFG->{output_count} = $_[1] }, 1037 on_changed => sub { $CFG->{output_count} = $_[1]; 0 },
1023 ); 1038 );
1024 1039
1025 $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");
1026 $table->add (1, 10, new CFClient::UI::Entry 1041 $table->add (1, 10, new CFClient::UI::Entry
1027 text => $CFG->{output_sync}, 1042 text => $CFG->{output_sync},
1028 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.",
1029 on_changed => sub { $CFG->{output_sync} = $_[1] }, 1044 on_changed => sub { $CFG->{output_sync} = $_[1]; 0 },
1030 ); 1045 );
1031 1046
1032 $table->add (1, 11, $LOGIN_BUTTON = new CFClient::UI::Button 1047 $table->add (1, 11, $LOGIN_BUTTON = new CFClient::UI::Button
1033 expand => 1, 1048 expand => 1,
1034 align => 0, 1049 align => 0,
1035 text => "Login", 1050 text => "Login",
1036 on_activate => sub { 1051 on_activate => sub {
1037 $CONN ? stop_game 1052 $CONN ? stop_game
1038 : start_game; 1053 : start_game;
1054 0
1039 }, 1055 },
1040 ); 1056 );
1041 1057
1042 $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");
1043 $table->add (1, 12, my $saycmd = new CFClient::UI::Entry 1059 $table->add (1, 12, my $saycmd = new CFClient::UI::Entry
1046 . "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. "
1047 . "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.",
1048 on_changed => sub { 1064 on_changed => sub {
1049 my ($self, $value) = @_; 1065 my ($self, $value) = @_;
1050 $CFG->{say_command} = $value; 1066 $CFG->{say_command} = $value;
1067 0
1051 } 1068 }
1052 ); 1069 );
1070
1071 $vbox->add (new CFClient::UI::Label
1072 text => "Server Info",
1073 fontsize => 1.2,
1074 padding_y => 8,
1075 fg => [1, 1, 0, 1],
1076 );
1077
1078 $vbox->add ($SERVER_INFO = new CFClient::UI::Label ellipsise => 0);
1053 1079
1054 $vbox 1080 $vbox
1055} 1081}
1056 1082
1057sub message_window { 1083sub message_window {
1062 bg => [0, 0, 0, 0.75], 1088 bg => [0, 0, 0, 0.75],
1063 x => "max", 1089 x => "max",
1064 y => 0, 1090 y => 0,
1065 force_w => $::WIDTH * 0.4, 1091 force_w => $::WIDTH * 0.4,
1066 force_h => $::HEIGHT * 0.5, 1092 force_h => $::HEIGHT * 0.5,
1067 child => (my $vbox = new CFClient::UI::VBox); 1093 child => (my $vbox = new CFClient::UI::VBox),
1094 has_close_button => 1;
1068 1095
1069 $vbox->add ($LOGVIEW); 1096 $vbox->add ($LOGVIEW);
1070 1097
1071 $vbox->add (my $input = new CFClient::UI::Entry 1098 $vbox->add (my $input = new CFClient::UI::Entry
1072 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> "
1080 1107
1081 if ($prev_focus == $MAPWIDGET && $input->{auto_activated}) { 1108 if ($prev_focus == $MAPWIDGET && $input->{auto_activated}) {
1082 $input->{refocus_map} = 1; 1109 $input->{refocus_map} = 1;
1083 } 1110 }
1084 delete $input->{auto_activated}; 1111 delete $input->{auto_activated};
1112
1113 0
1085 }, 1114 },
1086 on_activate => sub { 1115 on_activate => sub {
1087 my ($input, $text) = @_; 1116 my ($input, $text) = @_;
1088 $input->set_text (''); 1117 $input->set_text ('');
1089 1118
1095 } 1124 }
1096 if ($input->{refocus_map}) { 1125 if ($input->{refocus_map}) {
1097 delete $input->{refocus_map}; 1126 delete $input->{refocus_map};
1098 $MAPWIDGET->focus_in 1127 $MAPWIDGET->focus_in
1099 } 1128 }
1129
1130 0
1100 }, 1131 },
1101 on_escape => sub { 1132 on_escape => sub {
1102 $MAPWIDGET->focus_in 1133 $MAPWIDGET->grab_focus;
1134
1135 0
1103 }, 1136 },
1104 ); 1137 );
1105 1138
1106 $CONSOLE = { 1139 $CONSOLE = {
1107 window => $window, 1140 window => $window,
1129 ); 1162 );
1130 $vb->add (my $hb = new CFClient::UI::HBox expand => 1); 1163 $vb->add (my $hb = new CFClient::UI::HBox expand => 1);
1131 $hb->add (new CFClient::UI::Button 1164 $hb->add (new CFClient::UI::Button
1132 text => "Ok", 1165 text => "Ok",
1133 expand => 1, 1166 expand => 1,
1134 on_activate => sub { $QUIT_DIALOG->hide }, 1167 on_activate => sub { $QUIT_DIALOG->hide; 0 },
1135 ); 1168 );
1136 $hb->add (new CFClient::UI::Button 1169 $hb->add (new CFClient::UI::Button
1137 text => "Quit anyway", 1170 text => "Quit anyway",
1138 expand => 1, 1171 expand => 1,
1139 on_activate => sub { exit }, 1172 on_activate => sub { exit },
1182 ["Potions" => PICKUP_POTION], 1215 ["Potions" => PICKUP_POTION],
1183 ["Magic Devices" => PICKUP_MAGIC_DEVICE], 1216 ["Magic Devices" => PICKUP_MAGIC_DEVICE],
1184 ["Ignore cursed" => PICKUP_NOT_CURSED], 1217 ["Ignore cursed" => PICKUP_NOT_CURSED],
1185 ["Jewelery" => PICKUP_JEWELS], 1218 ["Jewelery" => PICKUP_JEWELS],
1186 ], 1219 ],
1220 ["Weight/Value ratio", 2, 17]
1187 ) 1221 )
1188 { 1222 {
1189 my ($title, $x, $y, @bits) = @$_; 1223 my ($title, $x, $y, @bits) = @$_;
1190 $table->add ($x, $y, new CFClient::UI::Label text => $title, align => 1, fg => [1, 1, 0]); 1224 $table->add ($x, $y, new CFClient::UI::Label text => $title, align => 1, fg => [1, 1, 0]);
1191 1225
1205 $::CFG->{pickup} &= ~$mask; 1239 $::CFG->{pickup} &= ~$mask;
1206 } 1240 }
1207 1241
1208 $::CONN->send_command ("pickup $::CFG->{pickup}") 1242 $::CONN->send_command ("pickup $::CFG->{pickup}")
1209 if defined $::CONN; 1243 if defined $::CONN;
1244
1245 0
1210 }); 1246 });
1211 } 1247 }
1212 } 1248 }
1249
1250 $table->add (2, 18, new CFClient::UI::ValSlider
1251 range => [0, 0, 16, 1, 1],
1252 to_value => sub { ">= " . 5 * $_[0] },
1253 on_changed => sub {
1254 my ($slider, $value) = @_;
1255
1256 $::CFG->{pickup} &= ~0x7;
1257 $::CFG->{pickup} |= int $value
1258 if $value;
1259 1;
1260 });
1261 $table->add (3, 18, new CFClient::UI::Button
1262 text => "set",
1263 on_activate => sub {
1264 $::CONN->send_command ("pickup $::CFG->{pickup}")
1265 if defined $::CONN;
1266 0
1267 });
1213 1268
1214 $table 1269 $table
1215} 1270}
1216 1271
1217sub inventory_window { 1272sub inventory_window {
1219 x => "center", 1274 x => "center",
1220 y => "center", 1275 y => "center",
1221 force_w => $WIDTH * 9/10, 1276 force_w => $WIDTH * 9/10,
1222 force_h => $HEIGHT * 9/10, 1277 force_h => $HEIGHT * 9/10,
1223 title => "Inventory", 1278 title => "Inventory",
1279 has_close_button => 1,
1224 ; 1280 ;
1225 1281
1226 $invwin->add (my $hb = new CFClient::UI::HBox homogeneous => 1); 1282 $invwin->add (my $hb = new CFClient::UI::HBox homogeneous => 1);
1227 1283
1228 $hb->add (my $vb1 = new CFClient::UI::VBox); 1284 $hb->add (my $vb1 = new CFClient::UI::VBox);
1264 text => "delete", 1320 text => "delete",
1265 tooltip => "Deletes the binding", 1321 tooltip => "Deletes the binding",
1266 on_activate => sub { 1322 on_activate => sub {
1267 $binding_list->remove ($hb); 1323 $binding_list->remove ($hb);
1268 delete $::CFG->{bindings}->{$mod}->{$sym}; 1324 delete $::CFG->{bindings}->{$mod}->{$sym};
1325 0
1269 }); 1326 });
1270 1327
1271 $hb->add (new CFClient::UI::Button 1328 $hb->add (new CFClient::UI::Button
1272 text => "edit", 1329 text => "edit",
1273 tooltip => "Edits the binding", 1330 tooltip => "Edits the binding",
1286 $SETUP_NOTEBOOK->set_current_page ($SETUP_KEYBOARD); 1343 $SETUP_NOTEBOOK->set_current_page ($SETUP_KEYBOARD);
1287 $SETUP_DIALOG->show; 1344 $SETUP_DIALOG->show;
1288 }); 1345 });
1289 $::BIND_EDITOR->show; 1346 $::BIND_EDITOR->show;
1290 $SETUP_DIALOG->hide; 1347 $SETUP_DIALOG->hide;
1348 0
1291 }); 1349 });
1292 1350
1293 $hb->add (new CFClient::UI::Label text => "(Key: $nam)"); 1351 $hb->add (new CFClient::UI::Label text => "(Key: $nam)");
1294 $hb->add (new CFClient::UI::Label text => $lbl, expand => 1); 1352 $hb->add (new CFClient::UI::Label text => $lbl, expand => 1);
1295 } 1353 }
1296 } 1354 }
1297 }; 1355 };
1298 1356
1299 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
1300 $vb->add ($binding_list); 1370 $vb->add ($binding_list);
1301 $vb->add (my $hb = new CFClient::UI::HBox); 1371 $vb->add (my $hb = new CFClient::UI::HBox);
1302 1372
1303 $hb->add (new CFClient::UI::Button 1373 $hb->add (new CFClient::UI::Button
1304 text => "record new", 1374 text => "record new",
1318 $SETUP_DIALOG->show; 1388 $SETUP_DIALOG->show;
1319 }, 1389 },
1320 ); 1390 );
1321 $SETUP_DIALOG->hide; 1391 $SETUP_DIALOG->hide;
1322 $::BIND_EDITOR->show; 1392 $::BIND_EDITOR->show;
1393 0
1323 }, 1394 },
1324 ); 1395 );
1325 1396
1326 $hb->add (new CFClient::UI::Button 1397 $hb->add (new CFClient::UI::Button
1327 text => "close", 1398 text => "close",
1328 tooltip => "Closes the binding window", 1399 tooltip => "Closes the binding window",
1329 expand => 1, 1400 expand => 1,
1330 on_activate => sub { 1401 on_activate => sub {
1331 $SETUP_DIALOG->hide; 1402 $SETUP_DIALOG->hide;
1403 0
1332 } 1404 }
1333 ); 1405 );
1334 1406
1335 $refresh->(); 1407 $refresh->();
1336 1408
1337 $vb 1409 $vb
1338} 1410}
1339 1411
1340sub make_help_window { 1412sub help_window {
1341 my $win = new CFClient::UI::FancyFrame 1413 my $win = new CFClient::UI::FancyFrame
1342 x => 'center', 1414 x => 'center',
1343 y => 'center', 1415 y => 'center',
1344 z => 2, 1416 z => 2,
1345 name => 'doc_browser', 1417 name => 'doc_browser',
1348 title => "Documentation"; 1420 title => "Documentation";
1349 1421
1350 $win->add (my $vbox = new CFClient::UI::VBox); 1422 $win->add (my $vbox = new CFClient::UI::VBox);
1351 1423
1352 $vbox->add (my $buttons = new CFClient::UI::HBox); 1424 $vbox->add (my $buttons = new CFClient::UI::HBox);
1353 $vbox->add (my $viewer = new CFClient::UI::TextView expand => 1, fontsize => 0.8); 1425 $vbox->add (my $viewer = new CFClient::UI::TextScroller
1426 expand => 1, fontsize => 0.8, padding_x => 4);
1354 1427
1355 for ( 1428 $buttons->add (new CFClient::UI::Label text => "Choose a document to display: ");
1429 $buttons->add (my $combo = new CFClient::UI::Combobox
1430 value => undef,
1431 options => [
1356 [intro => "Introduction"], 1432 [intro => "Introduction"],
1357 [manual => "Manual"], 1433 [manual => "Manual"],
1434 [skill_help => "Skills"],
1358 [command_help => "Commands"], 1435 [command_help => "Commands"],
1359 [skill_help => "Skills"], 1436 [dmcommand_help => "DM Commands"],
1360 ) { 1437 [COPYING => "License Terms"],
1361 my ($pod, $label) = @$_; 1438 ],
1439 on_changed => sub {
1440 my ($self, $pod) = @_;
1362 1441
1363 $buttons->add (new CFClient::UI::Button
1364 text => $label,
1365 on_activate => sub {
1366 my $pom = CFClient::load_pod CFClient::find_rcfile "pod/$pod.pod", 1442 my $pom = CFClient::load_pod CFClient::find_rcfile "pod/$pod.pod",
1367 doc_viewer => 1, sub { CFClient::pod_to_pango_list $_[0] }; 1443 doc_viewer => 1, sub { CFClient::pod_to_pango_list $_[0] };
1368 1444
1369 $viewer->clear; 1445 $viewer->clear;
1370 1446
1371 $viewer->add_paragraph ([1, 1, 1, 1], $_->[1], $_->[0]) 1447 $viewer->add_paragraph ([1, 1, 1, 1], $_->[1], $_->[0])
1372 for @$pom; 1448 for @$pom;
1373 1449
1374 $viewer->set_offset (0); 1450 $viewer->set_offset (0);
1375 }, 1451 0
1452 },
1453 on_visibility_change => sub {
1454 my ($self, $visible) = @_;
1455 return unless $visible;
1456 return if $self->{value};
1457 $self->set_value ("intro");
1458 0
1459 },
1376 ); 1460 );
1377 }
1378
1379 $viewer->add_paragraph ([1, 1, 0, 1], "<big>Use one of the buttons above to display a document.</big>");
1380 1461
1381 $win 1462 $win
1382} 1463}
1383 1464
1384sub sdl_init { 1465sub sdl_init {
1451 $MAPWIDGET->connect (activate_console => sub { 1532 $MAPWIDGET->connect (activate_console => sub {
1452 my ($mapwidget, $preset) = @_; 1533 my ($mapwidget, $preset) = @_;
1453 1534
1454 if ($CONSOLE) { 1535 if ($CONSOLE) {
1455 $CONSOLE->{input}->{auto_activated} = 1; 1536 $CONSOLE->{input}->{auto_activated} = 1;
1456 $CONSOLE->{input}->focus_in; 1537 $CONSOLE->{input}->grab_focus;
1457 1538
1458 if ($preset && $CONSOLE->{input}->get_text eq '') { 1539 if ($preset && $CONSOLE->{input}->get_text eq '') {
1459 $CONSOLE->{input}->set_text ($preset); 1540 $CONSOLE->{input}->set_text ($preset);
1460 } 1541 }
1461 } 1542 }
1462 }); 1543 });
1463 $MAPWIDGET->show; 1544 $MAPWIDGET->show;
1464 $MAPWIDGET->focus_in; 1545 $MAPWIDGET->grab_focus;
1465 1546
1466 $LOGVIEW = new CFClient::UI::TextView 1547 $LOGVIEW = new CFClient::UI::TextScroller
1467 expand => 1, 1548 expand => 1,
1468 font => $FONT_FIXED, 1549 font => $FONT_FIXED,
1469 fontsize => $::CFG->{log_fontsize}, 1550 fontsize => $::CFG->{log_fontsize},
1470 indent => -4, 1551 indent => -4,
1471 can_hover => 1, 1552 can_hover => 1,
1479 x => 'center', 1560 x => 'center',
1480 y => 'center', 1561 y => 'center',
1481 z => 2, 1562 z => 2,
1482 force_w => $::WIDTH * 0.6, 1563 force_w => $::WIDTH * 0.6,
1483 force_h => $::HEIGHT * 0.6, 1564 force_h => $::HEIGHT * 0.6,
1565 has_close_button => 1,
1484 ; 1566 ;
1485 1567
1486 $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,
1487 filter => new CFClient::UI::ScrolledWindow expand => 1, scroll_y => 1); 1569 filter => new CFClient::UI::ScrolledWindow expand => 1, scroll_y => 1);
1488 1570
1501 . "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. "
1502 . "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 "
1503 . "binding editor closes"); 1585 . "binding editor closes");
1504 $SETUP_NOTEBOOK->add (Spells => $SETUP_SPELLS = spell_setup, 1586 $SETUP_NOTEBOOK->add (Spells => $SETUP_SPELLS = spell_setup,
1505 "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.");
1588 $SETUP_NOTEBOOK->add (Debug => debug_setup,
1589 "Some debuggign options. Do not ask.");
1506 1590
1507 $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
1508 1592
1509 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Setup", other => $SETUP_DIALOG, 1593 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Setup", other => $SETUP_DIALOG,
1510 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.");
1525 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.",
1526 on_activate => sub { 1610 on_activate => sub {
1527 $::CFG->{layout} = CFClient::UI::get_layout; 1611 $::CFG->{layout} = CFClient::UI::get_layout;
1528 CFClient::write_cfg "$Crossfire::VARDIR/cfplusrc"; 1612 CFClient::write_cfg "$Crossfire::VARDIR/cfplusrc";
1529 status "Configuration Saved"; 1613 status "Configuration Saved";
1614 0
1530 }, 1615 },
1531 ); 1616 );
1532 1617
1533 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Help!", other => make_help_window, 1618 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Help!", other => help_window,
1534 tooltip => "View Documentation"); 1619 tooltip => "View Documentation");
1535 1620
1536 $BUTTONBAR->add (new CFClient::UI::Button 1621 $BUTTONBAR->add (new CFClient::UI::Button
1537 text => "Quit", 1622 text => "Quit",
1538 tooltip => "Terminates the program", 1623 tooltip => "Terminates the program",
1540 if ($CONN) { 1625 if ($CONN) {
1541 open_quit_dialog; 1626 open_quit_dialog;
1542 } else { 1627 } else {
1543 exit; 1628 exit;
1544 } 1629 }
1630 0
1545 }, 1631 },
1546 ); 1632 );
1547 1633
1548 $BUTTONBAR->show; 1634 $BUTTONBAR->show;
1549 $SETUP_DIALOG->show; 1635 $SETUP_DIALOG->show;
1551 1637
1552 $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]);
1553} 1639}
1554 1640
1555sub video_shutdown { 1641sub video_shutdown {
1642 CFClient::OpenGL::shutdown;
1643
1556 undef $SDL_ACTIVE; 1644 undef $SDL_ACTIVE;
1557} 1645}
1558 1646
1559my @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#
1560my $bgmusic;#TODO#hack#d# 1648my $bgmusic;#TODO#hack#d#
1856 video_init; 1944 video_init;
1857 audio_init; 1945 audio_init;
1858} 1946}
1859 1947
1860Event::loop; 1948Event::loop;
1949#CFClient::SDL_Quit;
1950#CFClient::_exit 0;
1861 1951
1862END { CFClient::SDL_Quit } 1952END { CFClient::SDL_Quit }
1863 1953
1864=head1 NAME 1954=head1 NAME
1865 1955

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines