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

Comparing deliantra/Deliantra-Client/bin/deliantra (file contents):
Revision 1.5 by root, Wed Nov 14 23:50:29 2007 UTC vs.
Revision 1.18 by root, Wed Dec 26 21:03:21 2007 UTC

1#!/opt/bin/perl 1#!/opt/bin/perl
2
3if ($ENV{DELIANTRA_CORO_DEBUG}) {
4 eval '
5 use Coro;
6 use Coro::EV;
7 use Coro::Debug;
8 our $debug = new_unix_server Coro::Debug "/tmp/dc";
9 ';
10}
2 11
3# do splash-screen thingy on win32 12# do splash-screen thingy on win32
4my $startup_done = sub { }; 13my $startup_done = sub { };
5BEGIN { 14BEGIN {
6 if (%PAR::LibCache && $^O eq "MSWin32") { 15 if (%PAR::LibCache && $^O eq "MSWin32") {
66 75
67 unshift @INC, $root; 76 unshift @INC, $root;
68 } 77 }
69} 78}
70 79
80# prepend private library directory
81BEGIN {
82 for (grep !ref, @INC) {
83 my $path = "$_/Deliantra/Client/private/dc";
84 if (-d $path) {
85 unshift @INC, $path;
86 last;
87 }
88 }
89}
90
71# need to do it again because that pile of garbage called PAR nukes it before main 91# need to do it again because that pile of garbage called PAR nukes it before main
72unshift @INC, $ENV{PAR_TEMP} 92unshift @INC, $ENV{PAR_TEMP}
73 if %PAR::LibCache; 93 if %PAR::LibCache;
74 94
75use Time::HiRes 'time'; 95use Time::HiRes 'time';
76use EV; 96use EV;
77use List::Util qw(max min); 97use List::Util qw(max min);
78 98
79use Crossfire; 99use Deliantra;
80use Crossfire::Protocol::Constants; 100use Deliantra::Protocol::Constants;
81 101
82use Compress::LZF; 102use Compress::LZF;
83 103
84use CFPlus; 104use DC;
85use CFPlus::OpenGL (); 105use DC::OpenGL ();
86use CFPlus::Protocol; 106use DC::Protocol;
87use CFPlus::DB; 107use DC::DB;
88use CFPlus::UI; 108use DC::UI;
89use CFPlus::UI::Canvas; 109use DC::UI::Canvas;
90use CFPlus::UI::Inventory; 110use DC::UI::Inventory;
91use CFPlus::UI::SpellList; 111use DC::UI::SpellList;
92use CFPlus::UI::Dockable; 112use DC::UI::Dockable;
93use CFPlus::UI::MessageWindow; 113use DC::UI::MessageWindow;
94use CFPlus::UI::ChatView; 114use DC::UI::ChatView;
95use CFPlus::Pod; 115use DC::Pod;
96use CFPlus::MapWidget; 116use DC::MapWidget;
97use CFPlus::Macro; 117use DC::Macro;
98 118
99$SIG{QUIT} = sub { Carp::cluck "QUIT" }; 119$SIG{QUIT} = sub { Carp::cluck "QUIT" };
100$SIG{PIPE} = 'IGNORE'; 120$SIG{PIPE} = 'IGNORE';
101 121
102$EV::DIED = sub { 122$EV::DIED = sub {
103 CFPlus::fatal Carp::longmess $@; 123 DC::fatal Carp::longmess $@;
104}; 124};
105 125
106my $MAX_FPS = 60; 126my $MAX_FPS = 60;
107my $MIN_FPS = 5; # unused as of yet 127my $MIN_FPS = 5; # unused as of yet
108 128
177our $INVR_HB; 197our $INVR_HB;
178 198
179############################################################################# 199#############################################################################
180 200
181sub status { 201sub status {
182 $STATUSBOX->add (CFPlus::asxml $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); 202 $STATUSBOX->add (DC::asxml $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]);
183} 203}
184 204
185sub debug { 205sub debug {
186 $DEBUG_STATUS->set_text ($_[0]); 206 $DEBUG_STATUS->set_text ($_[0]);
187} 207}
225 245
226 if (my $chunk = $AUDIO_CHUNK{$face}) { 246 if (my $chunk = $AUDIO_CHUNK{$face}) {
227 for (grep $_->[0] >= EV::now, @{(delete $AUDIO_PLAY{$face}) || []}) { 247 for (grep $_->[0] >= EV::now, @{(delete $AUDIO_PLAY{$face}) || []}) {
228 my (undef, $dx, $dy, $vol) = @$_; 248 my (undef, $dx, $dy, $vol) = @$_;
229 249
230 my $channel = CFPlus::Channel::find; 250 my $channel = DC::Channel::find;
231 $channel->volume ($vol * $CFG->{effects_volume} * 128 / 255); 251 $channel->volume ($vol * $CFG->{effects_volume} * 128 / 255);
232 $channel->set_position_r ($dx, $dy, 20); 252 $channel->set_position_r ($dx, $dy, 20);
233 $chunk->play ($channel); 253 $chunk->play ($channel);
234 } 254 }
235 } else { 255 } else {
246 push @MUSIC_JINGLE, $meta; # push it oto the music/jingle queue 266 push @MUSIC_JINGLE, $meta; # push it oto the music/jingle queue
247 &audio_music_push ($face); 267 &audio_music_push ($face);
248 } 268 }
249 } else { 269 } else {
250 # fetch from database 270 # fetch from database
251 CFPlus::DB::get res_data => $meta->{name}, sub { 271 DC::DB::get res_data => $meta->{name}, sub {
252 my $rwops = new CFPlus::RW $_[0]; 272 my $rwops = new DC::RW $_[0];
253 my $chunk = new CFPlus::MixChunk $rwops 273 my $chunk = new DC::MixChunk $rwops
254 or Carp::confess "sound face " . (JSON::XS::to_json $meta) . " unloadable: " . CFPlus::Mix_GetError; 274 or Carp::confess "sound face " . (JSON::XS::encode_json $meta) . " unloadable: " . DC::Mix_GetError;
255 $chunk->volume (($meta->{data}{volume} || 1) * 128); 275 $chunk->volume (($meta->{data}{volume} || 1) * 128);
256 $AUDIO_CHUNK{$face} = $chunk; 276 $AUDIO_CHUNK{$face} = $chunk;
257 277
258 audio_sound_push ($face); 278 audio_sound_push ($face);
259 }; 279 };
278sub audio_music_set_meta { 298sub audio_music_set_meta {
279 my ($meta) = @_; 299 my ($meta) = @_;
280 300
281 $MUSIC_PLAYING_META = $meta; 301 $MUSIC_PLAYING_META = $meta;
282 $MUSIC_PLAYING_WIDGET->set_markup ( 302 $MUSIC_PLAYING_WIDGET->set_markup (
283 "<b>Name</b>: " . (CFPlus::asxml $meta->{data}{name}) . "\n" 303 "<b>Name</b>: " . (DC::asxml $meta->{data}{name}) . "\n"
284 . "<b>Author</b>: " . (CFPlus::asxml $meta->{data}{author}) . "\n" 304 . "<b>Author</b>: " . (DC::asxml $meta->{data}{author}) . "\n"
285 . "<b>Source</b>: " . (CFPlus::asxml $meta->{data}{source}) . "\n" 305 . "<b>Source</b>: " . (DC::asxml $meta->{data}{source}) . "\n"
286 . "<b>License</b>: " . (CFPlus::asxml $meta->{data}{license}) 306 . "<b>License</b>: " . (DC::asxml $meta->{data}{license})
287 ); 307 );
288} 308}
289 309
290sub audio_music_update_volume { 310sub audio_music_update_volume {
291 return unless $MUSIC_PLAYING_META; 311 return unless $MUSIC_PLAYING_META;
292 my $volume = $MUSIC_PLAYING_META->{data}{volume} || 1; 312 my $volume = $MUSIC_PLAYING_META->{data}{volume} || 1;
293 my $base = $MUSIC_PLAYING_META->{data}{jingle} ? 1 : $CFG->{bgm_volume}; 313 my $base = $MUSIC_PLAYING_META->{data}{jingle} ? 1 : $CFG->{bgm_volume};
294 CFPlus::MixMusic::volume $base * $volume * 128; 314 DC::MixMusic::volume $base * $volume * 128;
295} 315}
296 316
297sub audio_music_start { 317sub audio_music_start {
298 my $meta = $MUSIC_PLAYING_META; 318 my $meta = $MUSIC_PLAYING_META;
299 319
300 CFPlus::DB::get res_data => $meta->{name}, sub { 320 DC::DB::get res_data => $meta->{name}, sub {
301 return unless $SDL_MIXER; 321 return unless $SDL_MIXER;
302 322
303 # music might have changed... 323 # music might have changed...
304 $meta eq $MUSIC_PLAYING_META 324 $meta eq $MUSIC_PLAYING_META
305 or return &audio_music_start (); 325 or return &audio_music_start ();
307 audio_music_update_volume; 327 audio_music_update_volume;
308 328
309 $MUSIC_PLAYING_DATA = \$_[0]; 329 $MUSIC_PLAYING_DATA = \$_[0];
310 330
311 my $rwops = $meta->{path} 331 my $rwops = $meta->{path}
312 ? new_from_file CFPlus::RW $meta->{path} 332 ? new_from_file DC::RW $meta->{path}
313 : new CFPlus::RW $$MUSIC_PLAYING_DATA; 333 : new DC::RW $$MUSIC_PLAYING_DATA;
314 334
315 $MUSIC_PLAYER = new CFPlus::MixMusic $rwops 335 $MUSIC_PLAYER = new DC::MixMusic $rwops
316 or Carp::confess "music face $meta->{face} unloadable: " . CFPlus::Mix_GetError; 336 or Carp::confess "music face $meta->{face} unloadable: " . DC::Mix_GetError;
317 337
318 my $NOW = time; 338 my $NOW = time;
319 339
320 if ($MUSIC_PLAYING_META->{stop_time} > $NOW - $MUSIC_RESUME) { 340 if ($MUSIC_PLAYING_META->{stop_time} > $NOW - $MUSIC_RESUME) {
321 my $pos = $MUSIC_PLAYING_META->{stop_pos}; 341 my $pos = $MUSIC_PLAYING_META->{stop_pos};
335 return unless $SDL_MIXER; 355 return unless $SDL_MIXER;
336 356
337 my $fade_out; 357 my $fade_out;
338 358
339 if (@MUSIC_JINGLE) { 359 if (@MUSIC_JINGLE) {
360 $fade_out = 333;
340 @MUSIC_HAVE = $MUSIC_JINGLE[0]; 361 @MUSIC_HAVE = $MUSIC_JINGLE[0];
341 $fade_out = 333; 362
342 } else { 363 } else {
343 return unless $CFG->{bgm_enable}; 364 return unless $CFG->{bgm_enable};
344 365
345 my @have = 366 $fade_out = 700;
367
368 @MUSIC_HAVE =
346 grep $_ && $_->{data}, 369 grep $_ && $_->{data},
347 map $CONN->{face}[$_], 370 map $CONN->{face}[$_],
348 @$MUSIC_WANT; 371 @$MUSIC_WANT;
349 372
350 # randomize music a bit so that the order is not always the same 373 # randomize music a bit so that the order is not always the same
351 $_->{stop_time} ||= rand for @have; 374 $_->{stop_time} ||= rand for @MUSIC_HAVE;
352
353 @MUSIC_HAVE = @have
354 if @have;
355 375
356 # default MUSIC_HAVE == MUSIC_DEFAULT 376 # default MUSIC_HAVE == MUSIC_DEFAULT
357 @MUSIC_HAVE = { path => CFPlus::find_rcfile "music/$MUSIC_DEFAULT" } unless @MUSIC_HAVE; 377 @MUSIC_HAVE = { path => DC::find_rcfile "music/$MUSIC_DEFAULT" }
358 $fade_out = 700; 378 unless @MUSIC_HAVE;
359 } 379 }
360 380
361 # if the currently playing song is acceptable, let it continue 381 # if the currently playing song is acceptable, let it continue
362 return if grep $MUSIC_PLAYING_META == $_, @MUSIC_HAVE; 382 return if grep $MUSIC_PLAYING_META == $_, @MUSIC_HAVE;
363 383
364 my $NOW = time; 384 my $NOW = time;
365 385
366 if ($MUSIC_PLAYING_META) { 386 if ($MUSIC_PLAYING_META) {
367 $MUSIC_PLAYING_META->{stop_time} = $NOW; 387 $MUSIC_PLAYING_META->{stop_time} = $NOW;
368 $MUSIC_PLAYING_META->{stop_pos} = $NOW - $MUSIC_START; 388 $MUSIC_PLAYING_META->{stop_pos} = $NOW - $MUSIC_START;
369 CFPlus::MixMusic::fade_out $fade_out; 389 DC::MixMusic::fade_out $fade_out;
370 } else { 390 } else {
371 # sort by stop time, oldest first 391 # sort by stop time, oldest first
372 @MUSIC_HAVE = sort { $a->{stop_time} <=> $b->{stop_time} } @MUSIC_HAVE; 392 @MUSIC_HAVE = sort { $a->{stop_time} <=> $b->{stop_time} } @MUSIC_HAVE;
373 393
374 # if the most recently-played piece played very recently, 394 # if the most recently-played piece played very recently,
408} 428}
409 429
410sub audio_init { 430sub audio_init {
411 if ($CFG->{audio_enable}) { 431 if ($CFG->{audio_enable}) {
412 $ENV{MIX_EFFECTSMAXSPEED} = 1; 432 $ENV{MIX_EFFECTSMAXSPEED} = 1;
413 $SDL_MIXER = !CFPlus::Mix_OpenAudio 433 $SDL_MIXER = !DC::Mix_OpenAudio
414 $CFG->{audio_hw_frequency}, 434 $CFG->{audio_hw_frequency},
415 CFPlus::MIX_DEFAULT_FORMAT, 435 DC::MIX_DEFAULT_FORMAT,
416 $CFG->{audio_hw_channels}, 436 $CFG->{audio_hw_channels},
417 $CFG->{audio_hw_chunksize}; 437 $CFG->{audio_hw_chunksize};
418 438
419 if ($SDL_MIXER) { 439 if ($SDL_MIXER) {
420 CFPlus::Mix_AllocateChannels $CFG->{audio_mix_channels}; 440 DC::Mix_AllocateChannels $CFG->{audio_mix_channels};
421 441
422 audio_music_finished; 442 audio_music_finished;
423 } else { 443 } else {
424 status "Unable to open sound device: there will be no sound"; 444 status "Unable to open sound device: there will be no sound";
425 } 445 }
439 $MUSIC_WANT = []; 459 $MUSIC_WANT = [];
440 @MUSIC_JINGLE = (); 460 @MUSIC_JINGLE = ();
441 %AUDIO_PLAY = (); 461 %AUDIO_PLAY = ();
442 %AUDIO_CHUNK = (); 462 %AUDIO_CHUNK = ();
443 463
444 CFPlus::Mix_CloseAudio if $SDL_MIXER; 464 DC::Mix_CloseAudio if $SDL_MIXER;
445 undef $SDL_MIXER; 465 undef $SDL_MIXER;
446} 466}
447 467
448############################################################################# 468#############################################################################
449 469
460 my ($conn, $flags, $prompt) = @_; 480 my ($conn, $flags, $prompt) = @_;
461 481
462 # FIXME: a very ugly hack to wait for stat update #d# 482 # FIXME: a very ugly hack to wait for stat update #d#
463 if ($prompt =~ /roll new stats/ and not $conn->{stat_change_with}) { 483 if ($prompt =~ /roll new stats/ and not $conn->{stat_change_with}) {
464 unless ($QUERY_TIMER) { 484 unless ($QUERY_TIMER) {
465 $QUERY_TIMER =
466 EV::timer 1, 0, sub { 485 $QUERY_TIMER = EV::timer 1, 0, sub {
467 server_query ($conn, $flags, $prompt, 1); 486 server_query ($conn, $flags, $prompt, 1);
468 $QUERY_TIMER = undef 487 $QUERY_TIMER = undef
469 }; 488 };
489
470 return; 490 return;
471 } 491 }
472 } 492 }
473 493
474 $conn->{query_dialog} = my $dialog = new CFPlus::UI::Toplevel 494 $conn->{query_dialog} = my $dialog = new DC::UI::Toplevel
475 x => "center", 495 x => "center",
476 y => "center", 496 y => "center",
477 title => "Server Query", 497 title => "Server Query",
478 child => my $vbox = new CFPlus::UI::VBox, 498 child => my $vbox = new DC::UI::VBox,
479 ; 499 ;
480 500
481 my @dialog = my $label = new CFPlus::UI::Label 501 my @dialog = my $label = new DC::UI::Label
482 max_w => $::WIDTH * 0.8, 502 max_w => $::WIDTH * 0.8,
483 ellipsise => 0, 503 ellipsise => 0,
484 text => $prompt; 504 text => $prompt;
485 505
486 if ($flags & CS_QUERY_YESNO) { 506 if ($flags & CS_QUERY_YESNO) {
487 push @dialog, my $hbox = new CFPlus::UI::HBox; 507 push @dialog, my $hbox = new DC::UI::HBox;
488 508
489 $hbox->add (new CFPlus::UI::Button 509 $hbox->add (new DC::UI::Button
490 text => "No", 510 text => "No",
491 on_activate => sub { 511 on_activate => sub {
492 $conn->send ("reply n"); 512 $conn->send ("reply n");
493 $dialog->destroy; 513 $dialog->destroy;
494 0 514 0
495 } 515 }
496 ); 516 );
497 $hbox->add (new CFPlus::UI::Button 517 $hbox->add (new DC::UI::Button
498 text => "Yes", 518 text => "Yes",
499 on_activate => sub { 519 on_activate => sub {
500 $conn->send ("reply y"); 520 $conn->send ("reply y");
501 destroy_query_dialog $conn; 521 destroy_query_dialog $conn;
502 0 522 0
507 527
508 } elsif ($flags & CS_QUERY_SINGLECHAR) { 528 } elsif ($flags & CS_QUERY_SINGLECHAR) {
509 if ($prompt =~ /Now choose a character|Press any key for the next race/i) { 529 if ($prompt =~ /Now choose a character|Press any key for the next race/i) {
510 $dialog->{tooltip} = "#charcreation_focus"; 530 $dialog->{tooltip} = "#charcreation_focus";
511 531
512 unshift @dialog, new CFPlus::UI::Label 532 unshift @dialog, new DC::UI::Label
513 max_w => $::WIDTH * 0.8, 533 max_w => $::WIDTH * 0.8,
514 ellipsise => 0, 534 ellipsise => 0,
515 markup => "\nOr use your keyboard and the text entry below:\n"; 535 markup => "\nOr use your keyboard and the text entry below:\n";
516 536
517 unshift @dialog, my $table = new CFPlus::UI::Table; 537 unshift @dialog, my $table = new DC::UI::Table;
518 538
519 $table->add_at (0, 0, new CFPlus::UI::Button 539 $table->add_at (0, 0, new DC::UI::Button
520 text => "Next Race", 540 text => "Next Race",
521 on_activate => sub { 541 on_activate => sub {
522 $conn->send ("reply n"); 542 $conn->send ("reply n");
523 destroy_query_dialog $conn; 543 destroy_query_dialog $conn;
524 0 544 0
525 }, 545 },
526 ); 546 );
527 $table->add_at (2, 0, new CFPlus::UI::Button 547 $table->add_at (2, 0, new DC::UI::Button
528 text => "Accept", 548 text => "Accept",
529 on_activate => sub { 549 on_activate => sub {
530 $conn->send ("reply d"); 550 $conn->send ("reply d");
531 destroy_query_dialog $conn; 551 destroy_query_dialog $conn;
532 0 552 0
533 }, 553 },
534 ); 554 );
535 555
536 if ($conn->{chargen_race_description}) { 556 if ($conn->{chargen_race_description}) {
537 unshift @dialog, new CFPlus::UI::Label 557 unshift @dialog, new DC::UI::Label
538 max_w => $::WIDTH * 0.8, 558 max_w => $::WIDTH * 0.8,
539 ellipsise => 0, 559 ellipsise => 0,
540 markup => "<span foreground='#ccccff'>$conn->{chargen_race_description}</span>", 560 markup => "<span foreground='#ccccff'>$conn->{chargen_race_description}</span>",
541 ; 561 ;
542 } 562 }
543 563
544 unshift @dialog, new CFPlus::UI::Face 564 unshift @dialog, new DC::UI::Face
545 face => $conn->{player}{face}, 565 face => $conn->{player}{face},
546 bg => [.2, .2, .2, 1], 566 bg => [.2, .2, .2, 1],
547 min_w => 64, 567 min_w => 64,
548 min_h => 64, 568 min_h => 64,
549 ; 569 ;
550 570
551 if ($conn->{chargen_race_title}) { 571 if ($conn->{chargen_race_title}) {
552 unshift @dialog, new CFPlus::UI::Label 572 unshift @dialog, new DC::UI::Label
553 allign => 1, 573 allign => 1,
554 ellipsise => 0, 574 ellipsise => 0,
555 markup => "<span foreground='#ccccff' size='large'>Race: $conn->{chargen_race_title}</span>", 575 markup => "<span foreground='#ccccff' size='large'>Race: $conn->{chargen_race_title}</span>",
556 ; 576 ;
557 } 577 }
558 578
559 unshift @dialog, new CFPlus::UI::Label 579 unshift @dialog, new DC::UI::Label
560 max_w => $::WIDTH * 0.4, 580 max_w => $::WIDTH * 0.4,
561 ellipsise => 0, 581 ellipsise => 0,
562 markup => (CFPlus::Pod::section_label ui => "chargen_race"), 582 markup => (DC::Pod::section_label ui => "chargen_race"),
563 ; 583 ;
564 584
565 } elsif ($prompt =~ /roll new stats/) { 585 } elsif ($prompt =~ /roll new stats/) {
566 if (my $stat = delete $conn->{stat_change_with}) { 586 if (my $stat = delete $conn->{stat_change_with}) {
567 $conn->send ("reply $stat"); 587 $conn->send ("reply $stat");
568 destroy_query_dialog $conn; 588 destroy_query_dialog $conn;
569 return; 589 return;
570 } 590 }
571 591
572 unshift @dialog, new CFPlus::UI::Label 592 unshift @dialog, new DC::UI::Label
573 max_w => $::WIDTH * 0.4, 593 max_w => $::WIDTH * 0.4,
574 ellipsise => 0, 594 ellipsise => 0,
575 markup => "\nOr use your keyboard and the text entry below:\n"; 595 markup => "\nOr use your keyboard and the text entry below:\n";
576 596
577 unshift @dialog, my $table = new CFPlus::UI::Table; 597 unshift @dialog, my $table = new DC::UI::Table;
578 598
579 # left: re-roll 599 # left: re-roll
580 $table->add_at (0, 0, new CFPlus::UI::Button 600 $table->add_at (0, 0, new DC::UI::Button
581 text => "Roll Again", 601 text => "Roll Again",
582 on_activate => sub { 602 on_activate => sub {
583 $conn->send ("reply y"); 603 $conn->send ("reply y");
584 destroy_query_dialog $conn; 604 destroy_query_dialog $conn;
585 0 605 0
586 }, 606 },
587 ); 607 );
588 608
589 # center: swap stats 609 # center: swap stats
590 my ($sw1, $sw2) = map +(new CFPlus::UI::Selector 610 my ($sw1, $sw2) = map +(new DC::UI::Selector
591 expand => 1, 611 expand => 1,
592 value => $_, 612 value => $_,
593 options => [ 613 options => [
594 [1 => "Str", "Strength ($conn->{stat}{+CS_STAT_STR})"], 614 [1 => "Str", "Strength ($conn->{stat}{+CS_STAT_STR})"],
595 [2 => "Dex", "Dexterity ($conn->{stat}{+CS_STAT_DEX})"], 615 [2 => "Dex", "Dexterity ($conn->{stat}{+CS_STAT_DEX})"],
599 [6 => "Pow", "Power ($conn->{stat}{+CS_STAT_POW})"], 619 [6 => "Pow", "Power ($conn->{stat}{+CS_STAT_POW})"],
600 [7 => "Cha", "Charisma ($conn->{stat}{+CS_STAT_CHA})"], 620 [7 => "Cha", "Charisma ($conn->{stat}{+CS_STAT_CHA})"],
601 ], 621 ],
602 ), 1 .. 2; 622 ), 1 .. 2;
603 623
604 $table->add_at (2, 0, new CFPlus::UI::Button 624 $table->add_at (2, 0, new DC::UI::Button
605 text => "Swap Stats", 625 text => "Swap Stats",
606 on_activate => sub { 626 on_activate => sub {
607 $conn->{stat_change_with} = $sw2->{value}; 627 $conn->{stat_change_with} = $sw2->{value};
608 $conn->send ("reply $sw1->{value}"); 628 $conn->send ("reply $sw1->{value}");
609 destroy_query_dialog $conn; 629 destroy_query_dialog $conn;
610 0 630 0
611 }, 631 },
612 ); 632 );
613 $table->add_at (2, 1, new CFPlus::UI::HBox children => [$sw1, $sw2]); 633 $table->add_at (2, 1, new DC::UI::HBox children => [$sw1, $sw2]);
614 634
615 # right: accept 635 # right: accept
616 $table->add_at (4, 0, new CFPlus::UI::Button 636 $table->add_at (4, 0, new DC::UI::Button
617 text => "Accept", 637 text => "Accept",
618 on_activate => sub { 638 on_activate => sub {
619 $conn->send ("reply n"); 639 $conn->send ("reply n");
620 $STATS_PAGE->hide; 640 $STATS_PAGE->hide;
621 destroy_query_dialog $conn; 641 destroy_query_dialog $conn;
622 0 642 0
623 }, 643 },
624 ); 644 );
625 645
626 unshift @dialog, my $hbox = new CFPlus::UI::HBox; 646 unshift @dialog, my $hbox = new DC::UI::HBox;
627 for ( 647 for (
628 [Str => CS_STAT_STR], 648 [Str => CS_STAT_STR],
629 [Dex => CS_STAT_DEX], 649 [Dex => CS_STAT_DEX],
630 [Con => CS_STAT_CON], 650 [Con => CS_STAT_CON],
631 [Int => CS_STAT_INT], 651 [Int => CS_STAT_INT],
632 [Wis => CS_STAT_WIS], 652 [Wis => CS_STAT_WIS],
633 [Pow => CS_STAT_POW], 653 [Pow => CS_STAT_POW],
634 [Cha => CS_STAT_CHA], 654 [Cha => CS_STAT_CHA],
635 ) { 655 ) {
636 my ($name, $id) = @$_; 656 my ($name, $id) = @$_;
637 $hbox->add (new CFPlus::UI::Label 657 $hbox->add (new DC::UI::Label
638 markup => "$conn->{stat}{$id} <span foreground='yellow'>$name</span>", 658 markup => "$conn->{stat}{$id} <span foreground='yellow'>$name</span>",
639 align => 0, 659 align => 0,
640 expand => 1, 660 expand => 1,
641 can_events => 1, 661 can_events => 1,
642 can_hover => 1, 662 can_hover => 1,
643 tooltip => "#stat_$name", 663 tooltip => "#stat_$name",
644 ); 664 );
645 } 665 }
646 666
647 unshift @dialog, new CFPlus::UI::Label 667 unshift @dialog, new DC::UI::Label
648 max_w => $::WIDTH * 0.4, 668 max_w => $::WIDTH * 0.4,
649 ellipsise => 0, 669 ellipsise => 0,
650 markup => (CFPlus::Pod::section_label ui => "chargen_stats"), 670 markup => (DC::Pod::section_label ui => "chargen_stats"),
651 ; 671 ;
652 } 672 }
653 673
654 push @dialog, my $entry = new CFPlus::UI::Entry 674 push @dialog, my $entry = new DC::UI::Entry
655 on_changed => sub { 675 on_changed => sub {
656 $conn->send ("reply $_[1]"); 676 $conn->send ("reply $_[1]");
657 destroy_query_dialog $conn; 677 destroy_query_dialog $conn;
658 0 678 0
659 }, 679 },
662 $entry->grab_focus; 682 $entry->grab_focus;
663 683
664 } else { 684 } else {
665 $dialog->{tooltip} = "Enter the reply and press return (click on the entry to make sure it has keyboard focus)"; 685 $dialog->{tooltip} = "Enter the reply and press return (click on the entry to make sure it has keyboard focus)";
666 686
667 push @dialog, my $entry = new CFPlus::UI::Entry 687 push @dialog, my $entry = new DC::UI::Entry
668 $flags & CS_QUERY_HIDEINPUT ? (hidden => "*") : (), 688 $flags & CS_QUERY_HIDEINPUT ? (hidden => "*") : (),
669 on_activate => sub { 689 on_activate => sub {
670 $conn->send ("reply $_[1]"); 690 $conn->send ("reply $_[1]");
671 destroy_query_dialog $conn; 691 destroy_query_dialog $conn;
672 0 692 0
688 708
689 my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; 709 my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32;
690 710
691 my ($host, $port) = split /:/, $PROFILE->{host}; 711 my ($host, $port) = split /:/, $PROFILE->{host};
692 712
693 $MAP = new CFPlus::Map; 713 $MAP = new DC::Map;
694 714
695 $CONN = eval { 715 $CONN = eval {
696 new CFPlus::Protocol 716 new DC::Protocol
697 host => $host, 717 host => $host,
698 port => $port || 13327, 718 port => $port || 13327,
699 user => $PROFILE->{user}, 719 user => $PROFILE->{user},
700 pass => $PROFILE->{password}, 720 pass => $PROFILE->{password},
701 mapw => $mapsize, 721 mapw => $mapsize,
702 maph => $mapsize, 722 maph => $mapsize,
703 723
704 client => "cfplus $CFPlus::VERSION $] $^O", 724 client => "cfplus $DC::VERSION $] $^O",
705 725
706 map_widget => $MAPWIDGET, 726 map_widget => $MAPWIDGET,
707 statusbox => $STATUSBOX, 727 statusbox => $STATUSBOX,
708 map => $MAP, 728 map => $MAP,
709 mapmap => $MAPMAP, 729 mapmap => $MAPMAP,
713 smoothing => $CFG->{map_smoothing}*1, 733 smoothing => $CFG->{map_smoothing}*1,
714 }, 734 },
715 }; 735 };
716 736
717 if ($CONN) { 737 if ($CONN) {
718 CFPlus::lowdelay fileno $CONN->{fh}; 738 DC::lowdelay fileno $CONN->{fh};
719 739
720 status "login successful"; 740 status "login successful";
721 } else { 741 } else {
722 status "unable to connect"; 742 status "unable to connect";
723 stop_game(); 743 stop_game();
728 $LOGIN_BUTTON->set_text ("Login / Register"); 748 $LOGIN_BUTTON->set_text ("Login / Register");
729 $SETUP_NOTEBOOK->set_current_page ($SETUP_LOGIN); 749 $SETUP_NOTEBOOK->set_current_page ($SETUP_LOGIN);
730 $SETUP_DIALOG->show; 750 $SETUP_DIALOG->show;
731 $PL_WINDOW->hide; 751 $PL_WINDOW->hide;
732 $SPELL_LIST->clear_spells; 752 $SPELL_LIST->clear_spells;
733 $CFPlus::UI::ROOT->emit (stop_game => ! ! $CONN); 753 $DC::UI::ROOT->emit (stop_game => ! ! $CONN);
734 754
735 &audio_music_set_ambient ([]); 755 &audio_music_set_ambient ([]);
736 756
737 return unless $CONN; 757 return unless $CONN;
738 758
744 764
745 undef $MAP; 765 undef $MAP;
746} 766}
747 767
748sub graphics_setup { 768sub graphics_setup {
749 my $vbox = new CFPlus::UI::VBox; 769 my $vbox = new DC::UI::VBox;
750 770
751 $vbox->add (my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 1]); 771 $vbox->add (my $table = new DC::UI::Table expand => 1, col_expand => [0, 1]);
752 772
753 my $row = 0; 773 my $row = 0;
754 774
755 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "OpenGL Info"); 775 $table->add_at (0, $row, new DC::UI::Label valign => 0, align => 1, text => "OpenGL Info");
756 $table->add_at (1, $row++, new CFPlus::UI::Label valign => 0, fontsize => 0.8, text => CFPlus::OpenGL::gl_vendor . ", " . CFPlus::OpenGL::gl_version, 776 $table->add_at (1, $row++, new DC::UI::Label valign => 0, fontsize => 0.8, text => DC::OpenGL::gl_vendor . ", " . DC::OpenGL::gl_version,
757 can_events => 1, 777 can_events => 1,
758 tooltip => "<tt><span size='8192'>" . (CFPlus::OpenGL::gl_extensions) . "</span></tt>"); 778 tooltip => "<tt><span size='8192'>" . (DC::OpenGL::gl_extensions) . "</span></tt>");
759 779
760 my $vidmode_tooltip = 780 my $vidmode_tooltip =
761 "<b>Video Mode.</b> The video mode to use for fullscreen (and the window size for windowed operation). " 781 "<b>Video Mode.</b> The video mode to use for fullscreen (and the window size for windowed operation). "
762 . "The format is <i>width</i> x <i>height</i> \@ <i>depth-per-channel</i> + <i>alpha-channel</i>."; 782 . "The format is <i>width</i> x <i>height</i> \@ <i>depth-per-channel</i> + <i>alpha-channel</i>.";
763 783
764 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Video Mode"); 784 $table->add_at (0, $row, new DC::UI::Label valign => 0, align => 1, text => "Video Mode");
765 $table->add_at (1, $row++, my $hbox = new CFPlus::UI::HBox); 785 $table->add_at (1, $row++, my $hbox = new DC::UI::HBox);
766 786
767 $hbox->add (my $mode_slider = new CFPlus::UI::Slider 787 $hbox->add (my $mode_slider = new DC::UI::Slider
768 force_w => $WIDTH * 0.1, expand => 1, range => [$CFG->{sdl_mode}, 0, $#SDL_MODES, 0, 1], 788 force_w => $WIDTH * 0.1, expand => 1, range => [$CFG->{sdl_mode}, 0, $#SDL_MODES, 0, 1],
769 tooltip => $vidmode_tooltip); 789 tooltip => $vidmode_tooltip);
770 $hbox->add (my $mode_label = new CFPlus::UI::Label 790 $hbox->add (my $mode_label = new DC::UI::Label
771 align => 0, valign => 0, height => 0.8, template => "9999x9999@9+9", 791 align => 0, valign => 0, height => 0.8, template => "9999x9999@9+9",
772 can_events => 1, tooltip => $vidmode_tooltip); 792 can_events => 1, tooltip => $vidmode_tooltip);
773 793
774 $mode_slider->connect (changed => sub { 794 $mode_slider->connect (changed => sub {
775 my ($self, $value) = @_; 795 my ($self, $value) = @_;
777 $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value; 797 $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value;
778 $mode_label->set_text (sprintf '%dx%d@%d+%d', @{$SDL_MODES[$value]}); 798 $mode_label->set_text (sprintf '%dx%d@%d+%d', @{$SDL_MODES[$value]});
779 }); 799 });
780 $mode_slider->emit (changed => $mode_slider->{range}[0]); 800 $mode_slider->emit (changed => $mode_slider->{range}[0]);
781 801
782 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fullscreen"); 802 $table->add_at (0, $row, new DC::UI::Label valign => 0, align => 1, text => "Fullscreen");
783 $table->add_at (1, $row++, $FULLSCREEN_ENABLE = new CFPlus::UI::CheckBox 803 $table->add_at (1, $row++, $FULLSCREEN_ENABLE = new DC::UI::CheckBox
784 state => $CFG->{fullscreen}, 804 state => $CFG->{fullscreen},
785 tooltip => "Bring the client into fullscreen mode.", 805 tooltip => "Bring the client into fullscreen mode.",
786 on_changed => sub { my ($self, $value) = @_; $CFG->{fullscreen} = $value; 0 } 806 on_changed => sub { my ($self, $value) = @_; $CFG->{fullscreen} = $value; 0 }
787 ); 807 );
788 808
789 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Force OpenGL 1.1"); 809 $table->add_at (0, $row, new DC::UI::Label valign => 0, align => 1, text => "Force OpenGL 1.1");
790 $table->add_at (1, $row++, new CFPlus::UI::CheckBox 810 $table->add_at (1, $row++, new DC::UI::CheckBox
791 state => $CFG->{force_opengl11}, 811 state => $CFG->{force_opengl11},
792 tooltip => "Limit CFPlus to use OpenGL 1.1 features only. This will normally result in " 812 tooltip => "Limit CFPlus to use OpenGL 1.1 features only. This will normally result in "
793 . "higher memory usage and slower performance. It will, however, help tremendously on " 813 . "higher memory usage and slower performance. It will, however, help tremendously on "
794 . "cards that claim to support a feature but fall back to software rendering. " 814 . "cards that claim to support a feature but fall back to software rendering. "
795 . "Nvidia Geforce FX cards are known to claim features the hardware doesn't support, " 815 . "Nvidia Geforce FX cards are known to claim features the hardware doesn't support, "
796 . "but cards and drivers from other vendors (ATI) are often just as bad. <b>If you " 816 . "but cards and drivers from other vendors (ATI) are often just as bad. <b>If you "
797 . "experience extremely low framerates and your card should do better, try this option.</b>", 817 . "experience extremely low framerates and your card should do better, try this option.</b>",
798 on_changed => sub { my ($self, $value) = @_; $CFG->{force_opengl11} = $value; 0 } 818 on_changed => sub { my ($self, $value) = @_; $CFG->{force_opengl11} = $value; 0 }
799 ); 819 );
800 820
801 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Compress Textures"); 821 $table->add_at (0, $row, new DC::UI::Label valign => 0, align => 1, text => "Compress Textures");
802 $table->add_at (1, $row++, new CFPlus::UI::CheckBox 822 $table->add_at (1, $row++, new DC::UI::CheckBox
803 state => $CFG->{texture_compression}, 823 state => $CFG->{texture_compression},
804 tooltip => "Use texture compression. Normally this will not reduce visual quality noticable but " 824 tooltip => "Use texture compression. Normally this will not reduce visual quality noticable but "
805 . "will save a lot of memory and increase performance. The compression algorithm " 825 . "will save a lot of memory and increase performance. The compression algorithm "
806 . "can differ form card to card, so your mileage may vary. This setting is ignored in " 826 . "can differ form card to card, so your mileage may vary. This setting is ignored in "
807 . "forced OpenGL 1.1 mode.", 827 . "forced OpenGL 1.1 mode.",
808 on_changed => sub { my ($self, $value) = @_; $CFG->{texture_compression} = $value; 0 } 828 on_changed => sub { my ($self, $value) = @_; $CFG->{texture_compression} = $value; 0 }
809 ); 829 );
810 830
811 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fast & Ugly"); 831 $table->add_at (0, $row, new DC::UI::Label valign => 0, align => 1, text => "Fast & Ugly");
812 $table->add_at (1, $row++, new CFPlus::UI::CheckBox 832 $table->add_at (1, $row++, new DC::UI::CheckBox
813 state => $CFG->{fast}, 833 state => $CFG->{fast},
814 tooltip => "Lower the visual quality considerably to speed up rendering.", 834 tooltip => "Lower the visual quality considerably to speed up rendering.",
815 on_changed => sub { my ($self, $value) = @_; $CFG->{fast} = $value; 0 } 835 on_changed => sub { my ($self, $value) = @_; $CFG->{fast} = $value; 0 }
816 ); 836 );
817 837
818 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "GUI Fontsize"); 838 $table->add_at (0, $row, new DC::UI::Label valign => 0, align => 1, text => "GUI Fontsize");
819 $table->add_at (1, $row++, new CFPlus::UI::Slider 839 $table->add_at (1, $row++, new DC::UI::Slider
820 range => [$CFG->{gui_fontsize}, 0.5, 2, 0, 0.1], 840 range => [$CFG->{gui_fontsize}, 0.5, 2, 0, 0.1],
821 tooltip => "The base font size used by most GUI elements that do not have their own setting.", 841 tooltip => "The base font size used by most GUI elements that do not have their own setting.",
822 on_changed => sub { $CFG->{gui_fontsize} = $_[1]; 0 }, 842 on_changed => sub { $CFG->{gui_fontsize} = $_[1]; 0 },
823 ); 843 );
824 844
825 $table->add_at (1, $row++, new CFPlus::UI::Button 845 $table->add_at (1, $row++, new DC::UI::Button
826 expand => 1, align => 0, text => "Apply", 846 expand => 1, align => 0, text => "Apply",
827 tooltip => "Apply the video settings above.", 847 tooltip => "Apply the video settings above.",
828 on_activate => sub { 848 on_activate => sub {
829 video_shutdown (); 849 video_shutdown ();
830 video_init (); 850 video_init ();
831 0 851 0
832 } 852 }
833 ); 853 );
834 854
835 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Map Scale"); 855 $table->add_at (0, $row, new DC::UI::Label valign => 0, align => 1, text => "Map Scale");
836 $table->add_at (1, $row++, new CFPlus::UI::Slider 856 $table->add_at (1, $row++, new DC::UI::Slider
837 range => [(log $CFG->{map_scale}) / (log 2), -3, 1, 0, 1], 857 range => [(log $CFG->{map_scale}) / (log 2), -3, 1, 0, 1],
838 tooltip => "Enlarge or shrink the displayed map. Changes are instant.", 858 tooltip => "Enlarge or shrink the displayed map. Changes are instant.",
839 on_changed => sub { my ($self, $value) = @_; $CFG->{map_scale} = 2 ** $value; 0 } 859 on_changed => sub { my ($self, $value) = @_; $CFG->{map_scale} = 2 ** $value; 0 }
840 ); 860 );
841 861
842 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Map Smoothing"); 862 $table->add_at (0, $row, new DC::UI::Label valign => 0, align => 1, text => "Map Smoothing");
843 $table->add_at (1, $row++, new CFPlus::UI::CheckBox 863 $table->add_at (1, $row++, new DC::UI::CheckBox
844 state => $CFG->{map_smoothing}, 864 state => $CFG->{map_smoothing},
845 tooltip => "<b>Map Smoothing</b> tries to make tile borders less square. " 865 tooltip => "<b>Map Smoothing</b> tries to make tile borders less square. "
846 . "This increases load on the graphics subsystem and works only with TRT servers. " 866 . "This increases load on the graphics subsystem and works only with TRT servers. "
847 . "Changes take effect at next login only.", 867 . "Changes take effect at next login only.",
848 on_changed => sub { my ($self, $value) = @_; $CFG->{map_smoothing} = $value; 0 } 868 on_changed => sub { my ($self, $value) = @_; $CFG->{map_smoothing} = $value; 0 }
849 ); 869 );
850 870
851 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fog of War"); 871 $table->add_at (0, $row, new DC::UI::Label valign => 0, align => 1, text => "Fog of War");
852 $table->add_at (1, $row++, new CFPlus::UI::CheckBox 872 $table->add_at (1, $row++, new DC::UI::CheckBox
853 state => $CFG->{fow_enable}, 873 state => $CFG->{fow_enable},
854 tooltip => "<b>Fog-of-War</b> marks areas that cannot be seen by the player. Changes are instant.", 874 tooltip => "<b>Fog-of-War</b> marks areas that cannot be seen by the player. Changes are instant.",
855 on_changed => sub { my ($self, $value) = @_; $CFG->{fow_enable} = $value; 0 } 875 on_changed => sub { my ($self, $value) = @_; $CFG->{fow_enable} = $value; 0 }
856 ); 876 );
857 877
858 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "FoW Intensity"); 878 $table->add_at (0, $row, new DC::UI::Label valign => 0, align => 1, text => "FoW Intensity");
859 $table->add_at (1, $row++, new CFPlus::UI::Slider 879 $table->add_at (1, $row++, new DC::UI::Slider
860 range => [$CFG->{fow_intensity}, 0, 1, 0, 1 / 256], 880 range => [$CFG->{fow_intensity}, 0, 1, 0, 1 / 256],
861 tooltip => "<b>Fog of War Lightness.</b> The higher the intensity, the lighter the Fog-of-War color. Changes are instant.", 881 tooltip => "<b>Fog of War Lightness.</b> The higher the intensity, the lighter the Fog-of-War color. Changes are instant.",
862 on_changed => sub { my ($self, $value) = @_; $CFG->{fow_intensity} = $value; 0 } 882 on_changed => sub { my ($self, $value) = @_; $CFG->{fow_intensity} = $value; 0 }
863 ); 883 );
864 884
865 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Message Fontsize"); 885 $table->add_at (0, $row, new DC::UI::Label valign => 0, align => 1, text => "Message Fontsize");
866 $table->add_at (1, $row++, new CFPlus::UI::Slider 886 $table->add_at (1, $row++, new DC::UI::Slider
867 range => [$CFG->{log_fontsize}, 0.5, 2, 0, 0.1], 887 range => [$CFG->{log_fontsize}, 0.5, 2, 0, 0.1],
868 tooltip => "The font size used by the <b>message/server log</b> window only. Changes are instant, " 888 tooltip => "The font size used by the <b>message/server log</b> window only. Changes are instant, "
869 . "but you still need to press apply to correctly re-layout the widget.", 889 . "but you still need to press apply to correctly re-layout the widget.",
870 on_changed => sub { $MESSAGE_WINDOW->set_fontsize ($CFG->{log_fontsize} = $_[1]); 0 }, 890 on_changed => sub { $MESSAGE_WINDOW->set_fontsize ($CFG->{log_fontsize} = $_[1]); 0 },
871 ); 891 );
872 892
873 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Gauge fontsize"); 893 $table->add_at (0, $row, new DC::UI::Label valign => 0, align => 1, text => "Gauge fontsize");
874 $table->add_at (1, $row++, new CFPlus::UI::Slider 894 $table->add_at (1, $row++, new DC::UI::Slider
875 range => [$CFG->{gauge_fontsize}, 0.5, 2, 0, 0.1], 895 range => [$CFG->{gauge_fontsize}, 0.5, 2, 0, 0.1],
876 tooltip => "Adjusts the fontsize of the gauges at the bottom right. Changes are instant.", 896 tooltip => "Adjusts the fontsize of the gauges at the bottom right. Changes are instant.",
877 on_changed => sub { 897 on_changed => sub {
878 $CFG->{gauge_fontsize} = $_[1]; 898 $CFG->{gauge_fontsize} = $_[1];
879 &set_gauge_window_fontsize; 899 &set_gauge_window_fontsize;
880 0 900 0
881 } 901 }
882 ); 902 );
883 903
884 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Gauge size"); 904 $table->add_at (0, $row, new DC::UI::Label valign => 0, align => 1, text => "Gauge size");
885 $table->add_at (1, $row++, new CFPlus::UI::Slider 905 $table->add_at (1, $row++, new DC::UI::Slider
886 range => [$CFG->{gauge_size}, 0.2, 0.8], 906 range => [$CFG->{gauge_size}, 0.2, 0.8],
887 tooltip => "Adjust the size of the stats gauges at the bottom right. Changes are instant.", 907 tooltip => "Adjust the size of the stats gauges at the bottom right. Changes are instant.",
888 on_changed => sub { 908 on_changed => sub {
889 $CFG->{gauge_size} = $_[1]; 909 $CFG->{gauge_size} = $_[1];
890 $GAUGES->{win}->set_size ($WIDTH, int $HEIGHT * $CFG->{gauge_size}); 910 $GAUGES->{win}->set_size ($WIDTH, int $HEIGHT * $CFG->{gauge_size});
897 917
898our $AUDIO_HW_CHUNKSIZE; 918our $AUDIO_HW_CHUNKSIZE;
899our $AUDIO_INFO; 919our $AUDIO_INFO;
900 920
901sub audio_tab_update { 921sub audio_tab_update {
902 my ($freq, $format, $chans) = CFPlus::Mix_QuerySpec; 922 my ($freq, $format, $chans) = DC::Mix_QuerySpec;
903 923
904 $AUDIO_HW_CHUNKSIZE->set_options ([ 924 $AUDIO_HW_CHUNKSIZE->set_options ([
905 [0, "default", "Use System Default"], 925 [0, "default", "Use System Default"],
906 map { 926 map {
907 my $ms = sprintf "%dms", 1000 * $_ / ($CFG->{audio_hw_frequency} || 22050); 927 my $ms = sprintf "%dms", 1000 * $_ / ($CFG->{audio_hw_frequency} || 22050);
917 937
918 $AUDIO_INFO->set_text ($text); 938 $AUDIO_INFO->set_text ($text);
919} 939}
920 940
921sub audio_setup { 941sub audio_setup {
922 my $vbox = new CFPlus::UI::VBox; 942 my $vbox = new DC::UI::VBox;
923 943
924 $vbox->add (my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 0, 1]); 944 $vbox->add (my $table = new DC::UI::Table expand => 1, col_expand => [0, 0, 1]);
925 945
926 my $row = 0; 946 my $row = 0;
927 947
928 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Audio Enable"); 948 $table->add_at (0, $row, new DC::UI::Label valign => 0, align => 1, text => "Audio Enable");
929 $table->add_at (1, $row++, new CFPlus::UI::CheckBox 949 $table->add_at (1, $row++, new DC::UI::CheckBox
930 state => $CFG->{audio_enable}, 950 state => $CFG->{audio_enable},
931 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.", 951 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.",
932 on_changed => sub { $CFG->{audio_enable} = $_[1]; 1 } 952 on_changed => sub { $CFG->{audio_enable} = $_[1]; 1 }
933 ); 953 );
934 954
935 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Sound Effects"); 955 $table->add_at (0, $row, new DC::UI::Label valign => 0, align => 1, text => "Sound Effects");
936 $table->add_at (1, $row, new CFPlus::UI::CheckBox 956 $table->add_at (1, $row, new DC::UI::CheckBox
937 expand => 1, state => $CFG->{effects_enable}, 957 expand => 1, state => $CFG->{effects_enable},
938 tooltip => "If enabled, sound effects are enabled. If disabled, no sound effects will be played.", 958 tooltip => "If enabled, sound effects are enabled. If disabled, no sound effects will be played.",
939 on_changed => sub { 959 on_changed => sub {
940 $CFG->{effects_enable} = $_[1]; 960 $CFG->{effects_enable} = $_[1];
941 $CONN->update_fx_want if $CONN; 961 $CONN->update_fx_want if $CONN;
942 1 962 1
943 } 963 }
944 ); 964 );
945 $table->add_at (2, $row++, new CFPlus::UI::Slider 965 $table->add_at (2, $row++, new DC::UI::Slider
946 expand => 1, range => [$CFG->{effects_volume}, 0, 1, 0, 1/128], 966 expand => 1, range => [$CFG->{effects_volume}, 0, 1, 0, 1/128],
947 tooltip => "The relative volume of sound effects. Best audio quality is achieved if this " 967 tooltip => "The relative volume of sound effects. Best audio quality is achieved if this "
948 . "is set highest (rightmost) and you use your operating system volume setting. Changes are instant.", 968 . "is set highest (rightmost) and you use your operating system volume setting. Changes are instant.",
949 on_changed => sub { $CFG->{effects_volume} = $_[1]; 1 } 969 on_changed => sub { $CFG->{effects_volume} = $_[1]; 1 }
950 ); 970 );
951 971
952 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Background Music"); 972 $table->add_at (0, $row, new DC::UI::Label valign => 0, align => 1, text => "Background Music");
953 $table->add_at (1, $row, new CFPlus::UI::CheckBox 973 $table->add_at (1, $row, new DC::UI::CheckBox
954 expand => 1, state => $CFG->{bgm_enable}, 974 expand => 1, state => $CFG->{bgm_enable},
955 tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played.", 975 tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played.",
956 on_changed => sub { 976 on_changed => sub {
957 $CFG->{bgm_enable} = $_[1]; 977 $CFG->{bgm_enable} = $_[1];
958 $CONN->update_fx_want if $CONN; 978 $CONN->update_fx_want if $CONN;
959 audio_music_push; 979 audio_music_push;
960 1 980 1
961 } 981 }
962 ); 982 );
963 $table->add_at (2, $row++, new CFPlus::UI::Slider 983 $table->add_at (2, $row++, new DC::UI::Slider
964 expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0, 1/128], 984 expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0, 1/128],
965 tooltip => "The volume of the background music. Changes are instant.", 985 tooltip => "The volume of the background music. Changes are instant.",
966 on_changed => sub { $CFG->{bgm_volume} = $_[1]; audio_music_update_volume; 0 } 986 on_changed => sub { $CFG->{bgm_volume} = $_[1]; audio_music_update_volume; 0 }
967 ); 987 );
968 988
969 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Frequency"); 989 $table->add_at (0, $row, new DC::UI::Label valign => 0, align => 1, text => "Frequency");
970 $table->add_at (1, $row++, new CFPlus::UI::Selector 990 $table->add_at (1, $row++, new DC::UI::Selector
971 c_colspan => 2, expand => 1, 991 c_colspan => 2, expand => 1,
972 value => $CFG->{audio_hw_frequency}, 992 value => $CFG->{audio_hw_frequency},
973 options => [ 993 options => [
974 [ 0, "default" , "Use System Default"], 994 [ 0, "default" , "Use System Default"],
975 [11025, "11 kHz" , "11kHz (low quality)"], 995 [11025, "11 kHz" , "11kHz (low quality)"],
983 audio_tab_update; 1003 audio_tab_update;
984 1 1004 1
985 } 1005 }
986 ); 1006 );
987 1007
988 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Channels"); 1008 $table->add_at (0, $row, new DC::UI::Label valign => 0, align => 1, text => "Channels");
989 $table->add_at (1, $row++, new CFPlus::UI::Selector 1009 $table->add_at (1, $row++, new DC::UI::Selector
990 c_colspan => 2, expand => 1, 1010 c_colspan => 2, expand => 1,
991 value => $CFG->{audio_hw_channels}, 1011 value => $CFG->{audio_hw_channels},
992 options => [ 1012 options => [
993 [0, "default" , "Use System Default"], 1013 [0, "default" , "Use System Default"],
994 [1, "Mono" , "Mono (single channel, low quality)"], 1014 [1, "Mono" , "Mono (single channel, low quality)"],
995 [2, "Stereo" , "Stereo (dual channe, standard quality)"], 1015 [2, "Stereo" , "Stereo (dual channel, standard quality)"],
996 [4, "4 Ch Surround", "4 Channel Surround Sound (3d sound, high quality)"], 1016 [4, "4 Ch Surround", "4 Channel Surround Sound (3d sound, high quality)"],
997 [6, "6 Ch Surround", "6 Channel Surround Sound (3d sound + center + lfe)"], 1017 [6, "6 Ch Surround", "6 Channel Surround Sound (3d sound + center + lfe)"],
998 ], 1018 ],
999 tooltip => "The number of independent sound channels to use. Higher sounds better, but also more cpu-intensive and might cause stuttering.", 1019 tooltip => "The number of independent sound channels to use. Higher sounds better, but also more cpu-intensive and might cause stuttering.",
1000 on_changed => sub { 1020 on_changed => sub {
1002 audio_tab_update; 1022 audio_tab_update;
1003 1 1023 1
1004 } 1024 }
1005 ); 1025 );
1006 1026
1007 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Latency"); 1027 $table->add_at (0, $row, new DC::UI::Label valign => 0, align => 1, text => "Latency");
1008 $table->add_at (1, $row++, $AUDIO_HW_CHUNKSIZE = new CFPlus::UI::Selector 1028 $table->add_at (1, $row++, $AUDIO_HW_CHUNKSIZE = new DC::UI::Selector
1009 c_colspan => 2, expand => 1, 1029 c_colspan => 2, expand => 1,
1010 value => $CFG->{audio_hw_chunksize}, 1030 value => $CFG->{audio_hw_chunksize},
1011 tooltip => "The guarenteed latency. Lower is better, but also more cpu-intensive and might cause stuttering. If music playback " 1031 tooltip => "The guarenteed latency. Lower is better, but also more cpu-intensive and might cause stuttering. If music playback "
1012 . "is stuttering, increase this value. Values of 50-100ms are optimal.", 1032 . "is stuttering, increase this value. Values of 50-100ms are optimal.",
1013 on_changed => sub { 1033 on_changed => sub {
1016 1 1036 1
1017 } 1037 }
1018 ); 1038 );
1019 1039
1020 # should really be a slider 1040 # should really be a slider
1021 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Mixer Voices"); 1041 $table->add_at (0, $row, new DC::UI::Label valign => 0, align => 1, text => "Mixer Voices");
1022 $table->add_at (1, $row++, new CFPlus::UI::ValSlider 1042 $table->add_at (1, $row++, new DC::UI::ValSlider
1023 c_colspan => 2, expand => 1, 1043 c_colspan => 2, expand => 1,
1024 tooltip => "The number of simultaneous sound effects possible. Higher is better, but also more cpu-intensive and might cause stuttering.", 1044 tooltip => "The number of simultaneous sound effects possible. Higher is better, but also more cpu-intensive and might cause stuttering.",
1025 range => [$::CFG->{audio_mix_channels}, 4, 32, 0, 1], 1045 range => [$::CFG->{audio_mix_channels}, 4, 32, 0, 1],
1026 template => ">= 99", 1046 template => ">= 99",
1027 on_changed => sub { 1047 on_changed => sub {
1031 if $value; 1051 if $value;
1032 1; 1052 1;
1033 } 1053 }
1034 ); 1054 );
1035 1055
1036 $table->add_at (1, $row++, new CFPlus::UI::Button 1056 $table->add_at (1, $row++, new DC::UI::Button
1037 c_colspan => 2, expand => 1, align => 0, text => "Apply", 1057 c_colspan => 2, expand => 1, align => 0, text => "Apply",
1038 tooltip => "Apply the audio settings", 1058 tooltip => "Apply the audio settings",
1039 on_activate => sub { 1059 on_activate => sub {
1040 audio_shutdown (); 1060 audio_shutdown ();
1041 audio_init (); 1061 audio_init ();
1042 0 1062 0
1043 } 1063 }
1044 ); 1064 );
1045 1065
1046 $vbox->add (new CFPlus::UI::FancyFrame 1066 $vbox->add (new DC::UI::FancyFrame
1047 expand => 1, 1067 expand => 1,
1048 label => "Audio Info", 1068 label => "Audio Info",
1049 child => ($AUDIO_INFO = new CFPlus::UI::Label ellipsise => 0), 1069 child => ($AUDIO_INFO = new DC::UI::Label ellipsise => 0),
1050 ); 1070 );
1051 1071
1052 audio_tab_update; 1072 audio_tab_update;
1053 1073
1054 $vbox 1074 $vbox
1061} 1081}
1062 1082
1063sub make_gauge_window { 1083sub make_gauge_window {
1064 my $gh = int $HEIGHT * $CFG->{gauge_size}; 1084 my $gh = int $HEIGHT * $CFG->{gauge_size};
1065 1085
1066 my $win = new CFPlus::UI::Frame ( 1086 my $win = new DC::UI::Frame (
1067 force_x => 0, 1087 force_x => 0,
1068 force_y => "max", 1088 force_y => "max",
1069 force_w => $WIDTH, 1089 force_w => $WIDTH,
1070 force_h => $gh, 1090 force_h => $gh,
1071 ); 1091 );
1072 1092
1073 $win->add (my $hbox = new CFPlus::UI::HBox 1093 $win->add (my $hbox = new DC::UI::HBox
1074 children => [ 1094 children => [
1075 (new CFPlus::UI::HBox expand => 1), 1095 (new DC::UI::HBox expand => 1),
1076 (new CFPlus::UI::VBox children => [ 1096 (new DC::UI::VBox children => [
1077 (new CFPlus::UI::Empty expand => 1), 1097 (new DC::UI::Empty expand => 1),
1078 (new CFPlus::UI::Frame bg => [0, 0, 0, 0.4], child => ($FLOORBOX = new CFPlus::UI::Table)), 1098 (new DC::UI::Frame bg => [0, 0, 0, 0.4], child => ($FLOORBOX = new DC::UI::Table)),
1079 ]), 1099 ]),
1080 (my $vbox = new CFPlus::UI::VBox), 1100 (my $vbox = new DC::UI::VBox),
1081 ], 1101 ],
1082 ); 1102 );
1083 1103
1084 $vbox->add (new CFPlus::UI::HBox 1104 $vbox->add (new DC::UI::HBox
1085 expand => 1, 1105 expand => 1,
1086 children => [ 1106 children => [
1087 (new CFPlus::UI::Empty expand => 1), 1107 (new DC::UI::Empty expand => 1),
1088 (my $hb = new CFPlus::UI::HBox), 1108 (my $hb = new DC::UI::HBox),
1089 ], 1109 ],
1090 ); 1110 );
1091 1111
1092 $hb->add (my $hg = new CFPlus::UI::Gauge type => 'hp', tooltip => "#stat_health"); 1112 $hb->add (my $hg = new DC::UI::Gauge type => 'hp', tooltip => "#stat_health");
1093 $hb->add (my $mg = new CFPlus::UI::Gauge type => 'mana', tooltip => "#stat_mana"); 1113 $hb->add (my $mg = new DC::UI::Gauge type => 'mana', tooltip => "#stat_mana");
1094 $hb->add (my $gg = new CFPlus::UI::Gauge type => 'grace', tooltip => "#stat_grace"); 1114 $hb->add (my $gg = new DC::UI::Gauge type => 'grace', tooltip => "#stat_grace");
1095 $hb->add (my $fg = new CFPlus::UI::Gauge type => 'food', tooltip => "#stat_food"); 1115 $hb->add (my $fg = new DC::UI::Gauge type => 'food', tooltip => "#stat_food");
1096 1116
1097 $vbox->add (my $exp = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_exp"); 1117 $vbox->add (my $exp = new DC::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_exp");
1098 $vbox->add (my $prg = new CFPlus::UI::ExperienceProgress); 1118 $vbox->add (my $prg = new DC::UI::ExperienceProgress);
1099 $vbox->add (my $sklprg = new CFPlus::UI::ExperienceProgress); 1119 $vbox->add (my $sklprg = new DC::UI::ExperienceProgress);
1100 $vbox->add (my $rng = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_ranged"); 1120 $vbox->add (my $rng = new DC::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_ranged");
1101 1121
1102 $GAUGES = { 1122 $GAUGES = {
1103 exp => $exp, prg => $prg, sklprg => $sklprg, 1123 exp => $exp, prg => $prg, sklprg => $sklprg,
1104 win => $win, range => $rng, 1124 win => $win, range => $rng,
1105 hp => $hg, mana => $mg, grace => $gg, food => $fg, 1125 hp => $hg, mana => $mg, grace => $gg, food => $fg,
1109 1129
1110 $win 1130 $win
1111} 1131}
1112 1132
1113sub debug_setup { 1133sub debug_setup {
1114 my $table = new CFPlus::UI::Table; 1134 my $table = new DC::UI::Table;
1115 1135
1116 $table->add_at (0, 0, new CFPlus::UI::Label text => "Widget Borders"); 1136 $table->add_at (0, 0, new DC::UI::Label text => "Widget Borders");
1117 $table->add_at (1, 0, new CFPlus::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 1; 0 }); 1137 $table->add_at (1, 0, new DC::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 1; 0 });
1118 $table->add_at (0, 1, new CFPlus::UI::Label text => "Tooltip Widget Info"); 1138 $table->add_at (0, 1, new DC::UI::Label text => "Tooltip Widget Info");
1119 $table->add_at (1, 1, new CFPlus::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 2; 0 }); 1139 $table->add_at (1, 1, new DC::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 2; 0 });
1120 $table->add_at (0, 2, new CFPlus::UI::Label text => "Show FPS"); 1140 $table->add_at (0, 2, new DC::UI::Label text => "Show FPS");
1121 $table->add_at (1, 2, new CFPlus::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 4; 0 }); 1141 $table->add_at (1, 2, new DC::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 4; 0 });
1122 $table->add_at (0, 3, new CFPlus::UI::Label text => "Suppress Tooltips"); 1142 $table->add_at (0, 3, new DC::UI::Label text => "Suppress Tooltips");
1123 $table->add_at (1, 3, new CFPlus::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 8; 0 }); 1143 $table->add_at (1, 3, new DC::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 8; 0 });
1124 $table->add_at (0, 4, new CFPlus::UI::Button text => "die on click(tm)", on_activate => sub { &CFPlus::debug() } ); 1144 $table->add_at (0, 4, new DC::UI::Button text => "die on click(tm)", on_activate => sub { &DC::debug() } );
1125 1145
1126 $table->add_at (0, 5, new CFPlus::UI::TextEdit text => "line1\0152\0153");#d# 1146 $table->add_at (0, 5, new DC::UI::TextEdit text => "line1\0152\0153");#d#
1127 1147
1128 $table->add_at (7,7, my $t = new CFPlus::UI::Table expand => 0); 1148 $table->add_at (7,7, my $t = new DC::UI::Table expand => 0);
1129 $t->add_at (0,0, new CFPlus::UI::Label text => "a a a a", c_rowspan => 1, c_colspan => 2); 1149 $t->add_at (0,0, new DC::UI::Label text => "a a a a", c_rowspan => 1, c_colspan => 2);
1130 $t->add_at (2,0, new CFPlus::UI::Label text => "b\nb", c_rowspan => 2, c_colspan => 1); 1150 $t->add_at (2,0, new DC::UI::Label text => "b\nb", c_rowspan => 2, c_colspan => 1);
1131 $t->add_at (1,2, new CFPlus::UI::Label text => "c c c c", c_rowspan => 1, c_colspan => 2); 1151 $t->add_at (1,2, new DC::UI::Label text => "c c c c", c_rowspan => 1, c_colspan => 2);
1132 $t->add_at (0,1, new CFPlus::UI::Label text => "d\nd", c_rowspan => 2, c_colspan => 1); 1152 $t->add_at (0,1, new DC::UI::Label text => "d\nd", c_rowspan => 2, c_colspan => 1);
1133 $t->add_at (1,1, new CFPlus::UI::Label text => "e"); 1153 $t->add_at (1,1, new DC::UI::Label text => "e");
1134 1154
1135 $table->add_at (7, 6, my $c = new CFPlus::UI::Canvas); 1155 $table->add_at (7, 6, my $c = new DC::UI::Canvas);
1136 1156
1137 $c->add_items ({ 1157 $c->add_items ({
1138 type => "line_loop", 1158 type => "line_loop",
1139 color => [0, 1, 0], 1159 color => [0, 1, 0],
1140 width => 9, 1160 width => 9,
1160 1180
1161 $table 1181 $table
1162} 1182}
1163 1183
1164sub stats_window { 1184sub stats_window {
1165 my $r = new CFPlus::UI::ScrolledWindow ( 1185 my $r = new DC::UI::ScrolledWindow (
1166 expand => 1, 1186 expand => 1,
1167 scroll_y => 1 1187 scroll_y => 1
1168 ); 1188 );
1169 $r->add (my $vb = new CFPlus::UI::VBox); 1189 $r->add (my $vb = new DC::UI::VBox);
1170 1190
1171 $vb->add (new CFPlus::UI::FancyFrame 1191 $vb->add (new DC::UI::FancyFrame
1172 label => "Player", 1192 label => "Player",
1173 child => (my $pi = new CFPlus::UI::VBox), 1193 child => (my $pi = new DC::UI::VBox),
1174 ); 1194 );
1175 1195
1176 $pi->add ($STATWIDS->{title} = new CFPlus::UI::Label valign => 0, align => -1, text => "Title:", expand => 1, 1196 $pi->add ($STATWIDS->{title} = new DC::UI::Label valign => 0, align => -1, text => "Title:", expand => 1,
1177 can_hover => 1, can_events => 1, 1197 can_hover => 1, can_events => 1,
1178 tooltip => "Your name and title. You can change your title by using the <b>title</b> command, if supported by the server."); 1198 tooltip => "Your name and title. You can change your title by using the <b>title</b> command, if supported by the server.");
1179 $pi->add ($STATWIDS->{map} = new CFPlus::UI::Label valign => 0, align => -1, text => "Map:", expand => 1, 1199 $pi->add ($STATWIDS->{map} = new DC::UI::Label valign => 0, align => -1, text => "Map:", expand => 1,
1180 can_hover => 1, can_events => 1, 1200 can_hover => 1, can_events => 1,
1181 tooltip => "The map you are currently on (if supported by the server)."); 1201 tooltip => "The map you are currently on (if supported by the server).");
1182 1202
1183 $pi->add (my $hb0 = new CFPlus::UI::HBox); 1203 $pi->add (my $hb0 = new DC::UI::HBox);
1184 $hb0->add ($STATWIDS->{weight} = new CFPlus::UI::Label valign => 0, align => -1, text => "Weight:", expand => 1, 1204 $hb0->add ($STATWIDS->{weight} = new DC::UI::Label valign => 0, align => -1, text => "Weight:", expand => 1,
1185 can_hover => 1, can_events => 1, 1205 can_hover => 1, can_events => 1,
1186 tooltip => "The weight of the player including all inventory items."); 1206 tooltip => "The weight of the player including all inventory items.");
1187 $hb0->add ($STATWIDS->{m_weight} = new CFPlus::UI::Label valign => 0, align => -1, text => "Max weight:", expand => 1, 1207 $hb0->add ($STATWIDS->{m_weight} = new DC::UI::Label valign => 0, align => -1, text => "Max weight:", expand => 1,
1188 can_hover => 1, can_events => 1, 1208 can_hover => 1, can_events => 1,
1189 tooltip => "The weight limit: you cannot carry more than this."); 1209 tooltip => "The weight limit: you cannot carry more than this.");
1190 1210
1191 $vb->add (new CFPlus::UI::FancyFrame 1211 $vb->add (new DC::UI::FancyFrame
1192 label => "Primary/Secondary Statistics", 1212 label => "Primary/Secondary Statistics",
1193 child => (my $hb = new CFPlus::UI::HBox expand => 1), 1213 child => (my $hb = new DC::UI::HBox expand => 1),
1194 ); 1214 );
1195 $hb->add (my $tbl = new CFPlus::UI::Table expand => 1); 1215 $hb->add (my $tbl = new DC::UI::Table expand => 1);
1196 1216
1197 my $color2 = [1, 1, 0]; 1217 my $color2 = [1, 1, 0];
1198 1218
1199 for ( 1219 for (
1200 [0, 0, st_str => "Str", 30], 1220 [0, 0, st_str => "Str", 30],
1212 [2, 4, st_spd => "Spd", 10.54], 1232 [2, 4, st_spd => "Spd", 10.54],
1213 [2, 5, st_wspd => "WSp", 10.54], 1233 [2, 5, st_wspd => "WSp", 10.54],
1214 ) { 1234 ) {
1215 my ($col, $row, $id, $label, $template) = @$_; 1235 my ($col, $row, $id, $label, $template) = @$_;
1216 1236
1217 $tbl->add_at ($col , $row, $STATWIDS->{$id} = new CFPlus::UI::Label 1237 $tbl->add_at ($col , $row, $STATWIDS->{$id} = new DC::UI::Label
1218 font => $FONT_FIXED, can_hover => 1, can_events => 1, valign => 0, 1238 font => $FONT_FIXED, can_hover => 1, can_events => 1, valign => 0,
1219 align => +1, template => $template, tooltip => "#stat_$label"); 1239 align => +1, template => $template, tooltip => "#stat_$label");
1220 $tbl->add_at ($col + 1, $row, $STATWIDS->{"$id\_lbl"} = new CFPlus::UI::Label 1240 $tbl->add_at ($col + 1, $row, $STATWIDS->{"$id\_lbl"} = new DC::UI::Label
1221 font => $FONT_FIXED, can_hover => 1, can_events => 1, fg => $color2, valign => 0, 1241 font => $FONT_FIXED, can_hover => 1, can_events => 1, fg => $color2, valign => 0,
1222 align => -1, text => $label, tooltip => "#stat_$label"); 1242 align => -1, text => $label, tooltip => "#stat_$label");
1223 } 1243 }
1224 1244
1225 $vb->add (new CFPlus::UI::FancyFrame 1245 $vb->add (new DC::UI::FancyFrame
1226 label => "Resistancies", 1246 label => "Resistancies",
1227 child => (my $tbl2 = new CFPlus::UI::Table expand => 1), 1247 child => (my $tbl2 = new DC::UI::Table expand => 1),
1228 ); 1248 );
1229 1249
1230 my $row = 0; 1250 my $row = 0;
1231 my $col = 0; 1251 my $col = 0;
1232 1252
1273 drain acid pois para deat phys 1293 drain acid pois para deat phys
1274 blind fear tund elec cold ghit/) 1294 blind fear tund elec cold ghit/)
1275 { 1295 {
1276 $tbl2->add_at ($col, $row, 1296 $tbl2->add_at ($col, $row,
1277 $STATWIDS->{"res_$_"} = 1297 $STATWIDS->{"res_$_"} =
1278 new CFPlus::UI::Label 1298 new DC::UI::Label
1279 font => $FONT_FIXED, 1299 font => $FONT_FIXED,
1280 template => "-100%", 1300 template => "-100%",
1281 align => +1, 1301 align => +1,
1282 valign => 0, 1302 valign => 0,
1283 can_events => 1, 1303 can_events => 1,
1284 can_hover => 1, 1304 can_hover => 1,
1285 tooltip => $resist_names{$_}->[1], 1305 tooltip => $resist_names{$_}->[1],
1286 ); 1306 );
1287 $tbl2->add_at ($col + 1, $row, new CFPlus::UI::Image 1307 $tbl2->add_at ($col + 1, $row, new DC::UI::Image
1288 font => $FONT_FIXED, 1308 font => $FONT_FIXED,
1289 can_hover => 1, 1309 can_hover => 1,
1290 can_events => 1, 1310 can_events => 1,
1291 path => "ui/resist/resist_$_.png", 1311 path => "ui/resist/resist_$_.png",
1292 tooltip => $resist_names{$_}->[1], 1312 tooltip => $resist_names{$_}->[1],
1293 ); 1313 );
1294 $tbl2->add_at ($col + 2, $row, new CFPlus::UI::Label 1314 $tbl2->add_at ($col + 2, $row, new DC::UI::Label
1295 text => $resist_names{$_}->[0], 1315 text => $resist_names{$_}->[0],
1296 font => $FONT_FIXED, 1316 font => $FONT_FIXED,
1297 can_hover => 1, 1317 can_hover => 1,
1298 can_events => 1, 1318 can_events => 1,
1299 tooltip => $resist_names{$_}->[1], 1319 tooltip => $resist_names{$_}->[1],
1310 1330
1311 $r 1331 $r
1312} 1332}
1313 1333
1314sub skill_window { 1334sub skill_window {
1315 my $sw = new CFPlus::UI::ScrolledWindow (expand => 1); 1335 my $sw = new DC::UI::ScrolledWindow (expand => 1);
1316 1336
1317 $sw->add ($STATWIDS->{skill_tbl} = new CFPlus::UI::Table expand => 1, col_expand => [0, 0, 1, .1, 0, 0, 1, .1]); 1337 $sw->add ($STATWIDS->{skill_tbl} = new DC::UI::Table expand => 1, col_expand => [0, 0, 1, .1, 0, 0, 1, .1]);
1318 1338
1319 $sw 1339 $sw
1320} 1340}
1321 1341
1322sub formsep($) { 1342sub formsep($) {
1334 return if $METASERVER_ATIME > time; 1354 return if $METASERVER_ATIME > time;
1335 $METASERVER_ATIME = time + 60; 1355 $METASERVER_ATIME = time + 60;
1336 1356
1337 my $table = $METASERVER->{table}; 1357 my $table = $METASERVER->{table};
1338 $table->clear; 1358 $table->clear;
1339 $table->add_at (0, 0, my $label = new CFPlus::UI::Label max_w => $WIDTH * 0.8, text => "fetching server list..."); 1359 $table->add_at (0, 0, my $label = new DC::UI::Label max_w => $WIDTH * 0.8, text => "fetching server list...");
1340 1360
1341 my $ok = 0; 1361 my $ok = 0;
1342 1362
1343 CFPlus::background { 1363 DC::background {
1344 my $ua = CFPlus::lwp_useragent; 1364 my $ua = DC::lwp_useragent;
1345 1365
1346 CFPlus::background_msg CFPlus::from_json +(CFPlus::lwp_check $ua->get ($META_SERVER))->decoded_content; 1366 DC::background_msg DC::decode_json +(DC::lwp_check $ua->get ($META_SERVER))->decoded_content;
1347 } sub { 1367 } sub {
1348 my ($msg) = @_; 1368 my ($msg) = @_;
1349 if ($msg) { 1369 if ($msg) {
1350 $table->clear; 1370 $table->clear;
1351 1371
1354 "The hostname of the server.", 1374 "The hostname of the server.",
1355 "The time this server has been running without being restarted.", 1375 "The time this server has been running without being restarted.",
1356 "Short information about this server provided by its admins.", 1376 "Short information about this server provided by its admins.",
1357 ); 1377 );
1358 my @col = qw(#Users Host Uptime Version Description); 1378 my @col = qw(#Users Host Uptime Version Description);
1359 $table->add_at ($_, 0, new CFPlus::UI::Label 1379 $table->add_at ($_, 0, new DC::UI::Label
1360 can_hover => 1, can_events => 1, 1380 can_hover => 1, can_events => 1,
1361 align => 0, fg => [1, 1, 0], 1381 align => 0, fg => [1, 1, 0],
1362 text => $col[$_], tooltip => $tip[$_]) 1382 text => $col[$_], tooltip => $tip[$_])
1363 for 0 .. $#col; 1383 for 0 .. $#col;
1364 1384
1386 1406
1387 $m = [$users, $host, $uptime, $version, $desc]; 1407 $m = [$users, $host, $uptime, $version, $desc];
1388 1408
1389 $y++; 1409 $y++;
1390 1410
1391 $table->add_at (scalar @$m, $y, new CFPlus::UI::VBox children => [ 1411 $table->add_at (scalar @$m, $y, new DC::UI::VBox children => [
1392 (new CFPlus::UI::Button 1412 (new DC::UI::Button
1393 text => "Use", 1413 text => "Use",
1394 tooltip => "Put this server into the <b>Host:Port</b> field", 1414 tooltip => "Put this server into the <b>Host:Port</b> field",
1395 on_activate => sub { 1415 on_activate => sub {
1396 $HOST_ENTRY->set_text ($CFG->{profile}{default}{host} = $host); 1416 $HOST_ENTRY->set_text ($CFG->{profile}{default}{host} = $host);
1397 $METASERVER->hide; 1417 $METASERVER->hide;
1398 0 1418 0
1399 }, 1419 },
1400 ), 1420 ),
1401 (new CFPlus::UI::Empty expand => 1), 1421 (new DC::UI::Empty expand => 1),
1402 ]); 1422 ]);
1403 1423
1404 $table->add_at ($_, $y, new CFPlus::UI::Label 1424 $table->add_at ($_, $y, new DC::UI::Label
1405 max_w => $::WIDTH * 0.4, 1425 max_w => $::WIDTH * 0.4,
1406 ellipsise => 0, 1426 ellipsise => 0,
1407 align => $align[$_], 1427 align => $align[$_],
1408 text => $m->[$_], 1428 text => $m->[$_],
1409 tooltip => $tip[$_], 1429 tooltip => $tip[$_],
1419 }; 1439 };
1420 1440
1421} 1441}
1422 1442
1423sub metaserver_dialog { 1443sub metaserver_dialog {
1424 my $vbox = new CFPlus::UI::VBox; 1444 my $vbox = new DC::UI::VBox;
1425 my $table = new CFPlus::UI::Table; 1445 my $table = new DC::UI::Table;
1426 $vbox->add (new CFPlus::UI::ScrolledWindow expand => 1, child => $table); 1446 $vbox->add (new DC::UI::ScrolledWindow expand => 1, child => $table);
1427 1447
1428 my $dialog = new CFPlus::UI::Toplevel 1448 my $dialog = new DC::UI::Toplevel
1429 title => "Server List", 1449 title => "Server List",
1430 name => 'metaserver_dialog', 1450 name => 'metaserver_dialog',
1431 x => 'center', 1451 x => 'center',
1432 y => 'center', 1452 y => 'center',
1433 z => 3, 1453 z => 3,
1444 1464
1445 $dialog 1465 $dialog
1446} 1466}
1447 1467
1448sub login_setup { 1468sub login_setup {
1449 my $vbox = new CFPlus::UI::VBox; 1469 my $vbox = new DC::UI::VBox;
1450 1470
1451 $vbox->add (new CFPlus::UI::FancyFrame 1471 $vbox->add (new DC::UI::FancyFrame
1452 label => "Login Settings", 1472 label => "Login Settings",
1453 child => (my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 1]), 1473 child => (my $table = new DC::UI::Table expand => 1, col_expand => [0, 1]),
1454 ); 1474 );
1455 1475
1456 $table->add_at (0, 4, new CFPlus::UI::Label valign => 0, align => 1, text => "Username"); 1476 $table->add_at (0, 4, new DC::UI::Label valign => 0, align => 1, text => "Username");
1457 $table->add_at (1, 4, new CFPlus::UI::Entry 1477 $table->add_at (1, 4, new DC::UI::Entry
1458 text => $CFG->{profile}{default}{user}, 1478 text => $CFG->{profile}{default}{user},
1459 tooltip => "The name of your character on the server.", 1479 tooltip => "The name of your character on the server.",
1460 on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{user} = $value; 1 } 1480 on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{user} = $value; 1 }
1461 ); 1481 );
1462 1482
1463 $table->add_at (0, 5, new CFPlus::UI::Label valign => 0, align => 1, text => "Password"); 1483 $table->add_at (0, 5, new DC::UI::Label valign => 0, align => 1, text => "Password");
1464 $table->add_at (1, 5, new CFPlus::UI::Entry 1484 $table->add_at (1, 5, new DC::UI::Entry
1465 text => $CFG->{profile}{default}{password}, 1485 text => $CFG->{profile}{default}{password},
1466 hidden => 1, 1486 hidden => 1,
1467 tooltip => "The password for your character.", 1487 tooltip => "The password for your character.",
1468 on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{password} = $value; 1 } 1488 on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{password} = $value; 1 }
1469 ); 1489 );
1470 1490
1471 $table->add_at (1, 11, $LOGIN_BUTTON = new CFPlus::UI::Button 1491 $table->add_at (1, 11, $LOGIN_BUTTON = new DC::UI::Button
1472 expand => 1, 1492 expand => 1,
1473 align => 0, 1493 align => 0,
1474 text => "Login / Register", 1494 text => "Login / Register",
1475 tooltip => "This button will either login to the account configured above or register a new account.", 1495 tooltip => "This button will either login to the account configured above or register a new account.",
1476 on_activate => sub { 1496 on_activate => sub {
1478 : start_game; 1498 : start_game;
1479 1 1499 1
1480 }, 1500 },
1481 ); 1501 );
1482 1502
1483 $vbox->add (new CFPlus::UI::FancyFrame 1503 $vbox->add (new DC::UI::FancyFrame
1484 label => "Registering", 1504 label => "Registering",
1485 min_h => 200, 1505 min_h => 200,
1486 child => (new CFPlus::UI::Label valign => -1, ellipsise => 0, 1506 child => (new DC::UI::Label valign => -1, ellipsise => 0,
1487 markup => 1507 markup =>
1488 "To register a new account, choose a username that hasn't been taken yet and " 1508 "To register a new account, choose a username that hasn't been taken yet and "
1489 . "try to log-in. Follow the instructions in the Log tab in the message window.", 1509 . "try to log-in. Follow the instructions in the Log tab in the message window.",
1490 ), 1510 ),
1491 ); 1511 );
1492 1512
1493 $vbox 1513 $vbox
1494} 1514}
1495 1515
1496sub server_setup { 1516sub server_setup {
1497 my $vbox = new CFPlus::UI::VBox; 1517 my $vbox = new DC::UI::VBox;
1498 1518
1499 $vbox->add (new CFPlus::UI::FancyFrame 1519 $vbox->add (new DC::UI::FancyFrame
1500 label => "Connection Settings", 1520 label => "Connection Settings",
1501 child => (my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 1]), 1521 child => (my $table = new DC::UI::Table expand => 1, col_expand => [0, 1]),
1502 ); 1522 );
1503 1523
1504 my $row = 0; 1524 my $row = 0;
1505 1525
1506 $table->add_at (0, ++$row, new CFPlus::UI::Label valign => 0, align => 1, text => "Host:Port"); 1526 $table->add_at (0, ++$row, new DC::UI::Label valign => 0, align => 1, text => "Host:Port");
1507 { 1527 {
1508 $table->add_at (1, $row, my $vbox = new CFPlus::UI::VBox); 1528 $table->add_at (1, $row, my $vbox = new DC::UI::VBox);
1509 1529
1510 $vbox->add ( 1530 $vbox->add (
1511 $HOST_ENTRY = new CFPlus::UI::Entry 1531 $HOST_ENTRY = new DC::UI::Entry
1512 expand => 1, 1532 expand => 1,
1513 text => $CFG->{profile}{default}{host}, 1533 text => $CFG->{profile}{default}{host},
1514 tooltip => "The hostname or ip address of the Deliantra server to connect to", 1534 tooltip => "The hostname or ip address of the Deliantra server to connect to",
1515 on_changed => sub { 1535 on_changed => sub {
1516 my ($self, $value) = @_; 1536 my ($self, $value) = @_;
1518 1 1538 1
1519 } 1539 }
1520 ); 1540 );
1521 1541
1522 if (0) { #d# disabled 1542 if (0) { #d# disabled
1523 $vbox->add (new CFPlus::UI::Button 1543 $vbox->add (new DC::UI::Button
1524 expand => 1, 1544 expand => 1,
1525 text => "Server List", 1545 text => "Server List",
1526 other => $METASERVER, 1546 other => $METASERVER,
1527 tooltip => "Show a list of available crossfire servers", 1547 tooltip => "Show a list of available crossfire servers",
1528 on_activate => sub { $METASERVER->toggle_visibility; 0 }, 1548 on_activate => sub { $METASERVER->toggle_visibility; 0 },
1529 on_visibility_change => sub { $METASERVER->hide unless $_[1]; 1 }, 1549 on_visibility_change => sub { $METASERVER->hide unless $_[1]; 1 },
1530 ); 1550 );
1531 }#d# 1551 }#d#
1532 } 1552 }
1533 1553
1534 $table->add_at (0, ++$row, new CFPlus::UI::Label valign => 0, align => 1, text => "Map Size"); 1554 $table->add_at (0, ++$row, new DC::UI::Label valign => 0, align => 1, text => "Map Size");
1535 $table->add_at (1, $row, new CFPlus::UI::Slider 1555 $table->add_at (1, $row, new DC::UI::Slider
1536 force_w => 100, 1556 force_w => 100,
1537 range => [$CFG->{mapsize}, 10, 100, 0, 1], 1557 range => [$CFG->{mapsize}, 10, 100, 0, 1],
1538 tooltip => "This is the size of the portion of the map update the server sends you. " 1558 tooltip => "This is the size of the portion of the map update the server sends you. "
1539 . "If you set this to a high value you will be able to see further, " 1559 . "If you set this to a high value you will be able to see further, "
1540 . "but you also increase bandwidth requirements and latency. " 1560 . "but you also increase bandwidth requirements and latency. "
1541 . "This option is only used once at log-in.", 1561 . "This option is only used once at log-in.",
1542 on_changed => sub { my ($self, $value) = @_; $CFG->{mapsize} = $self->{range}[0] = $value = int $value; 1 }, 1562 on_changed => sub { my ($self, $value) = @_; $CFG->{mapsize} = $self->{range}[0] = $value = int $value; 1 },
1543 ); 1563 );
1544 1564
1545 $table->add_at (0, ++$row, new CFPlus::UI::Label valign => 0, align => 1, text => "Output-Rate"); 1565 $table->add_at (0, ++$row, new DC::UI::Label valign => 0, align => 1, text => "Output-Rate");
1546 $table->add_at (1, $row, new CFPlus::UI::Entry 1566 $table->add_at (1, $row, new DC::UI::Entry
1547 text => $CFG->{output_rate}, 1567 text => $CFG->{output_rate},
1548 tooltip => "The maximum bandwidth in bytes per second that the server should not exceed " 1568 tooltip => "The maximum bandwidth in bytes per second that the server should not exceed "
1549 . "when sending data. When 0 or unset, the server " 1569 . "when sending data. When 0 or unset, the server "
1550 . "default will be used, which is usually around 100kb/s. Most servers will " 1570 . "default will be used, which is usually around 100kb/s. Most servers will "
1551 . "dynamically find an optimal rate, so adjust this only when necessary.", 1571 . "dynamically find an optimal rate, so adjust this only when necessary.",
1552 on_changed => sub { $CFG->{output_rate} = $_[1]; 1 }, 1572 on_changed => sub { $CFG->{output_rate} = $_[1]; 1 },
1553 ); 1573 );
1554 1574
1555 $vbox->add (new CFPlus::UI::FancyFrame 1575 $vbox->add (new DC::UI::FancyFrame
1556 label => "Server Info", 1576 label => "Server Info",
1557 child => ($SERVER_INFO = new CFPlus::UI::Label ellipsise => 0), 1577 child => ($SERVER_INFO = new DC::UI::Label ellipsise => 0),
1558 ); 1578 );
1559 1579
1560 $vbox 1580 $vbox
1561} 1581}
1562 1582
1563sub client_setup { 1583sub client_setup {
1564 my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 1]; 1584 my $table = new DC::UI::Table expand => 1, col_expand => [0, 1];
1565 1585
1566 my $row = 0; 1586 my $row = 0;
1567 1587
1568 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Tip of the day"); 1588 $table->add_at (0, $row, new DC::UI::Label valign => 0, align => 1, text => "Tip of the day");
1569 $table->add_at (1, $row++, new CFPlus::UI::CheckBox 1589 $table->add_at (1, $row++, new DC::UI::CheckBox
1570 state => $CFG->{show_tips}, 1590 state => $CFG->{show_tips},
1571 tooltip => "Show the <b>Tip of the day</b> window at startup?", 1591 tooltip => "Show the <b>Tip of the day</b> window at startup?",
1572 on_changed => sub { 1592 on_changed => sub {
1573 my ($self, $value) = @_; 1593 my ($self, $value) = @_;
1574 $CFG->{show_tips} = $value; 1594 $CFG->{show_tips} = $value;
1575 0 1595 0
1576 } 1596 }
1577 ); 1597 );
1578 1598
1579 $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Messages Window Size"); 1599 $table->add_at (0, $row, new DC::UI::Label valign => 0, align => 1, text => "Messages Window Size");
1580 $table->add_at (1, $row++, my $saycmd = new CFPlus::UI::Entry 1600 $table->add_at (1, $row++, my $saycmd = new DC::UI::Entry
1581 text => $CFG->{logview_max_par}, 1601 text => $CFG->{logview_max_par},
1582 tooltip => "This is maximum number of messages remembered in the <b>Messages</b> window. If the server " 1602 tooltip => "This is maximum number of messages remembered in the <b>Messages</b> window. If the server "
1583 . "sends more messages than this number, older messages get removed to save memory and " 1603 . "sends more messages than this number, older messages get removed to save memory and "
1584 . "computing time. A value of <b>0</b> disables this feature, but that is not recommended.", 1604 . "computing time. A value of <b>0</b> disables this feature, but that is not recommended.",
1585 on_changed => sub { 1605 on_changed => sub {
1591 1611
1592 $table 1612 $table
1593} 1613}
1594 1614
1595sub autopickup_setup { 1615sub autopickup_setup {
1596 my $r = new CFPlus::UI::ScrolledWindow ( 1616 my $r = new DC::UI::ScrolledWindow (
1597 expand => 1, 1617 expand => 1,
1598 scroll_y => 1 1618 scroll_y => 1
1599 ); 1619 );
1600 $r->add (my $table = new CFPlus::UI::Table 1620 $r->add (my $table = new DC::UI::Table
1601 row_expand => [0], 1621 row_expand => [0],
1602 col_expand => [0, 1, 0, 1], 1622 col_expand => [0, 1, 0, 1],
1603 ); 1623 );
1604 1624
1605 for ( 1625 for (
1643 ], 1663 ],
1644 ["Weight/Value ratio", 2, 17] 1664 ["Weight/Value ratio", 2, 17]
1645 ) 1665 )
1646 { 1666 {
1647 my ($title, $x, $y, @bits) = @$_; 1667 my ($title, $x, $y, @bits) = @$_;
1648 $table->add_at ($x, $y, new CFPlus::UI::Label text => $title, align => 1, fg => [1, 1, 0]); 1668 $table->add_at ($x, $y, new DC::UI::Label text => $title, align => 1, fg => [1, 1, 0]);
1649 1669
1650 for (@bits) { 1670 for (@bits) {
1651 ++$y; 1671 ++$y;
1652 1672
1653 my $mask = $_->[1]; 1673 my $mask = $_->[1];
1654 $table->add_at ($x , $y, new CFPlus::UI::Label text => $_->[0], align => 1, expand => 1); 1674 $table->add_at ($x , $y, new DC::UI::Label text => $_->[0], align => 1, expand => 1);
1655 $table->add_at ($x+1, $y, my $checkbox = new CFPlus::UI::CheckBox 1675 $table->add_at ($x+1, $y, my $checkbox = new DC::UI::CheckBox
1656 state => $::CFG->{pickup} & $mask, 1676 state => $::CFG->{pickup} & $mask,
1657 on_changed => sub { 1677 on_changed => sub {
1658 my ($box, $value) = @_; 1678 my ($box, $value) = @_;
1659 1679
1660 if ($value) { 1680 if ($value) {
1671 1691
1672 ${$_->[2]} = $checkbox if $_->[2]; 1692 ${$_->[2]} = $checkbox if $_->[2];
1673 } 1693 }
1674 } 1694 }
1675 1695
1676 $table->add_at (2, 18, new CFPlus::UI::ValSlider 1696 $table->add_at (2, 18, new DC::UI::ValSlider
1677 range => [$::CFG->{pickup} & 0xF, 0, 16, 1, 1], 1697 range => [$::CFG->{pickup} & 0xF, 0, 16, 1, 1],
1678 template => ">= 99", 1698 template => ">= 99",
1679 to_value => sub { ">= " . 5 * $_[0] }, 1699 to_value => sub { ">= " . 5 * $_[0] },
1680 on_changed => sub { 1700 on_changed => sub {
1681 my ($slider, $value) = @_; 1701 my ($slider, $value) = @_;
1684 $::CFG->{pickup} |= int $value 1704 $::CFG->{pickup} |= int $value
1685 if $value; 1705 if $value;
1686 1; 1706 1;
1687 }); 1707 });
1688 1708
1689 $table->add_at (3, 18, new CFPlus::UI::Button 1709 $table->add_at (3, 18, new DC::UI::Button
1690 text => "set", 1710 text => "set",
1691 on_activate => sub { 1711 on_activate => sub {
1692 $::CONN->send_command ("pickup $::CFG->{pickup}") 1712 $::CONN->send_command ("pickup $::CFG->{pickup}")
1693 if defined $::CONN; 1713 if defined $::CONN;
1694 0 1714 0
1715 or $a->{type} <=> $b->{type} 1735 or $a->{type} <=> $b->{type}
1716 } @_ }, 1736 } @_ },
1717); 1737);
1718 1738
1719sub inventory_widget { 1739sub inventory_widget {
1720 my $hb = new CFPlus::UI::HBox homogeneous => 1; 1740 my $hb = new DC::UI::HBox homogeneous => 1;
1721 1741
1722 $hb->add (my $vb1 = new CFPlus::UI::VBox); 1742 $hb->add (my $vb1 = new DC::UI::VBox);
1723 $vb1->add (new CFPlus::UI::Label align => 0, text => "Player"); 1743 $vb1->add (new DC::UI::Label align => 0, text => "Player");
1724 1744
1725 $vb1->add (my $hb1 = new CFPlus::UI::HBox); 1745 $vb1->add (my $hb1 = new DC::UI::HBox);
1726 1746
1727 use sort 'stable'; 1747 use sort 'stable';
1728 1748
1729 $hb1->add (new CFPlus::UI::Selector 1749 $hb1->add (new DC::UI::Selector
1730 value => $::CFG->{inv_sort}, 1750 value => $::CFG->{inv_sort},
1731 options => [ 1751 options => [
1732 [type => "Type/Name"], 1752 [type => "Type/Name"],
1733 [mtime => "Recent/Normal/Locked"], 1753 [mtime => "Recent/Normal/Locked"],
1734 [weight => "Weight/Type"], 1754 [weight => "Weight/Type"],
1736 on_changed => sub { 1756 on_changed => sub {
1737 $::CFG->{inv_sort} = $_[1]; 1757 $::CFG->{inv_sort} = $_[1];
1738 $INV->set_sort_order ($SORT_ORDER{$_[1]}); 1758 $INV->set_sort_order ($SORT_ORDER{$_[1]});
1739 }, 1759 },
1740 ); 1760 );
1741 $hb1->add (new CFPlus::UI::Label text => "Weight: ", align => 1, expand => 1); 1761 $hb1->add (new DC::UI::Label text => "Weight: ", align => 1, expand => 1);
1742 #TODO# update to weigh/maxweight 1762 #TODO# update to weigh/maxweight
1743 $hb1->add ($STATWIDS->{i_weight} = new CFPlus::UI::Label align => -1); 1763 $hb1->add ($STATWIDS->{i_weight} = new DC::UI::Label align => -1);
1744 1764
1745 $vb1->add (my $sw1 = new CFPlus::UI::ScrolledWindow expand => 1, scroll_y => 1); 1765 $vb1->add (my $sw1 = new DC::UI::ScrolledWindow expand => 1, scroll_y => 1);
1746 $sw1->add ($INV = new CFPlus::UI::Inventory); 1766 $sw1->add ($INV = new DC::UI::Inventory);
1747 $INV->set_sort_order ($SORT_ORDER{$::CFG->{inv_sort}}); 1767 $INV->set_sort_order ($SORT_ORDER{$::CFG->{inv_sort}});
1748 1768
1749 $hb->add (my $vb2 = new CFPlus::UI::VBox); 1769 $hb->add (my $vb2 = new DC::UI::VBox);
1750 1770
1751 $vb2->add ($INVR_HB = new CFPlus::UI::HBox); 1771 $vb2->add ($INVR_HB = new DC::UI::HBox);
1752 1772
1753 $vb2->add (my $sw2 = new CFPlus::UI::ScrolledWindow expand => 1, scroll_y => 1); 1773 $vb2->add (my $sw2 = new DC::UI::ScrolledWindow expand => 1, scroll_y => 1);
1754 $sw2->add ($INVR = new CFPlus::UI::Inventory); 1774 $sw2->add ($INVR = new DC::UI::Inventory);
1755 1775
1756 # XXX: Call after $INVR = ... because set_opencont sets the items 1776 # XXX: Call after $INVR = ... because set_opencont sets the items
1757 CFPlus::Protocol::set_opencont ($::CONN, 0, "Floor"); 1777 DC::Protocol::set_opencont ($::CONN, 0, "Floor");
1758 1778
1759 $hb 1779 $hb
1760} 1780}
1761 1781
1762sub media_window { 1782sub media_window {
1763 my $vb = new CFPlus::UI::VBox; 1783 my $vb = new DC::UI::VBox;
1764 1784
1765 $vb->add (new CFPlus::UI::FancyFrame 1785 $vb->add (new DC::UI::FancyFrame
1766 label => "Currently playing music", 1786 label => "Currently playing music",
1767 child => new CFPlus::UI::ScrolledWindow scroll_x => 1, scroll_y => 0, 1787 child => new DC::UI::ScrolledWindow scroll_x => 1, scroll_y => 0,
1768 child => ($MUSIC_PLAYING_WIDGET = new CFPlus::UI::Label ellipsise => 0, fontsize => 0.8), 1788 child => ($MUSIC_PLAYING_WIDGET = new DC::UI::Label ellipsise => 0, fontsize => 0.8),
1769 ); 1789 );
1770 1790
1771 $vb->add (new CFPlus::UI::FancyFrame 1791 $vb->add (new DC::UI::FancyFrame
1772 label => "Other media used in this session", 1792 label => "Other media used in this session",
1773 expand => 1, 1793 expand => 1,
1774 child => ($LICENSE_WIDGET = new CFPlus::UI::TextScroller 1794 child => ($LICENSE_WIDGET = new DC::UI::TextScroller
1775 expand => 1, fontsize => 0.8, padding_x => 4, padding_y => 4), 1795 expand => 1, fontsize => 0.8, padding_x => 4, padding_y => 4),
1776 ); 1796 );
1777 1797
1778 $vb 1798 $vb
1779} 1799}
1788 or return; 1808 or return;
1789 1809
1790 $LICENSE_WIDGET->add_paragraph ({ 1810 $LICENSE_WIDGET->add_paragraph ({
1791 fg => [1, 1, 1, 1], 1811 fg => [1, 1, 1, 1],
1792 markup => "<small>" 1812 markup => "<small>"
1793 . "<b>Name:</b> " . (CFPlus::asxml $meta->{name}) . "\n" 1813 . "<b>Name:</b> " . (DC::asxml $meta->{name}) . "\n"
1794 . "<b>Author:</b> " . (CFPlus::asxml $meta->{author}) . "\n" 1814 . "<b>Author:</b> " . (DC::asxml $meta->{author}) . "\n"
1795 . "<b>Source:</b> " . (CFPlus::asxml $meta->{source}) . "\n" 1815 . "<b>Source:</b> " . (DC::asxml $meta->{source}) . "\n"
1796 . "<b>License:</b> " . (CFPlus::asxml $meta->{license}) . "\n" 1816 . "<b>License:</b> " . (DC::asxml $meta->{license}) . "\n"
1797 . "</small>", 1817 . "</small>",
1798 }); 1818 });
1799 $LICENSE_WIDGET->scroll_to_bottom; 1819 $LICENSE_WIDGET->scroll_to_bottom;
1800} 1820}
1801 1821
1809 $PL_WINDOW->show; 1829 $PL_WINDOW->show;
1810 } 1830 }
1811} 1831}
1812 1832
1813sub player_window { 1833sub player_window {
1814 my $plwin = $PL_WINDOW = new CFPlus::UI::Toplevel 1834 my $plwin = $PL_WINDOW = new DC::UI::Toplevel
1815 x => "center", 1835 x => "center",
1816 y => "center", 1836 y => "center",
1817 force_w => $WIDTH * 9/10, 1837 force_w => $WIDTH * 9/10,
1818 force_h => $HEIGHT * 9/10, 1838 force_h => $HEIGHT * 9/10,
1819 title => "Player", 1839 title => "Player",
1821 has_close_button => 1 1841 has_close_button => 1
1822 ; 1842 ;
1823 1843
1824 my $ntb = 1844 my $ntb =
1825 $PL_NOTEBOOK = 1845 $PL_NOTEBOOK =
1826 new CFPlus::UI::Notebook expand => 1; 1846 new DC::UI::Notebook expand => 1;
1827 1847
1828 $ntb->add_tab ( 1848 $ntb->add_tab (
1829 "Statistics (F2)" => $STATS_PAGE = stats_window, 1849 "Statistics (F2)" => $STATS_PAGE = stats_window,
1830 "Shows statistics, where all your Stats and Resistances are shown." 1850 "Shows statistics, where all your Stats and Resistances are shown."
1831 ); 1851 );
1832 $ntb->add_tab ( 1852 $ntb->add_tab (
1833 "Skills (F3)" => $SKILL_PAGE = skill_window, 1853 "Skills (F3)" => $SKILL_PAGE = skill_window,
1834 "Shows all your Skills." 1854 "Shows all your Skills."
1835 ); 1855 );
1836 1856
1837 my $spellsw = $SPELL_PAGE = new CFPlus::UI::ScrolledWindow (expand => 1, scroll_y => 1); 1857 my $spellsw = $SPELL_PAGE = new DC::UI::ScrolledWindow (expand => 1, scroll_y => 1);
1838 $spellsw->add ($SPELL_LIST = new CFPlus::UI::SpellList); 1858 $spellsw->add ($SPELL_LIST = new DC::UI::SpellList);
1839 $ntb->add_tab ( 1859 $ntb->add_tab (
1840 "Spellbook (F4)" => $spellsw, 1860 "Spellbook (F4)" => $spellsw,
1841 "Displays all spells you have and lets you edit keyboard shortcuts for them." 1861 "Displays all spells you have and lets you edit keyboard shortcuts for them."
1842 ); 1862 );
1843 $ntb->add_tab ( 1863 $ntb->add_tab (
1856 $plwin->add ($ntb); 1876 $plwin->add ($ntb);
1857 $plwin 1877 $plwin
1858} 1878}
1859 1879
1860sub keyboard_setup { 1880sub keyboard_setup {
1861 CFPlus::Macro::keyboard_setup 1881 DC::Macro::keyboard_setup
1862} 1882}
1863 1883
1864sub help_window { 1884sub help_window {
1865 my $win = new CFPlus::UI::Toplevel 1885 my $win = new DC::UI::Toplevel
1866 x => 'center', 1886 x => 'center',
1867 y => 'center', 1887 y => 'center',
1868 z => 4, 1888 z => 4,
1869 name => 'doc_browser', 1889 name => 'doc_browser',
1870 force_w => int $WIDTH * 7/8, 1890 force_w => int $WIDTH * 7/8,
1871 force_h => int $HEIGHT * 7/8, 1891 force_h => int $HEIGHT * 7/8,
1872 title => "Help Browser", 1892 title => "Help Browser",
1873 has_close_button => 1; 1893 has_close_button => 1;
1874 1894
1875 $win->add (my $vbox = new CFPlus::UI::VBox); 1895 $win->add (my $vbox = new DC::UI::VBox);
1876 1896
1877 $vbox->add (new CFPlus::UI::FancyFrame 1897 $vbox->add (new DC::UI::FancyFrame
1878 label => "Navigation", 1898 label => "Navigation",
1879 child => (my $buttons = new CFPlus::UI::HBox), 1899 child => (my $buttons = new DC::UI::HBox),
1880 ); 1900 );
1881 $vbox->add (my $viewer = new CFPlus::UI::TextScroller 1901 $vbox->add (my $viewer = new DC::UI::TextScroller
1882 expand => 1, fontsize => 0.8, padding_x => 4, padding_y => 4); 1902 expand => 1, fontsize => 0.8, padding_x => 4, padding_y => 4);
1883 1903
1884 my @history; 1904 my @history;
1885 my @future; 1905 my @future;
1886 my $curnode; 1906 my $curnode;
1888 my $load_node; $load_node = sub { 1908 my $load_node; $load_node = sub {
1889 my ($node, $para) = @_; 1909 my ($node, $para) = @_;
1890 1910
1891 $buttons->clear; 1911 $buttons->clear;
1892 1912
1893 $buttons->add (new CFPlus::UI::Button 1913 $buttons->add (new DC::UI::Button
1894 text => "⇤", 1914 text => "⇤",
1895 tooltip => "back to the starting page", 1915 tooltip => "back to the starting page",
1896 on_activate => sub { 1916 on_activate => sub {
1897 unshift @future, [$curnode, $viewer->current_paragraph] if $curnode; 1917 unshift @future, [$curnode, $viewer->current_paragraph] if $curnode;
1898 unshift @future, @history; 1918 unshift @future, @history;
1900 $load_node->(@{shift @future}); 1920 $load_node->(@{shift @future});
1901 }, 1921 },
1902 ); 1922 );
1903 1923
1904 if (@history) { 1924 if (@history) {
1905 $buttons->add (new CFPlus::UI::Button 1925 $buttons->add (new DC::UI::Button
1906 text => "⋘", 1926 text => "⋘",
1907 tooltip => "back to <i>" . (CFPlus::asxml CFPlus::Pod::full_path $history[-1][0]) . "</i>", 1927 tooltip => "back to <i>" . (DC::asxml DC::Pod::full_path $history[-1][0]) . "</i>",
1908 on_activate => sub { 1928 on_activate => sub {
1909 unshift @future, [$curnode, $viewer->current_paragraph] if $curnode; 1929 unshift @future, [$curnode, $viewer->current_paragraph] if $curnode;
1910 $load_node->(@{pop @history}); 1930 $load_node->(@{pop @history});
1911 }, 1931 },
1912 ); 1932 );
1913 } 1933 }
1914 1934
1915 if (@future) { 1935 if (@future) {
1916 $buttons->add (new CFPlus::UI::Button 1936 $buttons->add (new DC::UI::Button
1917 text => "⋙", 1937 text => "⋙",
1918 tooltip => "forward to <i>" . (CFPlus::asxml CFPlus::Pod::full_path $future[0][0]) . "</i>", 1938 tooltip => "forward to <i>" . (DC::asxml DC::Pod::full_path $future[0][0]) . "</i>",
1919 on_activate => sub { 1939 on_activate => sub {
1920 push @history, [$curnode, $viewer->current_paragraph]; 1940 push @history, [$curnode, $viewer->current_paragraph];
1921 $load_node->(@{shift @future}); 1941 $load_node->(@{shift @future});
1922 }, 1942 },
1923 ); 1943 );
1924 } 1944 }
1925 1945
1926 $buttons->add (new CFPlus::UI::Label text => " "); 1946 $buttons->add (new DC::UI::Label text => " ");
1927 1947
1928 my @path = CFPlus::Pod::full_path_of $node; 1948 my @path = DC::Pod::full_path_of $node;
1929 pop @path; # drop current node 1949 pop @path; # drop current node
1930 1950
1931 for my $node (@path) { 1951 for my $node (@path) {
1932 $buttons->add (new CFPlus::UI::Button 1952 $buttons->add (new DC::UI::Button
1933 text => $node->{kw}[0], 1953 text => $node->{kw}[0],
1934 tooltip => "go to <i>" . (CFPlus::asxml CFPlus::Pod::full_path $node) . "</i>", 1954 tooltip => "go to <i>" . (DC::asxml DC::Pod::full_path $node) . "</i>",
1935 on_activate => sub { 1955 on_activate => sub {
1936 push @history, [$curnode, $viewer->current_paragraph] if $curnode; @future = (); 1956 push @history, [$curnode, $viewer->current_paragraph] if $curnode; @future = ();
1937 $load_node->($node); 1957 $load_node->($node);
1938 }, 1958 },
1939 ); 1959 );
1940 $buttons->add (new CFPlus::UI::Label text => "/"); 1960 $buttons->add (new DC::UI::Label text => "/");
1941 } 1961 }
1942 1962
1943 $buttons->add (new CFPlus::UI::Label text => $node->{kw}[0], padding_x => 4, padding_y => 4); 1963 $buttons->add (new DC::UI::Label text => $node->{kw}[0], padding_x => 4, padding_y => 4);
1944 1964
1945 $curnode = $node; 1965 $curnode = $node;
1946 1966
1947 $viewer->clear; 1967 $viewer->clear;
1948 $viewer->add_paragraph (CFPlus::Pod::as_paragraphs CFPlus::Pod::section_of $curnode); 1968 $viewer->add_paragraph (DC::Pod::as_paragraphs DC::Pod::section_of $curnode);
1949 $viewer->scroll_to ($para); 1969 $viewer->scroll_to ($para);
1950 }; 1970 };
1951 1971
1952 $load_node->(CFPlus::Pod::find pod => "mainpage"); 1972 $load_node->(DC::Pod::find pod => "mainpage");
1953 1973
1954 $CFPlus::Pod::goto_document = sub { 1974 $DC::Pod::goto_document = sub {
1955 my (@path) = @_; 1975 my (@path) = @_;
1956 1976
1957 push @history, [$curnode, $viewer->current_paragraph] if $curnode; @future = (); 1977 push @history, [$curnode, $viewer->current_paragraph] if $curnode; @future = ();
1958 1978
1959 $load_node->((CFPlus::Pod::find @path)[0]); 1979 $load_node->((DC::Pod::find @path)[0]);
1960 $win->show; 1980 $win->show;
1961 }; 1981 };
1962 1982
1963 $win 1983 $win
1964} 1984}
1965 1985
1966sub open_string_query { 1986sub open_string_query {
1967 my ($title, $cb, $txt, $tooltip) = @_; 1987 my ($title, $cb, $txt, $tooltip) = @_;
1968 my $dialog = new CFPlus::UI::Toplevel 1988 my $dialog = new DC::UI::Toplevel
1969 x => "center", 1989 x => "center",
1970 y => "center", 1990 y => "center",
1971 z => 50, 1991 z => 50,
1972 force_w => $WIDTH * 4/5, 1992 force_w => $WIDTH * 4/5,
1973 title => $title; 1993 title => $title;
1974 1994
1975 $dialog->add ( 1995 $dialog->add (
1976 my $e = new CFPlus::UI::Entry 1996 my $e = new DC::UI::Entry
1977 on_activate => sub { $cb->(@_); $dialog->hide; 0 }, 1997 on_activate => sub { $cb->(@_); $dialog->hide; 0 },
1978 on_key_down => sub { $_[1]->{sym} == 27 and $dialog->hide; 0 }, 1998 on_key_down => sub { $_[1]->{sym} == 27 and $dialog->hide; 0 },
1979 tooltip => $tooltip 1999 tooltip => $tooltip
1980 ); 2000 );
1981 2001
1984 $dialog->show; 2004 $dialog->show;
1985} 2005}
1986 2006
1987sub open_quit_dialog { 2007sub open_quit_dialog {
1988 unless ($QUIT_DIALOG) { 2008 unless ($QUIT_DIALOG) {
1989 $QUIT_DIALOG = new CFPlus::UI::Toplevel 2009 $QUIT_DIALOG = new DC::UI::Toplevel
1990 x => "center", 2010 x => "center",
1991 y => "center", 2011 y => "center",
1992 z => 50, 2012 z => 50,
1993 title => "Really Quit?", 2013 title => "Really Quit?",
1994 on_key_down => sub { 2014 on_key_down => sub {
1995 my ($dialog, $ev) = @_; 2015 my ($dialog, $ev) = @_;
1996 $ev->{sym} == 27 and $dialog->hide; 2016 $ev->{sym} == 27 and $dialog->hide;
1997 } 2017 }
1998 ; 2018 ;
1999 2019
2000 $QUIT_DIALOG->add (my $vb = new CFPlus::UI::VBox expand => 1); 2020 $QUIT_DIALOG->add (my $vb = new DC::UI::VBox expand => 1);
2001 2021
2002 $vb->add (new CFPlus::UI::Label 2022 $vb->add (new DC::UI::Label
2003 text => "You should find a savebed and apply it first!", 2023 text => "You should find a savebed and apply it first!",
2004 max_w => $WIDTH * 0.25, 2024 max_w => $WIDTH * 0.25,
2005 ellipsize => 0, 2025 ellipsize => 0,
2006 ); 2026 );
2007 $vb->add (my $hb = new CFPlus::UI::HBox expand => 1); 2027 $vb->add (my $hb = new DC::UI::HBox expand => 1);
2008 $hb->add (new CFPlus::UI::Button 2028 $hb->add (new DC::UI::Button
2009 text => "Ok", 2029 text => "Ok",
2010 expand => 1, 2030 expand => 1,
2011 on_activate => sub { $QUIT_DIALOG->hide; 0 }, 2031 on_activate => sub { $QUIT_DIALOG->hide; 0 },
2012 ); 2032 );
2013 $hb->add (new CFPlus::UI::Button 2033 $hb->add (new DC::UI::Button
2014 text => "Quit anyway", 2034 text => "Quit anyway",
2015 expand => 1, 2035 expand => 1,
2016 on_activate => sub { EV::unloop EV::UNLOOP_ALL }, 2036 on_activate => sub { EV::unloop EV::UNLOOP_ALL },
2017 ); 2037 );
2018 } 2038 }
2021 $QUIT_DIALOG->grab_focus; 2041 $QUIT_DIALOG->grab_focus;
2022} 2042}
2023 2043
2024sub show_tip_of_the_day { 2044sub show_tip_of_the_day {
2025 # find all tips 2045 # find all tips
2026 my @tod = CFPlus::Pod::find tip_of_the_day => "*"; 2046 my @tod = DC::Pod::find tip_of_the_day => "*";
2027 2047
2028 CFPlus::DB::get state => "tip_of_the_day", sub { 2048 DC::DB::get state => "tip_of_the_day", sub {
2029 my ($todindex) = @_; 2049 my ($todindex) = @_;
2030 $todindex = 0 if $todindex >= @tod; 2050 $todindex = 0 if $todindex >= @tod;
2031 CFPlus::DB::put state => tip_of_the_day => $todindex + 1, sub { }; 2051 DC::DB::put state => tip_of_the_day => $todindex + 1, sub { };
2032 2052
2033 # create dialog 2053 # create dialog
2034 my $dialog; 2054 my $dialog;
2035 2055
2036 my $close = sub { 2056 my $close = sub {
2037 $dialog->destroy; 2057 $dialog->destroy;
2038 }; 2058 };
2039 2059
2040 $dialog = new CFPlus::UI::Toplevel 2060 $dialog = new DC::UI::Toplevel
2041 x => "center", 2061 x => "center",
2042 y => "center", 2062 y => "center",
2043 z => 3, 2063 z => 3,
2044 name => 'tip_of_the_day', 2064 name => 'tip_of_the_day',
2045 force_w => int $WIDTH * 4/9, 2065 force_w => int $WIDTH * 4/9,
2046 force_h => int $WIDTH * 2/9, 2066 force_h => int $WIDTH * 2/9,
2047 title => "Tip of the day #" . (1 + $todindex), 2067 title => "Tip of the day #" . (1 + $todindex),
2048 child => my $vbox = new CFPlus::UI::VBox, 2068 child => my $vbox = new DC::UI::VBox,
2049 has_close_button => 1, 2069 has_close_button => 1,
2050 on_delete => $close, 2070 on_delete => $close,
2051 ; 2071 ;
2052 2072
2053 $vbox->add (my $viewer = new CFPlus::UI::TextScroller 2073 $vbox->add (my $viewer = new DC::UI::TextScroller
2054 expand => 1, fontsize => 0.8, padding_x => 4, padding_y => 4); 2074 expand => 1, fontsize => 0.8, padding_x => 4, padding_y => 4);
2055 $viewer->add_paragraph (CFPlus::Pod::as_paragraphs CFPlus::Pod::section_of $tod[$todindex]); 2075 $viewer->add_paragraph (DC::Pod::as_paragraphs DC::Pod::section_of $tod[$todindex]);
2056 2076
2057 $vbox->add (my $table = new CFPlus::UI::Table col_expand => [0, 1]); 2077 $vbox->add (my $table = new DC::UI::Table col_expand => [0, 1]);
2058 2078
2059 $table->add_at (0, 0, new CFPlus::UI::Button 2079 $table->add_at (0, 0, new DC::UI::Button
2060 text => "Close", 2080 text => "Close",
2061 tooltip => "Close the tip of the day window. To never see it again, disable the tip of the day in the <b>Server Setup</b>.", 2081 tooltip => "Close the tip of the day window. To never see it again, disable the tip of the day in the <b>Server Setup</b>.",
2062 on_activate => $close, 2082 on_activate => $close,
2063 ); 2083 );
2064 2084
2065 $table->add_at (2, 0, new CFPlus::UI::Button 2085 $table->add_at (2, 0, new DC::UI::Button
2066 text => "Next", 2086 text => "Next",
2067 tooltip => "Show the next <b>Tip of the day</b>.", 2087 tooltip => "Show the next <b>Tip of the day</b>.",
2068 on_activate => sub { 2088 on_activate => sub {
2069 $close->(); 2089 $close->();
2070 &show_tip_of_the_day; 2090 &show_tip_of_the_day;
2074 $dialog->show; 2094 $dialog->show;
2075 }; 2095 };
2076} 2096}
2077 2097
2078sub sdl_init { 2098sub sdl_init {
2079 CFPlus::SDL_Init 2099 DC::SDL_Init
2080 and die "SDL::Init failed!\n"; 2100 and die "SDL::Init failed!\n";
2081} 2101}
2082 2102
2083sub video_init { 2103sub video_init {
2084 $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} >= @SDL_MODES; 2104 $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} >= @SDL_MODES;
2087 2107
2088 ($WIDTH, $HEIGHT, my ($rgb, $alpha)) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; 2108 ($WIDTH, $HEIGHT, my ($rgb, $alpha)) = @{ $SDL_MODES[$CFG->{sdl_mode}] };
2089 $FULLSCREEN = $CFG->{fullscreen}; 2109 $FULLSCREEN = $CFG->{fullscreen};
2090 $FAST = $CFG->{fast}; 2110 $FAST = $CFG->{fast};
2091 2111
2092 CFPlus::SDL_SetVideoMode $WIDTH, $HEIGHT, $rgb, $alpha, $FULLSCREEN 2112 DC::SDL_SetVideoMode $WIDTH, $HEIGHT, $rgb, $alpha, $FULLSCREEN
2093 or die "SDL_SetVideoMode failed: " . (CFPlus::SDL_GetError) . "\n"; 2113 or die "SDL_SetVideoMode failed: " . (DC::SDL_GetError) . "\n";
2094 2114
2095 $SDL_ACTIVE = 1; 2115 $SDL_ACTIVE = 1;
2096 $LAST_REFRESH = time - 0.01; 2116 $LAST_REFRESH = time - 0.01;
2097 2117
2098 CFPlus::OpenGL::init; 2118 DC::OpenGL::init;
2099 CFPlus::Macro::init; 2119 DC::Macro::init;
2100 2120
2101 $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize}; 2121 $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize};
2102 2122
2103 $CFPlus::UI::ROOT->configure (0, 0, $WIDTH, $HEIGHT);#d# 2123 $DC::UI::ROOT->configure (0, 0, $WIDTH, $HEIGHT);#d#
2104 2124
2105 ############################################################################# 2125 #############################################################################
2106 2126
2107 if ($DEBUG_STATUS) { 2127 if ($DEBUG_STATUS) {
2108 CFPlus::UI::rescale_widgets $WIDTH / $old_w, $HEIGHT / $old_h; 2128 DC::UI::rescale_widgets $WIDTH / $old_w, $HEIGHT / $old_h;
2109 } else { 2129 } else {
2110 # create/configure the widgets 2130 # create/configure the widgets
2111 2131
2112 $CFPlus::UI::ROOT->connect (key_down => sub { 2132 $DC::UI::ROOT->connect (key_down => sub {
2113 my (undef, $ev) = @_; 2133 my (undef, $ev) = @_;
2114 2134
2115 if (my @macros = CFPlus::Macro::find $ev) { 2135 if (my @macros = DC::Macro::find $ev) {
2116 CFPlus::Macro::execute $_ for @macros; 2136 DC::Macro::execute $_ for @macros;
2117 2137
2118 return 1; 2138 return 1;
2119 } 2139 }
2120 2140
2121 0 2141 0
2122 }); 2142 });
2123 2143
2124 $DEBUG_STATUS = new CFPlus::UI::Label 2144 $DEBUG_STATUS = new DC::UI::Label
2125 padding => 0, 2145 padding => 0,
2126 z => 100, 2146 z => 100,
2127 force_x => "max", 2147 force_x => "max",
2128 force_y => 0; 2148 force_y => 0;
2129 $DEBUG_STATUS->show; 2149 $DEBUG_STATUS->show;
2130 2150
2131 $STATUSBOX = new CFPlus::UI::Statusbox; 2151 $STATUSBOX = new DC::UI::Statusbox;
2132 $STATUSBOX->add ("Use <b>Alt-Enter</b> to toggle fullscreen mode", timeout => 864000, pri => -100, color => [1, 1, 1, 0.8]); 2152 $STATUSBOX->add ("Use <b>Alt-Enter</b> to toggle fullscreen mode", timeout => 864000, pri => -100, color => [1, 1, 1, 0.8]);
2133 2153
2134 (new CFPlus::UI::Frame 2154 (new DC::UI::Frame
2135 bg => [0, 0, 0, 0.4], 2155 bg => [0, 0, 0, 0.4],
2136 force_x => 0, 2156 force_x => 0,
2137 force_y => "max", 2157 force_y => "max",
2138 child => $STATUSBOX, 2158 child => $STATUSBOX,
2139 )->show; 2159 )->show;
2140 2160
2141 CFPlus::UI::Toplevel->new ( 2161 DC::UI::Toplevel->new (
2142 title => "Minimap", 2162 title => "Minimap",
2143 name => "mapmap", 2163 name => "mapmap",
2144 x => 0, 2164 x => 0,
2145 y => $FONTSIZE + 8, 2165 y => $FONTSIZE + 8,
2146 border_bg => [1, 1, 1, 192/255], 2166 border_bg => [1, 1, 1, 192/255],
2147 bg => [1, 1, 1, 0], 2167 bg => [1, 1, 1, 0],
2148 child => ($MAPMAP = new CFPlus::MapWidget::MapMap 2168 child => ($MAPMAP = new DC::MapWidget::MapMap
2149 tooltip => "<b>Map</b>. On servers that support this feature, this will display an overview of the surrounding areas.", 2169 tooltip => "<b>Map</b>. On servers that support this feature, this will display an overview of the surrounding areas.",
2150 ), 2170 ),
2151 )->show; 2171 )->show;
2152 2172
2153 $MAPWIDGET = new CFPlus::MapWidget; 2173 $MAPWIDGET = new DC::MapWidget;
2154 $MAPWIDGET->connect (activate_console => sub { 2174 $MAPWIDGET->connect (activate_console => sub {
2155 my ($mapwidget, $preset) = @_; 2175 my ($mapwidget, $preset) = @_;
2156 2176
2157 $MESSAGE_WINDOW->activate_console ($preset) 2177 $MESSAGE_WINDOW->activate_console ($preset)
2158 if $MESSAGE_WINDOW; 2178 if $MESSAGE_WINDOW;
2159 }); 2179 });
2160 $MAPWIDGET->show; 2180 $MAPWIDGET->show;
2161 $MAPWIDGET->grab_focus; 2181 $MAPWIDGET->grab_focus;
2162 2182
2163 $COMPLETER = new CFPlus::MapWidget::Command:: 2183 $COMPLETER = new DC::MapWidget::Command::
2164 command => { }, 2184 command => { },
2165 tooltip => "#completer_help", 2185 tooltip => "#completer_help",
2166 ; 2186 ;
2167 2187
2168 $SETUP_DIALOG = new CFPlus::UI::Toplevel 2188 $SETUP_DIALOG = new DC::UI::Toplevel
2169 title => "Setup", 2189 title => "Setup",
2170 name => "setup_dialog", 2190 name => "setup_dialog",
2171 x => 'center', 2191 x => 'center',
2172 y => 'center', 2192 y => 'center',
2173 z => 2, 2193 z => 2,
2175 force_h => $::HEIGHT * 0.6, 2195 force_h => $::HEIGHT * 0.6,
2176 has_close_button => 1, 2196 has_close_button => 1,
2177 ; 2197 ;
2178 2198
2179 $METASERVER = metaserver_dialog; 2199 $METASERVER = metaserver_dialog;
2180 $MESSAGE_WINDOW = new CFPlus::UI::MessageWindow; 2200 $MESSAGE_WINDOW = new DC::UI::MessageWindow;
2181 2201
2182 $SETUP_DIALOG->add ($SETUP_NOTEBOOK = new CFPlus::UI::Notebook expand => 1, debug => 1, 2202 $SETUP_DIALOG->add ($SETUP_NOTEBOOK = new DC::UI::Notebook expand => 1, debug => 1,
2183 filter => new CFPlus::UI::ScrolledWindow expand => 1, scroll_y => 1); 2203 filter => new DC::UI::ScrolledWindow expand => 1, scroll_y => 1);
2184 2204
2185 $SETUP_NOTEBOOK->add_tab (Login => $SETUP_LOGIN = login_setup, 2205 $SETUP_NOTEBOOK->add_tab (Login => $SETUP_LOGIN = login_setup,
2186 "Configure the server to play on, your username and password."); 2206 "Configure the server to play on, your username and password.");
2187 $SETUP_NOTEBOOK->add_tab (Server => $SETUP_SERVER = server_setup, 2207 $SETUP_NOTEBOOK->add_tab (Server => $SETUP_SERVER = server_setup,
2188 "Configure other server related options."); 2208 "Configure other server related options.");
2200 . "After pressing the combo the binding will be saved automatically and the " 2220 . "After pressing the combo the binding will be saved automatically and the "
2201 . "binding editor closes"); 2221 . "binding editor closes");
2202 $SETUP_NOTEBOOK->add_tab (Debug => debug_setup, 2222 $SETUP_NOTEBOOK->add_tab (Debug => debug_setup,
2203 "Some debuggin' options. Do not ask."); 2223 "Some debuggin' options. Do not ask.");
2204 2224
2205 $BUTTONBAR = new CFPlus::UI::Buttonbar x => 0, y => 0, z => 200; # put on top 2225 $BUTTONBAR = new DC::UI::Buttonbar x => 0, y => 0, z => 200; # put on top
2206 2226
2207 $BUTTONBAR->add (new CFPlus::UI::Flopper text => "Setup", other => $SETUP_DIALOG, 2227 $BUTTONBAR->add (new DC::UI::Flopper text => "Setup", other => $SETUP_DIALOG,
2208 tooltip => "Toggles a dialog where you can configure all aspects of this client."); 2228 tooltip => "Toggles a dialog where you can configure all aspects of this client.");
2209 2229
2210 $BUTTONBAR->add (new CFPlus::UI::Flopper text => "Message Window", other => $MESSAGE_WINDOW, 2230 $BUTTONBAR->add (new DC::UI::Flopper text => "Message Window", other => $MESSAGE_WINDOW,
2211 tooltip => "Toggles the server message log, where the client collects <i>all</i> messages from the server."); 2231 tooltip => "Toggles the server message log, where the client collects <i>all</i> messages from the server.");
2212 2232
2213 make_gauge_window->show; # XXX: this has to be set before make_stats_window as make_stats_window calls update_stats_window which updated the gauges also X-D 2233 make_gauge_window->show; # XXX: this has to be set before make_stats_window as make_stats_window calls update_stats_window which updated the gauges also X-D
2214 2234
2215 $BUTTONBAR->add (new CFPlus::UI::Flopper text => "Playerbook", other => player_window, 2235 $BUTTONBAR->add (new DC::UI::Flopper text => "Playerbook", other => player_window,
2216 tooltip => "Toggles the player view, where you can manage Inventory, Spells, Skills and see your Stats."); 2236 tooltip => "Toggles the player view, where you can manage Inventory, Spells, Skills and see your Stats.");
2217 2237
2218 $BUTTONBAR->add (new CFPlus::UI::Button 2238 $BUTTONBAR->add (new DC::UI::Button
2219 text => "Save Config", 2239 text => "Save Config",
2220 tooltip => "Saves the options chosen in the client setting, server settings and the window layout to be restored on later runs.", 2240 tooltip => "Saves the options chosen in the client setting, server settings and the window layout to be restored on later runs.",
2221 on_activate => sub { 2241 on_activate => sub {
2222 $::CFG->{layout} = CFPlus::UI::get_layout; 2242 $::CFG->{layout} = DC::UI::get_layout;
2223 CFPlus::write_cfg "$Crossfire::VARDIR/cfplusrc"; 2243 DC::write_cfg "$Deliantra::VARDIR/client.cf";
2224 status "Configuration Saved"; 2244 status "Configuration Saved";
2225 0 2245 0
2226 }, 2246 },
2227 ); 2247 );
2228 2248
2229 $BUTTONBAR->add (new CFPlus::UI::Flopper text => "Help!", other => $HELP_WINDOW = help_window, 2249 $BUTTONBAR->add (new DC::UI::Flopper text => "Help!", other => $HELP_WINDOW = help_window,
2230 tooltip => "View Documentation"); 2250 tooltip => "View Documentation");
2231 2251
2232 2252
2233 $BUTTONBAR->add (new CFPlus::UI::Button 2253 $BUTTONBAR->add (new DC::UI::Button
2234 text => "Quit", 2254 text => "Quit",
2235 tooltip => "Terminates the program", 2255 tooltip => "Terminates the program",
2236 on_activate => sub { 2256 on_activate => sub {
2237 if ($CONN) { 2257 if ($CONN) {
2238 open_quit_dialog; 2258 open_quit_dialog;
2250 2270
2251 $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]); 2271 $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]);
2252} 2272}
2253 2273
2254sub video_shutdown { 2274sub video_shutdown {
2255 CFPlus::OpenGL::shutdown; 2275 DC::OpenGL::shutdown;
2256 2276
2257 undef $SDL_ACTIVE; 2277 undef $SDL_ACTIVE;
2258} 2278}
2259 2279
2260my %animate_object; 2280my %animate_object;
2261my $animate_timer; 2281my $animate_timer;
2262 2282
2263my $fps = 9; 2283my $fps = 9;
2264 2284
2265sub force_refresh { 2285sub force_refresh {
2266 $WANT_REFRESH->stop;
2267
2268 if ($ENV{CFPLUS_DEBUG} & 4) { 2286 if ($ENV{CFPLUS_DEBUG} & 4) {
2269 $fps = $fps * 0.98 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.02; 2287 $fps = $fps * 0.98 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.02;
2270 debug sprintf "%3.2f", $fps; 2288 debug sprintf "%3.2f", $fps;
2271 } 2289 }
2272 2290
2291 undef $WANT_REFRESH;
2292 $_[0]->stop;
2293
2273 $CFPlus::UI::ROOT->draw; 2294 $DC::UI::ROOT->draw;
2274 CFPlus::SDL_GL_SwapBuffers; 2295 DC::SDL_GL_SwapBuffers;
2275 $LAST_REFRESH = $NOW; 2296 $LAST_REFRESH = $NOW;
2276} 2297}
2277 2298
2278$WANT_REFRESH = EV::idle_ns \&force_refresh; 2299my $want_refresh = EV::idle_ns \&force_refresh;
2279 2300
2280my $input = EV::timer 0, 1/60, sub { 2301my $input = EV::periodic 0, 1/60, undef, sub {
2281 $NOW = time; 2302 $NOW = time;
2282 2303
2283 ($SDL_CB{$_->{type}} || sub { warn "unhandled event $_->{type}" })->($_) 2304 ($SDL_CB{$_->{type}} || sub { warn "unhandled event $_->{type}" })->($_)
2284 for CFPlus::poll_events; 2305 for DC::poll_events;
2285 2306
2286 if (%animate_object) { 2307 if (%animate_object) {
2287 $_->animate ($LAST_REFRESH - $NOW) for values %animate_object; 2308 $_->animate ($LAST_REFRESH - $NOW) for values %animate_object;
2288 $WANT_REFRESH->start; 2309 $WANT_REFRESH = 1;
2289 } 2310 }
2311
2312 $want_refresh->start
2313 if $WANT_REFRESH;
2290}; 2314};
2291 2315
2292sub animation_start { 2316sub animation_start {
2293 my ($widget) = @_; 2317 my ($widget) = @_;
2294 $animate_object{$widget} = $widget; 2318 $animate_object{$widget} = $widget;
2298 my ($widget) = @_; 2322 my ($widget) = @_;
2299 delete $animate_object{$widget}; 2323 delete $animate_object{$widget};
2300} 2324}
2301 2325
2302%SDL_CB = ( 2326%SDL_CB = (
2303 CFPlus::SDL_QUIT => sub { 2327 DC::SDL_QUIT => sub {
2304 EV::unloop EV::UNLOOP_ALL; 2328 EV::unloop EV::UNLOOP_ALL;
2305 }, 2329 },
2306 CFPlus::SDL_VIDEORESIZE => sub { 2330 DC::SDL_VIDEORESIZE => sub {
2307 }, 2331 },
2308 CFPlus::SDL_VIDEOEXPOSE => sub { 2332 DC::SDL_VIDEOEXPOSE => sub {
2309 CFPlus::UI::full_refresh; 2333 DC::UI::full_refresh;
2310 }, 2334 },
2311 CFPlus::SDL_ACTIVEEVENT => sub { 2335 DC::SDL_ACTIVEEVENT => sub {
2312# not useful, as APPACTIVE include sonly iconified state, not unmapped 2336# not useful, as APPACTIVE includes only iconified state, not unmapped
2313# printf "active %x %x %x\n", $_[0]{gain}, $_[0]{state}, CFPlus::SDL_GetAppState;#d# 2337# printf "active %x %x %x\n", $_[0]{gain}, $_[0]{state}, DC::SDL_GetAppState;#d#
2314# printf "a %x\n", CFPlus::SDL_GetAppState & CFPlus::SDL_APPACTIVE;#d# 2338# printf "a %x\n", DC::SDL_GetAppState & DC::SDL_APPACTIVE;#d#
2315# printf "A\n" if $_[0]{state} & CFPlus::SDL_APPACTIVE; 2339# printf "A\n" if $_[0]{state} & DC::SDL_APPACTIVE;
2316# printf "K\n" if $_[0]{state} & CFPlus::SDL_APPINPUTFOCUS; 2340# printf "K\n" if $_[0]{state} & DC::SDL_APPINPUTFOCUS;
2317# printf "M\n" if $_[0]{state} & CFPlus::SDL_APPMOUSEFOCUS; 2341# printf "M\n" if $_[0]{state} & DC::SDL_APPMOUSEFOCUS;
2318 }, 2342 },
2319 CFPlus::SDL_KEYDOWN => sub { 2343 DC::SDL_KEYDOWN => sub {
2320 if ($_[0]{mod} & CFPlus::KMOD_ALT && $_[0]{sym} == 13) { 2344 if ($_[0]{mod} & DC::KMOD_ALT && $_[0]{sym} == 13) {
2321 # alt-enter 2345 # alt-enter
2322 $FULLSCREEN_ENABLE->toggle; 2346 $FULLSCREEN_ENABLE->toggle;
2323 video_shutdown; 2347 video_shutdown;
2324 video_init; 2348 video_init;
2325 } else { 2349 } else {
2326 CFPlus::UI::feed_sdl_key_down_event ($_[0]); 2350 DC::UI::feed_sdl_key_down_event ($_[0]);
2327 } 2351 }
2328 }, 2352 },
2329 CFPlus::SDL_KEYUP => \&CFPlus::UI::feed_sdl_key_up_event, 2353 DC::SDL_KEYUP => \&DC::UI::feed_sdl_key_up_event,
2330 CFPlus::SDL_MOUSEMOTION => \&CFPlus::UI::feed_sdl_motion_event, 2354 DC::SDL_MOUSEMOTION => \&DC::UI::feed_sdl_motion_event,
2331 CFPlus::SDL_MOUSEBUTTONDOWN => \&CFPlus::UI::feed_sdl_button_down_event, 2355 DC::SDL_MOUSEBUTTONDOWN => \&DC::UI::feed_sdl_button_down_event,
2332 CFPlus::SDL_MOUSEBUTTONUP => \&CFPlus::UI::feed_sdl_button_up_event, 2356 DC::SDL_MOUSEBUTTONUP => \&DC::UI::feed_sdl_button_up_event,
2333 CFPlus::SDL_USEREVENT => sub { 2357 DC::SDL_USEREVENT => sub {
2334 if ($_[0]{code} == 1) { 2358 if ($_[0]{code} == 1) {
2335 audio_channel_finished $_[0]{data1}; 2359 audio_channel_finished $_[0]{data1};
2336 } elsif ($_[0]{code} == 0) { 2360 } elsif ($_[0]{code} == 0) {
2337 audio_music_finished; 2361 audio_music_finished;
2338 } 2362 }
2339 }, 2363 },
2340); 2364);
2341 2365
2342############################################################################# 2366#############################################################################
2343 2367
2344$SIG{INT} = $SIG{TERM} = sub { exit }; 2368$SIG{INT} = $SIG{TERM} = sub {
2369 EV::unloop;
2370 #d# TODO calling exit here hangs the process in some futex
2371};
2345 2372
2346{ 2373{
2347 CFPlus::read_cfg "$Crossfire::VARDIR/cfplusrc"; 2374 if (-e "$Deliantra::VARDIR/client.cf") {
2375 DC::read_cfg "$Deliantra::VARDIR/client.cf";
2376 } else {
2377 #TODO: compatibility cruft
2378 DC::read_cfg "$Deliantra::OLDDIR/cfplusrc";
2379 print STDERR "INFO: used old configuratrion file\n";
2380 }
2381
2348 CFPlus::DB::Server::run; 2382 DC::DB::Server::run;
2349 2383
2350 CFPlus::UI::set_layout ($::CFG->{layout}); 2384 DC::UI::set_layout ($::CFG->{layout});
2351 2385
2352 my %DEF_CFG = ( 2386 my %DEF_CFG = (
2353 sdl_mode => 0, 2387 sdl_mode => 0,
2354 fullscreen => 1, 2388 fullscreen => 1,
2355 fast => 0, 2389 fast => 0,
2401 } 2435 }
2402 } 2436 }
2403 2437
2404 sdl_init; 2438 sdl_init;
2405 2439
2406 @SDL_MODES = CFPlus::SDL_ListModes 8, 8; 2440 @SDL_MODES = DC::SDL_ListModes 8, 8;
2407 @SDL_MODES = CFPlus::SDL_ListModes 5, 0 unless @SDL_MODES; 2441 @SDL_MODES = DC::SDL_ListModes 5, 0 unless @SDL_MODES;
2408 @SDL_MODES or CFPlus::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; 2442 @SDL_MODES or DC::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)";
2409 2443
2410 @SDL_MODES = sort { $a->[0] * $a->[1] <=> $b->[0] * $b->[1] } @SDL_MODES; 2444 @SDL_MODES = sort { $a->[0] * $a->[1] <=> $b->[0] * $b->[1] } @SDL_MODES;
2411 2445
2412 $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES; 2446 $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES;
2413 2447
2414 { 2448 {
2415 my @fonts = map CFPlus::find_rcfile "fonts/$_", qw( 2449 my @fonts = map DC::find_rcfile "fonts/$_", qw(
2416 DejaVuSans.ttf 2450 DejaVuSans.ttf
2417 DejaVuSansMono.ttf 2451 DejaVuSansMono.ttf
2418 DejaVuSans-Bold.ttf 2452 DejaVuSans-Bold.ttf
2419 DejaVuSansMono-Bold.ttf 2453 DejaVuSansMono-Bold.ttf
2420 DejaVuSans-Oblique.ttf 2454 DejaVuSans-Oblique.ttf
2421 DejaVuSansMono-Oblique.ttf 2455 DejaVuSansMono-Oblique.ttf
2422 DejaVuSans-BoldOblique.ttf 2456 DejaVuSans-BoldOblique.ttf
2423 DejaVuSansMono-BoldOblique.ttf 2457 DejaVuSansMono-BoldOblique.ttf
2424 ); 2458 );
2425 2459
2426 CFPlus::add_font $_ for @fonts; 2460 DC::add_font $_ for @fonts;
2427 2461
2428 CFPlus::pango_init; 2462 DC::pango_init;
2429 2463
2430 $FONT_PROP = new_from_file CFPlus::Font $fonts[0]; 2464 $FONT_PROP = new_from_file DC::Font $fonts[0];
2431 $FONT_FIXED = new_from_file CFPlus::Font $fonts[1]; 2465 $FONT_FIXED = new_from_file DC::Font $fonts[1];
2432 2466
2433 $FONT_PROP->make_default; 2467 $FONT_PROP->make_default;
2434 } 2468 }
2435 2469
2436# compare mono (ft) vs. rgba (cairo) 2470# compare mono (ft) vs. rgba (cairo)
2437# ft - 1.8s, cairo 3s, even in alpha-only mode 2471# ft - 1.8s, cairo 3s, even in alpha-only mode
2438# for my $rgba (0..1) { 2472# for my $rgba (0..1) {
2439# my $t1 = Time::HiRes::time; 2473# my $t1 = Time::HiRes::time;
2440# for (1..1000) { 2474# for (1..1000) {
2441# my $layout = CFPlus::Layout->new ($rgba); 2475# my $layout = DC::Layout->new ($rgba);
2442# $layout->set_text ("hallo" x 100); 2476# $layout->set_text ("hallo" x 100);
2443# $layout->render; 2477# $layout->render;
2444# } 2478# }
2445# my $t2 = Time::HiRes::time; 2479# my $t2 = Time::HiRes::time;
2446# warn $t2-$t1; 2480# warn $t2-$t1;
2459 2493
2460EV::loop; 2494EV::loop;
2461 2495
2462#video_shutdown; 2496#video_shutdown;
2463#audio_shutdown; 2497#audio_shutdown;
2498DC::OpenGL::quit;
2464CFPlus::SDL_Quit; 2499DC::SDL_Quit;
2465CFPlus::DB::Server::stop; 2500DC::DB::Server::stop;
2466 2501
2467=head1 NAME 2502=head1 NAME
2468 2503
2469deliantra - A Deliantra MORPG game client 2504deliantra - A Deliantra MORPG game client
2470 2505

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines