--- deliantra/Deliantra-Client/bin/cfplus 2006/06/05 22:30:35 1.59 +++ deliantra/Deliantra-Client/bin/cfplus 2006/06/06 02:55:50 1.60 @@ -93,6 +93,8 @@ our $SETUP_KEYBOARD; our $SETUP_SPELLS; +our $STATS_WINDOW; +our $MESSAGE_WINDOW; our $FLOORBOX; our $GAUGES; our $STATWIDS; @@ -125,6 +127,187 @@ $DEBUG_STATUS->set_text ($_[0]); } +sub destroy_query_dialog { + (delete $_[0]{query_dialog})->destroy + if $_[0]{query_dialog}; +} + +# server query dialog +sub server_query { + my ($conn, $flags, $prompt) = @_; + + $conn->{query_dialog} = my $dialog = new CFClient::UI::FancyFrame + x => "center", + y => "center", + title => "Server Query", + child => my $vbox = new CFClient::UI::VBox, + ; + + my @dialog = my $label = new CFClient::UI::Label + max_w => $::WIDTH * 0.4, + ellipsise => 0, + text => $prompt; + + if ($flags & CS_QUERY_YESNO) { + push @dialog, my $hbox = new CFClient::UI::HBox; + + $hbox->add (new CFClient::UI::Button + text => "No", + on_activate => sub { + $conn->send ("reply n"); + $dialog->destroy; + } + ); + $hbox->add (new CFClient::UI::Button + text => "Yes", + on_activate => sub { + $conn->send ("reply y"); + destroy_query_dialog $conn; + }, + ); + + $dialog->focus_in; + + } elsif ($flags & CS_QUERY_SINGLECHAR) { + $dialog->{tooltip} = "Press a key (click on the entry to make sure it has keyboard focus)"; + + if ($prompt =~ /Now choose a character|Press any key for the next race/i) { + $MESSAGE_WINDOW->show; + + unshift @dialog, new CFClient::UI::Label + max_w => $::WIDTH * 0.4, + ellipsise => 0, + markup => "\nOr use your keyboard:\n"; + + unshift @dialog, my $table = new CFClient::UI::Table; + + $table->add (0, 0, new CFClient::UI::Button + text => "Next Race", + on_activate => sub { + $conn->send ("reply n"); + destroy_query_dialog $conn; + }, + ); + $table->add (2, 0, new CFClient::UI::Button + text => "Accept", + on_activate => sub { + $conn->send ("reply d"); + destroy_query_dialog $conn; + }, + ); + + unshift @dialog, new CFClient::UI::Label + max_w => $::WIDTH * 0.4, + ellipsise => 0, + markup => + "Character Creation: Race\n\n" + . "Look at the Messages window to see a description of this race " + . "(or hover with your mouse over the bottommost entry in the status area in the lower left area of the screen) " + . "and the center of the screen to see how this race looks like " + . "(this is below this dialog window, you may need to click on the display area to make it visible).\n\n" + . "You can look at another race, or accept this race (you will come back to this race eventually, " + . "so you can take your time making this important choice." + ; + + } elsif ($prompt =~ /roll new stats/) { + if (my $stat = delete $conn->{stat_change_with}) { + $conn->send ("reply $stat"); + destroy_query_dialog $conn; + return; + } + + $STATS_WINDOW->show; + $MESSAGE_WINDOW->hide; + + unshift @dialog, new CFClient::UI::Label + max_w => $::WIDTH * 0.4, + ellipsise => 0, + markup => "\nOr use your keyboard:\n"; + + unshift @dialog, my $table = new CFClient::UI::Table; + + # left: re-roll + $table->add (0, 0, new CFClient::UI::Button + text => "Roll Again", + on_activate => sub { + $conn->send ("reply y"); + destroy_query_dialog $conn; + }, + ); + + # center: swap stats + my ($sw1, $sw2) = map +(new CFClient::UI::Combobox + value => $_, + options => [ + [Str => 1, "Strength ($conn->{stat}{+CS_STAT_STR})"], + [Dex => 2, "Dexterity ($conn->{stat}{+CS_STAT_DEX})"], + [Con => 3, "Constitution ($conn->{stat}{+CS_STAT_CON})"], + [Int => 4, "Intelligence ($conn->{stat}{+CS_STAT_INT})"], + [Wis => 5, "Wisdom ($conn->{stat}{+CS_STAT_WIS})"], + [Pow => 6, "Power ($conn->{stat}{+CS_STAT_POW})"], + [Cha => 7, "Charisma ($conn->{stat}{+CS_STAT_CHA})"], + ], + ), 1 .. 2; + + $table->add (2, 0, new CFClient::UI::Button + text => "Swap Stats", + on_activate => sub { + $conn->{stat_change_with} = $sw2->{value}; + $conn->send ("reply $sw1->{value}"); + destroy_query_dialog $conn; + }, + ); + $table->add (2, 1, new CFClient::UI::HBox children => [$sw1, $sw2]); + + # right: accept + $table->add (4, 0, new CFClient::UI::Button + text => "Accept", + on_activate => sub { + $conn->send ("reply n"); + $STATS_WINDOW->hide; + destroy_query_dialog $conn; + }, + ); + + unshift @dialog, new CFClient::UI::Label + max_w => $::WIDTH * 0.4, + ellipsise => 0, + markup => + "Character Creation: Stats\n\n" + . "Look at the Stats window to see your basic stats " + . "(first column: 1 strength, 2 dexterity, 3 constitution, 4 intelligence, 5 wisdom, 6 power and 7 charisma).\n\n" + . "You can create another set of stats, swap two stat values with each other or accept the stats as they are now and continue. " + . "Race selection will influence those values later on." + ; + } + + push @dialog, my $entry = new CFClient::UI::Entry + on_changed => sub { + $conn->send ("reply $_[1]"); + destroy_query_dialog $conn; + }, + ; + + $entry->focus_in; + + } else { + $dialog->{tooltip} = "Enter the reply and press return (click on the entry to make sure it has keyboard focus)"; + + push @dialog, my $entry = new CFClient::UI::Entry + $flags & CS_QUERY_HIDEINPUT ? (hidden => "*") : (), + on_activate => sub { + $conn->send ("reply $_[1]"); + destroy_query_dialog $conn; + }, + ; + + $entry->focus_in; + } + + $vbox->add (@dialog); + $dialog->show; +} + sub start_game { status "logging in..."; @@ -151,6 +334,7 @@ statusbox => $STATUSBOX, map => $MAP, mapmap => $MAPMAP, + query => \&server_query, sound_play => sub { my ($x, $y, $soundnum, $type) = @_; @@ -185,6 +369,7 @@ status "connection closed"; + destroy_query_dialog $CONN; $CONN->destroy; $CONN = 0; # false, does not autovivify } @@ -443,7 +628,7 @@ } -sub make_stats_window { +sub stats_window { my $tgw = new CFClient::UI::FancyFrame y => $HEIGHT * (2/8), x => "max", @@ -853,8 +1038,8 @@ bg => [0, 0, 0, 0.75], x => "max", y => 0, - force_w => $::WIDTH / 3, - force_h => $::HEIGHT / 5, + force_w => $::WIDTH * 0.4, + force_h => $::HEIGHT * 0.5, child => (my $vbox = new CFClient::UI::VBox); $vbox->add ($LOGVIEW); @@ -1003,7 +1188,7 @@ $table } -sub make_inventory_window { +sub inventory_window { my $invwin = $INV_WINDOW = new CFClient::UI::FancyFrame x => "center", y => "center", @@ -1272,7 +1457,7 @@ ; $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); + filter => new CFClient::UI::ScrolledWindow 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."); @@ -1297,14 +1482,14 @@ $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, + $BUTTONBAR->add (new CFClient::UI::Flopper text => "Message Window", other => $MESSAGE_WINDOW = message_window, tooltip => "Toggles the server message log, where the client collects all messages from the server."); make_gauge_window->show; # XXX: this has to be set before make_stats_window as make_stats_window calls update_stats_window which updated the gauges also X-D - $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window, + $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => $STATS_WINDOW = 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, + $BUTTONBAR->add (new CFClient::UI::Flopper text => "Inventory", other => inventory_window, tooltip => "Toggles the inventory window, where you can manage your loot (or treasures :). " . "You can also hit the Tab-key to show/hide the Inventory."); @@ -1576,10 +1761,10 @@ fow_intensity => 0.45, fow_smooth => 0, gui_fontsize => 1, - log_fontsize => 1, + log_fontsize => 0.7, gauge_fontsize=> 1, gauge_size => 0.35, - stat_fontsize => 1, + stat_fontsize => 0.7, mapsize => 100, host => "crossfire.schmorp.de", say_command => 'say',