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.96 by root, Mon Jul 27 23:08:41 2009 UTC vs.
Revision 1.106 by root, Sat Apr 3 03:02:28 2010 UTC

32 Win32::GUI::SplashScreen::Done (1); 32 Win32::GUI::SplashScreen::Done (1);
33 }; 33 };
34 } 34 }
35} 35}
36 36
37use strict; 37use common::sense;
38use utf8;
39 38
40use Carp 'verbose'; 39use Carp 'verbose';
41 40
42# do things only needed for single-binary version (par) 41# do things only needed for single-binary version (par)
43BEGIN { 42BEGIN {
133 crash "CRASH/EV::DIED: $@" => 0; 132 crash "CRASH/EV::DIED: $@" => 0;
134 DC::fatal Carp::longmess $@; 133 DC::fatal Carp::longmess $@;
135}; 134};
136 135
137my $MAX_FPS = 60; 136my $MAX_FPS = 60;
137
138our $DEFAULT_SERVER = "gameserver.deliantra.net";
138 139
139our $META_SERVER = "http://metaserver.schmorp.de/current.json"; 140our $META_SERVER = "http://metaserver.schmorp.de/current.json";
140 141
141our $LAST_REFRESH; 142our $LAST_REFRESH;
142our $NOW; 143our $NOW;
539 sub audio_tab_update; 540 sub audio_tab_update;
540 audio_tab_update; 541 audio_tab_update;
541} 542}
542 543
543sub audio_shutdown { 544sub audio_shutdown {
545 if ($SDL_MIXER) {
546 DC::MixMusic::halt;
547 DC::Mix_AllocateChannels 0;
548 }
549
544 undef $MUSIC_PLAYER; 550 undef $MUSIC_PLAYER;
545 undef $MUSIC_PLAYING_META; 551 undef $MUSIC_PLAYING_META;
546 undef $MUSIC_PLAYING_DATA; 552 undef $MUSIC_PLAYING_DATA;
547 553
548 $MUSIC_WANT = []; 554 $MUSIC_WANT = [];
549 @MUSIC_JINGLE = (); 555 @MUSIC_JINGLE = ();
550 %AUDIO_PLAY = (); 556 %AUDIO_PLAY = ();
551 %AUDIO_CHUNK = (); 557 %AUDIO_CHUNK = ();
552 558
553 DC::MixMusic::halt;
554 DC::Mix_AllocateChannels 0;
555 DC::Mix_CloseAudio if $SDL_MIXER; 559 DC::Mix_CloseAudio if $SDL_MIXER;
556 undef $SDL_MIXER; 560 undef $SDL_MIXER;
557} 561}
558 562
559############################################################################# 563#############################################################################
830 ; 834 ;
831} 835}
832 836
833sub start_game { 837sub start_game {
834 status "logging in..."; 838 status "logging in...";
839
840 my $server = $PROFILE->{host} || $DEFAULT_SERVER;
841 my ($host, $port) = AnyEvent::Socket::parse_hostport $server, "deliantra=13327"
842 or return status "$server: unable to parse server address, try an empty field.";
835 843
836 $LOGIN_BUTTON->set_text ("Logout"); 844 $LOGIN_BUTTON->set_text ("Logout");
837 $SETUP_DIALOG->hide; 845 $SETUP_DIALOG->hide;
838
839 my ($host, $port) = AnyEvent::Socket::parse_hostport $PROFILE->{host}, "deliantra=13327";
840 846
841 $MAP = new DC::Map; 847 $MAP = new DC::Map;
842 848
843 # hack to make SURE we find the IP address all right 849 # hack to make SURE we find the IP address all right
844 # can be removed once AnyEvent::DNS is proven stable. 850 # can be removed once AnyEvent::DNS is proven stable.
1027 . "If you have a very slow system, non-accelerated drivers or plain dislike smooth scrolling, " 1033 . "If you have a very slow system, non-accelerated drivers or plain dislike smooth scrolling, "
1028 . "then disable this option. Changes take effect immdiately.", 1034 . "then disable this option. Changes take effect immdiately.",
1029 on_changed => sub { my ($self, $value) = @_; $CFG->{smooth_movement} = $value; 0 } 1035 on_changed => sub { my ($self, $value) = @_; $CFG->{smooth_movement} = $value; 0 }
1030 ); 1036 );
1031 1037
1038 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Smooth Transitions");
1039 $table->add_at (1, $row++, new DC::UI::CheckBox
1040 state => $CFG->{smooth_transitions},
1041 tooltip => "<b>Smooth Transitions</b> tries to blend the fog of war and lighting smoothly between updates. "
1042 . "If you have a very slow system, non-accelerated drivers or plain dislike smooth scrolling, "
1043 . "then disable this option. Requires Smooth Movement and OpenGL Multitexturing. Changes take effect immdiately.",
1044 on_changed => sub { my ($self, $value) = @_; $CFG->{smooth_transitions} = $value; 0 }
1045 );
1046
1047
1032 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Map Scale"); 1048 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Map Scale");
1033 $table->add_at (1, $row++, new DC::UI::Slider 1049 $table->add_at (1, $row++, new DC::UI::Slider
1034 range => [(log $CFG->{map_scale}) / (log 2), -3, 1, 0, 1], 1050 range => [(log $CFG->{map_scale}) / (log 2), -3, 1, 0, 1],
1035 tooltip => "Enlarge or shrink the displayed map. Changes are instant.", 1051 tooltip => "Enlarge or shrink the displayed map. Changes are instant.",
1036 on_changed => sub { my ($self, $value) = @_; $CFG->{map_scale} = 2 ** $value; 0 } 1052 on_changed => sub { my ($self, $value) = @_; $CFG->{map_scale} = 2 ** $value; 0 }
1048 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Fog of War"); 1064 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Fog of War");
1049 $table->add_at (1, $row++, new DC::UI::CheckBox 1065 $table->add_at (1, $row++, new DC::UI::CheckBox
1050 state => $CFG->{fow_enable}, 1066 state => $CFG->{fow_enable},
1051 tooltip => "<b>Fog-of-War</b> marks areas that cannot be seen by the player. Changes are instant.", 1067 tooltip => "<b>Fog-of-War</b> marks areas that cannot be seen by the player. Changes are instant.",
1052 on_changed => sub { my ($self, $value) = @_; $CFG->{fow_enable} = $value; 0 } 1068 on_changed => sub { my ($self, $value) = @_; $CFG->{fow_enable} = $value; 0 }
1069 );
1070
1071 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "FoW Pattern");
1072 $table->add_at (1, $row++, new DC::UI::ImageButton
1073 tex => $DC::MapWidget::TEX_HIDDEN[$CFG->{fow_texture}],
1074 bg => [0.3, 0.3, 0.2],
1075 force_w => 64,
1076 force_h => 64,
1077 tooltip => "<b>Fog of War Pattern.</b> The pattern that is overlaid over areas hidden from view. Click to cycle through various alternatives. Changes are instant.",
1078 on_activate => sub {
1079 my ($self) = @_;
1080 $CFG->{fow_texture} = ($CFG->{fow_texture} + 1) % @DC::MapWidget::TEX_HIDDEN;
1081 $self->set_texture ($DC::MapWidget::TEX_HIDDEN[$CFG->{fow_texture}]);
1082 $MAPWIDGET->update;
1083 }
1053 ); 1084 );
1054 1085
1055 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "FoW Intensity"); 1086 $table->add_at (0, $row, new DC::UI::Label align => 1, text => "FoW Intensity");
1056 $table->add_at (1, $row++, new DC::UI::Slider 1087 $table->add_at (1, $row++, new DC::UI::Slider
1057 range => [$CFG->{fow_intensity}, 0, 1, 0, 1 / 256], 1088 range => [$CFG->{fow_intensity}, 0, 1, 0, 1 / 256],
1109 1140
1110 my $text = !$freq 1141 my $text = !$freq
1111 ? "audio is off" 1142 ? "audio is off"
1112 : "audio is enabled\n" 1143 : "audio is enabled\n"
1113 . "frequency (Hz): $freq\n" 1144 . "frequency (Hz): $freq\n"
1114 . "channels: $chans"; 1145 . "channels: $chans\n"
1146 . "chunk decoders available: " . (join ", ", DC::MixChunk::decoders) . "\n"
1147 . "music decoders available: " . (join ", ", DC::MixMusic::decoders);
1115 1148
1116 $AUDIO_INFO->set_text ($text); 1149 $AUDIO_INFO->set_text ($text);
1117} 1150}
1118 1151
1119sub audio_setup { 1152sub audio_setup {
1639 child => (my $table = new DC::UI::Table expand => 1, col_expand => [0, 1]), 1672 child => (my $table = new DC::UI::Table expand => 1, col_expand => [0, 1]),
1640 ); 1673 );
1641 1674
1642 $table->add_at (0, 4, new DC::UI::Label align => 1, text => "Username"); 1675 $table->add_at (0, 4, new DC::UI::Label align => 1, text => "Username");
1643 $table->add_at (1, 4, new DC::UI::Entry 1676 $table->add_at (1, 4, new DC::UI::Entry
1644 text => $CFG->{profile}{default}{user}, 1677 text => $PROFILE->{user},
1645 tooltip => "The name of your character on the server. The name is case-sensitive!", 1678 tooltip => "The name of your character on the server. The name is case-sensitive!",
1646 on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{user} = $value; 1 } 1679 on_changed => sub { my ($self, $value) = @_; $PROFILE->{user} = $value; 1 }
1647 ); 1680 );
1648 1681
1649 $table->add_at (0, 5, new DC::UI::Label align => 1, text => "Password"); 1682 $table->add_at (0, 5, new DC::UI::Label align => 1, text => "Password");
1650 $table->add_at (1, 5, new DC::UI::Entry 1683 $table->add_at (1, 5, new DC::UI::Entry
1651 text => $CFG->{profile}{default}{password}, 1684 text => $PROFILE->{password},
1652 hidden => 1, 1685 hidden => 1,
1653 tooltip => "The password for your character.", 1686 tooltip => "The password for your character.",
1654 on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{password} = $value; 1 } 1687 on_changed => sub { my ($self, $value) = @_; $PROFILE->{password} = $value; 1 }
1655 ); 1688 );
1656 1689
1657 $table->add_at (1, 11, $LOGIN_BUTTON = new DC::UI::Button 1690 $table->add_at (1, 11, $LOGIN_BUTTON = new DC::UI::Button
1658 expand => 1, 1691 expand => 1,
1659 text => "Login / Register", 1692 text => "Login / Register",
1695 $table->add_at (1, $row, my $vbox = new DC::UI::VBox); 1728 $table->add_at (1, $row, my $vbox = new DC::UI::VBox);
1696 1729
1697 $vbox->add ( 1730 $vbox->add (
1698 $HOST_ENTRY = new DC::UI::Entry 1731 $HOST_ENTRY = new DC::UI::Entry
1699 expand => 1, 1732 expand => 1,
1700 text => $CFG->{profile}{default}{host}, 1733 text => $PROFILE->{host},
1701 tooltip => "The hostname or ip address of the Deliantra server to connect to (e.g. <b>gameserver.deliantra.net</b>)", 1734 tooltip => "The hostname or ip address of the Deliantra server to connect to (e.g. <b>gameserver.deliantra.net</b>)",
1702 on_changed => sub { 1735 on_changed => sub {
1703 my ($self, $value) = @_; 1736 my ($self, $value) = @_;
1704 $CFG->{profile}{default}{host} = $value; 1737 $PROFILE->{host} = $value;
1705 1 1738 1
1706 } 1739 }
1707 ); 1740 );
1708 1741
1709 if (0) { #d# disabled 1742 if (0) { #d# disabled
1908 $r 1941 $r
1909} 1942}
1910 1943
1911my %SORT_ORDER = ( 1944my %SORT_ORDER = (
1912 type => sub { 1945 type => sub {
1946 use sort 'stable';
1913 sort { $a->{type} <=> $b->{type} or $a->{name} cmp $b->{name} } @_ 1947 sort { $a->{type} <=> $b->{type} or $a->{name} cmp $b->{name} } @_
1914 }, 1948 },
1915 mtime => sub { 1949 mtime => sub {
1950 use sort 'stable';
1916 my $NOW = time; 1951 my $NOW = time;
1917 sort { 1952 sort {
1918 my $atime = $a->{mtime} - $NOW; $atime = $atime < 5 * 60 ? int $atime / 60 : 6; 1953 my $atime = $a->{mtime} - $NOW; $atime = $atime < 5 * 60 ? int $atime / 60 : 6;
1919 my $btime = $b->{mtime} - $NOW; $btime = $btime < 5 * 60 ? int $btime / 60 : 6; 1954 my $btime = $b->{mtime} - $NOW; $btime = $btime < 5 * 60 ? int $btime / 60 : 6;
1920 1955
1921 ($a->{flags} & F_LOCKED) <=> ($b->{flags} & F_LOCKED) 1956 ($a->{flags} & F_LOCKED) <=> ($b->{flags} & F_LOCKED)
1922 or $btime <=> $atime 1957 or $btime <=> $atime
1923 or $a->{type} <=> $b->{type} 1958 or $a->{type} <=> $b->{type}
1924 } @_ 1959 } @_
1925 }, 1960 },
1926 weight => sub { sort { 1961 weight => sub {
1962 use sort 'stable';
1963 sort {
1927 $a->{weight} * ($a->{nrof} || 1) <=> $b->{weight} * ($b->{nrof} || 1) 1964 $a->{weight} * ($a->{nrof} || 1) <=> $b->{weight} * ($b->{nrof} || 1)
1928 or $a->{type} <=> $b->{type} 1965 or $a->{type} <=> $b->{type}
1929 } @_ }, 1966 } @_
1967 },
1930); 1968);
1931 1969
1932sub inventory_widget { 1970sub inventory_widget {
1933 my $hb = new DC::UI::HBox homogeneous => 1; 1971 my $hb = new DC::UI::HBox homogeneous => 1;
1934 1972
2565 2603
2566 $MODE_SLIDER->set_range ([$CFG->{sdl_mode}, 0, scalar @SDL_MODES, 1, 1]); 2604 $MODE_SLIDER->set_range ([$CFG->{sdl_mode}, 0, scalar @SDL_MODES, 1, 1]);
2567 $MODE_SLIDER->emit (changed => $CFG->{sdl_mode}); 2605 $MODE_SLIDER->emit (changed => $CFG->{sdl_mode});
2568 2606
2569 $CAVEAT_LABEL->set_text ("None :)"); 2607 $CAVEAT_LABEL->set_text ("None :)");
2608 $CAVEAT_LABEL->set_text ("Apple/NVIDIA Texture bug (slow)")
2609 if $DC::OpenGL::APPLE_NVIDIA_BUG;
2570 $CAVEAT_LABEL->set_text ("Software Rendering (very slow)") 2610 $CAVEAT_LABEL->set_text ("Software Rendering (very slow)")
2571 unless DC::SDL_GL_GetAttribute DC::SDL_GL_ACCELERATED_VISUAL; 2611 unless DC::SDL_GL_GetAttribute DC::SDL_GL_ACCELERATED_VISUAL;
2572 2612
2573 $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]); 2613 $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]);
2574} 2614}
2707 fullscreen => 1, 2747 fullscreen => 1,
2708 fast => 0, 2748 fast => 0,
2709 force_opengl11 => undef, 2749 force_opengl11 => undef,
2710 disable_alpha => 0, 2750 disable_alpha => 0,
2711 smooth_movement => 1, 2751 smooth_movement => 1,
2752 smooth_transitions => 1,
2712 texture_compression => 1, 2753 texture_compression => 1,
2713 map_scale => 1, 2754 map_scale => 1,
2714 fow_enable => 1, 2755 fow_enable => 1,
2715 fow_intensity => 0, 2756 fow_intensity => 0,
2757 fow_texture => 0,
2716 map_smoothing => 1, 2758 map_smoothing => 1,
2717 gui_fontsize => 1, 2759 gui_fontsize => 1,
2718 log_fontsize => 0.7, 2760 log_fontsize => 0.7,
2719 gauge_fontsize => 1, 2761 gauge_fontsize => 1,
2720 gauge_size => 0.35, 2762 gauge_size => 0.35,
2738 shift_fire_stop => 0, 2780 shift_fire_stop => 0,
2739 uitheme => "wood", 2781 uitheme => "wood",
2740 map_shift_x => -24, # arbitrary 2782 map_shift_x => -24, # arbitrary
2741 map_shift_y => +24, # arbitrary 2783 map_shift_y => +24, # arbitrary
2742 ); 2784 );
2743 2785
2744 while (my ($k, $v) = each %DEF_CFG) { 2786 while (my ($k, $v) = each %DEF_CFG) {
2745 $CFG->{$k} = $v unless exists $CFG->{$k}; 2787 $CFG->{$k} = $v unless exists $CFG->{$k};
2746 } 2788 }
2747 2789
2748 $CFG->{profile}{default}{host} ||= "gameserver.deliantra.net"; 2790 my @args = @ARGV;
2791
2792 my $profile = 'default';
2793
2794 for (my $i = 0; $i < @args; $i++) {
2795 if ($args[$i] =~ /^--?profile$/) {
2796 $profile = $args[$i + 1];
2797 splice @args, $i, 2, ();
2798 $i = 0;
2799 } elsif ($args[$i] =~ /^--?h/) {
2800 print STDERR "Usage: $0 [--profile name] [host [user [password]]]\n";
2801 exit 0;
2802 }
2803 }
2804
2805 $CFG->{profile}{$profile} ||= {};
2749 $PROFILE = $CFG->{profile}{default}; 2806 $PROFILE = $CFG->{profile}{$profile};
2807 $PROFILE->{host} ||= "gameserver.deliantra.net";
2808
2809 $PROFILE->{host} = $args[0] if @args > 0;
2810 $PROFILE->{user} = $args[1] if @args > 1;
2811 $PROFILE->{password} = $args[2] if @args > 2;
2750 2812
2751 # convert old bindings (only default profile matters) 2813 # convert old bindings (only default profile matters)
2752 if (my $bindings = delete $PROFILE->{bindings}) { 2814 if (my $bindings = delete $PROFILE->{bindings}) {
2753 while (my ($mod, $syms) = each %$bindings) { 2815 while (my ($mod, $syms) = each %$bindings) {
2754 while (my ($sym, $cmds) = each %$syms) { 2816 while (my ($sym, $cmds) = each %$syms) {
2777 DejaVuSansMono-BoldOblique.ttf 2839 DejaVuSansMono-BoldOblique.ttf
2778 mona.ttf 2840 mona.ttf
2779 ); 2841 );
2780 2842
2781 DC::add_font $_ for @fonts; 2843 DC::add_font $_ for @fonts;
2782 2844
2783 $FONT_PROP = new_from_file DC::Font $fonts[0]; 2845 $FONT_PROP = new_from_file DC::Font $fonts[0];
2784 $FONT_FIXED = new_from_file DC::Font $fonts[1]; 2846 $FONT_FIXED = new_from_file DC::Font $fonts[1];
2785 2847
2786 $FONT_PROP->make_default; 2848 $FONT_PROP->make_default;
2787 2849
2831 2893
2832deliantra - A Deliantra MORPG game client 2894deliantra - A Deliantra MORPG game client
2833 2895
2834=head1 SYNOPSIS 2896=head1 SYNOPSIS
2835 2897
2836Just run it - no commandline arguments are supported. 2898 deliantra [--profile name] [host [user [password]]]
2899 deliantra --help
2837 2900
2838=head1 USAGE 2901=head1 USAGE
2839 2902
2840deliantra utilises OpenGL for all UI elements and the game. It is supposed to 2903The deliantra client utilises OpenGL for all UI elements and the game. It
2841be used in fullscreen mode and interactively. 2904is supposed to be used in fullscreen mode and interactively.
2842 2905
2843=head1 DEBUGGING 2906=head1 DEBUGGING
2844
2845 2907
2846CFPLUS_DEBUG - environment variable 2908CFPLUS_DEBUG - environment variable
2847 2909
2848 1 draw borders around widgets 2910 1 draw borders around widgets
2849 2 add low-level widget info to tooltips 2911 2 add low-level widget info to tooltips

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines