--- deliantra/Deliantra-Client/bin/cfplus 2006/06/02 16:52:49 1.45 +++ deliantra/Deliantra-Client/bin/cfplus 2006/06/03 02:32:35 1.50 @@ -43,6 +43,7 @@ $Event::DIED = sub { # TODO: display dialog box or so + Carp::confess $_[1];#d#TODO: remove when stable CFClient::error $_[1]; }; @@ -84,7 +85,12 @@ our $LOGIN_BUTTON; our $QUIT_DIALOG; our $HOST_ENTRY; -our $SERVER_SETUP; + +our $SETUP_DIALOG; +our $SETUP_NOTEBOOK; +our $SETUP_SERVER; +our $SETUP_KEYBOARD; +our $SETUP_SPELLS; our $FLOORBOX; our $GAUGES; @@ -106,10 +112,8 @@ our $INVR; our $INV_RIGHT_HB; -our $BIND_WINDOW; our $BIND_EDITOR; -our $SPELL_LIST; our $PICKUP_CFG; sub status { @@ -124,7 +128,7 @@ status "logging in..."; $LOGIN_BUTTON->set_text ("Logout"); - $SERVER_SETUP->hide; + $SETUP_DIALOG->hide; my $mapsize = List::Util::min 32, List::Util::max 11, int $WIDTH * $CFG->{mapsize} * 0.01 / 32; @@ -172,7 +176,7 @@ sub stop_game { $LOGIN_BUTTON->set_text ("Login"); - $SERVER_SETUP->show; + $SETUP_DIALOG->show; $INV_WINDOW->hide; $LOGVIEW->hide; @@ -184,13 +188,8 @@ $CONN = 0; # false, does not autovivify } -sub client_setup { - my $dialog = new CFClient::UI::FancyFrame - x => 1, - y => $HEIGHT * (1/8), - name => "client_setup", - title => "Client Setup", - child => (my $vbox = new CFClient::UI::VBox); +sub graphics_setup { + my $vbox = new CFClient::UI::VBox; $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); @@ -325,6 +324,16 @@ } ); + $vbox +} + +sub audio_setup { + my $vbox = new CFClient::UI::VBox; + + $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); + + my $row = 0; + $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Audio Enable"); $table->add (1, $row++, new CFClient::UI::CheckBox state => $CFG->{audio_enable}, @@ -364,19 +373,7 @@ } ); - $table->add (0, $row, new CFClient::UI::Label valign => 0, align => 1, text => "Chat Command"); - $table->add (1, $row++, my $saycmd = new CFClient::UI::Entry - text => $CFG->{say_command}, - tooltip => "This is the command that will be used if you write a line in the message window entry or press \" in the map window. " - . "Usually you want to enter something like 'say' or 'shout' or 'gsay' here. " - . "But you could also set it to tell playername to only chat with that user.", - on_changed => sub { - my ($self, $value) = @_; - $CFG->{say_command} = $value; - } - ); - - $dialog + $vbox } sub set_stats_window_fontsize { @@ -559,8 +556,8 @@ $tgw } -sub formsep { - reverse join ",", grep length, split /(...)/, reverse $_[0] * 1 +sub formsep($) { + scalar reverse join ",", unpack "(A3)*", reverse $_[0] * 1 } sub update_stats_window { @@ -728,13 +725,7 @@ } sub server_setup { - my $dialog = $SERVER_SETUP = new CFClient::UI::FancyFrame - x => "center", - y => "center", - name => "server_setup", - title => "Server Setup", - child => (my $vbox = new CFClient::UI::VBox), - ; + my $vbox = new CFClient::UI::VBox; $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); $table->add (0, 2, new CFClient::UI::Label valign => 0, align => 1, text => "Host:Port"); @@ -837,7 +828,19 @@ }, ); - $dialog + $table->add (0, 12, new CFClient::UI::Label valign => 0, align => 1, text => "Chat Command"); + $table->add (1, 12, my $saycmd = new CFClient::UI::Entry + text => $CFG->{say_command}, + tooltip => "This is the command that will be used if you write a line in the message window entry or press \" in the map window. " + . "Usually you want to enter something like 'say' or 'shout' or 'gsay' here. " + . "But you could also set it to tell playername to only chat with that user.", + on_changed => sub { + my ($self, $value) = @_; + $CFG->{say_command} = $value; + } + ); + + $vbox } sub message_window { @@ -873,12 +876,7 @@ my ($input, $text) = @_; $input->set_text (''); - if ($text =~ /^\/bind\s+(.*)$/) { - CFClient::Binder::open_binding_dialog (sub { - my ($mod, $sym) = @_; - $::CFG->{bindings}->{$mod}->{$sym} = [$1]; - }); - } elsif ($text =~ /^\/(.*)/) { + if ($text =~ /^\/(.*)/) { $::CONN->user_send ($1); } else { my $say_cmd = $::CFG->{say_command} || 'say'; @@ -933,16 +931,9 @@ $QUIT_DIALOG->show; } -sub make_pickup_cfg_window { - $PICKUP_CFG = new CFClient::UI::FancyFrame - title => "Autopickup configuration", - x => "center", - y => "center", - force_w => $WIDTH * 6/10, - force_h => $HEIGHT * 9/10; - +sub autopickup_setup { + my $vb = new CFClient::UI::VBox; - $PICKUP_CFG->add (my $vb = new CFClient::UI::VBox); $vb->add (my $gen_tbl = new CFClient::UI::Table expand => 1); $vb->add (my $hb = new CFClient::UI::HBox expand => 1); $hb->add (my $ltbl = new CFClient::UI::Table expand => 1); @@ -1009,7 +1000,7 @@ } } - $PICKUP_CFG + $vb } sub make_inventory_window { @@ -1039,14 +1030,11 @@ $invwin } -sub make_spell_list { - $SPELL_LIST = new CFClient::UI::SpellList - force_w => $WIDTH * (9/10), - force_h => $HEIGHT * (9/10); - $SPELL_LIST +sub spell_setup { + new CFClient::UI::SpellList } -sub make_binding_window { +sub keyboard_setup { my $binding_list = new CFClient::UI::VBox; my $refresh; @@ -1080,13 +1068,15 @@ delete $::CFG->{bindings}->{$mod}->{$sym}; $::CFG->{bindings}->{$nmod}->{$nsym} = $ncmds; $refresh->(); - $::BIND_WINDOW->show; + $SETUP_NOTEBOOK->set_current_page ($SETUP_KEYBOARD); + $SETUP_DIALOG->show; }, sub { - $::BIND_WINDOW->show; + $SETUP_NOTEBOOK->set_current_page ($SETUP_KEYBOARD); + $SETUP_DIALOG->show; }); $::BIND_EDITOR->show; - $::BIND_WINDOW->hide; + $SETUP_DIALOG->hide; }); $hb->add (new CFClient::UI::Label text => "(Key: $nam)"); @@ -1095,20 +1085,10 @@ } }; - $BIND_WINDOW = new CFClient::UI::FancyFrame - title => "Bindings", - x => "center", - y => "center", - def_w => int $WIDTH * 9/10, - def_h => int $HEIGHT * 9/10, - on_visibility_change => sub { - my ($self, $visible) = @_; - $refresh->() if $visible; - }; - - $BIND_WINDOW->add (my $vb = new CFClient::UI::VBox); + 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, @@ -1119,26 +1099,30 @@ my ($mod, $sym, $cmds) = @_; $::CFG->{bindings}->{$mod}->{$sym} = $cmds; $refresh->(); - $::BIND_WINDOW->show; + $SETUP_NOTEBOOK->set_current_page ($SETUP_KEYBOARD); + $SETUP_DIALOG->show; }, sub { - $::BIND_WINDOW->show; + $SETUP_NOTEBOOK->set_current_page ($SETUP_KEYBOARD); + $SETUP_DIALOG->show; }); - $::BIND_WINDOW->hide; + $SETUP_DIALOG->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; + $SETUP_DIALOG->hide; } ); $refresh->(); - $BIND_WINDOW + + $vb } sub make_help_window { @@ -1239,7 +1223,7 @@ )->show; CFClient::UI::FancyFrame->new ( - title => "Mini Map", + title => "Map", name => "mapmap", x => 0, y => $FONTSIZE + 8, @@ -1275,12 +1259,41 @@ tooltip => "Server Log. This text viewer contains all the messages sent by the server.", ; + $SETUP_DIALOG = new CFClient::UI::FancyFrame + title => "Setup", + name => "setup_dialog", + x => 'center', + y => 'center', + force_w => $::WIDTH * 0.6, + force_h => $::HEIGHT * 0.6, + ; + + $SETUP_DIALOG->add ($SETUP_NOTEBOOK = new CFClient::UI::Notebook expand => 1, debug => 1, + filter => new CFClient::UI::ScrolledWindow xxx => 1, expand => 1, scroll_y => 1); + + $SETUP_NOTEBOOK->add (Server => $SETUP_SERVER = server_setup, + "Configure the server to play on, your username, password and other server-related options."); + $SETUP_NOTEBOOK->add (Pickup => autopickup_setup, + "Configure autopicking stetings, i.e. which items you will pick up automatically when walking over them."); + $SETUP_NOTEBOOK->add (Graphics => graphics_setup, + "Configure the video mode, performance, fonts and other graphical aspects of the game."); + $SETUP_NOTEBOOK->add (Audio => audio_setup, + "Configure the use of audio, sound effects and background music."); + $SETUP_NOTEBOOK->add (Keyboard => $SETUP_KEYBOARD = keyboard_setup, + "Lets you define, edit and delete bindings." + . "There is a shortcut for making bindings: Left Control + 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"); + $SETUP_NOTEBOOK->add (Spells => $SETUP_SPELLS = spell_setup, + "Displays all spells you have and lets you edit keyboard shortcuts for them."); + $BUTTONBAR = new CFClient::UI::HBox x => 0, y => 0; - $BUTTONBAR->add (new CFClient::UI::Flopper text => "Client Setup", other => client_setup, - tooltip => "Toggles a dialog where you can configure various aspects of the client, such as graphics mode, performance, and audio options."); - $BUTTONBAR->add (new CFClient::UI::Flopper text => "Server Setup", other => server_setup, - tooltip => "Toggles a dialog where you can configure the server to play on, your username, password and other server-related options."); + $BUTTONBAR->add (new CFClient::UI::Flopper text => "Setup", other => $SETUP_DIALOG, + tooltip => "Toggles a dialog where you can configure all aspects of this client."); + $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => message_window, tooltip => "Toggles the server message log, where the client collects all messages from the server."); @@ -1290,7 +1303,7 @@ 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 :)." - ."You can also hit the Tab-key to show/hide the Inventory."); + ."You can also hit the Tab-key to show/hide the Inventory."); $BUTTONBAR->add (new CFClient::UI::Button text => "Save Config", @@ -1305,28 +1318,6 @@ $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 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::Flopper - text => "Pickup", - other => make_pickup_cfg_window, - tooltip => "The pickup dialog"); - - $BUTTONBAR->add (new CFClient::UI::Button text => "Quit", tooltip => "Terminates the program", @@ -1340,10 +1331,10 @@ ); $BUTTONBAR->show; - $SERVER_SETUP->show; - - $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]); + $SETUP_DIALOG->show; } + + $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]); } sub video_shutdown { @@ -1485,7 +1476,7 @@ CFClient::SDL_GL_SwapBuffers; } -my $refresh_watcher = Event->timer (after => 0, hard => 1, interval => 1 / $MAX_FPS, cb => sub { +my $refresh_watcher = Event->timer (after => 0, hard => 0, interval => 1 / $MAX_FPS, cb => sub { $NOW = time; ($SDL_CB{$_->{type}} || sub { warn "unhandled event $_->{type}" })->($_) @@ -1562,7 +1553,11 @@ $SIG{INT} = $SIG{TERM} = sub { exit }; { - local $SIG{__DIE__} = sub { CFClient::fatal $_[0] if defined $^S && !$^S }; + local $SIG{__DIE__} = sub { + return unless defined $^S && !$^S; + Carp::confess $_[1];#d#TODO: remove when stable + CFClient::fatal $_[0]; + }; CFClient::read_cfg "$Crossfire::VARDIR/cfplusrc"; CFClient::UI::set_layout ($::CFG->{layout});