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.139 by root, Sat Dec 9 22:06:51 2006 UTC vs.
Revision 1.153 by root, Tue Apr 24 01:13:54 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;
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",
189 child => my $vbox = new CFPlus::UI::VBox, 208 child => my $vbox = new CFPlus::UI::VBox,
190 ; 209 ;
191 210
192 my @dialog = my $label = new CFPlus::UI::Label 211 my @dialog = my $label = new CFPlus::UI::Label
193 max_w => $::WIDTH * 0.4, 212 max_w => $::WIDTH * 0.8,
194 ellipsise => 0, 213 ellipsise => 0,
195 text => $prompt; 214 text => $prompt;
196 215
197 if ($flags & CS_QUERY_YESNO) { 216 if ($flags & CS_QUERY_YESNO) {
198 push @dialog, my $hbox = new CFPlus::UI::HBox; 217 push @dialog, my $hbox = new CFPlus::UI::HBox;
215 ); 234 );
216 235
217 $dialog->grab_focus; 236 $dialog->grab_focus;
218 237
219 } elsif ($flags & CS_QUERY_SINGLECHAR) { 238 } elsif ($flags & CS_QUERY_SINGLECHAR) {
220 $dialog->{tooltip} = "#charcreation_focus";
221
222 if ($prompt =~ /Now choose a character|Press any key for the next race/i) { 239 if ($prompt =~ /Now choose a character|Press any key for the next race/i) {
223 $MESSAGE_WINDOW->show; 240 $dialog->{tooltip} = "#charcreation_focus";
224 241
225 unshift @dialog, new CFPlus::UI::Label 242 unshift @dialog, new CFPlus::UI::Label
226 max_w => $::WIDTH * 0.4, 243 max_w => $::WIDTH * 0.8,
227 ellipsise => 0, 244 ellipsise => 0,
228 markup => "\nOr use your keyboard and the text entry below:\n"; 245 markup => "\nOr use your keyboard and the text entry below:\n";
229 246
230 unshift @dialog, my $table = new CFPlus::UI::Table; 247 unshift @dialog, my $table = new CFPlus::UI::Table;
231 248
243 $conn->send ("reply d"); 260 $conn->send ("reply d");
244 destroy_query_dialog $conn; 261 destroy_query_dialog $conn;
245 0 262 0
246 }, 263 },
247 ); 264 );
265
266 if ($conn->{chargen_race_description}) {
267 unshift @dialog, new CFPlus::UI::Label
268 max_w => $::WIDTH * 0.8,
269 ellipsise => 0,
270 markup => "<span foreground='#ccccff'>$conn->{chargen_race_description}</span>",
271 ;
272 }
273
274 unshift @dialog, new CFPlus::UI::Face
275 face => $conn->{player}{face},
276 bg => [.2, .2, .2, 1],
277 min_w => 64,
278 min_h => 64,
279 ;
280
281 if ($conn->{chargen_race_title}) {
282 unshift @dialog, new CFPlus::UI::Label
283 allign => 1,
284 ellipsise => 0,
285 markup => "<span foreground='#ccccff' size='large'>Race: $conn->{chargen_race_title}</span>",
286 ;
287 }
248 288
249 unshift @dialog, new CFPlus::UI::Label 289 unshift @dialog, new CFPlus::UI::Label
250 max_w => $::WIDTH * 0.4, 290 max_w => $::WIDTH * 0.4,
251 ellipsise => 0, 291 ellipsise => 0,
252 markup => (CFPlus::Pod::section_label ui => "chargen_race"), 292 markup => (CFPlus::Pod::section_label ui => "chargen_race"),
401 statusbox => $STATUSBOX, 441 statusbox => $STATUSBOX,
402 map => $MAP, 442 map => $MAP,
403 mapmap => $MAPMAP, 443 mapmap => $MAPMAP,
404 query => \&server_query, 444 query => \&server_query,
405 445
446 setup_req => {
447 smoothing => $CFG->{map_smoothing}*1,
448 },
449
406 sound_play => sub { 450 sound_play => sub {
407 my ($x, $y, $soundnum, $type) = @_; 451 my ($x, $y, $soundnum, $type) = @_;
408 452
409 $SDL_MIXER 453 $SDL_MIXER
410 or return; 454 or return;
447sub graphics_setup { 491sub graphics_setup {
448 my $vbox = new CFPlus::UI::VBox; 492 my $vbox = new CFPlus::UI::VBox;
449 493
450 $vbox->add (my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 1]); 494 $vbox->add (my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 1]);
451 495
496 my $row = 0;
497
498 $table->add (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "OpenGL Info");
499 $table->add (1, $row++, new CFPlus::UI::Label valign => 0, fontsize => 0.8, text => CFPlus::OpenGL::gl_vendor . ", " . CFPlus::OpenGL::gl_version,
500 can_events => 1,
501 tooltip => "<tt><span size='8192'>" . (CFPlus::OpenGL::gl_extensions) . "</span></tt>");
502
452 $table->add (0, 0, new CFPlus::UI::Label valign => 0, align => 1, text => "Video Mode"); 503 $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); 504 $table->add (1, $row++, my $hbox = new CFPlus::UI::HBox);
454 505
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]); 506 $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"); 507 $hbox->add (my $mode_label = new CFPlus::UI::Label align => 0, valign => 0, height => 0.8, template => "9999x9999");
457 508
458 $mode_slider->connect (changed => sub { 509 $mode_slider->connect (changed => sub {
460 511
461 $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value; 512 $CFG->{sdl_mode} = $self->{range}[0] = $value = int $value;
462 $mode_label->set_text (sprintf "%dx%d", @{$SDL_MODES[$value]}); 513 $mode_label->set_text (sprintf "%dx%d", @{$SDL_MODES[$value]});
463 }); 514 });
464 $mode_slider->emit (changed => $mode_slider->{range}[0]); 515 $mode_slider->emit (changed => $mode_slider->{range}[0]);
465
466 my $row = 1;
467 516
468 $table->add (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fullscreen"); 517 $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 518 $table->add (1, $row++, $FULLSCREEN_ENABLE = new CFPlus::UI::CheckBox
470 state => $CFG->{fullscreen}, 519 state => $CFG->{fullscreen},
471 tooltip => "Bring the client into fullscreen mode.", 520 tooltip => "Bring the client into fullscreen mode.",
477 state => $CFG->{fast}, 526 state => $CFG->{fast},
478 tooltip => "Lower the visual quality considerably to speed up rendering.", 527 tooltip => "Lower the visual quality considerably to speed up rendering.",
479 on_changed => sub { my ($self, $value) = @_; $CFG->{fast} = $value; 0 } 528 on_changed => sub { my ($self, $value) = @_; $CFG->{fast} = $value; 0 }
480 ); 529 );
481 530
531 $table->add (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "GUI Fontsize");
532 $table->add (1, $row++, new CFPlus::UI::Slider
533 range => [$CFG->{gui_fontsize}, 0.5, 2, 0, 0.1],
534 tooltip => "The base font size used by most GUI elements that do not have their own setting.",
535 on_changed => sub { $CFG->{gui_fontsize} = $_[1]; 0 },
536 );
537
538 $table->add (1, $row++, new CFPlus::UI::Button
539 expand => 1, align => 0, text => "Apply",
540 tooltip => "Apply the video settings above.",
541 on_activate => sub {
542 video_shutdown ();
543 video_init ();
544 0
545 }
546 );
547
482 $table->add (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Map Scale"); 548 $table->add (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Map Scale");
483 $table->add (1, $row++, new CFPlus::UI::Slider 549 $table->add (1, $row++, new CFPlus::UI::Slider
484 range => [(log $CFG->{map_scale}) / (log 2), -3, 1, 0, 1], 550 range => [(log $CFG->{map_scale}) / (log 2), -3, 1, 0, 1],
485 tooltip => "Enlarge or shrink the displayed map. Changes are instant.", 551 tooltip => "Enlarge or shrink the displayed map. Changes are instant.",
486 on_changed => sub { my ($self, $value) = @_; $CFG->{map_scale} = 2 ** $value; 0 } 552 on_changed => sub { my ($self, $value) = @_; $CFG->{map_scale} = 2 ** $value; 0 }
553 );
554
555 $table->add (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Smoothing");
556 $table->add (1, $row++, new CFPlus::UI::CheckBox
557 state => $CFG->{map_smoothing},
558 tooltip => "<b>Map Smoothing</b> tries to make tile borders less square. "
559 . "This increases load on the graphics subsystem and works only with 2.x servers. "
560 . "Changes take effect at next connection only.",
561 on_changed => sub { my ($self, $value) = @_; $CFG->{map_smoothing} = $value; 0 }
487 ); 562 );
488 563
489 $table->add (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fog of War"); 564 $table->add (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Fog of War");
490 $table->add (1, $row++, new CFPlus::UI::CheckBox 565 $table->add (1, $row++, new CFPlus::UI::CheckBox
491 state => $CFG->{fow_enable}, 566 state => $CFG->{fow_enable},
510 status "Fog of War smoothing requires OpenGL 1.2 or higher" if $CFPlus::OpenGL::GL_VERSION < 1.2; 585 status "Fog of War smoothing requires OpenGL 1.2 or higher" if $CFPlus::OpenGL::GL_VERSION < 1.2;
511 0 586 0
512 } 587 }
513 ); 588 );
514 589
515 $table->add (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "GUI Fontsize");
516 $table->add (1, $row++, new CFPlus::UI::Slider
517 range => [$CFG->{gui_fontsize}, 0.5, 2, 0, 0.1],
518 tooltip => "The base font size used by most GUI elements that do not have their own setting.",
519 on_changed => sub { $CFG->{gui_fontsize} = $_[1]; 0 },
520 );
521
522 $table->add (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Message Fontsize"); 590 $table->add (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Message Fontsize");
523 $table->add (1, $row++, new CFPlus::UI::Slider 591 $table->add (1, $row++, new CFPlus::UI::Slider
524 range => [$CFG->{log_fontsize}, 0.5, 2, 0, 0.1], 592 range => [$CFG->{log_fontsize}, 0.5, 2, 0, 0.1],
525 tooltip => "The font size used by the <b>message/server log</b> window only. Changes are instant.", 593 tooltip => "The font size used by the <b>message/server log</b> window only. Changes are instant.",
526 on_changed => sub { $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = $_[1]); 0 }, 594 on_changed => sub { $LOGVIEW->set_fontsize ($CFG->{log_fontsize} = $_[1]); 0 },
542 range => [$CFG->{gauge_size}, 0.2, 0.8], 610 range => [$CFG->{gauge_size}, 0.2, 0.8],
543 tooltip => "Adjust the size of the stats gauges at the bottom right. Changes are instant.", 611 tooltip => "Adjust the size of the stats gauges at the bottom right. Changes are instant.",
544 on_changed => sub { 612 on_changed => sub {
545 $CFG->{gauge_size} = $_[1]; 613 $CFG->{gauge_size} = $_[1];
546 $GAUGES->{win}->set_size ($WIDTH, int $HEIGHT * $CFG->{gauge_size}); 614 $GAUGES->{win}->set_size ($WIDTH, int $HEIGHT * $CFG->{gauge_size});
547 0
548 }
549 );
550
551 $table->add (1, $row++, new CFPlus::UI::Button
552 expand => 1, align => 0, text => "Apply",
553 tooltip => "Apply the video settings",
554 on_activate => sub {
555 video_shutdown ();
556 video_init ();
557 0 615 0
558 } 616 }
559 ); 617 );
560 618
561 $vbox 619 $vbox
887 for 0 .. $#col; 945 for 0 .. $#col;
888 946
889 my @align = qw(1 0 1 1 -1); 947 my @align = qw(1 0 1 1 -1);
890 948
891 my $y = 0; 949 my $y = 0;
892 for my $m (
893 sort {
894 $b->{version} <=> $a->{version}
895 or $b->{users} <=> $a->{users}
896 }
897 @{ $msg->{servers} } 950 for my $m (@{ $msg->{servers} }) {
898 ) {
899 my ($ip, $last, $host, $users, $version, $desc, $ibytes, $obytes, $uptime) = 951 my ($ip, $last, $host, $users, $version, $desc, $ibytes, $obytes, $uptime, $highlight) =
900 @$m{qw(ip age hostname users version description ibytes obytes uptime)}; 952 @$m{qw(ip age hostname users version description ibytes obytes uptime highlight)};
901 953
902 for ($desc) { 954 for ($desc) {
903 s/<br>/\n/gi; 955 s/<br>/\n/gi;
904 s/<li>/\n· /gi; 956 s/<li>/\n· /gi;
905 s/<.*?>//sgi; 957 s/<.*?>//sgi;
935 max_w => $::WIDTH * 0.4, 987 max_w => $::WIDTH * 0.4,
936 ellipsise => 0, 988 ellipsise => 0,
937 align => $align[$_], 989 align => $align[$_],
938 text => $m->[$_], 990 text => $m->[$_],
939 tooltip => $tip[$_], 991 tooltip => $tip[$_],
940 fg => ($m->[3] =~ /\+$/ ? [1, 1, 1] : [.7, .7, .7]), 992 fg => ($highlight ? [1, 1, 1] : [.7, .7, .7]),
941 can_hover => 1, 993 can_hover => 1,
942 can_events => 1, 994 can_events => 1,
943 fontsize => 0.8) 995 fontsize => 0.8)
944 for 0 .. $#$m; 996 for 0 .. $#$m;
945 } 997 }
1046 . "so only set it if you really need to prefetch images. " 1098 . "so only set it if you really need to prefetch images. "
1047 . "This option can be set and unset any time.", 1099 . "This option can be set and unset any time.",
1048 on_changed => sub { $CFG->{face_prefetch} = $_[1]; 0 }, 1100 on_changed => sub { $CFG->{face_prefetch} = $_[1]; 0 },
1049 ); 1101 );
1050 1102
1051 $table->add (0, 9, new CFPlus::UI::Label valign => 0, align => 1, text => "Output-Count"); 1103 $table->add (0, 9, new CFPlus::UI::Label valign => 0, align => 1, text => "Output-Rate");
1052 $table->add (1, 9, new CFPlus::UI::Entry 1104 $table->add (1, 9, new CFPlus::UI::Entry
1105 text => $CFG->{output_rate},
1106 tooltip => "The approximate bandwidth in bytes per second that the server should not exceed "
1107 . "when sending images, to ensure interactiveness. When 0 or unset, the server "
1108 . "default will be used, which is usually around 100kb/s.",
1109 on_changed => sub { $CFG->{output_rate} = $_[1]; 0 },
1110 );
1111
1112 $table->add (0, 10, new CFPlus::UI::Label valign => 0, align => 1, text => "Output-Count");
1113 $table->add (1, 10, new CFPlus::UI::Entry
1053 text => $CFG->{output_count}, 1114 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.", 1115 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 }, 1116 on_changed => sub { $CFG->{output_count} = $_[1]; 0 },
1056 ); 1117 );
1057 1118
1058 $table->add (0, 10, new CFPlus::UI::Label valign => 0, align => 1, text => "Output-Sync"); 1119 $table->add (0, 11, new CFPlus::UI::Label valign => 0, align => 1, text => "Output-Sync");
1059 $table->add (1, 10, new CFPlus::UI::Entry 1120 $table->add (1, 11, new CFPlus::UI::Entry
1060 text => $CFG->{output_sync}, 1121 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.", 1122 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 }, 1123 on_changed => sub { $CFG->{output_sync} = $_[1]; 0 },
1063 ); 1124 );
1064 1125
1065 $table->add (1, 11, $LOGIN_BUTTON = new CFPlus::UI::Button 1126 $table->add (1, 12, $LOGIN_BUTTON = new CFPlus::UI::Button
1066 expand => 1, 1127 expand => 1,
1067 align => 0, 1128 align => 0,
1068 text => "Login", 1129 text => "Login",
1069 on_activate => sub { 1130 on_activate => sub {
1070 $CONN ? stop_game 1131 $CONN ? stop_game
1071 : start_game; 1132 : start_game;
1072 0 1133 0
1073 }, 1134 },
1074 ); 1135 );
1075 1136
1137 $vbox->add (new CFPlus::UI::FancyFrame
1138 label => "Server Info",
1139 child => ($SERVER_INFO = new CFPlus::UI::Label ellipsise => 0),
1140 );
1141
1142 $vbox
1143}
1144
1145sub client_setup {
1146 my $table = new CFPlus::UI::Table expand => 1, col_expand => [0, 1];
1147
1148 my $row = 0;
1149
1076 $table->add (0, 12, new CFPlus::UI::Label valign => 0, align => 1, text => "Chat Command"); 1150 $table->add (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Chat Command");
1077 $table->add (1, 12, my $saycmd = new CFPlus::UI::Entry 1151 $table->add (1, $row++, my $saycmd = new CFPlus::UI::Entry
1078 text => $CFG->{say_command}, 1152 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. " 1153 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. " 1154 . "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.", 1155 . "But you could also set it to <b>tell <i>playername</i></b> to only chat with that user.",
1082 on_changed => sub { 1156 on_changed => sub {
1083 my ($self, $value) = @_; 1157 my ($self, $value) = @_;
1084 $CFG->{say_command} = $value; 1158 $CFG->{say_command} = $value;
1085 0 1159 0
1086 } 1160 }
1087 ); 1161 );
1088 1162
1089 $table->add (0, 13, new CFPlus::UI::Label valign => 0, align => 1, text => "Tip of the day"); 1163 $table->add (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Tip of the day");
1090 $table->add (1, 13, my $saycmd = new CFPlus::UI::CheckBox 1164 $table->add (1, $row++, new CFPlus::UI::CheckBox
1091 state => $CFG->{show_tips}, 1165 state => $CFG->{show_tips},
1092 tooltip => "Show the <b>Tip of the day</b> window at startup?", 1166 tooltip => "Show the <b>Tip of the day</b> window at startup?",
1093 on_changed => sub { 1167 on_changed => sub {
1094 my ($self, $value) = @_; 1168 my ($self, $value) = @_;
1095 $CFG->{show_tips} = $value; 1169 $CFG->{show_tips} = $value;
1096 0 1170 0
1097 } 1171 }
1098 ); 1172 );
1099 1173
1100 $vbox->add (new CFPlus::UI::FancyFrame 1174 $table->add (0, $row, new CFPlus::UI::Label valign => 0, align => 1, text => "Messages Window Size");
1101 label => "Server Info", 1175 $table->add (1, $row++, my $saycmd = new CFPlus::UI::Entry
1102 child => ($SERVER_INFO = new CFPlus::UI::Label ellipsise => 0), 1176 text => $CFG->{logview_max_par},
1177 tooltip => "This is maximum number of messages remembered in the <b>Messages</b> window. If the server "
1178 . "sends more messages than this number, older messages get removed to save memory and "
1179 . "computing time. A value of <b>0</b> disables this feature, but that is not recommended.",
1180 on_changed => sub {
1181 my ($self, $value) = @_;
1182 $LOGVIEW->{max_par} = $CFG->{logview_max_par} = $value*1;
1183 0
1184 },
1103 ); 1185 );
1104 1186
1105 $vbox 1187 $table
1106} 1188}
1107 1189
1108sub message_window { 1190sub message_window {
1109 my $window = new CFPlus::UI::Toplevel 1191 my $window = new CFPlus::UI::Toplevel
1110 name => "message_window", 1192 name => "message_window",
1547 1629
1548sub show_tip_of_the_day { 1630sub show_tip_of_the_day {
1549 # find all tips 1631 # find all tips
1550 my @tod = CFPlus::Pod::find tip_of_the_day => "*"; 1632 my @tod = CFPlus::Pod::find tip_of_the_day => "*";
1551 1633
1552 my $todindex = $CFPlus::DB_STATE->get ("tip_of_the_day"); 1634 CFPlus::DB::get state => "tip_of_the_day", sub {
1635 my ($todindex) = @_;
1553 $todindex = 0 if $todindex >= @tod; 1636 $todindex = 0 if $todindex >= @tod;
1554 $CFPlus::DB_STATE->put (tip_of_the_day => $todindex + 1); 1637 CFPlus::DB::put state => tip_of_the_day => $todindex + 1, sub { };
1555 1638
1556 # create dialog 1639 # create dialog
1557 my $dialog; 1640 my $dialog;
1558 1641
1559 my $close = sub { 1642 my $close = sub {
1560 $dialog->destroy; 1643 $dialog->destroy;
1644 };
1645
1646 $dialog = new CFPlus::UI::Toplevel
1647 x => "center",
1648 y => "center",
1649 z => 3,
1650 name => 'tip_of_the_day',
1651 force_w => int $WIDTH * 4/9,
1652 force_h => int $WIDTH * 2/9,
1653 title => "Tip of the day #" . (1 + $todindex),
1654 child => my $vbox = new CFPlus::UI::VBox,
1655 has_close_button => 1,
1656 on_delete => $close,
1657 ;
1658
1659 $vbox->add (my $viewer = new CFPlus::UI::TextScroller
1660 expand => 1, fontsize => 0.8, padding_x => 4, padding_y => 4);
1661 $viewer->add_paragraph (CFPlus::Pod::as_paragraphs CFPlus::Pod::section_of $tod[$todindex]);
1662
1663 $vbox->add (my $table = new CFPlus::UI::Table col_expand => [0, 1]);
1664
1665 $table->add (0, 0, new CFPlus::UI::Button
1666 text => "Close",
1667 tooltip => "Close the tip of the day window. To never see it again, disable the tip of the day in the <b>Server Setup</b>.",
1668 on_activate => $close,
1669 );
1670
1671 $table->add (2, 0, new CFPlus::UI::Button
1672 text => "Next",
1673 tooltip => "Show the next <b>Tip of the day</b>.",
1674 on_activate => sub {
1675 $close->();
1676 &show_tip_of_the_day;
1677 },
1678 );
1679
1680 $dialog->show;
1561 }; 1681 };
1562
1563 $dialog = new CFPlus::UI::Toplevel
1564 x => "center",
1565 y => "center",
1566 z => 3,
1567 name => 'tip_of_the_day',
1568 force_w => int $WIDTH * 4/9,
1569 force_h => int $WIDTH * 2/9,
1570 title => "Tip of the day #" . (1 + $todindex),
1571 child => my $vbox = new CFPlus::UI::VBox,
1572 has_close_button => 1,
1573 on_delete => $close,
1574 ;
1575
1576 $vbox->add (my $viewer = new CFPlus::UI::TextScroller
1577 expand => 1, fontsize => 0.8, padding_x => 4, padding_y => 4);
1578 $viewer->add_paragraph (CFPlus::Pod::as_paragraphs CFPlus::Pod::section_of $tod[$todindex]);
1579
1580 $vbox->add (my $table = new CFPlus::UI::Table col_expand => [0, 1]);
1581
1582 $table->add (0, 0, new CFPlus::UI::Button
1583 text => "Close",
1584 tooltip => "Close the tip of the day window. To never see it again, disable the tip of the day in the <b>Server Setup</b>.",
1585 on_activate => $close,
1586 );
1587
1588 $table->add (2, 0, new CFPlus::UI::Button
1589 text => "Next",
1590 tooltip => "Show the next <b>Tip of the day</b>.",
1591 on_activate => sub {
1592 $close->();
1593 &show_tip_of_the_day;
1594 },
1595 );
1596
1597 $dialog->show;
1598} 1682}
1599 1683
1600sub sdl_init { 1684sub sdl_init {
1601 CFPlus::SDL_Init 1685 CFPlus::SDL_Init
1602 and die "SDL::Init failed!\n"; 1686 and die "SDL::Init failed!\n";
1682 font => $FONT_FIXED, 1766 font => $FONT_FIXED,
1683 fontsize => $::CFG->{log_fontsize}, 1767 fontsize => $::CFG->{log_fontsize},
1684 indent => -4, 1768 indent => -4,
1685 can_hover => 1, 1769 can_hover => 1,
1686 can_events => 1, 1770 can_events => 1,
1771 max_par => $CFG->{logview_max_par},
1687 tooltip => "<b>Server Log</b>. This text viewer contains all the messages sent by the server.", 1772 tooltip => "<b>Server Log</b>. This text viewer contains all recent messages sent by the server.",
1688 ; 1773 ;
1689 1774
1690 $SETUP_DIALOG = new CFPlus::UI::Toplevel 1775 $SETUP_DIALOG = new CFPlus::UI::Toplevel
1691 title => "Setup", 1776 title => "Setup",
1692 name => "setup_dialog", 1777 name => "setup_dialog",
1703 $SETUP_DIALOG->add ($SETUP_NOTEBOOK = new CFPlus::UI::Notebook expand => 1, debug => 1, 1788 $SETUP_DIALOG->add ($SETUP_NOTEBOOK = new CFPlus::UI::Notebook expand => 1, debug => 1,
1704 filter => new CFPlus::UI::ScrolledWindow expand => 1, scroll_y => 1); 1789 filter => new CFPlus::UI::ScrolledWindow expand => 1, scroll_y => 1);
1705 1790
1706 $SETUP_NOTEBOOK->add (Server => $SETUP_SERVER = server_setup, 1791 $SETUP_NOTEBOOK->add (Server => $SETUP_SERVER = server_setup,
1707 "Configure the server to play on, your username, password and other server-related options."); 1792 "Configure the server to play on, your username, password and other server-related options.");
1793 $SETUP_NOTEBOOK->add (Client => client_setup,
1794 "Configure various client-specific settings.");
1708 $SETUP_NOTEBOOK->add (Pickup => autopickup_setup, 1795 $SETUP_NOTEBOOK->add (Pickup => autopickup_setup,
1709 "Configure autopickup settings, i.e. which items you will pick up automatically when walking (or running) over them."); 1796 "Configure autopickup settings, i.e. which items you will pick up automatically when walking (or running) over them.");
1710 $SETUP_NOTEBOOK->add (Graphics => graphics_setup, 1797 $SETUP_NOTEBOOK->add (Graphics => graphics_setup,
1711 "Configure the video mode, performance, fonts and other graphical aspects of the game."); 1798 "Configure the video mode, performance, fonts and other graphical aspects of the game.");
1712 $SETUP_NOTEBOOK->add (Audio => audio_setup, 1799 $SETUP_NOTEBOOK->add (Audio => audio_setup,
1770} 1857}
1771 1858
1772sub setup_build_button { 1859sub setup_build_button {
1773 my ($enabled) = @_; 1860 my ($enabled) = @_;
1774 if ($enabled) { 1861 if ($enabled) {
1862 $BUILD_BUTTON->hide if $BUILD_BUTTON;
1775 $BUILD_BUTTON ||= new CFPlus::UI::Button 1863 $BUILD_BUTTON ||= new CFPlus::UI::Button
1776 text => "Build", 1864 text => "Build",
1777 tooltip => "Opens the ingame builder", 1865 tooltip => "Opens the ingame builder",
1778 on_activate => sub { 1866 on_activate => sub {
1779 if ($CONN) { 1867 if ($CONN) {
2012 if $CONN; 2100 if $CONN;
2013}); 2101});
2014 2102
2015%SDL_CB = ( 2103%SDL_CB = (
2016 CFPlus::SDL_QUIT => sub { 2104 CFPlus::SDL_QUIT => sub {
2017 Event::unloop -1; 2105 exit;
2018 }, 2106 },
2019 CFPlus::SDL_VIDEORESIZE => sub { 2107 CFPlus::SDL_VIDEORESIZE => sub {
2020 }, 2108 },
2021 CFPlus::SDL_VIDEOEXPOSE => sub { 2109 CFPlus::SDL_VIDEOEXPOSE => sub {
2022 CFPlus::UI::full_refresh; 2110 CFPlus::UI::full_refresh;
2055 2143
2056$SIG{INT} = $SIG{TERM} = sub { exit }; 2144$SIG{INT} = $SIG{TERM} = sub { exit };
2057 2145
2058{ 2146{
2059 CFPlus::read_cfg "$Crossfire::VARDIR/cfplusrc"; 2147 CFPlus::read_cfg "$Crossfire::VARDIR/cfplusrc";
2148 CFPlus::DB::Server::run;
2149
2060 CFPlus::UI::set_layout ($::CFG->{layout}); 2150 CFPlus::UI::set_layout ($::CFG->{layout});
2061 2151
2062 my %DEF_CFG = ( 2152 my %DEF_CFG = (
2063 sdl_mode => 0, 2153 sdl_mode => 0,
2064 width => 640, 2154 width => 640,
2065 height => 480, 2155 height => 480,
2066 fullscreen => 0, 2156 fullscreen => 0,
2067 fast => 0, 2157 fast => 0,
2068 map_scale => 1, 2158 map_scale => 1,
2069 fow_enable => 1, 2159 fow_enable => 1,
2070 fow_intensity => 0.45, 2160 fow_intensity => 0.45,
2071 fow_smooth => 0, 2161 fow_smooth => 0,
2162 map_smoothing => 1,
2072 gui_fontsize => 1, 2163 gui_fontsize => 1,
2073 log_fontsize => 0.7, 2164 log_fontsize => 0.7,
2074 gauge_fontsize => 1, 2165 gauge_fontsize => 1,
2075 gauge_size => 0.35, 2166 gauge_size => 0.35,
2076 stat_fontsize => 0.7, 2167 stat_fontsize => 0.7,
2077 mapsize => 100, 2168 mapsize => 100,
2078 say_command => 'chat', 2169 say_command => 'chat',
2079 audio_enable => 1, 2170 audio_enable => 1,
2080 bgm_enable => 1, 2171 bgm_enable => 1,
2081 bgm_volume => 0.25, 2172 bgm_volume => 0.25,
2082 face_prefetch => 0, 2173 face_prefetch => 0,
2083 output_sync => 1, 2174 output_sync => 1,
2084 output_count => 1, 2175 output_count => 1,
2176 output_rate => "",
2085 pickup => 0, 2177 pickup => 0,
2086 inv_sort => "mtime", 2178 inv_sort => "mtime",
2087 default => "profile", # default profile 2179 default => "profile", # default profile
2088 show_tips => 1, 2180 show_tips => 1,
2181 logview_max_par => 1000,
2089 ); 2182 );
2090 2183
2091 while (my ($k, $v) = each %DEF_CFG) { 2184 while (my ($k, $v) = each %DEF_CFG) {
2092 $CFG->{$k} = $v unless exists $CFG->{$k}; 2185 $CFG->{$k} = $v unless exists $CFG->{$k};
2093 } 2186 }
2162 2255
2163Event::loop; 2256Event::loop;
2164#CFPlus::SDL_Quit; 2257#CFPlus::SDL_Quit;
2165#CFPlus::_exit 0; 2258#CFPlus::_exit 0;
2166 2259
2260END {
2167END { CFPlus::SDL_Quit } 2261 CFPlus::SDL_Quit;
2262 CFPlus::DB::Server::stop;
2263}
2168 2264
2169=head1 NAME 2265=head1 NAME
2170 2266
2171cfplus - A Crossfire+ and Crossfire game client 2267cfplus - A Crossfire+ and Crossfire game client
2172 2268

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines