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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines