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.109 by root, Sun Aug 13 14:30:07 2006 UTC vs.
Revision 1.118 by root, Tue Aug 22 06:37:30 2006 UTC

59 return;#d# 59 return;#d#
60 #return unless defined $^S && !$^S; 60 #return unless defined $^S && !$^S;
61 $Event::DIED->(undef, $_[0]); 61 $Event::DIED->(undef, $_[0]);
62}; 62};
63 63
64our $VERSION = '0.1'; 64our $VERSION = '0.9';
65 65
66my $MAX_FPS = 60; 66my $MAX_FPS = 60;
67my $MIN_FPS = 5; # unused as of yet 67my $MIN_FPS = 5; # unused as of yet
68 68
69our $META_SERVER = "crossfire.real-time.com:13326"; 69our $META_SERVER = "crossfire.real-time.com:13326";
155 155
156# server query dialog 156# server query dialog
157sub server_query { 157sub server_query {
158 my ($conn, $flags, $prompt) = @_; 158 my ($conn, $flags, $prompt) = @_;
159 159
160 $conn->{query_dialog} = my $dialog = new CFPlus::UI::FancyFrame 160 $conn->{query_dialog} = my $dialog = new CFPlus::UI::Toplevel
161 x => "center", 161 x => "center",
162 y => "center", 162 y => "center",
163 title => "Server Query", 163 title => "Server Query",
164 child => my $vbox = new CFPlus::UI::VBox, 164 child => my $vbox = new CFPlus::UI::VBox,
165 ; 165 ;
367 user => $CFG->{profile}{default}{user}, 367 user => $CFG->{profile}{default}{user},
368 pass => $CFG->{profile}{default}{password}, 368 pass => $CFG->{profile}{default}{password},
369 mapw => $mapsize, 369 mapw => $mapsize,
370 maph => $mapsize, 370 maph => $mapsize,
371 371
372 client => "cfplus $VERSION $] $^O",
373
372 map_widget => $MAPWIDGET, 374 map_widget => $MAPWIDGET,
373 logview => $LOGVIEW, 375 logview => $LOGVIEW,
374 statusbox => $STATUSBOX, 376 statusbox => $STATUSBOX,
375 map => $MAP, 377 map => $MAP,
376 mapmap => $MAPMAP, 378 mapmap => $MAPMAP,
663 expand => 1, 665 expand => 1,
664 scroll_y => 1 666 scroll_y => 1
665 ); 667 );
666 $r->add (my $vb = new CFPlus::UI::VBox); 668 $r->add (my $vb = new CFPlus::UI::VBox);
667 669
670 $vb->add (new CFPlus::UI::FancyFrame
671 label => "Player",
672 child => (my $pi = new CFPlus::UI::VBox),
673 );
674
668 $vb->add ($STATWIDS->{title} = new CFPlus::UI::Label valign => 0, align => -1, text => "Title:", expand => 1, 675 $pi->add ($STATWIDS->{title} = new CFPlus::UI::Label valign => 0, align => -1, text => "Title:", expand => 1,
669 can_hover => 1, can_events => 1, 676 can_hover => 1, can_events => 1,
670 tooltip => "Your name and title. You can change your title by using the <b>title</b> command, if supported by the server."); 677 tooltip => "Your name and title. You can change your title by using the <b>title</b> command, if supported by the server.");
671 $vb->add ($STATWIDS->{map} = new CFPlus::UI::Label valign => 0, align => -1, text => "Map:", expand => 1, 678 $pi->add ($STATWIDS->{map} = new CFPlus::UI::Label valign => 0, align => -1, text => "Map:", expand => 1,
672 can_hover => 1, can_events => 1, 679 can_hover => 1, can_events => 1,
673 tooltip => "The map you are currently on (if supported by the server)."); 680 tooltip => "The map you are currently on (if supported by the server).");
674 681
675 $vb->add (my $hb0 = new CFPlus::UI::HBox); 682 $pi->add (my $hb0 = new CFPlus::UI::HBox);
676 $hb0->add ($STATWIDS->{weight} = new CFPlus::UI::Label valign => 0, align => -1, text => "Weight:", expand => 1, 683 $hb0->add ($STATWIDS->{weight} = new CFPlus::UI::Label valign => 0, align => -1, text => "Weight:", expand => 1,
677 can_hover => 1, can_events => 1, 684 can_hover => 1, can_events => 1,
678 tooltip => "The weight of the player including all inventory items."); 685 tooltip => "The weight of the player including all inventory items.");
679 $hb0->add ($STATWIDS->{m_weight} = new CFPlus::UI::Label valign => 0, align => -1, text => "Max weight:", expand => 1, 686 $hb0->add ($STATWIDS->{m_weight} = new CFPlus::UI::Label valign => 0, align => -1, text => "Max weight:", expand => 1,
680 can_hover => 1, can_events => 1, 687 can_hover => 1, can_events => 1,
681 tooltip => "The weight limit: you cannot carry more than this."); 688 tooltip => "The weight limit: you cannot carry more than this.");
682 689
690 $vb->add (new CFPlus::UI::FancyFrame
691 label => "Primary/Secondary Statistics",
683 $vb->add (my $hb = new CFPlus::UI::HBox expand => 1); 692 child => (my $hb = new CFPlus::UI::HBox expand => 1),
693 );
684 $hb->add (my $tbl = new CFPlus::UI::Table expand => 1); 694 $hb->add (my $tbl = new CFPlus::UI::Table expand => 1);
685 695
686 my $color2 = [1, 1, 0]; 696 my $color2 = [1, 1, 0];
687 697
688 for ( 698 for (
709 $tbl->add ($col + 1, $row, $STATWIDS->{"$id\_lbl"} = new CFPlus::UI::Label 719 $tbl->add ($col + 1, $row, $STATWIDS->{"$id\_lbl"} = new CFPlus::UI::Label
710 font => $FONT_FIXED, can_hover => 1, can_events => 1, fg => $color2, valign => 0, 720 font => $FONT_FIXED, can_hover => 1, can_events => 1, fg => $color2, valign => 0,
711 align => -1, text => $label, tooltip => "#stat_$label"); 721 align => -1, text => $label, tooltip => "#stat_$label");
712 } 722 }
713 723
724 $vb->add (new CFPlus::UI::FancyFrame
725 label => "Resistancies",
714 $vb->add (my $tbl2 = new CFPlus::UI::Table expand => 1); 726 child => (my $tbl2 = new CFPlus::UI::Table expand => 1),
727 );
715 728
716 my $row = 0; 729 my $row = 0;
717 my $col = 0; 730 my $col = 0;
718 731
719 my %resist_names = ( 732 my %resist_names = (
913sub metaserver_dialog { 926sub metaserver_dialog {
914 my $vbox = new CFPlus::UI::VBox; 927 my $vbox = new CFPlus::UI::VBox;
915 my $table = new CFPlus::UI::Table; 928 my $table = new CFPlus::UI::Table;
916 $vbox->add (new CFPlus::UI::ScrolledWindow expand => 1, child => $table); 929 $vbox->add (new CFPlus::UI::ScrolledWindow expand => 1, child => $table);
917 930
918 my $dialog = new CFPlus::UI::FancyFrame 931 my $dialog = new CFPlus::UI::Toplevel
919 title => "Server List", 932 title => "Server List",
920 name => 'metaserver_dialog', 933 name => 'metaserver_dialog',
921 x => 'center', 934 x => 'center',
922 y => 'center', 935 y => 'center',
923 z => 3, 936 z => 3,
935} 948}
936 949
937sub server_setup { 950sub server_setup {
938 my $vbox = new CFPlus::UI::VBox; 951 my $vbox = new CFPlus::UI::VBox;
939 952
953 $vbox->add (new CFPlus::UI::FancyFrame
954 label => "Connection Settings",
940 $vbox->add (my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 1]); 955 child => (my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 1]),
956 );
941 $table->add (0, 2, new CFPlus::UI::Label valign => 0, align => 1, text => "Host:Port"); 957 $table->add (0, 2, new CFPlus::UI::Label valign => 0, align => 1, text => "Host:Port");
942 958
943 { 959 {
944 $table->add (1, 2, my $vbox = new CFPlus::UI::VBox); 960 $table->add (1, 2, my $vbox = new CFPlus::UI::VBox);
945 961
1040 $CFG->{say_command} = $value; 1056 $CFG->{say_command} = $value;
1041 0 1057 0
1042 } 1058 }
1043 ); 1059 );
1044 1060
1045 $vbox->add (new CFPlus::UI::Label 1061 $vbox->add (new CFPlus::UI::FancyFrame
1046 text => "Server Info", 1062 label => "Server Info",
1047 fontsize => 1.2,
1048 padding_y => 8,
1049 fg => [1, 1, 0, 1],
1050 );
1051
1052 $vbox->add ($SERVER_INFO = new CFPlus::UI::Label ellipsise => 0); 1063 child => ($SERVER_INFO = new CFPlus::UI::Label ellipsise => 0),
1064 );
1053 1065
1054 $vbox 1066 $vbox
1055} 1067}
1056 1068
1057sub message_window { 1069sub message_window {
1058 my $window = new CFPlus::UI::FancyFrame 1070 my $window = new CFPlus::UI::Toplevel
1059 name => "message_window", 1071 name => "message_window",
1060 title => "Messages", 1072 title => "Messages",
1061 border_bg => [1, 1, 1, 1], 1073 border_bg => [1, 1, 1, 1],
1062 x => "max", 1074 x => "max",
1063 y => 0, 1075 y => 0,
1116 1128
1117 $window 1129 $window
1118} 1130}
1119 1131
1120sub open_string_query { 1132sub open_string_query {
1121 my $cb = $_[1]; 1133 my ($title, $cb, $txt, $tooltip) = @_;
1122 my $dialog = new CFPlus::UI::FancyFrame 1134 my $dialog = new CFPlus::UI::Toplevel
1123 x => "center", 1135 x => "center",
1124 y => "center", 1136 y => "center",
1125 z => 50, 1137 z => 50,
1126 force_w => $WIDTH * 4/5, 1138 force_w => $WIDTH * 4/5,
1127 title => $_[0]; 1139 title => $title;
1128 1140
1129 $dialog->add ( 1141 $dialog->add (
1130 my $e = new CFPlus::UI::Entry 1142 my $e = new CFPlus::UI::Entry
1131 on_activate => sub { $cb->(@_); $dialog->hide; 0 }, 1143 on_activate => sub { $cb->(@_); $dialog->hide; 0 },
1132 on_key_down => sub { $_[1]->{sym} == 27 and $dialog->hide; 0 }, 1144 on_key_down => sub { $_[1]->{sym} == 27 and $dialog->hide; 0 },
1145 tooltip => $tooltip
1133 ); 1146 );
1134 1147
1135 $e->grab_focus; 1148 $e->grab_focus;
1149 $e->set_text ($txt) if $txt;
1136 $dialog->show; 1150 $dialog->show;
1137} 1151}
1138 1152
1139sub open_quit_dialog { 1153sub open_quit_dialog {
1140 unless ($QUIT_DIALOG) { 1154 unless ($QUIT_DIALOG) {
1141 $QUIT_DIALOG = new CFPlus::UI::FancyFrame 1155 $QUIT_DIALOG = new CFPlus::UI::Toplevel
1142 x => "center", 1156 x => "center",
1143 y => "center", 1157 y => "center",
1144 z => 50, 1158 z => 50,
1145 title => "Really Quit?", 1159 title => "Really Quit?",
1146 on_key_down => sub { 1160 on_key_down => sub {
1335 $PL_WINDOW->show; 1349 $PL_WINDOW->show;
1336 } 1350 }
1337} 1351}
1338 1352
1339sub player_window { 1353sub player_window {
1340 my $plwin = $PL_WINDOW = new CFPlus::UI::FancyFrame 1354 my $plwin = $PL_WINDOW = new CFPlus::UI::Toplevel
1341 x => "center", 1355 x => "center",
1342 y => "center", 1356 y => "center",
1343 force_w => $WIDTH * 9/10, 1357 force_w => $WIDTH * 9/10,
1344 force_h => $HEIGHT * 9/10, 1358 force_h => $HEIGHT * 9/10,
1345 title => "Player", 1359 title => "Player",
1434 } 1448 }
1435 } 1449 }
1436 }; 1450 };
1437 1451
1438 my $vb = new CFPlus::UI::VBox; 1452 my $vb = new CFPlus::UI::VBox;
1453 $vb->add (new CFPlus::UI::FancyFrame
1454 label => "Options",
1439 $vb->add (my $hb = new CFPlus::UI::HBox); 1455 child => (my $hb = new CFPlus::UI::HBox),
1456 );
1440 $hb->add (new CFPlus::UI::Label text => "only shift-up stops fire"); 1457 $hb->add (new CFPlus::UI::Label text => "only shift-up stops fire");
1441 $hb->add (new CFPlus::UI::CheckBox 1458 $hb->add (new CFPlus::UI::CheckBox
1442 expand => 1, 1459 expand => 1,
1443 state => $CFG->{shift_fire_stop}, 1460 state => $CFG->{shift_fire_stop},
1444 tooltip => "If this checkbox is enabled you will stop fire only if you stop pressing shift", 1461 tooltip => "If this checkbox is enabled you will stop fire only if you stop pressing shift",
1446 my ($cbox, $value) = @_; 1463 my ($cbox, $value) = @_;
1447 $CFG->{shift_fire_stop} = $value; 1464 $CFG->{shift_fire_stop} = $value;
1448 0 1465 0
1449 }); 1466 });
1450 1467
1451 $vb->add ($binding_list); 1468 $vb->add (new CFPlus::UI::FancyFrame
1469 label => "Bindings",
1470 child => $binding_list);
1452 $vb->add (my $hb = new CFPlus::UI::HBox); 1471 $vb->add (my $hb = new CFPlus::UI::HBox);
1453 1472
1454 $hb->add (new CFPlus::UI::Button 1473 $hb->add (new CFPlus::UI::Button
1455 text => "record new", 1474 text => "record new",
1456 expand => 1, 1475 expand => 1,
1489 1508
1490 $vb 1509 $vb
1491} 1510}
1492 1511
1493sub help_window { 1512sub help_window {
1494 my $win = new CFPlus::UI::FancyFrame 1513 my $win = new CFPlus::UI::Toplevel
1495 x => 'center', 1514 x => 'center',
1496 y => 'center', 1515 y => 'center',
1497 z => 2, 1516 z => 2,
1498 name => 'doc_browser', 1517 name => 'doc_browser',
1499 force_w => int $WIDTH * 7/8, 1518 force_w => int $WIDTH * 7/8,
1501 title => "Help Browser", 1520 title => "Help Browser",
1502 has_close_button => 1; 1521 has_close_button => 1;
1503 1522
1504 $win->add (my $vbox = new CFPlus::UI::VBox); 1523 $win->add (my $vbox = new CFPlus::UI::VBox);
1505 1524
1525 $vbox->add (new CFPlus::UI::FancyFrame
1526 label => "Navigation",
1506 $vbox->add (my $buttons = new CFPlus::UI::HBox); 1527 child => (my $buttons = new CFPlus::UI::HBox),
1528 );
1507 $vbox->add (my $viewer = new CFPlus::UI::TextScroller 1529 $vbox->add (my $viewer = new CFPlus::UI::TextScroller
1508 expand => 1, fontsize => 0.8, padding_x => 4); 1530 expand => 1, fontsize => 0.8, padding_x => 4, padding_y => 4);
1509 1531
1510 $buttons->add (new CFPlus::UI::Label text => "Choose a document to display: "); 1532 my @history;
1511 $buttons->add (my $combo = new CFPlus::UI::Selector 1533 my @future;
1512 value => undef, 1534 my $curnode;
1513 options => [ 1535
1514 [intro => "Introduction"], 1536 my $load_node; $load_node = sub {
1515 [manual => "Main Manual"], 1537 my ($node, $para) = @_;
1516 [skill_help => "Skill Reference"], 1538
1517 [command_help => "Command Reference"], 1539 $buttons->clear;
1518 [dmcommand_help => "DM Commands"], 1540
1519 [COPYING => "License Terms"], 1541 $buttons->add (new CFPlus::UI::Button
1520 ], 1542 text => "⇤",
1543 tooltip => "back to the starting page",
1521 on_changed => sub { 1544 on_activate => sub {
1522 my ($self, $pod) = @_; 1545 unshift @future, [$curnode, $viewer->current_paragraph] if $curnode;
1523 1546 unshift @future, @history;
1524 $viewer->clear; 1547 @history = ();
1525 $viewer->add_paragraph (CFPlus::Pod::section pod => $pod); 1548 $load_node->(@{shift @future});
1526 $viewer->set_offset (0);
1527
1528 0 1549 },
1550 );
1551
1552 if (@history) {
1553 $buttons->add (new CFPlus::UI::Button
1554 text => "⋘",
1555 tooltip => "back to <i>" . (CFPlus::asxml CFPlus::Pod::full_path $history[-1][0]) . "</i>",
1556 on_activate => sub {
1557 unshift @future, [$curnode, $viewer->current_paragraph] if $curnode;
1558 $load_node->(@{pop @history});
1559 },
1560 );
1529 }, 1561 }
1530 on_visibility_change => sub { 1562
1531 my ($self, $visible) = @_; 1563 if (@future) {
1532 return unless $visible; 1564 $buttons->add (new CFPlus::UI::Button
1533 return if $self->{value}; 1565 text => "⋙",
1534 $self->set_value ("intro"); 1566 tooltip => "forward to <i>" . (CFPlus::asxml CFPlus::Pod::full_path $future[0][0]) . "</i>",
1567 on_activate => sub {
1568 push @history, [$curnode, $viewer->current_paragraph];
1569 $load_node->(@{shift @future});
1570 },
1535 0 1571 );
1536 }, 1572 }
1573
1574 $buttons->add (new CFPlus::UI::Label text => " ");
1575
1576 my @path = CFPlus::Pod::full_path_of $node;
1577 pop @path; # drop current node
1578
1579 for my $node (@path) {
1580 $buttons->add (new CFPlus::UI::Button
1581 text => $node->{kw}[0],
1582 tooltip => "go to <i>" . (CFPlus::asxml CFPlus::Pod::full_path $node) . "</i>",
1583 on_activate => sub {
1584 push @history, [$curnode, $viewer->current_paragraph] if $curnode; @future = ();
1585 $load_node->($node);
1586 },
1587 );
1588 $buttons->add (new CFPlus::UI::Label text => "/");
1589 }
1590
1591 $buttons->add (new CFPlus::UI::Label text => $node->{kw}[0], padding_x => 4, padding_y => 4);
1592
1593 $curnode = $node;
1594
1595 $viewer->clear;
1596 $viewer->add_paragraph (CFPlus::Pod::as_paragraphs CFPlus::Pod::section_of $curnode);
1597 $viewer->scroll_to ($para);
1537 ); 1598 };
1599
1600 $load_node->(CFPlus::Pod::find pod => "mainpage");
1601
1602 $CFPlus::Pod::goto_document = sub {
1603 my (@path) = @_;
1604
1605 push @history, [$curnode, $viewer->current_paragraph] if $curnode; @future = ();
1606
1607 $load_node->((CFPlus::Pod::find @path)[0]);
1608 $win->show;
1609 };
1538 1610
1539 $win 1611 $win
1540} 1612}
1541 1613
1542sub sdl_init { 1614sub sdl_init {
1591 force_x => 0, 1663 force_x => 0,
1592 force_y => "max", 1664 force_y => "max",
1593 child => $STATUSBOX, 1665 child => $STATUSBOX,
1594 )->show; 1666 )->show;
1595 1667
1596 CFPlus::UI::FancyFrame->new ( 1668 CFPlus::UI::Toplevel->new (
1597 title => "Map", 1669 title => "Map",
1598 name => "mapmap", 1670 name => "mapmap",
1599 x => 0, 1671 x => 0,
1600 y => $FONTSIZE + 8, 1672 y => $FONTSIZE + 8,
1601 border_bg => [1, 1, 1, 192/255], 1673 border_bg => [1, 1, 1, 192/255],
1629 can_hover => 1, 1701 can_hover => 1,
1630 can_events => 1, 1702 can_events => 1,
1631 tooltip => "<b>Server Log</b>. This text viewer contains all the messages sent by the server.", 1703 tooltip => "<b>Server Log</b>. This text viewer contains all the messages sent by the server.",
1632 ; 1704 ;
1633 1705
1634 $SETUP_DIALOG = new CFPlus::UI::FancyFrame 1706 $SETUP_DIALOG = new CFPlus::UI::Toplevel
1635 title => "Setup", 1707 title => "Setup",
1636 name => "setup_dialog", 1708 name => "setup_dialog",
1637 x => 'center', 1709 x => 'center',
1638 y => 'center', 1710 y => 'center',
1639 z => 2, 1711 z => 2,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines