--- deliantra/Deliantra-Client/bin/cfplus 2006/12/08 14:59:54 1.136 +++ deliantra/Deliantra-Client/bin/cfplus 2006/12/16 17:33:26 1.141 @@ -61,14 +61,16 @@ use CFPlus::OpenGL (); use CFPlus::Protocol; use CFPlus::UI; +use CFPlus::UI::Inventory; +use CFPlus::UI::SpellList; use CFPlus::Pod; -use CFPlus::BindingEditor; use CFPlus::MapWidget; +use CFPlus::Macro; $SIG{QUIT} = sub { Carp::cluck "QUIT" }; $SIG{PIPE} = 'IGNORE'; -$Event::Eval = 0; +$Event::Eval = 1; $Event::DIED = sub { CFPlus::fatal Carp::longmess $_[1] }; @@ -147,9 +149,6 @@ our $INVR; our $INV_RIGHT_HB; -our $BIND_EDITOR; -our $BIND_UPD_CB; - our $PICKUP_CFG; our $IN_BUILD_MODE; @@ -179,10 +178,28 @@ if $_[0]{query_dialog}; } +# FIXME: a very ugly hack to wait for stat update look below! #d# +our $QUERY_TIMER; #d# + # server query dialog sub server_query { my ($conn, $flags, $prompt) = @_; + # FIXME: a very ugly hack to wait for stat update #d# + if ($prompt =~ /roll new stats/ and not $conn->{stat_change_with}) { + unless ($QUERY_TIMER) { + $QUERY_TIMER = + Event->timer ( + after => 1, + cb => sub { + server_query ($conn, $flags, $prompt, 1); + $QUERY_TIMER = undef + } + ); + return; + } + } + $conn->{query_dialog} = my $dialog = new CFPlus::UI::Toplevel x => "center", y => "center", @@ -380,8 +397,6 @@ $LOGIN_BUTTON->set_text ("Logout"); $SETUP_DIALOG->hide; - $PROFILE = $CFG->{profile}{default}; - my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; my ($host, $port) = split /:/, $PROFILE->{host}; @@ -1384,123 +1399,8 @@ $plwin } -sub update_bindings { - $BIND_UPD_CB->() if $BIND_UPD_CB; -} - sub keyboard_setup { - my $binding_list = new CFPlus::UI::VBox; - - my $refresh; - $refresh = $BIND_UPD_CB = sub { - $binding_list->clear (); - - return unless $PROFILE; - - for my $mod (keys %{$PROFILE->{bindings}}) { - for my $sym (keys %{$PROFILE->{bindings}{$mod}}) { - my $cmds = $PROFILE->{bindings}{$mod}{$sym}; - next unless ref $cmds eq 'ARRAY' and @$cmds > 0; - - my $lbl = join "; ", @$cmds; - my $nam = CFPlus::BindingEditor::keycombo_to_name ($mod, $sym); - $binding_list->add (my $hb = new CFPlus::UI::HBox); - $hb->add (new CFPlus::UI::Button - text => "delete", - tooltip => "Deletes the binding", - on_activate => sub { - $binding_list->remove ($hb); - delete $PROFILE->{bindings}{$mod}{$sym}; - 0 - }); - - $hb->add (new CFPlus::UI::Button - text => "edit", - tooltip => "Edits the binding", - on_activate => sub { - $::BIND_EDITOR->set_binding ( - $mod, $sym, $PROFILE->{bindings}{$mod}{$sym}, - sub { - my ($nmod, $nsym, $ncmds) = @_; - $::BIND_EDITOR->cfg_unbind ($mod, $sym); - $::BIND_EDITOR->cfg_bind ($nmod, $nsym, $ncmds); - $refresh->(); - $SETUP_NOTEBOOK->set_current_page ($SETUP_KEYBOARD); - $SETUP_DIALOG->show; - }, - sub { - $SETUP_NOTEBOOK->set_current_page ($SETUP_KEYBOARD); - $SETUP_DIALOG->show; - }); - $::BIND_EDITOR->show; - $SETUP_DIALOG->hide; - 0 - }); - - $hb->add (new CFPlus::UI::Label text => "(Key: $nam)"); - $hb->add (new CFPlus::UI::Label text => $lbl, expand => 1); - } - } - }; - - my $vb = new CFPlus::UI::VBox; - $vb->add (new CFPlus::UI::FancyFrame - label => "Options", - child => (my $hb = new CFPlus::UI::HBox), - ); - $hb->add (new CFPlus::UI::Label text => "only shift-up stops fire"); - $hb->add (new CFPlus::UI::CheckBox - expand => 1, - state => $CFG->{shift_fire_stop}, - tooltip => "If this checkbox is enabled you will stop fire only if you stop pressing shift", - on_changed => sub { - my ($cbox, $value) = @_; - $CFG->{shift_fire_stop} = $value; - 0 - }); - - $vb->add (new CFPlus::UI::FancyFrame - label => "Bindings", - child => $binding_list); - $vb->add (my $hb = new CFPlus::UI::HBox); - - $hb->add (new CFPlus::UI::Button - text => "record new", - expand => 1, - tooltip => "This button opens the binding editor with an empty binding.", - on_activate => sub { - $::BIND_EDITOR->set_binding (undef, undef, [], - sub { - my ($mod, $sym, $cmds) = @_; - $::BIND_EDITOR->cfg_bind ($mod, $sym, $cmds); - $refresh->(); - $SETUP_NOTEBOOK->set_current_page ($SETUP_KEYBOARD); - $SETUP_DIALOG->show; - }, - sub { - $SETUP_NOTEBOOK->set_current_page ($SETUP_KEYBOARD); - $SETUP_DIALOG->show; - }, - ); - $SETUP_DIALOG->hide; - $::BIND_EDITOR->show; - 0 - }, - ); - - $hb->add (new CFPlus::UI::Button - text => "close", - tooltip => "Closes the binding window", - expand => 1, - on_activate => sub { - $SETUP_DIALOG->hide; - 0 - } - ); - - $refresh->(); - - $vb + CFPlus::Macro::keyboard_setup } sub help_window { @@ -1695,16 +1595,16 @@ expand => 1, fontsize => 0.8, padding_x => 4, padding_y => 4); $viewer->add_paragraph (CFPlus::Pod::as_paragraphs CFPlus::Pod::section_of $tod[$todindex]); - $vbox->add (my $table = new CFPlus::UI::Table); + $vbox->add (my $table = new CFPlus::UI::Table col_expand => [0, 1]); $table->add (0, 0, new CFPlus::UI::Button - text => "Close", + text => "Close", tooltip => "Close the tip of the day window. To never see it again, disable the tip of the day in the Server Setup.", on_activate => $close, ); $table->add (2, 0, new CFPlus::UI::Button - text => "Next", + text => "Next", tooltip => "Show the next Tip of the day.", on_activate => sub { $close->(); @@ -1757,8 +1657,6 @@ force_y => 0; $DEBUG_STATUS->show; - $BIND_EDITOR = new CFPlus::BindingEditor (x => "max", y => 0); - $STATUSBOX = new CFPlus::UI::Statusbox; $STATUSBOX->add ("Use Alt-Enter to toggle fullscreen mode", timeout => 864000, pri => -100, color => [1, 1, 1, 0.8]); @@ -1892,6 +1790,7 @@ sub setup_build_button { my ($enabled) = @_; if ($enabled) { + $BUILD_BUTTON->hide if $BUILD_BUTTON; $BUILD_BUTTON ||= new CFPlus::UI::Button text => "Build", tooltip => "Opens the ingame builder", @@ -2142,7 +2041,11 @@ CFPlus::UI::full_refresh; }, CFPlus::SDL_ACTIVEEVENT => sub { -# printf "active %x %x\n", $SDL_EV->active_gain, $SDL_EV->active_state;#d# +# not useful, as APPACTIVE include sonly iconified state, not unmapped +# printf "active %x %x\n", $_[0]{gain}, $_[0]{state};#d# +# printf "A\n" if $_[0]{state} & CFPlus::SDL_APPACTIVE; +# printf "K\n" if $_[0]{state} & CFPlus::SDL_APPINPUTFOCUS; +# printf "M\n" if $_[0]{state} & CFPlus::SDL_APPMOUSEFOCUS; }, CFPlus::SDL_KEYDOWN => sub { if ($_[0]{mod} & CFPlus::KMOD_ALT && $_[0]{sym} == 13) { @@ -2209,6 +2112,19 @@ } $CFG->{profile}{default}{host} ||= "crossfire.schmorp.de"; + $PROFILE = $CFG->{profile}{default}; + + # convert old bindings (only default profile matters) + if (my $bindings = delete $PROFILE->{bindings}) { + while (my ($mod, $syms) = each %$bindings) { + while (my ($sym, $cmds) = each %$syms) { + push @{ $PROFILE->{macro} }, { + accelkey => [$mod*1, $sym*1], + action => $cmds, + }; + } + } + } sdl_init;