--- deliantra/Deliantra-Client/bin/cfplus 2007/08/02 14:35:21 1.200
+++ deliantra/Deliantra-Client/bin/cfplus 2007/08/19 14:09:28 1.217
@@ -115,7 +115,6 @@
our $FAST; # fast, low-quality mode, possibly useful for software-rendering
our $WANT_REFRESH;
-our $CAN_REFRESH;
our @SDL_MODES;
our $WIDTH;
@@ -170,9 +169,7 @@
our $INV;
our $INVR;
-our $INV_RIGHT_HB;
-
-our $PICKUP_CFG;
+our $INVR_HB;
#############################################################################
@@ -219,19 +216,16 @@
$CFG->{effects_enable}
or return;
+ $AUDIO_PLAY{$face}
+ or return;
+
if (my $chunk = $AUDIO_CHUNK{$face}) {
for (grep $_->[0] >= Event::time, @{(delete $AUDIO_PLAY{$face}) || []}) {
my (undef, $dx, $dy, $vol) = @$_;
my $channel = CFPlus::Channel::find;
$channel->volume ($vol * $CFG->{effects_volume} * 128 / 255);
- $dx = $dx / 10 * 255;
- $channel->set_panning (255 - $dx, 255 + $dx);
-
-# my $angle = $dx ? : $dx < 0 ?
-# my $distance = -$vol;
-# $channel->set_position ($angle, $distance);
-
+ $channel->set_position_r ($dx, $dy, 20);
$chunk->play ($channel);
}
} else {
@@ -241,14 +235,16 @@
# if its a jingle, play it as ambient music
if ($meta->{meta}{jingle}) {
- delete $AUDIO_PLAY{$face}; # take the jingle out of the sound queue
- push @MUSIC_JINGLE, $meta; # push it oto the music/jingle queue
- &audio_music_push ($face);
+ if (delete $AUDIO_PLAY{$face}) { # take the jingle out of the sound queue
+ push @MUSIC_JINGLE, $meta; # push it oto the music/jingle queue
+ &audio_music_push ($face);
+ }
} else {
# fetch from database
CFPlus::DB::get res_data => $meta->{name}, sub {
my $rwops = new CFPlus::RW $_[0];
- my $chunk = new CFPlus::MixChunk $rwops;
+ my $chunk = new CFPlus::MixChunk $rwops
+ or Carp::confess "sound face " . (JSON::XS::to_json $meta) . " unloadable: " . CFPlus::Mix_GetError;
$chunk->volume (($meta->{meta}{volume} || 1) * 128);
$AUDIO_CHUNK{$face} = $chunk;
@@ -267,7 +263,7 @@
or return;
my $queue = $AUDIO_PLAY{$face} ||= [];
- push @$queue, [Event::time + 0.2, $dx, $dy, $vol]; # delay sound by max. 0.2s
+ push @$queue, [Event::time + 0.6, $dx, $dy, $vol]; # do not play sound for outdated events
audio_sound_push $face
unless @$queue > 1;
}
@@ -310,7 +306,7 @@
: new CFPlus::RW $$MUSIC_PLAYING_DATA;
$MUSIC_PLAYER = new CFPlus::MixMusic $rwops
- or ((warn CFPlus::Mix_GetError), return); # pretty fatal error
+ or Carp::confess "music face $meta->{face} unloadable: " . CFPlus::Mix_GetError;
my $NOW = time;
@@ -353,8 +349,7 @@
}
# if the currently playing song is acceptable, let it continue
- return if $MUSIC_PLAYING_META
- && grep $MUSIC_PLAYING_META == $_, @MUSIC_HAVE;
+ return if grep $MUSIC_PLAYING_META == $_, @MUSIC_HAVE;
my $NOW = time;
@@ -421,8 +416,6 @@
undef $MUSIC_PLAYING_META;
undef $MUSIC_PLAYING_DATA;
- audio_music_set_meta { };
-
$MUSIC_WANT = [];
@MUSIC_JINGLE = ();
%AUDIO_PLAY = ();
@@ -776,6 +769,27 @@
on_changed => sub { my ($self, $value) = @_; $CFG->{fullscreen} = $value; 0 }
);
+ $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Force OpenGL 1.1");
+ $table->add_at (1, $row++, new CFPlus::UI::CheckBox
+ state => $CFG->{force_opengl11},
+ tooltip => "Limit CFPlus to use OpenGL 1.1 features only. This will normally result in "
+ . "higher memory usage and slower performance. It will, however, help tremendously on "
+ . "cards that claim to support a feature but fall back to software rendering. "
+ . "Nvidia Geforce FX cards are known to claim features the hardware doesn't support, "
+ . "but cards and drivers from other vendors (ATI) are often just as bad. If you "
+ . "experience extremely low framerates and your card should do better, try this option.",
+ on_changed => sub { my ($self, $value) = @_; $CFG->{force_opengl11} = $value; 0 }
+ );
+
+ $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Compress Textures");
+ $table->add_at (1, $row++, new CFPlus::UI::CheckBox
+ state => $CFG->{texture_compression},
+ tooltip => "Use texture compression. Normally this will not reduce visual quality noticable but "
+ . "will save a lot of memory and increase performance. The compression algorithm "
+ . "can differ form card to card, so your mileage may vary.",
+ on_changed => sub { my ($self, $value) = @_; $CFG->{texture_compression} = $value; 0 }
+ );
+
$table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fast & Ugly");
$table->add_at (1, $row++, new CFPlus::UI::CheckBox
state => $CFG->{fast},
@@ -811,8 +825,8 @@
$table->add_at (1, $row++, new CFPlus::UI::CheckBox
state => $CFG->{map_smoothing},
tooltip => "Map Smoothing tries to make tile borders less square. "
- . "This increases load on the graphics subsystem and works only with 2.x servers. "
- . "Changes take effect at next connection only.",
+ . "This increases load on the graphics subsystem and works only with TRT servers. "
+ . "Changes take effect at next login only.",
on_changed => sub { my ($self, $value) = @_; $CFG->{map_smoothing} = $value; 0 }
);
@@ -833,7 +847,8 @@
$table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Message Fontsize");
$table->add_at (1, $row++, new CFPlus::UI::Slider
range => [$CFG->{log_fontsize}, 0.5, 2, 0, 0.1],
- tooltip => "The font size used by the message/server log window only. Changes are instant.",
+ tooltip => "The font size used by the message/server log window only. Changes are instant, "
+ . "but you still need to press apply to correctly re-layout the widget.",
on_changed => sub { $MESSAGE_WINDOW->set_fontsize ($CFG->{log_fontsize} = $_[1]); 0 },
);
@@ -880,16 +895,20 @@
# $CFG->{effects_volume} = $_[1];
# });
- $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Effects Volume");
+ $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Sound Effects");
$table->add_at (1, $row, new CFPlus::UI::CheckBox
expand => 1, state => $CFG->{effects_enable},
tooltip => "If enabled, sound effects are enabled. If disabled, no sound effects will be played.",
- on_changed => sub { $CFG->{effects_enable} = $_[1]; 0 }
+ on_changed => sub {
+ $CFG->{effects_enable} = $_[1];
+ $CONN->update_fx_want if $CONN;
+ 0
+ }
);
$table->add_at (2, $row++, new CFPlus::UI::Slider
expand => 1, range => [$CFG->{effects_volume}, 0, 1, 0, 1/128],
tooltip => "The relative volume of sound effects. Best audio quality is achieved if this "
- . "is set highest and you use your operating system volume setting. Changes are instant.",
+ . "is set highest (rightmost) and you use your operating system volume setting. Changes are instant.",
on_changed => sub { $CFG->{effects_volume} = $_[1]; 0 }
);
@@ -897,7 +916,11 @@
$table->add_at (1, $row, new CFPlus::UI::CheckBox
expand => 1, state => $CFG->{bgm_enable},
tooltip => "If enabled, playing of background music is enabled. If disabled, no background music will be played.",
- on_changed => sub { $CFG->{bgm_enable} = $_[1]; 0 }
+ on_changed => sub {
+ $CFG->{bgm_enable} = $_[1];
+ $CONN->update_fx_want if $CONN;
+ 0
+ }
);
$table->add_at (2, $row++, new CFPlus::UI::Slider
expand => 1, range => [$CFG->{bgm_volume}, 0, 1, 0, 1/128],
@@ -1596,7 +1619,7 @@
$hb->add (my $vb2 = new CFPlus::UI::VBox);
- $vb2->add ($INV_RIGHT_HB = new CFPlus::UI::HBox);
+ $vb2->add ($INVR_HB = new CFPlus::UI::HBox);
$vb2->add (my $sw2 = new CFPlus::UI::ScrolledWindow expand => 1, scroll_y => 1);
$sw2->add ($INVR = new CFPlus::UI::Inventory);
@@ -1612,18 +1635,41 @@
$vb->add (new CFPlus::UI::FancyFrame
label => "Currently playing music",
- child => ($MUSIC_PLAYING_WIDGET = new CFPlus::UI::Label ellipsise => 0),
+ child => new CFPlus::UI::ScrolledWindow scroll_x => 1, scroll_y => 0,
+ child => ($MUSIC_PLAYING_WIDGET = new CFPlus::UI::Label ellipsise => 0, fontsize => 0.8),
);
$vb->add (new CFPlus::UI::FancyFrame
- label => "Other media used in this session",
- child => ($LICENSE_WIDGET = new CFPlus::UI::TextScroller
+ label => "Other media used in this session",
+ expand => 1,
+ child => ($LICENSE_WIDGET = new CFPlus::UI::TextScroller
expand => 1, fontsize => 0.8, padding_x => 4, padding_y => 4),
);
$vb
}
+sub add_license {
+ my ($meta) = @_;
+
+ $meta = $meta->{meta}
+ or return;
+
+ $meta->{license} || $meta->{author} || $meta->{source}
+ or return;
+
+ $LICENSE_WIDGET->add_paragraph ({
+ fg => [1, 1, 1, 1],
+ markup => ""
+ . "Name: " . (CFPlus::asxml $meta->{name}) . "\n"
+ . "Author: " . (CFPlus::asxml $meta->{author}) . "\n"
+ . "Source: " . (CFPlus::asxml $meta->{source}) . "\n"
+ . "License: " . (CFPlus::asxml $meta->{license}) . "\n"
+ . "",
+ });
+ $LICENSE_WIDGET->scroll_to_bottom;
+}
+
sub toggle_player_page {
my ($widget) = @_;
@@ -1838,7 +1884,7 @@
$hb->add (new CFPlus::UI::Button
text => "Quit anyway",
expand => 1,
- on_activate => sub { exit },
+ on_activate => sub { Event::unloop_all },
);
}
@@ -2042,7 +2088,7 @@
if ($CONN) {
open_quit_dialog;
} else {
- exit;
+ Event::unloop_all;
}
0
},
@@ -2050,6 +2096,7 @@
$BUTTONBAR->show;
$SETUP_DIALOG->show;
+ $MESSAGE_WINDOW->show;
}
$STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]);
@@ -2067,19 +2114,20 @@
my $fps = 9;
sub force_refresh {
- $fps = $fps * 0.95 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.05;
- debug sprintf "%3.2f", $fps if $ENV{CFPLUS_DEBUG} & 4;
+ if ($ENV{CFPLUS_DEBUG} & 4) {
+ $fps = $fps * 0.98 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.02;
+ debug sprintf "%3.2f", $fps;
+ }
$CFPlus::UI::ROOT->draw;
-
- $WANT_REFRESH = 0;
- $CAN_REFRESH = 0;
- $LAST_REFRESH = $NOW;
-
CFPlus::SDL_GL_SwapBuffers;
+ $LAST_REFRESH = $NOW;
+ $WANT_REFRESH->stop;
}
-my $refresh_watcher = Event->timer (after => 0, hard => 0, interval => 1 / $MAX_FPS, cb => sub {
+$WANT_REFRESH = Event->idle (min => 0.001, max => 0.06, parked => 1, cb => \&force_refresh);
+
+my $input = Event->timer (after => 0, hard => 0, interval => 1 / 50, cb => sub {
$NOW = time;
($SDL_CB{$_->{type}} || sub { warn "unhandled event $_->{type}" })->($_)
@@ -2087,13 +2135,7 @@
if (%animate_object) {
$_->animate ($LAST_REFRESH - $NOW) for values %animate_object;
- ++$WANT_REFRESH;
- }
-
- if ($WANT_REFRESH) {
- force_refresh;
- } else {
- $CAN_REFRESH = 1;
+ $WANT_REFRESH->start;
}
});
@@ -2158,32 +2200,34 @@
CFPlus::UI::set_layout ($::CFG->{layout});
my %DEF_CFG = (
- sdl_mode => 0,
- fullscreen => 0,
- fast => 0,
- map_scale => 1,
- fow_enable => 1,
- fow_intensity => 0,
- map_smoothing => 1,
- gui_fontsize => 1,
- log_fontsize => 0.7,
- gauge_fontsize => 1,
- gauge_size => 0.35,
- stat_fontsize => 0.7,
- mapsize => 100,
- audio_enable => 1,
- effects_enable => 1,
- effects_volume => 1,
- bgm_enable => 1,
- bgm_volume => 0.5,
- output_sync => 1,
- output_count => 1,
- output_rate => "",
- pickup => 0,
- inv_sort => "mtime",
- default => "profile", # default profile
- show_tips => 1,
- logview_max_par => 1000,
+ sdl_mode => 0,
+ fullscreen => 0,
+ fast => 0,
+ force_opengl11 => undef,
+ texture_compression => 1,
+ map_scale => 1,
+ fow_enable => 1,
+ fow_intensity => 0,
+ map_smoothing => 1,
+ gui_fontsize => 1,
+ log_fontsize => 0.7,
+ gauge_fontsize => 1,
+ gauge_size => 0.35,
+ stat_fontsize => 0.7,
+ mapsize => 100,
+ audio_enable => 1,
+ effects_enable => 1,
+ effects_volume => 1,
+ bgm_enable => 1,
+ bgm_volume => 0.5,
+ output_sync => 1,
+ output_count => 1,
+ output_rate => "",
+ pickup => 0,
+ inv_sort => "mtime",
+ default => "profile", # default profile
+ show_tips => 1,
+ logview_max_par => 1000,
);
while (my ($k, $v) = each %DEF_CFG) {
@@ -2259,17 +2303,15 @@
show_tip_of_the_day if $CFG->{show_tips};
Event::loop;
-#CFPlus::SDL_Quit;
-#CFPlus::_exit 0;
-END {
- CFPlus::SDL_Quit;
- CFPlus::DB::Server::stop;
-}
+#video_shutdown;
+#audio_shutdown;
+CFPlus::SDL_Quit;
+CFPlus::DB::Server::stop;
=head1 NAME
-cfplus - A Crossfire+ and Crossfire game client
+cfplus - A Crossfire TRT and Crossfire game client
=head1 SYNOPSIS
@@ -2277,8 +2319,8 @@
=head1 USAGE
-cfplus utilises OpenGL for all UI elements and the game. It is supposed to be used
-fullscreen and interactively.
+cfplus utilises OpenGL for all UI elements and the game. It is supposed to
+be used in fullscreen mode and interactively.
=head1 DEBUGGING