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.38 by elmex, Wed May 31 13:44:26 2006 UTC vs.
Revision 1.47 by root, Fri Jun 2 21:36:12 2006 UTC

81our $LOGVIEW; 81our $LOGVIEW;
82our $CONSOLE; 82our $CONSOLE;
83our $METASERVER; 83our $METASERVER;
84our $LOGIN_BUTTON; 84our $LOGIN_BUTTON;
85our $QUIT_DIALOG; 85our $QUIT_DIALOG;
86our $HOST_ENTRY;
86our $SERVER_SETUP; 87our $SERVER_SETUP;
87 88
88our $FLOORBOX; 89our $FLOORBOX;
89our $GAUGES; 90our $GAUGES;
90our $STATWIDS; 91our $STATWIDS;
107 108
108our $BIND_WINDOW; 109our $BIND_WINDOW;
109our $BIND_EDITOR; 110our $BIND_EDITOR;
110 111
111our $SPELL_LIST; 112our $SPELL_LIST;
113our $PICKUP_CFG;
112 114
113sub status { 115sub status {
114 $STATUSBOX->add (CFClient::UI::Label::escape $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); 116 $STATUSBOX->add (CFClient::UI::Label::escape $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]);
115} 117}
116 118
628 630
629 $STATWIDS->{"res_$_"}->set_text (sprintf "%d%", $stats->{$tbl{$_}}) 631 $STATWIDS->{"res_$_"}->set_text (sprintf "%d%", $stats->{$tbl{$_}})
630 for keys %tbl; 632 for keys %tbl;
631} 633}
632 634
633sub metaserver_dialog {
634 my $dialog = new CFClient::UI::FancyFrame
635 title => "Server List",
636 child => (my $vbox = new CFClient::UI::VBox);
637
638 $vbox->add ($dialog->{table} = new CFClient::UI::Table);
639
640 $dialog
641}
642
643my $METASERVER_ATIME; 635my $METASERVER_ATIME;
644 636
645sub update_metaserver { 637sub update_metaserver {
646 my ($HOST) = @_;
647
648 return if $METASERVER_ATIME > time; 638 return if $METASERVER_ATIME > time;
649 $METASERVER_ATIME = time + 60; 639 $METASERVER_ATIME = time + 60;
650 640
651 my $table = $METASERVER->{table}; 641 my $table = $METASERVER->{table};
652 $table->clear; 642 $table->clear;
704 694
705 $y++; 695 $y++;
706 696
707 $table->add (0, $y, new CFClient::UI::VBox children => [ 697 $table->add (0, $y, new CFClient::UI::VBox children => [
708 (new CFClient::UI::Button text => "Use", on_activate => sub { 698 (new CFClient::UI::Button text => "Use", on_activate => sub {
709 $HOST->set_text ($CFG->{host} = $host); 699 $HOST_ENTRY->set_text ($CFG->{host} = $host);
700 $METASERVER->toggle_visibility;
710 }), 701 }),
711 (new CFClient::UI::Empty expand => 1), 702 (new CFClient::UI::Empty expand => 1),
712 ]); 703 ]);
713 704
714 $table->add ($_ + 1, $y, new CFClient::UI::Label 705 $table->add ($_ + 1, $y, new CFClient::UI::Label
717 } 708 }
718 } 709 }
719 }); 710 });
720} 711}
721 712
713sub metaserver_dialog {
714 my $dialog = new CFClient::UI::FancyFrame
715 title => "Server List",
716 name => 'metaserver_dialog',
717 x => 'center',
718 y => 'center',
719 child => (my $vbox = new CFClient::UI::VBox),
720 on_visibility_change => sub {
721 update_metaserver if $_[1];
722 },
723 ;
724
725 $vbox->add ($dialog->{table} = new CFClient::UI::Table);
726
727 $dialog
728}
729
722sub server_setup { 730sub server_setup {
723 my $dialog = $SERVER_SETUP = new CFClient::UI::FancyFrame 731 my $dialog = $SERVER_SETUP = new CFClient::UI::FancyFrame
724 x => "center", 732 x => "center",
725 y => "center", 733 y => "center",
726 name => "server_setup", 734 name => "server_setup",
733 741
734 { 742 {
735 $table->add (1, 2, my $vbox = new CFClient::UI::VBox); 743 $table->add (1, 2, my $vbox = new CFClient::UI::VBox);
736 744
737 $vbox->add ( 745 $vbox->add (
738 my $HOST = new CFClient::UI::Entry 746 $HOST_ENTRY = new CFClient::UI::Entry
739 expand => 1, 747 expand => 1,
740 text => $CFG->{host}, 748 text => $CFG->{host},
741 tooltip => "The hostname or ip address of the Crossfire(+) server to connect to", 749 tooltip => "The hostname or ip address of the Crossfire(+) server to connect to",
742 on_changed => sub { 750 on_changed => sub {
743 my ($self, $value) = @_; 751 my ($self, $value) = @_;
745 } 753 }
746 ); 754 );
747 755
748 $METASERVER = metaserver_dialog; 756 $METASERVER = metaserver_dialog;
749 757
750 $vbox->add (new CFClient::UI::Flopper 758 $vbox->add (new CFClient::UI::Button
751 expand => 1, 759 expand => 1,
752 text => "Server List", 760 text => "Server List",
753 other => $METASERVER, 761 other => $METASERVER,
754 tooltip => "Show a list of available crossfire servers", 762 tooltip => "Show a list of available crossfire servers",
755 on_open => sub { 763 on_activate => sub { $METASERVER->toggle_visibility },
756 update_metaserver $HOST;
757 }
758 ); 764 );
759 } 765 }
760 766
761 $table->add (0, 4, new CFClient::UI::Label valign => 0, align => 1, text => "Username"); 767 $table->add (0, 4, new CFClient::UI::Label valign => 0, align => 1, text => "Username");
762 $table->add (1, 4, new CFClient::UI::Entry 768 $table->add (1, 4, new CFClient::UI::Entry
865 }, 871 },
866 on_activate => sub { 872 on_activate => sub {
867 my ($input, $text) = @_; 873 my ($input, $text) = @_;
868 $input->set_text (''); 874 $input->set_text ('');
869 875
870 if ($text =~ /^\/bind\s+(.*)$/) {
871 CFClient::Binder::open_binding_dialog (sub {
872 my ($mod, $sym) = @_;
873 $::CFG->{bindings}->{$mod}->{$sym} = [$1];
874 });
875 } elsif ($text =~ /^\/(.*)/) { 876 if ($text =~ /^\/(.*)/) {
876 $::CONN->user_send ($1); 877 $::CONN->user_send ($1);
877 } else { 878 } else {
878 my $say_cmd = $::CFG->{say_command} || 'say'; 879 my $say_cmd = $::CFG->{say_command} || 'say';
879 $::CONN->user_send ("$say_cmd $text"); 880 $::CONN->user_send ("$say_cmd $text");
880 } 881 }
923 on_activate => sub { exit }, 924 on_activate => sub { exit },
924 ); 925 );
925 } 926 }
926 927
927 $QUIT_DIALOG->show; 928 $QUIT_DIALOG->show;
929}
930
931sub make_pickup_cfg_window {
932 $PICKUP_CFG = new CFClient::UI::FancyFrame
933 title => "Autopickup configuration",
934 x => "center",
935 y => "center",
936 force_w => $WIDTH * 6/10,
937 force_h => $HEIGHT * 9/10;
938
939
940 $PICKUP_CFG->add (my $vb = new CFClient::UI::VBox);
941 $vb->add (my $gen_tbl = new CFClient::UI::Table expand => 1);
942 $vb->add (my $hb = new CFClient::UI::HBox expand => 1);
943 $hb->add (my $ltbl = new CFClient::UI::Table expand => 1);
944 $hb->add (my $rtbl = new CFClient::UI::Table expand => 1);
945
946 my $tbl = 0;
947 my $tblrow = 0;
948
949 for (
950 ["General", $gen_tbl],
951 ["Enable autopickup" => CFClient::Pickup::PU_NEWMODE],
952 ["Inhibit autopickup" => CFClient::Pickup::PU_INHIBIT],
953 ["Stop before pickup" => CFClient::Pickup::PU_STOP],
954 ["Debug autopickup" => CFClient::Pickup::PU_DEBUG],
955 ["Weapons", $ltbl],
956 ["All weapons" => CFClient::Pickup::PU_ALLWEAPON],
957 ["Missile weapons" => CFClient::Pickup::PU_MISSILEWEAPON],
958 ["Bows" => CFClient::Pickup::PU_BOW],
959 ["Arrows" => CFClient::Pickup::PU_ARROW],
960 ["Armour"],
961 ["Helmets" => CFClient::Pickup::PU_HELMET],
962 ["Shields" => CFClient::Pickup::PU_SHIELD],
963 ["Body Armour" => CFClient::Pickup::PU_ARMOUR],
964 ["Boots" => CFClient::Pickup::PU_BOOTS],
965 ["Gloves" => CFClient::Pickup::PU_GLOVES],
966 ["Cloaks" => CFClient::Pickup::PU_CLOAK],
967 ["Readables", $rtbl],
968 ["Spellbooks" => CFClient::Pickup::PU_SPELLBOOK],
969 ["Skillscrolls" => CFClient::Pickup::PU_SKILLSCROLL],
970 ["Normal Books/Scrolls" => CFClient::Pickup::PU_READABLES],
971 ["Misc"],
972 ["Food" => CFClient::Pickup::PU_FOOD],
973 ["Drinks" => CFClient::Pickup::PU_DRINK],
974 ["Valuables (Money, Gems)" => CFClient::Pickup::PU_VALUABLES],
975 ["Keys" => CFClient::Pickup::PU_KEY],
976 ["Magical Items" => CFClient::Pickup::PU_MAGICAL],
977 ["Potions" => CFClient::Pickup::PU_POTION],
978 ["Magic Devices" => CFClient::Pickup::PU_MAGIC_DEVICE],
979 ["Ignore cursed" => CFClient::Pickup::PU_NOT_CURSED],
980 ["Jewelery" => CFClient::Pickup::PU_JEWELS],
981 )
982 {
983 if (ref $_->[1]) {
984 $tbl = $_->[1];
985 $tblrow = 0;
986 $tbl->add (0, $tblrow++, new CFClient::UI::Label text => $_->[0], align => -1);
987 } elsif (not defined $_->[1]) {
988 $tbl->add (0, $tblrow++, new CFClient::UI::Label text => $_->[0], align => -1);
989 } else {
990 my $mask = $_->[1];
991 $tbl->add (0, $tblrow, new CFClient::UI::Label text => $_->[0], align => 1, expand => 1);
992 $tbl->add (1, $tblrow++, new CFClient::UI::CheckBox
993 state => $CFG->{pickup} & $mask,
994 on_changed => sub {
995 my ($box, $value) = @_;
996 if ($value) {
997 $::CFG->{pickup} |= $mask;
998 } else {
999 $::CFG->{pickup} = $::CFG->{pickup} & ~$mask;
1000 }
1001 $::CONN->send (sprintf "command pickup %u", $::CFG->{pickup})
1002 if defined $::CONN;
1003 });
1004 }
1005 }
1006
1007 $PICKUP_CFG
928} 1008}
929 1009
930sub make_inventory_window { 1010sub make_inventory_window {
931 my $invwin = $INV_WINDOW = new CFClient::UI::FancyFrame 1011 my $invwin = $INV_WINDOW = new CFClient::UI::FancyFrame
932 x => "center", 1012 x => "center",
1056 $BIND_WINDOW 1136 $BIND_WINDOW
1057} 1137}
1058 1138
1059sub make_help_window { 1139sub make_help_window {
1060 my $win = new CFClient::UI::FancyFrame 1140 my $win = new CFClient::UI::FancyFrame
1141 x => 'center',
1142 y => 'center',
1143 name => 'doc_browser',
1061 def_w => int $WIDTH * 7/8, 1144 force_w => int $WIDTH * 7/8,
1062 def_h => int $HEIGHT * 7/8, 1145 force_h => int $HEIGHT * 7/8,
1063 title => "Documentation"; 1146 title => "Documentation";
1064 1147
1065 $win->add (my $vbox = new CFClient::UI::VBox); 1148 $win->add (my $vbox = new CFClient::UI::VBox);
1066 1149
1067 $vbox->add (my $buttons = new CFClient::UI::HBox); 1150 $vbox->add (my $buttons = new CFClient::UI::HBox);
1068 $vbox->add (my $viewer = new CFClient::UI::TextView expand => 1, fontsize => 0.8); 1151 $vbox->add (my $viewer = new CFClient::UI::TextView expand => 1, fontsize => 0.8);
1149 force_y => "max", 1232 force_y => "max",
1150 child => $STATUSBOX, 1233 child => $STATUSBOX,
1151 )->show; 1234 )->show;
1152 1235
1153 CFClient::UI::FancyFrame->new ( 1236 CFClient::UI::FancyFrame->new (
1237 title => "Map",
1238 name => "mapmap",
1154 x => 0, 1239 x => 0,
1155 y => $FONTSIZE + 8, 1240 y => $FONTSIZE + 8,
1156 border_bg => [1, 1, 1, 192/255], 1241 border_bg => [1, 1, 1, 192/255],
1157 bg => [1, 1, 1, 0], 1242 bg => [1, 1, 1, 0],
1158 child => ($MAPMAP = new CFClient::MapWidget::MapMap 1243 child => ($MAPMAP = new CFClient::MapWidget::MapMap
1228 1313
1229 $BUTTONBAR->add (new CFClient::UI::Flopper 1314 $BUTTONBAR->add (new CFClient::UI::Flopper
1230 text => "Spells", 1315 text => "Spells",
1231 other => make_spell_list, 1316 other => make_spell_list,
1232 tooltip => "The spell list"); 1317 tooltip => "The spell list");
1318
1319 $BUTTONBAR->add (new CFClient::UI::Flopper
1320 text => "Pickup",
1321 other => make_pickup_cfg_window,
1322 tooltip => "The pickup dialog");
1323
1233 1324
1234 $BUTTONBAR->add (new CFClient::UI::Button 1325 $BUTTONBAR->add (new CFClient::UI::Button
1235 text => "Quit", 1326 text => "Quit",
1236 tooltip => "Terminates the program", 1327 tooltip => "Terminates the program",
1237 on_activate => sub { 1328 on_activate => sub {
1565=head1 USAGE 1656=head1 USAGE
1566 1657
1567cfplus utilises OpenGL for all UI elements and the game. It is supposed to be used 1658cfplus utilises OpenGL for all UI elements and the game. It is supposed to be used
1568fullscreen and interactively. 1659fullscreen and interactively.
1569 1660
1661=head1 DEBUGGING
1662
1663
1664CFPLUS_DEBUG - environment variable
1665
1666 1 draw borders around widgets
1667 2 add low-level widget info to tooltips
1668 4 show fps
1669 8 suppress tooltips
1670
1570=head1 AUTHOR 1671=head1 AUTHOR
1571 1672
1572Marc Lehmann <crossfire@schmorp.de>, Robin Redeker <elmex@ta-sa.org> 1673Marc Lehmann <crossfire@schmorp.de>, Robin Redeker <elmex@ta-sa.org>
1573 1674
1574 1675

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines