… | |
… | |
81 | our $LOGVIEW; |
81 | our $LOGVIEW; |
82 | our $CONSOLE; |
82 | our $CONSOLE; |
83 | our $METASERVER; |
83 | our $METASERVER; |
84 | our $LOGIN_BUTTON; |
84 | our $LOGIN_BUTTON; |
85 | our $QUIT_DIALOG; |
85 | our $QUIT_DIALOG; |
|
|
86 | our $HOST_ENTRY; |
86 | our $SERVER_SETUP; |
87 | our $SERVER_SETUP; |
87 | |
88 | |
88 | our $FLOORBOX; |
89 | our $FLOORBOX; |
89 | our $GAUGES; |
90 | our $GAUGES; |
90 | our $STATWIDS; |
91 | our $STATWIDS; |
… | |
… | |
105 | our $INVR; |
106 | our $INVR; |
106 | our $INV_RIGHT_HB; |
107 | our $INV_RIGHT_HB; |
107 | |
108 | |
108 | our $BIND_WINDOW; |
109 | our $BIND_WINDOW; |
109 | our $BIND_EDITOR; |
110 | our $BIND_EDITOR; |
|
|
111 | |
|
|
112 | our $SPELL_LIST; |
|
|
113 | our $PICKUP_CFG; |
110 | |
114 | |
111 | sub status { |
115 | sub 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 | |
631 | sub 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 | |
|
|
641 | my $METASERVER_ATIME; |
635 | my $METASERVER_ATIME; |
642 | |
636 | |
643 | sub update_metaserver { |
637 | sub 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 | |
|
|
713 | sub 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 | |
720 | sub server_setup { |
730 | sub 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 | |
|
|
936 | sub 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 * 3/10, |
|
|
942 | force_h => $HEIGHT * 9/10; |
|
|
943 | |
|
|
944 | my $tbl = new CFClient::UI::Table; |
|
|
945 | my $tblrow = 0; |
|
|
946 | |
|
|
947 | $PICKUP_CFG->add (my $sw = new CFClient::UI::ScrolledWindow scrolled => $tbl, expand => 1); |
|
|
948 | |
|
|
949 | for ( |
|
|
950 | ["Enable (new) autopickup" => CFClient::Pickup::PU_NEWMODE], |
|
|
951 | ["Inhibit autopickup" => CFClient::Pickup::PU_INHIBIT], |
|
|
952 | ["Stop before pickup" => CFClient::Pickup::PU_STOP], |
|
|
953 | ["Debug autopickup" => CFClient::Pickup::PU_DEBUG], |
|
|
954 | ["Weapons"], |
|
|
955 | ["All weapons" => CFClient::Pickup::PU_ALLWEAPON], |
|
|
956 | ["Missile weapons" => CFClient::Pickup::PU_MISSILEWEAPON], |
|
|
957 | ["Bows" => CFClient::Pickup::PU_BOW], |
|
|
958 | ["Arrows" => CFClient::Pickup::PU_ARROW], |
|
|
959 | ["Armour"], |
|
|
960 | ["Helmets" => CFClient::Pickup::PU_HELMET], |
|
|
961 | ["Shields" => CFClient::Pickup::PU_SHIELD], |
|
|
962 | ["Body Armour" => CFClient::Pickup::PU_ARMOUR], |
|
|
963 | ["Boots" => CFClient::Pickup::PU_BOOTS], |
|
|
964 | ["Gloves" => CFClient::Pickup::PU_GLOVES], |
|
|
965 | ["Cloaks" => CFClient::Pickup::PU_CLOAK], |
|
|
966 | ["Readables"], |
|
|
967 | ["Spellbooks" => CFClient::Pickup::PU_SPELLBOOK], |
|
|
968 | ["Skillscrolls" => CFClient::Pickup::PU_SKILLSCROLL], |
|
|
969 | ["Normal Books/Scrolls" => CFClient::Pickup::PU_READABLES], |
|
|
970 | ["Misc"], |
|
|
971 | ["Food" => CFClient::Pickup::PU_FOOD], |
|
|
972 | ["Drinks" => CFClient::Pickup::PU_DRINK], |
|
|
973 | ["Valuables (Money, Gems)" => CFClient::Pickup::PU_VALUABLES], |
|
|
974 | ["Keys" => CFClient::Pickup::PU_KEY], |
|
|
975 | ["Magical Items" => CFClient::Pickup::PU_MAGICAL], |
|
|
976 | ["Potions" => CFClient::Pickup::PU_POTION], |
|
|
977 | ["Magic Devices" => CFClient::Pickup::PU_MAGIC_DEVICE], |
|
|
978 | ["Ignore cursed" => CFClient::Pickup::PU_NOT_CURSED], |
|
|
979 | ["Jewelery" => CFClient::Pickup::PU_JEWELS], |
|
|
980 | ) |
|
|
981 | { |
|
|
982 | unless (defined $_->[1]) { |
|
|
983 | $tbl->add (0, $tblrow++, new CFClient::UI::Label text => $_->[0], align => 0); |
|
|
984 | } else { |
|
|
985 | my $mask = $_->[1]; |
|
|
986 | $tbl->add (0, $tblrow, new CFClient::UI::Label text => $_->[0], align => -1); |
|
|
987 | $tbl->add (1, $tblrow++, new CFClient::UI::CheckBox |
|
|
988 | state => $CFG->{pickup} & $mask, |
|
|
989 | on_changed => sub { |
|
|
990 | my ($box, $value) = @_; |
|
|
991 | if ($value) { |
|
|
992 | $CFG->{pickup} |= $mask; |
|
|
993 | } else { |
|
|
994 | $CFG->{pickup} = $CFG->{pickup} & ~$mask; |
|
|
995 | } |
|
|
996 | $::CONN->send (sprintf "command pickup %u", $CFG->{pickup}); |
|
|
997 | }); |
|
|
998 | } |
|
|
999 | } |
|
|
1000 | |
|
|
1001 | $PICKUP_CFG |
|
|
1002 | } |
|
|
1003 | |
928 | sub make_inventory_window { |
1004 | sub make_inventory_window { |
929 | my $invwin = $INV_WINDOW = new CFClient::UI::FancyFrame |
1005 | my $invwin = $INV_WINDOW = new CFClient::UI::FancyFrame |
930 | x => "center", |
1006 | x => "center", |
931 | y => "center", |
1007 | y => "center", |
932 | force_w => $WIDTH * 9/10, |
1008 | force_w => $WIDTH * 9/10, |
933 | force_h => $HEIGHT * 9/10, |
1009 | force_h => $HEIGHT * 9/10, |
934 | title => "Inventory", |
1010 | title => "Inventory", |
935 | name => "inventory_window", |
|
|
936 | ; |
1011 | ; |
937 | |
1012 | |
938 | $invwin->add (my $hb = new CFClient::UI::HBox homogeneous => 1); |
1013 | $invwin->add (my $hb = new CFClient::UI::HBox homogeneous => 1); |
939 | |
1014 | |
940 | $hb->add (my $vb1 = new CFClient::UI::VBox); |
1015 | $hb->add (my $vb1 = new CFClient::UI::VBox); |
… | |
… | |
949 | |
1024 | |
950 | # XXX: Call after $INVR = ... because set_opencont sets the items |
1025 | # XXX: Call after $INVR = ... because set_opencont sets the items |
951 | CFClient::Protocol::set_opencont ($::CONN, 0, "Floor"); |
1026 | CFClient::Protocol::set_opencont ($::CONN, 0, "Floor"); |
952 | |
1027 | |
953 | $invwin |
1028 | $invwin |
|
|
1029 | } |
|
|
1030 | |
|
|
1031 | sub make_spell_list { |
|
|
1032 | $SPELL_LIST = new CFClient::UI::SpellList |
|
|
1033 | force_w => $WIDTH * (9/10), |
|
|
1034 | force_h => $HEIGHT * (9/10); |
|
|
1035 | $SPELL_LIST |
954 | } |
1036 | } |
955 | |
1037 | |
956 | sub make_binding_window { |
1038 | sub make_binding_window { |
957 | my $binding_list = new CFClient::UI::VBox; |
1039 | my $binding_list = new CFClient::UI::VBox; |
958 | |
1040 | |
… | |
… | |
1048 | $BIND_WINDOW |
1130 | $BIND_WINDOW |
1049 | } |
1131 | } |
1050 | |
1132 | |
1051 | sub make_help_window { |
1133 | sub make_help_window { |
1052 | my $win = new CFClient::UI::FancyFrame |
1134 | my $win = new CFClient::UI::FancyFrame |
|
|
1135 | x => 'center', |
|
|
1136 | y => 'center', |
|
|
1137 | name => 'doc_browser', |
1053 | def_w => int $WIDTH * 7/8, |
1138 | force_w => int $WIDTH * 7/8, |
1054 | def_h => int $HEIGHT * 7/8, |
1139 | force_h => int $HEIGHT * 7/8, |
1055 | title => "Documentation"; |
1140 | title => "Documentation"; |
1056 | |
1141 | |
1057 | $win->add (my $vbox = new CFClient::UI::VBox); |
1142 | $win->add (my $vbox = new CFClient::UI::VBox); |
1058 | |
1143 | |
1059 | $vbox->add (my $buttons = new CFClient::UI::HBox); |
1144 | $vbox->add (my $buttons = new CFClient::UI::HBox); |
1060 | $vbox->add (my $viewer = new CFClient::UI::TextView expand => 1, fontsize => 0.8); |
1145 | $vbox->add (my $viewer = new CFClient::UI::TextView expand => 1, fontsize => 0.8); |
… | |
… | |
1141 | force_y => "max", |
1226 | force_y => "max", |
1142 | child => $STATUSBOX, |
1227 | child => $STATUSBOX, |
1143 | )->show; |
1228 | )->show; |
1144 | |
1229 | |
1145 | CFClient::UI::FancyFrame->new ( |
1230 | CFClient::UI::FancyFrame->new ( |
|
|
1231 | title => "Mini Map", |
|
|
1232 | name => "mapmap", |
1146 | x => 0, |
1233 | x => 0, |
1147 | y => $FONTSIZE + 8, |
1234 | y => $FONTSIZE + 8, |
1148 | border_bg => [1, 1, 1, 192/255], |
1235 | border_bg => [1, 1, 1, 192/255], |
1149 | bg => [1, 1, 1, 0], |
1236 | bg => [1, 1, 1, 0], |
1150 | child => ($MAPMAP = new CFClient::MapWidget::MapMap |
1237 | child => ($MAPMAP = new CFClient::MapWidget::MapMap |
… | |
… | |
1214 | "Lets you define, edit and delete bindings." |
1301 | "Lets you define, edit and delete bindings." |
1215 | ."There is a shortcut for making bindings: LCTRL+Insert opens the binding editor " |
1302 | ."There is a shortcut for making bindings: LCTRL+Insert opens the binding editor " |
1216 | ."with nothing set and the recording started. After doing the actions you " |
1303 | ."with nothing set and the recording started. After doing the actions you " |
1217 | ."want to record press Insert and you will be asked to press a key-combo." |
1304 | ."want to record press Insert and you will be asked to press a key-combo." |
1218 | ."After pressing the combo the binding will be saved automatically and the " |
1305 | ."After pressing the combo the binding will be saved automatically and the " |
1219 | ."binding editor closes" |
1306 | ."binding editor closes"); |
1220 | ); |
1307 | |
|
|
1308 | $BUTTONBAR->add (new CFClient::UI::Flopper |
|
|
1309 | text => "Spells", |
|
|
1310 | other => make_spell_list, |
|
|
1311 | tooltip => "The spell list"); |
|
|
1312 | |
|
|
1313 | $BUTTONBAR->add (new CFClient::UI::Flopper |
|
|
1314 | text => "Pickup", |
|
|
1315 | other => make_pickup_cfg_window, |
|
|
1316 | tooltip => "The pickup dialog"); |
|
|
1317 | |
1221 | |
1318 | |
1222 | $BUTTONBAR->add (new CFClient::UI::Button |
1319 | $BUTTONBAR->add (new CFClient::UI::Button |
1223 | text => "Quit", |
1320 | text => "Quit", |
1224 | tooltip => "Terminates the program", |
1321 | tooltip => "Terminates the program", |
1225 | on_activate => sub { |
1322 | on_activate => sub { |
… | |
… | |
1553 | =head1 USAGE |
1650 | =head1 USAGE |
1554 | |
1651 | |
1555 | cfplus utilises OpenGL for all UI elements and the game. It is supposed to be used |
1652 | cfplus utilises OpenGL for all UI elements and the game. It is supposed to be used |
1556 | fullscreen and interactively. |
1653 | fullscreen and interactively. |
1557 | |
1654 | |
|
|
1655 | =head1 DEBUGGING |
|
|
1656 | |
|
|
1657 | |
|
|
1658 | CFPLUS_DEBUG - environment variable |
|
|
1659 | |
|
|
1660 | 1 draw borders around widgets |
|
|
1661 | 2 add low-level widget info to tooltips |
|
|
1662 | 4 show fps |
|
|
1663 | 8 suppress tooltips |
|
|
1664 | |
1558 | =head1 AUTHOR |
1665 | =head1 AUTHOR |
1559 | |
1666 | |
1560 | Marc Lehmann <crossfire@schmorp.de>, Robin Redeker <elmex@ta-sa.org> |
1667 | Marc Lehmann <crossfire@schmorp.de>, Robin Redeker <elmex@ta-sa.org> |
1561 | |
1668 | |
1562 | |
1669 | |