--- deliantra/Deliantra-Client/bin/cfplus 2007/08/21 02:39:17 1.220 +++ deliantra/Deliantra-Client/bin/cfplus 2007/08/30 07:57:59 1.224 @@ -128,6 +128,7 @@ our $MAP; our $MAPMAP; our $MAPWIDGET; +our $COMPLETER; our $BUTTONBAR; our $METASERVER; our $LOGIN_BUTTON; @@ -148,6 +149,7 @@ our $MUSIC_PLAYING_WIDGET; our $LICENSE_WIDGET; +our $PICKUP_PAGE; our $INVENTORY_PAGE; our $STATS_PAGE; our $SKILL_PAGE; @@ -315,7 +317,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 +345,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 +372,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 +388,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]; @@ -986,13 +995,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 $prg = 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"); + $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, prg => $prg, 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; @@ -1724,7 +1735,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, @@ -1975,6 +1986,7 @@ $LAST_REFRESH = time - 0.01; CFPlus::OpenGL::init; + CFPlus::Macro::init; $FONTSIZE = int $HEIGHT / 40 * $CFG->{gui_fontsize}; @@ -1985,7 +1997,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, @@ -2026,6 +2050,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", @@ -2159,7 +2188,7 @@ %SDL_CB = ( CFPlus::SDL_QUIT => sub { - exit; + Event::unloop_all; }, CFPlus::SDL_VIDEORESIZE => sub { }, @@ -2302,14 +2331,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;