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.61 by root, Tue Jun 6 03:05:16 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}
846 868
847 utf8::decode $buf if utf8::valid $buf; 869 utf8::decode $buf if utf8::valid $buf;
848 870
849 $table->clear; 871 $table->clear;
850 872
873 my @tip = (
874 "The current number of users logged in on the server.",
875 "The hostname of the server.",
876 "The time this server has been running without being restarted.",
877 "The server software version - a '+' indicates a Crossfire+ server.",
878 "Short information about this server provided by its admins.",
879 );
851 my @col = qw(Use #Users Host Uptime Version Description); 880 my @col = qw(#Users Host Uptime Version Description);
852 $table->add ($_, 0, new CFClient::UI::Label align => 0, fg => [1, 1, 0], text => $col[$_]) 881 $table->add ($_, 0, new CFClient::UI::Label
882 can_hover => 1, can_events => 1,
883 align => 0, fg => [1, 1, 0],
884 text => $col[$_], tooltip => $tip[$_])
853 for 0 .. $#col; 885 for 0 .. $#col;
854 886
855 my @align = qw(1 0 1 1 -1); 887 my @align = qw(1 0 1 1 -1);
856 888
857 my $y = 0; 889 my $y = 0;
858 for my $m (sort { $b->[3] <=> $a->[3] } map [split /\|/], split /\015?\012/, $buf) { 890 for my $m (sort { $b->[3] <=> $a->[3] } map [split /\|/], split /\015?\012/, $buf) {
875 907
876 $m = [$users, $host, $uptime, $version, $desc]; 908 $m = [$users, $host, $uptime, $version, $desc];
877 909
878 $y++; 910 $y++;
879 911
880 $table->add (0, $y, new CFClient::UI::VBox children => [ 912 $table->add (scalar @$m, $y, new CFClient::UI::VBox children => [
881 (new CFClient::UI::Button text => "Use", on_activate => sub { 913 (new CFClient::UI::Button
914 text => "Use",
915 tooltip => "Put this server into the <b>Host:Port</b> field",
916 on_activate => sub {
882 $HOST_ENTRY->set_text ($CFG->{host} = $host); 917 $HOST_ENTRY->set_text ($CFG->{host} = $host);
883 $METASERVER->toggle_visibility; 918 $METASERVER->hide;
919 0
920 },
884 }), 921 ),
885 (new CFClient::UI::Empty expand => 1), 922 (new CFClient::UI::Empty expand => 1),
886 ]); 923 ]);
887 924
888 $table->add ($_ + 1, $y, new CFClient::UI::Label 925 $table->add ($_, $y, new CFClient::UI::Label
889 ellipsise => 0, align => $align[$_], text => $m->[$_], fontsize => 0.8) 926 ellipsise => 0,
927 align => $align[$_],
928 text => $m->[$_],
929 tooltip => $tip[$_],
930 can_hover => 1,
931 can_events => 1,
932 fontsize => 0.8)
890 for 0 .. $#$m; 933 for 0 .. $#$m;
891 } 934 }
892 } 935 }
893 }); 936 });
894} 937}
895 938
896sub metaserver_dialog { 939sub metaserver_dialog {
897 my $dialog = new CFClient::UI::FancyFrame 940 my $dialog = new CFClient::UI::FancyFrame
898 title => "Server List", 941 title => "Server List",
899 name => 'metaserver_dialog', 942 name => 'metaserver_dialog',
900 x => 'center', 943 x => 'center',
901 y => 'center', 944 y => 'center',
902 z => 3, 945 z => 3,
946 force_h => $::HEIGHT * 0.4,
903 child => (my $vbox = new CFClient::UI::VBox), 947 child => (my $vbox = new CFClient::UI::VBox),
904 on_visibility_change => sub { 948 on_visibility_change => sub {
905 update_metaserver if $_[1]; 949 update_metaserver if $_[1];
950 0
906 }, 951 },
907 ; 952 ;
908 953
909 $vbox->add ($dialog->{table} = new CFClient::UI::Table); 954 $dialog->{table} = new CFClient::UI::Table;
955
956 $vbox->add (new CFClient::UI::ScrolledWindow expand => 1, child => $dialog->{table});
910 957
911 $dialog 958 $dialog
912} 959}
913 960
914sub server_setup { 961sub server_setup {
926 text => $CFG->{host}, 973 text => $CFG->{host},
927 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",
928 on_changed => sub { 975 on_changed => sub {
929 my ($self, $value) = @_; 976 my ($self, $value) = @_;
930 $CFG->{host} = $value; 977 $CFG->{host} = $value;
978 0
931 } 979 }
932 ); 980 );
933 981
934 $METASERVER = metaserver_dialog; 982 $METASERVER = metaserver_dialog;
935 983
936 $vbox->add (new CFClient::UI::Button 984 $vbox->add (new CFClient::UI::Button
937 expand => 1, 985 expand => 1,
938 text => "Server List", 986 text => "Server List",
939 other => $METASERVER, 987 other => $METASERVER,
940 tooltip => "Show a list of available crossfire servers", 988 tooltip => "Show a list of available crossfire servers",
941 on_activate => sub { $METASERVER->toggle_visibility }, 989 on_activate => sub { $METASERVER->toggle_visibility; 0 },
990 on_visibility_change => sub { $METASERVER->hide unless $_[1]; 0 },
942 ); 991 );
943 } 992 }
944 993
945 $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");
946 $table->add (1, 4, new CFClient::UI::Entry 995 $table->add (1, 4, new CFClient::UI::Entry
947 text => $CFG->{user}, 996 text => $CFG->{user},
948 tooltip => "The name of your character on the server", 997 tooltip => "The name of your character on the server",
949 on_changed => sub { 998 on_changed => sub { my ($self, $value) = @_; $CFG->{user} = $value; 0 }
950 my ($self, $value) = @_;
951 $CFG->{user} = $value;
952 }
953 ); 999 );
954 1000
955 $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");
956 $table->add (1, 5, new CFClient::UI::Entry 1002 $table->add (1, 5, new CFClient::UI::Entry
957 text => $CFG->{password}, 1003 text => $CFG->{password},
958 hidden => 1, 1004 hidden => 1,
959 tooltip => "The password for your character", 1005 tooltip => "The password for your character",
960 on_changed => sub { 1006 on_changed => sub { my ($self, $value) = @_; $CFG->{password} = $value; 0 }
961 my ($self, $value) = @_;
962 $CFG->{password} = $value;
963 }
964 ); 1007 );
965 1008
966 $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");
967 $table->add (1, 7, new CFClient::UI::Slider 1010 $table->add (1, 7, new CFClient::UI::Slider
968 force_w => 100, 1011 force_w => 100,
969 range => [$CFG->{mapsize}, 10, 100, 0, 1], 1012 range => [$CFG->{mapsize}, 10, 100, 0, 1],
970 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. "
971 . "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, "
972 . "but you also increase bandwidth requirements and latency. " 1015 . "but you also increase bandwidth requirements and latency. "
973 . "This option is only used once at log-in.", 1016 . "This option is only used once at log-in.",
974 on_changed => sub { 1017 on_changed => sub { my ($self, $value) = @_; $CFG->{mapsize} = $self->{range}[0] = $value = int $value; 0 },
975 my ($self, $value) = @_;
976
977 $CFG->{mapsize} = $self->{range}[0] = $value = int $value;
978 },
979 ); 1018 );
980 1019
981 $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");
982 $table->add (1, 8, new CFClient::UI::CheckBox 1021 $table->add (1, 8, new CFClient::UI::CheckBox
983 state => $CFG->{face_prefetch}, 1022 state => $CFG->{face_prefetch},
986 . "This might increase or create lag, but increases the chances " 1025 . "This might increase or create lag, but increases the chances "
987 . "of faces being ready for display when you encounter them. " 1026 . "of faces being ready for display when you encounter them. "
988 . "It also uses up server bandwidth on every connect, " 1027 . "It also uses up server bandwidth on every connect, "
989 . "so only set it if you really need to prefetch images. " 1028 . "so only set it if you really need to prefetch images. "
990 . "This option can be set and unset any time.", 1029 . "This option can be set and unset any time.",
991 on_changed => sub { $CFG->{face_prefetch} = $_[1] }, 1030 on_changed => sub { $CFG->{face_prefetch} = $_[1]; 0 },
992 ); 1031 );
993 1032
994 $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");
995 $table->add (1, 9, new CFClient::UI::Entry 1034 $table->add (1, 9, new CFClient::UI::Entry
996 text => $CFG->{output_count}, 1035 text => $CFG->{output_count},
997 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.",
998 on_changed => sub { $CFG->{output_count} = $_[1] }, 1037 on_changed => sub { $CFG->{output_count} = $_[1]; 0 },
999 ); 1038 );
1000 1039
1001 $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");
1002 $table->add (1, 10, new CFClient::UI::Entry 1041 $table->add (1, 10, new CFClient::UI::Entry
1003 text => $CFG->{output_sync}, 1042 text => $CFG->{output_sync},
1004 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.",
1005 on_changed => sub { $CFG->{output_sync} = $_[1] }, 1044 on_changed => sub { $CFG->{output_sync} = $_[1]; 0 },
1006 ); 1045 );
1007 1046
1008 $table->add (1, 11, $LOGIN_BUTTON = new CFClient::UI::Button 1047 $table->add (1, 11, $LOGIN_BUTTON = new CFClient::UI::Button
1009 expand => 1, 1048 expand => 1,
1010 align => 0, 1049 align => 0,
1011 text => "Login", 1050 text => "Login",
1012 on_activate => sub { 1051 on_activate => sub {
1013 $CONN ? stop_game 1052 $CONN ? stop_game
1014 : start_game; 1053 : start_game;
1054 0
1015 }, 1055 },
1016 ); 1056 );
1017 1057
1018 $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");
1019 $table->add (1, 12, my $saycmd = new CFClient::UI::Entry 1059 $table->add (1, 12, my $saycmd = new CFClient::UI::Entry
1022 . "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. "
1023 . "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.",
1024 on_changed => sub { 1064 on_changed => sub {
1025 my ($self, $value) = @_; 1065 my ($self, $value) = @_;
1026 $CFG->{say_command} = $value; 1066 $CFG->{say_command} = $value;
1067 0
1027 } 1068 }
1028 ); 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);
1029 1079
1030 $vbox 1080 $vbox
1031} 1081}
1032 1082
1033sub message_window { 1083sub message_window {
1038 bg => [0, 0, 0, 0.75], 1088 bg => [0, 0, 0, 0.75],
1039 x => "max", 1089 x => "max",
1040 y => 0, 1090 y => 0,
1041 force_w => $::WIDTH * 0.4, 1091 force_w => $::WIDTH * 0.4,
1042 force_h => $::HEIGHT * 0.5, 1092 force_h => $::HEIGHT * 0.5,
1043 child => (my $vbox = new CFClient::UI::VBox); 1093 child => (my $vbox = new CFClient::UI::VBox),
1094 has_close_button => 1;
1044 1095
1045 $vbox->add ($LOGVIEW); 1096 $vbox->add ($LOGVIEW);
1046 1097
1047 $vbox->add (my $input = new CFClient::UI::Entry 1098 $vbox->add (my $input = new CFClient::UI::Entry
1048 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> "
1056 1107
1057 if ($prev_focus == $MAPWIDGET && $input->{auto_activated}) { 1108 if ($prev_focus == $MAPWIDGET && $input->{auto_activated}) {
1058 $input->{refocus_map} = 1; 1109 $input->{refocus_map} = 1;
1059 } 1110 }
1060 delete $input->{auto_activated}; 1111 delete $input->{auto_activated};
1112
1113 0
1061 }, 1114 },
1062 on_activate => sub { 1115 on_activate => sub {
1063 my ($input, $text) = @_; 1116 my ($input, $text) = @_;
1064 $input->set_text (''); 1117 $input->set_text ('');
1065 1118
1071 } 1124 }
1072 if ($input->{refocus_map}) { 1125 if ($input->{refocus_map}) {
1073 delete $input->{refocus_map}; 1126 delete $input->{refocus_map};
1074 $MAPWIDGET->focus_in 1127 $MAPWIDGET->focus_in
1075 } 1128 }
1129
1130 0
1076 }, 1131 },
1077 on_escape => sub { 1132 on_escape => sub {
1078 $MAPWIDGET->focus_in 1133 $MAPWIDGET->grab_focus;
1134
1135 0
1079 }, 1136 },
1080 ); 1137 );
1081 1138
1082 $CONSOLE = { 1139 $CONSOLE = {
1083 window => $window, 1140 window => $window,
1105 ); 1162 );
1106 $vb->add (my $hb = new CFClient::UI::HBox expand => 1); 1163 $vb->add (my $hb = new CFClient::UI::HBox expand => 1);
1107 $hb->add (new CFClient::UI::Button 1164 $hb->add (new CFClient::UI::Button
1108 text => "Ok", 1165 text => "Ok",
1109 expand => 1, 1166 expand => 1,
1110 on_activate => sub { $QUIT_DIALOG->hide }, 1167 on_activate => sub { $QUIT_DIALOG->hide; 0 },
1111 ); 1168 );
1112 $hb->add (new CFClient::UI::Button 1169 $hb->add (new CFClient::UI::Button
1113 text => "Quit anyway", 1170 text => "Quit anyway",
1114 expand => 1, 1171 expand => 1,
1115 on_activate => sub { exit }, 1172 on_activate => sub { exit },
1158 ["Potions" => PICKUP_POTION], 1215 ["Potions" => PICKUP_POTION],
1159 ["Magic Devices" => PICKUP_MAGIC_DEVICE], 1216 ["Magic Devices" => PICKUP_MAGIC_DEVICE],
1160 ["Ignore cursed" => PICKUP_NOT_CURSED], 1217 ["Ignore cursed" => PICKUP_NOT_CURSED],
1161 ["Jewelery" => PICKUP_JEWELS], 1218 ["Jewelery" => PICKUP_JEWELS],
1162 ], 1219 ],
1220 ["Weight/Value ratio", 2, 17]
1163 ) 1221 )
1164 { 1222 {
1165 my ($title, $x, $y, @bits) = @$_; 1223 my ($title, $x, $y, @bits) = @$_;
1166 $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]);
1167 1225
1172 $table->add ($x , $y, new CFClient::UI::Label text => $_->[0], align => 1, expand => 1); 1230 $table->add ($x , $y, new CFClient::UI::Label text => $_->[0], align => 1, expand => 1);
1173 $table->add ($x+1, $y, new CFClient::UI::CheckBox 1231 $table->add ($x+1, $y, new CFClient::UI::CheckBox
1174 state => $CFG->{pickup} & $mask, 1232 state => $CFG->{pickup} & $mask,
1175 on_changed => sub { 1233 on_changed => sub {
1176 my ($box, $value) = @_; 1234 my ($box, $value) = @_;
1235
1177 if ($value) { 1236 if ($value) {
1178 $::CFG->{pickup} |= $mask; 1237 $::CFG->{pickup} |= $mask;
1179 } else { 1238 } else {
1180 $::CFG->{pickup} = $::CFG->{pickup} & ~$mask; 1239 $::CFG->{pickup} &= ~$mask;
1181 } 1240 }
1241
1182 $::CONN->send (sprintf "command pickup %u", $::CFG->{pickup}) 1242 $::CONN->send_command ("pickup $::CFG->{pickup}")
1183 if defined $::CONN; 1243 if defined $::CONN;
1244
1245 0
1184 }); 1246 });
1185 } 1247 }
1186 } 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 });
1187 1268
1188 $table 1269 $table
1189} 1270}
1190 1271
1191sub inventory_window { 1272sub inventory_window {
1193 x => "center", 1274 x => "center",
1194 y => "center", 1275 y => "center",
1195 force_w => $WIDTH * 9/10, 1276 force_w => $WIDTH * 9/10,
1196 force_h => $HEIGHT * 9/10, 1277 force_h => $HEIGHT * 9/10,
1197 title => "Inventory", 1278 title => "Inventory",
1279 has_close_button => 1,
1198 ; 1280 ;
1199 1281
1200 $invwin->add (my $hb = new CFClient::UI::HBox homogeneous => 1); 1282 $invwin->add (my $hb = new CFClient::UI::HBox homogeneous => 1);
1201 1283
1202 $hb->add (my $vb1 = new CFClient::UI::VBox); 1284 $hb->add (my $vb1 = new CFClient::UI::VBox);
1238 text => "delete", 1320 text => "delete",
1239 tooltip => "Deletes the binding", 1321 tooltip => "Deletes the binding",
1240 on_activate => sub { 1322 on_activate => sub {
1241 $binding_list->remove ($hb); 1323 $binding_list->remove ($hb);
1242 delete $::CFG->{bindings}->{$mod}->{$sym}; 1324 delete $::CFG->{bindings}->{$mod}->{$sym};
1325 0
1243 }); 1326 });
1244 1327
1245 $hb->add (new CFClient::UI::Button 1328 $hb->add (new CFClient::UI::Button
1246 text => "edit", 1329 text => "edit",
1247 tooltip => "Edits the binding", 1330 tooltip => "Edits the binding",
1260 $SETUP_NOTEBOOK->set_current_page ($SETUP_KEYBOARD); 1343 $SETUP_NOTEBOOK->set_current_page ($SETUP_KEYBOARD);
1261 $SETUP_DIALOG->show; 1344 $SETUP_DIALOG->show;
1262 }); 1345 });
1263 $::BIND_EDITOR->show; 1346 $::BIND_EDITOR->show;
1264 $SETUP_DIALOG->hide; 1347 $SETUP_DIALOG->hide;
1348 0
1265 }); 1349 });
1266 1350
1267 $hb->add (new CFClient::UI::Label text => "(Key: $nam)"); 1351 $hb->add (new CFClient::UI::Label text => "(Key: $nam)");
1268 $hb->add (new CFClient::UI::Label text => $lbl, expand => 1); 1352 $hb->add (new CFClient::UI::Label text => $lbl, expand => 1);
1269 } 1353 }
1270 } 1354 }
1271 }; 1355 };
1272 1356
1273 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
1274 $vb->add ($binding_list); 1370 $vb->add ($binding_list);
1275 $vb->add (my $hb = new CFClient::UI::HBox); 1371 $vb->add (my $hb = new CFClient::UI::HBox);
1276 1372
1277 $hb->add (new CFClient::UI::Button 1373 $hb->add (new CFClient::UI::Button
1278 text => "record new", 1374 text => "record new",
1292 $SETUP_DIALOG->show; 1388 $SETUP_DIALOG->show;
1293 }, 1389 },
1294 ); 1390 );
1295 $SETUP_DIALOG->hide; 1391 $SETUP_DIALOG->hide;
1296 $::BIND_EDITOR->show; 1392 $::BIND_EDITOR->show;
1393 0
1297 }, 1394 },
1298 ); 1395 );
1299 1396
1300 $hb->add (new CFClient::UI::Button 1397 $hb->add (new CFClient::UI::Button
1301 text => "close", 1398 text => "close",
1302 tooltip => "Closes the binding window", 1399 tooltip => "Closes the binding window",
1303 expand => 1, 1400 expand => 1,
1304 on_activate => sub { 1401 on_activate => sub {
1305 $SETUP_DIALOG->hide; 1402 $SETUP_DIALOG->hide;
1403 0
1306 } 1404 }
1307 ); 1405 );
1308 1406
1309 $refresh->(); 1407 $refresh->();
1310 1408
1311 $vb 1409 $vb
1312} 1410}
1313 1411
1314sub make_help_window { 1412sub help_window {
1315 my $win = new CFClient::UI::FancyFrame 1413 my $win = new CFClient::UI::FancyFrame
1316 x => 'center', 1414 x => 'center',
1317 y => 'center', 1415 y => 'center',
1318 z => 2, 1416 z => 2,
1319 name => 'doc_browser', 1417 name => 'doc_browser',
1322 title => "Documentation"; 1420 title => "Documentation";
1323 1421
1324 $win->add (my $vbox = new CFClient::UI::VBox); 1422 $win->add (my $vbox = new CFClient::UI::VBox);
1325 1423
1326 $vbox->add (my $buttons = new CFClient::UI::HBox); 1424 $vbox->add (my $buttons = new CFClient::UI::HBox);
1327 $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);
1328 1427
1329 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 => [
1330 [intro => "Introduction"], 1432 [intro => "Introduction"],
1331 [manual => "Manual"], 1433 [manual => "Manual"],
1434 [skill_help => "Skills"],
1332 [command_help => "Commands"], 1435 [command_help => "Commands"],
1333 [skill_help => "Skills"], 1436 [dmcommand_help => "DM Commands"],
1334 ) { 1437 [COPYING => "License Terms"],
1335 my ($pod, $label) = @$_; 1438 ],
1439 on_changed => sub {
1440 my ($self, $pod) = @_;
1336 1441
1337 $buttons->add (new CFClient::UI::Button
1338 text => $label,
1339 on_activate => sub {
1340 my $pom = CFClient::load_pod CFClient::find_rcfile "pod/$pod.pod", 1442 my $pom = CFClient::load_pod CFClient::find_rcfile "pod/$pod.pod",
1341 doc_viewer => 1, sub { CFClient::pod_to_pango_list $_[0] }; 1443 doc_viewer => 1, sub { CFClient::pod_to_pango_list $_[0] };
1342 1444
1343 $viewer->clear; 1445 $viewer->clear;
1344 1446
1345 $viewer->add_paragraph ([1, 1, 1, 1], $_->[1], $_->[0]) 1447 $viewer->add_paragraph ([1, 1, 1, 1], $_->[1], $_->[0])
1346 for @$pom; 1448 for @$pom;
1347 1449
1348 $viewer->set_offset (0); 1450 $viewer->set_offset (0);
1349 }, 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 },
1350 ); 1460 );
1351 }
1352
1353 $viewer->add_paragraph ([1, 1, 0, 1], "<big>Use one of the buttons above to display a document.</big>");
1354 1461
1355 $win 1462 $win
1356} 1463}
1357 1464
1358sub sdl_init { 1465sub sdl_init {
1425 $MAPWIDGET->connect (activate_console => sub { 1532 $MAPWIDGET->connect (activate_console => sub {
1426 my ($mapwidget, $preset) = @_; 1533 my ($mapwidget, $preset) = @_;
1427 1534
1428 if ($CONSOLE) { 1535 if ($CONSOLE) {
1429 $CONSOLE->{input}->{auto_activated} = 1; 1536 $CONSOLE->{input}->{auto_activated} = 1;
1430 $CONSOLE->{input}->focus_in; 1537 $CONSOLE->{input}->grab_focus;
1431 1538
1432 if ($preset && $CONSOLE->{input}->get_text eq '') { 1539 if ($preset && $CONSOLE->{input}->get_text eq '') {
1433 $CONSOLE->{input}->set_text ($preset); 1540 $CONSOLE->{input}->set_text ($preset);
1434 } 1541 }
1435 } 1542 }
1436 }); 1543 });
1437 $MAPWIDGET->show; 1544 $MAPWIDGET->show;
1438 $MAPWIDGET->focus_in; 1545 $MAPWIDGET->grab_focus;
1439 1546
1440 $LOGVIEW = new CFClient::UI::TextView 1547 $LOGVIEW = new CFClient::UI::TextScroller
1441 expand => 1, 1548 expand => 1,
1442 font => $FONT_FIXED, 1549 font => $FONT_FIXED,
1443 fontsize => $::CFG->{log_fontsize}, 1550 fontsize => $::CFG->{log_fontsize},
1444 indent => -4, 1551 indent => -4,
1445 can_hover => 1, 1552 can_hover => 1,
1453 x => 'center', 1560 x => 'center',
1454 y => 'center', 1561 y => 'center',
1455 z => 2, 1562 z => 2,
1456 force_w => $::WIDTH * 0.6, 1563 force_w => $::WIDTH * 0.6,
1457 force_h => $::HEIGHT * 0.6, 1564 force_h => $::HEIGHT * 0.6,
1565 has_close_button => 1,
1458 ; 1566 ;
1459 1567
1460 $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,
1461 filter => new CFClient::UI::ScrolledWindow expand => 1, scroll_y => 1); 1569 filter => new CFClient::UI::ScrolledWindow expand => 1, scroll_y => 1);
1462 1570
1475 . "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. "
1476 . "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 "
1477 . "binding editor closes"); 1585 . "binding editor closes");
1478 $SETUP_NOTEBOOK->add (Spells => $SETUP_SPELLS = spell_setup, 1586 $SETUP_NOTEBOOK->add (Spells => $SETUP_SPELLS = spell_setup,
1479 "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.");
1480 1590
1481 $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
1482 1592
1483 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Setup", other => $SETUP_DIALOG, 1593 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Setup", other => $SETUP_DIALOG,
1484 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.");
1499 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.",
1500 on_activate => sub { 1610 on_activate => sub {
1501 $::CFG->{layout} = CFClient::UI::get_layout; 1611 $::CFG->{layout} = CFClient::UI::get_layout;
1502 CFClient::write_cfg "$Crossfire::VARDIR/cfplusrc"; 1612 CFClient::write_cfg "$Crossfire::VARDIR/cfplusrc";
1503 status "Configuration Saved"; 1613 status "Configuration Saved";
1614 0
1504 }, 1615 },
1505 ); 1616 );
1506 1617
1507 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Help!", other => make_help_window, 1618 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Help!", other => help_window,
1508 tooltip => "View Documentation"); 1619 tooltip => "View Documentation");
1509 1620
1510 $BUTTONBAR->add (new CFClient::UI::Button 1621 $BUTTONBAR->add (new CFClient::UI::Button
1511 text => "Quit", 1622 text => "Quit",
1512 tooltip => "Terminates the program", 1623 tooltip => "Terminates the program",
1514 if ($CONN) { 1625 if ($CONN) {
1515 open_quit_dialog; 1626 open_quit_dialog;
1516 } else { 1627 } else {
1517 exit; 1628 exit;
1518 } 1629 }
1630 0
1519 }, 1631 },
1520 ); 1632 );
1521 1633
1522 $BUTTONBAR->show; 1634 $BUTTONBAR->show;
1523 $SETUP_DIALOG->show; 1635 $SETUP_DIALOG->show;
1525 1637
1526 $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]);
1527} 1639}
1528 1640
1529sub video_shutdown { 1641sub video_shutdown {
1642 CFClient::OpenGL::shutdown;
1643
1530 undef $SDL_ACTIVE; 1644 undef $SDL_ACTIVE;
1531} 1645}
1532 1646
1533my @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#
1534my $bgmusic;#TODO#hack#d# 1648my $bgmusic;#TODO#hack#d#
1773 bgm_enable => 1, 1887 bgm_enable => 1,
1774 bgm_volume => 0.25, 1888 bgm_volume => 0.25,
1775 face_prefetch => 0, 1889 face_prefetch => 0,
1776 output_sync => 1, 1890 output_sync => 1,
1777 output_count => 1, 1891 output_count => 1,
1892 pickup => 0,
1778 ); 1893 );
1779 1894
1780 while (my ($k, $v) = each %DEF_CFG) { 1895 while (my ($k, $v) = each %DEF_CFG) {
1781 $CFG->{$k} = $v unless exists $CFG->{$k}; 1896 $CFG->{$k} = $v unless exists $CFG->{$k};
1782 } 1897 }
1829 video_init; 1944 video_init;
1830 audio_init; 1945 audio_init;
1831} 1946}
1832 1947
1833Event::loop; 1948Event::loop;
1949#CFClient::SDL_Quit;
1950#CFClient::_exit 0;
1834 1951
1835END { CFClient::SDL_Quit } 1952END { CFClient::SDL_Quit }
1836 1953
1837=head1 NAME 1954=head1 NAME
1838 1955

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines