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.137 by root, Sat Dec 9 02:21:25 2006 UTC vs.
Revision 1.147 by root, Fri Apr 6 07:45:35 2007 UTC

58use Compress::LZF; 58use Compress::LZF;
59 59
60use CFPlus; 60use CFPlus;
61use CFPlus::OpenGL (); 61use CFPlus::OpenGL ();
62use CFPlus::Protocol; 62use CFPlus::Protocol;
63use CFPlus::DB;
63use CFPlus::UI; 64use CFPlus::UI;
64use CFPlus::UI::Inventory; 65use CFPlus::UI::Inventory;
65use CFPlus::UI::SpellList; 66use CFPlus::UI::SpellList;
66use CFPlus::Pod; 67use CFPlus::Pod;
67use CFPlus::MapWidget; 68use CFPlus::MapWidget;
68use CFPlus::Macro; 69use CFPlus::Macro;
69 70
70$SIG{QUIT} = sub { Carp::cluck "QUIT" }; 71$SIG{QUIT} = sub { Carp::cluck "QUIT" };
71$SIG{PIPE} = 'IGNORE'; 72$SIG{PIPE} = 'IGNORE';
72 73
73$Event::Eval = 0; 74$Event::Eval = 1;
74$Event::DIED = sub { 75$Event::DIED = sub {
75 CFPlus::fatal Carp::longmess $_[1] 76 CFPlus::fatal Carp::longmess $_[1]
76}; 77};
77 78
78my $MAX_FPS = 60; 79my $MAX_FPS = 60;
176sub destroy_query_dialog { 177sub destroy_query_dialog {
177 (delete $_[0]{query_dialog})->destroy 178 (delete $_[0]{query_dialog})->destroy
178 if $_[0]{query_dialog}; 179 if $_[0]{query_dialog};
179} 180}
180 181
182# FIXME: a very ugly hack to wait for stat update look below! #d#
183our $QUERY_TIMER; #d#
184
181# server query dialog 185# server query dialog
182sub server_query { 186sub server_query {
183 my ($conn, $flags, $prompt) = @_; 187 my ($conn, $flags, $prompt) = @_;
188
189 # FIXME: a very ugly hack to wait for stat update #d#
190 if ($prompt =~ /roll new stats/ and not $conn->{stat_change_with}) {
191 unless ($QUERY_TIMER) {
192 $QUERY_TIMER =
193 Event->timer (
194 after => 1,
195 cb => sub {
196 server_query ($conn, $flags, $prompt, 1);
197 $QUERY_TIMER = undef
198 }
199 );
200 return;
201 }
202 }
184 203
185 $conn->{query_dialog} = my $dialog = new CFPlus::UI::Toplevel 204 $conn->{query_dialog} = my $dialog = new CFPlus::UI::Toplevel
186 x => "center", 205 x => "center",
187 y => "center", 206 y => "center",
188 title => "Server Query", 207 title => "Server Query",
447sub graphics_setup { 466sub graphics_setup {
448 my $vbox = new CFPlus::UI::VBox; 467 my $vbox = new CFPlus::UI::VBox;
449 468
450 $vbox->add (my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 1]); 469 $vbox->add (my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 1]);
451 470
471 my $row = 0;
472
473 $table->add (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "OpenGL Info");
474 $table->add (1, $row++, new CFPlus::UI::Label valign => 0, fontsize => 0.8, text => CFPlus::OpenGL::gl_vendor . ", " . CFPlus::OpenGL::gl_version,
475 can_events => 1,
476 tooltip => "<tt><span size='8192'>" . (CFPlus::OpenGL::gl_extensions) . "</span></tt>");
477
452 $table->add (0, 0, new CFPlus::UI::Label valign => 0, align => 1, text => "Video Mode"); 478 $table->add (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Video Mode");
453 $table->add (1, 0, my $hbox = new CFPlus::UI::HBox); 479 $table->add (1, $row++, my $hbox = new CFPlus::UI::HBox);
454 480
455 $hbox->add (my $mode_slider = new CFPlus::UI::Slider force_w => $WIDTH * 0.1, expand => 1, range => [$CFG->{sdl_mode}, 0, $#SDL_MODES, 0, 1]); 481 $hbox->add (my $mode_slider = new CFPlus::UI::Slider force_w => $WIDTH * 0.1, expand => 1, range => [$CFG->{sdl_mode}, 0, $#SDL_MODES, 0, 1]);
456 $hbox->add (my $mode_label = new CFPlus::UI::Label align => 0, valign => 0, height => 0.8, template => "9999x9999"); 482 $hbox->add (my $mode_label = new CFPlus::UI::Label align => 0, valign => 0, height => 0.8, template => "9999x9999");
457 483
458 $mode_slider->connect (changed => sub { 484 $mode_slider->connect (changed => sub {
460 486
461 $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value; 487 $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value;
462 $mode_label->set_text (sprintf "%dx%d", @{$SDL_MODES[$value]}); 488 $mode_label->set_text (sprintf "%dx%d", @{$SDL_MODES[$value]});
463 }); 489 });
464 $mode_slider->emit (changed => $mode_slider->{range}[0]); 490 $mode_slider->emit (changed => $mode_slider->{range}[0]);
465
466 my $row = 1;
467 491
468 $table->add (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fullscreen"); 492 $table->add (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fullscreen");
469 $table->add (1, $row++, $FULLSCREEN_ENABLE = new CFPlus::UI::CheckBox 493 $table->add (1, $row++, $FULLSCREEN_ENABLE = new CFPlus::UI::CheckBox
470 state => $CFG->{fullscreen}, 494 state => $CFG->{fullscreen},
471 tooltip => "Bring the client into fullscreen mode.", 495 tooltip => "Bring the client into fullscreen mode.",
887 for 0 .. $#col; 911 for 0 .. $#col;
888 912
889 my @align = qw(1 0 1 1 -1); 913 my @align = qw(1 0 1 1 -1);
890 914
891 my $y = 0; 915 my $y = 0;
892 for my $m (
893 sort {
894 $b->{version} <=> $a->{version}
895 or $b->{users} <=> $a->{users}
896 }
897 @{ $msg->{servers} } 916 for my $m (@{ $msg->{servers} }) {
898 ) {
899 my ($ip, $last, $host, $users, $version, $desc, $ibytes, $obytes, $uptime) = 917 my ($ip, $last, $host, $users, $version, $desc, $ibytes, $obytes, $uptime, $highlight) =
900 @$m{qw(ip age hostname users version description ibytes obytes uptime)}; 918 @$m{qw(ip age hostname users version description ibytes obytes uptime highlight)};
901 919
902 for ($desc) { 920 for ($desc) {
903 s/<br>/\n/gi; 921 s/<br>/\n/gi;
904 s/<li>/\n· /gi; 922 s/<li>/\n· /gi;
905 s/<.*?>//sgi; 923 s/<.*?>//sgi;
935 max_w => $::WIDTH * 0.4, 953 max_w => $::WIDTH * 0.4,
936 ellipsise => 0, 954 ellipsise => 0,
937 align => $align[$_], 955 align => $align[$_],
938 text => $m->[$_], 956 text => $m->[$_],
939 tooltip => $tip[$_], 957 tooltip => $tip[$_],
940 fg => ($m->[3] =~ /\+$/ ? [1, 1, 1] : [.7, .7, .7]), 958 fg => ($highlight ? [1, 1, 1] : [.7, .7, .7]),
941 can_hover => 1, 959 can_hover => 1,
942 can_events => 1, 960 can_events => 1,
943 fontsize => 0.8) 961 fontsize => 0.8)
944 for 0 .. $#$m; 962 for 0 .. $#$m;
945 } 963 }
1046 . "so only set it if you really need to prefetch images. " 1064 . "so only set it if you really need to prefetch images. "
1047 . "This option can be set and unset any time.", 1065 . "This option can be set and unset any time.",
1048 on_changed => sub { $CFG->{face_prefetch} = $_[1]; 0 }, 1066 on_changed => sub { $CFG->{face_prefetch} = $_[1]; 0 },
1049 ); 1067 );
1050 1068
1051 $table->add (0, 9, new CFPlus::UI::Label valign => 0, align => 1, text => "Output-Count"); 1069 $table->add (0, 9, new CFPlus::UI::Label valign => 0, align => 1, text => "Output-Rate");
1052 $table->add (1, 9, new CFPlus::UI::Entry 1070 $table->add (1, 9, new CFPlus::UI::Entry
1071 text => $CFG->{output_rate},
1072 tooltip => "The approximate bandwidth in bytes per second that the server should not exceed "
1073 . "when sending images, to ensure interactiveness. When 0 or unset, the server "
1074 . "default will be used, which is usually around 100kb/s.",
1075 on_changed => sub { $CFG->{output_rate} = $_[1]; 0 },
1076 );
1077
1078 $table->add (0, 10, new CFPlus::UI::Label valign => 0, align => 1, text => "Output-Count");
1079 $table->add (1, 10, new CFPlus::UI::Entry
1053 text => $CFG->{output_count}, 1080 text => $CFG->{output_count},
1054 tooltip => "Should be set to 1 unless you know what you are doing. This option is only used once at log-in.", 1081 tooltip => "Should be set to 1 unless you know what you are doing. This option is only used once at log-in.",
1055 on_changed => sub { $CFG->{output_count} = $_[1]; 0 }, 1082 on_changed => sub { $CFG->{output_count} = $_[1]; 0 },
1056 ); 1083 );
1057 1084
1058 $table->add (0, 10, new CFPlus::UI::Label valign => 0, align => 1, text => "Output-Sync"); 1085 $table->add (0, 11, new CFPlus::UI::Label valign => 0, align => 1, text => "Output-Sync");
1059 $table->add (1, 10, new CFPlus::UI::Entry 1086 $table->add (1, 11, new CFPlus::UI::Entry
1060 text => $CFG->{output_sync}, 1087 text => $CFG->{output_sync},
1061 tooltip => "Should be set to 1 unless you know what you are doing. This option is only used once at log-in.", 1088 tooltip => "Should be set to 1 unless you know what you are doing. This option is only used once at log-in.",
1062 on_changed => sub { $CFG->{output_sync} = $_[1]; 0 }, 1089 on_changed => sub { $CFG->{output_sync} = $_[1]; 0 },
1063 ); 1090 );
1064 1091
1065 $table->add (1, 11, $LOGIN_BUTTON = new CFPlus::UI::Button 1092 $table->add (1, 12, $LOGIN_BUTTON = new CFPlus::UI::Button
1066 expand => 1, 1093 expand => 1,
1067 align => 0, 1094 align => 0,
1068 text => "Login", 1095 text => "Login",
1069 on_activate => sub { 1096 on_activate => sub {
1070 $CONN ? stop_game 1097 $CONN ? stop_game
1071 : start_game; 1098 : start_game;
1072 0 1099 0
1073 }, 1100 },
1074 ); 1101 );
1075 1102
1076 $table->add (0, 12, new CFPlus::UI::Label valign => 0, align => 1, text => "Chat Command"); 1103 $table->add (0, 13, new CFPlus::UI::Label valign => 0, align => 1, text => "Chat Command");
1077 $table->add (1, 12, my $saycmd = new CFPlus::UI::Entry 1104 $table->add (1, 13, my $saycmd = new CFPlus::UI::Entry
1078 text => $CFG->{say_command}, 1105 text => $CFG->{say_command},
1079 tooltip => "This is the command that will be used if you write a line in the message window entry or press <b>\"</b> in the map window. " 1106 tooltip => "This is the command that will be used if you write a line in the message window entry or press <b>\"</b> in the map window. "
1080 . "Usually you want to enter something like 'say' or 'shout' or 'gsay' here. " 1107 . "Usually you want to enter something like 'say' or 'shout' or 'gsay' here. "
1081 . "But you could also set it to <b>tell <i>playername</i></b> to only chat with that user.", 1108 . "But you could also set it to <b>tell <i>playername</i></b> to only chat with that user.",
1082 on_changed => sub { 1109 on_changed => sub {
1084 $CFG->{say_command} = $value; 1111 $CFG->{say_command} = $value;
1085 0 1112 0
1086 } 1113 }
1087 ); 1114 );
1088 1115
1089 $table->add (0, 13, new CFPlus::UI::Label valign => 0, align => 1, text => "Tip of the day"); 1116 $table->add (0, 14, new CFPlus::UI::Label valign => 0, align => 1, text => "Tip of the day");
1090 $table->add (1, 13, my $saycmd = new CFPlus::UI::CheckBox 1117 $table->add (1, 14, my $saycmd = new CFPlus::UI::CheckBox
1091 state => $CFG->{show_tips}, 1118 state => $CFG->{show_tips},
1092 tooltip => "Show the <b>Tip of the day</b> window at startup?", 1119 tooltip => "Show the <b>Tip of the day</b> window at startup?",
1093 on_changed => sub { 1120 on_changed => sub {
1094 my ($self, $value) = @_; 1121 my ($self, $value) = @_;
1095 $CFG->{show_tips} = $value; 1122 $CFG->{show_tips} = $value;
1770} 1797}
1771 1798
1772sub setup_build_button { 1799sub setup_build_button {
1773 my ($enabled) = @_; 1800 my ($enabled) = @_;
1774 if ($enabled) { 1801 if ($enabled) {
1802 $BUILD_BUTTON->hide if $BUILD_BUTTON;
1775 $BUILD_BUTTON ||= new CFPlus::UI::Button 1803 $BUILD_BUTTON ||= new CFPlus::UI::Button
1776 text => "Build", 1804 text => "Build",
1777 tooltip => "Opens the ingame builder", 1805 tooltip => "Opens the ingame builder",
1778 on_activate => sub { 1806 on_activate => sub {
1779 if ($CONN) { 1807 if ($CONN) {
2055 2083
2056$SIG{INT} = $SIG{TERM} = sub { exit }; 2084$SIG{INT} = $SIG{TERM} = sub { exit };
2057 2085
2058{ 2086{
2059 CFPlus::read_cfg "$Crossfire::VARDIR/cfplusrc"; 2087 CFPlus::read_cfg "$Crossfire::VARDIR/cfplusrc";
2088 CFPlus::DB::Server::run;
2089
2060 CFPlus::UI::set_layout ($::CFG->{layout}); 2090 CFPlus::UI::set_layout ($::CFG->{layout});
2061 2091
2062 my %DEF_CFG = ( 2092 my %DEF_CFG = (
2063 sdl_mode => 0, 2093 sdl_mode => 0,
2064 width => 640, 2094 width => 640,
2080 bgm_enable => 1, 2110 bgm_enable => 1,
2081 bgm_volume => 0.25, 2111 bgm_volume => 0.25,
2082 face_prefetch => 0, 2112 face_prefetch => 0,
2083 output_sync => 1, 2113 output_sync => 1,
2084 output_count => 1, 2114 output_count => 1,
2115 output_rate => "",
2085 pickup => 0, 2116 pickup => 0,
2086 inv_sort => "mtime", 2117 inv_sort => "mtime",
2087 default => "profile", # default profile 2118 default => "profile", # default profile
2088 show_tips => 1, 2119 show_tips => 1,
2089 ); 2120 );
2158 audio_init; 2189 audio_init;
2159} 2190}
2160 2191
2161show_tip_of_the_day if $CFG->{show_tips}; 2192show_tip_of_the_day if $CFG->{show_tips};
2162 2193
2163#CFPlus::Macro::quick_macro ["test"];#d#
2164Event::loop; 2194Event::loop;
2165#CFPlus::SDL_Quit; 2195#CFPlus::SDL_Quit;
2166#CFPlus::_exit 0; 2196#CFPlus::_exit 0;
2167 2197
2168END { CFPlus::SDL_Quit } 2198END { CFPlus::SDL_Quit }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines