… | |
… | |
98 | |
98 | |
99 | use Deliantra; |
99 | use Deliantra; |
100 | use Deliantra::Protocol::Constants; |
100 | use Deliantra::Protocol::Constants; |
101 | |
101 | |
102 | use AnyEvent::DNS; |
102 | use AnyEvent::DNS; |
|
|
103 | use AnyEvent::Socket (); |
103 | |
104 | |
104 | use Compress::LZF; |
105 | use Compress::LZF; |
105 | |
106 | |
106 | use DC; |
107 | use DC; |
107 | BEGIN { $SIG{__DIE__} = sub { DC::fatal Carp::longmess "$@" unless $^S } } |
108 | BEGIN { $SIG{__DIE__} = sub { DC::fatal Carp::longmess "$_[0]" unless $^S } } |
108 | use DC::OpenGL (); |
109 | use DC::OpenGL (); |
109 | use DC::Protocol; |
110 | use DC::Protocol; |
110 | use DC::DB; |
111 | use DC::DB; |
111 | use DC::UI; |
112 | use DC::UI; |
112 | use DC::UI::Canvas; |
113 | use DC::UI::Canvas; |
… | |
… | |
141 | our $FAST; # fast, low-quality mode, possibly useful for software-rendering |
142 | our $FAST; # fast, low-quality mode, possibly useful for software-rendering |
142 | |
143 | |
143 | our $WANT_REFRESH; |
144 | our $WANT_REFRESH; |
144 | |
145 | |
145 | our @SDL_MODES; |
146 | our @SDL_MODES; |
|
|
147 | our $SDL_REINIT = 1; |
146 | our $WIDTH; |
148 | our $WIDTH; |
147 | our $HEIGHT; |
149 | our $HEIGHT; |
148 | our $FULLSCREEN; |
150 | our $FULLSCREEN; |
149 | our $FONTSIZE; |
151 | our $FONTSIZE; |
150 | |
152 | |
… | |
… | |
736 | my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; |
738 | my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; |
737 | |
739 | |
738 | $CONN = |
740 | $CONN = |
739 | new DC::Protocol |
741 | new DC::Protocol |
740 | host => $host, |
742 | host => $host, |
741 | port => $port || 13327, |
743 | port => $port, |
742 | user => $PROFILE->{user}, |
744 | user => $PROFILE->{user}, |
743 | pass => $PROFILE->{password}, |
745 | pass => $PROFILE->{password}, |
744 | mapw => $mapsize, |
746 | mapw => $mapsize, |
745 | maph => $mapsize, |
747 | maph => $mapsize, |
746 | |
748 | |
… | |
… | |
774 | status "logging in..."; |
776 | status "logging in..."; |
775 | |
777 | |
776 | $LOGIN_BUTTON->set_text ("Logout"); |
778 | $LOGIN_BUTTON->set_text ("Logout"); |
777 | $SETUP_DIALOG->hide; |
779 | $SETUP_DIALOG->hide; |
778 | |
780 | |
779 | my ($host, $port) = split /:/, $PROFILE->{host}; |
781 | my ($host, $port) = AnyEvent::Socket::parse_hostport $PROFILE->{host}, "deliantra=13327"; |
780 | |
782 | |
781 | $MAP = new DC::Map; |
783 | $MAP = new DC::Map; |
782 | |
784 | |
783 | # hack to make SURE we find the IP address all right |
785 | # hack to make SURE we find the IP address all right |
784 | # can be removed once AnyEvent::DNS is proven stable. |
786 | # can be removed once AnyEvent::DNS is proven stable. |
… | |
… | |
863 | state => $CFG->{force_opengl11}, |
865 | state => $CFG->{force_opengl11}, |
864 | tooltip => "Limit Deliantra to use OpenGL 1.1 features only. This will normally result in " |
866 | tooltip => "Limit Deliantra to use OpenGL 1.1 features only. This will normally result in " |
865 | . "higher memory usage and slower performance. It will, however, help tremendously on " |
867 | . "higher memory usage and slower performance. It will, however, help tremendously on " |
866 | . "cards that claim to support a feature but fall back to software rendering. " |
868 | . "cards that claim to support a feature but fall back to software rendering. " |
867 | . "Nvidia Geforce FX cards are known to claim features the hardware doesn't support, " |
869 | . "Nvidia Geforce FX cards are known to claim features the hardware doesn't support, " |
868 | . "but cards and drivers from other vendors (ATI) are often just as bad. <b>If you " |
870 | . "but cards and drivers from other vendors (ATI) are often just as bad. " |
869 | . "experience extremely low framerates and your card should do better, try this option.</b>", |
871 | . "<b>If you experience extremely low framerates and your card should do better, try this option.</b>", |
870 | on_changed => sub { my ($self, $value) = @_; $CFG->{force_opengl11} = $value; 0 } |
872 | on_changed => sub { my ($self, $value) = @_; $CFG->{force_opengl11} = $value; 0 } |
|
|
873 | ); |
|
|
874 | |
|
|
875 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Forbid Alpha"); |
|
|
876 | $table->add_at (1, $row++, new DC::UI::CheckBox |
|
|
877 | state => $CFG->{disable_alpha}, |
|
|
878 | tooltip => "Forbid off the use of the alpha channel. This makes Deliantra look a lot worse " |
|
|
879 | . "by disabling a number of textures and transparency effects. Normally, these " |
|
|
880 | . "effects do not cost a lot of resources, but some graphics cards might fall " |
|
|
881 | . "back to etxremely slow rendering if this is enabled. If disabling this option " |
|
|
882 | . "noticably improves the framerate of the client please report this! " |
|
|
883 | . "<b>If you experience extremely low framerates and your card should do better, try this option.</b>", |
|
|
884 | on_changed => sub { |
|
|
885 | my ($self, $value) = @_; |
|
|
886 | $CFG->{disable_alpha} = $value; |
|
|
887 | $SDL_REINIT = 1; # SDL_SetVideoMode ignores GL attr changes |
|
|
888 | 0 |
|
|
889 | } |
871 | ); |
890 | ); |
872 | |
891 | |
873 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Compress Textures"); |
892 | $table->add_at (0, $row, new DC::UI::Label align => 1, text => "Compress Textures"); |
874 | $table->add_at (1, $row++, new DC::UI::CheckBox |
893 | $table->add_at (1, $row++, new DC::UI::CheckBox |
875 | state => $CFG->{texture_compression}, |
894 | state => $CFG->{texture_compression}, |
… | |
… | |
2146 | $dialog->show; |
2165 | $dialog->show; |
2147 | }; |
2166 | }; |
2148 | } |
2167 | } |
2149 | |
2168 | |
2150 | sub sdl_init { |
2169 | sub sdl_init { |
2151 | DC::SDL_Init |
2170 | DC::SDL_Init DC::SDL_INIT_AUDIO #| DC::SDL_NOPARACHUTE |
2152 | and die "SDL::Init failed!\n"; |
2171 | and die "SDL::Init failed!\n"; |
2153 | } |
2172 | } |
2154 | |
2173 | |
2155 | sub video_init { |
2174 | sub video_init { |
|
|
2175 | DC::SDL_InitSubSystem DC::SDL_INIT_VIDEO if $SDL_REINIT; |
|
|
2176 | $SDL_REINIT = 0; |
|
|
2177 | |
|
|
2178 | @SDL_MODES = DC::SDL_ListModes 8, $CFG->{disable_alpha} ? 0 : 8; |
|
|
2179 | @SDL_MODES = DC::SDL_ListModes 8, 8 unless @SDL_MODES; |
|
|
2180 | @SDL_MODES = DC::SDL_ListModes 5, 0 unless @SDL_MODES; |
|
|
2181 | @SDL_MODES or DC::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; |
|
|
2182 | |
|
|
2183 | @SDL_MODES = sort { $a->[0] * $a->[1] <=> $b->[0] * $b->[1] } @SDL_MODES; |
|
|
2184 | |
2156 | $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} >= @SDL_MODES; |
2185 | if (!exists $CFG->{sdl_mode} or $CFG->{sdl_mode} >= @SDL_MODES) { |
|
|
2186 | $CFG->{sdl_mode} = 0; |
|
|
2187 | for (reverse 0 .. $#SDL_MODES) { |
|
|
2188 | $CFG->{sdl_mode} = $_ if $SDL_MODES[$_][0] * $SDL_MODES[$_][1] >= 800 * 600; |
|
|
2189 | } |
|
|
2190 | } |
2157 | |
2191 | |
2158 | my ($old_w, $old_h) = ($WIDTH, $HEIGHT); |
2192 | my ($old_w, $old_h) = ($WIDTH, $HEIGHT); |
2159 | |
2193 | |
2160 | ($WIDTH, $HEIGHT, my ($rgb, $alpha)) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; |
2194 | ($WIDTH, $HEIGHT, my ($rgb, $alpha)) = @{ $SDL_MODES[$CFG->{sdl_mode}] }; |
2161 | $FULLSCREEN = $CFG->{fullscreen}; |
2195 | $FULLSCREEN = $CFG->{fullscreen}; |
… | |
… | |
2350 | $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]); |
2384 | $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]); |
2351 | } |
2385 | } |
2352 | |
2386 | |
2353 | sub video_shutdown { |
2387 | sub video_shutdown { |
2354 | DC::OpenGL::shutdown; |
2388 | DC::OpenGL::shutdown; |
|
|
2389 | DC::SDL_QuitSubSystem DC::SDL_INIT_VIDEO if $SDL_REINIT; |
2355 | |
2390 | |
2356 | undef $SDL_ACTIVE; |
2391 | undef $SDL_ACTIVE; |
2357 | } |
2392 | } |
2358 | |
2393 | |
2359 | my %animate_object; |
2394 | my %animate_object; |
… | |
… | |
2420 | # printf "M\n" if $_[0]{state} & DC::SDL_APPMOUSEFOCUS; |
2455 | # printf "M\n" if $_[0]{state} & DC::SDL_APPMOUSEFOCUS; |
2421 | }, |
2456 | }, |
2422 | DC::SDL_KEYDOWN => sub { |
2457 | DC::SDL_KEYDOWN => sub { |
2423 | if ($_[0]{mod} & DC::KMOD_ALT && $_[0]{sym} == 13) { |
2458 | if ($_[0]{mod} & DC::KMOD_ALT && $_[0]{sym} == 13) { |
2424 | # alt-enter |
2459 | # alt-enter |
|
|
2460 | video_shutdown; |
2425 | $FULLSCREEN_ENABLE->toggle; |
2461 | $FULLSCREEN_ENABLE->toggle; |
2426 | video_shutdown; |
|
|
2427 | video_init; |
2462 | video_init; |
2428 | } else { |
2463 | } else { |
2429 | &DC::UI::feed_sdl_key_down_event; |
2464 | &DC::UI::feed_sdl_key_down_event; |
2430 | } |
2465 | } |
2431 | update_modbox; |
2466 | update_modbox; |
… | |
… | |
2480 | my %DEF_CFG = ( |
2515 | my %DEF_CFG = ( |
2481 | sdl_mode => 0, |
2516 | sdl_mode => 0, |
2482 | fullscreen => 1, |
2517 | fullscreen => 1, |
2483 | fast => 0, |
2518 | fast => 0, |
2484 | force_opengl11 => undef, |
2519 | force_opengl11 => undef, |
|
|
2520 | disable_alpha => 0, |
2485 | texture_compression => 1, |
2521 | texture_compression => 1, |
2486 | map_scale => 1, |
2522 | map_scale => 1, |
2487 | fow_enable => 1, |
2523 | fow_enable => 1, |
2488 | fow_intensity => 0, |
2524 | fow_intensity => 0, |
2489 | map_smoothing => 1, |
2525 | map_smoothing => 1, |
… | |
… | |
2530 | } |
2566 | } |
2531 | } |
2567 | } |
2532 | |
2568 | |
2533 | sdl_init; |
2569 | sdl_init; |
2534 | |
2570 | |
2535 | @SDL_MODES = DC::SDL_ListModes 8, 8; |
|
|
2536 | @SDL_MODES = DC::SDL_ListModes 5, 0 unless @SDL_MODES; |
|
|
2537 | @SDL_MODES or DC::fatal "Unable to find a usable video mode\n(hardware accelerated opengl fullscreen)"; |
|
|
2538 | |
|
|
2539 | @SDL_MODES = sort { $a->[0] * $a->[1] <=> $b->[0] * $b->[1] } @SDL_MODES; |
|
|
2540 | |
|
|
2541 | $CFG->{sdl_mode} = 0 if $CFG->{sdl_mode} > @SDL_MODES; |
|
|
2542 | |
|
|
2543 | { |
2571 | { |
2544 | my @fonts = map DC::find_rcfile "fonts/$_", qw( |
2572 | my @fonts = map DC::find_rcfile "fonts/$_", qw( |
2545 | DejaVuSans.ttf |
2573 | DejaVuSans.ttf |
2546 | DejaVuSansMono.ttf |
2574 | DejaVuSansMono.ttf |
2547 | DejaVuSans-Bold.ttf |
2575 | DejaVuSans-Bold.ttf |