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.45 by elmex, Fri Jun 2 16:52:49 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
923 on_activate => sub { exit }, 929 on_activate => sub { exit },
924 ); 930 );
925 } 931 }
926 932
927 $QUIT_DIALOG->show; 933 $QUIT_DIALOG->show;
934}
935
936sub make_pickup_cfg_window {
937 $PICKUP_CFG = new CFClient::UI::FancyFrame
938 title => "Autopickup configuration",
939 x => "center",
940 y => "center",
941 force_w => $WIDTH * 6/10,
942 force_h => $HEIGHT * 9/10;
943
944
945 $PICKUP_CFG->add (my $vb = new CFClient::UI::VBox);
946 $vb->add (my $gen_tbl = new CFClient::UI::Table expand => 1);
947 $vb->add (my $hb = new CFClient::UI::HBox expand => 1);
948 $hb->add (my $ltbl = new CFClient::UI::Table expand => 1);
949 $hb->add (my $rtbl = new CFClient::UI::Table expand => 1);
950
951 my $tbl = 0;
952 my $tblrow = 0;
953
954 for (
955 ["General", $gen_tbl],
956 ["Enable autopickup" => CFClient::Pickup::PU_NEWMODE],
957 ["Inhibit autopickup" => CFClient::Pickup::PU_INHIBIT],
958 ["Stop before pickup" => CFClient::Pickup::PU_STOP],
959 ["Debug autopickup" => CFClient::Pickup::PU_DEBUG],
960 ["Weapons", $ltbl],
961 ["All weapons" => CFClient::Pickup::PU_ALLWEAPON],
962 ["Missile weapons" => CFClient::Pickup::PU_MISSILEWEAPON],
963 ["Bows" => CFClient::Pickup::PU_BOW],
964 ["Arrows" => CFClient::Pickup::PU_ARROW],
965 ["Armour"],
966 ["Helmets" => CFClient::Pickup::PU_HELMET],
967 ["Shields" => CFClient::Pickup::PU_SHIELD],
968 ["Body Armour" => CFClient::Pickup::PU_ARMOUR],
969 ["Boots" => CFClient::Pickup::PU_BOOTS],
970 ["Gloves" => CFClient::Pickup::PU_GLOVES],
971 ["Cloaks" => CFClient::Pickup::PU_CLOAK],
972 ["Readables", $rtbl],
973 ["Spellbooks" => CFClient::Pickup::PU_SPELLBOOK],
974 ["Skillscrolls" => CFClient::Pickup::PU_SKILLSCROLL],
975 ["Normal Books/Scrolls" => CFClient::Pickup::PU_READABLES],
976 ["Misc"],
977 ["Food" => CFClient::Pickup::PU_FOOD],
978 ["Drinks" => CFClient::Pickup::PU_DRINK],
979 ["Valuables (Money, Gems)" => CFClient::Pickup::PU_VALUABLES],
980 ["Keys" => CFClient::Pickup::PU_KEY],
981 ["Magical Items" => CFClient::Pickup::PU_MAGICAL],
982 ["Potions" => CFClient::Pickup::PU_POTION],
983 ["Magic Devices" => CFClient::Pickup::PU_MAGIC_DEVICE],
984 ["Ignore cursed" => CFClient::Pickup::PU_NOT_CURSED],
985 ["Jewelery" => CFClient::Pickup::PU_JEWELS],
986 )
987 {
988 if (ref $_->[1]) {
989 $tbl = $_->[1];
990 $tblrow = 0;
991 $tbl->add (0, $tblrow++, new CFClient::UI::Label text => $_->[0], align => -1);
992 } elsif (not defined $_->[1]) {
993 $tbl->add (0, $tblrow++, new CFClient::UI::Label text => $_->[0], align => -1);
994 } else {
995 my $mask = $_->[1];
996 $tbl->add (0, $tblrow, new CFClient::UI::Label text => $_->[0], align => 1, expand => 1);
997 $tbl->add (1, $tblrow++, new CFClient::UI::CheckBox
998 state => $CFG->{pickup} & $mask,
999 on_changed => sub {
1000 my ($box, $value) = @_;
1001 if ($value) {
1002 $::CFG->{pickup} |= $mask;
1003 } else {
1004 $::CFG->{pickup} = $::CFG->{pickup} & ~$mask;
1005 }
1006 $::CONN->send (sprintf "command pickup %u", $::CFG->{pickup})
1007 if defined $::CONN;
1008 });
1009 }
1010 }
1011
1012 $PICKUP_CFG
928} 1013}
929 1014
930sub make_inventory_window { 1015sub make_inventory_window {
931 my $invwin = $INV_WINDOW = new CFClient::UI::FancyFrame 1016 my $invwin = $INV_WINDOW = new CFClient::UI::FancyFrame
932 x => "center", 1017 x => "center",
1056 $BIND_WINDOW 1141 $BIND_WINDOW
1057} 1142}
1058 1143
1059sub make_help_window { 1144sub make_help_window {
1060 my $win = new CFClient::UI::FancyFrame 1145 my $win = new CFClient::UI::FancyFrame
1146 x => 'center',
1147 y => 'center',
1148 name => 'doc_browser',
1061 def_w => int $WIDTH * 7/8, 1149 force_w => int $WIDTH * 7/8,
1062 def_h => int $HEIGHT * 7/8, 1150 force_h => int $HEIGHT * 7/8,
1063 title => "Documentation"; 1151 title => "Documentation";
1064 1152
1065 $win->add (my $vbox = new CFClient::UI::VBox); 1153 $win->add (my $vbox = new CFClient::UI::VBox);
1066 1154
1067 $vbox->add (my $buttons = new CFClient::UI::HBox); 1155 $vbox->add (my $buttons = new CFClient::UI::HBox);
1068 $vbox->add (my $viewer = new CFClient::UI::TextView expand => 1, fontsize => 0.8); 1156 $vbox->add (my $viewer = new CFClient::UI::TextView expand => 1, fontsize => 0.8);
1149 force_y => "max", 1237 force_y => "max",
1150 child => $STATUSBOX, 1238 child => $STATUSBOX,
1151 )->show; 1239 )->show;
1152 1240
1153 CFClient::UI::FancyFrame->new ( 1241 CFClient::UI::FancyFrame->new (
1242 title => "Mini Map",
1243 name => "mapmap",
1154 x => 0, 1244 x => 0,
1155 y => $FONTSIZE + 8, 1245 y => $FONTSIZE + 8,
1156 border_bg => [1, 1, 1, 192/255], 1246 border_bg => [1, 1, 1, 192/255],
1157 bg => [1, 1, 1, 0], 1247 bg => [1, 1, 1, 0],
1158 child => ($MAPMAP = new CFClient::MapWidget::MapMap 1248 child => ($MAPMAP = new CFClient::MapWidget::MapMap
1228 1318
1229 $BUTTONBAR->add (new CFClient::UI::Flopper 1319 $BUTTONBAR->add (new CFClient::UI::Flopper
1230 text => "Spells", 1320 text => "Spells",
1231 other => make_spell_list, 1321 other => make_spell_list,
1232 tooltip => "The spell list"); 1322 tooltip => "The spell list");
1323
1324 $BUTTONBAR->add (new CFClient::UI::Flopper
1325 text => "Pickup",
1326 other => make_pickup_cfg_window,
1327 tooltip => "The pickup dialog");
1328
1233 1329
1234 $BUTTONBAR->add (new CFClient::UI::Button 1330 $BUTTONBAR->add (new CFClient::UI::Button
1235 text => "Quit", 1331 text => "Quit",
1236 tooltip => "Terminates the program", 1332 tooltip => "Terminates the program",
1237 on_activate => sub { 1333 on_activate => sub {
1565=head1 USAGE 1661=head1 USAGE
1566 1662
1567cfplus utilises OpenGL for all UI elements and the game. It is supposed to be used 1663cfplus utilises OpenGL for all UI elements and the game. It is supposed to be used
1568fullscreen and interactively. 1664fullscreen and interactively.
1569 1665
1666=head1 DEBUGGING
1667
1668
1669CFPLUS_DEBUG - environment variable
1670
1671 1 draw borders around widgets
1672 2 add low-level widget info to tooltips
1673 4 show fps
1674 8 suppress tooltips
1675
1570=head1 AUTHOR 1676=head1 AUTHOR
1571 1677
1572Marc Lehmann <crossfire@schmorp.de>, Robin Redeker <elmex@ta-sa.org> 1678Marc Lehmann <crossfire@schmorp.de>, Robin Redeker <elmex@ta-sa.org>
1573 1679
1574 1680

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines