… | |
… | |
49 | } |
49 | } |
50 | } |
50 | } |
51 | |
51 | |
52 | if ($^O eq "MSWin32") { |
52 | if ($^O eq "MSWin32") { |
53 | # pango is relocatable on win32 |
53 | # pango is relocatable on win32 |
54 | } else { |
54 | } elsif (-e "$root/pangoversion") { |
55 | open my $fh, "<:perlio", "$root/pangoversion" |
55 | open my $fh, "<:perlio", "$root/pangoversion" |
56 | or die "pangoversion: $!"; |
56 | or die "pangoversion: $!"; |
57 | my $PANGO = <$fh>; |
57 | my $PANGO = <$fh>; |
58 | # unix, need to patch pango rc file |
58 | # unix, need to patch pango rc file |
59 | open my $fh, "<:perlio", "$root/usr/lib/pango/$PANGO/module-files.d/libpango1.0-0.modules" |
59 | open my $fh, "<:perlio", "$root/usr/lib/pango/$PANGO/module-files.d/libpango1.0-0.modules" |
… | |
… | |
69 | |
69 | |
70 | $ENV{PANGO_RC_FILE} = "$root/pango.rc"; |
70 | $ENV{PANGO_RC_FILE} = "$root/pango.rc"; |
71 | open my $fh, ">:perlio", $ENV{PANGO_RC_FILE} |
71 | open my $fh, ">:perlio", $ENV{PANGO_RC_FILE} |
72 | or die "$ENV{PANGO_RC_FILE}: $!"; |
72 | or die "$ENV{PANGO_RC_FILE}: $!"; |
73 | print $fh "[Pango]\nModuleFiles = $root/pango-modules\n"; |
73 | print $fh "[Pango]\nModuleFiles = $root/pango-modules\n"; |
|
|
74 | } else { |
|
|
75 | # OS X |
|
|
76 | $ENV{FC_CONFIG_FILE} = "$root/fonts.conf"; # no effect??!?! |
|
|
77 | $ENV{FC_CONFIG_DIR} = $root; # no effect??!?! |
|
|
78 | $ENV{PANGO_RC_FILE} = "$root/pango.rc"; |
|
|
79 | $ENV{DYLD_LIBRARY_PATH} = $root; |
|
|
80 | chdir $root; # for pango modules, maybe other things |
74 | } |
81 | } |
75 | |
82 | |
76 | unshift @INC, $root; |
83 | unshift @INC, $root; |
77 | } |
84 | } |
78 | } |
85 | } |
… | |
… | |
97 | use List::Util qw(max min); |
104 | use List::Util qw(max min); |
98 | |
105 | |
99 | use Deliantra; |
106 | use Deliantra; |
100 | use Deliantra::Protocol::Constants; |
107 | use Deliantra::Protocol::Constants; |
101 | |
108 | |
|
|
109 | use AnyEvent::Util (); |
102 | use AnyEvent::DNS; |
110 | use AnyEvent::DNS; |
103 | use AnyEvent::Socket (); |
111 | use AnyEvent::Socket (); |
104 | |
112 | |
105 | use Compress::LZF; |
113 | use Compress::LZF; |
|
|
114 | use JSON::XS; |
106 | |
115 | |
107 | use DC; |
116 | use DC; |
108 | BEGIN { $SIG{__DIE__} = sub { DC::fatal Carp::longmess "$_[0]" unless $^S } } |
117 | |
|
|
118 | ############################################################################# |
|
|
119 | |
|
|
120 | our $CONN; |
|
|
121 | |
|
|
122 | # write a crash message blockingly to the socket, if possible |
|
|
123 | # this is a bit too complicated for my tastes, but it was easy. |
|
|
124 | sub crash($;$) { |
|
|
125 | my ($msg, $backtrace) = @_; |
|
|
126 | |
|
|
127 | return unless $CONN; |
|
|
128 | |
|
|
129 | my $fh = $CONN->{fh} |
|
|
130 | or return; |
|
|
131 | |
|
|
132 | my $buf = delete $CONN->{wbuf}; |
|
|
133 | |
|
|
134 | $buf .= pack "n/a*", "exti " . JSON::XS::encode_json [clientlog => undef, substr $msg, 0, 8000]; |
|
|
135 | |
|
|
136 | AnyEvent::Util::fh_nonblocking $fh, 0; |
|
|
137 | |
|
|
138 | syswrite $fh, $buf; |
|
|
139 | AnyEvent::Util::fh_nonblocking $fh, 1; |
|
|
140 | |
|
|
141 | $msg =~ s/\s+$//; |
|
|
142 | |
|
|
143 | # backtrace as second step, in case it crashes, too |
|
|
144 | crash (Carp::longmess "$msg\nbacktrace, for client version $DC::VERSION, generated") |
|
|
145 | if $backtrace; |
|
|
146 | } |
|
|
147 | |
|
|
148 | ############################################################################# |
|
|
149 | |
|
|
150 | BEGIN { |
|
|
151 | $SIG{__DIE__} = sub { |
|
|
152 | return if $^S; |
|
|
153 | crash ("CRASH/DIE: $_[0]" => 1); |
|
|
154 | DC::fatal Carp::longmess "$_[0]"; |
|
|
155 | } |
|
|
156 | } |
|
|
157 | |
109 | use DC::OpenGL (); |
158 | use DC::OpenGL (); |
110 | use DC::Protocol; |
159 | use DC::Protocol; |
111 | use DC::DB; |
160 | use DC::DB; |
112 | use DC::UI; |
161 | use DC::UI; |
113 | use DC::UI::Canvas; |
162 | use DC::UI::Canvas; |
114 | use DC::UI::Inventory; |
163 | use DC::UI::Inventory; |
115 | use DC::UI::SpellList; |
164 | use DC::UI::SpellList; |
116 | use DC::UI::Dockable; |
165 | use DC::UI::Dockable; |
117 | use DC::UI::Dockbar; |
166 | use DC::UI::Dockbar; |
118 | use DC::UI::MessageWindow; |
|
|
119 | use DC::UI::ChatView; |
167 | use DC::UI::ChatView; |
120 | use DC::MessageDistributor; |
168 | use DC::MessageDistributor; |
121 | use DC::Pod; |
169 | use DC::Pod; |
122 | use DC::MapWidget; |
170 | use DC::MapWidget; |
123 | use DC::Macro; |
171 | use DC::Macro; |
124 | |
172 | |
125 | $SIG{QUIT} = sub { Carp::cluck "QUIT" }; |
173 | $SIG{QUIT} = sub { Carp::cluck "QUIT" }; |
126 | $SIG{PIPE} = 'IGNORE'; |
174 | $SIG{PIPE} = 'IGNORE'; |
127 | |
175 | |
128 | $EV::DIED = sub { |
176 | $EV::DIED = sub { |
|
|
177 | crash ("CRASH/EV::DIED: $@" => 1); |
129 | DC::fatal Carp::longmess $@; |
178 | DC::fatal Carp::longmess $@; |
130 | }; |
179 | }; |
131 | |
180 | |
132 | my $MAX_FPS = 60; |
181 | my $MAX_FPS = 60; |
133 | |
182 | |
… | |
… | |
135 | |
184 | |
136 | our $LAST_REFRESH; |
185 | our $LAST_REFRESH; |
137 | our $NOW; |
186 | our $NOW; |
138 | |
187 | |
139 | our $CFG; |
188 | our $CFG; |
140 | our $CONN; |
|
|
141 | our $PROFILE; # current profile |
189 | our $PROFILE; # current profile |
142 | our $FAST; # fast, low-quality mode, possibly useful for software-rendering |
190 | our $FAST; # fast, low-quality mode, possibly useful for software-rendering |
143 | |
191 | |
144 | our $WANT_REFRESH; |
192 | our $WANT_REFRESH; |
145 | |
193 | |
… | |
… | |
800 | dc_connect $host, $port; |
848 | dc_connect $host, $port; |
801 | } |
849 | } |
802 | } |
850 | } |
803 | |
851 | |
804 | sub stop_game { |
852 | sub stop_game { |
|
|
853 | crash "stop_game"; |
|
|
854 | |
805 | $LOGIN_BUTTON->set_text ("Login / Register"); |
855 | $LOGIN_BUTTON->set_text ("Login / Register"); |
806 | $SETUP_NOTEBOOK->set_current_page ($SETUP_LOGIN); |
856 | $SETUP_NOTEBOOK->set_current_page ($SETUP_LOGIN); |
807 | $SETUP_DIALOG->show; |
857 | $SETUP_DIALOG->show; |
808 | $PL_WINDOW->hide; |
858 | $PL_WINDOW->hide; |
809 | $SPELL_LIST->clear_spells; |
859 | $SPELL_LIST->clear_spells; |
… | |
… | |
829 | |
879 | |
830 | my $row = 0; |
880 | my $row = 0; |
831 | |
881 | |
832 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "OpenGL Info"); |
882 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "OpenGL Info"); |
833 | $table->add_at (1, $row++, new DC::UI::Label fontsize => 0.8, text => DC::OpenGL::gl_vendor . ", " . DC::OpenGL::gl_version, |
883 | $table->add_at (1, $row++, new DC::UI::Label fontsize => 0.8, text => DC::OpenGL::gl_vendor . ", " . DC::OpenGL::gl_version, |
834 | can_events => 1, |
884 | can_events => 1, |
835 | tooltip => "<tt><span size='8192'>" . (DC::OpenGL::gl_extensions) . "</span></tt>"); |
885 | tooltip => "<tt><span size='8192'>" . (DC::OpenGL::gl_extensions) . "</span></tt>"); |
836 | |
886 | |
837 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Caveats"); |
887 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Caveats"); |
838 | $table->add_at (1, $row++, $CAVEAT_LABEL = new DC::UI::Label fontsize => 0.8, |
888 | $table->add_at (1, $row++, $CAVEAT_LABEL = new DC::UI::Label fontsize => 0.8, |
839 | can_events => 1, |
889 | can_events => 1, |
840 | tooltip => "This field shows any known issues with your config or driver, such as " |
890 | tooltip => "This field shows any known issues with your config or driver, such as " |
… | |
… | |
849 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Video Mode"); |
899 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Video Mode"); |
850 | $table->add_at (1, $row++, my $hbox = new DC::UI::HBox); |
900 | $table->add_at (1, $row++, my $hbox = new DC::UI::HBox); |
851 | |
901 | |
852 | $hbox->add ($MODE_SLIDER = new DC::UI::Slider |
902 | $hbox->add ($MODE_SLIDER = new DC::UI::Slider |
853 | force_w => $WIDTH * 0.1, expand => 1, |
903 | force_w => $WIDTH * 0.1, expand => 1, |
|
|
904 | range => [ ($CFG->{sdl_mode}) x 3 ], |
854 | tooltip => $vidmode_tooltip); |
905 | tooltip => $vidmode_tooltip); |
855 | $hbox->add (my $mode_label = new DC::UI::Label |
906 | $hbox->add (my $mode_label = new DC::UI::Label |
856 | height => 0.8, template => "9999x9999@9+9", |
907 | height => 0.8, template => "9999x9999@9+9", |
857 | can_events => 1, tooltip => $vidmode_tooltip); |
908 | can_events => 1, tooltip => $vidmode_tooltip); |
858 | |
909 | |
… | |
… | |
902 | |
953 | |
903 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Compress Textures"); |
954 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Compress Textures"); |
904 | $table->add_at (1, $row++, new DC::UI::CheckBox |
955 | $table->add_at (1, $row++, new DC::UI::CheckBox |
905 | state => $CFG->{texture_compression}, |
956 | state => $CFG->{texture_compression}, |
906 | tooltip => "Use texture compression. Normally this will not reduce visual quality noticable but " |
957 | tooltip => "Use texture compression. Normally this will not reduce visual quality noticable but " |
907 | . "will save a lot of memory and increase performance. The compression algorithm " |
958 | . "will save a lot of memory and increase performance (and also fall prey to the ever-buggy Mac OS X software renderer). " |
908 | . "can differ form card to card, so your mileage may vary. This setting is ignored in " |
959 | . "The compression algorithm can differ form card to card, so your mileage may vary. This setting is ignored in " |
909 | . "forced OpenGL 1.1 mode.", |
960 | . "forced OpenGL 1.1 mode and when using the Apple renderer.", |
910 | on_changed => sub { my ($self, $value) = @_; $CFG->{texture_compression} = $value; 0 } |
961 | on_changed => sub { my ($self, $value) = @_; $CFG->{texture_compression} = $value; 0 } |
911 | ); |
962 | ); |
912 | |
963 | |
913 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Fast & Ugly"); |
964 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Fast & Ugly"); |
914 | $table->add_at (1, $row++, new DC::UI::CheckBox |
965 | $table->add_at (1, $row++, new DC::UI::CheckBox |
… | |
… | |
930 | on_activate => sub { |
981 | on_activate => sub { |
931 | video_shutdown (); |
982 | video_shutdown (); |
932 | video_init (); |
983 | video_init (); |
933 | 0 |
984 | 0 |
934 | } |
985 | } |
|
|
986 | ); |
|
|
987 | |
|
|
988 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Smooth Movement"); |
|
|
989 | $table->add_at (1, $row++, new DC::UI::CheckBox |
|
|
990 | state => $CFG->{smooth_movement}, |
|
|
991 | tooltip => "<b>Smooth Movement</b> tries to make movement, well, smoother, but also increases the framerate. " |
|
|
992 | . "If you have a very slow system, non-accelerated drivers or plain dislike smooth scrolling, " |
|
|
993 | . "then disable this option. Changes take effect immdiately.", |
|
|
994 | on_changed => sub { my ($self, $value) = @_; $CFG->{smooth_movement} = $value; 0 } |
935 | ); |
995 | ); |
936 | |
996 | |
937 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Map Scale"); |
997 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Map Scale"); |
938 | $table->add_at (1, $row++, new DC::UI::Slider |
998 | $table->add_at (1, $row++, new DC::UI::Slider |
939 | range => [(log $CFG->{map_scale}) / (log 2), -3, 1, 0, 1], |
999 | range => [(log $CFG->{map_scale}) / (log 2), -3, 1, 0, 1], |
… | |
… | |
1579 | 1 |
1639 | 1 |
1580 | }, |
1640 | }, |
1581 | ); |
1641 | ); |
1582 | |
1642 | |
1583 | $vbox->add (new DC::UI::FancyFrame |
1643 | $vbox->add (new DC::UI::FancyFrame |
1584 | label => "Registering", |
1644 | label => "How to Play", |
1585 | min_h => 200, |
1645 | min_h => 240, |
1586 | child => (new DC::UI::Label valign => 0, ellipsise => 0, |
1646 | child => (new DC::UI::Label valign => 0, ellipsise => 0, |
1587 | markup => |
1647 | markup => |
|
|
1648 | "First select a suitable video resolution in the <b>Graphics</b> tab, above.\n\n" |
|
|
1649 | . "Then register a new account (or use an existing one if you have one). " |
1588 | "To register a new account, choose a username that hasn't been taken yet and " |
1650 | . "To register an account, choose a username that hasn't been taken yet (just guess) and " |
1589 | . "try to log-in. Follow the instructions in the Log tab in the message window.", |
1651 | . "try to log-in. Follow the instructions in the Log tab in the message window.", |
1590 | ), |
1652 | ), |
1591 | ); |
1653 | ); |
1592 | |
1654 | |
1593 | $vbox |
1655 | $vbox |
… | |
… | |
1739 | ["Magic Devices" => PICKUP_MAGIC_DEVICE], |
1801 | ["Magic Devices" => PICKUP_MAGIC_DEVICE], |
1740 | ["Ignore cursed" => PICKUP_NOT_CURSED], |
1802 | ["Ignore cursed" => PICKUP_NOT_CURSED], |
1741 | ["Jewelery" => PICKUP_JEWELS], |
1803 | ["Jewelery" => PICKUP_JEWELS], |
1742 | ["Flesh" => PICKUP_FLESH], |
1804 | ["Flesh" => PICKUP_FLESH], |
1743 | ], |
1805 | ], |
1744 | ["Weight/Value ratio", 2, 17] |
1806 | ["Value/Weight ratio", 2, 17] |
1745 | ) |
1807 | ) |
1746 | { |
1808 | { |
1747 | my ($title, $x, $y, @bits) = @$_; |
1809 | my ($title, $x, $y, @bits) = @$_; |
1748 | $table->add_at ($x, $y, new DC::UI::Label text => $title, align => 1, fg => [1, 1, 0]); |
1810 | $table->add_at ($x, $y, new DC::UI::Label text => $title, align => 1, fg => [1, 1, 0]); |
1749 | |
1811 | |
… | |
… | |
1774 | } |
1836 | } |
1775 | |
1837 | |
1776 | $table->add_at (2, 18, new DC::UI::ValSlider |
1838 | $table->add_at (2, 18, new DC::UI::ValSlider |
1777 | range => [$::CFG->{pickup} & 0xF, 0, 16, 1, 1], |
1839 | range => [$::CFG->{pickup} & 0xF, 0, 16, 1, 1], |
1778 | template => ">= 99", |
1840 | template => ">= 99", |
|
|
1841 | tooltip => "Pick up items whose value/weight (silver/kg) ratio is equal or higher than this setting (which is specified in gold coins).", |
1779 | to_value => sub { ">= " . 5 * $_[0] }, |
1842 | to_value => sub { ">= " . 5 * $_[0] }, |
1780 | on_changed => sub { |
1843 | on_changed => sub { |
1781 | my ($slider, $value) = @_; |
1844 | my ($slider, $value) = @_; |
1782 | |
1845 | |
1783 | $::CFG->{pickup} &= ~0xF; |
1846 | $::CFG->{pickup} &= ~0xF; |
… | |
… | |
1839 | $::CFG->{inv_sort} = $_[1]; |
1902 | $::CFG->{inv_sort} = $_[1]; |
1840 | $INV->set_sort_order ($SORT_ORDER{$_[1]}); |
1903 | $INV->set_sort_order ($SORT_ORDER{$_[1]}); |
1841 | }, |
1904 | }, |
1842 | ); |
1905 | ); |
1843 | $hb1->add (new DC::UI::Label text => "Weight: ", align => 1, expand => 1); |
1906 | $hb1->add (new DC::UI::Label text => "Weight: ", align => 1, expand => 1); |
1844 | #TODO# update to weigh/maxweight |
1907 | #TODO# update to weight/maxweight |
1845 | $hb1->add ($STATWIDS->{i_weight} = new DC::UI::Label align => 0); |
1908 | $hb1->add ($STATWIDS->{i_weight} = new DC::UI::Label align => 0); |
1846 | |
1909 | |
1847 | $vb1->add (my $sw1 = new DC::UI::ScrolledWindow expand => 1, scroll_y => 1); |
1910 | $vb1->add (my $sw1 = new DC::UI::ScrolledWindow expand => 1, scroll_y => 1); |
1848 | $sw1->add ($INV = new DC::UI::Inventory); |
1911 | $sw1->add ($INV = new DC::UI::Inventory); |
1849 | $INV->set_sort_order ($SORT_ORDER{$::CFG->{inv_sort}}); |
1912 | $INV->set_sort_order ($SORT_ORDER{$::CFG->{inv_sort}}); |
… | |
… | |
2113 | on_activate => sub { $QUIT_DIALOG->hide; 0 }, |
2176 | on_activate => sub { $QUIT_DIALOG->hide; 0 }, |
2114 | ); |
2177 | ); |
2115 | $hb->add (new DC::UI::Button |
2178 | $hb->add (new DC::UI::Button |
2116 | text => "Quit anyway", |
2179 | text => "Quit anyway", |
2117 | expand => 1, |
2180 | expand => 1, |
2118 | on_activate => sub { EV::unloop EV::UNLOOP_ALL }, |
2181 | on_activate => sub { |
|
|
2182 | crash "Quit anyway"; |
|
|
2183 | EV::unloop EV::UNLOOP_ALL; |
|
|
2184 | }, |
2119 | ); |
2185 | ); |
2120 | } |
2186 | } |
2121 | |
2187 | |
2122 | $QUIT_DIALOG->show; |
2188 | $QUIT_DIALOG->show; |
2123 | $QUIT_DIALOG->grab_focus; |
2189 | $QUIT_DIALOG->grab_focus; |
… | |
… | |
2191 | @SDL_MODES = DC::SDL_ListModes 5, 0 unless @SDL_MODES; |
2257 | @SDL_MODES = DC::SDL_ListModes 5, 0 unless @SDL_MODES; |
2192 | @SDL_MODES or DC::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; |
2258 | @SDL_MODES or DC::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; |
2193 | |
2259 | |
2194 | @SDL_MODES = sort { $a->[0] * $a->[1] <=> $b->[0] * $b->[1] } @SDL_MODES; |
2260 | @SDL_MODES = sort { $a->[0] * $a->[1] <=> $b->[0] * $b->[1] } @SDL_MODES; |
2195 | |
2261 | |
2196 | if (!exists $CFG->{sdl_mode} or $CFG->{sdl_mode} >= @SDL_MODES) { |
2262 | if (!defined $CFG->{sdl_mode} or $CFG->{sdl_mode} > $#SDL_MODES) { |
2197 | $CFG->{sdl_mode} = 0; |
2263 | $CFG->{sdl_mode} = 0; # lowest resolution by default |
|
|
2264 | |
|
|
2265 | # now choose biggets mode <= 1024x768 |
2198 | for (reverse 0 .. $#SDL_MODES) { |
2266 | for (0 .. $#SDL_MODES) { |
2199 | $CFG->{sdl_mode} = $_ if $SDL_MODES[$_][0] * $SDL_MODES[$_][1] >= 800 * 600; |
2267 | if ($SDL_MODES[$_][0] * $SDL_MODES[$_][1] <= 1024 * 768) { |
|
|
2268 | $CFG->{sdl_mode} = $_; |
|
|
2269 | } |
2200 | } |
2270 | } |
2201 | } |
2271 | } |
2202 | |
2272 | |
2203 | my ($old_w, $old_h) = ($WIDTH, $HEIGHT); |
2273 | my ($old_w, $old_h) = ($WIDTH, $HEIGHT); |
2204 | |
2274 | |
2205 | ($WIDTH, $HEIGHT, my ($rgb, $alpha)) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; |
2275 | ($WIDTH, $HEIGHT, my ($rgb, $alpha)) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; |
2206 | $FULLSCREEN = $CFG->{fullscreen}; |
2276 | $FULLSCREEN = $CFG->{fullscreen}; |
2207 | $FAST = $CFG->{fast}; |
2277 | $FAST = $CFG->{fast}; |
2208 | |
2278 | |
|
|
2279 | # due to mac os x braindamage, we simply retry with !fullscreen in case of an error |
2209 | DC::SDL_SetVideoMode $WIDTH, $HEIGHT, $rgb, $alpha, $FULLSCREEN |
2280 | DC::SDL_SetVideoMode $WIDTH, $HEIGHT, $rgb, $alpha, $FULLSCREEN |
|
|
2281 | or DC::SDL_SetVideoMode $WIDTH, $HEIGHT, $rgb, $alpha, !$FULLSCREEN |
2210 | or die "SDL_SetVideoMode failed: " . (DC::SDL_GetError) . "\n"; |
2282 | or die "SDL_SetVideoMode failed: " . (DC::SDL_GetError) . "\n"; |
2211 | |
2283 | |
2212 | $SDL_ACTIVE = 1; |
2284 | $SDL_ACTIVE = 1; |
2213 | $LAST_REFRESH = time - 0.01; |
2285 | $LAST_REFRESH = time - 0.01; |
2214 | |
2286 | |
… | |
… | |
2394 | |
2466 | |
2395 | $MODE_SLIDER->set_range ([$CFG->{sdl_mode}, 0, $#SDL_MODES, 1, 1]); |
2467 | $MODE_SLIDER->set_range ([$CFG->{sdl_mode}, 0, $#SDL_MODES, 1, 1]); |
2396 | $MODE_SLIDER->emit (changed => $CFG->{sdl_mode}); |
2468 | $MODE_SLIDER->emit (changed => $CFG->{sdl_mode}); |
2397 | |
2469 | |
2398 | $CAVEAT_LABEL->set_text ("None :)"); |
2470 | $CAVEAT_LABEL->set_text ("None :)"); |
2399 | $CAVEAT_LABEL->set_text ("Sofwtare Rendering (very slow)") |
2471 | $CAVEAT_LABEL->set_text ("Software Rendering (very slow)") |
2400 | unless DC::SDL_GL_GetAttribute DC::SDL_GL_ACCELERATED_VISUAL; |
2472 | unless DC::SDL_GL_GetAttribute DC::SDL_GL_ACCELERATED_VISUAL; |
2401 | |
2473 | |
2402 | $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]); |
2474 | $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]); |
2403 | } |
2475 | } |
2404 | |
2476 | |
… | |
… | |
2455 | delete $animate_object{$widget}; |
2527 | delete $animate_object{$widget}; |
2456 | } |
2528 | } |
2457 | |
2529 | |
2458 | %SDL_CB = ( |
2530 | %SDL_CB = ( |
2459 | DC::SDL_QUIT => sub { |
2531 | DC::SDL_QUIT => sub { |
|
|
2532 | crash "SDL_QUIT"; |
2460 | EV::unloop EV::UNLOOP_ALL; |
2533 | EV::unloop EV::UNLOOP_ALL; |
2461 | }, |
2534 | }, |
2462 | DC::SDL_VIDEORESIZE => sub { |
2535 | DC::SDL_VIDEORESIZE => sub { |
2463 | }, |
2536 | }, |
2464 | DC::SDL_VIDEOEXPOSE => sub { |
2537 | DC::SDL_VIDEOEXPOSE => sub { |
… | |
… | |
2504 | $SIG{INT} = $SIG{TERM} = sub { |
2577 | $SIG{INT} = $SIG{TERM} = sub { |
2505 | EV::unloop; |
2578 | EV::unloop; |
2506 | #d# TODO calling exit here hangs the process in some futex |
2579 | #d# TODO calling exit here hangs the process in some futex |
2507 | }; |
2580 | }; |
2508 | |
2581 | |
2509 | { |
2582 | # due to mac os x + sdl combined briandamage, we need this contortion |
|
|
2583 | sub main { |
|
|
2584 | { |
2510 | DC::Pod::load_docwiki DC::find_rcfile "docwiki.pst"; |
2585 | DC::Pod::load_docwiki DC::find_rcfile "docwiki.pst"; |
2511 | |
2586 | |
2512 | if (-e "$Deliantra::VARDIR/client.cf") { |
2587 | if (-e "$Deliantra::VARDIR/client.cf") { |
2513 | DC::read_cfg "$Deliantra::VARDIR/client.cf"; |
2588 | DC::read_cfg "$Deliantra::VARDIR/client.cf"; |
2514 | } else { |
2589 | } else { |
2515 | #TODO: compatibility cruft |
2590 | #TODO: compatibility cruft |
2516 | DC::read_cfg "$Deliantra::OLDDIR/cfplusrc"; |
2591 | DC::read_cfg "$Deliantra::OLDDIR/cfplusrc"; |
2517 | print STDERR "INFO: used old configuration file\n"; |
2592 | print STDERR "INFO: used old configuration file\n"; |
2518 | } |
2593 | } |
2519 | |
2594 | |
2520 | DC::DB::Server::run; |
2595 | DC::DB::Server::run; |
2521 | |
2596 | |
2522 | if ($CFG->{db_schema} < 1) { |
2597 | if ($CFG->{db_schema} < 1) { |
2523 | warn "INFO: upgrading database schema from 0 to 1, mapcache and tilecache will be lost\n"; |
2598 | warn "INFO: upgrading database schema from 0 to 1, mapcache and tilecache will be lost\n"; |
2524 | DC::DB::nuke_db; |
2599 | DC::DB::nuke_db; |
2525 | $CFG->{db_schema} = 1; |
2600 | $CFG->{db_schema} = 1; |
2526 | DC::write_cfg; |
2601 | DC::write_cfg; |
2527 | } |
2602 | } |
2528 | |
2603 | |
2529 | DC::DB::open_db; |
2604 | DC::DB::open_db; |
2530 | |
2605 | |
2531 | DC::UI::set_layout ($::CFG->{layout}); |
2606 | DC::UI::set_layout ($::CFG->{layout}); |
2532 | |
2607 | |
2533 | my %DEF_CFG = ( |
2608 | my %DEF_CFG = ( |
2534 | sdl_mode => 0, |
2609 | sdl_mode => undef, |
2535 | fullscreen => 1, |
2610 | fullscreen => 1, |
2536 | fast => 0, |
2611 | fast => 0, |
2537 | force_opengl11 => undef, |
2612 | force_opengl11 => undef, |
2538 | disable_alpha => 0, |
2613 | disable_alpha => 0, |
|
|
2614 | smooth_movement => 1, |
2539 | texture_compression => 1, |
2615 | texture_compression => 1, |
2540 | map_scale => 1, |
2616 | map_scale => 1, |
2541 | fow_enable => 1, |
2617 | fow_enable => 1, |
2542 | fow_intensity => 0, |
2618 | fow_intensity => 0, |
2543 | map_smoothing => 1, |
2619 | map_smoothing => 1, |
2544 | gui_fontsize => 1, |
2620 | gui_fontsize => 1, |
2545 | log_fontsize => 0.7, |
2621 | log_fontsize => 0.7, |
2546 | gauge_fontsize => 1, |
2622 | gauge_fontsize => 1, |
2547 | gauge_size => 0.35, |
2623 | gauge_size => 0.35, |
2548 | stat_fontsize => 0.7, |
2624 | stat_fontsize => 0.7, |
2549 | mapsize => 100, |
2625 | mapsize => 100, |
2550 | audio_enable => 1, |
2626 | audio_enable => 1, |
2551 | audio_hw_channels => 0, |
2627 | audio_hw_channels => 0, |
2552 | audio_hw_frequency => 0, |
2628 | audio_hw_frequency => 0, |
2553 | audio_hw_chunksize => 0, |
2629 | audio_hw_chunksize => 0, |
2554 | audio_mix_channels => 8, |
2630 | audio_mix_channels => 8, |
2555 | effects_enable => 1, |
2631 | effects_enable => 1, |
2556 | effects_volume => 1, |
2632 | effects_volume => 1, |
2557 | bgm_enable => 1, |
2633 | bgm_enable => 1, |
2558 | bgm_volume => 0.5, |
2634 | bgm_volume => 0.5, |
2559 | output_rate => "", |
2635 | output_rate => "", |
2560 | pickup => 0, |
2636 | pickup => 0, |
2561 | inv_sort => "mtime", |
2637 | inv_sort => "mtime", |
2562 | default => "profile", # default profile |
2638 | default => "profile", # default profile |
2563 | show_tips => 1, |
2639 | show_tips => 1, |
2564 | logview_max_par => 1000, |
2640 | logview_max_par => 1000, |
2565 | shift_fire_stop => 0, |
2641 | shift_fire_stop => 0, |
2566 | ); |
2642 | ); |
2567 | |
2643 | |
2568 | while (my ($k, $v) = each %DEF_CFG) { |
2644 | while (my ($k, $v) = each %DEF_CFG) { |
2569 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
2645 | $CFG->{$k} = $v unless exists $CFG->{$k}; |
2570 | } |
2646 | } |
2571 | |
2647 | |
2572 | $CFG->{profile}{default}{host} ||= "gameserver.deliantra.net"; |
2648 | $CFG->{profile}{default}{host} ||= "gameserver.deliantra.net"; |
2573 | $PROFILE = $CFG->{profile}{default}; |
2649 | $PROFILE = $CFG->{profile}{default}; |
2574 | |
2650 | |
2575 | # convert old bindings (only default profile matters) |
2651 | # convert old bindings (only default profile matters) |
2576 | if (my $bindings = delete $PROFILE->{bindings}) { |
2652 | if (my $bindings = delete $PROFILE->{bindings}) { |
2577 | while (my ($mod, $syms) = each %$bindings) { |
2653 | while (my ($mod, $syms) = each %$bindings) { |
2578 | while (my ($sym, $cmds) = each %$syms) { |
2654 | while (my ($sym, $cmds) = each %$syms) { |
2579 | push @{ $PROFILE->{macro} }, { |
2655 | push @{ $PROFILE->{macro} }, { |
2580 | accelkey => [$mod*1, $sym*1], |
2656 | accelkey => [$mod*1, $sym*1], |
2581 | action => $cmds, |
2657 | action => $cmds, |
|
|
2658 | }; |
2582 | }; |
2659 | } |
2583 | } |
2660 | } |
2584 | } |
2661 | } |
2585 | } |
|
|
2586 | |
2662 | |
2587 | sdl_init; |
2663 | sdl_init; |
2588 | |
2664 | |
2589 | { |
2665 | { |
2590 | my @fonts = map DC::find_rcfile "fonts/$_", qw( |
2666 | my @fonts = map DC::find_rcfile "fonts/$_", qw( |
2591 | DejaVuSans.ttf |
2667 | DejaVuSans.ttf |
2592 | DejaVuSansMono.ttf |
2668 | DejaVuSansMono.ttf |
2593 | DejaVuSans-Bold.ttf |
2669 | DejaVuSans-Bold.ttf |
2594 | DejaVuSansMono-Bold.ttf |
2670 | DejaVuSansMono-Bold.ttf |
2595 | DejaVuSans-Oblique.ttf |
2671 | DejaVuSans-Oblique.ttf |
2596 | DejaVuSansMono-Oblique.ttf |
2672 | DejaVuSansMono-Oblique.ttf |
2597 | DejaVuSans-BoldOblique.ttf |
2673 | DejaVuSans-BoldOblique.ttf |
2598 | DejaVuSansMono-BoldOblique.ttf |
2674 | DejaVuSansMono-BoldOblique.ttf |
2599 | ); |
2675 | ); |
2600 | |
2676 | |
2601 | DC::add_font $_ for @fonts; |
2677 | DC::add_font $_ for @fonts; |
2602 | |
2678 | |
2603 | $FONT_PROP = new_from_file DC::Font $fonts[0]; |
2679 | $FONT_PROP = new_from_file DC::Font $fonts[0]; |
2604 | $FONT_FIXED = new_from_file DC::Font $fonts[1]; |
2680 | $FONT_FIXED = new_from_file DC::Font $fonts[1]; |
2605 | |
2681 | |
2606 | $FONT_PROP->make_default; |
2682 | $FONT_PROP->make_default; |
2607 | |
2683 | |
2608 | DC::pango_init; |
2684 | DC::pango_init; |
2609 | } |
2685 | } |
2610 | |
2686 | |
2611 | # compare mono (ft) vs. rgba (cairo) |
2687 | # compare mono (ft) vs. rgba (cairo) |
2612 | # ft - 1.8s, cairo 3s, even in alpha-only mode |
2688 | # ft - 1.8s, cairo 3s, even in alpha-only mode |
2613 | # for my $rgba (0..1) { |
2689 | # for my $rgba (0..1) { |
2614 | # my $t1 = Time::HiRes::time; |
2690 | # my $t1 = Time::HiRes::time; |
… | |
… | |
2619 | # } |
2695 | # } |
2620 | # my $t2 = Time::HiRes::time; |
2696 | # my $t2 = Time::HiRes::time; |
2621 | # warn $t2-$t1; |
2697 | # warn $t2-$t1; |
2622 | # } |
2698 | # } |
2623 | |
2699 | |
2624 | video_init; |
2700 | video_init; |
2625 | audio_init; |
2701 | audio_init; |
2626 | } |
2702 | } |
2627 | |
2703 | |
2628 | show_tip_of_the_day if $CFG->{show_tips}; |
2704 | show_tip_of_the_day if $CFG->{show_tips}; |
2629 | |
2705 | |
2630 | our $STARTUP_CANCEL = EV::idle sub { |
2706 | our $STARTUP_CANCEL = EV::idle sub { |
2631 | undef $::STARTUP_CANCEL; |
2707 | undef $::STARTUP_CANCEL; |
2632 | $startup_done->(); |
2708 | $startup_done->(); |
2633 | }; |
2709 | }; |
2634 | |
2710 | |
2635 | delete $SIG{__DIE__}; |
2711 | delete $SIG{__DIE__}; |
2636 | EV::loop; |
2712 | EV::loop; |
2637 | |
2713 | |
2638 | #video_shutdown; |
2714 | #video_shutdown; |
2639 | #audio_shutdown; |
2715 | #audio_shutdown; |
2640 | DC::OpenGL::quit; |
2716 | DC::OpenGL::quit; |
2641 | DC::SDL_Quit; |
2717 | DC::SDL_Quit; |
2642 | DC::DB::Server::stop; |
2718 | DC::DB::Server::stop; |
|
|
2719 | } |
|
|
2720 | |
|
|
2721 | DC::SDL_braino; # see sub above |
2643 | |
2722 | |
2644 | =head1 NAME |
2723 | =head1 NAME |
2645 | |
2724 | |
2646 | deliantra - A Deliantra MORPG game client |
2725 | deliantra - A Deliantra MORPG game client |
2647 | |
2726 | |
… | |
… | |
2664 | 4 show fps |
2743 | 4 show fps |
2665 | 8 suppress tooltips |
2744 | 8 suppress tooltips |
2666 | |
2745 | |
2667 | =head1 AUTHOR |
2746 | =head1 AUTHOR |
2668 | |
2747 | |
2669 | Marc Lehmann <crossfire@schmorp.de>, Robin Redeker <elmex@ta-sa.org> |
2748 | Marc Lehmann <deliantra@schmorp.de>, Robin Redeker <elmex@ta-sa.org> |
2670 | |
2749 | |
2671 | |
2750 | |
2672 | |
2751 | |