… | |
… | |
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; |
… | |
… | |
107 | |
108 | |
108 | our $BIND_WINDOW; |
109 | our $BIND_WINDOW; |
109 | our $BIND_EDITOR; |
110 | our $BIND_EDITOR; |
110 | |
111 | |
111 | our $SPELL_LIST; |
112 | our $SPELL_LIST; |
|
|
113 | our $PICKUP_CFG; |
112 | |
114 | |
113 | sub status { |
115 | sub 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 | |
633 | sub 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 | |
|
|
643 | my $METASERVER_ATIME; |
635 | my $METASERVER_ATIME; |
644 | |
636 | |
645 | sub update_metaserver { |
637 | sub 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 | |
|
|
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 | |
722 | sub server_setup { |
730 | sub 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 | |
|
|
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 |
928 | } |
1002 | } |
929 | |
1003 | |
930 | sub make_inventory_window { |
1004 | sub make_inventory_window { |
931 | my $invwin = $INV_WINDOW = new CFClient::UI::FancyFrame |
1005 | my $invwin = $INV_WINDOW = new CFClient::UI::FancyFrame |
932 | x => "center", |
1006 | x => "center", |
… | |
… | |
1056 | $BIND_WINDOW |
1130 | $BIND_WINDOW |
1057 | } |
1131 | } |
1058 | |
1132 | |
1059 | sub make_help_window { |
1133 | sub make_help_window { |
1060 | my $win = new CFClient::UI::FancyFrame |
1134 | my $win = new CFClient::UI::FancyFrame |
|
|
1135 | x => 'center', |
|
|
1136 | y => 'center', |
|
|
1137 | name => 'doc_browser', |
1061 | def_w => int $WIDTH * 7/8, |
1138 | force_w => int $WIDTH * 7/8, |
1062 | def_h => int $HEIGHT * 7/8, |
1139 | force_h => int $HEIGHT * 7/8, |
1063 | title => "Documentation"; |
1140 | title => "Documentation"; |
1064 | |
1141 | |
1065 | $win->add (my $vbox = new CFClient::UI::VBox); |
1142 | $win->add (my $vbox = new CFClient::UI::VBox); |
1066 | |
1143 | |
1067 | $vbox->add (my $buttons = new CFClient::UI::HBox); |
1144 | $vbox->add (my $buttons = new CFClient::UI::HBox); |
1068 | $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); |
… | |
… | |
1149 | force_y => "max", |
1226 | force_y => "max", |
1150 | child => $STATUSBOX, |
1227 | child => $STATUSBOX, |
1151 | )->show; |
1228 | )->show; |
1152 | |
1229 | |
1153 | CFClient::UI::FancyFrame->new ( |
1230 | CFClient::UI::FancyFrame->new ( |
|
|
1231 | title => "Mini Map", |
|
|
1232 | name => "mapmap", |
1154 | x => 0, |
1233 | x => 0, |
1155 | y => $FONTSIZE + 8, |
1234 | y => $FONTSIZE + 8, |
1156 | border_bg => [1, 1, 1, 192/255], |
1235 | border_bg => [1, 1, 1, 192/255], |
1157 | bg => [1, 1, 1, 0], |
1236 | bg => [1, 1, 1, 0], |
1158 | child => ($MAPMAP = new CFClient::MapWidget::MapMap |
1237 | child => ($MAPMAP = new CFClient::MapWidget::MapMap |
… | |
… | |
1228 | |
1307 | |
1229 | $BUTTONBAR->add (new CFClient::UI::Flopper |
1308 | $BUTTONBAR->add (new CFClient::UI::Flopper |
1230 | text => "Spells", |
1309 | text => "Spells", |
1231 | other => make_spell_list, |
1310 | other => make_spell_list, |
1232 | tooltip => "The 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 | |
1233 | |
1318 | |
1234 | $BUTTONBAR->add (new CFClient::UI::Button |
1319 | $BUTTONBAR->add (new CFClient::UI::Button |
1235 | text => "Quit", |
1320 | text => "Quit", |
1236 | tooltip => "Terminates the program", |
1321 | tooltip => "Terminates the program", |
1237 | on_activate => sub { |
1322 | on_activate => sub { |
… | |
… | |
1565 | =head1 USAGE |
1650 | =head1 USAGE |
1566 | |
1651 | |
1567 | 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 |
1568 | fullscreen and interactively. |
1653 | fullscreen and interactively. |
1569 | |
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 | |
1570 | =head1 AUTHOR |
1665 | =head1 AUTHOR |
1571 | |
1666 | |
1572 | Marc Lehmann <crossfire@schmorp.de>, Robin Redeker <elmex@ta-sa.org> |
1667 | Marc Lehmann <crossfire@schmorp.de>, Robin Redeker <elmex@ta-sa.org> |
1573 | |
1668 | |
1574 | |
1669 | |