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.34 by elmex, Tue May 30 14:35:09 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;
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
863 }, 871 },
864 on_activate => sub { 872 on_activate => sub {
865 my ($input, $text) = @_; 873 my ($input, $text) = @_;
866 $input->set_text (''); 874 $input->set_text ('');
867 875
868 if ($text =~ /^\/bind\s+(.*)$/) {
869 CFClient::Binder::open_binding_dialog (sub {
870 my ($mod, $sym) = @_;
871 $::CFG->{bindings}->{$mod}->{$sym} = [$1];
872 });
873 } elsif ($text =~ /^\/(.*)/) { 876 if ($text =~ /^\/(.*)/) {
874 $::CONN->user_send ($1); 877 $::CONN->user_send ($1);
875 } else { 878 } else {
876 my $say_cmd = $::CFG->{say_command} || 'say'; 879 my $say_cmd = $::CFG->{say_command} || 'say';
877 $::CONN->user_send ("$say_cmd $text"); 880 $::CONN->user_send ("$say_cmd $text");
878 } 881 }
923 } 926 }
924 927
925 $QUIT_DIALOG->show; 928 $QUIT_DIALOG->show;
926} 929}
927 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
1008}
1009
928sub make_inventory_window { 1010sub make_inventory_window {
929 my $invwin = $INV_WINDOW = new CFClient::UI::FancyFrame 1011 my $invwin = $INV_WINDOW = new CFClient::UI::FancyFrame
930 x => "center", 1012 x => "center",
931 y => "center", 1013 y => "center",
932 force_w => $WIDTH * 9/10, 1014 force_w => $WIDTH * 9/10,
933 force_h => $HEIGHT * 9/10, 1015 force_h => $HEIGHT * 9/10,
934 title => "Inventory", 1016 title => "Inventory",
935 name => "inventory_window",
936 ; 1017 ;
937 1018
938 $invwin->add (my $hb = new CFClient::UI::HBox homogeneous => 1); 1019 $invwin->add (my $hb = new CFClient::UI::HBox homogeneous => 1);
939 1020
940 $hb->add (my $vb1 = new CFClient::UI::VBox); 1021 $hb->add (my $vb1 = new CFClient::UI::VBox);
949 1030
950 # XXX: Call after $INVR = ... because set_opencont sets the items 1031 # XXX: Call after $INVR = ... because set_opencont sets the items
951 CFClient::Protocol::set_opencont ($::CONN, 0, "Floor"); 1032 CFClient::Protocol::set_opencont ($::CONN, 0, "Floor");
952 1033
953 $invwin 1034 $invwin
1035}
1036
1037sub make_spell_list {
1038 $SPELL_LIST = new CFClient::UI::SpellList
1039 force_w => $WIDTH * (9/10),
1040 force_h => $HEIGHT * (9/10);
1041 $SPELL_LIST
954} 1042}
955 1043
956sub make_binding_window { 1044sub make_binding_window {
957 my $binding_list = new CFClient::UI::VBox; 1045 my $binding_list = new CFClient::UI::VBox;
958 1046
1012 my ($self, $visible) = @_; 1100 my ($self, $visible) = @_;
1013 $refresh->() if $visible; 1101 $refresh->() if $visible;
1014 }; 1102 };
1015 1103
1016 $BIND_WINDOW->add (my $vb = new CFClient::UI::VBox); 1104 $BIND_WINDOW->add (my $vb = new CFClient::UI::VBox);
1105 $vb->add ($binding_list);
1106 $vb->add (my $hb = new CFClient::UI::HBox);
1017 $vb->add (new CFClient::UI::Button 1107 $hb->add (new CFClient::UI::Button
1018 text => "record new", 1108 text => "record new",
1109 expand => 1,
1019 tooltip => "This button opens the binding editor with an empty binding.", 1110 tooltip => "This button opens the binding editor with an empty binding.",
1020 on_activate => sub { 1111 on_activate => sub {
1021 $::BIND_EDITOR->set_binding (undef, undef, [], 1112 $::BIND_EDITOR->set_binding (undef, undef, [],
1022 sub { 1113 sub {
1023 my ($mod, $sym, $cmds) = @_; 1114 my ($mod, $sym, $cmds) = @_;
1030 }); 1121 });
1031 $::BIND_WINDOW->hide; 1122 $::BIND_WINDOW->hide;
1032 $::BIND_EDITOR->show; 1123 $::BIND_EDITOR->show;
1033 }, 1124 },
1034 ); 1125 );
1035 $vb->add ($binding_list); 1126 $hb->add (new CFClient::UI::Button
1127 text => "close",
1128 tooltip => "Closes the binding window",
1129 expand => 1,
1130 on_activate => sub {
1131 $::BIND_WINDOW->hide;
1132 }
1133 );
1134
1036 $refresh->(); 1135 $refresh->();
1037 $BIND_WINDOW 1136 $BIND_WINDOW
1038} 1137}
1039 1138
1040sub make_help_window { 1139sub make_help_window {
1041 my $win = new CFClient::UI::FancyFrame 1140 my $win = new CFClient::UI::FancyFrame
1141 x => 'center',
1142 y => 'center',
1143 name => 'doc_browser',
1042 def_w => int $WIDTH * 7/8, 1144 force_w => int $WIDTH * 7/8,
1043 def_h => int $HEIGHT * 7/8, 1145 force_h => int $HEIGHT * 7/8,
1044 title => "Documentation"; 1146 title => "Documentation";
1045 1147
1046 $win->add (my $vbox = new CFClient::UI::VBox); 1148 $win->add (my $vbox = new CFClient::UI::VBox);
1047 1149
1048 $vbox->add (my $buttons = new CFClient::UI::HBox); 1150 $vbox->add (my $buttons = new CFClient::UI::HBox);
1049 $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);
1130 force_y => "max", 1232 force_y => "max",
1131 child => $STATUSBOX, 1233 child => $STATUSBOX,
1132 )->show; 1234 )->show;
1133 1235
1134 CFClient::UI::FancyFrame->new ( 1236 CFClient::UI::FancyFrame->new (
1237 title => "Map",
1238 name => "mapmap",
1135 x => 0, 1239 x => 0,
1136 y => $FONTSIZE + 8, 1240 y => $FONTSIZE + 8,
1137 border_bg => [1, 1, 1, 192/255], 1241 border_bg => [1, 1, 1, 192/255],
1138 bg => [1, 1, 1, 0], 1242 bg => [1, 1, 1, 0],
1139 child => ($MAPMAP = new CFClient::MapWidget::MapMap 1243 child => ($MAPMAP = new CFClient::MapWidget::MapMap
1178 make_gauge_window->show; # XXX: this has to be set before make_stats_window as make_stats_window calls update_stats_window which updated the gauges also X-D 1282 make_gauge_window->show; # XXX: this has to be set before make_stats_window as make_stats_window calls update_stats_window which updated the gauges also X-D
1179 1283
1180 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window, 1284 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window,
1181 tooltip => "Toggles the statistics window, where all your Stats and Resistances are being displayed at all times."); 1285 tooltip => "Toggles the statistics window, where all your Stats and Resistances are being displayed at all times.");
1182 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Inventory", other => make_inventory_window, 1286 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Inventory", other => make_inventory_window,
1183 tooltip => "Toggles the inventory window, where you can manage your loot (or treaures :)."); 1287 tooltip => "Toggles the inventory window, where you can manage your loot (or treaures :)."
1288 ."You can also hit the Tab-key to show/hide the Inventory.");
1184 1289
1185 $BUTTONBAR->add (new CFClient::UI::Button 1290 $BUTTONBAR->add (new CFClient::UI::Button
1186 text => "Save Config", 1291 text => "Save Config",
1187 tooltip => "Saves the options chosen in the client setting, server settings and the window layout to be restored on later runs.", 1292 tooltip => "Saves the options chosen in the client setting, server settings and the window layout to be restored on later runs.",
1188 on_activate => sub { 1293 on_activate => sub {
1196 tooltip => "View Documentation"); 1301 tooltip => "View Documentation");
1197 1302
1198 $BUTTONBAR->add (new CFClient::UI::Flopper 1303 $BUTTONBAR->add (new CFClient::UI::Flopper
1199 text => "Bindings", 1304 text => "Bindings",
1200 other => make_binding_window, 1305 other => make_binding_window,
1201 tooltip => "Lets you delete bindings you have made with the recorder" 1306 tooltip =>
1202 ); 1307 "Lets you define, edit and delete bindings."
1308 ."There is a shortcut for making bindings: LCTRL+Insert opens the binding editor "
1309 ."with nothing set and the recording started. After doing the actions you "
1310 ."want to record press Insert and you will be asked to press a key-combo."
1311 ."After pressing the combo the binding will be saved automatically and the "
1312 ."binding editor closes");
1313
1314 $BUTTONBAR->add (new CFClient::UI::Flopper
1315 text => "Spells",
1316 other => make_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
1203 1324
1204 $BUTTONBAR->add (new CFClient::UI::Button 1325 $BUTTONBAR->add (new CFClient::UI::Button
1205 text => "Quit", 1326 text => "Quit",
1206 tooltip => "Terminates the program", 1327 tooltip => "Terminates the program",
1207 on_activate => sub { 1328 on_activate => sub {
1535=head1 USAGE 1656=head1 USAGE
1536 1657
1537cfplus 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
1538fullscreen and interactively. 1659fullscreen and interactively.
1539 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
1540=head1 AUTHOR 1671=head1 AUTHOR
1541 1672
1542Marc Lehmann <crossfire@schmorp.de>, Robin Redeker <elmex@ta-sa.org> 1673Marc Lehmann <crossfire@schmorp.de>, Robin Redeker <elmex@ta-sa.org>
1543 1674
1544 1675

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines