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.24 by elmex, Mon May 29 19:30:28 2006 UTC vs.
Revision 1.32 by root, Tue May 30 02:55:45 2006 UTC

101our $DEBUG_STATUS; 101our $DEBUG_STATUS;
102 102
103our $INV_WINDOW; 103our $INV_WINDOW;
104our $INV; 104our $INV;
105our $INVR; 105our $INVR;
106our $INVR_LBL; 106our $INV_RIGHT_HB;
107 107
108our $BIND_WINDOW; 108our $BIND_WINDOW;
109 109
110sub status { 110sub status {
111 $STATUSBOX->add (CFClient::UI::Label::escape $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]); 111 $STATUSBOX->add (CFClient::UI::Label::escape $_[0], pri => -10, group => "status", timeout => 10, fg => [1, 1, 0, 1]);
112} 112}
113 113
114sub debug { 114sub debug {
115 $DEBUG_STATUS->set_text ($_[0]); 115 $DEBUG_STATUS->set_text ($_[0]);
116 my ($w, $h) = $DEBUG_STATUS->size_request;
117 $DEBUG_STATUS->move ($WIDTH - $w, 0);
118} 116}
119 117
120sub start_game { 118sub start_game {
121 status "logging in..."; 119 status "logging in...";
122 120
181 $CONN = 0; # false, does not autovivify 179 $CONN = 0; # false, does not autovivify
182} 180}
183 181
184sub client_setup { 182sub client_setup {
185 my $dialog = new CFClient::UI::FancyFrame 183 my $dialog = new CFClient::UI::FancyFrame
186 req_x => 1, 184 x => 1,
187 req_y => $HEIGHT * (1/8), 185 y => $HEIGHT * (1/8),
188 name => "client_setup", 186 name => "client_setup",
189 title => "Client Setup", 187 title => "Client Setup",
190 child => (my $vbox = new CFClient::UI::VBox); 188 child => (my $vbox = new CFClient::UI::VBox);
189
191 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); 190 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]);
192 191
193 $table->add (0, 0, new CFClient::UI::Label valign => 0, align => 1, text => "Video Mode"); 192 $table->add (0, 0, new CFClient::UI::Label valign => 0, align => 1, text => "Video Mode");
194 $table->add (1, 0, my $hbox = new CFClient::UI::HBox); 193 $table->add (1, 0, my $hbox = new CFClient::UI::HBox);
195 194
196 $hbox->add (my $mode_slider = new CFClient::UI::Slider expand => 1, req_w => 100, range => [$CFG->{sdl_mode}, 0, $#SDL_MODES, 0, 1]); 195 $hbox->add (my $mode_slider = new CFClient::UI::Slider force_w => $WIDTH * 0.1, expand => 1, range => [$CFG->{sdl_mode}, 0, $#SDL_MODES, 0, 1]);
197 $hbox->add (my $mode_label = new CFClient::UI::Label align => 0, valign => 0, height => 0.8, template => "9999x9999"); 196 $hbox->add (my $mode_label = new CFClient::UI::Label align => 0, valign => 0, height => 0.8, template => "9999x9999");
198 197
199 $mode_slider->connect (changed => sub { 198 $mode_slider->connect (changed => sub {
200 my ($self, $value) = @_; 199 my ($self, $value) = @_;
201 200
389 388
390sub make_gauge_window { 389sub make_gauge_window {
391 my $gh = int $HEIGHT * $CFG->{gauge_size}; 390 my $gh = int $HEIGHT * $CFG->{gauge_size};
392 391
393 my $win = new CFClient::UI::Frame ( 392 my $win = new CFClient::UI::Frame (
394 req_x => 0, 393 force_x => 0,
395 req_y => -1, 394 force_y => "max",
396 def_w => $WIDTH, 395 force_w => $WIDTH,
397 def_h => $gh, 396 force_h => $gh,
398 ); 397 );
399 398
400 $win->add (my $hbox = new CFClient::UI::HBox 399 $win->add (my $hbox = new CFClient::UI::HBox
401 children => [ 400 children => [
402 (new CFClient::UI::HBox expand => 1), 401 (new CFClient::UI::HBox expand => 1),
441} 440}
442 441
443 442
444sub make_stats_window { 443sub make_stats_window {
445 my $tgw = new CFClient::UI::FancyFrame 444 my $tgw = new CFClient::UI::FancyFrame
446 req_y => $HEIGHT * (2/8), 445 y => $HEIGHT * (2/8),
447 req_x => -1, 446 x => "max",
448 title => "Stats", 447 title => "Stats",
449 name => "stats_window"; 448 name => "stats_window";
450 449
451 $tgw->add (new CFClient::UI::Window child => my $vb = new CFClient::UI::VBox); 450 $tgw->add (new CFClient::UI::Window child => my $vb = new CFClient::UI::VBox);
452 $vb->add ($STATWIDS->{title} = new CFClient::UI::Label valign => 0, align => -1, text => "Title:", expand => 1, 451 $vb->add ($STATWIDS->{title} = new CFClient::UI::Label valign => 0, align => -1, text => "Title:", expand => 1,
453 can_hover => 1, can_events => 1, 452 can_hover => 1, can_events => 1,
454 tooltip => "Your name and title. You can change your title by using the <b>title</b> command, if supported by the server."); 453 tooltip => "Your name and title. You can change your title by using the <b>title</b> command, if supported by the server.");
717 }); 716 });
718} 717}
719 718
720sub server_setup { 719sub server_setup {
721 my $dialog = $SERVER_SETUP = new CFClient::UI::FancyFrame 720 my $dialog = $SERVER_SETUP = new CFClient::UI::FancyFrame
722 x => $WIDTH * (1/3), 721 x => "center",
723 y => $HEIGHT * (1/8), 722 y => "center",
724 name => "server_setup", 723 name => "server_setup",
725 title => "Server Setup", 724 title => "Server Setup",
726 child => (my $vbox = new CFClient::UI::VBox), 725 child => (my $vbox = new CFClient::UI::VBox),
727 on_visibility_change => sub {
728 my ($self, $visible) = @_;
729 $self->center if $visible;
730 },
731 ; 726 ;
732 727
733 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]); 728 $vbox->add (my $table = new CFClient::UI::Table expand => 1, col_expand => [0, 1]);
734 $table->add (0, 2, new CFClient::UI::Label valign => 0, align => 1, text => "Host:Port"); 729 $table->add (0, 2, new CFClient::UI::Label valign => 0, align => 1, text => "Host:Port");
735 730
781 } 776 }
782 ); 777 );
783 778
784 $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size"); 779 $table->add (0, 7, new CFClient::UI::Label valign => 0, align => 1, text => "Map Size");
785 $table->add (1, 7, new CFClient::UI::Slider 780 $table->add (1, 7, new CFClient::UI::Slider
786 req_w => 100, 781 force_w => 100,
787 range => [$CFG->{mapsize}, 10, 100, 0, 1], 782 range => [$CFG->{mapsize}, 10, 100, 0, 1],
788 tooltip => "This is the size of the portion of the map update the server sends you. " 783 tooltip => "This is the size of the portion of the map update the server sends you. "
789 . "If you set this to a high value you will be able to see further, " 784 . "If you set this to a high value you will be able to see further, "
790 . "but you also increase bandwidth requirements and latency. " 785 . "but you also increase bandwidth requirements and latency. "
791 . "This option is only used once at log-in.", 786 . "This option is only used once at log-in.",
840 my $window = new CFClient::UI::FancyFrame 835 my $window = new CFClient::UI::FancyFrame
841 name => "message_window", 836 name => "message_window",
842 title => "Messages", 837 title => "Messages",
843 border_bg => [1, 1, 1, 1], 838 border_bg => [1, 1, 1, 1],
844 bg => [0, 0, 0, 0.75], 839 bg => [0, 0, 0, 0.75],
845 req_x => -1, 840 x => "max",
846 req_y => 0, 841 y => 0,
847 def_w => int $::WIDTH / 3, 842 force_w => $::WIDTH / 3,
848 def_h => int $::HEIGHT / 5, 843 force_h => $::HEIGHT / 5,
849 child => (my $vbox = new CFClient::UI::VBox); 844 child => (my $vbox = new CFClient::UI::VBox);
850 845
851 $vbox->add ($LOGVIEW); 846 $vbox->add ($LOGVIEW);
852 847
853 $vbox->add (my $input = new CFClient::UI::Entry 848 $vbox->add (my $input = new CFClient::UI::Entry
887 }, 882 },
888 ); 883 );
889 884
890 $CONSOLE = { 885 $CONSOLE = {
891 window => $window, 886 window => $window,
892 input => $input 887 input => $input,
893 }; 888 };
894 889
895 $window 890 $window
896} 891}
897 892
898sub open_quit_dialog { 893sub open_quit_dialog {
899 unless ($QUIT_DIALOG) { 894 unless ($QUIT_DIALOG) {
900 $QUIT_DIALOG = new CFClient::UI::FancyFrame title => "Really Quit?"; 895 $QUIT_DIALOG = new CFClient::UI::FancyFrame
896 x => "center",
897 y => "center",
898 title => "Really Quit?",
899 ;
901 900
902 $QUIT_DIALOG->add (my $vb = new CFClient::UI::VBox expand => 1); 901 $QUIT_DIALOG->add (my $vb = new CFClient::UI::VBox expand => 1);
903 902
904 $vb->add (new CFClient::UI::Label 903 $vb->add (new CFClient::UI::Label
905 text => "You should find a savebed and apply it first!", 904 text => "You should find a savebed and apply it first!",
918 on_activate => sub { exit }, 917 on_activate => sub { exit },
919 ); 918 );
920 } 919 }
921 920
922 $QUIT_DIALOG->show; 921 $QUIT_DIALOG->show;
923 $QUIT_DIALOG->center;
924} 922}
925 923
926sub make_inventory_window { 924sub make_inventory_window {
927 my $invwin = $INV_WINDOW = new CFClient::UI::FancyFrame 925 my $invwin = $INV_WINDOW = new CFClient::UI::FancyFrame
926 x => "center",
927 y => "center",
928 def_w => $WIDTH * 7/8, 928 force_w => $WIDTH * 9/10,
929 def_h => $HEIGHT * 7/8, 929 force_h => $HEIGHT * 9/10,
930 title => "Inventory", 930 title => "Inventory",
931 name => "inventory_window", 931 name => "inventory_window",
932 on_visibility_change => sub {
933 my ($self, $visible) = @_;
934 $self->center if $visible;
935 },
936 ; 932 ;
937 933
938 $invwin->add (my $hb = new CFClient::UI::HBox homogeneous => 1); 934 $invwin->add (my $hb = new CFClient::UI::HBox homogeneous => 1);
939 935
940 $hb->add (my $vb1 = new CFClient::UI::VBox); 936 $hb->add (my $vb1 = new CFClient::UI::VBox);
941 $vb1->add (new CFClient::UI::Label align => 0, text => "Player"); 937 $vb1->add (new CFClient::UI::Label align => 0, text => "Player");
942 $vb1->add ($INV = new CFClient::UI::Inventory expand => 1); 938 $vb1->add ($INV = new CFClient::UI::Inventory expand => 1);
943 939
944 $hb->add (my $vb2 = new CFClient::UI::VBox); 940 $hb->add (my $vb2 = new CFClient::UI::VBox);
945 941
946 $vb2->add (my $hb2 = new CFClient::UI::HBox); 942 $vb2->add ($INV_RIGHT_HB = new CFClient::UI::HBox);
947 $hb2->add ($INVR_LBL = new CFClient::UI::Label align => 0, expand => 1, text => "Floor");
948 $hb2->add (new CFClient::UI::Button
949 text => "Close",
950 tooltip => "Close the currently open container (if one is open)",
951 on_activate => sub {
952 $CONN->send ("apply $CONN->{open_container}")
953 if $CONN->{open_container} != 0;
954 },
955 );
956 943
957 $vb2->add ($INVR = new CFClient::UI::Inventory expand => 1); 944 $vb2->add ($INVR = new CFClient::UI::Inventory expand => 1);
945
946 # XXX: Call after $INVR = ... because set_opencont sets the items
947 CFClient::Protocol::set_opencont ($::CONN, 0, "Floor");
958 948
959 $invwin 949 $invwin
960} 950}
961 951
962sub make_binding_window { 952sub make_binding_window {
972 962
973 my $lbl = join "; ", @$cmds; 963 my $lbl = join "; ", @$cmds;
974 my $nam = CFClient::Recorder::keycombo_to_name ($mod, $sym); 964 my $nam = CFClient::Recorder::keycombo_to_name ($mod, $sym);
975 $binding_list->add (my $hb = new CFClient::UI::HBox); 965 $binding_list->add (my $hb = new CFClient::UI::HBox);
976 $hb->add (new CFClient::UI::Button 966 $hb->add (new CFClient::UI::Button
977 text => "del", 967 text => "delete",
978 on_activate => sub { 968 on_activate => sub {
979 $binding_list->remove ($hb); 969 $binding_list->remove ($hb);
980 delete $::CFG->{bindings}->{$mod}->{$sym}; 970 delete $::CFG->{bindings}->{$mod}->{$sym};
981 }); 971 });
982 $hb->add (new CFClient::UI::Label text => "($nam)"); 972 $hb->add (new CFClient::UI::Label text => "($nam)");
985 } 975 }
986 }; 976 };
987 977
988 $BIND_WINDOW = new CFClient::UI::FancyFrame 978 $BIND_WINDOW = new CFClient::UI::FancyFrame
989 title => "Bindings", 979 title => "Bindings",
980 x => "center",
981 y => "center",
990 def_w => int $WIDTH * 7/8, 982 def_w => int $WIDTH * 9/10,
991 def_h => int $HEIGHT * 7/8, 983 def_h => int $HEIGHT * 9/10,
992 on_visibility_change => sub { 984 on_visibility_change => sub {
993 my ($self, $visible) = @_; 985 my ($self, $visible) = @_;
994 if ($visible) { 986 $refresh->() if $visible;
995 $self->center;
996 $refresh->()
997 }
998 }; 987 };
999 988
1000 $BIND_WINDOW->add ($binding_list); 989 $BIND_WINDOW->add ($binding_list);
1001 $refresh->(); 990 $refresh->();
1002 $BIND_WINDOW 991 $BIND_WINDOW
1075 if ($DEBUG_STATUS) { 1064 if ($DEBUG_STATUS) {
1076 CFClient::UI::rescale_widgets $WIDTH / $old_w, $HEIGHT / $old_h; 1065 CFClient::UI::rescale_widgets $WIDTH / $old_w, $HEIGHT / $old_h;
1077 } else { 1066 } else {
1078 # create the widgets 1067 # create the widgets
1079 1068
1080 $DEBUG_STATUS = new CFClient::UI::Label padding => 0, z => 100, req_x => -1; 1069 $DEBUG_STATUS = new CFClient::UI::Label
1070 padding => 0,
1071 z => 100,
1072 force_x => "max",
1073 force_y => 0;
1081 $DEBUG_STATUS->show; 1074 $DEBUG_STATUS->show;
1082 1075
1083 $STATUSBOX = new CFClient::UI::Statusbox; 1076 $STATUSBOX = new CFClient::UI::Statusbox;
1084 $STATUSBOX->add ("Use <b>Alt-Enter</b> to toggle fullscreen mode", pri => -100, color => [1, 1, 1, 0.8]); 1077 $STATUSBOX->add ("Use <b>Alt-Enter</b> to toggle fullscreen mode", pri => -100, color => [1, 1, 1, 0.8]);
1085 1078
1086 (new CFClient::UI::Frame 1079 (new CFClient::UI::Frame
1087 bg => [0, 0, 0, 0.4], 1080 bg => [0, 0, 0, 0.4],
1088 req_y => -1, 1081 force_x => 0,
1082 force_y => "max",
1089 child => $STATUSBOX, 1083 child => $STATUSBOX,
1090 )->show; 1084 )->show;
1091 1085
1092 CFClient::UI::FancyFrame->new ( 1086 CFClient::UI::FancyFrame->new (
1087 x => 0,
1088 y => $FONTSIZE + 8,
1093 border_bg => [1, 1, 1, 192/255], 1089 border_bg => [1, 1, 1, 192/255],
1094 bg => [1, 1, 1, 0], 1090 bg => [1, 1, 1, 0],
1095 child => ($MAPMAP = new CFClient::MapWidget::MapMap 1091 child => ($MAPMAP = new CFClient::MapWidget::MapMap
1096 tooltip => "<b>Map</b>. On servers that support this feature, this will display an overview of the surrounding areas.", 1092 tooltip => "<b>Map</b>. On servers that support this feature, this will display an overview of the surrounding areas.",
1097 ), 1093 ),
1120 can_hover => 1, 1116 can_hover => 1,
1121 can_events => 1, 1117 can_events => 1,
1122 tooltip => "<b>Server Log</b>. This text viewer contains all the messages sent by the server.", 1118 tooltip => "<b>Server Log</b>. This text viewer contains all the messages sent by the server.",
1123 ; 1119 ;
1124 1120
1125 $BUTTONBAR = new CFClient::UI::HBox; 1121 $BUTTONBAR = new CFClient::UI::HBox x => 0, y => 0;
1126 1122
1127 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Client Setup", other => client_setup, 1123 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Client Setup", other => client_setup,
1128 tooltip => "Toggles a dialog where you can configure various aspects of the client, such as graphics mode, performance, and audio options."); 1124 tooltip => "Toggles a dialog where you can configure various aspects of the client, such as graphics mode, performance, and audio options.");
1129 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Server Setup", other => server_setup, 1125 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Server Setup", other => server_setup,
1130 tooltip => "Toggles a dialog where you can configure the server to play on, your username, password and other server-related options."); 1126 tooltip => "Toggles a dialog where you can configure the server to play on, your username, password and other server-related options.");
1141 $BUTTONBAR->add (new CFClient::UI::Button 1137 $BUTTONBAR->add (new CFClient::UI::Button
1142 text => "Save Config", 1138 text => "Save Config",
1143 tooltip => "Saves the options chosen in the client setting, server settings and the window layout to be restored on later runs.", 1139 tooltip => "Saves the options chosen in the client setting, server settings and the window layout to be restored on later runs.",
1144 on_activate => sub { 1140 on_activate => sub {
1145 $::CFG->{layout} = CFClient::UI::get_layout; 1141 $::CFG->{layout} = CFClient::UI::get_layout;
1146 CFClient::write_cfg "$Crossfire::VARDIR/pclientrc"; 1142 CFClient::write_cfg "$Crossfire::VARDIR/cfplusrc";
1147 status "Configuration Saved"; 1143 status "Configuration Saved";
1148 }, 1144 },
1149 ); 1145 );
1150 1146
1151 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Help!", other => make_help_window, 1147 $BUTTONBAR->add (new CFClient::UI::Flopper text => "Help!", other => make_help_window,
1170 } 1166 }
1171 }, 1167 },
1172 ); 1168 );
1173 1169
1174 $BUTTONBAR->show; 1170 $BUTTONBAR->show;
1171 $SERVER_SETUP->show;
1175 1172
1176 $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]); 1173 $STATUSBOX->add ("Set video mode $WIDTH×$HEIGHT", timeout => 10, fg => [1, 1, 1, 0.5]);
1177
1178 $SERVER_SETUP->show;
1179 } 1174 }
1180} 1175}
1181 1176
1182sub video_shutdown { 1177sub video_shutdown {
1183 undef $SDL_ACTIVE; 1178 undef $SDL_ACTIVE;
1393############################################################################# 1388#############################################################################
1394 1389
1395$SIG{INT} = $SIG{TERM} = sub { exit }; 1390$SIG{INT} = $SIG{TERM} = sub { exit };
1396 1391
1397{ 1392{
1398 local $SIG{__DIE__} = sub { CFClient::fatal $_[0] }; 1393 local $SIG{__DIE__} = sub { CFClient::fatal $_[0] if defined $^S && !$^S };
1399 1394
1400 CFClient::read_cfg "$Crossfire::VARDIR/pclientrc"; 1395 CFClient::read_cfg "$Crossfire::VARDIR/cfplusrc";
1401 CFClient::UI::set_layout ($::CFG->{layout}); 1396 CFClient::UI::set_layout ($::CFG->{layout});
1402 1397
1403 my %DEF_CFG = ( 1398 my %DEF_CFG = (
1404 sdl_mode => 0, 1399 sdl_mode => 0,
1405 width => 640, 1400 width => 640,
1483 1478
1484END { CFClient::SDL_Quit } 1479END { CFClient::SDL_Quit }
1485 1480
1486=head1 NAME 1481=head1 NAME
1487 1482
1488pclient - A Crossfire+ and Crossfire game client 1483cfplus - A Crossfire+ and Crossfire game client
1489 1484
1490=head1 SYNOPSIS 1485=head1 SYNOPSIS
1491 1486
1492Just run it - no commandline arguments are supported. 1487Just run it - no commandline arguments are supported.
1493 1488
1494=head1 USAGE 1489=head1 USAGE
1495 1490
1496Pclient utilises OpenGL for all UI elements and the game. It is supposed to be used 1491cfplus utilises OpenGL for all UI elements and the game. It is supposed to be used
1497fullscreen and interactively. 1492fullscreen and interactively.
1498 1493
1499=head1 AUTHOR 1494=head1 AUTHOR
1500 1495
1501Marc Lehmann <crossfire@schmorp.de>, Robin Redeker <elmex@ta-sa.org> 1496Marc Lehmann <crossfire@schmorp.de>, Robin Redeker <elmex@ta-sa.org>

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines