ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/bin/cfplus
(Generate patch)

Comparing deliantra/Deliantra-Client/bin/cfplus (file contents):
Revision 1.60 by root, Tue Jun 6 02:55:50 2006 UTC vs.
Revision 1.69 by root, Mon Jun 12 13:26:15 2006 UTC

84our $CONSOLE; 84our $CONSOLE;
85our $METASERVER; 85our $METASERVER;
86our $LOGIN_BUTTON; 86our $LOGIN_BUTTON;
87our $QUIT_DIALOG; 87our $QUIT_DIALOG;
88our $HOST_ENTRY; 88our $HOST_ENTRY;
89our $SERVER_INFO;
89 90
90our $SETUP_DIALOG; 91our $SETUP_DIALOG;
91our $SETUP_NOTEBOOK; 92our $SETUP_NOTEBOOK;
92our $SETUP_SERVER; 93our $SETUP_SERVER;
93our $SETUP_KEYBOARD; 94our $SETUP_KEYBOARD;
237 238
238 # center: swap stats 239 # center: swap stats
239 my ($sw1, $sw2) = map +(new CFClient::UI::Combobox 240 my ($sw1, $sw2) = map +(new CFClient::UI::Combobox
240 value => $_, 241 value => $_,
241 options => [ 242 options => [
242 [Str => 1, "Strength ($conn->{stat}{+CS_STAT_STR})"], 243 [1 => "Str", "Strength ($conn->{stat}{+CS_STAT_STR})"],
243 [Dex => 2, "Dexterity ($conn->{stat}{+CS_STAT_DEX})"], 244 [2 => "Dex", "Dexterity ($conn->{stat}{+CS_STAT_DEX})"],
244 [Con => 3, "Constitution ($conn->{stat}{+CS_STAT_CON})"], 245 [3 => "Con", "Constitution ($conn->{stat}{+CS_STAT_CON})"],
245 [Int => 4, "Intelligence ($conn->{stat}{+CS_STAT_INT})"], 246 [4 => "Int", "Intelligence ($conn->{stat}{+CS_STAT_INT})"],
246 [Wis => 5, "Wisdom ($conn->{stat}{+CS_STAT_WIS})"], 247 [5 => "Wis", "Wisdom ($conn->{stat}{+CS_STAT_WIS})"],
247 [Pow => 6, "Power ($conn->{stat}{+CS_STAT_POW})"], 248 [6 => "Pow", "Power ($conn->{stat}{+CS_STAT_POW})"],
248 [Cha => 7, "Charisma ($conn->{stat}{+CS_STAT_CHA})"], 249 [7 => "Cha", "Charisma ($conn->{stat}{+CS_STAT_CHA})"],
249 ], 250 ],
250 ), 1 .. 2; 251 ), 1 .. 2;
251 252
252 $table->add (2, 0, new CFClient::UI::Button 253 $table->add (2, 0, new CFClient::UI::Button
253 text => "Swap Stats", 254 text => "Swap Stats",
362sub stop_game { 363sub stop_game {
363 $LOGIN_BUTTON->set_text ("Login"); 364 $LOGIN_BUTTON->set_text ("Login");
364 $SETUP_NOTEBOOK->set_current_page ($SETUP_SERVER); 365 $SETUP_NOTEBOOK->set_current_page ($SETUP_SERVER);
365 $SETUP_DIALOG->show; 366 $SETUP_DIALOG->show;
366 $INV_WINDOW->hide; 367 $INV_WINDOW->hide;
368 $SETUP_SPELLS->clear_spells;
367 369
368 return unless $CONN; 370 return unless $CONN;
369 371
370 status "connection closed"; 372 status "connection closed";
371 373
625 &set_gauge_window_fontsize; 627 &set_gauge_window_fontsize;
626 628
627 $win 629 $win
628} 630}
629 631
632sub debug_setup {
633 my $table = new CFClient::UI::Table;
634
635 $table->add (0, 0, new CFClient::UI::Label text => "Widget Borders");
636 $table->add (1, 0, new CFClient::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 1 });
637 $table->add (0, 1, new CFClient::UI::Label text => "Tooltip Widget Info");
638 $table->add (1, 1, new CFClient::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 2 });
639 $table->add (0, 2, new CFClient::UI::Label text => "Show FPS");
640 $table->add (1, 2, new CFClient::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 4 });
641 $table->add (0, 3, new CFClient::UI::Label text => "Suppress Tooltips");
642 $table->add (1, 3, new CFClient::UI::CheckBox on_changed => sub { $ENV{CFPLUS_DEBUG} ^= 8 });
643
644 my @default_smooth = (0.05, 0.13, 0.05, 0.13, 0.30, 0.13, 0.05, 0.13, 0.05);
645
646 for my $x (0..2) {
647 for my $y (0 .. 2) {
648 $table->add ($x + 3, $y,
649 new CFClient::UI::Entry
650 text => $default_smooth[$x * 3 + $y],
651 on_changed => sub { $MAP->{smooth_matrix}[$x * 3 + $y] = $_[1] if $MAP; 0 },
652 );
653 }
654 }
655
656
657 $table
658}
630 659
631sub stats_window { 660sub stats_window {
632 my $tgw = new CFClient::UI::FancyFrame 661 my $tgw = new CFClient::UI::FancyFrame
633 y => $HEIGHT * (2/8), 662 y => $HEIGHT * (2/8),
634 x => "max", 663 x => "max",
846 875
847 utf8::decode $buf if utf8::valid $buf; 876 utf8::decode $buf if utf8::valid $buf;
848 877
849 $table->clear; 878 $table->clear;
850 879
880 my @tip = (
881 "The current number of users logged in on the server.",
882 "The hostname of the server.",
883 "The time this server has been running without being restarted.",
884 "The server software version - a '+' indicates a Crossfire+ server.",
885 "Short information about this server provided by its admins.",
886 );
851 my @col = qw(Use #Users Host Uptime Version Description); 887 my @col = qw(#Users Host Uptime Version Description);
852 $table->add ($_, 0, new CFClient::UI::Label align => 0, fg => [1, 1, 0], text => $col[$_]) 888 $table->add ($_, 0, new CFClient::UI::Label
889 can_hover => 1, can_events => 1,
890 align => 0, fg => [1, 1, 0],
891 text => $col[$_], tooltip => $tip[$_])
853 for 0 .. $#col; 892 for 0 .. $#col;
854 893
855 my @align = qw(1 0 1 1 -1); 894 my @align = qw(1 0 1 1 -1);
856 895
857 my $y = 0; 896 my $y = 0;
858 for my $m (sort { $b->[3] <=> $a->[3] } map [split /\|/], split /\015?\012/, $buf) { 897 for my $m (sort { $b->[3] <=> $a->[3] } map [split /\|/], split /\015?\012/, $buf) {
875 914
876 $m = [$users, $host, $uptime, $version, $desc]; 915 $m = [$users, $host, $uptime, $version, $desc];
877 916
878 $y++; 917 $y++;
879 918
880 $table->add (0, $y, new CFClient::UI::VBox children => [ 919 $table->add (scalar @$m, $y, new CFClient::UI::VBox children => [
881 (new CFClient::UI::Button text => "Use", on_activate => sub { 920 (new CFClient::UI::Button
921 text => "Use",
922 tooltip => "Put this server into the <b>Host:Port</b> field",
923 on_activate => sub {
882 $HOST_ENTRY->set_text ($CFG->{host} = $host); 924 $HOST_ENTRY->set_text ($CFG->{host} = $host);
883 $METASERVER->toggle_visibility; 925 $METASERVER->hide;
926 },
884 }), 927 ),
885 (new CFClient::UI::Empty expand => 1), 928 (new CFClient::UI::Empty expand => 1),
886 ]); 929 ]);
887 930
888 $table->add ($_ + 1, $y, new CFClient::UI::Label 931 $table->add ($_, $y, new CFClient::UI::Label
889 ellipsise => 0, align => $align[$_], text => $m->[$_], fontsize => 0.8) 932 ellipsise => 0,
933 align => $align[$_],
934 text => $m->[$_],
935 tooltip => $tip[$_],
936 can_hover => 1,
937 can_events => 1,
938 fontsize => 0.8)
890 for 0 .. $#$m; 939 for 0 .. $#$m;
891 } 940 }
892 } 941 }
893 }); 942 });
894} 943}
895 944
896sub metaserver_dialog { 945sub metaserver_dialog {
897 my $dialog = new CFClient::UI::FancyFrame 946 my $dialog = new CFClient::UI::FancyFrame
898 title => "Server List", 947 title => "Server List",
899 name => 'metaserver_dialog', 948 name => 'metaserver_dialog',
900 x => 'center', 949 x => 'center',
901 y => 'center', 950 y => 'center',
902 z => 3, 951 z => 3,
952 force_h => $::HEIGHT * 0.4,
903 child => (my $vbox = new CFClient::UI::VBox), 953 child => (my $vbox = new CFClient::UI::VBox),
904 on_visibility_change => sub { 954 on_visibility_change => sub {
905 update_metaserver if $_[1]; 955 update_metaserver if $_[1];
906 }, 956 },
907 ; 957 ;
908 958
909 $vbox->add ($dialog->{table} = new CFClient::UI::Table); 959 $dialog->{table} = new CFClient::UI::Table;
960
961 $vbox->add (new CFClient::UI::ScrolledWindow expand => 1, child => $dialog->{table});
910 962
911 $dialog 963 $dialog
912} 964}
913 965
914sub server_setup { 966sub server_setup {
937 expand => 1, 989 expand => 1,
938 text => "Server List", 990 text => "Server List",
939 other => $METASERVER, 991 other => $METASERVER,
940 tooltip => "Show a list of available crossfire servers", 992 tooltip => "Show a list of available crossfire servers",
941 on_activate => sub { $METASERVER->toggle_visibility }, 993 on_activate => sub { $METASERVER->toggle_visibility },
994 on_visibility_change => sub { $METASERVER->hide unless $_[1] },
942 ); 995 );
943 } 996 }
944 997
945 $table->add (0, 4, new CFClient::UI::Label valign => 0, align => 1, text => "Username"); 998 $table->add (0, 4, new CFClient::UI::Label valign => 0, align => 1, text => "Username");
946 $table->add (1, 4, new CFClient::UI::Entry 999 $table->add (1, 4, new CFClient::UI::Entry
1024 on_changed => sub { 1077 on_changed => sub {
1025 my ($self, $value) = @_; 1078 my ($self, $value) = @_;
1026 $CFG->{say_command} = $value; 1079 $CFG->{say_command} = $value;
1027 } 1080 }
1028 ); 1081 );
1082
1083 $vbox->add (new CFClient::UI::Label
1084 text => "Server Info",
1085 fontsize => 1.2,
1086 padding_y => 8,
1087 fg => [1, 1, 0, 1],
1088 );
1089
1090 $vbox->add ($SERVER_INFO = new CFClient::UI::Label ellipsise => 0);
1029 1091
1030 $vbox 1092 $vbox
1031} 1093}
1032 1094
1033sub message_window { 1095sub message_window {
1158 ["Potions" => PICKUP_POTION], 1220 ["Potions" => PICKUP_POTION],
1159 ["Magic Devices" => PICKUP_MAGIC_DEVICE], 1221 ["Magic Devices" => PICKUP_MAGIC_DEVICE],
1160 ["Ignore cursed" => PICKUP_NOT_CURSED], 1222 ["Ignore cursed" => PICKUP_NOT_CURSED],
1161 ["Jewelery" => PICKUP_JEWELS], 1223 ["Jewelery" => PICKUP_JEWELS],
1162 ], 1224 ],
1225 ["Weight/Value ratio", 2, 17]
1163 ) 1226 )
1164 { 1227 {
1165 my ($title, $x, $y, @bits) = @$_; 1228 my ($title, $x, $y, @bits) = @$_;
1166 $table->add ($x, $y, new CFClient::UI::Label text => $title, align => 1, fg => [1, 1, 0]); 1229 $table->add ($x, $y, new CFClient::UI::Label text => $title, align => 1, fg => [1, 1, 0]);
1167 1230
1172 $table->add ($x , $y, new CFClient::UI::Label text => $_->[0], align => 1, expand => 1); 1235 $table->add ($x , $y, new CFClient::UI::Label text => $_->[0], align => 1, expand => 1);
1173 $table->add ($x+1, $y, new CFClient::UI::CheckBox 1236 $table->add ($x+1, $y, new CFClient::UI::CheckBox
1174 state => $CFG->{pickup} & $mask, 1237 state => $CFG->{pickup} & $mask,
1175 on_changed => sub { 1238 on_changed => sub {
1176 my ($box, $value) = @_; 1239 my ($box, $value) = @_;
1240
1177 if ($value) { 1241 if ($value) {
1178 $::CFG->{pickup} |= $mask; 1242 $::CFG->{pickup} |= $mask;
1179 } else { 1243 } else {
1180 $::CFG->{pickup} = $::CFG->{pickup} & ~$mask; 1244 $::CFG->{pickup} &= ~$mask;
1181 } 1245 }
1246
1182 $::CONN->send (sprintf "command pickup %u", $::CFG->{pickup}) 1247 $::CONN->send_command ("pickup $::CFG->{pickup}")
1183 if defined $::CONN; 1248 if defined $::CONN;
1184 }); 1249 });
1185 } 1250 }
1186 } 1251 }
1252
1253 $table->add (2, 18, new CFClient::UI::ValSlider
1254 range => [0, 0, 16, 1, 1],
1255 to_value => sub { ">= " . 5 * $_[0] },
1256 on_changed => sub {
1257 my ($slider, $value) = @_;
1258
1259 $::CFG->{pickup} &= ~0x7;
1260 $::CFG->{pickup} |= int $value
1261 if $value;
1262 1;
1263 });
1264 $table->add (3, 18, new CFClient::UI::Button
1265 text => "set",
1266 on_activate => sub {
1267 $::CONN->send_command ("pickup $::CFG->{pickup}")
1268 if defined $::CONN;
1269 1;
1270 });
1187 1271
1188 $table 1272 $table
1189} 1273}
1190 1274
1191sub inventory_window { 1275sub inventory_window {
1309 $refresh->(); 1393 $refresh->();
1310 1394
1311 $vb 1395 $vb
1312} 1396}
1313 1397
1314sub make_help_window { 1398sub help_window {
1315 my $win = new CFClient::UI::FancyFrame 1399 my $win = new CFClient::UI::FancyFrame
1316 x => 'center', 1400 x => 'center',
1317 y => 'center', 1401 y => 'center',
1318 z => 2, 1402 z => 2,
1319 name => 'doc_browser', 1403 name => 'doc_browser',
1322 title => "Documentation"; 1406 title => "Documentation";
1323 1407
1324 $win->add (my $vbox = new CFClient::UI::VBox); 1408 $win->add (my $vbox = new CFClient::UI::VBox);
1325 1409
1326 $vbox->add (my $buttons = new CFClient::UI::HBox); 1410 $vbox->add (my $buttons = new CFClient::UI::HBox);
1327 $vbox->add (my $viewer = new CFClient::UI::TextView expand => 1, fontsize => 0.8); 1411 $vbox->add (my $viewer = new CFClient::UI::TextScroller
1412 expand => 1, fontsize => 0.8, padding_x => 4);
1328 1413
1329 for ( 1414 $buttons->add (new CFClient::UI::Label text => "Choose a document to display: ");
1415 $buttons->add (my $combo = new CFClient::UI::Combobox
1416 value => undef,
1417 options => [
1330 [intro => "Introduction"], 1418 [intro => "Introduction"],
1331 [manual => "Manual"], 1419 [manual => "Manual"],
1420 [skill_help => "Skills"],
1332 [command_help => "Commands"], 1421 [command_help => "Commands"],
1333 [skill_help => "Skills"], 1422 [dmcommand_help => "DM Commands"],
1334 ) { 1423 [COPYING => "License Terms"],
1335 my ($pod, $label) = @$_; 1424 ],
1425 on_changed => sub {
1426 my ($self, $pod) = @_;
1336 1427
1337 $buttons->add (new CFClient::UI::Button
1338 text => $label,
1339 on_activate => sub {
1340 my $pom = CFClient::load_pod CFClient::find_rcfile "pod/$pod.pod", 1428 my $pom = CFClient::load_pod CFClient::find_rcfile "pod/$pod.pod",
1341 doc_viewer => 1, sub { CFClient::pod_to_pango_list $_[0] }; 1429 doc_viewer => 1, sub { CFClient::pod_to_pango_list $_[0] };
1342 1430
1343 $viewer->clear; 1431 $viewer->clear;
1344 1432
1345 $viewer->add_paragraph ([1, 1, 1, 1], $_->[1], $_->[0]) 1433 $viewer->add_paragraph ([1, 1, 1, 1], $_->[1], $_->[0])
1346 for @$pom; 1434 for @$pom;
1347 1435
1348 $viewer->set_offset (0); 1436 $viewer->set_offset (0);
1349 }, 1437 },
1438 on_visibility_change => sub {
1439 my ($self, $visible) = @_;
1440 return unless $visible;
1441 return if $self->{value};
1442 $self->set_value ("intro");
1443 },
1350 ); 1444 );
1351 }
1352
1353 $viewer->add_paragraph ([1, 1, 0, 1], "<big>Use one of the buttons above to display a document.</big>");
1354 1445
1355 $win 1446 $win
1356} 1447}
1357 1448
1358sub sdl_init { 1449sub sdl_init {
1435 } 1526 }
1436 }); 1527 });
1437 $MAPWIDGET->show; 1528 $MAPWIDGET->show;
1438 $MAPWIDGET->focus_in; 1529 $MAPWIDGET->focus_in;
1439 1530
1440 $LOGVIEW = new CFClient::UI::TextView 1531 $LOGVIEW = new CFClient::UI::TextScroller
1441 expand => 1, 1532 expand => 1,
1442 font => $FONT_FIXED, 1533 font => $FONT_FIXED,
1443 fontsize => $::CFG->{log_fontsize}, 1534 fontsize => $::CFG->{log_fontsize},
1535 indent => -4,
1444 can_hover => 1, 1536 can_hover => 1,
1445 can_events => 1, 1537 can_events => 1,
1446 tooltip => "<b>Server Log</b>. This text viewer contains all the messages sent by the server.", 1538 tooltip => "<b>Server Log</b>. This text viewer contains all the messages sent by the server.",
1447 ; 1539 ;
1448 1540
1474 . "want to record press <b>Insert</b> and you will be asked to press a key-combo. " 1566 . "want to record press <b>Insert</b> and you will be asked to press a key-combo. "
1475 . "After pressing the combo the binding will be saved automatically and the " 1567 . "After pressing the combo the binding will be saved automatically and the "
1476 . "binding editor closes"); 1568 . "binding editor closes");
1477 $SETUP_NOTEBOOK->add (Spells => $SETUP_SPELLS = spell_setup, 1569 $SETUP_NOTEBOOK->add (Spells => $SETUP_SPELLS = spell_setup,
1478 "Displays all spells you have and lets you edit keyboard shortcuts for them."); 1570 "Displays all spells you have and lets you edit keyboard shortcuts for them.");
1571 $SETUP_NOTEBOOK->add (Debug => debug_setup,
1572 "Some debuggign options. Do not ask.");
1479 1573
1480 $BUTTONBAR = new CFClient::UI::Buttonbar x => 0, y => 0, z => 200; # put on top 1574 $BUTTONBAR = new CFClient::UI::Buttonbar x => 0, y => 0, z => 200; # put on top
1481 1575
1482 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Setup", other => $SETUP_DIALOG, 1576 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Setup", other => $SETUP_DIALOG,
1483 tooltip => "Toggles a dialog where you can configure all aspects of this client."); 1577 tooltip => "Toggles a dialog where you can configure all aspects of this client.");
1501 CFClient::write_cfg "$Crossfire::VARDIR/cfplusrc"; 1595 CFClient::write_cfg "$Crossfire::VARDIR/cfplusrc";
1502 status "Configuration Saved"; 1596 status "Configuration Saved";
1503 }, 1597 },
1504 ); 1598 );
1505 1599
1506 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Help!", other => make_help_window, 1600 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Help!", other => help_window,
1507 tooltip => "View Documentation"); 1601 tooltip => "View Documentation");
1508 1602
1509 $BUTTONBAR->add (new CFClient::UI::Button 1603 $BUTTONBAR->add (new CFClient::UI::Button
1510 text => "Quit", 1604 text => "Quit",
1511 tooltip => "Terminates the program", 1605 tooltip => "Terminates the program",
1772 bgm_enable => 1, 1866 bgm_enable => 1,
1773 bgm_volume => 0.25, 1867 bgm_volume => 0.25,
1774 face_prefetch => 0, 1868 face_prefetch => 0,
1775 output_sync => 1, 1869 output_sync => 1,
1776 output_count => 1, 1870 output_count => 1,
1871 pickup => 0,
1777 ); 1872 );
1778 1873
1779 while (my ($k, $v) = each %DEF_CFG) { 1874 while (my ($k, $v) = each %DEF_CFG) {
1780 $CFG->{$k} = $v unless exists $CFG->{$k}; 1875 $CFG->{$k} = $v unless exists $CFG->{$k};
1781 } 1876 }
1828 video_init; 1923 video_init;
1829 audio_init; 1924 audio_init;
1830} 1925}
1831 1926
1832Event::loop; 1927Event::loop;
1928#CFClient::SDL_Quit;
1929#CFClient::_exit 0;
1833 1930
1834END { CFClient::SDL_Quit } 1931END { CFClient::SDL_Quit }
1835 1932
1836=head1 NAME 1933=head1 NAME
1837 1934

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines