… | |
… | |
32 | Win32::GUI::SplashScreen::Done (1); |
32 | Win32::GUI::SplashScreen::Done (1); |
33 | }; |
33 | }; |
34 | } |
34 | } |
35 | } |
35 | } |
36 | |
36 | |
37 | use strict; |
37 | use common::sense; |
38 | use utf8; |
|
|
39 | |
38 | |
40 | use Carp 'verbose'; |
39 | use Carp 'verbose'; |
41 | |
40 | |
42 | # do things only needed for single-binary version (par) |
41 | # do things only needed for single-binary version (par) |
43 | BEGIN { |
42 | BEGIN { |
… | |
… | |
541 | sub audio_tab_update; |
540 | sub audio_tab_update; |
542 | audio_tab_update; |
541 | audio_tab_update; |
543 | } |
542 | } |
544 | |
543 | |
545 | sub audio_shutdown { |
544 | sub audio_shutdown { |
|
|
545 | if ($SDL_MIXER) { |
|
|
546 | DC::MixMusic::halt; |
|
|
547 | DC::Mix_AllocateChannels 0; |
|
|
548 | } |
|
|
549 | |
546 | undef $MUSIC_PLAYER; |
550 | undef $MUSIC_PLAYER; |
547 | undef $MUSIC_PLAYING_META; |
551 | undef $MUSIC_PLAYING_META; |
548 | undef $MUSIC_PLAYING_DATA; |
552 | undef $MUSIC_PLAYING_DATA; |
549 | |
553 | |
550 | $MUSIC_WANT = []; |
554 | $MUSIC_WANT = []; |
551 | @MUSIC_JINGLE = (); |
555 | @MUSIC_JINGLE = (); |
552 | %AUDIO_PLAY = (); |
556 | %AUDIO_PLAY = (); |
553 | %AUDIO_CHUNK = (); |
557 | %AUDIO_CHUNK = (); |
554 | |
558 | |
555 | DC::MixMusic::halt; |
|
|
556 | DC::Mix_AllocateChannels 0; |
|
|
557 | DC::Mix_CloseAudio if $SDL_MIXER; |
559 | DC::Mix_CloseAudio if $SDL_MIXER; |
558 | undef $SDL_MIXER; |
560 | undef $SDL_MIXER; |
559 | } |
561 | } |
560 | |
562 | |
561 | ############################################################################# |
563 | ############################################################################# |
… | |
… | |
804 | user => $PROFILE->{user}, |
806 | user => $PROFILE->{user}, |
805 | pass => $PROFILE->{password}, |
807 | pass => $PROFILE->{password}, |
806 | mapw => $mapw, |
808 | mapw => $mapw, |
807 | maph => $maph, |
809 | maph => $maph, |
808 | |
810 | |
|
|
811 | client => "deliantra", |
809 | client => "$DC::VERSION $] $^O", |
812 | clientversion => $DC::VERSION, |
810 | |
813 | |
811 | map_widget => $MAPWIDGET, |
814 | map_widget => $MAPWIDGET, |
812 | statusbox => $STATUSBOX, |
815 | statusbox => $STATUSBOX, |
813 | map => $MAP, |
816 | map => $MAP, |
814 | mapmap => $MAPMAP, |
817 | mapmap => $MAPMAP, |
… | |
… | |
1036 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Smooth Transitions"); |
1039 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Smooth Transitions"); |
1037 | $table->add_at (1, $row++, new DC::UI::CheckBox |
1040 | $table->add_at (1, $row++, new DC::UI::CheckBox |
1038 | state => $CFG->{smooth_transitions}, |
1041 | state => $CFG->{smooth_transitions}, |
1039 | tooltip => "<b>Smooth Transitions</b> tries to blend the fog of war and lighting smoothly between updates. " |
1042 | tooltip => "<b>Smooth Transitions</b> tries to blend the fog of war and lighting smoothly between updates. " |
1040 | . "If you have a very slow system, non-accelerated drivers or plain dislike smooth scrolling, " |
1043 | . "If you have a very slow system, non-accelerated drivers or plain dislike smooth scrolling, " |
1041 | . "then disable this option. Requires Smooth Movement and OpenGL 1.4 or up. Changes take effect immdiately.", |
1044 | . "then disable this option. Requires Smooth Movement and OpenGL Multitexturing. Changes take effect immdiately.", |
1042 | on_changed => sub { my ($self, $value) = @_; $CFG->{smooth_transitions} = $value; 0 } |
1045 | on_changed => sub { my ($self, $value) = @_; $CFG->{smooth_transitions} = $value; 0 } |
1043 | ); |
1046 | ); |
1044 | |
1047 | |
1045 | |
1048 | |
1046 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Map Scale"); |
1049 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Map Scale"); |
… | |
… | |
1062 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Fog of War"); |
1065 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Fog of War"); |
1063 | $table->add_at (1, $row++, new DC::UI::CheckBox |
1066 | $table->add_at (1, $row++, new DC::UI::CheckBox |
1064 | state => $CFG->{fow_enable}, |
1067 | state => $CFG->{fow_enable}, |
1065 | tooltip => "<b>Fog-of-War</b> marks areas that cannot be seen by the player. Changes are instant.", |
1068 | tooltip => "<b>Fog-of-War</b> marks areas that cannot be seen by the player. Changes are instant.", |
1066 | on_changed => sub { my ($self, $value) = @_; $CFG->{fow_enable} = $value; 0 } |
1069 | on_changed => sub { my ($self, $value) = @_; $CFG->{fow_enable} = $value; 0 } |
|
|
1070 | ); |
|
|
1071 | |
|
|
1072 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "FoW Pattern"); |
|
|
1073 | $table->add_at (1, $row++, new DC::UI::ImageButton |
|
|
1074 | tex => $DC::MapWidget::TEX_HIDDEN[$CFG->{fow_texture}], |
|
|
1075 | bg => [0.3, 0.3, 0.2], |
|
|
1076 | force_w => 64, |
|
|
1077 | force_h => 64, |
|
|
1078 | 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.", |
|
|
1079 | on_activate => sub { |
|
|
1080 | my ($self) = @_; |
|
|
1081 | $CFG->{fow_texture} = ($CFG->{fow_texture} + 1) % @DC::MapWidget::TEX_HIDDEN; |
|
|
1082 | $self->set_texture ($DC::MapWidget::TEX_HIDDEN[$CFG->{fow_texture}]); |
|
|
1083 | $MAPWIDGET->update; |
|
|
1084 | } |
1067 | ); |
1085 | ); |
1068 | |
1086 | |
1069 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "FoW Intensity"); |
1087 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "FoW Intensity"); |
1070 | $table->add_at (1, $row++, new DC::UI::Slider |
1088 | $table->add_at (1, $row++, new DC::UI::Slider |
1071 | range => [$CFG->{fow_intensity}, 0, 1, 0, 1 / 256], |
1089 | range => [$CFG->{fow_intensity}, 0, 1, 0, 1 / 256], |
… | |
… | |
1123 | |
1141 | |
1124 | my $text = !$freq |
1142 | my $text = !$freq |
1125 | ? "audio is off" |
1143 | ? "audio is off" |
1126 | : "audio is enabled\n" |
1144 | : "audio is enabled\n" |
1127 | . "frequency (Hz): $freq\n" |
1145 | . "frequency (Hz): $freq\n" |
1128 | . "channels: $chans"; |
1146 | . "channels: $chans\n" |
|
|
1147 | . "chunk decoders available: " . (join ", ", DC::MixChunk::decoders) . "\n" |
|
|
1148 | . "music decoders available: " . (join ", ", DC::MixMusic::decoders); |
1129 | |
1149 | |
1130 | $AUDIO_INFO->set_text ($text); |
1150 | $AUDIO_INFO->set_text ($text); |
1131 | } |
1151 | } |
1132 | |
1152 | |
1133 | sub audio_setup { |
1153 | sub audio_setup { |
… | |
… | |
1653 | child => (my $table = new DC::UI::Table expand => 1, col_expand => [0, 1]), |
1673 | child => (my $table = new DC::UI::Table expand => 1, col_expand => [0, 1]), |
1654 | ); |
1674 | ); |
1655 | |
1675 | |
1656 | $table->add_at (0, 4, new DC::UI::Label align => 1, text => "Username"); |
1676 | $table->add_at (0, 4, new DC::UI::Label align => 1, text => "Username"); |
1657 | $table->add_at (1, 4, new DC::UI::Entry |
1677 | $table->add_at (1, 4, new DC::UI::Entry |
1658 | text => $CFG->{profile}{default}{user}, |
1678 | text => $PROFILE->{user}, |
1659 | tooltip => "The name of your character on the server. The name is case-sensitive!", |
1679 | tooltip => "The name of your character on the server. The name is case-sensitive!", |
1660 | on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{user} = $value; 1 } |
1680 | on_changed => sub { my ($self, $value) = @_; $PROFILE->{user} = $value; 1 } |
1661 | ); |
1681 | ); |
1662 | |
1682 | |
1663 | $table->add_at (0, 5, new DC::UI::Label align => 1, text => "Password"); |
1683 | $table->add_at (0, 5, new DC::UI::Label align => 1, text => "Password"); |
1664 | $table->add_at (1, 5, new DC::UI::Entry |
1684 | $table->add_at (1, 5, new DC::UI::Entry |
1665 | text => $CFG->{profile}{default}{password}, |
1685 | text => $PROFILE->{password}, |
1666 | hidden => 1, |
1686 | hidden => 1, |
1667 | tooltip => "The password for your character.", |
1687 | tooltip => "The password for your character.", |
1668 | on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{password} = $value; 1 } |
1688 | on_changed => sub { my ($self, $value) = @_; $PROFILE->{password} = $value; 1 } |
1669 | ); |
1689 | ); |
1670 | |
1690 | |
1671 | $table->add_at (1, 11, $LOGIN_BUTTON = new DC::UI::Button |
1691 | $table->add_at (1, 11, $LOGIN_BUTTON = new DC::UI::Button |
1672 | expand => 1, |
1692 | expand => 1, |
1673 | text => "Login / Register", |
1693 | text => "Login / Register", |
… | |
… | |
1709 | $table->add_at (1, $row, my $vbox = new DC::UI::VBox); |
1729 | $table->add_at (1, $row, my $vbox = new DC::UI::VBox); |
1710 | |
1730 | |
1711 | $vbox->add ( |
1731 | $vbox->add ( |
1712 | $HOST_ENTRY = new DC::UI::Entry |
1732 | $HOST_ENTRY = new DC::UI::Entry |
1713 | expand => 1, |
1733 | expand => 1, |
1714 | text => $CFG->{profile}{default}{host}, |
1734 | text => $PROFILE->{host}, |
1715 | tooltip => "The hostname or ip address of the Deliantra server to connect to (e.g. <b>gameserver.deliantra.net</b>)", |
1735 | tooltip => "The hostname or ip address of the Deliantra server to connect to (e.g. <b>gameserver.deliantra.net</b>)", |
1716 | on_changed => sub { |
1736 | on_changed => sub { |
1717 | my ($self, $value) = @_; |
1737 | my ($self, $value) = @_; |
1718 | $CFG->{profile}{default}{host} = $value; |
1738 | $PROFILE->{host} = $value; |
1719 | 1 |
1739 | 1 |
1720 | } |
1740 | } |
1721 | ); |
1741 | ); |
1722 | |
1742 | |
1723 | if (0) { #d# disabled |
1743 | if (0) { #d# disabled |
… | |
… | |
1922 | $r |
1942 | $r |
1923 | } |
1943 | } |
1924 | |
1944 | |
1925 | my %SORT_ORDER = ( |
1945 | my %SORT_ORDER = ( |
1926 | type => sub { |
1946 | type => sub { |
|
|
1947 | use sort 'stable'; |
1927 | sort { $a->{type} <=> $b->{type} or $a->{name} cmp $b->{name} } @_ |
1948 | sort { $a->{type} <=> $b->{type} or $a->{name} cmp $b->{name} } @_ |
1928 | }, |
1949 | }, |
1929 | mtime => sub { |
1950 | mtime => sub { |
|
|
1951 | use sort 'stable'; |
1930 | my $NOW = time; |
1952 | my $NOW = time; |
1931 | sort { |
1953 | sort { |
1932 | my $atime = $a->{mtime} - $NOW; $atime = $atime < 5 * 60 ? int $atime / 60 : 6; |
1954 | my $atime = $a->{mtime} - $NOW; $atime = $atime < 5 * 60 ? int $atime / 60 : 6; |
1933 | my $btime = $b->{mtime} - $NOW; $btime = $btime < 5 * 60 ? int $btime / 60 : 6; |
1955 | my $btime = $b->{mtime} - $NOW; $btime = $btime < 5 * 60 ? int $btime / 60 : 6; |
1934 | |
1956 | |
1935 | ($a->{flags} & F_LOCKED) <=> ($b->{flags} & F_LOCKED) |
1957 | ($a->{flags} & F_LOCKED) <=> ($b->{flags} & F_LOCKED) |
1936 | or $btime <=> $atime |
1958 | or $btime <=> $atime |
1937 | or $a->{type} <=> $b->{type} |
1959 | or $a->{type} <=> $b->{type} |
1938 | } @_ |
1960 | } @_ |
1939 | }, |
1961 | }, |
1940 | weight => sub { sort { |
1962 | weight => sub { |
|
|
1963 | use sort 'stable'; |
|
|
1964 | sort { |
1941 | $a->{weight} * ($a->{nrof} || 1) <=> $b->{weight} * ($b->{nrof} || 1) |
1965 | $a->{weight} * ($a->{nrof} || 1) <=> $b->{weight} * ($b->{nrof} || 1) |
1942 | or $a->{type} <=> $b->{type} |
1966 | or $a->{type} <=> $b->{type} |
1943 | } @_ }, |
1967 | } @_ |
|
|
1968 | }, |
1944 | ); |
1969 | ); |
1945 | |
1970 | |
1946 | sub inventory_widget { |
1971 | sub inventory_widget { |
1947 | my $hb = new DC::UI::HBox homogeneous => 1; |
1972 | my $hb = new DC::UI::HBox homogeneous => 1; |
1948 | |
1973 | |
… | |
… | |
2728 | smooth_transitions => 1, |
2753 | smooth_transitions => 1, |
2729 | texture_compression => 1, |
2754 | texture_compression => 1, |
2730 | map_scale => 1, |
2755 | map_scale => 1, |
2731 | fow_enable => 1, |
2756 | fow_enable => 1, |
2732 | fow_intensity => 0, |
2757 | fow_intensity => 0, |
|
|
2758 | fow_texture => 0, |
2733 | map_smoothing => 1, |
2759 | map_smoothing => 1, |
2734 | gui_fontsize => 1, |
2760 | gui_fontsize => 1, |
2735 | log_fontsize => 0.7, |
2761 | log_fontsize => 0.7, |
2736 | gauge_fontsize => 1, |
2762 | gauge_fontsize => 1, |
2737 | gauge_size => 0.35, |
2763 | gauge_size => 0.35, |
… | |
… | |
2755 | shift_fire_stop => 0, |
2781 | shift_fire_stop => 0, |
2756 | uitheme => "wood", |
2782 | uitheme => "wood", |
2757 | map_shift_x => -24, # arbitrary |
2783 | map_shift_x => -24, # arbitrary |
2758 | map_shift_y => +24, # arbitrary |
2784 | map_shift_y => +24, # arbitrary |
2759 | ); |
2785 | ); |
2760 | |
2786 | |
2761 | while (my ($k, $v) = each %DEF_CFG) { |
2787 | while (my ($k, $v) = each %DEF_CFG) { |
2762 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
2788 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
2763 | } |
2789 | } |
2764 | |
2790 | |
2765 | $CFG->{profile}{default}{host} ||= "gameserver.deliantra.net"; |
2791 | my @args = @ARGV; |
|
|
2792 | |
|
|
2793 | my $profile = 'default'; |
|
|
2794 | |
|
|
2795 | for (my $i = 0; $i < @args; $i++) { |
|
|
2796 | if ($args[$i] =~ /^--?profile$/) { |
|
|
2797 | $profile = $args[$i + 1]; |
|
|
2798 | splice @args, $i, 2, (); |
|
|
2799 | $i = 0; |
|
|
2800 | } elsif ($args[$i] =~ /^--?h/) { |
|
|
2801 | print STDERR "Usage: $0 [--profile name] [host [user [password]]]\n"; |
|
|
2802 | exit 0; |
|
|
2803 | } |
|
|
2804 | } |
|
|
2805 | |
|
|
2806 | $CFG->{profile}{$profile} ||= {}; |
2766 | $PROFILE = $CFG->{profile}{default}; |
2807 | $PROFILE = $CFG->{profile}{$profile}; |
|
|
2808 | $PROFILE->{host} ||= "gameserver.deliantra.net"; |
|
|
2809 | |
|
|
2810 | $PROFILE->{host} = $args[0] if @args > 0; |
|
|
2811 | $PROFILE->{user} = $args[1] if @args > 1; |
|
|
2812 | $PROFILE->{password} = $args[2] if @args > 2; |
2767 | |
2813 | |
2768 | # convert old bindings (only default profile matters) |
2814 | # convert old bindings (only default profile matters) |
2769 | if (my $bindings = delete $PROFILE->{bindings}) { |
2815 | if (my $bindings = delete $PROFILE->{bindings}) { |
2770 | while (my ($mod, $syms) = each %$bindings) { |
2816 | while (my ($mod, $syms) = each %$bindings) { |
2771 | while (my ($sym, $cmds) = each %$syms) { |
2817 | while (my ($sym, $cmds) = each %$syms) { |
… | |
… | |
2794 | DejaVuSansMono-BoldOblique.ttf |
2840 | DejaVuSansMono-BoldOblique.ttf |
2795 | mona.ttf |
2841 | mona.ttf |
2796 | ); |
2842 | ); |
2797 | |
2843 | |
2798 | DC::add_font $_ for @fonts; |
2844 | DC::add_font $_ for @fonts; |
2799 | |
2845 | |
2800 | $FONT_PROP = new_from_file DC::Font $fonts[0]; |
2846 | $FONT_PROP = new_from_file DC::Font $fonts[0]; |
2801 | $FONT_FIXED = new_from_file DC::Font $fonts[1]; |
2847 | $FONT_FIXED = new_from_file DC::Font $fonts[1]; |
2802 | |
2848 | |
2803 | $FONT_PROP->make_default; |
2849 | $FONT_PROP->make_default; |
2804 | |
2850 | |
… | |
… | |
2848 | |
2894 | |
2849 | deliantra - A Deliantra MORPG game client |
2895 | deliantra - A Deliantra MORPG game client |
2850 | |
2896 | |
2851 | =head1 SYNOPSIS |
2897 | =head1 SYNOPSIS |
2852 | |
2898 | |
2853 | Just run it - no commandline arguments are supported. |
2899 | deliantra [--profile name] [host [user [password]]] |
|
|
2900 | deliantra --help |
2854 | |
2901 | |
2855 | =head1 USAGE |
2902 | =head1 USAGE |
2856 | |
2903 | |
2857 | deliantra utilises OpenGL for all UI elements and the game. It is supposed to |
2904 | The deliantra client utilises OpenGL for all UI elements and the game. It |
2858 | be used in fullscreen mode and interactively. |
2905 | is supposed to be used in fullscreen mode and interactively. |
2859 | |
2906 | |
2860 | =head1 DEBUGGING |
2907 | =head1 DEBUGGING |
2861 | |
|
|
2862 | |
2908 | |
2863 | CFPLUS_DEBUG - environment variable |
2909 | CFPLUS_DEBUG - environment variable |
2864 | |
2910 | |
2865 | 1 draw borders around widgets |
2911 | 1 draw borders around widgets |
2866 | 2 add low-level widget info to tooltips |
2912 | 2 add low-level widget info to tooltips |