--- deliantra/Deliantra-Client/bin/cfplus 2007/08/21 00:59:34 1.219
+++ deliantra/Deliantra-Client/bin/cfplus 2007/10/14 10:33:50 1.231
@@ -1,9 +1,7 @@
#!/opt/bin/perl
-my $startup_done = sub { };
-our $PANGO = "1.5.0";
-
# do splash-screen thingy on win32
+my $startup_done = sub { };
BEGIN {
if (%PAR::LibCache && $^O eq "MSWin32") {
while (my ($filename, $zip) = each %PAR::LibCache) {
@@ -32,38 +30,41 @@
if (%PAR::LibCache) {
@INC = grep ref, @INC; # weed out all paths except pars loader refs
- my $tmp = $ENV{PAR_TEMP};
+ my $root = $ENV{PAR_TEMP};
while (my ($filename, $zip) = each %PAR::LibCache) {
for ($zip->memberNames) {
next unless /^root\/(.*)/;
- $zip->extractMember ($_, "$tmp/$1")
- unless -e "$tmp/$1";
+ $zip->extractMember ($_, "$root/$1")
+ unless -e "$root/$1";
}
}
if ($^O eq "MSWin32") {
- # relocatable
+ # pango is relocatable on win32
} else {
+ open my $fh, "<:perlio", "$root/pangoversion"
+ or die "pangoversion: $!";
+ my $PANGO = <$fh>;
# unix, need to patch pango rc file
- open my $fh, "<:perlio", "$tmp/usr/lib/pango/$PANGO/module-files.d/libpango1.0-0.modules"
- or die "$tmp/usr/lib/$PANGO/module-files.d/libpango1.0-0.modules: $!";
+ open my $fh, "<:perlio", "$root/usr/lib/pango/$PANGO/module-files.d/libpango1.0-0.modules"
+ or die "$root/usr/lib/$PANGO/module-files.d/libpango1.0-0.modules: $!";
local $/;
my $rc = <$fh>;
- $rc =~ s/^\//$tmp\//gm; # replace abs paths by relative ones
+ $rc =~ s/^\//$root\//gm; # replace abs paths by relative ones
- mkdir "$tmp/pango-modules";
- open my $fh, ">:perlio", "$tmp/pango-modules/pango.modules"
- or die "$tmp/pango-modules/pango.modules: $!";
+ mkdir "$root/pango-modules";
+ open my $fh, ">:perlio", "$root/pango-modules/pango.modules"
+ or die "$root/pango-modules/pango.modules: $!";
print $fh $rc;
- $ENV{PANGO_RC_FILE} = "$tmp/pango.rc";
+ $ENV{PANGO_RC_FILE} = "$root/pango.rc";
open my $fh, ">:perlio", $ENV{PANGO_RC_FILE}
or die "$ENV{PANGO_RC_FILE}: $!";
- print $fh "[Pango]\nModuleFiles = $tmp/pango-modules\n";
+ print $fh "[Pango]\nModuleFiles = $root/pango-modules\n";
}
- unshift @INC, $tmp;
+ unshift @INC, $root;
}
}
@@ -88,7 +89,9 @@
use CFPlus::UI::Canvas;
use CFPlus::UI::Inventory;
use CFPlus::UI::SpellList;
+use CFPlus::UI::Dockable;
use CFPlus::UI::MessageWindow;
+use CFPlus::UI::ChatView;
use CFPlus::Pod;
use CFPlus::MapWidget;
use CFPlus::Macro;
@@ -128,6 +131,7 @@
our $MAP;
our $MAPMAP;
our $MAPWIDGET;
+our $COMPLETER;
our $BUTTONBAR;
our $METASERVER;
our $LOGIN_BUTTON;
@@ -140,6 +144,7 @@
our $SETUP_DIALOG;
our $SETUP_NOTEBOOK;
our $SETUP_SERVER;
+our $SETUP_LOGIN;
our $SETUP_KEYBOARD;
our $PL_NOTEBOOK;
@@ -148,6 +153,7 @@
our $MUSIC_PLAYING_WIDGET;
our $LICENSE_WIDGET;
+our $PICKUP_PAGE;
our $INVENTORY_PAGE;
our $STATS_PAGE;
our $SKILL_PAGE;
@@ -182,8 +188,7 @@
}
sub message {
- my ($para) = @_;
- $MESSAGE_WINDOW->message ($para);
+ $MESSAGE_WINDOW->message (@_);
}
#############################################################################
@@ -315,7 +320,7 @@
if ($MUSIC_PLAYING_META->{stop_time} > $NOW - $MUSIC_RESUME) {
my $pos = $MUSIC_PLAYING_META->{stop_pos};
- $MUSIC_PLAYER->fade_in_pos (0, 1000, $pos);
+ $MUSIC_PLAYER->fade_in_pos (0, 700, $pos);
$MUSIC_START = time - $pos;
} else {
$MUSIC_PLAYER->play (0);
@@ -343,12 +348,15 @@
map $CONN->{face}[$_],
@$MUSIC_WANT;
+ # randomize music a bit so that the order is not always the same
+ $_->{stop_time} ||= rand for @have;
+
@MUSIC_HAVE = @have
if @have;
# default MUSIC_HAVE == MUSIC_DEFAULT
@MUSIC_HAVE = { path => CFPlus::find_rcfile "music/$MUSIC_DEFAULT" } unless @MUSIC_HAVE;
- $fade_out = 1000;
+ $fade_out = 700;
}
# if the currently playing song is acceptable, let it continue
@@ -367,7 +375,7 @@
# if the most recently-played piece played very recently,
# resume it, else choose the oldest piece for rotation.
audio_music_set_meta
- $MUSIC_HAVE[-1]{stop_time} > $NOW - $MUSIC_RESUME
+ $MUSIC_HAVE[-1]{stop_pos} && $MUSIC_HAVE[-1]{stop_time} > $NOW - $MUSIC_RESUME
? $MUSIC_HAVE[-1]
: $MUSIC_HAVE[0];
@@ -383,6 +391,10 @@
}
sub audio_music_finished {
+ if ($MUSIC_PLAYING_META) {
+ $MUSIC_PLAYING_META->{stop_time} = time;
+ }
+
# we compress multiple jingles of the same type
shift @MUSIC_JINGLE
while @MUSIC_JINGLE && $MUSIC_PLAYING_META == $MUSIC_JINGLE[0];
@@ -399,19 +411,25 @@
sub audio_init {
if ($CFG->{audio_enable}) {
$ENV{MIX_EFFECTSMAXSPEED} = 1;
- $SDL_MIXER = !CFPlus::Mix_OpenAudio;
+ $SDL_MIXER = !CFPlus::Mix_OpenAudio
+ $CFG->{audio_hw_frequency},
+ CFPlus::MIX_DEFAULT_FORMAT,
+ $CFG->{audio_hw_channels},
+ $CFG->{audio_hw_chunksize};
- unless ($SDL_MIXER) {
+ if ($SDL_MIXER) {
+ CFPlus::Mix_AllocateChannels $CFG->{audio_mix_channels};
+
+ audio_music_finished;
+ } else {
status "Unable to open sound device: there will be no sound";
- return;
}
-
- CFPlus::Mix_AllocateChannels 16;
-
- audio_music_finished;
} else {
undef $SDL_MIXER;
}
+
+ sub audio_tab_update;
+ audio_tab_update;
}
sub audio_shutdown {
@@ -711,8 +729,8 @@
}
sub stop_game {
- $LOGIN_BUTTON->set_text ("Login");
- $SETUP_NOTEBOOK->set_current_page ($SETUP_SERVER);
+ $LOGIN_BUTTON->set_text ("Login / Register");
+ $SETUP_NOTEBOOK->set_current_page ($SETUP_LOGIN);
$SETUP_DIALOG->show;
$PL_WINDOW->hide;
$SPELL_LIST->clear_spells;
@@ -881,6 +899,29 @@
$vbox
}
+our $AUDIO_HW_CHUNKSIZE;
+our $AUDIO_INFO;
+
+sub audio_tab_update {
+ my ($freq, $format, $chans) = CFPlus::Mix_QuerySpec;
+
+ $AUDIO_HW_CHUNKSIZE->set_options ([
+ [0, "default", "Use System Default"],
+ map {
+ my $ms = sprintf "%dms", 1000 * $_ / ($CFG->{audio_hw_frequency} || 22050);
+ [$_, $ms, "$ms ($_ samples)"],
+ } 256, 512, 1024, 2048, 4096, 8192, 16384, 32768
+ ]);
+
+ my $text = !$freq
+ ? "audio is off"
+ : "audio is enabled\n"
+ . "frequency (Hz): $freq\n"
+ . "channels: $chans";
+
+ $AUDIO_INFO->set_text ($text);
+}
+
sub audio_setup {
my $vbox = new CFPlus::UI::VBox;
@@ -892,12 +933,8 @@
$table->add_at (1, $row++, new CFPlus::UI::CheckBox
state => $CFG->{audio_enable},
tooltip => "Master Audio Enable. If enabled, sound effects and music will be played. If disabled, no audio will be used and the soundcard will not be opened.",
- on_changed => sub { $CFG->{audio_enable} = $_[1]; 0 }
+ on_changed => sub { $CFG->{audio_enable} = $_[1]; 1 }
);
-# $table->add_at (0, 9, new CFPlus::UI::Label valign => 0, align => 1, text => "Effects Volume");
-# $table->add_at (1, 8, new CFPlus::UI::Slider range => [$CFG->{effects_volume}, 0, 128, 1], on_changed => sub {
-# $CFG->{effects_volume} = $_[1];
-# });
$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
@@ -906,14 +943,14 @@
on_changed => sub {
$CFG->{effects_enable} = $_[1];
$CONN->update_fx_want if $CONN;
- 0
+ 1
}
);
$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 (rightmost) and you use your operating system volume setting. Changes are instant.",
- on_changed => sub { $CFG->{effects_volume} = $_[1]; 0 }
+ on_changed => sub { $CFG->{effects_volume} = $_[1]; 1 }
);
$table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Background Music");
@@ -924,7 +961,7 @@
$CFG->{bgm_enable} = $_[1];
$CONN->update_fx_want if $CONN;
audio_music_push;
- 0
+ 1
}
);
$table->add_at (2, $row++, new CFPlus::UI::Slider
@@ -933,6 +970,73 @@
on_changed => sub { $CFG->{bgm_volume} = $_[1]; audio_music_update_volume; 0 }
);
+ $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Frequency");
+ $table->add_at (1, $row++, new CFPlus::UI::Selector
+ c_colspan => 2, expand => 1,
+ value => $CFG->{audio_hw_frequency},
+ options => [
+ [ 0, "default" , "Use System Default"],
+ [11025, "11 kHz" , "11kHz (low quality)"],
+ [22050, "22 kHz" , "22kHz (reduced quality)"],
+ [44100, "44.1 kHz", "44.1kHz (cd quality)"],
+ [48000, "48 kHz" , "48kHz (studio quality)"],
+ ],
+ tooltip => "The sampling frequency to use. Higher sounds better, but also more cpu-intensive and might cause stuttering.",
+ on_changed => sub {
+ $CFG->{audio_hw_frequency} = $_[1];
+ audio_tab_update;
+ 1
+ }
+ );
+
+ $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Channels");
+ $table->add_at (1, $row++, new CFPlus::UI::Selector
+ c_colspan => 2, expand => 1,
+ value => $CFG->{audio_hw_channels},
+ options => [
+ [0, "default" , "Use System Default"],
+ [1, "Mono" , "Mono (single channel, low quality)"],
+ [2, "Stereo" , "Stereo (dual channe, standard quality)"],
+ [4, "4 Ch Surround", "4 Channel Surround Sound (3d sound, high quality)"],
+ [6, "6 Ch Surround", "6 Channel Surround Sound (3d sound + center + lfe)"],
+ ],
+ tooltip => "The number of independent sound channels to use. Higher sounds better, but also more cpu-intensive and might cause stuttering.",
+ on_changed => sub {
+ $CFG->{audio_hw_channels} = $_[1];
+ audio_tab_update;
+ 1
+ }
+ );
+
+ $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Latency");
+ $table->add_at (1, $row++, $AUDIO_HW_CHUNKSIZE = new CFPlus::UI::Selector
+ c_colspan => 2, expand => 1,
+ value => $CFG->{audio_hw_chunksize},
+ tooltip => "The guarenteed latency. Lower is better, but also more cpu-intensive and might cause stuttering. If music playback "
+ . "is stuttering, increase this value. Values of 50-100ms are optimal.",
+ on_changed => sub {
+ $CFG->{audio_hw_chunksize} = $_[1];
+ audio_tab_update;
+ 1
+ }
+ );
+
+ # should really be a slider
+ $table->add_at (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Mixer Voices");
+ $table->add_at (1, $row++, new CFPlus::UI::ValSlider
+ c_colspan => 2, expand => 1,
+ tooltip => "The number of simultaneous sound effects possible. Higher is better, but also more cpu-intensive and might cause stuttering.",
+ range => [$::CFG->{audio_mix_channels}, 4, 32, 0, 1],
+ template => ">= 99",
+ on_changed => sub {
+ my ($slider, $value) = @_;
+
+ $CFG->{audio_mix_channels} = $value
+ if $value;
+ 1;
+ }
+ );
+
$table->add_at (1, $row++, new CFPlus::UI::Button
c_colspan => 2, expand => 1, align => 0, text => "Apply",
tooltip => "Apply the audio settings",
@@ -943,6 +1047,14 @@
}
);
+ $vbox->add (new CFPlus::UI::FancyFrame
+ expand => 1,
+ label => "Audio Info",
+ child => ($AUDIO_INFO = new CFPlus::UI::Label ellipsise => 0),
+ );
+
+ audio_tab_update;
+
$vbox
}
@@ -986,12 +1098,15 @@
$hb->add (my $gg = new CFPlus::UI::Gauge type => 'grace', tooltip => "#stat_grace");
$hb->add (my $fg = new CFPlus::UI::Gauge type => 'food', tooltip => "#stat_food");
- $vbox->add (my $exp = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_exp");
- $vbox->add (my $rng = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_ranged");
+ $vbox->add (my $exp = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_exp");
+ $vbox->add (my $prg = new CFPlus::UI::ExperienceProgress);
+ $vbox->add (my $sklprg = new CFPlus::UI::ExperienceProgress);
+ $vbox->add (my $rng = new CFPlus::UI::Label valign => 0, align => 1, can_hover => 1, can_events => 1, tooltip => "#stat_ranged");
$GAUGES = {
- exp => $exp, win => $win, range => $rng,
- food => $fg, mana => $mg, hp => $hg, grace => $gg
+ exp => $exp, prg => $prg, sklprg => $sklprg,
+ win => $win, range => $rng,
+ hp => $hg, mana => $mg, grace => $gg, food => $fg,
};
&set_gauge_window_fontsize;
@@ -1202,7 +1317,9 @@
sub skill_window {
my $sw = new CFPlus::UI::ScrolledWindow (expand => 1);
- $sw->add ($STATWIDS->{skill_tbl} = new CFPlus::UI::Table expand => 1, col_expand => [0, 0, 1, 0, 0, 1]);
+
+ $sw->add ($STATWIDS->{skill_tbl} = new CFPlus::UI::Table expand => 1, col_expand => [0, 0, 1, .1, 0, 0, 1, .1]);
+
$sw
}
@@ -1333,11 +1450,11 @@
$dialog
}
-sub server_setup {
+sub login_setup {
my $vbox = new CFPlus::UI::VBox;
$vbox->add (new CFPlus::UI::FancyFrame
- label => "Connection Settings",
+ label => "Login Settings",
child => (my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 1]),
);
$table->add_at (0, 2, new CFPlus::UI::Label valign => 0, align => 1, text => "Host:Port");
@@ -1382,8 +1499,31 @@
on_changed => sub { my ($self, $value) = @_; $CFG->{profile}{default}{password} = $value; 1 }
);
- $table->add_at (0, 7, new CFPlus::UI::Label valign => 0, align => 1, text => "Map Size");
- $table->add_at (1, 7, new CFPlus::UI::Slider
+ $table->add_at (1, 11, $LOGIN_BUTTON = new CFPlus::UI::Button
+ expand => 1,
+ align => 0,
+ text => "Login / Register",
+ tooltip => "This button will either login to the account configured above or register a new account.",
+ on_activate => sub {
+ $CONN ? stop_game
+ : start_game;
+ 1
+ },
+ );
+
+ $vbox
+}
+
+sub server_setup {
+ my $vbox = new CFPlus::UI::VBox;
+
+ $vbox->add (new CFPlus::UI::FancyFrame
+ label => "Connection Settings",
+ child => (my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 1]),
+ );
+
+ $table->add_at (0, 1, new CFPlus::UI::Label valign => 0, align => 1, text => "Map Size");
+ $table->add_at (1, 1, new CFPlus::UI::Slider
force_w => 100,
range => [$CFG->{mapsize}, 10, 100, 0, 1],
tooltip => "This is the size of the portion of the map update the server sends you. "
@@ -1393,8 +1533,8 @@
on_changed => sub { my ($self, $value) = @_; $CFG->{mapsize} = $self->{range}[0] = $value = int $value; 1 },
);
- $table->add_at (0, 8, new CFPlus::UI::Label valign => 0, align => 1, text => "Output-Rate");
- $table->add_at (1, 8, new CFPlus::UI::Entry
+ $table->add_at (0, 2, new CFPlus::UI::Label valign => 0, align => 1, text => "Output-Rate");
+ $table->add_at (1, 2, new CFPlus::UI::Entry
text => $CFG->{output_rate},
tooltip => "The maximum bandwidth in bytes per second that the server should not exceed "
. "when sending data. When 0 or unset, the server "
@@ -1403,31 +1543,20 @@
on_changed => sub { $CFG->{output_rate} = $_[1]; 1 },
);
- $table->add_at (0, 9, new CFPlus::UI::Label valign => 0, align => 1, text => "Output-Count");
- $table->add_at (1, 9, new CFPlus::UI::Entry
+ $table->add_at (0, 3, new CFPlus::UI::Label valign => 0, align => 1, text => "Output-Count");
+ $table->add_at (1, 3, new CFPlus::UI::Entry
text => $CFG->{output_count},
tooltip => "Should be set to 1 unless you know what you are doing. This option is only used once at log-in.",
on_changed => sub { $CFG->{output_count} = $_[1]; 1 },
);
- $table->add_at (0, 10, new CFPlus::UI::Label valign => 0, align => 1, text => "Output-Sync");
- $table->add_at (1, 10, new CFPlus::UI::Entry
+ $table->add_at (0, 4, new CFPlus::UI::Label valign => 0, align => 1, text => "Output-Sync");
+ $table->add_at (1, 4, new CFPlus::UI::Entry
text => $CFG->{output_sync},
tooltip => "Should be set to 1 unless you know what you are doing. This option is only used once at log-in.",
on_changed => sub { $CFG->{output_sync} = $_[1]; 1 },
);
- $table->add_at (1, 11, $LOGIN_BUTTON = new CFPlus::UI::Button
- expand => 1,
- align => 0,
- text => "Login",
- on_activate => sub {
- $CONN ? stop_game
- : start_game;
- 1
- },
- );
-
$vbox->add (new CFPlus::UI::FancyFrame
label => "Server Info",
child => ($SERVER_INFO = new CFPlus::UI::Label ellipsise => 0),
@@ -1721,7 +1850,7 @@
"Toggles the inventory window, where you can manage your loot (or treasures :). "
. "You can also hit the Tab-key to show/hide the Inventory."
);
- $ntb->add_tab (Pickup => autopickup_setup,
+ $ntb->add_tab (Pickup => $PICKUP_PAGE = autopickup_setup,
"Configure autopickup settings, i.e. which items you will pick up automatically when walking (or running) over them.");
$ntb->add_tab (Media => media_window,
@@ -1972,6 +2101,7 @@
$LAST_REFRESH = time - 0.01;
CFPlus::OpenGL::init;
+ CFPlus::Macro::init;
$FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize};
@@ -1982,7 +2112,19 @@
if ($DEBUG_STATUS) {
CFPlus::UI::rescale_widgets $WIDTH / $old_w, $HEIGHT / $old_h;
} else {
- # create the widgets
+ # create/configure the widgets
+
+ $CFPlus::UI::ROOT->connect (key_down => sub {
+ my (undef, $ev) = @_;
+
+ if (my @macros = CFPlus::Macro::find $ev) {
+ CFPlus::Macro::execute $_ for @macros;
+
+ return 1;
+ }
+
+ 0
+ });
$DEBUG_STATUS = new CFPlus::UI::Label
padding => 0,
@@ -2023,6 +2165,11 @@
$MAPWIDGET->show;
$MAPWIDGET->grab_focus;
+ $COMPLETER = new CFPlus::MapWidget::Command::
+ command => { },
+ tooltip => "#completer_help",
+ ;
+
$SETUP_DIALOG = new CFPlus::UI::Toplevel
title => "Setup",
name => "setup_dialog",
@@ -2040,8 +2187,10 @@
$SETUP_DIALOG->add ($SETUP_NOTEBOOK = new CFPlus::UI::Notebook expand => 1, debug => 1,
filter => new CFPlus::UI::ScrolledWindow expand => 1, scroll_y => 1);
+ $SETUP_NOTEBOOK->add_tab (Login => $SETUP_LOGIN = login_setup,
+ "Configure the server to play on, your username and password.");
$SETUP_NOTEBOOK->add_tab (Server => $SETUP_SERVER = server_setup,
- "Configure the server to play on, your username, password and other server-related options.");
+ "Configure other server related options.");
$SETUP_NOTEBOOK->add_tab (Client => client_setup,
"Configure various client-specific settings.");
$SETUP_NOTEBOOK->add_tab (Graphics => graphics_setup,
@@ -2156,7 +2305,7 @@
%SDL_CB = (
CFPlus::SDL_QUIT => sub {
- exit;
+ Event::unloop_all;
},
CFPlus::SDL_VIDEORESIZE => sub {
},
@@ -2221,6 +2370,10 @@
stat_fontsize => 0.7,
mapsize => 100,
audio_enable => 1,
+ audio_hw_channels => 0,
+ audio_hw_frequency => 0,
+ audio_hw_chunksize => 0,
+ audio_mix_channels => 8,
effects_enable => 1,
effects_volume => 1,
bgm_enable => 1,
@@ -2299,14 +2452,17 @@
# warn $t2-$t1;
# }
- $startup_done->();
-
video_init;
audio_init;
}
show_tip_of_the_day if $CFG->{show_tips};
+Event->idle (cb => sub {
+ $_[0]->w->cancel;
+ $startup_done->();
+});
+
Event::loop;
#video_shutdown;