--- deliantra/Deliantra-Client/bin/pclient 2006/04/18 21:37:48 1.138 +++ deliantra/Deliantra-Client/bin/pclient 2006/04/19 06:21:07 1.141 @@ -24,6 +24,7 @@ use CFClient; use CFClient::UI; +use CFClient::MapWidget; our $VERSION = '0.1'; @@ -112,14 +113,14 @@ sub client_setup { my $dialog = new CFClient::UI::FancyFrame child => (my $vbox = new CFClient::UI::VBox); - $vbox->add (new CFClient::UI::Label align => 0, text => "Client Setup"); + $vbox->add (new CFClient::UI::Label valign => 0, align => 0, text => "Client Setup"); $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); - $table->add (0, 0, new CFClient::UI::Label align => 1, text => "Video Mode"); + $table->add (0, 0, new CFClient::UI::Label valign => 0, align => 1, text => "Video Mode"); $table->add (1, 0, my $hbox = new CFClient::UI::HBox); $hbox->add (my $mode_slider = new CFClient::UI::Slider expand => 1, req_w => 100, range => [$CFG->{sdl_mode}, 0, scalar @SDL_MODES, 1]); - $hbox->add (my $mode_label = new CFClient::UI::Label height => $FONTSIZE * 0.8); + $hbox->add (my $mode_label = new CFClient::UI::Label valign => 0, height => 0.8); $mode_slider->connect (changed => sub { my ($self, $value) = @_; @@ -129,59 +130,72 @@ }); $mode_slider->emit (changed => $mode_slider->{range}[0]); - $table->add (0, 1, new CFClient::UI::Label align => 1, text => "Fullscreen"); + $table->add (0, 1, new CFClient::UI::Label valign => 0, align => 1, text => "Fullscreen"); $table->add (1, 1, new CFClient::UI::CheckBox state => $CFG->{fullscreen}, connect_changed => sub { my ($self, $value) = @_; $CFG->{fullscreen} = $value; }); - $table->add (0, 2, new CFClient::UI::Label align => 1, text => "Fast & Ugly"); + $table->add (0, 2, new CFClient::UI::Label valign => 0, align => 1, text => "Fast & Ugly"); $table->add (1, 2, new CFClient::UI::CheckBox state => $CFG->{fast}, connect_changed => sub { my ($self, $value) = @_; $CFG->{fast} = $value; }); - $table->add (0, 3, new CFClient::UI::Label align => 1, text => "Fog of War"); + $table->add (0, 3, new CFClient::UI::Label valign => 0, align => 1, text => "Fog of War"); $table->add (1, 3, new CFClient::UI::CheckBox state => $CFG->{fow_enable}, connect_changed => sub { my ($self, $value) = @_; $CFG->{fow_enable} = $value; }); - $table->add (0, 4, new CFClient::UI::Label align => 1, text => "FoW Intensity"); + $table->add (0, 4, new CFClient::UI::Label valign => 0, align => 1, text => "FoW Intensity"); $table->add (1, 4, new CFClient::UI::Slider range => [$CFG->{fow_intensity}, 0, 1 + 0.001, 0.001], connect_changed => sub { my ($self, $value) = @_; $CFG->{fow_intensity} = $value; }); - $table->add (0, 5, new CFClient::UI::Label align => 1, text => "FoW Smooth"); + $table->add (0, 5, new CFClient::UI::Label valign => 0, align => 1, text => "FoW Smooth"); $table->add (1, 5, new CFClient::UI::CheckBox state => $CFG->{fow_smooth}, connect_changed => sub { my ($self, $value) = @_; $CFG->{fow_smooth} = $value; status "Fog of War smoothing requires OpenGL 1.2 or higher" if $CFClient::GL_VERSION < 1.2; }); - $table->add (0, 6, new CFClient::UI::Label align => 1, text => "Log Fontsize"); - $table->add (1, 6, new CFClient::UI::Slider range => [$CFG->{log_fontsize}, 8, 30, 1], connect_changed => sub { - my ($self, $value) = @_; - $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = int $value); + $table->add (0, 6, new CFClient::UI::Label valign => 0, align => 1, text => "GUI Fontsize"); + $table->add (1, 6, new CFClient::UI::Slider range => [$CFG->{gui_fontsize}, 0.7, 1.7, 0.1], connect_changed => sub { + $CFG->{gui_fontsize} = 0.1 * int $_[1] * 10; +# $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize}; + }); + + $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Server Log Fontsize"); + $table->add (1, 7, new CFClient::UI::Slider range => [$CFG->{log_fontsize}, 0.7, 1.7, 0.1], connect_changed => sub { + $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = 0.1 * int $_[1] * 10); }); - $table->add (1, 7, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { + $table->add (1, 8, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { video_shutdown (); video_init (); }); - $table->add (0, 8, new CFClient::UI::Label align => 1, text => "Sound"); - $table->add (1, 8, new CFClient::UI::CheckBox state => $CFG->{sound}, connect_changed => sub { - my ($self, $value) = @_; - $CFG->{sound} = $value; + $table->add (0, 9, new CFClient::UI::Label valign => 0, align => 1, text => "Audio Enable"); + $table->add (1, 9, new CFClient::UI::CheckBox state => $CFG->{audio_enable}, connect_changed => sub { + $CFG->{audio_enable} = $_[1]; + }); +# $table->add (0, 9, new CFClient::UI::Label valign => 0, align => 1, text => "Effects Volume"); +# $table->add (1, 8, new CFClient::UI::Slider range => [$CFG->{effects_volume}, 0, 128, 1], connect_changed => sub { +# $CFG->{effects_volume} = $_[1]; +# }); + $table->add (0, 10, new CFClient::UI::Label valign => 0, align => 1, text => "Background Music"); + $table->add (1, 10, my $hbox = new CFClient::UI::HBox); + $hbox->add (new CFClient::UI::CheckBox expand => 1, state => $CFG->{bgm_enable}, connect_changed => sub { + $CFG->{bgm_enable} = $_[1]; + }); + $hbox->add (new CFClient::UI::Slider expand => 1, range => [$CFG->{bgm_volume}, 0, 128, 1], connect_changed => sub { + $CFG->{bgm_volume} = $_[1]; + $SDL_MIXER->music_volume ($_[1]); }); - $table->add (0, 9, new CFClient::UI::Label align => 1, text => "Bg. Music"); - $table->add (1, 9, new CFClient::UI::CheckBox state => $CFG->{bg_music_enable}, connect_changed => sub { - my ($self, $value) = @_; - $CFG->{bg_music_enable} = $value; - }); - $table->add (1, 10, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { + + $table->add (1, 11, new CFClient::UI::Button expand => 1, align => 0, text => "Apply", connect_activate => sub { audio_shutdown (); audio_init (); }); @@ -257,7 +271,7 @@ (new CFClient::UI::Empty expand => 1), ]); - $table->add ($_ + 1, $y, new CFClient::UI::Label align => $align[$_], text => $m->[$_], fontsize => $FONTSIZE * 0.8) + $table->add ($_ + 1, $y, new CFClient::UI::Label align => $align[$_], text => $m->[$_], fontsize => 0.8) for 0 .. $#$m; } } @@ -268,44 +282,44 @@ my $dialog = new CFClient::UI::FancyFrame child => (my $vbox = new CFClient::UI::VBox); - $vbox->add (new CFClient::UI::Label align => 0, text => "Server Setup"); + $vbox->add (new CFClient::UI::Label valign => 0, align => 0, text => "Server Setup"); $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); - $table->add (0, 2, new CFClient::UI::Label align => 1, text => "Host:Port"); + $table->add (0, 2, new CFClient::UI::Label valign => 0, align => 1, text => "Host:Port"); { $table->add (1, 2, my $vbox = new CFClient::UI::VBox); - $vbox->add (my $HOST = new CFClient::UI::Entry text => $CFG->{host}, connect_changed => sub { + $vbox->add (my $HOST = new CFClient::UI::Entry expand => 1, text => $CFG->{host}, connect_changed => sub { my ($self, $value) = @_; $CFG->{host} = $value; }); $METASERVER = metaserver_dialog; - $vbox->add (new CFClient::UI::Flopper text => "Metaserver", other => $METASERVER, connect_open => sub { + $vbox->add (new CFClient::UI::Flopper expand => 1, text => "Metaserver", other => $METASERVER, connect_open => sub { update_metaserver $HOST; }); } - $table->add (0, 4, new CFClient::UI::Label align => 1, text => "Username"); + $table->add (0, 4, new CFClient::UI::Label valign => 0, align => 1, text => "Username"); $table->add (1, 4, new CFClient::UI::Entry text => $CFG->{user}, connect_changed => sub { my ($self, $value) = @_; $CFG->{user} = $value; }); - $table->add (0, 5, new CFClient::UI::Label align => 1, text => "Password"); + $table->add (0, 5, new CFClient::UI::Label valign => 0, align => 1, text => "Password"); $table->add (1, 5, new CFClient::UI::Entry text => $CFG->{password}, hidden => 1, connect_changed => sub { my ($self, $value) = @_; $CFG->{password} = $value; }); - $table->add (0, 6, new CFClient::UI::Label align => 1, text => "Def. say cmd"); + $table->add (0, 6, new CFClient::UI::Label valign => 0, align => 1, text => "Def. say cmd"); $table->add (1, 6, my $saycmd = new CFClient::UI::Entry text => $CFG->{say_command}, connect_changed => sub { my ($self, $value) = @_; $CFG->{say_command} = $value; }); - $table->add (0, 7, new CFClient::UI::Label align => 1, text => "Map Size"); + $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size"); $table->add (1, 7, new CFClient::UI::Slider req_w => 100, range => [$CFG->{mapsize}, 10, 100 + 1, 1], @@ -418,26 +432,26 @@ CFClient::gl_init; - $FONTSIZE = int $HEIGHT / 40; + $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize}; ############################################################################# $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100; - $CFClient::UI::ROOT->add ($DEBUG_STATUS); + $DEBUG_STATUS->show; $STATUS_LINE = new CFClient::UI::Label padding => 0, - y => $HEIGHT * 44 / 45 - $FONTSIZE; - $CFClient::UI::ROOT->add ($STATUS_LINE); + y => $HEIGHT - $FONTSIZE * 1.8; + $STATUS_LINE->show; $ALT_ENTER_MESSAGE = new CFClient::UI::Label padding => 0, - y => $HEIGHT * 44 / 45, - fontsize => $HEIGHT / 45, + fontsize => 0.8, markup => "Use Alt-Enter to toggle fullscreen mode"; - $CFClient::UI::ROOT->add ($ALT_ENTER_MESSAGE); + $ALT_ENTER_MESSAGE->show; + $ALT_ENTER_MESSAGE->move (0, $HEIGHT - $ALT_ENTER_MESSAGE->{h}); - $CFClient::UI::ROOT->add ($MAPWIDGET = new CFClient::UI::MapWidget); + $CFClient::UI::ROOT->add ($MAPWIDGET = new CFClient::MapWidget); $MAPWIDGET->focus_in; $MAPWIDGET->connect (activate_console => sub { my ($mapwidget, $preset) = @_; @@ -486,14 +500,16 @@ my $bgmusic;#TODO#hack#d# sub audio_init { - if ($CFG->{sound} || 1) { + if ($CFG->{audio_enable}) { if (open my $fh, "<:utf8", CFClient::find_rcfile "sounds/config") { $SDL_MIXER = new SDL::Mixer; $SDL_MIXER->allocate_channels (8); - if ($CFG->{bg_music_enable}) { + # TODO: hack, do play loop and mood music + if ($CFG->{bgm_enable}) { $bgmusic = new SDL::Music CFClient::find_rcfile "music/game3.ogg"; $SDL_MIXER->play_music ($bgmusic, -1); + $SDL_MIXER->music_volume ($CFG->{bgm_volume}); } while (<$fh>) { @@ -775,6 +791,9 @@ sub conn::sound_play { my ($self, $x, $y, $soundnum, $type) = @_; + $SDL_MIXER + or return; + my $chunk = $AUDIO_CHUNKS{$SOUNDS[$soundnum]} or return; @@ -865,12 +884,14 @@ fow_enable => 1, fow_intensity => 0.45, fow_smooth => 0, + gui_fontsize => 1, log_fontsize => 14, mapsize => 100, host => "crossfire.schmorp.de", say_command => 'say', - sound => 1, - bg_music_enable => 1, + audio_enable => 1, + bgm_enable => 1, + bgm_volume => 64, ); while (my ($k, $v) = each %DEF_CFG) {