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.33 by root, Tue May 30 07:13:09 2006 UTC vs.
Revision 1.40 by root, Fri Jun 2 02:12:04 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;
104our $INV; 105our $INV;
105our $INVR; 106our $INVR;
106our $INV_RIGHT_HB; 107our $INV_RIGHT_HB;
107 108
108our $BIND_WINDOW; 109our $BIND_WINDOW;
110our $BIND_EDITOR;
111
112our $SPELL_LIST;
109 113
110sub status { 114sub status {
111 $STATUSBOX->add (CFClient::UI::Label::escape $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); 115 $STATUSBOX->add (CFClient::UI::Label::escape $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]);
112} 116}
113 117
625 629
626 $STATWIDS->{"res_$_"}->set_text (sprintf "%d%", $stats->{$tbl{$_}}) 630 $STATWIDS->{"res_$_"}->set_text (sprintf "%d%", $stats->{$tbl{$_}})
627 for keys %tbl; 631 for keys %tbl;
628} 632}
629 633
630sub metaserver_dialog {
631 my $dialog = new CFClient::UI::FancyFrame
632 title => "Server List",
633 child => (my $vbox = new CFClient::UI::VBox);
634
635 $vbox->add ($dialog->{table} = new CFClient::UI::Table);
636
637 $dialog
638}
639
640my $METASERVER_ATIME; 634my $METASERVER_ATIME;
641 635
642sub update_metaserver { 636sub update_metaserver {
643 my ($HOST) = @_;
644
645 return if $METASERVER_ATIME > time; 637 return if $METASERVER_ATIME > time;
646 $METASERVER_ATIME = time + 60; 638 $METASERVER_ATIME = time + 60;
647 639
648 my $table = $METASERVER->{table}; 640 my $table = $METASERVER->{table};
649 $table->clear; 641 $table->clear;
701 693
702 $y++; 694 $y++;
703 695
704 $table->add (0, $y, new CFClient::UI::VBox children => [ 696 $table->add (0, $y, new CFClient::UI::VBox children => [
705 (new CFClient::UI::Button text => "Use", on_activate => sub { 697 (new CFClient::UI::Button text => "Use", on_activate => sub {
706 $HOST->set_text ($CFG->{host} = $host); 698 $HOST_ENTRY->set_text ($CFG->{host} = $host);
699 $METASERVER->toggle_visibility;
707 }), 700 }),
708 (new CFClient::UI::Empty expand => 1), 701 (new CFClient::UI::Empty expand => 1),
709 ]); 702 ]);
710 703
711 $table->add ($_ + 1, $y, new CFClient::UI::Label 704 $table->add ($_ + 1, $y, new CFClient::UI::Label
714 } 707 }
715 } 708 }
716 }); 709 });
717} 710}
718 711
712sub metaserver_dialog {
713 my $dialog = new CFClient::UI::FancyFrame
714 title => "Server List",
715 x => 'center',
716 y => 'center',
717 child => (my $vbox = new CFClient::UI::VBox),
718 on_visibility_change => sub {
719 update_metaserver if $_[1];
720 },
721 ;
722
723 $vbox->add ($dialog->{table} = new CFClient::UI::Table);
724
725 $dialog
726}
727
719sub server_setup { 728sub server_setup {
720 my $dialog = $SERVER_SETUP = new CFClient::UI::FancyFrame 729 my $dialog = $SERVER_SETUP = new CFClient::UI::FancyFrame
721 x => "center", 730 x => "center",
722 y => "center", 731 y => "center",
723 name => "server_setup", 732 name => "server_setup",
730 739
731 { 740 {
732 $table->add (1, 2, my $vbox = new CFClient::UI::VBox); 741 $table->add (1, 2, my $vbox = new CFClient::UI::VBox);
733 742
734 $vbox->add ( 743 $vbox->add (
735 my $HOST = new CFClient::UI::Entry 744 $HOST_ENTRY = new CFClient::UI::Entry
736 expand => 1, 745 expand => 1,
737 text => $CFG->{host}, 746 text => $CFG->{host},
738 tooltip => "The hostname or ip address of the Crossfire(+) server to connect to", 747 tooltip => "The hostname or ip address of the Crossfire(+) server to connect to",
739 on_changed => sub { 748 on_changed => sub {
740 my ($self, $value) = @_; 749 my ($self, $value) = @_;
742 } 751 }
743 ); 752 );
744 753
745 $METASERVER = metaserver_dialog; 754 $METASERVER = metaserver_dialog;
746 755
747 $vbox->add (new CFClient::UI::Flopper 756 $vbox->add (new CFClient::UI::Button
748 expand => 1, 757 expand => 1,
749 text => "Server List", 758 text => "Server List",
750 other => $METASERVER, 759 other => $METASERVER,
751 tooltip => "Show a list of available crossfire servers", 760 tooltip => "Show a list of available crossfire servers",
752 on_open => sub { 761 on_activate => sub { $METASERVER->toggle_visibility },
753 update_metaserver $HOST;
754 }
755 ); 762 );
756 } 763 }
757 764
758 $table->add (0, 4, new CFClient::UI::Label valign => 0, align => 1, text => "Username"); 765 $table->add (0, 4, new CFClient::UI::Label valign => 0, align => 1, text => "Username");
759 $table->add (1, 4, new CFClient::UI::Entry 766 $table->add (1, 4, new CFClient::UI::Entry
863 on_activate => sub { 870 on_activate => sub {
864 my ($input, $text) = @_; 871 my ($input, $text) = @_;
865 $input->set_text (''); 872 $input->set_text ('');
866 873
867 if ($text =~ /^\/bind\s+(.*)$/) { 874 if ($text =~ /^\/bind\s+(.*)$/) {
868 CFClient::Recorder::open_binding_dialog ([$1]); 875 CFClient::Binder::open_binding_dialog (sub {
876 my ($mod, $sym) = @_;
877 $::CFG->{bindings}->{$mod}->{$sym} = [$1];
878 });
869 } elsif ($text =~ /^\/(.*)/) { 879 } elsif ($text =~ /^\/(.*)/) {
870 $::CONN->user_send ($1); 880 $::CONN->user_send ($1);
871 } else { 881 } else {
872 my $say_cmd = $::CFG->{say_command} || 'say'; 882 my $say_cmd = $::CFG->{say_command} || 'say';
873 $::CONN->user_send ("$say_cmd $text"); 883 $::CONN->user_send ("$say_cmd $text");
926 x => "center", 936 x => "center",
927 y => "center", 937 y => "center",
928 force_w => $WIDTH * 9/10, 938 force_w => $WIDTH * 9/10,
929 force_h => $HEIGHT * 9/10, 939 force_h => $HEIGHT * 9/10,
930 title => "Inventory", 940 title => "Inventory",
931 name => "inventory_window",
932 ; 941 ;
933 942
934 $invwin->add (my $hb = new CFClient::UI::HBox homogeneous => 1); 943 $invwin->add (my $hb = new CFClient::UI::HBox homogeneous => 1);
935 944
936 $hb->add (my $vb1 = new CFClient::UI::VBox); 945 $hb->add (my $vb1 = new CFClient::UI::VBox);
947 CFClient::Protocol::set_opencont ($::CONN, 0, "Floor"); 956 CFClient::Protocol::set_opencont ($::CONN, 0, "Floor");
948 957
949 $invwin 958 $invwin
950} 959}
951 960
961sub make_spell_list {
962 $SPELL_LIST = new CFClient::UI::SpellList
963 force_w => $WIDTH * (9/10),
964 force_h => $HEIGHT * (9/10);
965 $SPELL_LIST
966}
967
952sub make_binding_window { 968sub make_binding_window {
953 my $binding_list = new CFClient::UI::VBox; 969 my $binding_list = new CFClient::UI::VBox;
954 970
971 my $refresh;
955 my $refresh = sub { 972 $refresh = sub {
956 $binding_list->clear (); 973 $binding_list->clear ();
957 974
958 for my $mod (keys %{$::CFG->{bindings}}) { 975 for my $mod (keys %{$::CFG->{bindings}}) {
959 for my $sym (keys %{$::CFG->{bindings}->{$mod}}) { 976 for my $sym (keys %{$::CFG->{bindings}->{$mod}}) {
960 my $cmds = $::CFG->{bindings}->{$mod}->{$sym}; 977 my $cmds = $::CFG->{bindings}->{$mod}->{$sym};
961 next unless ref $cmds eq 'ARRAY' and @$cmds > 0; 978 next unless ref $cmds eq 'ARRAY' and @$cmds > 0;
962 979
963 my $lbl = join "; ", @$cmds; 980 my $lbl = join "; ", @$cmds;
964 my $nam = CFClient::Recorder::keycombo_to_name ($mod, $sym); 981 my $nam = CFClient::Binder::keycombo_to_name ($mod, $sym);
965 $binding_list->add (my $hb = new CFClient::UI::HBox); 982 $binding_list->add (my $hb = new CFClient::UI::HBox);
966 $hb->add (new CFClient::UI::Button 983 $hb->add (new CFClient::UI::Button
967 text => "delete", 984 text => "delete",
985 tooltip => "Deletes the binding",
968 on_activate => sub { 986 on_activate => sub {
969 $binding_list->remove ($hb); 987 $binding_list->remove ($hb);
970 delete $::CFG->{bindings}->{$mod}->{$sym}; 988 delete $::CFG->{bindings}->{$mod}->{$sym};
971 }); 989 });
990
991 $hb->add (new CFClient::UI::Button
992 text => "edit",
993 tooltip => "Edits the binding",
994 on_activate => sub {
995 $::BIND_EDITOR->set_binding (
996 $mod, $sym, $::CFG->{bindings}->{$mod}->{$sym},
997 sub {
998 my ($nmod, $nsym, $ncmds) = @_;
999 delete $::CFG->{bindings}->{$mod}->{$sym};
1000 $::CFG->{bindings}->{$nmod}->{$nsym} = $ncmds;
1001 $refresh->();
1002 $::BIND_WINDOW->show;
1003 },
1004 sub {
1005 $::BIND_WINDOW->show;
1006 });
1007 $::BIND_EDITOR->show;
1008 $::BIND_WINDOW->hide;
1009 });
1010
972 $hb->add (new CFClient::UI::Label text => "($nam)"); 1011 $hb->add (new CFClient::UI::Label text => "(Key: $nam)");
973 $hb->add (new CFClient::UI::Label text => $lbl, expand => 1); 1012 $hb->add (new CFClient::UI::Label text => $lbl, expand => 1);
974 } 1013 }
975 } 1014 }
976 }; 1015 };
977 1016
984 on_visibility_change => sub { 1023 on_visibility_change => sub {
985 my ($self, $visible) = @_; 1024 my ($self, $visible) = @_;
986 $refresh->() if $visible; 1025 $refresh->() if $visible;
987 }; 1026 };
988 1027
1028 $BIND_WINDOW->add (my $vb = new CFClient::UI::VBox);
989 $BIND_WINDOW->add ($binding_list); 1029 $vb->add ($binding_list);
1030 $vb->add (my $hb = new CFClient::UI::HBox);
1031 $hb->add (new CFClient::UI::Button
1032 text => "record new",
1033 expand => 1,
1034 tooltip => "This button opens the binding editor with an empty binding.",
1035 on_activate => sub {
1036 $::BIND_EDITOR->set_binding (undef, undef, [],
1037 sub {
1038 my ($mod, $sym, $cmds) = @_;
1039 $::CFG->{bindings}->{$mod}->{$sym} = $cmds;
1040 $refresh->();
1041 $::BIND_WINDOW->show;
1042 },
1043 sub {
1044 $::BIND_WINDOW->show;
1045 });
1046 $::BIND_WINDOW->hide;
1047 $::BIND_EDITOR->show;
1048 },
1049 );
1050 $hb->add (new CFClient::UI::Button
1051 text => "close",
1052 tooltip => "Closes the binding window",
1053 expand => 1,
1054 on_activate => sub {
1055 $::BIND_WINDOW->hide;
1056 }
1057 );
1058
990 $refresh->(); 1059 $refresh->();
991 $BIND_WINDOW 1060 $BIND_WINDOW
992} 1061}
993 1062
994sub make_help_window { 1063sub make_help_window {
1070 padding => 0, 1139 padding => 0,
1071 z => 100, 1140 z => 100,
1072 force_x => "max", 1141 force_x => "max",
1073 force_y => 0; 1142 force_y => 0;
1074 $DEBUG_STATUS->show; 1143 $DEBUG_STATUS->show;
1075 1144
1145 $BIND_EDITOR = new CFClient::UI::BindEditor (x => "max", y => 0);
1146
1076 $STATUSBOX = new CFClient::UI::Statusbox; 1147 $STATUSBOX = new CFClient::UI::Statusbox;
1077 $STATUSBOX->add ("Use <b>Alt-Enter</b> to toggle fullscreen mode", pri => -100, color => [1, 1, 1, 0.8]); 1148 $STATUSBOX->add ("Use <b>Alt-Enter</b> to toggle fullscreen mode", pri => -100, color => [1, 1, 1, 0.8]);
1078 1149
1079 (new CFClient::UI::Frame 1150 (new CFClient::UI::Frame
1080 bg => [0, 0, 0, 0.4], 1151 bg => [0, 0, 0, 0.4],
1130 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 1201 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
1131 1202
1132 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window, 1203 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Stats Window", other => make_stats_window,
1133 tooltip => "Toggles the statistics window, where all your Stats and Resistances are being displayed at all times."); 1204 tooltip => "Toggles the statistics window, where all your Stats and Resistances are being displayed at all times.");
1134 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Inventory", other => make_inventory_window, 1205 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Inventory", other => make_inventory_window,
1135 tooltip => "Toggles the inventory window, where you can manage your loot (or treaures :)."); 1206 tooltip => "Toggles the inventory window, where you can manage your loot (or treaures :)."
1207 ."You can also hit the Tab-key to show/hide the Inventory.");
1136 1208
1137 $BUTTONBAR->add (new CFClient::UI::Button 1209 $BUTTONBAR->add (new CFClient::UI::Button
1138 text => "Save Config", 1210 text => "Save Config",
1139 tooltip => "Saves the options chosen in the client setting, server settings and the window layout to be restored on later runs.", 1211 tooltip => "Saves the options chosen in the client setting, server settings and the window layout to be restored on later runs.",
1140 on_activate => sub { 1212 on_activate => sub {
1148 tooltip => "View Documentation"); 1220 tooltip => "View Documentation");
1149 1221
1150 $BUTTONBAR->add (new CFClient::UI::Flopper 1222 $BUTTONBAR->add (new CFClient::UI::Flopper
1151 text => "Bindings", 1223 text => "Bindings",
1152 other => make_binding_window, 1224 other => make_binding_window,
1153 tooltip => "Lets you delete bindings you have made with the recorder" 1225 tooltip =>
1154 ); 1226 "Lets you define, edit and delete bindings."
1155 $BUTTONBAR->add (new CFClient::UI::Flopper text => "[Rec]", other => CFClient::Recorder::make_window, 1227 ."There is a shortcut for making bindings: LCTRL+Insert opens the binding editor "
1156 tooltip => "This feature lets you record a series of actions (eg. walking a path or ready a skill) and bind them to keys"); 1228 ."with nothing set and the recording started. After doing the actions you "
1229 ."want to record press Insert and you will be asked to press a key-combo."
1230 ."After pressing the combo the binding will be saved automatically and the "
1231 ."binding editor closes");
1232
1233 $BUTTONBAR->add (new CFClient::UI::Flopper
1234 text => "Spells",
1235 other => make_spell_list,
1236 tooltip => "The spell list");
1157 1237
1158 $BUTTONBAR->add (new CFClient::UI::Button 1238 $BUTTONBAR->add (new CFClient::UI::Button
1159 text => "Quit", 1239 text => "Quit",
1160 tooltip => "Terminates the program", 1240 tooltip => "Terminates the program",
1161 on_activate => sub { 1241 on_activate => sub {
1489=head1 USAGE 1569=head1 USAGE
1490 1570
1491cfplus utilises OpenGL for all UI elements and the game. It is supposed to be used 1571cfplus utilises OpenGL for all UI elements and the game. It is supposed to be used
1492fullscreen and interactively. 1572fullscreen and interactively.
1493 1573
1574=head1 DEBUGGING
1575
1576
1577CFPLUS_DEBUG - environment variable
1578
1579 1 draw borders around widgets
1580 2 add low-level widget info to tooltips
1581 4 show fps
1582 8 suppress tooltips
1583
1494=head1 AUTHOR 1584=head1 AUTHOR
1495 1585
1496Marc Lehmann <crossfire@schmorp.de>, Robin Redeker <elmex@ta-sa.org> 1586Marc Lehmann <crossfire@schmorp.de>, Robin Redeker <elmex@ta-sa.org>
1497 1587
1498 1588

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines