--- deliantra/Deliantra-Client/bin/cfplus 2006/05/30 01:42:16 1.30 +++ deliantra/Deliantra-Client/bin/cfplus 2006/06/02 06:22:55 1.42 @@ -83,6 +83,7 @@ our $METASERVER; our $LOGIN_BUTTON; our $QUIT_DIALOG; +our $HOST_ENTRY; our $SERVER_SETUP; our $FLOORBOX; @@ -106,6 +107,9 @@ our $INV_RIGHT_HB; our $BIND_WINDOW; +our $BIND_EDITOR; + +our $SPELL_LIST; sub status { $STATUSBOX->add (CFClient::UI::Label::escape $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); @@ -192,7 +196,7 @@ $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, force_w => 100, range => [$CFG->{sdl_mode}, 0, $#SDL_MODES, 0, 1]); + $hbox->add (my $mode_slider = new CFClient::UI::Slider force_w => $WIDTH * 0.1, expand => 1, range => [$CFG->{sdl_mode}, 0, $#SDL_MODES, 0, 1]); $hbox->add (my $mode_label = new CFClient::UI::Label align => 0, valign => 0, height => 0.8, template => "9999x9999"); $mode_slider->connect (changed => sub { @@ -627,21 +631,9 @@ for keys %tbl; } -sub metaserver_dialog { - my $dialog = new CFClient::UI::FancyFrame - title => "Server List", - child => (my $vbox = new CFClient::UI::VBox); - - $vbox->add ($dialog->{table} = new CFClient::UI::Table); - - $dialog -} - my $METASERVER_ATIME; sub update_metaserver { - my ($HOST) = @_; - return if $METASERVER_ATIME > time; $METASERVER_ATIME = time + 60; @@ -703,7 +695,8 @@ $table->add (0, $y, new CFClient::UI::VBox children => [ (new CFClient::UI::Button text => "Use", on_activate => sub { - $HOST->set_text ($CFG->{host} = $host); + $HOST_ENTRY->set_text ($CFG->{host} = $host); + $METASERVER->toggle_visibility; }), (new CFClient::UI::Empty expand => 1), ]); @@ -716,6 +709,23 @@ }); } +sub metaserver_dialog { + my $dialog = new CFClient::UI::FancyFrame + title => "Server List", + name => 'metaserver_dialog', + x => 'center', + y => 'center', + child => (my $vbox = new CFClient::UI::VBox), + on_visibility_change => sub { + update_metaserver if $_[1]; + }, + ; + + $vbox->add ($dialog->{table} = new CFClient::UI::Table); + + $dialog +} + sub server_setup { my $dialog = $SERVER_SETUP = new CFClient::UI::FancyFrame x => "center", @@ -732,7 +742,7 @@ $table->add (1, 2, my $vbox = new CFClient::UI::VBox); $vbox->add ( - my $HOST = new CFClient::UI::Entry + $HOST_ENTRY = new CFClient::UI::Entry expand => 1, text => $CFG->{host}, tooltip => "The hostname or ip address of the Crossfire(+) server to connect to", @@ -744,14 +754,12 @@ $METASERVER = metaserver_dialog; - $vbox->add (new CFClient::UI::Flopper - expand => 1, - text => "Server List", - other => $METASERVER, + $vbox->add (new CFClient::UI::Button + expand => 1, + text => "Server List", + other => $METASERVER, tooltip => "Show a list of available crossfire servers", - on_open => sub { - update_metaserver $HOST; - } + on_activate => sub { $METASERVER->toggle_visibility }, ); } @@ -865,7 +873,10 @@ $input->set_text (''); if ($text =~ /^\/bind\s+(.*)$/) { - CFClient::Recorder::open_binding_dialog ([$1]); + CFClient::Binder::open_binding_dialog (sub { + my ($mod, $sym) = @_; + $::CFG->{bindings}->{$mod}->{$sym} = [$1]; + }); } elsif ($text =~ /^\/(.*)/) { $::CONN->user_send ($1); } else { @@ -923,12 +934,11 @@ sub make_inventory_window { my $invwin = $INV_WINDOW = new CFClient::UI::FancyFrame - x => "center", - y => "center", - def_w => $WIDTH * 9/10, - def_h => $HEIGHT * 9/10, - title => "Inventory", - name => "inventory_window", + x => "center", + y => "center", + force_w => $WIDTH * 9/10, + force_h => $HEIGHT * 9/10, + title => "Inventory", ; $invwin->add (my $hb = new CFClient::UI::HBox homogeneous => 1); @@ -949,10 +959,18 @@ $invwin } +sub make_spell_list { + $SPELL_LIST = new CFClient::UI::SpellList + force_w => $WIDTH * (9/10), + force_h => $HEIGHT * (9/10); + $SPELL_LIST +} + sub make_binding_window { my $binding_list = new CFClient::UI::VBox; - my $refresh = sub { + my $refresh; + $refresh = sub { $binding_list->clear (); for my $mod (keys %{$::CFG->{bindings}}) { @@ -961,15 +979,37 @@ next unless ref $cmds eq 'ARRAY' and @$cmds > 0; my $lbl = join "; ", @$cmds; - my $nam = CFClient::Recorder::keycombo_to_name ($mod, $sym); + my $nam = CFClient::Binder::keycombo_to_name ($mod, $sym); $binding_list->add (my $hb = new CFClient::UI::HBox); $hb->add (new CFClient::UI::Button text => "delete", + tooltip => "Deletes the binding", 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::Button + text => "edit", + tooltip => "Edits the binding", + on_activate => sub { + $::BIND_EDITOR->set_binding ( + $mod, $sym, $::CFG->{bindings}->{$mod}->{$sym}, + sub { + my ($nmod, $nsym, $ncmds) = @_; + delete $::CFG->{bindings}->{$mod}->{$sym}; + $::CFG->{bindings}->{$nmod}->{$nsym} = $ncmds; + $refresh->(); + $::BIND_WINDOW->show; + }, + sub { + $::BIND_WINDOW->show; + }); + $::BIND_EDITOR->show; + $::BIND_WINDOW->hide; + }); + + $hb->add (new CFClient::UI::Label text => "(Key: $nam)"); $hb->add (new CFClient::UI::Label text => $lbl, expand => 1); } } @@ -986,16 +1026,49 @@ $refresh->() if $visible; }; - $BIND_WINDOW->add ($binding_list); + $BIND_WINDOW->add (my $vb = new CFClient::UI::VBox); + $vb->add ($binding_list); + $vb->add (my $hb = new CFClient::UI::HBox); + $hb->add (new CFClient::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) = @_; + $::CFG->{bindings}->{$mod}->{$sym} = $cmds; + $refresh->(); + $::BIND_WINDOW->show; + }, + sub { + $::BIND_WINDOW->show; + }); + $::BIND_WINDOW->hide; + $::BIND_EDITOR->show; + }, + ); + $hb->add (new CFClient::UI::Button + text => "close", + tooltip => "Closes the binding window", + expand => 1, + on_activate => sub { + $::BIND_WINDOW->hide; + } + ); + $refresh->(); $BIND_WINDOW } sub make_help_window { my $win = new CFClient::UI::FancyFrame - def_w => int $WIDTH * 7/8, - def_h => int $HEIGHT * 7/8, - title => "Documentation"; + x => 'center', + y => 'center', + name => 'doc_browser', + force_w => int $WIDTH * 7/8, + force_h => int $HEIGHT * 7/8, + title => "Documentation"; $win->add (my $vbox = new CFClient::UI::VBox); @@ -1072,7 +1145,9 @@ force_x => "max", force_y => 0; $DEBUG_STATUS->show; - + + $BIND_EDITOR = new CFClient::UI::BindEditor (x => "max", y => 0); + $STATUSBOX = new CFClient::UI::Statusbox; $STATUSBOX->add ("Use Alt-Enter to toggle fullscreen mode", pri => -100, color => [1, 1, 1, 0.8]); @@ -1084,6 +1159,8 @@ )->show; CFClient::UI::FancyFrame->new ( + title => "Mini Map", + name => "mapmap", x => 0, y => $FONTSIZE + 8, border_bg => [1, 1, 1, 192/255], @@ -1132,7 +1209,8 @@ $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window, tooltip => "Toggles the statistics window, where all your Stats and Resistances are being displayed at all times."); $BUTTONBAR->add (new CFClient::UI::Flopper text => "Inventory", other => make_inventory_window, - tooltip => "Toggles the inventory window, where you can manage your loot (or treaures :)."); + tooltip => "Toggles the inventory window, where you can manage your loot (or treaures :)." + ."You can also hit the Tab-key to show/hide the Inventory."); $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", @@ -1150,10 +1228,18 @@ $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"); + tooltip => + "Lets you define, edit and delete bindings." + ."There is a shortcut for making bindings: LCTRL+Insert opens the binding editor " + ."with nothing set and the recording started. After doing the actions you " + ."want to record press Insert and you will be asked to press a key-combo." + ."After pressing the combo the binding will be saved automatically and the " + ."binding editor closes"); + + $BUTTONBAR->add (new CFClient::UI::Flopper + text => "Spells", + other => make_spell_list, + tooltip => "The spell list"); $BUTTONBAR->add (new CFClient::UI::Button text => "Quit", @@ -1248,7 +1334,7 @@ sub force_refresh { $fps = $fps * 0.95 + 1 / (($NOW - $LAST_REFRESH) || 0.1) * 0.05; - debug sprintf "%3.2f", $fps; + debug sprintf "%3.2f", $fps if $ENV{CFPLUS_DEBUG} & 4; $CFClient::UI::ROOT->draw; @@ -1491,6 +1577,16 @@ cfplus utilises OpenGL for all UI elements and the game. It is supposed to be used fullscreen and interactively. +=head1 DEBUGGING + + +CFPLUS_DEBUG - environment variable + + 1 draw borders around widgets + 2 add low-level widget info to tooltips + 4 show fps + 8 suppress tooltips + =head1 AUTHOR Marc Lehmann , Robin Redeker