--- deliantra/Deliantra-Client/bin/cfplus 2006/05/28 01:16:04 1.21 +++ deliantra/Deliantra-Client/bin/cfplus 2006/05/29 20:22:33 1.27 @@ -83,6 +83,7 @@ our $METASERVER; our $LOGIN_BUTTON; our $QUIT_DIALOG; +our $SERVER_SETUP; our $FLOORBOX; our $GAUGES; @@ -99,9 +100,12 @@ our $STATUSBOX; our $DEBUG_STATUS; +our $INV_WINDOW; our $INV; our $INVR; -our $INVR_LBL; +our $INV_RIGHT_HB; + +our $BIND_WINDOW; sub status { $STATUSBOX->add (CFClient::UI::Label::escape $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); @@ -116,6 +120,9 @@ sub start_game { status "logging in..."; + $LOGIN_BUTTON->set_text ("Logout"); + $SERVER_SETUP->hide; + my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; my ($host, $port) = split /:/, $CFG->{host}; @@ -153,12 +160,7 @@ if ($CONN) { CFClient::lowdelay fileno $CONN->{fh}; - $LOGIN_BUTTON->set_text ("Logout"); status "login successful"; - - $BUTTONBAR->{children}[1]->emit ("activate") - if $BUTTONBAR->{children}[1]->{state}; - } else { status "unable to connect"; stop_game(); @@ -166,15 +168,17 @@ } sub stop_game { + $LOGIN_BUTTON->set_text ("Login"); + $SERVER_SETUP->show; + $INV_WINDOW->hide; + $LOGVIEW->hide; + return unless $CONN; status "connection closed"; - $LOGIN_BUTTON->set_text ("Login"); + $CONN->destroy; $CONN = 0; # false, does not autovivify - - $BUTTONBAR->{children}[1]->emit ("activate") - unless $BUTTONBAR->{children}[1]->{state}; } sub client_setup { @@ -436,6 +440,7 @@ $win } + sub make_stats_window { my $tgw = new CFClient::UI::FancyFrame req_y => $HEIGHT * (2/8), @@ -713,7 +718,7 @@ } sub server_setup { - my $dialog = new CFClient::UI::FancyFrame + my $dialog = $SERVER_SETUP = new CFClient::UI::FancyFrame x => $WIDTH * (1/3), y => $HEIGHT * (1/8), name => "server_setup", @@ -864,7 +869,9 @@ my ($input, $text) = @_; $input->set_text (''); - if ($text =~ /^\/(.*)/) { + if ($text =~ /^\/bind\s+(.*)$/) { + CFClient::Recorder::open_binding_dialog ([$1]); + } elsif ($text =~ /^\/(.*)/) { $::CONN->user_send ($1); } else { my $say_cmd = $::CFG->{say_command} || 'say'; @@ -917,7 +924,7 @@ } sub make_inventory_window { - my $invwin = new CFClient::UI::FancyFrame + my $invwin = $INV_WINDOW = new CFClient::UI::FancyFrame def_w => $WIDTH * 7/8, def_h => $HEIGHT * 7/8, title => "Inventory", @@ -936,22 +943,59 @@ $hb->add (my $vb2 = new CFClient::UI::VBox); - $vb2->add (my $hb2 = new CFClient::UI::HBox); - $hb2->add ($INVR_LBL = new CFClient::UI::Label align => 0, expand => 1, text => "Floor"); - $hb2->add (new CFClient::UI::Button - text => "Close", - tooltip => "Close the currently open container (if one is open)", - on_activate => sub { - $CONN->send ("apply $CONN->{open_container}") - if $CONN->{open_container} != 0; - }, - ); + $vb2->add ($INV_RIGHT_HB = new CFClient::UI::HBox); $vb2->add ($INVR = new CFClient::UI::Inventory expand => 1); + # XXX: Call after $INVR = ... because set_opencont sets the items + CFClient::Protocol::set_opencont ($::CONN, 0, "Floor"); + $invwin } +sub make_binding_window { + my $binding_list = new CFClient::UI::VBox; + + my $refresh = sub { + $binding_list->clear (); + + for my $mod (keys %{$::CFG->{bindings}}) { + for my $sym (keys %{$::CFG->{bindings}->{$mod}}) { + my $cmds = $::CFG->{bindings}->{$mod}->{$sym}; + next unless ref $cmds eq 'ARRAY' and @$cmds > 0; + + my $lbl = join "; ", @$cmds; + my $nam = CFClient::Recorder::keycombo_to_name ($mod, $sym); + $binding_list->add (my $hb = new CFClient::UI::HBox); + $hb->add (new CFClient::UI::Button + text => "delete", + on_activate => sub { + $binding_list->remove ($hb); + delete $::CFG->{bindings}->{$mod}->{$sym}; + }); + $hb->add (new CFClient::UI::Label text => "($nam)"); + $hb->add (new CFClient::UI::Label text => $lbl, expand => 1); + } + } + }; + + $BIND_WINDOW = new CFClient::UI::FancyFrame + title => "Bindings", + def_w => int $WIDTH * 7/8, + def_h => int $HEIGHT * 7/8, + on_visibility_change => sub { + my ($self, $visible) = @_; + if ($visible) { + $self->center; + $refresh->() + } + }; + + $BIND_WINDOW->add ($binding_list); + $refresh->(); + $BIND_WINDOW +} + sub make_help_window { my $win = new CFClient::UI::FancyFrame def_w => int $WIDTH * 7/8, @@ -1101,6 +1145,14 @@ $BUTTONBAR->add (new CFClient::UI::Flopper text => "Help!", other => make_help_window, tooltip => "View Documentation"); + $BUTTONBAR->add (new CFClient::UI::Flopper + text => "Bindings", + other => make_binding_window, + tooltip => "Lets you delete bindings you have made with the recorder" + ); + $BUTTONBAR->add (new CFClient::UI::Flopper text => "[Rec]", other => CFClient::Recorder::make_window, + tooltip => "This feature lets you record a series of actions (eg. walking a path or ready a skill) and bind them to keys"); + $BUTTONBAR->add (new CFClient::UI::Button text => "Quit", tooltip => "Terminates the program", @@ -1117,13 +1169,7 @@ $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]); - # delay till geometry is constant - $CFClient::UI::ROOT->on_post_alloc (startup => sub { - $BUTTONBAR->{children}[1]->emit ("activate"); # pop up server setup - my $widget = $GAUGES->{win}; - $widget->move (0, $HEIGHT - $widget->{h});#d# to in toplevel - }); - force_refresh (); + $SERVER_SETUP->show; } }