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.37 by elmex, Wed May 31 10:15:34 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;
105our $INVR; 106our $INVR;
106our $INV_RIGHT_HB; 107our $INV_RIGHT_HB;
107 108
108our $BIND_WINDOW; 109our $BIND_WINDOW;
109our $BIND_EDITOR; 110our $BIND_EDITOR;
111
112our $SPELL_LIST;
113our $PICKUP_CFG;
110 114
111sub status { 115sub status {
112 $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]);
113} 117}
114 118
626 630
627 $STATWIDS->{"res_$_"}->set_text (sprintf "%d%", $stats->{$tbl{$_}}) 631 $STATWIDS->{"res_$_"}->set_text (sprintf "%d%", $stats->{$tbl{$_}})
628 for keys %tbl; 632 for keys %tbl;
629} 633}
630 634
631sub metaserver_dialog {
632 my $dialog = new CFClient::UI::FancyFrame
633 title => "Server List",
634 child => (my $vbox = new CFClient::UI::VBox);
635
636 $vbox->add ($dialog->{table} = new CFClient::UI::Table);
637
638 $dialog
639}
640
641my $METASERVER_ATIME; 635my $METASERVER_ATIME;
642 636
643sub update_metaserver { 637sub update_metaserver {
644 my ($HOST) = @_;
645
646 return if $METASERVER_ATIME > time; 638 return if $METASERVER_ATIME > time;
647 $METASERVER_ATIME = time + 60; 639 $METASERVER_ATIME = time + 60;
648 640
649 my $table = $METASERVER->{table}; 641 my $table = $METASERVER->{table};
650 $table->clear; 642 $table->clear;
702 694
703 $y++; 695 $y++;
704 696
705 $table->add (0, $y, new CFClient::UI::VBox children => [ 697 $table->add (0, $y, new CFClient::UI::VBox children => [
706 (new CFClient::UI::Button text => "Use", on_activate => sub { 698 (new CFClient::UI::Button text => "Use", on_activate => sub {
707 $HOST->set_text ($CFG->{host} = $host); 699 $HOST_ENTRY->set_text ($CFG->{host} = $host);
700 $METASERVER->toggle_visibility;
708 }), 701 }),
709 (new CFClient::UI::Empty expand => 1), 702 (new CFClient::UI::Empty expand => 1),
710 ]); 703 ]);
711 704
712 $table->add ($_ + 1, $y, new CFClient::UI::Label 705 $table->add ($_ + 1, $y, new CFClient::UI::Label
715 } 708 }
716 } 709 }
717 }); 710 });
718} 711}
719 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
720sub server_setup { 730sub server_setup {
721 my $dialog = $SERVER_SETUP = new CFClient::UI::FancyFrame 731 my $dialog = $SERVER_SETUP = new CFClient::UI::FancyFrame
722 x => "center", 732 x => "center",
723 y => "center", 733 y => "center",
724 name => "server_setup", 734 name => "server_setup",
731 741
732 { 742 {
733 $table->add (1, 2, my $vbox = new CFClient::UI::VBox); 743 $table->add (1, 2, my $vbox = new CFClient::UI::VBox);
734 744
735 $vbox->add ( 745 $vbox->add (
736 my $HOST = new CFClient::UI::Entry 746 $HOST_ENTRY = new CFClient::UI::Entry
737 expand => 1, 747 expand => 1,
738 text => $CFG->{host}, 748 text => $CFG->{host},
739 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",
740 on_changed => sub { 750 on_changed => sub {
741 my ($self, $value) = @_; 751 my ($self, $value) = @_;
743 } 753 }
744 ); 754 );
745 755
746 $METASERVER = metaserver_dialog; 756 $METASERVER = metaserver_dialog;
747 757
748 $vbox->add (new CFClient::UI::Flopper 758 $vbox->add (new CFClient::UI::Button
749 expand => 1, 759 expand => 1,
750 text => "Server List", 760 text => "Server List",
751 other => $METASERVER, 761 other => $METASERVER,
752 tooltip => "Show a list of available crossfire servers", 762 tooltip => "Show a list of available crossfire servers",
753 on_open => sub { 763 on_activate => sub { $METASERVER->toggle_visibility },
754 update_metaserver $HOST;
755 }
756 ); 764 );
757 } 765 }
758 766
759 $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");
760 $table->add (1, 4, new CFClient::UI::Entry 768 $table->add (1, 4, new CFClient::UI::Entry
923 } 931 }
924 932
925 $QUIT_DIALOG->show; 933 $QUIT_DIALOG->show;
926} 934}
927 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
1013}
1014
928sub make_inventory_window { 1015sub make_inventory_window {
929 my $invwin = $INV_WINDOW = new CFClient::UI::FancyFrame 1016 my $invwin = $INV_WINDOW = new CFClient::UI::FancyFrame
930 x => "center", 1017 x => "center",
931 y => "center", 1018 y => "center",
932 force_w => $WIDTH * 9/10, 1019 force_w => $WIDTH * 9/10,
948 1035
949 # XXX: Call after $INVR = ... because set_opencont sets the items 1036 # XXX: Call after $INVR = ... because set_opencont sets the items
950 CFClient::Protocol::set_opencont ($::CONN, 0, "Floor"); 1037 CFClient::Protocol::set_opencont ($::CONN, 0, "Floor");
951 1038
952 $invwin 1039 $invwin
1040}
1041
1042sub make_spell_list {
1043 $SPELL_LIST = new CFClient::UI::SpellList
1044 force_w => $WIDTH * (9/10),
1045 force_h => $HEIGHT * (9/10);
1046 $SPELL_LIST
953} 1047}
954 1048
955sub make_binding_window { 1049sub make_binding_window {
956 my $binding_list = new CFClient::UI::VBox; 1050 my $binding_list = new CFClient::UI::VBox;
957 1051
1047 $BIND_WINDOW 1141 $BIND_WINDOW
1048} 1142}
1049 1143
1050sub make_help_window { 1144sub make_help_window {
1051 my $win = new CFClient::UI::FancyFrame 1145 my $win = new CFClient::UI::FancyFrame
1146 x => 'center',
1147 y => 'center',
1148 name => 'doc_browser',
1052 def_w => int $WIDTH * 7/8, 1149 force_w => int $WIDTH * 7/8,
1053 def_h => int $HEIGHT * 7/8, 1150 force_h => int $HEIGHT * 7/8,
1054 title => "Documentation"; 1151 title => "Documentation";
1055 1152
1056 $win->add (my $vbox = new CFClient::UI::VBox); 1153 $win->add (my $vbox = new CFClient::UI::VBox);
1057 1154
1058 $vbox->add (my $buttons = new CFClient::UI::HBox); 1155 $vbox->add (my $buttons = new CFClient::UI::HBox);
1059 $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);
1140 force_y => "max", 1237 force_y => "max",
1141 child => $STATUSBOX, 1238 child => $STATUSBOX,
1142 )->show; 1239 )->show;
1143 1240
1144 CFClient::UI::FancyFrame->new ( 1241 CFClient::UI::FancyFrame->new (
1242 title => "Mini Map",
1243 name => "mapmap",
1145 x => 0, 1244 x => 0,
1146 y => $FONTSIZE + 8, 1245 y => $FONTSIZE + 8,
1147 border_bg => [1, 1, 1, 192/255], 1246 border_bg => [1, 1, 1, 192/255],
1148 bg => [1, 1, 1, 0], 1247 bg => [1, 1, 1, 0],
1149 child => ($MAPMAP = new CFClient::MapWidget::MapMap 1248 child => ($MAPMAP = new CFClient::MapWidget::MapMap
1213 "Lets you define, edit and delete bindings." 1312 "Lets you define, edit and delete bindings."
1214 ."There is a shortcut for making bindings: LCTRL+Insert opens the binding editor " 1313 ."There is a shortcut for making bindings: LCTRL+Insert opens the binding editor "
1215 ."with nothing set and the recording started. After doing the actions you " 1314 ."with nothing set and the recording started. After doing the actions you "
1216 ."want to record press Insert and you will be asked to press a key-combo." 1315 ."want to record press Insert and you will be asked to press a key-combo."
1217 ."After pressing the combo the binding will be saved automatically and the " 1316 ."After pressing the combo the binding will be saved automatically and the "
1218 ."binding editor closes" 1317 ."binding editor closes");
1219 ); 1318
1319 $BUTTONBAR->add (new CFClient::UI::Flopper
1320 text => "Spells",
1321 other => make_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
1220 1329
1221 $BUTTONBAR->add (new CFClient::UI::Button 1330 $BUTTONBAR->add (new CFClient::UI::Button
1222 text => "Quit", 1331 text => "Quit",
1223 tooltip => "Terminates the program", 1332 tooltip => "Terminates the program",
1224 on_activate => sub { 1333 on_activate => sub {
1552=head1 USAGE 1661=head1 USAGE
1553 1662
1554cfplus 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
1555fullscreen and interactively. 1664fullscreen and interactively.
1556 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
1557=head1 AUTHOR 1676=head1 AUTHOR
1558 1677
1559Marc Lehmann <crossfire@schmorp.de>, Robin Redeker <elmex@ta-sa.org> 1678Marc Lehmann <crossfire@schmorp.de>, Robin Redeker <elmex@ta-sa.org>
1560 1679
1561 1680

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines