… | |
… | |
56 | |
56 | |
57 | if ($^O eq "MSWin32") { |
57 | if ($^O eq "MSWin32") { |
58 | # pango is relocatable on win32 |
58 | # pango is relocatable on win32 |
59 | } else { |
59 | } else { |
60 | # OS X |
60 | # OS X |
61 | $ENV{FONTCONFIG_FILE} = "$root/fonts.conf"; # no effect??!?! |
|
|
62 | $ENV{FONTCONFIG_DIR} = $root; # no effect??!?! |
|
|
63 | $ENV{PANGO_RC_FILE} = "$root/pango.rc"; |
61 | $ENV{PANGO_RC_FILE} = "$root/pango.rc"; |
64 | $ENV{DYLD_LIBRARY_PATH} = $root; |
62 | $ENV{DYLD_LIBRARY_PATH} = $root; |
65 | chdir $root; # for pango modules, maybe other things |
63 | chdir $root; # for pango modules, maybe other things |
66 | } |
64 | } |
67 | |
65 | |
68 | unshift @INC, $root; |
66 | unshift @INC, $root; |
69 | } |
67 | } |
70 | } |
68 | } |
71 | |
69 | |
72 | # prepend private library directory |
70 | # prepend private library directory and prepare env |
73 | BEGIN { |
71 | BEGIN { |
74 | for (grep !ref, @INC) { |
72 | for (grep !ref, @INC) { |
75 | my $path = "$_/Deliantra/Client/private"; |
73 | my $path = "$_/Deliantra/Client/private"; |
76 | if (-d $path) { |
74 | if (-d $path) { |
77 | unshift @INC, $path; |
75 | unshift @INC, $path; |
… | |
… | |
205 | our $FLOORBOX; |
203 | our $FLOORBOX; |
206 | our $GAUGES; |
204 | our $GAUGES; |
207 | our $STATWIDS; |
205 | our $STATWIDS; |
208 | |
206 | |
209 | our $SDL_ACTIVE; |
207 | our $SDL_ACTIVE; |
210 | our %SDL_CB; |
208 | our @SDL_CB; |
211 | |
209 | |
212 | our $ALT_ENTER_MESSAGE; |
210 | our $ALT_ENTER_MESSAGE; |
213 | our $STATUSBOX; |
211 | our $STATUSBOX; |
214 | our $MODBOX; |
212 | our $MODBOX; |
215 | our $DEBUG_STATUS; |
213 | our $DEBUG_STATUS; |
… | |
… | |
550 | $MUSIC_WANT = []; |
548 | $MUSIC_WANT = []; |
551 | @MUSIC_JINGLE = (); |
549 | @MUSIC_JINGLE = (); |
552 | %AUDIO_PLAY = (); |
550 | %AUDIO_PLAY = (); |
553 | %AUDIO_CHUNK = (); |
551 | %AUDIO_CHUNK = (); |
554 | |
552 | |
|
|
553 | DC::MixMusic::halt; |
|
|
554 | DC::Mix_AllocateChannels 0; |
555 | DC::Mix_CloseAudio if $SDL_MIXER; |
555 | DC::Mix_CloseAudio if $SDL_MIXER; |
556 | undef $SDL_MIXER; |
556 | undef $SDL_MIXER; |
557 | } |
557 | } |
558 | |
558 | |
559 | ############################################################################# |
559 | ############################################################################# |
… | |
… | |
818 | |
818 | |
819 | on_connect => sub { |
819 | on_connect => sub { |
820 | if ($_[0]) { |
820 | if ($_[0]) { |
821 | DC::lowdelay fileno $CONN->{fh}; |
821 | DC::lowdelay fileno $CONN->{fh}; |
822 | |
822 | |
823 | status "login successful"; |
823 | status "successfully connected to the server"; |
824 | } else { |
824 | } else { |
825 | undef $CONN; |
825 | undef $CONN; |
826 | status "unable to connect: $!"; |
826 | status "unable to connect: $!"; |
827 | stop_game(); |
827 | stop_game(); |
828 | } |
828 | } |
… | |
… | |
843 | # hack to make SURE we find the IP address all right |
843 | # hack to make SURE we find the IP address all right |
844 | # can be removed once AnyEvent::DNS is proven stable. |
844 | # can be removed once AnyEvent::DNS is proven stable. |
845 | if ($host eq "gameserver.deliantra.net") { |
845 | if ($host eq "gameserver.deliantra.net") { |
846 | AnyEvent::DNS::a "dnstest.deliantra.net", sub { |
846 | AnyEvent::DNS::a "dnstest.deliantra.net", sub { |
847 | if ($_[0] ne "80.101.114.108") { # Perl |
847 | if ($_[0] ne "80.101.114.108") { # Perl |
|
|
848 | status "dns failure, trying differently"; |
|
|
849 | $host = eval { Socket::inet_ntoa Socket::inet_aton "gameserver.deliantra.net" }; |
|
|
850 | unless (defined $host) { |
848 | status "dns failure, using hardcoded address"; |
851 | status "dns failure, using hardcoded address"; |
849 | $host = "129.13.162.95"; |
852 | $host = "129.13.162.95"; |
|
|
853 | } |
850 | } |
854 | } |
851 | |
855 | |
852 | dc_connect $host, $port; |
856 | dc_connect $host, $port; |
853 | }; |
857 | }; |
854 | } else { |
858 | } else { |
… | |
… | |
2258 | ); |
2262 | ); |
2259 | |
2263 | |
2260 | $MENUBAR->add ($GAUGES->{exp} = new DC::UI::ExperienceProgress |
2264 | $MENUBAR->add ($GAUGES->{exp} = new DC::UI::ExperienceProgress |
2261 | padding_x => 6, |
2265 | padding_x => 6, |
2262 | padding_y => 3, |
2266 | padding_y => 3, |
2263 | tooltip => "This progress bar shows your progress towards the next character level.", |
2267 | tooltip => "This progress bar shows your overall experience and your progress towards the next character level.", |
2264 | template => " Exp: 888,888,888,888 (lvl 188) ", |
2268 | template => " Exp: 888,888,888,888 (lvl 188) ", |
2265 | ); |
2269 | ); |
2266 | |
2270 | |
2267 | $MENUBAR->add ($PICKUP_ENABLE = new DC::UI::CheckBox # checkbox bad, button better? |
2271 | $MENUBAR->add ($PICKUP_ENABLE = new DC::UI::CheckBox # checkbox bad, button better? |
2268 | tooltip => "Automatic Pickup Enable - when this checkbox is enabled, then your character " |
2272 | tooltip => "Automatic Pickup Enable - when this checkbox is enabled, then your character " |
2269 | . "will automatically pick up items as defined by your item pickup settings " |
2273 | . "will automatically pick up items as defined by your item pickup settings " |
2270 | . "in the playerbook. Often (e.g. in apartments) you want to temporarily " |
2274 | . "in the playerbook. Often (e.g. in apartments) you want to temporarily " |
2271 | . "disable autopickup by disdabling this checkbox.", |
2275 | . "disable autopickup by disabling this checkbox.", |
2272 | state => $CFG->{pickup} & PICKUP_INHIBIT ? 0 : 1, |
2276 | state => $CFG->{pickup} & PICKUP_INHIBIT ? 0 : 1, |
2273 | on_changed => sub { |
2277 | on_changed => sub { |
2274 | my ($self, $value) = @_; |
2278 | my ($self, $value) = @_; |
2275 | $CFG->{pickup} &= ~PICKUP_INHIBIT; |
2279 | $CFG->{pickup} &= ~PICKUP_INHIBIT; |
2276 | $CFG->{pickup} |= PICKUP_INHIBIT unless $_[1]; |
2280 | $CFG->{pickup} |= PICKUP_INHIBIT unless $_[1]; |
… | |
… | |
2481 | |
2485 | |
2482 | DC::UI::Toplevel->new ( |
2486 | DC::UI::Toplevel->new ( |
2483 | title => "Minimap", |
2487 | title => "Minimap", |
2484 | name => "mapmap", |
2488 | name => "mapmap", |
2485 | x => 0, |
2489 | x => 0, |
2486 | y => $FONTSIZE + 8, |
2490 | y => $::FONTSIZE + 8,#d# hack to move messages window below the menubar |
2487 | border_bg => [1, 1, 1, 192/255], |
2491 | border_bg => [1, 1, 1, 192/255], |
2488 | bg => [1, 1, 1, 0], |
2492 | bg => [1, 1, 1, 0], |
2489 | child => ($MAPMAP = new DC::MapWidget::MapMap |
2493 | child => ($MAPMAP = new DC::MapWidget::MapMap |
2490 | tooltip => "<b>Minimap</b>. This will display an overview of the surrounding areas.", |
2494 | tooltip => "<b>Minimap</b>. This will display an overview of the surrounding areas.", |
2491 | ), |
2495 | ), |
… | |
… | |
2520 | $METASERVER = metaserver_dialog; |
2524 | $METASERVER = metaserver_dialog; |
2521 | # the name is changed to not conflict with the older name as users could have hidden it |
2525 | # the name is changed to not conflict with the older name as users could have hidden it |
2522 | $MESSAGE_WINDOW = new DC::UI::Dockbar |
2526 | $MESSAGE_WINDOW = new DC::UI::Dockbar |
2523 | name => "message_window2", |
2527 | name => "message_window2", |
2524 | title => 'Messages', |
2528 | title => 'Messages', |
|
|
2529 | y => $::FONTSIZE + 8,#d# hack to move messages window below the menubar |
2525 | force_w => $::WIDTH * 0.6, |
2530 | force_w => $::WIDTH * 0.6, |
2526 | force_h => $::HEIGHT * 0.25, |
2531 | force_h => $::HEIGHT * 0.25, |
2527 | ; |
2532 | ; |
2528 | |
2533 | |
2529 | $MESSAGE_DIST = new DC::MessageDistributor dockbar => $MESSAGE_WINDOW; |
2534 | $MESSAGE_DIST = new DC::MessageDistributor dockbar => $MESSAGE_WINDOW; |
… | |
… | |
2597 | my $want_refresh = EV::prepare_ns \&force_refresh; |
2602 | my $want_refresh = EV::prepare_ns \&force_refresh; |
2598 | |
2603 | |
2599 | my $input = EV::periodic 0, 1 / $MAX_FPS, undef, sub { |
2604 | my $input = EV::periodic 0, 1 / $MAX_FPS, undef, sub { |
2600 | $NOW = EV::now; |
2605 | $NOW = EV::now; |
2601 | |
2606 | |
2602 | ($SDL_CB{$_->{type}} || sub { warn "unhandled event $_->{type}" })->($_) |
2607 | ($SDL_CB[$_->{type}] || sub { warn "unhandled event $_->{type}" })->($_) |
2603 | for DC::poll_events; |
2608 | for DC::poll_events; |
2604 | |
2609 | |
2605 | if (%animate_object) { |
2610 | if (%animate_object) { |
2606 | $_->animate ($LAST_REFRESH - $NOW) for values %animate_object; |
2611 | $_->animate ($LAST_REFRESH - $NOW) for values %animate_object; |
2607 | $WANT_REFRESH = 1; |
2612 | $WANT_REFRESH = 1; |
… | |
… | |
2619 | sub animation_stop { |
2624 | sub animation_stop { |
2620 | my ($widget) = @_; |
2625 | my ($widget) = @_; |
2621 | delete $animate_object{$widget}; |
2626 | delete $animate_object{$widget}; |
2622 | } |
2627 | } |
2623 | |
2628 | |
2624 | %SDL_CB = ( |
|
|
2625 | DC::SDL_QUIT => sub { |
2629 | $SDL_CB[DC::SDL_QUIT] = sub { |
2626 | crash "SDL_QUIT"; |
2630 | crash "SDL_QUIT"; |
2627 | EV::unloop EV::UNLOOP_ALL; |
2631 | EV::unloop EV::UNLOOP_ALL; |
2628 | }, |
2632 | }; |
2629 | DC::SDL_VIDEORESIZE => sub { |
2633 | $SDL_CB[DC::SDL_VIDEORESIZE] = sub { }; |
2630 | }, |
|
|
2631 | DC::SDL_VIDEOEXPOSE => sub { |
2634 | $SDL_CB[DC::SDL_VIDEOEXPOSE] = sub { |
2632 | DC::UI::full_refresh; |
2635 | DC::UI::full_refresh; |
2633 | }, |
2636 | }; |
2634 | DC::SDL_ACTIVEEVENT => sub { |
2637 | $SDL_CB[DC::SDL_ACTIVEEVENT] = sub { |
2635 | # not useful, as APPACTIVE includes only iconified state, not unmapped |
2638 | # not useful, as APPACTIVE includes only iconified state, not unmapped |
2636 | # printf "active %x %x %x\n", $_[0]{gain}, $_[0]{state}, DC::SDL_GetAppState;#d# |
2639 | # printf "active %x %x %x\n", $_[0]{gain}, $_[0]{state}, DC::SDL_GetAppState;#d# |
2637 | # printf "a %x\n", DC::SDL_GetAppState & DC::SDL_APPACTIVE;#d# |
2640 | # printf "a %x\n", DC::SDL_GetAppState & DC::SDL_APPACTIVE;#d# |
2638 | # printf "A\n" if $_[0]{state} & DC::SDL_APPACTIVE; |
2641 | # printf "A\n" if $_[0]{state} & DC::SDL_APPACTIVE; |
2639 | # printf "K\n" if $_[0]{state} & DC::SDL_APPINPUTFOCUS; |
2642 | # printf "K\n" if $_[0]{state} & DC::SDL_APPINPUTFOCUS; |
2640 | # printf "M\n" if $_[0]{state} & DC::SDL_APPMOUSEFOCUS; |
2643 | # printf "M\n" if $_[0]{state} & DC::SDL_APPMOUSEFOCUS; |
2641 | }, |
2644 | }; |
2642 | DC::SDL_KEYDOWN => sub { |
2645 | $SDL_CB[DC::SDL_KEYDOWN] = sub { |
2643 | if ($_[0]{mod} & DC::KMOD_ALT && $_[0]{sym} == 13) { |
2646 | if ($_[0]{mod} & DC::KMOD_ALT && $_[0]{sym} == 13) { |
2644 | # alt-enter |
2647 | # alt-enter |
2645 | video_shutdown; |
2648 | video_shutdown; |
2646 | $FULLSCREEN_ENABLE->toggle; |
2649 | $FULLSCREEN_ENABLE->toggle; |
2647 | video_init; |
2650 | video_init; |
2648 | } else { |
2651 | } else { |
2649 | &DC::UI::feed_sdl_key_down_event; |
2652 | &DC::UI::feed_sdl_key_down_event; |
2650 | } |
2653 | } |
2651 | update_modbox; |
2654 | update_modbox; |
2652 | }, |
2655 | }; |
2653 | DC::SDL_KEYUP => sub { |
2656 | $SDL_CB[DC::SDL_KEYUP] = sub { |
2654 | &DC::UI::feed_sdl_key_up_event; |
2657 | &DC::UI::feed_sdl_key_up_event; |
2655 | update_modbox; |
2658 | update_modbox; |
2656 | }, |
2659 | }; |
2657 | DC::SDL_MOUSEMOTION => \&DC::UI::feed_sdl_motion_event, |
2660 | $SDL_CB[DC::SDL_MOUSEMOTION] = \&DC::UI::feed_sdl_motion_event, |
2658 | DC::SDL_MOUSEBUTTONDOWN => \&DC::UI::feed_sdl_button_down_event, |
2661 | $SDL_CB[DC::SDL_MOUSEBUTTONDOWN] = \&DC::UI::feed_sdl_button_down_event, |
2659 | DC::SDL_MOUSEBUTTONUP => \&DC::UI::feed_sdl_button_up_event, |
2662 | $SDL_CB[DC::SDL_MOUSEBUTTONUP] = \&DC::UI::feed_sdl_button_up_event, |
2660 | DC::SDL_USEREVENT => sub { |
2663 | $SDL_CB[DC::SDL_USEREVENT] = sub { |
2661 | if ($_[0]{code} == 1) { |
2664 | if ($_[0]{code} == 1) { |
2662 | audio_channel_finished $_[0]{data1}; |
2665 | audio_channel_finished $_[0]{data1}; |
2663 | } elsif ($_[0]{code} == 0) { |
2666 | } elsif ($_[0]{code} == 0) { |
2664 | audio_music_finished; |
2667 | audio_music_finished; |
2665 | } |
|
|
2666 | }, |
2668 | } |
2667 | ); |
2669 | }; |
2668 | |
2670 | |
2669 | ############################################################################# |
2671 | ############################################################################# |
2670 | |
2672 | |
2671 | $SIG{INT} = $SIG{TERM} = sub { |
2673 | $SIG{INT} = $SIG{TERM} = sub { |
2672 | EV::unloop; |
2674 | EV::unloop; |
… | |
… | |
2733 | default => "profile", # default profile |
2735 | default => "profile", # default profile |
2734 | show_tips => 1, |
2736 | show_tips => 1, |
2735 | logview_max_par => 1000, |
2737 | logview_max_par => 1000, |
2736 | shift_fire_stop => 0, |
2738 | shift_fire_stop => 0, |
2737 | uitheme => "wood", |
2739 | uitheme => "wood", |
|
|
2740 | map_shift_x => -24, # arbitrary |
|
|
2741 | map_shift_y => +24, # arbitrary |
2738 | ); |
2742 | ); |
2739 | |
2743 | |
2740 | while (my ($k, $v) = each %DEF_CFG) { |
2744 | while (my ($k, $v) = each %DEF_CFG) { |
2741 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
2745 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
2742 | } |
2746 | } |
… | |
… | |
2756 | } |
2760 | } |
2757 | } |
2761 | } |
2758 | |
2762 | |
2759 | sdl_init; |
2763 | sdl_init; |
2760 | |
2764 | |
|
|
2765 | $ENV{FONTCONFIG_FILE} = DC::find_rcfile "fonts/fonts.conf"; |
|
|
2766 | $ENV{FONTCONFIG_DIR} = DC::find_rcfile "fonts"; |
|
|
2767 | |
2761 | { |
2768 | { |
2762 | my @fonts = map DC::find_rcfile "fonts/$_", qw( |
2769 | my @fonts = map DC::find_rcfile "fonts/$_", qw( |
2763 | DejaVuSans.ttf |
2770 | DejaVuSans.ttf |
2764 | DejaVuSansMono.ttf |
2771 | DejaVuSansMono.ttf |
2765 | DejaVuSans-Bold.ttf |
2772 | DejaVuSans-Bold.ttf |
2766 | DejaVuSansMono-Bold.ttf |
2773 | DejaVuSansMono-Bold.ttf |
2767 | DejaVuSans-Oblique.ttf |
2774 | DejaVuSans-Oblique.ttf |
2768 | DejaVuSansMono-Oblique.ttf |
2775 | DejaVuSansMono-Oblique.ttf |
2769 | DejaVuSans-BoldOblique.ttf |
2776 | DejaVuSans-BoldOblique.ttf |
2770 | DejaVuSansMono-BoldOblique.ttf |
2777 | DejaVuSansMono-BoldOblique.ttf |
|
|
2778 | mona.ttf |
2771 | ); |
2779 | ); |
2772 | |
2780 | |
2773 | DC::add_font $_ for @fonts; |
2781 | DC::add_font $_ for @fonts; |
2774 | |
2782 | |
2775 | $FONT_PROP = new_from_file DC::Font $fonts[0]; |
2783 | $FONT_PROP = new_from_file DC::Font $fonts[0]; |