… | |
… | |
113 | our $CONN; |
113 | our $CONN; |
114 | our $PROFILE; # current profile |
114 | our $PROFILE; # current profile |
115 | our $FAST; # fast, low-quality mode, possibly useful for software-rendering |
115 | our $FAST; # fast, low-quality mode, possibly useful for software-rendering |
116 | |
116 | |
117 | our $WANT_REFRESH; |
117 | our $WANT_REFRESH; |
118 | our $CAN_REFRESH; |
|
|
119 | |
118 | |
120 | our @SDL_MODES; |
119 | our @SDL_MODES; |
121 | our $WIDTH; |
120 | our $WIDTH; |
122 | our $HEIGHT; |
121 | our $HEIGHT; |
123 | our $FULLSCREEN; |
122 | our $FULLSCREEN; |
… | |
… | |
226 | for (grep $_->[0] >= Event::time, @{(delete $AUDIO_PLAY{$face}) || []}) { |
225 | for (grep $_->[0] >= Event::time, @{(delete $AUDIO_PLAY{$face}) || []}) { |
227 | my (undef, $dx, $dy, $vol) = @$_; |
226 | my (undef, $dx, $dy, $vol) = @$_; |
228 | |
227 | |
229 | my $channel = CFPlus::Channel::find; |
228 | my $channel = CFPlus::Channel::find; |
230 | $channel->volume ($vol * $CFG->{effects_volume} * 128 / 255); |
229 | $channel->volume ($vol * $CFG->{effects_volume} * 128 / 255); |
231 | $dx = $dx / 10 * 255; |
|
|
232 | $channel->set_panning (255 - $dx, 255 + $dx); |
|
|
233 | |
|
|
234 | # my $angle = $dx ? : $dx < 0 ? |
|
|
235 | # my $distance = -$vol; |
|
|
236 | # $channel->set_position ($angle, $distance); |
230 | $channel->set_position_r ($dx, $dy, 20); |
237 | |
|
|
238 | $chunk->play ($channel); |
231 | $chunk->play ($channel); |
239 | } |
232 | } |
240 | } else { |
233 | } else { |
241 | # sound_meta not set means data is in flight either way |
234 | # sound_meta not set means data is in flight either way |
242 | my $meta = $CONN->{sound_meta}{$face} |
235 | my $meta = $CONN->{sound_meta}{$face} |
… | |
… | |
811 | |
804 | |
812 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Map Smoothing"); |
805 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Map Smoothing"); |
813 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
806 | $table->add_at (1, $row++, new CFPlus::UI::CheckBox |
814 | state => $CFG->{map_smoothing}, |
807 | state => $CFG->{map_smoothing}, |
815 | tooltip => "<b>Map Smoothing</b> tries to make tile borders less square. " |
808 | tooltip => "<b>Map Smoothing</b> tries to make tile borders less square. " |
816 | . "This increases load on the graphics subsystem and works only with 2.x servers. " |
809 | . "This increases load on the graphics subsystem and works only with TRT servers. " |
817 | . "Changes take effect at next connection only.", |
810 | . "Changes take effect at next connection only.", |
818 | on_changed => sub { my ($self, $value) = @_; $CFG->{map_smoothing} = $value; 0 } |
811 | on_changed => sub { my ($self, $value) = @_; $CFG->{map_smoothing} = $value; 0 } |
819 | ); |
812 | ); |
820 | |
813 | |
821 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fog of War"); |
814 | $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fog of War"); |
… | |
… | |
2098 | my $animate_timer; |
2091 | my $animate_timer; |
2099 | |
2092 | |
2100 | my $fps = 9; |
2093 | my $fps = 9; |
2101 | |
2094 | |
2102 | sub force_refresh { |
2095 | sub force_refresh { |
|
|
2096 | if ($ENV{CFPLUS_DEBUG} & 4) { |
2103 | $fps = $fps * 0.95 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.05; |
2097 | $fps = $fps * 0.98 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.02; |
2104 | debug sprintf "%3.2f", $fps if $ENV{CFPLUS_DEBUG} & 4; |
2098 | debug sprintf "%3.2f", $fps; |
|
|
2099 | } |
2105 | |
2100 | |
2106 | $CFPlus::UI::ROOT->draw; |
2101 | $CFPlus::UI::ROOT->draw; |
2107 | |
2102 | CFPlus::SDL_GL_SwapBuffers; |
2108 | $WANT_REFRESH = 0; |
|
|
2109 | $CAN_REFRESH = 0; |
|
|
2110 | $LAST_REFRESH = $NOW; |
2103 | $LAST_REFRESH = $NOW; |
2111 | |
2104 | $WANT_REFRESH->stop; |
2112 | CFPlus::SDL_GL_SwapBuffers; |
|
|
2113 | } |
2105 | } |
2114 | |
2106 | |
|
|
2107 | $WANT_REFRESH = Event->idle (min => 0.001, max => 0.06, parked => 1, cb => \&force_refresh); |
|
|
2108 | |
2115 | my $refresh_watcher = Event->timer (after => 0, hard => 0, interval => 1 / $MAX_FPS, cb => sub { |
2109 | my $input = Event->timer (after => 0, hard => 0, interval => 1 / 50, cb => sub { |
2116 | $NOW = time; |
2110 | $NOW = time; |
2117 | |
2111 | |
2118 | ($SDL_CB{$_->{type}} || sub { warn "unhandled event $_->{type}" })->($_) |
2112 | ($SDL_CB{$_->{type}} || sub { warn "unhandled event $_->{type}" })->($_) |
2119 | for CFPlus::poll_events; |
2113 | for CFPlus::poll_events; |
2120 | |
2114 | |
2121 | if (%animate_object) { |
2115 | if (%animate_object) { |
2122 | $_->animate ($LAST_REFRESH - $NOW) for values %animate_object; |
2116 | $_->animate ($LAST_REFRESH - $NOW) for values %animate_object; |
2123 | ++$WANT_REFRESH; |
2117 | $WANT_REFRESH->start; |
2124 | } |
|
|
2125 | |
|
|
2126 | if ($WANT_REFRESH) { |
|
|
2127 | force_refresh; |
|
|
2128 | } else { |
|
|
2129 | $CAN_REFRESH = 1; |
|
|
2130 | } |
2118 | } |
2131 | }); |
2119 | }); |
2132 | |
2120 | |
2133 | sub animation_start { |
2121 | sub animation_start { |
2134 | my ($widget) = @_; |
2122 | my ($widget) = @_; |